@wyxos/vibe 1.6.11 → 1.6.13

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 J, defineComponent as Le, ref as k, computed as te, onMounted as Se, onUnmounted as Ne, watch as He, createElementBlock as B, openBlock as D, renderSlot as $e, createElementVNode as S, createCommentVNode as X, normalizeClass as Y, toDisplayString as ue, withModifiers as ze, normalizeStyle as Re, createVNode as Te, TransitionGroup as _e, withCtx as Ce, Fragment as qe, renderList as Ve, mergeProps as Ge, unref as Ue } from "vue";
2
- let fe = null;
3
- function Xe() {
4
- if (fe != null) return fe;
5
- const e = document.createElement("div");
6
- e.style.visibility = "hidden", e.style.overflow = "scroll", e.style.msOverflowStyle = "scrollbar", e.style.width = "100px", e.style.height = "100px", document.body.appendChild(e);
7
- const r = document.createElement("div");
8
- r.style.width = "100%", e.appendChild(r);
9
- const l = e.offsetWidth - r.offsetWidth;
10
- return document.body.removeChild(e), fe = l, l;
1
+ import { nextTick as R, defineComponent as Je, ref as T, computed as J, onMounted as Ke, onUnmounted as Qe, watch as ne, createElementBlock as O, openBlock as B, renderSlot as Le, createElementVNode as A, createCommentVNode as ae, normalizeClass as Z, toDisplayString as _e, withModifiers as dt, normalizeStyle as Te, Fragment as Ce, renderList as qe, createVNode as Ie, TransitionGroup as mt, withCtx as pt, mergeProps as ht, unref as gt } from "vue";
2
+ let Ee = null;
3
+ function yt() {
4
+ if (Ee != null) return Ee;
5
+ const t = document.createElement("div");
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 i = document.createElement("div");
8
+ i.style.width = "100%", t.appendChild(i);
9
+ const u = t.offsetWidth - i.offsetWidth;
10
+ return document.body.removeChild(t), Ee = u, u;
11
11
  }
12
- function Ye(e, r, l, s = {}) {
12
+ function wt(t, i, u, l = {}) {
13
13
  const {
14
- gutterX: w = 0,
15
- gutterY: v = 0,
14
+ gutterX: I = 0,
15
+ gutterY: h = 0,
16
16
  header: a = 0,
17
- footer: n = 0,
18
- paddingLeft: h = 0,
19
- paddingRight: c = 0,
20
- sizes: f = {
17
+ footer: c = 0,
18
+ paddingLeft: w = 0,
19
+ paddingRight: k = 0,
20
+ sizes: v = {
21
21
  base: 1,
22
22
  sm: 2,
23
23
  md: 3,
@@ -25,307 +25,307 @@ function Ye(e, r, l, s = {}) {
25
25
  xl: 5,
26
26
  "2xl": 6
27
27
  },
28
- placement: T = "masonry"
29
- } = s;
30
- let m = 0, d = 0;
28
+ placement: H = "masonry"
29
+ } = l;
30
+ let N = 0, b = 0;
31
31
  try {
32
- if (r && r.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
- const P = window.getComputedStyle(r);
34
- m = parseFloat(P.paddingLeft) || 0, d = parseFloat(P.paddingRight) || 0;
32
+ if (i && i.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
+ const y = window.getComputedStyle(i);
34
+ N = parseFloat(y.paddingLeft) || 0, b = parseFloat(y.paddingRight) || 0;
35
35
  }
36
36
  } catch {
37
37
  }
38
- const N = (h || 0) + m, z = (c || 0) + d, $ = r.offsetWidth - r.clientWidth, E = $ > 0 ? $ + 2 : Xe() + 2, i = r.offsetWidth - E - N - z, g = w * (l - 1), M = Math.floor((i - g) / l), I = e.map((P) => {
39
- const H = P.width, L = P.height;
40
- return Math.round(M * L / H) + n + a;
38
+ const P = (w || 0) + N, s = (k || 0) + b, $ = i.offsetWidth - i.clientWidth, f = $ > 0 ? $ + 2 : yt() + 2, o = i.offsetWidth - f - P - s, d = I * (u - 1), g = Math.floor((o - d) / u), E = t.map((y) => {
39
+ const W = y.width, S = y.height;
40
+ return Math.round(g * S / W) + c + a;
41
41
  });
42
- if (T === "sequential-balanced") {
43
- const P = I.length;
44
- if (P === 0) return [];
45
- const H = (x, F, R) => x + (F > 0 ? v : 0) + R;
46
- let L = Math.max(...I), _ = I.reduce((x, F) => x + F, 0) + v * Math.max(0, P - 1);
47
- const ae = (x) => {
48
- let F = 1, R = 0, q = 0;
49
- for (let O = 0; O < P; O++) {
50
- const U = I[O], V = H(R, q, U);
51
- if (V <= x)
52
- R = V, q++;
53
- else if (F++, R = U, q = 1, U > x || F > l) return !1;
42
+ if (H === "sequential-balanced") {
43
+ const y = E.length;
44
+ if (y === 0) return [];
45
+ const W = (M, F, _) => M + (F > 0 ? h : 0) + _;
46
+ let S = Math.max(...E), D = E.reduce((M, F) => M + F, 0) + h * Math.max(0, y - 1);
47
+ const le = (M) => {
48
+ let F = 1, _ = 0, Q = 0;
49
+ for (let C = 0; C < y; C++) {
50
+ const re = E[C], q = W(_, Q, re);
51
+ if (q <= M)
52
+ _ = q, Q++;
53
+ else if (F++, _ = re, Q = 1, re > M || F > u) return !1;
54
54
  }
55
- return F <= l;
55
+ return F <= u;
56
56
  };
57
- for (; L < _; ) {
58
- const x = Math.floor((L + _) / 2);
59
- ae(x) ? _ = x : L = x + 1;
57
+ for (; S < D; ) {
58
+ const M = Math.floor((S + D) / 2);
59
+ le(M) ? D = M : S = M + 1;
60
60
  }
61
- const ne = _, K = new Array(l).fill(0);
62
- let oe = l - 1, Q = 0, Z = 0;
63
- for (let x = P - 1; x >= 0; x--) {
64
- const F = I[x], R = x < oe;
65
- !(H(Q, Z, F) <= ne) || R ? (K[oe] = x + 1, oe--, Q = F, Z = 1) : (Q = H(Q, Z, F), Z++);
61
+ const oe = D, ee = new Array(u).fill(0);
62
+ let V = u - 1, U = 0, te = 0;
63
+ for (let M = y - 1; M >= 0; M--) {
64
+ const F = E[M], _ = M < V;
65
+ !(W(U, te, F) <= oe) || _ ? (ee[V] = M + 1, V--, U = F, te = 1) : (U = W(U, te, F), te++);
66
66
  }
67
- K[0] = 0;
68
- const C = [], re = new Array(l).fill(0);
69
- for (let x = 0; x < l; x++) {
70
- const F = K[x], R = x + 1 < l ? K[x + 1] : P, q = x * (M + w);
71
- for (let O = F; O < R; O++) {
72
- const V = {
73
- ...e[O],
74
- columnWidth: M,
67
+ ee[0] = 0;
68
+ const K = [], ue = new Array(u).fill(0);
69
+ for (let M = 0; M < u; M++) {
70
+ const F = ee[M], _ = M + 1 < u ? ee[M + 1] : y, Q = M * (g + I);
71
+ for (let C = F; C < _; C++) {
72
+ const q = {
73
+ ...t[C],
74
+ columnWidth: g,
75
75
  imageHeight: 0,
76
76
  columnHeight: 0,
77
77
  left: 0,
78
78
  top: 0
79
79
  };
80
- V.imageHeight = I[O] - (n + a), V.columnHeight = I[O], V.left = q, V.top = re[x], re[x] += V.columnHeight + (O + 1 < R ? v : 0), C.push(V);
80
+ q.imageHeight = E[C] - (c + a), q.columnHeight = E[C], q.left = Q, q.top = ue[M], ue[M] += q.columnHeight + (C + 1 < _ ? h : 0), K.push(q);
81
81
  }
82
82
  }
83
- return C;
83
+ return K;
84
84
  }
85
- const b = new Array(l).fill(0), A = [];
86
- for (let P = 0; P < e.length; P++) {
87
- const H = e[P], L = {
88
- ...H,
85
+ const m = new Array(u).fill(0), L = [];
86
+ for (let y = 0; y < t.length; y++) {
87
+ const W = t[y], S = {
88
+ ...W,
89
89
  columnWidth: 0,
90
90
  imageHeight: 0,
91
91
  columnHeight: 0,
92
92
  left: 0,
93
93
  top: 0
94
- }, _ = b.indexOf(Math.min(...b)), ae = H.width, ne = H.height;
95
- L.columnWidth = M, L.left = _ * (M + w), L.imageHeight = Math.round(M * ne / ae), L.columnHeight = L.imageHeight + n + a, L.top = b[_], b[_] += L.columnHeight + v, A.push(L);
94
+ }, D = m.indexOf(Math.min(...m)), le = W.width, oe = W.height;
95
+ S.columnWidth = g, S.left = D * (g + I), S.imageHeight = Math.round(g * oe / le), S.columnHeight = S.imageHeight + c + a, S.top = m[D], m[D] += S.columnHeight + h, L.push(S);
96
96
  }
97
- return A;
97
+ return L;
98
98
  }
99
- var Je = typeof global == "object" && global && global.Object === Object && global, Ke = typeof self == "object" && self && self.Object === Object && self, Ae = Je || Ke || Function("return this")(), ce = Ae.Symbol, Fe = Object.prototype, Qe = Fe.hasOwnProperty, Ze = Fe.toString, se = ce ? ce.toStringTag : void 0;
100
- function et(e) {
101
- var r = Qe.call(e, se), l = e[se];
99
+ var bt = typeof global == "object" && global && global.Object === Object && global, xt = typeof self == "object" && self && self.Object === Object && self, Ze = bt || xt || Function("return this")(), he = Ze.Symbol, et = Object.prototype, Mt = et.hasOwnProperty, Tt = et.toString, ve = he ? he.toStringTag : void 0;
100
+ function It(t) {
101
+ var i = Mt.call(t, ve), u = t[ve];
102
102
  try {
103
- e[se] = void 0;
104
- var s = !0;
103
+ t[ve] = void 0;
104
+ var l = !0;
105
105
  } catch {
106
106
  }
107
- var w = Ze.call(e);
108
- return s && (r ? e[se] = l : delete e[se]), w;
107
+ var I = Tt.call(t);
108
+ return l && (i ? t[ve] = u : delete t[ve]), I;
109
109
  }
110
- var tt = Object.prototype, at = tt.toString;
111
- function nt(e) {
112
- return at.call(e);
110
+ var Et = Object.prototype, kt = Et.toString;
111
+ function Lt(t) {
112
+ return kt.call(t);
113
113
  }
114
- var ot = "[object Null]", rt = "[object Undefined]", Me = ce ? ce.toStringTag : void 0;
115
- function lt(e) {
116
- return e == null ? e === void 0 ? rt : ot : Me && Me in Object(e) ? et(e) : nt(e);
114
+ var Pt = "[object Null]", St = "[object Undefined]", Ye = he ? he.toStringTag : void 0;
115
+ function $t(t) {
116
+ return t == null ? t === void 0 ? St : Pt : Ye && Ye in Object(t) ? It(t) : Lt(t);
117
117
  }
118
- function st(e) {
119
- return e != null && typeof e == "object";
118
+ function Ht(t) {
119
+ return t != null && typeof t == "object";
120
120
  }
121
- var it = "[object Symbol]";
122
- function ut(e) {
123
- return typeof e == "symbol" || st(e) && lt(e) == it;
121
+ var Nt = "[object Symbol]";
122
+ function Wt(t) {
123
+ return typeof t == "symbol" || Ht(t) && $t(t) == Nt;
124
124
  }
125
- var ct = /\s/;
126
- function ft(e) {
127
- for (var r = e.length; r-- && ct.test(e.charAt(r)); )
125
+ var Dt = /\s/;
126
+ function At(t) {
127
+ for (var i = t.length; i-- && Dt.test(t.charAt(i)); )
128
128
  ;
129
- return r;
129
+ return i;
130
130
  }
131
- var dt = /^\s+/;
132
- function vt(e) {
133
- return e && e.slice(0, ft(e) + 1).replace(dt, "");
131
+ var Ot = /^\s+/;
132
+ function Bt(t) {
133
+ return t && t.slice(0, At(t) + 1).replace(Ot, "");
134
134
  }
135
- function me(e) {
136
- var r = typeof e;
137
- return e != null && (r == "object" || r == "function");
135
+ function Pe(t) {
136
+ var i = typeof t;
137
+ return t != null && (i == "object" || i == "function");
138
138
  }
139
- var Ie = NaN, mt = /^[-+]0x[0-9a-f]+$/i, gt = /^0b[01]+$/i, pt = /^0o[0-7]+$/i, yt = parseInt;
140
- function Pe(e) {
141
- if (typeof e == "number")
142
- return e;
143
- if (ut(e))
144
- return Ie;
145
- if (me(e)) {
146
- var r = typeof e.valueOf == "function" ? e.valueOf() : e;
147
- e = me(r) ? r + "" : r;
139
+ var Ve = NaN, Ft = /^[-+]0x[0-9a-f]+$/i, zt = /^0b[01]+$/i, jt = /^0o[0-7]+$/i, Rt = parseInt;
140
+ function Ue(t) {
141
+ if (typeof t == "number")
142
+ return t;
143
+ if (Wt(t))
144
+ return Ve;
145
+ if (Pe(t)) {
146
+ var i = typeof t.valueOf == "function" ? t.valueOf() : t;
147
+ t = Pe(i) ? i + "" : i;
148
148
  }
149
- if (typeof e != "string")
150
- return e === 0 ? e : +e;
151
- e = vt(e);
152
- var l = gt.test(e);
153
- return l || pt.test(e) ? yt(e.slice(2), l ? 2 : 8) : mt.test(e) ? Ie : +e;
149
+ if (typeof t != "string")
150
+ return t === 0 ? t : +t;
151
+ t = Bt(t);
152
+ var u = zt.test(t);
153
+ return u || jt.test(t) ? Rt(t.slice(2), u ? 2 : 8) : Ft.test(t) ? Ve : +t;
154
154
  }
155
- var de = function() {
156
- return Ae.Date.now();
157
- }, ht = "Expected a function", bt = Math.max, xt = Math.min;
158
- function ke(e, r, l) {
159
- var s, w, v, a, n, h, c = 0, f = !1, T = !1, m = !0;
160
- if (typeof e != "function")
161
- throw new TypeError(ht);
162
- r = Pe(r) || 0, me(l) && (f = !!l.leading, T = "maxWait" in l, v = T ? bt(Pe(l.maxWait) || 0, r) : v, m = "trailing" in l ? !!l.trailing : m);
163
- function d(b) {
164
- var A = s, P = w;
165
- return s = w = void 0, c = b, a = e.apply(P, A), a;
155
+ var ke = function() {
156
+ return Ze.Date.now();
157
+ }, _t = "Expected a function", Ct = Math.max, qt = Math.min;
158
+ function Ge(t, i, u) {
159
+ var l, I, h, a, c, w, k = 0, v = !1, H = !1, N = !0;
160
+ if (typeof t != "function")
161
+ throw new TypeError(_t);
162
+ i = Ue(i) || 0, Pe(u) && (v = !!u.leading, H = "maxWait" in u, h = H ? Ct(Ue(u.maxWait) || 0, i) : h, N = "trailing" in u ? !!u.trailing : N);
163
+ function b(m) {
164
+ var L = l, y = I;
165
+ return l = I = void 0, k = m, a = t.apply(y, L), a;
166
166
  }
167
- function N(b) {
168
- return c = b, n = setTimeout(E, r), f ? d(b) : a;
167
+ function P(m) {
168
+ return k = m, c = setTimeout(f, i), v ? b(m) : a;
169
169
  }
170
- function z(b) {
171
- var A = b - h, P = b - c, H = r - A;
172
- return T ? xt(H, v - P) : H;
170
+ function s(m) {
171
+ var L = m - w, y = m - k, W = i - L;
172
+ return H ? qt(W, h - y) : W;
173
173
  }
174
- function $(b) {
175
- var A = b - h, P = b - c;
176
- return h === void 0 || A >= r || A < 0 || T && P >= v;
174
+ function $(m) {
175
+ var L = m - w, y = m - k;
176
+ return w === void 0 || L >= i || L < 0 || H && y >= h;
177
177
  }
178
- function E() {
179
- var b = de();
180
- if ($(b))
181
- return i(b);
182
- n = setTimeout(E, z(b));
178
+ function f() {
179
+ var m = ke();
180
+ if ($(m))
181
+ return o(m);
182
+ c = setTimeout(f, s(m));
183
183
  }
184
- function i(b) {
185
- return n = void 0, m && s ? d(b) : (s = w = void 0, a);
184
+ function o(m) {
185
+ return c = void 0, N && l ? b(m) : (l = I = void 0, a);
186
186
  }
187
- function g() {
188
- n !== void 0 && clearTimeout(n), c = 0, s = h = w = n = void 0;
187
+ function d() {
188
+ c !== void 0 && clearTimeout(c), k = 0, l = w = I = c = void 0;
189
189
  }
190
- function M() {
191
- return n === void 0 ? a : i(de());
190
+ function g() {
191
+ return c === void 0 ? a : o(ke());
192
192
  }
193
- function I() {
194
- var b = de(), A = $(b);
195
- if (s = arguments, w = this, h = b, A) {
196
- if (n === void 0)
197
- return N(h);
198
- if (T)
199
- return clearTimeout(n), n = setTimeout(E, r), d(h);
193
+ function E() {
194
+ var m = ke(), L = $(m);
195
+ if (l = arguments, I = this, w = m, L) {
196
+ if (c === void 0)
197
+ return P(w);
198
+ if (H)
199
+ return clearTimeout(c), c = setTimeout(f, i), b(w);
200
200
  }
201
- return n === void 0 && (n = setTimeout(E, r)), a;
201
+ return c === void 0 && (c = setTimeout(f, i)), a;
202
202
  }
203
- return I.cancel = g, I.flush = M, I;
203
+ return E.cancel = d, E.flush = g, E;
204
204
  }
205
- function ve(e) {
206
- const r = window.innerWidth, l = e.sizes;
207
- return r >= 1536 && l["2xl"] ? l["2xl"] : r >= 1280 && l.xl ? l.xl : r >= 1024 && l.lg ? l.lg : r >= 768 && l.md ? l.md : r >= 640 && l.sm ? l.sm : l.base;
205
+ function de(t, i) {
206
+ const u = i ?? (typeof window < "u" ? window.innerWidth : 1024), l = t.sizes;
207
+ return u >= 1536 && l["2xl"] ? l["2xl"] : u >= 1280 && l.xl ? l.xl : u >= 1024 && l.lg ? l.lg : u >= 768 && l.md ? l.md : u >= 640 && l.sm ? l.sm : l.base;
208
208
  }
209
- function wt(e) {
210
- return e.reduce((l, s) => Math.max(l, s.top + s.columnHeight), 0) + 500;
209
+ function Yt(t) {
210
+ return t.reduce((u, l) => Math.max(u, l.top + l.columnHeight), 0) + 500;
211
211
  }
212
- function Tt(e) {
212
+ function Vt(t) {
213
213
  return {
214
- transform: `translate3d(${e.left}px, ${e.top}px, 0)`,
214
+ transform: `translate3d(${t.left}px, ${t.top}px, 0)`,
215
215
  top: "0px",
216
216
  left: "0px",
217
- width: `${e.columnWidth}px`,
218
- height: `${e.columnHeight}px`
217
+ width: `${t.columnWidth}px`,
218
+ height: `${t.columnHeight}px`
219
219
  };
220
220
  }
221
- function Mt(e, r = 0) {
221
+ function Ut(t, i = 0) {
222
222
  return {
223
- style: Tt(e),
224
- "data-top": e.top,
225
- "data-left": e.left,
226
- "data-id": `${e.page}-${e.id}`,
227
- "data-index": r
223
+ style: Vt(t),
224
+ "data-top": t.top,
225
+ "data-left": t.left,
226
+ "data-id": `${t.page}-${t.id}`,
227
+ "data-index": i
228
228
  };
229
229
  }
230
- function ge(e, r) {
231
- if (!e.length || r <= 0)
232
- return new Array(Math.max(1, r)).fill(0);
233
- const s = Array.from(new Set(e.map((a) => a.left))).sort((a, n) => a - n).slice(0, r), w = /* @__PURE__ */ new Map();
234
- for (let a = 0; a < s.length; a++) w.set(s[a], a);
235
- const v = new Array(s.length).fill(0);
236
- for (const a of e) {
237
- const n = w.get(a.left);
238
- n != null && (v[n] = Math.max(v[n], a.top + a.columnHeight));
230
+ function Se(t, i) {
231
+ if (!t.length || i <= 0)
232
+ return new Array(Math.max(1, i)).fill(0);
233
+ const l = Array.from(new Set(t.map((a) => a.left))).sort((a, c) => a - c).slice(0, i), I = /* @__PURE__ */ new Map();
234
+ for (let a = 0; a < l.length; a++) I.set(l[a], a);
235
+ const h = new Array(l.length).fill(0);
236
+ for (const a of t) {
237
+ const c = I.get(a.left);
238
+ c != null && (h[c] = Math.max(h[c], a.top + a.columnHeight));
239
239
  }
240
- for (; v.length < r; ) v.push(0);
241
- return v;
240
+ for (; h.length < i; ) h.push(0);
241
+ return h;
242
242
  }
243
- function It(e, r) {
244
- function l(a, n) {
245
- const h = parseInt(a.dataset.left || "0", 10), c = parseInt(a.dataset.top || "0", 10), f = parseInt(a.dataset.index || "0", 10), T = Math.min(f * 20, 160), m = a.style.getPropertyValue("--masonry-opacity-delay");
246
- a.style.setProperty("--masonry-opacity-delay", `${T}ms`), requestAnimationFrame(() => {
247
- a.style.opacity = "1", a.style.transform = `translate3d(${h}px, ${c}px, 0) scale(1)`;
248
- const d = () => {
249
- m ? a.style.setProperty("--masonry-opacity-delay", m) : a.style.removeProperty("--masonry-opacity-delay"), a.removeEventListener("transitionend", d), n();
243
+ function Gt(t, i) {
244
+ function u(a, c) {
245
+ const w = parseInt(a.dataset.left || "0", 10), k = parseInt(a.dataset.top || "0", 10), v = parseInt(a.dataset.index || "0", 10), H = Math.min(v * 20, 160), N = a.style.getPropertyValue("--masonry-opacity-delay");
246
+ a.style.setProperty("--masonry-opacity-delay", `${H}ms`), requestAnimationFrame(() => {
247
+ a.style.opacity = "1", a.style.transform = `translate3d(${w}px, ${k}px, 0) scale(1)`;
248
+ const b = () => {
249
+ N ? a.style.setProperty("--masonry-opacity-delay", N) : a.style.removeProperty("--masonry-opacity-delay"), a.removeEventListener("transitionend", b), c();
250
250
  };
251
- a.addEventListener("transitionend", d);
251
+ a.addEventListener("transitionend", b);
252
252
  });
253
253
  }
254
- function s(a) {
255
- const n = parseInt(a.dataset.left || "0", 10), h = parseInt(a.dataset.top || "0", 10);
256
- a.style.opacity = "0", a.style.transform = `translate3d(${n}px, ${h + 10}px, 0) scale(0.985)`;
254
+ function l(a) {
255
+ const c = parseInt(a.dataset.left || "0", 10), w = parseInt(a.dataset.top || "0", 10);
256
+ a.style.opacity = "0", a.style.transform = `translate3d(${c}px, ${w + 10}px, 0) scale(0.985)`;
257
257
  }
258
- function w(a) {
259
- const n = parseInt(a.dataset.left || "0", 10), h = parseInt(a.dataset.top || "0", 10);
260
- a.style.transition = "none", a.style.opacity = "1", a.style.transform = `translate3d(${n}px, ${h}px, 0) scale(1)`, a.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
258
+ function I(a) {
259
+ const c = parseInt(a.dataset.left || "0", 10), w = parseInt(a.dataset.top || "0", 10);
260
+ a.style.transition = "none", a.style.opacity = "1", a.style.transform = `translate3d(${c}px, ${w}px, 0) scale(1)`, a.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
261
261
  a.style.transition = "";
262
262
  });
263
263
  }
264
- function v(a, n) {
265
- const h = parseInt(a.dataset.left || "0", 10), c = parseInt(a.dataset.top || "0", 10), f = typeof (r == null ? void 0 : r.leaveDurationMs) == "number" ? r.leaveDurationMs : NaN;
266
- let T = Number.isFinite(f) && f > 0 ? f : NaN;
267
- if (!Number.isFinite(T)) {
268
- const E = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", i = parseFloat(E);
269
- T = Number.isFinite(i) && i > 0 ? i : 200;
264
+ function h(a, c) {
265
+ const w = parseInt(a.dataset.left || "0", 10), k = parseInt(a.dataset.top || "0", 10), v = typeof (i == null ? void 0 : i.leaveDurationMs) == "number" ? i.leaveDurationMs : NaN;
266
+ let H = Number.isFinite(v) && v > 0 ? v : NaN;
267
+ if (!Number.isFinite(H)) {
268
+ const f = getComputedStyle(a).getPropertyValue("--masonry-leave-duration") || "", o = parseFloat(f);
269
+ H = Number.isFinite(o) && o > 0 ? o : 200;
270
270
  }
271
- const m = a.style.transitionDuration, d = () => {
272
- a.removeEventListener("transitionend", N), clearTimeout(z), a.style.transitionDuration = m || "";
273
- }, N = ($) => {
274
- (!$ || $.target === a) && (d(), n());
275
- }, z = setTimeout(() => {
276
- d(), n();
277
- }, T + 100);
271
+ const N = a.style.transitionDuration, b = () => {
272
+ a.removeEventListener("transitionend", P), clearTimeout(s), a.style.transitionDuration = N || "";
273
+ }, P = ($) => {
274
+ (!$ || $.target === a) && (b(), c());
275
+ }, s = setTimeout(() => {
276
+ b(), c();
277
+ }, H + 100);
278
278
  requestAnimationFrame(() => {
279
- a.style.transitionDuration = `${T}ms`, a.style.opacity = "0", a.style.transform = `translate3d(${h}px, ${c + 10}px, 0) scale(0.985)`, a.addEventListener("transitionend", N);
279
+ a.style.transitionDuration = `${H}ms`, a.style.opacity = "0", a.style.transform = `translate3d(${w}px, ${k + 10}px, 0) scale(0.985)`, a.addEventListener("transitionend", P);
280
280
  });
281
281
  }
282
282
  return {
283
- onEnter: l,
284
- onBeforeEnter: s,
285
- onBeforeLeave: w,
286
- onLeave: v
283
+ onEnter: u,
284
+ onBeforeEnter: l,
285
+ onBeforeLeave: I,
286
+ onLeave: h
287
287
  };
288
288
  }
289
- function Pt({
290
- container: e,
291
- masonry: r,
292
- columns: l,
293
- containerHeight: s,
294
- isLoading: w,
295
- pageSize: v,
289
+ function Xt({
290
+ container: t,
291
+ masonry: i,
292
+ columns: u,
293
+ containerHeight: l,
294
+ isLoading: I,
295
+ pageSize: h,
296
296
  refreshLayout: a,
297
- setItemsRaw: n,
298
- loadNext: h,
299
- loadThresholdPx: c
297
+ setItemsRaw: c,
298
+ loadNext: w,
299
+ loadThresholdPx: k
300
300
  }) {
301
- let f = 0;
302
- async function T(m) {
303
- if (!e.value) return;
304
- const d = m ?? ge(r.value, l.value), N = d.length ? Math.max(...d) : 0, z = e.value.scrollTop + e.value.clientHeight, $ = e.value.scrollTop > f + 1;
305
- f = e.value.scrollTop;
306
- const E = typeof c == "number" ? c : 200, i = E >= 0 ? Math.max(0, N - E) : Math.max(0, N + E);
307
- if (z >= i && $ && !w.value) {
308
- await h(), await J();
301
+ let v = 0;
302
+ async function H(N) {
303
+ if (!t.value) return;
304
+ const b = N ?? Se(i.value, u.value), P = b.length ? Math.max(...b) : 0, s = t.value.scrollTop + t.value.clientHeight, $ = t.value.scrollTop > v + 1;
305
+ v = t.value.scrollTop;
306
+ const f = typeof k == "number" ? k : 200, o = f >= 0 ? Math.max(0, P - f) : Math.max(0, P + f);
307
+ if (s >= o && $ && !I.value) {
308
+ await w(), await R();
309
309
  return;
310
310
  }
311
311
  }
312
312
  return {
313
- handleScroll: T
313
+ handleScroll: H
314
314
  };
315
315
  }
316
- const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 bg-white relative" }, Et = {
316
+ const Jt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:shadow-md transition-all duration-300 bg-white relative" }, Kt = {
317
317
  key: 0,
318
318
  class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-100 text-slate-400 text-sm p-4 text-center"
319
- }, Lt = {
319
+ }, Qt = {
320
320
  key: 1,
321
321
  class: "relative w-full h-full"
322
- }, St = ["src"], Nt = ["src"], Ht = { class: "w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm" }, $t = {
322
+ }, Zt = ["src"], ea = ["src"], ta = { class: "w-12 h-12 rounded-full bg-white/80 backdrop-blur-sm flex items-center justify-center shadow-sm" }, aa = {
323
323
  key: 3,
324
324
  class: "absolute bottom-2 left-1/2 transform -translate-x-1/2 flex items-center justify-center"
325
- }, At = {
325
+ }, na = {
326
326
  key: 4,
327
327
  class: "absolute inset-0 flex flex-col items-center justify-center bg-slate-50 text-slate-400 text-sm p-4 text-center"
328
- }, Ft = ["title"], Wt = { class: "absolute bottom-0 left-0 right-0 p-3 opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 delay-75 pointer-events-none" }, Ot = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, pe = /* @__PURE__ */ Le({
328
+ }, la = ["title"], oa = { class: "absolute bottom-0 left-0 right-0 p-3 opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 delay-75 pointer-events-none" }, ra = { class: "text-white text-xs font-medium truncate drop-shadow-md" }, ge = /* @__PURE__ */ Je({
329
329
  __name: "MasonryItem",
330
330
  props: {
331
331
  item: {},
@@ -333,208 +333,208 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
333
333
  type: { default: void 0 },
334
334
  notFound: { type: Boolean, default: void 0 }
335
335
  },
336
- setup(e) {
337
- const r = e, l = k(!1), s = k(!1), w = k(null), v = k(!1), a = k(!1), n = k(null), h = k(!1), c = k(!1), f = k(!1), T = k(null);
338
- let m = null;
339
- const d = te(() => {
340
- var i;
341
- return r.type ?? ((i = r.item) == null ? void 0 : i.type) ?? "image";
342
- }), N = te(() => {
343
- var i;
344
- return r.notFound ?? ((i = r.item) == null ? void 0 : i.notFound) ?? !1;
336
+ setup(t) {
337
+ const i = t, u = T(!1), l = T(!1), I = T(null), h = T(!1), a = T(!1), c = T(null), w = T(!1), k = T(!1), v = T(!1), H = T(null);
338
+ let N = null;
339
+ const b = J(() => {
340
+ var o;
341
+ return i.type ?? ((o = i.item) == null ? void 0 : o.type) ?? "image";
342
+ }), P = J(() => {
343
+ var o;
344
+ return i.notFound ?? ((o = i.item) == null ? void 0 : o.notFound) ?? !1;
345
345
  });
346
- function z(i) {
347
- return new Promise((g, M) => {
348
- if (!i) {
349
- M(new Error("No image source provided"));
346
+ function s(o) {
347
+ return new Promise((d, g) => {
348
+ if (!o) {
349
+ g(new Error("No image source provided"));
350
350
  return;
351
351
  }
352
- const I = new Image(), b = Date.now(), A = 300;
353
- I.onload = () => {
354
- const P = Date.now() - b, H = Math.max(0, A - P);
352
+ const E = new Image(), m = Date.now(), L = 300;
353
+ E.onload = () => {
354
+ const y = Date.now() - m, W = Math.max(0, L - y);
355
355
  setTimeout(async () => {
356
- l.value = !0, s.value = !1, c.value = !1, await J(), await new Promise((L) => setTimeout(L, 100)), f.value = !0, g();
357
- }, H);
358
- }, I.onerror = () => {
359
- s.value = !0, l.value = !1, c.value = !1, M(new Error("Failed to load image"));
360
- }, I.src = i;
356
+ u.value = !0, l.value = !1, k.value = !1, await R(), await new Promise((S) => setTimeout(S, 100)), v.value = !0, d();
357
+ }, W);
358
+ }, E.onerror = () => {
359
+ l.value = !0, u.value = !1, k.value = !1, g(new Error("Failed to load image"));
360
+ }, E.src = o;
361
361
  });
362
362
  }
363
- function $(i) {
364
- return new Promise((g, M) => {
365
- if (!i) {
366
- M(new Error("No video source provided"));
363
+ function $(o) {
364
+ return new Promise((d, g) => {
365
+ if (!o) {
366
+ g(new Error("No video source provided"));
367
367
  return;
368
368
  }
369
- const I = document.createElement("video"), b = Date.now(), A = 300;
370
- I.preload = "metadata", I.muted = !0, I.onloadedmetadata = () => {
371
- const P = Date.now() - b, H = Math.max(0, A - P);
369
+ const E = document.createElement("video"), m = Date.now(), L = 300;
370
+ E.preload = "metadata", E.muted = !0, E.onloadedmetadata = () => {
371
+ const y = Date.now() - m, W = Math.max(0, L - y);
372
372
  setTimeout(async () => {
373
- v.value = !0, a.value = !1, c.value = !1, await J(), await new Promise((L) => setTimeout(L, 100)), f.value = !0, g();
374
- }, H);
375
- }, I.onerror = () => {
376
- a.value = !0, v.value = !1, c.value = !1, M(new Error("Failed to load video"));
377
- }, I.src = i;
373
+ h.value = !0, a.value = !1, k.value = !1, await R(), await new Promise((S) => setTimeout(S, 100)), v.value = !0, d();
374
+ }, W);
375
+ }, E.onerror = () => {
376
+ a.value = !0, h.value = !1, k.value = !1, g(new Error("Failed to load video"));
377
+ }, E.src = o;
378
378
  });
379
379
  }
380
- async function E() {
381
- var g;
382
- if (!h.value || c.value || N.value || d.value === "video" && v.value || d.value === "image" && l.value)
380
+ async function f() {
381
+ var d;
382
+ if (!w.value || k.value || P.value || b.value === "video" && h.value || b.value === "image" && u.value)
383
383
  return;
384
- const i = (g = r.item) == null ? void 0 : g.src;
385
- if (i)
386
- if (c.value = !0, f.value = !1, d.value === "video") {
387
- n.value = i, v.value = !1, a.value = !1;
384
+ const o = (d = i.item) == null ? void 0 : d.src;
385
+ if (o)
386
+ if (k.value = !0, v.value = !1, b.value === "video") {
387
+ c.value = o, h.value = !1, a.value = !1;
388
388
  try {
389
- await $(i);
389
+ await $(o);
390
390
  } catch {
391
391
  }
392
392
  } else {
393
- w.value = i, l.value = !1, s.value = !1;
393
+ I.value = o, u.value = !1, l.value = !1;
394
394
  try {
395
- await z(i);
395
+ await s(o);
396
396
  } catch {
397
397
  }
398
398
  }
399
399
  }
400
- return Se(() => {
401
- T.value && (m = new IntersectionObserver(
402
- (i) => {
403
- i.forEach((g) => {
404
- g.isIntersecting && g.intersectionRatio >= 1 ? h.value || (h.value = !0, E()) : g.isIntersecting;
400
+ return Ke(() => {
401
+ H.value && (N = new IntersectionObserver(
402
+ (o) => {
403
+ o.forEach((d) => {
404
+ d.isIntersecting && d.intersectionRatio >= 1 ? w.value || (w.value = !0, f()) : d.isIntersecting;
405
405
  });
406
406
  },
407
407
  {
408
408
  // Only trigger when item is 100% visible (full height in view)
409
409
  threshold: [1]
410
410
  }
411
- ), m.observe(T.value));
412
- }), Ne(() => {
413
- m && (m.disconnect(), m = null);
414
- }), He(
411
+ ), N.observe(H.value));
412
+ }), Qe(() => {
413
+ N && (N.disconnect(), N = null);
414
+ }), ne(
415
415
  () => {
416
- var i;
417
- return (i = r.item) == null ? void 0 : i.src;
416
+ var o;
417
+ return (o = i.item) == null ? void 0 : o.src;
418
418
  },
419
- async (i) => {
420
- if (!(!i || N.value)) {
421
- if (d.value === "video") {
422
- if (i !== n.value && (v.value = !1, a.value = !1, n.value = i, h.value)) {
423
- c.value = !0;
419
+ async (o) => {
420
+ if (!(!o || P.value)) {
421
+ if (b.value === "video") {
422
+ if (o !== c.value && (h.value = !1, a.value = !1, c.value = o, w.value)) {
423
+ k.value = !0;
424
424
  try {
425
- await $(i);
425
+ await $(o);
426
426
  } catch {
427
427
  }
428
428
  }
429
- } else if (i !== w.value && (l.value = !1, s.value = !1, w.value = i, h.value)) {
430
- c.value = !0;
429
+ } else if (o !== I.value && (u.value = !1, l.value = !1, I.value = o, w.value)) {
430
+ k.value = !0;
431
431
  try {
432
- await z(i);
432
+ await s(o);
433
433
  } catch {
434
434
  }
435
435
  }
436
436
  }
437
437
  }
438
- ), (i, g) => (D(), B("div", {
438
+ ), (o, d) => (B(), O("div", {
439
439
  ref_key: "containerRef",
440
- ref: T,
440
+ ref: H,
441
441
  class: "relative w-full h-full group"
442
442
  }, [
443
- $e(i.$slots, "default", {
444
- item: i.item,
445
- remove: i.remove,
446
- imageLoaded: l.value,
447
- imageError: s.value,
448
- videoLoaded: v.value,
443
+ Le(o.$slots, "default", {
444
+ item: o.item,
445
+ remove: o.remove,
446
+ imageLoaded: u.value,
447
+ imageError: l.value,
448
+ videoLoaded: h.value,
449
449
  videoError: a.value,
450
- showNotFound: N.value,
451
- isLoading: c.value,
452
- mediaType: d.value
450
+ showNotFound: P.value,
451
+ isLoading: k.value,
452
+ mediaType: b.value
453
453
  }, () => [
454
- S("div", kt, [
455
- N.value ? (D(), B("div", Et, g[4] || (g[4] = [
456
- S("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
457
- S("span", { class: "font-medium" }, "Not Found", -1),
458
- S("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
459
- ]))) : (D(), B("div", Lt, [
460
- d.value === "image" && w.value ? (D(), B("img", {
454
+ A("div", Jt, [
455
+ P.value ? (B(), O("div", Kt, d[4] || (d[4] = [
456
+ A("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
457
+ A("span", { class: "font-medium" }, "Not Found", -1),
458
+ A("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
459
+ ]))) : (B(), O("div", Qt, [
460
+ b.value === "image" && I.value ? (B(), O("img", {
461
461
  key: 0,
462
- src: w.value,
463
- class: Y([
462
+ src: I.value,
463
+ class: Z([
464
464
  "w-full h-full object-cover transition-opacity duration-700 ease-in-out group-hover:scale-105",
465
- l.value && f.value ? "opacity-100" : "opacity-0"
465
+ u.value && v.value ? "opacity-100" : "opacity-0"
466
466
  ]),
467
467
  style: { position: "absolute", top: "0", left: "0" },
468
468
  loading: "lazy",
469
469
  decoding: "async",
470
470
  alt: ""
471
- }, null, 10, St)) : X("", !0),
472
- d.value === "video" && n.value ? (D(), B("video", {
471
+ }, null, 10, Zt)) : ae("", !0),
472
+ b.value === "video" && c.value ? (B(), O("video", {
473
473
  key: 1,
474
- src: n.value,
475
- class: Y([
474
+ src: c.value,
475
+ class: Z([
476
476
  "w-full h-full object-cover transition-opacity duration-700 ease-in-out group-hover:scale-105",
477
- v.value && f.value ? "opacity-100" : "opacity-0"
477
+ h.value && v.value ? "opacity-100" : "opacity-0"
478
478
  ]),
479
479
  style: { position: "absolute", top: "0", left: "0" },
480
480
  muted: "",
481
481
  loop: "",
482
482
  playsinline: "",
483
- onMouseenter: g[0] || (g[0] = (M) => M.target.play()),
484
- onMouseleave: g[1] || (g[1] = (M) => M.target.pause()),
485
- onError: g[2] || (g[2] = (M) => a.value = !0)
486
- }, null, 42, Nt)) : X("", !0),
487
- !l.value && !v.value && !s.value && !a.value ? (D(), B("div", {
483
+ onMouseenter: d[0] || (d[0] = (g) => g.target.play()),
484
+ onMouseleave: d[1] || (d[1] = (g) => g.target.pause()),
485
+ onError: d[2] || (d[2] = (g) => a.value = !0)
486
+ }, null, 42, ea)) : ae("", !0),
487
+ !u.value && !h.value && !l.value && !a.value ? (B(), O("div", {
488
488
  key: 2,
489
- class: Y([
489
+ class: Z([
490
490
  "absolute inset-0 bg-slate-100 flex items-center justify-center transition-opacity duration-500",
491
- f.value ? "opacity-0 pointer-events-none" : "opacity-100"
491
+ v.value ? "opacity-0 pointer-events-none" : "opacity-100"
492
492
  ])
493
493
  }, [
494
- S("div", Ht, [
495
- S("i", {
496
- class: Y(d.value === "video" ? "fas fa-video text-xl text-slate-400" : "fas fa-image text-xl text-slate-400")
494
+ A("div", ta, [
495
+ A("i", {
496
+ class: Z(b.value === "video" ? "fas fa-video text-xl text-slate-400" : "fas fa-image text-xl text-slate-400")
497
497
  }, null, 2)
498
498
  ])
499
- ], 2)) : X("", !0),
500
- c.value ? (D(), B("div", $t, g[5] || (g[5] = [
501
- S("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
502
- S("div", { class: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" })
499
+ ], 2)) : ae("", !0),
500
+ k.value ? (B(), O("div", aa, d[5] || (d[5] = [
501
+ A("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
502
+ A("div", { class: "animate-spin rounded-full h-4 w-4 border-b-2 border-blue-500" })
503
503
  ], -1)
504
- ]))) : X("", !0),
505
- d.value === "image" && s.value || d.value === "video" && a.value ? (D(), B("div", At, [
506
- S("i", {
507
- class: Y(d.value === "video" ? "fas fa-video text-2xl mb-2 opacity-50" : "fas fa-image text-2xl mb-2 opacity-50")
504
+ ]))) : ae("", !0),
505
+ b.value === "image" && l.value || b.value === "video" && a.value ? (B(), O("div", na, [
506
+ A("i", {
507
+ class: Z(b.value === "video" ? "fas fa-video text-2xl mb-2 opacity-50" : "fas fa-image text-2xl mb-2 opacity-50")
508
508
  }, null, 2),
509
- S("span", null, "Failed to load " + ue(d.value), 1)
510
- ])) : X("", !0)
509
+ A("span", null, "Failed to load " + _e(b.value), 1)
510
+ ])) : ae("", !0)
511
511
  ])),
512
- !N.value && (l.value || v.value || c.value) ? (D(), B("div", {
512
+ !P.value && (u.value || h.value || k.value) ? (B(), O("div", {
513
513
  key: 2,
514
514
  class: "absolute top-2 left-2 w-7 h-7 flex items-center justify-center bg-black/60 backdrop-blur-sm text-white rounded-full shadow-sm opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none",
515
- title: d.value === "video" ? "Video" : "Image"
515
+ title: b.value === "video" ? "Video" : "Image"
516
516
  }, [
517
- S("i", {
518
- class: Y(d.value === "video" ? "fas fa-video text-xs" : "fas fa-image text-xs")
517
+ A("i", {
518
+ class: Z(b.value === "video" ? "fas fa-video text-xs" : "fas fa-image text-xs")
519
519
  }, null, 2)
520
- ], 8, Ft)) : X("", !0),
521
- g[7] || (g[7] = S("div", { class: "absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none" }, null, -1)),
522
- i.remove ? (D(), B("button", {
520
+ ], 8, la)) : ae("", !0),
521
+ d[7] || (d[7] = A("div", { class: "absolute inset-0 bg-gradient-to-t from-black/50 via-transparent to-transparent opacity-0 group-hover:opacity-100 transition-opacity duration-300 pointer-events-none" }, null, -1)),
522
+ o.remove ? (B(), O("button", {
523
523
  key: 3,
524
524
  class: "absolute top-2 right-2 w-8 h-8 flex items-center justify-center bg-white/90 backdrop-blur-sm text-slate-700 rounded-full shadow-sm opacity-0 group-hover:opacity-100 transform translate-y-2 group-hover:translate-y-0 transition-all duration-300 hover:bg-red-500 hover:text-white cursor-pointer z-10",
525
- onClick: g[3] || (g[3] = ze((M) => i.remove(i.item), ["stop"])),
525
+ onClick: d[3] || (d[3] = dt((g) => o.remove(o.item), ["stop"])),
526
526
  "aria-label": "Remove item"
527
- }, g[6] || (g[6] = [
528
- S("i", { class: "fas fa-times text-sm" }, null, -1)
529
- ]))) : X("", !0),
530
- S("div", Wt, [
531
- S("p", Ot, "Item #" + ue(String(i.item.id).split("-")[0]), 1)
527
+ }, d[6] || (d[6] = [
528
+ A("i", { class: "fas fa-times text-sm" }, null, -1)
529
+ ]))) : ae("", !0),
530
+ A("div", oa, [
531
+ A("p", ra, "Item #" + _e(String(o.item.id).split("-")[0]), 1)
532
532
  ])
533
533
  ])
534
534
  ])
535
535
  ], 512));
536
536
  }
537
- }), jt = /* @__PURE__ */ Le({
537
+ }), ia = { class: "w-full h-full flex items-center justify-center p-4" }, sa = { class: "w-full h-full max-w-full max-h-full" }, ua = /* @__PURE__ */ Je({
538
538
  __name: "Masonry",
539
539
  props: {
540
540
  getNextPage: {
@@ -557,7 +557,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
557
557
  type: String,
558
558
  default: "page",
559
559
  // or 'cursor'
560
- validator: (e) => ["page", "cursor"].includes(e)
560
+ validator: (t) => ["page", "cursor"].includes(t)
561
561
  },
562
562
  skipInitialLoad: {
563
563
  type: Boolean,
@@ -622,6 +622,18 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
622
622
  autoRefreshOnEmpty: {
623
623
  type: Boolean,
624
624
  default: !1
625
+ },
626
+ // Layout mode: 'auto' (detect from screen size), 'masonry', or 'swipe'
627
+ layoutMode: {
628
+ type: String,
629
+ default: "auto",
630
+ validator: (t) => ["auto", "masonry", "swipe"].includes(t)
631
+ },
632
+ // Breakpoint for switching to swipe mode (in pixels or Tailwind breakpoint name)
633
+ mobileBreakpoint: {
634
+ type: [Number, String],
635
+ default: 768
636
+ // 'md' breakpoint
625
637
  }
626
638
  },
627
639
  emits: [
@@ -634,8 +646,8 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
634
646
  "retry:stop",
635
647
  "remove-all:complete"
636
648
  ],
637
- setup(e, { expose: r, emit: l }) {
638
- const s = e, w = {
649
+ setup(t, { expose: i, emit: u }) {
650
+ const l = t, I = {
639
651
  sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
640
652
  gutterX: 10,
641
653
  gutterY: 10,
@@ -644,41 +656,69 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
644
656
  paddingLeft: 0,
645
657
  paddingRight: 0,
646
658
  placement: "masonry"
647
- }, v = te(() => {
648
- var t;
659
+ }, h = J(() => {
660
+ var e;
649
661
  return {
650
- ...w,
651
- ...s.layout,
662
+ ...I,
663
+ ...l.layout,
652
664
  sizes: {
653
- ...w.sizes,
654
- ...((t = s.layout) == null ? void 0 : t.sizes) || {}
665
+ ...I.sizes,
666
+ ...((e = l.layout) == null ? void 0 : e.sizes) || {}
655
667
  }
656
668
  };
657
- }), a = l, n = te({
658
- get: () => s.items,
659
- set: (t) => a("update:items", t)
660
- }), h = k(7), c = k(null), f = k([]), T = k(null), m = k(!1), d = k(0), N = k(/* @__PURE__ */ new Set());
661
- function z(t) {
662
- return typeof t == "number" && Number.isFinite(t) && t > 0;
669
+ }), a = T(null), c = T(typeof window < "u" ? window.innerWidth : 1024);
670
+ let w = null;
671
+ function k(e) {
672
+ return {
673
+ sm: 640,
674
+ md: 768,
675
+ lg: 1024,
676
+ xl: 1280,
677
+ "2xl": 1536
678
+ }[e] || 768;
663
679
  }
664
- function $(t, o) {
680
+ const v = J(() => {
681
+ if (l.layoutMode === "masonry") return !1;
682
+ if (l.layoutMode === "swipe") return !0;
683
+ const e = typeof l.mobileBreakpoint == "string" ? k(l.mobileBreakpoint) : l.mobileBreakpoint;
684
+ return c.value < e;
685
+ }), H = J(() => {
686
+ if (!v.value || s.value.length === 0) return null;
687
+ const e = Math.max(0, Math.min(m.value, s.value.length - 1));
688
+ return s.value[e] || null;
689
+ }), N = J(() => {
690
+ if (!v.value || !H.value) return null;
691
+ const e = m.value + 1;
692
+ return e >= s.value.length ? null : s.value[e] || null;
693
+ }), b = J(() => {
694
+ if (!v.value || !H.value) return null;
695
+ const e = m.value - 1;
696
+ return e < 0 ? null : s.value[e] || null;
697
+ }), P = u, s = J({
698
+ get: () => l.items,
699
+ set: (e) => P("update:items", e)
700
+ }), $ = T(7), f = T(null), o = T([]), d = T(null), g = T(!1), E = T(0), m = T(0), L = T(0), y = T(!1), W = T(0), S = T(0), D = T(null), le = T(/* @__PURE__ */ new Set());
701
+ function oe(e) {
702
+ return typeof e == "number" && Number.isFinite(e) && e > 0;
703
+ }
704
+ function ee(e, n) {
665
705
  try {
666
- if (!Array.isArray(t) || t.length === 0) return;
667
- const u = t.filter((y) => !z(y == null ? void 0 : y.width) || !z(y == null ? void 0 : y.height));
668
- if (u.length === 0) return;
706
+ if (!Array.isArray(e) || e.length === 0) return;
707
+ const r = e.filter((x) => !oe(x == null ? void 0 : x.width) || !oe(x == null ? void 0 : x.height));
708
+ if (r.length === 0) return;
669
709
  const p = [];
670
- for (const y of u) {
671
- const j = (y == null ? void 0 : y.id) ?? `idx:${t.indexOf(y)}`;
672
- N.value.has(j) || (N.value.add(j), p.push(j));
710
+ for (const x of r) {
711
+ const j = (x == null ? void 0 : x.id) ?? `idx:${e.indexOf(x)}`;
712
+ le.value.has(j) || (le.value.add(j), p.push(j));
673
713
  }
674
714
  if (p.length > 0) {
675
- const y = p.slice(0, 10);
715
+ const x = p.slice(0, 10);
676
716
  console.warn(
677
717
  "[Masonry] Items missing width/height detected:",
678
718
  {
679
- context: o,
719
+ context: n,
680
720
  count: p.length,
681
- sampleIds: y,
721
+ sampleIds: x,
682
722
  hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
683
723
  }
684
724
  );
@@ -686,367 +726,473 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
686
726
  } catch {
687
727
  }
688
728
  }
689
- const E = k(0), i = k(0), g = s.virtualBufferPx, M = k(!1), I = k({
729
+ const V = T(0), U = T(0), te = l.virtualBufferPx, K = T(!1), ue = T({
690
730
  distanceToTrigger: 0,
691
731
  isNearTrigger: !1
692
- }), b = (t) => {
693
- if (!c.value) return;
694
- const { scrollTop: o, clientHeight: u } = c.value, p = o + u, y = t ?? ge(n.value, h.value), j = y.length ? Math.max(...y) : 0, G = typeof s.loadThresholdPx == "number" ? s.loadThresholdPx : 200, ee = G >= 0 ? Math.max(0, j - G) : Math.max(0, j + G), we = Math.max(0, ee - p), De = we <= 100;
695
- I.value = {
696
- distanceToTrigger: Math.round(we),
697
- isNearTrigger: De
732
+ }), M = (e) => {
733
+ if (!f.value) return;
734
+ const { scrollTop: n, clientHeight: r } = f.value, p = n + r, x = e ?? Se(s.value, $.value), j = x.length ? Math.max(...x) : 0, Y = typeof l.loadThresholdPx == "number" ? l.loadThresholdPx : 200, se = Y >= 0 ? Math.max(0, j - Y) : Math.max(0, j + Y), Re = Math.max(0, se - p), vt = Re <= 100;
735
+ ue.value = {
736
+ distanceToTrigger: Math.round(Re),
737
+ isNearTrigger: vt
698
738
  };
699
- }, { onEnter: A, onBeforeEnter: P, onBeforeLeave: H, onLeave: L } = It(n, { leaveDurationMs: s.leaveDurationMs });
700
- function _(t, o) {
701
- if (M.value) {
702
- const u = parseInt(t.dataset.left || "0", 10), p = parseInt(t.dataset.top || "0", 10);
703
- t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${u}px, ${p}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
704
- t.style.transition = "", o();
739
+ }, { onEnter: F, onBeforeEnter: _, onBeforeLeave: Q, onLeave: C } = Gt(s, { leaveDurationMs: l.leaveDurationMs });
740
+ function re(e, n) {
741
+ if (K.value) {
742
+ const r = parseInt(e.dataset.left || "0", 10), p = parseInt(e.dataset.top || "0", 10);
743
+ e.style.transition = "none", e.style.opacity = "1", e.style.transform = `translate3d(${r}px, ${p}px, 0) scale(1)`, e.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
744
+ e.style.transition = "", n();
705
745
  });
706
746
  } else
707
- A(t, o);
747
+ F(e, n);
708
748
  }
709
- function ae(t) {
710
- if (M.value) {
711
- const o = parseInt(t.dataset.left || "0", 10), u = parseInt(t.dataset.top || "0", 10);
712
- t.style.transition = "none", t.style.opacity = "1", t.style.transform = `translate3d(${o}px, ${u}px, 0) scale(1)`, t.style.removeProperty("--masonry-opacity-delay");
749
+ function q(e) {
750
+ if (K.value) {
751
+ const n = parseInt(e.dataset.left || "0", 10), r = parseInt(e.dataset.top || "0", 10);
752
+ e.style.transition = "none", e.style.opacity = "1", e.style.transform = `translate3d(${n}px, ${r}px, 0) scale(1)`, e.style.removeProperty("--masonry-opacity-delay");
713
753
  } else
714
- P(t);
754
+ _(e);
715
755
  }
716
- function ne(t) {
717
- M.value || H(t);
756
+ function tt(e) {
757
+ K.value || Q(e);
718
758
  }
719
- function K(t, o) {
720
- M.value ? o() : L(t, o);
759
+ function at(e, n) {
760
+ K.value ? n() : C(e, n);
721
761
  }
722
- const oe = te(() => {
723
- const t = E.value - g, o = E.value + i.value + g, u = n.value;
724
- return !u || u.length === 0 ? [] : u.filter((p) => {
725
- const y = p.top;
726
- return p.top + p.columnHeight >= t && y <= o;
762
+ const nt = J(() => {
763
+ const e = V.value - te, n = V.value + U.value + te, r = s.value;
764
+ return !r || r.length === 0 ? [] : r.filter((p) => {
765
+ const x = p.top;
766
+ return p.top + p.columnHeight >= e && x <= n;
727
767
  });
728
- }), { handleScroll: Q } = Pt({
729
- container: c,
730
- masonry: n,
731
- columns: h,
732
- containerHeight: d,
733
- isLoading: m,
734
- pageSize: s.pageSize,
735
- refreshLayout: C,
736
- setItemsRaw: (t) => {
737
- n.value = t;
768
+ }), { handleScroll: lt } = Xt({
769
+ container: f,
770
+ masonry: s,
771
+ columns: $,
772
+ containerHeight: E,
773
+ isLoading: g,
774
+ pageSize: l.pageSize,
775
+ refreshLayout: G,
776
+ setItemsRaw: (e) => {
777
+ s.value = e;
738
778
  },
739
- loadNext: q,
740
- loadThresholdPx: s.loadThresholdPx
779
+ loadNext: ie,
780
+ loadThresholdPx: l.loadThresholdPx
741
781
  });
742
- r({
743
- isLoading: m,
744
- refreshLayout: C,
745
- containerHeight: d,
746
- remove: U,
747
- removeMany: V,
748
- removeAll: We,
749
- loadNext: q,
750
- loadPage: R,
751
- refreshCurrentPage: O,
752
- reset: je,
753
- init: Be,
754
- paginationHistory: f,
755
- cancelLoad: he,
756
- scrollToTop: ye,
757
- totalItems: te(() => n.value.length)
782
+ i({
783
+ isLoading: g,
784
+ refreshLayout: G,
785
+ containerHeight: E,
786
+ remove: ce,
787
+ removeMany: it,
788
+ removeAll: st,
789
+ loadNext: ie,
790
+ loadPage: ye,
791
+ refreshCurrentPage: we,
792
+ reset: ct,
793
+ init: ft,
794
+ paginationHistory: o,
795
+ cancelLoad: Ne,
796
+ scrollToTop: He,
797
+ totalItems: J(() => s.value.length)
758
798
  });
759
- function Z(t) {
760
- const o = wt(t);
761
- let u = 0;
762
- if (c.value) {
763
- const { scrollTop: p, clientHeight: y } = c.value;
764
- u = p + y + 100;
799
+ function ot(e) {
800
+ const n = Yt(e);
801
+ let r = 0;
802
+ if (f.value) {
803
+ const { scrollTop: p, clientHeight: x } = f.value;
804
+ r = p + x + 100;
765
805
  }
766
- d.value = Math.max(o, u);
806
+ E.value = Math.max(n, r);
767
807
  }
768
- function C(t) {
769
- if (!c.value) return;
770
- $(t, "refreshLayout");
771
- const o = t.map((p, y) => ({
808
+ function G(e) {
809
+ if (v.value) {
810
+ s.value = e;
811
+ return;
812
+ }
813
+ if (!f.value) return;
814
+ ee(e, "refreshLayout");
815
+ const n = e.map((p, x) => ({
772
816
  ...p,
773
- originalIndex: p.originalIndex ?? y
774
- })), u = Ye(o, c.value, h.value, v.value);
775
- Z(u), n.value = u;
817
+ originalIndex: p.originalIndex ?? x
818
+ })), r = wt(n, f.value, $.value, h.value);
819
+ ot(r), s.value = r;
776
820
  }
777
- function re(t, o) {
778
- return new Promise((u) => {
779
- const p = Math.max(0, t | 0), y = Date.now();
780
- o(p, p);
821
+ function $e(e, n) {
822
+ return new Promise((r) => {
823
+ const p = Math.max(0, e | 0), x = Date.now();
824
+ n(p, p);
781
825
  const j = setInterval(() => {
782
- if (W.value) {
783
- clearInterval(j), u();
826
+ if (z.value) {
827
+ clearInterval(j), r();
784
828
  return;
785
829
  }
786
- const G = Date.now() - y, ee = Math.max(0, p - G);
787
- o(ee, p), ee <= 0 && (clearInterval(j), u());
830
+ const Y = Date.now() - x, se = Math.max(0, p - Y);
831
+ n(se, p), se <= 0 && (clearInterval(j), r());
788
832
  }, 100);
789
833
  });
790
834
  }
791
- async function x(t) {
835
+ async function me(e) {
792
836
  try {
793
- const o = await F(() => s.getNextPage(t));
794
- return C([...n.value, ...o.items]), o;
795
- } catch (o) {
796
- throw console.error("Error in getContent:", o), o;
837
+ const n = await rt(() => l.getNextPage(e));
838
+ return G([...s.value, ...n.items]), n;
839
+ } catch (n) {
840
+ throw console.error("Error in getContent:", n), n;
797
841
  }
798
842
  }
799
- async function F(t) {
800
- let o = 0;
801
- const u = s.retryMaxAttempts;
802
- let p = s.retryInitialDelayMs;
843
+ async function rt(e) {
844
+ let n = 0;
845
+ const r = l.retryMaxAttempts;
846
+ let p = l.retryInitialDelayMs;
803
847
  for (; ; )
804
848
  try {
805
- const y = await t();
806
- return o > 0 && a("retry:stop", { attempt: o, success: !0 }), y;
807
- } catch (y) {
808
- if (o++, o > u)
809
- throw a("retry:stop", { attempt: o - 1, success: !1 }), y;
810
- a("retry:start", { attempt: o, max: u, totalMs: p }), await re(p, (j, G) => {
811
- a("retry:tick", { attempt: o, remainingMs: j, totalMs: G });
812
- }), p += s.retryBackoffStepMs;
849
+ const x = await e();
850
+ return n > 0 && P("retry:stop", { attempt: n, success: !0 }), x;
851
+ } catch (x) {
852
+ if (n++, n > r)
853
+ throw P("retry:stop", { attempt: n - 1, success: !1 }), x;
854
+ P("retry:start", { attempt: n, max: r, totalMs: p }), await $e(p, (j, Y) => {
855
+ P("retry:tick", { attempt: n, remainingMs: j, totalMs: Y });
856
+ }), p += l.retryBackoffStepMs;
813
857
  }
814
858
  }
815
- async function R(t) {
816
- if (!m.value) {
817
- W.value = !1, m.value = !0;
859
+ async function ye(e) {
860
+ if (!g.value) {
861
+ z.value = !1, g.value = !0;
818
862
  try {
819
- const o = n.value.length;
820
- if (W.value) return;
821
- const u = await x(t);
822
- return W.value ? void 0 : (T.value = t, f.value.push(u.nextPage), await le(o), u);
823
- } catch (o) {
824
- throw console.error("Error loading page:", o), o;
863
+ const n = s.value.length;
864
+ if (z.value) return;
865
+ const r = await me(e);
866
+ return z.value ? void 0 : (d.value = e, o.value.push(r.nextPage), await fe(n), r);
867
+ } catch (n) {
868
+ throw console.error("Error loading page:", n), n;
825
869
  } finally {
826
- m.value = !1;
870
+ g.value = !1;
827
871
  }
828
872
  }
829
873
  }
830
- async function q() {
831
- if (!m.value) {
832
- W.value = !1, m.value = !0;
874
+ async function ie() {
875
+ if (!g.value) {
876
+ z.value = !1, g.value = !0;
833
877
  try {
834
- const t = n.value.length;
835
- if (W.value) return;
836
- const o = f.value[f.value.length - 1], u = await x(o);
837
- return W.value ? void 0 : (T.value = o, f.value.push(u.nextPage), await le(t), u);
838
- } catch (t) {
839
- throw console.error("Error loading next page:", t), t;
878
+ const e = s.value.length;
879
+ if (z.value) return;
880
+ const n = o.value[o.value.length - 1], r = await me(n);
881
+ return z.value ? void 0 : (d.value = n, o.value.push(r.nextPage), await fe(e), r);
882
+ } catch (e) {
883
+ throw console.error("Error loading next page:", e), e;
840
884
  } finally {
841
- m.value = !1;
885
+ g.value = !1;
842
886
  }
843
887
  }
844
888
  }
845
- async function O() {
846
- if (console.log("[Masonry] refreshCurrentPage called, isLoading:", m.value, "currentPage:", T.value), !m.value) {
847
- W.value = !1, m.value = !0;
889
+ async function we() {
890
+ if (console.log("[Masonry] refreshCurrentPage called, isLoading:", g.value, "currentPage:", d.value), !g.value) {
891
+ z.value = !1, g.value = !0;
848
892
  try {
849
- const t = T.value;
850
- if (console.log("[Masonry] pageToRefresh:", t), t == null) {
851
- console.warn("[Masonry] No current page to refresh - currentPage:", T.value, "paginationHistory:", f.value);
893
+ const e = d.value;
894
+ if (console.log("[Masonry] pageToRefresh:", e), e == null) {
895
+ console.warn("[Masonry] No current page to refresh - currentPage:", d.value, "paginationHistory:", o.value);
852
896
  return;
853
897
  }
854
- n.value = [], d.value = 0, f.value = [t], await J();
855
- const o = await x(t);
856
- if (W.value) return;
857
- T.value = t, f.value.push(o.nextPage);
858
- const u = n.value.length;
859
- return await le(u), o;
860
- } catch (t) {
861
- throw console.error("[Masonry] Error refreshing current page:", t), t;
898
+ s.value = [], E.value = 0, o.value = [e], await R();
899
+ const n = await me(e);
900
+ if (z.value) return;
901
+ d.value = e, o.value.push(n.nextPage);
902
+ const r = s.value.length;
903
+ return await fe(r), n;
904
+ } catch (e) {
905
+ throw console.error("[Masonry] Error refreshing current page:", e), e;
862
906
  } finally {
863
- m.value = !1;
907
+ g.value = !1;
864
908
  }
865
909
  }
866
910
  }
867
- async function U(t) {
868
- const o = n.value.filter((u) => u.id !== t.id);
869
- if (n.value = o, await J(), console.log("[Masonry] remove - next.length:", o.length, "paginationHistory.length:", f.value.length), o.length === 0 && f.value.length > 0) {
870
- if (s.autoRefreshOnEmpty)
871
- console.log("[Masonry] All items removed, calling refreshCurrentPage"), await O();
911
+ async function ce(e) {
912
+ const n = s.value.filter((r) => r.id !== e.id);
913
+ if (s.value = n, await R(), console.log("[Masonry] remove - next.length:", n.length, "paginationHistory.length:", o.value.length), n.length === 0 && o.value.length > 0) {
914
+ if (l.autoRefreshOnEmpty)
915
+ console.log("[Masonry] All items removed, calling refreshCurrentPage"), await we();
872
916
  else {
873
917
  console.log("[Masonry] All items removed, calling loadNext and forcing backfill");
874
918
  try {
875
- await q(), await le(0, !0);
919
+ await ie(), await fe(0, !0);
876
920
  } catch {
877
921
  }
878
922
  }
879
923
  return;
880
924
  }
881
- await new Promise((u) => requestAnimationFrame(() => u())), requestAnimationFrame(() => {
882
- C(o);
925
+ await new Promise((r) => requestAnimationFrame(() => r())), requestAnimationFrame(() => {
926
+ G(n);
883
927
  });
884
928
  }
885
- async function V(t) {
886
- if (!t || t.length === 0) return;
887
- const o = new Set(t.map((p) => p.id)), u = n.value.filter((p) => !o.has(p.id));
888
- if (n.value = u, await J(), u.length === 0 && f.value.length > 0) {
889
- if (s.autoRefreshOnEmpty)
890
- await O();
929
+ async function it(e) {
930
+ if (!e || e.length === 0) return;
931
+ const n = new Set(e.map((p) => p.id)), r = s.value.filter((p) => !n.has(p.id));
932
+ if (s.value = r, await R(), r.length === 0 && o.value.length > 0) {
933
+ if (l.autoRefreshOnEmpty)
934
+ await we();
891
935
  else
892
936
  try {
893
- await q(), await le(0, !0);
937
+ await ie(), await fe(0, !0);
894
938
  } catch {
895
939
  }
896
940
  return;
897
941
  }
898
942
  await new Promise((p) => requestAnimationFrame(() => p())), requestAnimationFrame(() => {
899
- C(u);
943
+ G(r);
900
944
  });
901
945
  }
902
- function ye(t) {
903
- c.value && c.value.scrollTo({
946
+ function He(e) {
947
+ f.value && f.value.scrollTo({
904
948
  top: 0,
905
- behavior: (t == null ? void 0 : t.behavior) ?? "smooth",
906
- ...t
949
+ behavior: (e == null ? void 0 : e.behavior) ?? "smooth",
950
+ ...e
907
951
  });
908
952
  }
909
- async function We() {
910
- ye({ behavior: "smooth" }), n.value = [], d.value = 0, await J(), a("remove-all:complete");
953
+ async function st() {
954
+ He({ behavior: "smooth" }), s.value = [], E.value = 0, await R(), P("remove-all:complete");
911
955
  }
912
- function Oe() {
913
- h.value = ve(v.value), C(n.value), c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight);
956
+ function ut() {
957
+ $.value = de(h.value), G(s.value), f.value && (V.value = f.value.scrollTop, U.value = f.value.clientHeight);
914
958
  }
915
- let ie = !1;
916
- const W = k(!1);
917
- async function le(t, o = !1) {
918
- if (!o && !s.backfillEnabled || ie || W.value) return;
919
- const u = (t || 0) + (s.pageSize || 0);
920
- if (!(!s.pageSize || s.pageSize <= 0 || f.value[f.value.length - 1] == null) && !(n.value.length >= u)) {
921
- ie = !0;
959
+ let pe = !1;
960
+ const z = T(!1);
961
+ async function fe(e, n = !1) {
962
+ if (!n && !l.backfillEnabled || pe || z.value) return;
963
+ const r = (e || 0) + (l.pageSize || 0);
964
+ if (!(!l.pageSize || l.pageSize <= 0 || o.value[o.value.length - 1] == null) && !(s.value.length >= r)) {
965
+ pe = !0;
922
966
  try {
923
- let y = 0;
924
- for (a("backfill:start", { target: u, fetched: n.value.length, calls: y }); n.value.length < u && y < s.backfillMaxCalls && f.value[f.value.length - 1] != null && !W.value && (await re(s.backfillDelayMs, (G, ee) => {
925
- a("backfill:tick", {
926
- fetched: n.value.length,
927
- target: u,
928
- calls: y,
929
- remainingMs: G,
930
- totalMs: ee
967
+ let x = 0;
968
+ for (P("backfill:start", { target: r, fetched: s.value.length, calls: x }); s.value.length < r && x < l.backfillMaxCalls && o.value[o.value.length - 1] != null && !z.value && (await $e(l.backfillDelayMs, (Y, se) => {
969
+ P("backfill:tick", {
970
+ fetched: s.value.length,
971
+ target: r,
972
+ calls: x,
973
+ remainingMs: Y,
974
+ totalMs: se
931
975
  });
932
- }), !W.value); ) {
933
- const j = f.value[f.value.length - 1];
976
+ }), !z.value); ) {
977
+ const j = o.value[o.value.length - 1];
934
978
  try {
935
- m.value = !0;
936
- const G = await x(j);
937
- if (W.value) break;
938
- f.value.push(G.nextPage);
979
+ g.value = !0;
980
+ const Y = await me(j);
981
+ if (z.value) break;
982
+ o.value.push(Y.nextPage);
939
983
  } finally {
940
- m.value = !1;
984
+ g.value = !1;
941
985
  }
942
- y++;
986
+ x++;
943
987
  }
944
- a("backfill:stop", { fetched: n.value.length, calls: y });
988
+ P("backfill:stop", { fetched: s.value.length, calls: x });
945
989
  } finally {
946
- ie = !1;
990
+ pe = !1;
947
991
  }
948
992
  }
949
993
  }
950
- function he() {
951
- W.value = !0, m.value = !1, ie = !1;
994
+ function Ne() {
995
+ z.value = !0, g.value = !1, pe = !1;
952
996
  }
953
- function je() {
954
- he(), W.value = !1, c.value && c.value.scrollTo({
997
+ function ct() {
998
+ Ne(), z.value = !1, f.value && f.value.scrollTo({
955
999
  top: 0,
956
1000
  behavior: "smooth"
957
- }), n.value = [], d.value = 0, T.value = s.loadAtPage, f.value = [s.loadAtPage], I.value = {
1001
+ }), s.value = [], E.value = 0, d.value = l.loadAtPage, o.value = [l.loadAtPage], ue.value = {
958
1002
  distanceToTrigger: 0,
959
1003
  isNearTrigger: !1
960
1004
  };
961
1005
  }
962
- const be = ke(async () => {
963
- c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight), M.value = !0, await J(), await new Promise((o) => requestAnimationFrame(() => o())), M.value = !1;
964
- const t = ge(n.value, h.value);
965
- Q(t), b(t);
966
- }, 200), xe = ke(Oe, 200);
967
- function Be(t, o, u) {
968
- T.value = o, f.value = [o], f.value.push(u), $(t, "init"), C([...n.value, ...t]), b();
1006
+ const be = Ge(async () => {
1007
+ if (v.value) return;
1008
+ f.value && (V.value = f.value.scrollTop, U.value = f.value.clientHeight), K.value = !0, await R(), await new Promise((n) => requestAnimationFrame(() => n())), K.value = !1;
1009
+ const e = Se(s.value, $.value);
1010
+ lt(e), M(e);
1011
+ }, 200), We = Ge(ut, 200);
1012
+ function De(e) {
1013
+ v.value && (y.value = !0, W.value = e.touches[0].clientY, S.value = L.value, e.preventDefault());
1014
+ }
1015
+ function Ae(e) {
1016
+ if (!v.value || !y.value) return;
1017
+ const n = e.touches[0].clientY - W.value;
1018
+ L.value = S.value + n, e.preventDefault();
1019
+ }
1020
+ function Oe(e) {
1021
+ if (!v.value || !y.value) return;
1022
+ y.value = !1;
1023
+ const n = L.value - S.value;
1024
+ Math.abs(n) > 100 ? n > 0 && b.value ? ze() : n < 0 && N.value ? Fe() : X() : X(), e.preventDefault();
1025
+ }
1026
+ function Be(e) {
1027
+ v.value && (y.value = !0, W.value = e.clientY, S.value = L.value, e.preventDefault());
1028
+ }
1029
+ function xe(e) {
1030
+ if (!v.value || !y.value) return;
1031
+ const n = e.clientY - W.value;
1032
+ L.value = S.value + n, e.preventDefault();
969
1033
  }
970
- return He(
971
- v,
1034
+ function Me(e) {
1035
+ if (!v.value || !y.value) return;
1036
+ y.value = !1;
1037
+ const n = L.value - S.value;
1038
+ Math.abs(n) > 100 ? n > 0 && b.value ? ze() : n < 0 && N.value ? Fe() : X() : X(), e.preventDefault();
1039
+ }
1040
+ function Fe() {
1041
+ if (!N.value) {
1042
+ ie();
1043
+ return;
1044
+ }
1045
+ m.value++, X(), m.value >= s.value.length - 5 && ie();
1046
+ }
1047
+ function ze() {
1048
+ b.value && (m.value--, X());
1049
+ }
1050
+ function X() {
1051
+ if (!D.value) return;
1052
+ const e = D.value.clientHeight;
1053
+ L.value = -m.value * e;
1054
+ }
1055
+ function je() {
1056
+ a.value ? c.value = a.value.clientWidth : typeof window < "u" && (c.value = window.innerWidth), !v.value && m.value > 0 && (m.value = 0, L.value = 0), v.value && s.value.length === 0 && !g.value && ye(o.value[0]), v.value && X();
1057
+ }
1058
+ function ft(e, n, r) {
1059
+ d.value = n, o.value = [n], o.value.push(r), ee(e, "init"), v.value ? (s.value = [...s.value, ...e], m.value === 0 && s.value.length > 0 && (L.value = 0)) : (G([...s.value, ...e]), M());
1060
+ }
1061
+ return ne(
1062
+ h,
972
1063
  () => {
973
- c.value && (h.value = ve(v.value), C(n.value));
1064
+ v.value || f.value && ($.value = de(h.value, c.value), G(s.value));
974
1065
  },
975
1066
  { deep: !0 }
976
- ), Se(async () => {
977
- var t;
1067
+ ), ne(v, (e) => {
1068
+ R(() => {
1069
+ e ? (document.addEventListener("mousemove", xe), document.addEventListener("mouseup", Me), m.value = 0, L.value = 0, s.value.length > 0 && X()) : (document.removeEventListener("mousemove", xe), document.removeEventListener("mouseup", Me), f.value && a.value && (c.value = a.value.clientWidth, f.value.removeEventListener("scroll", be), f.value.addEventListener("scroll", be, { passive: !0 }), s.value.length > 0 && ($.value = de(h.value, c.value), G(s.value), V.value = f.value.scrollTop, U.value = f.value.clientHeight, M())));
1070
+ });
1071
+ }, { immediate: !0 }), ne(D, (e) => {
1072
+ e && (e.addEventListener("touchstart", De, { passive: !1 }), e.addEventListener("touchmove", Ae, { passive: !1 }), e.addEventListener("touchend", Oe), e.addEventListener("mousedown", Be));
1073
+ }), ne(() => s.value.length, (e, n) => {
1074
+ v.value && e > 0 && n === 0 && (m.value = 0, R(() => X()));
1075
+ }), ne(a, (e) => {
1076
+ w && (w.disconnect(), w = null), e && typeof ResizeObserver < "u" ? (w = new ResizeObserver((n) => {
1077
+ for (const r of n) {
1078
+ const p = r.contentRect.width;
1079
+ c.value !== p && (c.value = p);
1080
+ }
1081
+ }), w.observe(e), c.value = e.clientWidth) : e && (c.value = e.clientWidth);
1082
+ }, { immediate: !0 }), ne(c, (e, n) => {
1083
+ e !== n && e > 0 && !v.value && f.value && s.value.length > 0 && R(() => {
1084
+ $.value = de(h.value, e), G(s.value), M();
1085
+ });
1086
+ }), Ke(async () => {
978
1087
  try {
979
- h.value = ve(v.value), c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight);
980
- const o = s.loadAtPage;
981
- f.value = [o], s.skipInitialLoad || await R(f.value[0]), b();
982
- } catch (o) {
983
- console.error("Error during component initialization:", o), m.value = !1;
1088
+ await R(), a.value ? c.value = a.value.clientWidth : typeof window < "u" && (c.value = window.innerWidth), v.value || ($.value = de(h.value, c.value), f.value && (V.value = f.value.scrollTop, U.value = f.value.clientHeight));
1089
+ const e = l.loadAtPage;
1090
+ o.value = [e], l.skipInitialLoad || await ye(o.value[0]), v.value ? R(() => X()) : M();
1091
+ } catch (e) {
1092
+ console.error("Error during component initialization:", e), g.value = !1;
984
1093
  }
985
- (t = c.value) == null || t.addEventListener("scroll", be, { passive: !0 }), window.addEventListener("resize", xe);
986
- }), Ne(() => {
987
- var t;
988
- (t = c.value) == null || t.removeEventListener("scroll", be), window.removeEventListener("resize", xe);
989
- }), (t, o) => (D(), B("div", {
990
- class: Y(["overflow-auto w-full flex-1 masonry-container", { "force-motion": s.forceMotion }]),
991
- ref_key: "container",
992
- ref: c
1094
+ window.addEventListener("resize", We), window.addEventListener("resize", je);
1095
+ }), Qe(() => {
1096
+ var e;
1097
+ w && (w.disconnect(), w = null), (e = f.value) == null || e.removeEventListener("scroll", be), window.removeEventListener("resize", We), window.removeEventListener("resize", je), D.value && (D.value.removeEventListener("touchstart", De), D.value.removeEventListener("touchmove", Ae), D.value.removeEventListener("touchend", Oe), D.value.removeEventListener("mousedown", Be)), document.removeEventListener("mousemove", xe), document.removeEventListener("mouseup", Me);
1098
+ }), (e, n) => (B(), O("div", {
1099
+ ref_key: "wrapper",
1100
+ ref: a,
1101
+ class: "w-full h-full flex flex-col relative"
993
1102
  }, [
994
- S("div", {
995
- class: "relative",
996
- style: Re({ height: `${d.value}px`, "--masonry-duration": `${e.transitionDurationMs}ms`, "--masonry-leave-duration": `${e.leaveDurationMs}ms`, "--masonry-ease": e.transitionEasing })
1103
+ v.value ? (B(), O("div", {
1104
+ key: 0,
1105
+ class: Z(["overflow-hidden w-full flex-1 swipe-container touch-none select-none", { "force-motion": l.forceMotion, "cursor-grab": !y.value, "cursor-grabbing": y.value }]),
1106
+ ref_key: "swipeContainer",
1107
+ ref: D,
1108
+ style: { height: "100%", "max-height": "100%", position: "relative" }
1109
+ }, [
1110
+ A("div", {
1111
+ class: "relative w-full",
1112
+ style: Te({
1113
+ transform: `translateY(${L.value}px)`,
1114
+ transition: y.value ? "none" : `transform ${t.transitionDurationMs}ms ${t.transitionEasing}`,
1115
+ height: `${s.value.length * 100}%`
1116
+ })
1117
+ }, [
1118
+ (B(!0), O(Ce, null, qe(s.value, (r, p) => (B(), O("div", {
1119
+ key: `${r.page}-${r.id}`,
1120
+ class: "absolute top-0 left-0 w-full",
1121
+ style: Te({
1122
+ top: `${p * (100 / s.value.length)}%`,
1123
+ height: `${100 / s.value.length}%`
1124
+ })
1125
+ }, [
1126
+ A("div", ia, [
1127
+ A("div", sa, [
1128
+ Le(e.$slots, "default", {
1129
+ item: r,
1130
+ remove: ce
1131
+ }, () => [
1132
+ Ie(ge, {
1133
+ item: r,
1134
+ remove: ce
1135
+ }, null, 8, ["item"])
1136
+ ], !0)
1137
+ ])
1138
+ ])
1139
+ ], 4))), 128))
1140
+ ], 4)
1141
+ ], 2)) : (B(), O("div", {
1142
+ key: 1,
1143
+ class: Z(["overflow-auto w-full flex-1 masonry-container", { "force-motion": l.forceMotion }]),
1144
+ ref_key: "container",
1145
+ ref: f
997
1146
  }, [
998
- Te(_e, {
999
- name: "masonry",
1000
- css: !1,
1001
- onEnter: _,
1002
- onBeforeEnter: ae,
1003
- onLeave: K,
1004
- onBeforeLeave: ne
1005
- }, {
1006
- default: Ce(() => [
1007
- (D(!0), B(qe, null, Ve(oe.value, (u, p) => (D(), B("div", Ge({
1008
- key: `${u.page}-${u.id}`,
1009
- class: "absolute masonry-item",
1010
- ref_for: !0
1011
- }, Ue(Mt)(u, p), {
1012
- style: { paddingTop: `${v.value.header}px`, paddingBottom: `${v.value.footer}px` }
1013
- }), [
1014
- $e(t.$slots, "default", {
1015
- item: u,
1016
- remove: U
1017
- }, () => [
1018
- Te(pe, {
1019
- item: u,
1020
- remove: U
1021
- }, null, 8, ["item"])
1022
- ], !0)
1023
- ], 16))), 128))
1024
- ]),
1025
- _: 3
1026
- }),
1027
- d.value > 0 ? (D(), B("div", {
1028
- key: 0,
1029
- class: Y(["fixed bottom-4 right-4 bg-gray-800 text-white text-xs rounded-full px-3 py-1.5 shadow-lg z-10 transition-opacity duration-300", { "opacity-50 hover:opacity-100": !I.value.isNearTrigger, "opacity-100": I.value.isNearTrigger }])
1147
+ A("div", {
1148
+ class: "relative",
1149
+ style: Te({ height: `${E.value}px`, "--masonry-duration": `${t.transitionDurationMs}ms`, "--masonry-leave-duration": `${t.leaveDurationMs}ms`, "--masonry-ease": t.transitionEasing })
1030
1150
  }, [
1031
- S("span", null, ue(n.value.length) + " items", 1),
1032
- o[0] || (o[0] = S("span", { class: "mx-2" }, "|", -1)),
1033
- S("span", null, ue(I.value.distanceToTrigger) + "px to load", 1)
1034
- ], 2)) : X("", !0)
1035
- ], 4)
1036
- ], 2));
1151
+ Ie(mt, {
1152
+ name: "masonry",
1153
+ css: !1,
1154
+ onEnter: re,
1155
+ onBeforeEnter: q,
1156
+ onLeave: at,
1157
+ onBeforeLeave: tt
1158
+ }, {
1159
+ default: pt(() => [
1160
+ (B(!0), O(Ce, null, qe(nt.value, (r, p) => (B(), O("div", ht({
1161
+ key: `${r.page}-${r.id}`,
1162
+ class: "absolute masonry-item",
1163
+ ref_for: !0
1164
+ }, gt(Ut)(r, p), {
1165
+ style: { paddingTop: `${h.value.header}px`, paddingBottom: `${h.value.footer}px` }
1166
+ }), [
1167
+ Le(e.$slots, "default", {
1168
+ item: r,
1169
+ remove: ce
1170
+ }, () => [
1171
+ Ie(ge, {
1172
+ item: r,
1173
+ remove: ce
1174
+ }, null, 8, ["item"])
1175
+ ], !0)
1176
+ ], 16))), 128))
1177
+ ]),
1178
+ _: 3
1179
+ })
1180
+ ], 4)
1181
+ ], 2))
1182
+ ], 512));
1037
1183
  }
1038
- }), Bt = (e, r) => {
1039
- const l = e.__vccOpts || e;
1040
- for (const [s, w] of r)
1041
- l[s] = w;
1042
- return l;
1043
- }, Ee = /* @__PURE__ */ Bt(jt, [["__scopeId", "data-v-110c3294"]]), zt = {
1044
- install(e) {
1045
- e.component("WyxosMasonry", Ee), e.component("WMasonry", Ee), e.component("WyxosMasonryItem", pe), e.component("WMasonryItem", pe);
1184
+ }), ca = (t, i) => {
1185
+ const u = t.__vccOpts || t;
1186
+ for (const [l, I] of i)
1187
+ u[l] = I;
1188
+ return u;
1189
+ }, Xe = /* @__PURE__ */ ca(ua, [["__scopeId", "data-v-9c79a3fb"]]), va = {
1190
+ install(t) {
1191
+ t.component("WyxosMasonry", Xe), t.component("WMasonry", Xe), t.component("WyxosMasonryItem", ge), t.component("WMasonryItem", ge);
1046
1192
  }
1047
1193
  };
1048
1194
  export {
1049
- Ee as Masonry,
1050
- pe as MasonryItem,
1051
- zt as default
1195
+ Xe as Masonry,
1196
+ ge as MasonryItem,
1197
+ va as default
1052
1198
  };