@wyxos/vibe 1.6.11 → 1.6.12

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 k, computed as J, onMounted as Ke, onUnmounted as Qe, watch as le, createElementBlock as A, openBlock as O, renderSlot as $e, createElementVNode as W, createCommentVNode as Z, normalizeClass as K, toDisplayString as ce, withModifiers as dt, normalizeStyle as ke, Fragment as Ie, renderList as Ee, createVNode as Le, TransitionGroup as mt, withCtx as pt, mergeProps as ht, unref as gt } from "vue";
2
+ let Pe = null;
3
+ function yt() {
4
+ if (Pe != null) return Pe;
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 s = document.createElement("div");
8
+ s.style.width = "100%", t.appendChild(s);
9
+ const u = t.offsetWidth - s.offsetWidth;
10
+ return document.body.removeChild(t), Pe = u, u;
11
11
  }
12
- function Ye(e, r, l, s = {}) {
12
+ function wt(t, s, u, l = {}) {
13
13
  const {
14
- gutterX: w = 0,
15
- gutterY: v = 0,
16
- header: a = 0,
17
- footer: n = 0,
18
- paddingLeft: h = 0,
19
- paddingRight: c = 0,
20
- sizes: f = {
14
+ gutterX: I = 0,
15
+ gutterY: h = 0,
16
+ header: n = 0,
17
+ footer: c = 0,
18
+ paddingLeft: w = 0,
19
+ paddingRight: E = 0,
20
+ sizes: d = {
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 (s && s.nodeType === 1 && typeof window < "u" && window.getComputedStyle) {
33
+ const y = window.getComputedStyle(s);
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, r = (E || 0) + b, $ = s.offsetWidth - s.clientWidth, f = $ > 0 ? $ + 2 : yt() + 2, o = s.offsetWidth - f - P - r, p = I * (u - 1), g = Math.floor((o - p) / u), T = t.map((y) => {
39
+ const D = y.width, S = y.height;
40
+ return Math.round(g * S / D) + c + n;
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 = T.length;
44
+ if (y === 0) return [];
45
+ const D = (M, B, _) => M + (B > 0 ? h : 0) + _;
46
+ let S = Math.max(...T), z = T.reduce((M, B) => M + B, 0) + h * Math.max(0, y - 1);
47
+ const oe = (M) => {
48
+ let B = 1, _ = 0, te = 0;
49
+ for (let C = 0; C < y; C++) {
50
+ const ie = T[C], q = D(_, te, ie);
51
+ if (q <= M)
52
+ _ = q, te++;
53
+ else if (B++, _ = ie, te = 1, ie > M || B > u) return !1;
54
54
  }
55
- return F <= l;
55
+ return B <= u;
56
56
  };
57
- for (; L < _; ) {
58
- const x = Math.floor((L + _) / 2);
59
- ae(x) ? _ = x : L = x + 1;
57
+ for (; S < z; ) {
58
+ const M = Math.floor((S + z) / 2);
59
+ oe(M) ? z = 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 re = z, ae = new Array(u).fill(0);
62
+ let V = u - 1, U = 0, ne = 0;
63
+ for (let M = y - 1; M >= 0; M--) {
64
+ const B = T[M], _ = M < V;
65
+ !(D(U, ne, B) <= re) || _ ? (ae[V] = M + 1, V--, U = B, ne = 1) : (U = D(U, ne, B), ne++);
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
+ ae[0] = 0;
68
+ const Q = [], ee = new Array(u).fill(0);
69
+ for (let M = 0; M < u; M++) {
70
+ const B = ae[M], _ = M + 1 < u ? ae[M + 1] : y, te = M * (g + I);
71
+ for (let C = B; 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 = T[C] - (c + n), q.columnHeight = T[C], q.left = te, q.top = ee[M], ee[M] += q.columnHeight + (C + 1 < _ ? h : 0), Q.push(q);
81
81
  }
82
82
  }
83
- return C;
83
+ return Q;
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 v = new Array(u).fill(0), L = [];
86
+ for (let y = 0; y < t.length; y++) {
87
+ const D = t[y], S = {
88
+ ...D,
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
+ }, z = v.indexOf(Math.min(...v)), oe = D.width, re = D.height;
95
+ S.columnWidth = g, S.left = z * (g + I), S.imageHeight = Math.round(g * re / oe), S.columnHeight = S.imageHeight + c + n, S.top = v[z], v[z] += 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")(), ge = Ze.Symbol, et = Object.prototype, Mt = et.hasOwnProperty, Tt = et.toString, de = ge ? ge.toStringTag : void 0;
100
+ function kt(t) {
101
+ var s = Mt.call(t, de), u = t[de];
102
102
  try {
103
- e[se] = void 0;
104
- var s = !0;
103
+ t[de] = 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 && (s ? t[de] = u : delete t[de]), I;
109
109
  }
110
- var tt = Object.prototype, at = tt.toString;
111
- function nt(e) {
112
- return at.call(e);
110
+ var It = Object.prototype, Et = It.toString;
111
+ function Lt(t) {
112
+ return Et.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 = ge ? ge.toStringTag : void 0;
115
+ function $t(t) {
116
+ return t == null ? t === void 0 ? St : Pt : Ye && Ye in Object(t) ? kt(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 s = t.length; s-- && Dt.test(t.charAt(s)); )
128
128
  ;
129
- return r;
129
+ return s;
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 zt(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 He(t) {
136
+ var s = typeof t;
137
+ return t != null && (s == "object" || s == "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, Bt = /^[-+]0x[0-9a-f]+$/i, Ft = /^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 (He(t)) {
146
+ var s = typeof t.valueOf == "function" ? t.valueOf() : t;
147
+ t = He(s) ? s + "" : s;
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 = zt(t);
152
+ var u = Ft.test(t);
153
+ return u || jt.test(t) ? Rt(t.slice(2), u ? 2 : 8) : Bt.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 Se = function() {
156
+ return Ze.Date.now();
157
+ }, _t = "Expected a function", Ct = Math.max, qt = Math.min;
158
+ function Ge(t, s, u) {
159
+ var l, I, h, n, c, w, E = 0, d = !1, H = !1, N = !0;
160
+ if (typeof t != "function")
161
+ throw new TypeError(_t);
162
+ s = Ue(s) || 0, He(u) && (d = !!u.leading, H = "maxWait" in u, h = H ? Ct(Ue(u.maxWait) || 0, s) : h, N = "trailing" in u ? !!u.trailing : N);
163
+ function b(v) {
164
+ var L = l, y = I;
165
+ return l = I = void 0, E = v, n = t.apply(y, L), n;
166
166
  }
167
- function N(b) {
168
- return c = b, n = setTimeout(E, r), f ? d(b) : a;
167
+ function P(v) {
168
+ return E = v, c = setTimeout(f, s), d ? b(v) : n;
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 r(v) {
171
+ var L = v - w, y = v - E, D = s - L;
172
+ return H ? qt(D, h - y) : D;
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 $(v) {
175
+ var L = v - w, y = v - E;
176
+ return w === void 0 || L >= s || 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 v = Se();
180
+ if ($(v))
181
+ return o(v);
182
+ c = setTimeout(f, r(v));
183
183
  }
184
- function i(b) {
185
- return n = void 0, m && s ? d(b) : (s = w = void 0, a);
184
+ function o(v) {
185
+ return c = void 0, N && l ? b(v) : (l = I = void 0, n);
186
186
  }
187
- function g() {
188
- n !== void 0 && clearTimeout(n), c = 0, s = h = w = n = void 0;
187
+ function p() {
188
+ c !== void 0 && clearTimeout(c), E = 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 ? n : o(Se());
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 T() {
194
+ var v = Se(), L = $(v);
195
+ if (l = arguments, I = this, w = v, L) {
196
+ if (c === void 0)
197
+ return P(w);
198
+ if (H)
199
+ return clearTimeout(c), c = setTimeout(f, s), b(w);
200
200
  }
201
- return n === void 0 && (n = setTimeout(E, r)), a;
201
+ return c === void 0 && (c = setTimeout(f, s)), n;
202
202
  }
203
- return I.cancel = g, I.flush = M, I;
203
+ return T.cancel = p, T.flush = g, T;
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 me(t, s) {
206
+ const u = s ?? (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, s = 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": s
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 Ne(t, s) {
231
+ if (!t.length || s <= 0)
232
+ return new Array(Math.max(1, s)).fill(0);
233
+ const l = Array.from(new Set(t.map((n) => n.left))).sort((n, c) => n - c).slice(0, s), I = /* @__PURE__ */ new Map();
234
+ for (let n = 0; n < l.length; n++) I.set(l[n], n);
235
+ const h = new Array(l.length).fill(0);
236
+ for (const n of t) {
237
+ const c = I.get(n.left);
238
+ c != null && (h[c] = Math.max(h[c], n.top + n.columnHeight));
239
239
  }
240
- for (; v.length < r; ) v.push(0);
241
- return v;
240
+ for (; h.length < s; ) 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, s) {
244
+ function u(n, c) {
245
+ const w = parseInt(n.dataset.left || "0", 10), E = parseInt(n.dataset.top || "0", 10), d = parseInt(n.dataset.index || "0", 10), H = Math.min(d * 20, 160), N = n.style.getPropertyValue("--masonry-opacity-delay");
246
+ n.style.setProperty("--masonry-opacity-delay", `${H}ms`), requestAnimationFrame(() => {
247
+ n.style.opacity = "1", n.style.transform = `translate3d(${w}px, ${E}px, 0) scale(1)`;
248
+ const b = () => {
249
+ N ? n.style.setProperty("--masonry-opacity-delay", N) : n.style.removeProperty("--masonry-opacity-delay"), n.removeEventListener("transitionend", b), c();
250
250
  };
251
- a.addEventListener("transitionend", d);
251
+ n.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(n) {
255
+ const c = parseInt(n.dataset.left || "0", 10), w = parseInt(n.dataset.top || "0", 10);
256
+ n.style.opacity = "0", n.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(() => {
261
- a.style.transition = "";
258
+ function I(n) {
259
+ const c = parseInt(n.dataset.left || "0", 10), w = parseInt(n.dataset.top || "0", 10);
260
+ n.style.transition = "none", n.style.opacity = "1", n.style.transform = `translate3d(${c}px, ${w}px, 0) scale(1)`, n.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
261
+ n.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(n, c) {
265
+ const w = parseInt(n.dataset.left || "0", 10), E = parseInt(n.dataset.top || "0", 10), d = typeof (s == null ? void 0 : s.leaveDurationMs) == "number" ? s.leaveDurationMs : NaN;
266
+ let H = Number.isFinite(d) && d > 0 ? d : NaN;
267
+ if (!Number.isFinite(H)) {
268
+ const f = getComputedStyle(n).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 = n.style.transitionDuration, b = () => {
272
+ n.removeEventListener("transitionend", P), clearTimeout(r), n.style.transitionDuration = N || "";
273
+ }, P = ($) => {
274
+ (!$ || $.target === n) && (b(), c());
275
+ }, r = 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
+ n.style.transitionDuration = `${H}ms`, n.style.opacity = "0", n.style.transform = `translate3d(${w}px, ${E + 10}px, 0) scale(0.985)`, n.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,
296
- refreshLayout: a,
297
- setItemsRaw: n,
298
- loadNext: h,
299
- loadThresholdPx: c
289
+ function Xt({
290
+ container: t,
291
+ masonry: s,
292
+ columns: u,
293
+ containerHeight: l,
294
+ isLoading: I,
295
+ pageSize: h,
296
+ refreshLayout: n,
297
+ setItemsRaw: c,
298
+ loadNext: w,
299
+ loadThresholdPx: E
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 d = 0;
302
+ async function H(N) {
303
+ if (!t.value) return;
304
+ const b = N ?? Ne(s.value, u.value), P = b.length ? Math.max(...b) : 0, r = t.value.scrollTop + t.value.clientHeight, $ = t.value.scrollTop > d + 1;
305
+ d = t.value.scrollTop;
306
+ const f = typeof E == "number" ? E : 200, o = f >= 0 ? Math.max(0, P - f) : Math.max(0, P + f);
307
+ if (r >= 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" }, ye = /* @__PURE__ */ Je({
329
329
  __name: "MasonryItem",
330
330
  props: {
331
331
  item: {},
@@ -333,208 +333,211 @@ 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 s = t, u = k(!1), l = k(!1), I = k(null), h = k(!1), n = k(!1), c = k(null), w = k(!1), E = k(!1), d = k(!1), H = k(null);
338
+ let N = null;
339
+ const b = J(() => {
340
+ var o;
341
+ return s.type ?? ((o = s.item) == null ? void 0 : o.type) ?? "image";
342
+ }), P = J(() => {
343
+ var o;
344
+ return s.notFound ?? ((o = s.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 r(o) {
347
+ return new Promise((p, 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 T = new Image(), v = Date.now(), L = 300;
353
+ T.onload = () => {
354
+ const y = Date.now() - v, D = 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, E.value = !1, await R(), await new Promise((S) => setTimeout(S, 100)), d.value = !0, p();
357
+ }, D);
358
+ }, T.onerror = () => {
359
+ l.value = !0, u.value = !1, E.value = !1, g(new Error("Failed to load image"));
360
+ }, T.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((p, 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 T = document.createElement("video"), v = Date.now(), L = 300;
370
+ T.preload = "metadata", T.muted = !0, T.onloadedmetadata = () => {
371
+ const y = Date.now() - v, D = 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, n.value = !1, E.value = !1, await R(), await new Promise((S) => setTimeout(S, 100)), d.value = !0, p();
374
+ }, D);
375
+ }, T.onerror = () => {
376
+ n.value = !0, h.value = !1, E.value = !1, g(new Error("Failed to load video"));
377
+ }, T.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 p;
382
+ if (!w.value || E.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 = (p = s.item) == null ? void 0 : p.src;
385
+ if (o)
386
+ if (E.value = !0, d.value = !1, b.value === "video") {
387
+ c.value = o, h.value = !1, n.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 r(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((p) => {
404
+ p.isIntersecting && p.intersectionRatio >= 1 ? w.value || (w.value = !0, f()) : p.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
+ }), le(
415
415
  () => {
416
- var i;
417
- return (i = r.item) == null ? void 0 : i.src;
416
+ var o;
417
+ return (o = s.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, n.value = !1, c.value = o, w.value)) {
423
+ E.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
+ E.value = !0;
431
431
  try {
432
- await z(i);
432
+ await r(o);
433
433
  } catch {
434
434
  }
435
435
  }
436
436
  }
437
437
  }
438
- ), (i, g) => (D(), B("div", {
438
+ ), (o, p) => (O(), A("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,
449
- videoError: a.value,
450
- showNotFound: N.value,
451
- isLoading: c.value,
452
- mediaType: d.value
443
+ $e(o.$slots, "default", {
444
+ item: o.item,
445
+ remove: o.remove,
446
+ imageLoaded: u.value,
447
+ imageError: l.value,
448
+ videoLoaded: h.value,
449
+ videoError: n.value,
450
+ showNotFound: P.value,
451
+ isLoading: E.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
+ W("div", Jt, [
455
+ P.value ? (O(), A("div", Kt, p[4] || (p[4] = [
456
+ W("i", { class: "fas fa-search text-3xl mb-3 opacity-50" }, null, -1),
457
+ W("span", { class: "font-medium" }, "Not Found", -1),
458
+ W("span", { class: "text-xs mt-1 opacity-75" }, "This item could not be located", -1)
459
+ ]))) : (O(), A("div", Qt, [
460
+ b.value === "image" && I.value ? (O(), A("img", {
461
461
  key: 0,
462
- src: w.value,
463
- class: Y([
462
+ src: I.value,
463
+ class: K([
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 && d.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)) : Z("", !0),
472
+ b.value === "video" && c.value ? (O(), A("video", {
473
473
  key: 1,
474
- src: n.value,
475
- class: Y([
474
+ src: c.value,
475
+ class: K([
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 && d.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: p[0] || (p[0] = (g) => g.target.play()),
484
+ onMouseleave: p[1] || (p[1] = (g) => g.target.pause()),
485
+ onError: p[2] || (p[2] = (g) => n.value = !0)
486
+ }, null, 42, ea)) : Z("", !0),
487
+ !u.value && !h.value && !l.value && !n.value ? (O(), A("div", {
488
488
  key: 2,
489
- class: Y([
489
+ class: K([
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
+ d.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
+ W("div", ta, [
495
+ W("i", {
496
+ class: K(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)) : Z("", !0),
500
+ E.value ? (O(), A("div", aa, p[5] || (p[5] = [
501
+ W("div", { class: "bg-white/90 backdrop-blur-sm rounded-full px-3 py-1.5 shadow-sm" }, [
502
+ W("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
+ ]))) : Z("", !0),
505
+ b.value === "image" && l.value || b.value === "video" && n.value ? (O(), A("div", na, [
506
+ W("i", {
507
+ class: K(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
+ W("span", null, "Failed to load " + ce(b.value), 1)
510
+ ])) : Z("", !0)
511
511
  ])),
512
- !N.value && (l.value || v.value || c.value) ? (D(), B("div", {
512
+ !P.value && (u.value || h.value || E.value) ? (O(), A("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
+ W("i", {
518
+ class: K(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)) : Z("", !0),
521
+ p[7] || (p[7] = W("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 ? (O(), A("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: p[3] || (p[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
+ }, p[6] || (p[6] = [
528
+ W("i", { class: "fas fa-times text-sm" }, null, -1)
529
+ ]))) : Z("", !0),
530
+ W("div", oa, [
531
+ W("p", ra, "Item #" + ce(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 = {
538
+ key: 0,
539
+ class: "fixed bottom-4 left-1/2 transform -translate-x-1/2 flex gap-2 z-10 pointer-events-none"
540
+ }, ca = { class: "fixed top-20 right-4 bg-black/50 backdrop-blur-sm text-white text-xs font-medium px-3 py-1.5 rounded-full z-20 pointer-events-none" }, fa = /* @__PURE__ */ Je({
538
541
  __name: "Masonry",
539
542
  props: {
540
543
  getNextPage: {
@@ -557,7 +560,7 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
557
560
  type: String,
558
561
  default: "page",
559
562
  // or 'cursor'
560
- validator: (e) => ["page", "cursor"].includes(e)
563
+ validator: (t) => ["page", "cursor"].includes(t)
561
564
  },
562
565
  skipInitialLoad: {
563
566
  type: Boolean,
@@ -622,6 +625,18 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
622
625
  autoRefreshOnEmpty: {
623
626
  type: Boolean,
624
627
  default: !1
628
+ },
629
+ // Layout mode: 'auto' (detect from screen size), 'masonry', or 'swipe'
630
+ layoutMode: {
631
+ type: String,
632
+ default: "auto",
633
+ validator: (t) => ["auto", "masonry", "swipe"].includes(t)
634
+ },
635
+ // Breakpoint for switching to swipe mode (in pixels or Tailwind breakpoint name)
636
+ mobileBreakpoint: {
637
+ type: [Number, String],
638
+ default: 768
639
+ // 'md' breakpoint
625
640
  }
626
641
  },
627
642
  emits: [
@@ -634,8 +649,8 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
634
649
  "retry:stop",
635
650
  "remove-all:complete"
636
651
  ],
637
- setup(e, { expose: r, emit: l }) {
638
- const s = e, w = {
652
+ setup(t, { expose: s, emit: u }) {
653
+ const l = t, I = {
639
654
  sizes: { base: 1, sm: 2, md: 3, lg: 4, xl: 5, "2xl": 6 },
640
655
  gutterX: 10,
641
656
  gutterY: 10,
@@ -644,41 +659,69 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
644
659
  paddingLeft: 0,
645
660
  paddingRight: 0,
646
661
  placement: "masonry"
647
- }, v = te(() => {
648
- var t;
662
+ }, h = J(() => {
663
+ var e;
649
664
  return {
650
- ...w,
651
- ...s.layout,
665
+ ...I,
666
+ ...l.layout,
652
667
  sizes: {
653
- ...w.sizes,
654
- ...((t = s.layout) == null ? void 0 : t.sizes) || {}
668
+ ...I.sizes,
669
+ ...((e = l.layout) == null ? void 0 : e.sizes) || {}
655
670
  }
656
671
  };
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;
672
+ }), n = k(null), c = k(typeof window < "u" ? window.innerWidth : 1024);
673
+ let w = null;
674
+ function E(e) {
675
+ return {
676
+ sm: 640,
677
+ md: 768,
678
+ lg: 1024,
679
+ xl: 1280,
680
+ "2xl": 1536
681
+ }[e] || 768;
663
682
  }
664
- function $(t, o) {
683
+ const d = J(() => {
684
+ if (l.layoutMode === "masonry") return !1;
685
+ if (l.layoutMode === "swipe") return !0;
686
+ const e = typeof l.mobileBreakpoint == "string" ? E(l.mobileBreakpoint) : l.mobileBreakpoint;
687
+ return c.value < e;
688
+ }), H = J(() => {
689
+ if (!d.value || r.value.length === 0) return null;
690
+ const e = Math.max(0, Math.min(v.value, r.value.length - 1));
691
+ return r.value[e] || null;
692
+ }), N = J(() => {
693
+ if (!d.value || !H.value) return null;
694
+ const e = v.value + 1;
695
+ return e >= r.value.length ? null : r.value[e] || null;
696
+ }), b = J(() => {
697
+ if (!d.value || !H.value) return null;
698
+ const e = v.value - 1;
699
+ return e < 0 ? null : r.value[e] || null;
700
+ }), P = u, r = J({
701
+ get: () => l.items,
702
+ set: (e) => P("update:items", e)
703
+ }), $ = k(7), f = k(null), o = k([]), p = k(null), g = k(!1), T = k(0), v = k(0), L = k(0), y = k(!1), D = k(0), S = k(0), z = k(null), oe = k(/* @__PURE__ */ new Set());
704
+ function re(e) {
705
+ return typeof e == "number" && Number.isFinite(e) && e > 0;
706
+ }
707
+ function ae(e, a) {
665
708
  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;
669
- 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));
709
+ if (!Array.isArray(e) || e.length === 0) return;
710
+ const i = e.filter((x) => !re(x == null ? void 0 : x.width) || !re(x == null ? void 0 : x.height));
711
+ if (i.length === 0) return;
712
+ const m = [];
713
+ for (const x of i) {
714
+ const j = (x == null ? void 0 : x.id) ?? `idx:${e.indexOf(x)}`;
715
+ oe.value.has(j) || (oe.value.add(j), m.push(j));
673
716
  }
674
- if (p.length > 0) {
675
- const y = p.slice(0, 10);
717
+ if (m.length > 0) {
718
+ const x = m.slice(0, 10);
676
719
  console.warn(
677
720
  "[Masonry] Items missing width/height detected:",
678
721
  {
679
- context: o,
680
- count: p.length,
681
- sampleIds: y,
722
+ context: a,
723
+ count: m.length,
724
+ sampleIds: x,
682
725
  hint: "Ensure each item has positive width and height. Consider providing fallbacks (e.g., 512x512) at the data layer."
683
726
  }
684
727
  );
@@ -686,367 +729,488 @@ const kt = { class: "w-full h-full rounded-xl overflow-hidden shadow-sm hover:sh
686
729
  } catch {
687
730
  }
688
731
  }
689
- const E = k(0), i = k(0), g = s.virtualBufferPx, M = k(!1), I = k({
732
+ const V = k(0), U = k(0), ne = l.virtualBufferPx, Q = k(!1), ee = k({
690
733
  distanceToTrigger: 0,
691
734
  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
735
+ }), M = (e) => {
736
+ if (!f.value) return;
737
+ const { scrollTop: a, clientHeight: i } = f.value, m = a + i, x = e ?? Ne(r.value, $.value), j = x.length ? Math.max(...x) : 0, Y = typeof l.loadThresholdPx == "number" ? l.loadThresholdPx : 200, ue = Y >= 0 ? Math.max(0, j - Y) : Math.max(0, j + Y), qe = Math.max(0, ue - m), vt = qe <= 100;
738
+ ee.value = {
739
+ distanceToTrigger: Math.round(qe),
740
+ isNearTrigger: vt
698
741
  };
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();
742
+ }, { onEnter: B, onBeforeEnter: _, onBeforeLeave: te, onLeave: C } = Gt(r, { leaveDurationMs: l.leaveDurationMs });
743
+ function ie(e, a) {
744
+ if (Q.value) {
745
+ const i = parseInt(e.dataset.left || "0", 10), m = parseInt(e.dataset.top || "0", 10);
746
+ e.style.transition = "none", e.style.opacity = "1", e.style.transform = `translate3d(${i}px, ${m}px, 0) scale(1)`, e.style.removeProperty("--masonry-opacity-delay"), requestAnimationFrame(() => {
747
+ e.style.transition = "", a();
705
748
  });
706
749
  } else
707
- A(t, o);
750
+ B(e, a);
708
751
  }
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");
752
+ function q(e) {
753
+ if (Q.value) {
754
+ const a = parseInt(e.dataset.left || "0", 10), i = parseInt(e.dataset.top || "0", 10);
755
+ e.style.transition = "none", e.style.opacity = "1", e.style.transform = `translate3d(${a}px, ${i}px, 0) scale(1)`, e.style.removeProperty("--masonry-opacity-delay");
713
756
  } else
714
- P(t);
757
+ _(e);
715
758
  }
716
- function ne(t) {
717
- M.value || H(t);
759
+ function tt(e) {
760
+ Q.value || te(e);
718
761
  }
719
- function K(t, o) {
720
- M.value ? o() : L(t, o);
762
+ function at(e, a) {
763
+ Q.value ? a() : C(e, a);
721
764
  }
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;
765
+ const nt = J(() => {
766
+ const e = V.value - ne, a = V.value + U.value + ne, i = r.value;
767
+ return !i || i.length === 0 ? [] : i.filter((m) => {
768
+ const x = m.top;
769
+ return m.top + m.columnHeight >= e && x <= a;
727
770
  });
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;
771
+ }), { handleScroll: lt } = Xt({
772
+ container: f,
773
+ masonry: r,
774
+ columns: $,
775
+ containerHeight: T,
776
+ isLoading: g,
777
+ pageSize: l.pageSize,
778
+ refreshLayout: G,
779
+ setItemsRaw: (e) => {
780
+ r.value = e;
738
781
  },
739
- loadNext: q,
740
- loadThresholdPx: s.loadThresholdPx
782
+ loadNext: se,
783
+ loadThresholdPx: l.loadThresholdPx
741
784
  });
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)
785
+ s({
786
+ isLoading: g,
787
+ refreshLayout: G,
788
+ containerHeight: T,
789
+ remove: fe,
790
+ removeMany: it,
791
+ removeAll: st,
792
+ loadNext: se,
793
+ loadPage: we,
794
+ refreshCurrentPage: be,
795
+ reset: ct,
796
+ init: ft,
797
+ paginationHistory: o,
798
+ cancelLoad: Ae,
799
+ scrollToTop: De,
800
+ totalItems: J(() => r.value.length)
758
801
  });
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;
802
+ function ot(e) {
803
+ const a = Yt(e);
804
+ let i = 0;
805
+ if (f.value) {
806
+ const { scrollTop: m, clientHeight: x } = f.value;
807
+ i = m + x + 100;
765
808
  }
766
- d.value = Math.max(o, u);
809
+ T.value = Math.max(a, i);
767
810
  }
768
- function C(t) {
769
- if (!c.value) return;
770
- $(t, "refreshLayout");
771
- const o = t.map((p, y) => ({
772
- ...p,
773
- originalIndex: p.originalIndex ?? y
774
- })), u = Ye(o, c.value, h.value, v.value);
775
- Z(u), n.value = u;
811
+ function G(e) {
812
+ if (d.value) {
813
+ r.value = e;
814
+ return;
815
+ }
816
+ if (!f.value) return;
817
+ ae(e, "refreshLayout");
818
+ const a = e.map((m, x) => ({
819
+ ...m,
820
+ originalIndex: m.originalIndex ?? x
821
+ })), i = wt(a, f.value, $.value, h.value);
822
+ ot(i), r.value = i;
776
823
  }
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);
824
+ function We(e, a) {
825
+ return new Promise((i) => {
826
+ const m = Math.max(0, e | 0), x = Date.now();
827
+ a(m, m);
781
828
  const j = setInterval(() => {
782
- if (W.value) {
783
- clearInterval(j), u();
829
+ if (F.value) {
830
+ clearInterval(j), i();
784
831
  return;
785
832
  }
786
- const G = Date.now() - y, ee = Math.max(0, p - G);
787
- o(ee, p), ee <= 0 && (clearInterval(j), u());
833
+ const Y = Date.now() - x, ue = Math.max(0, m - Y);
834
+ a(ue, m), ue <= 0 && (clearInterval(j), i());
788
835
  }, 100);
789
836
  });
790
837
  }
791
- async function x(t) {
838
+ async function pe(e) {
792
839
  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;
840
+ const a = await rt(() => l.getNextPage(e));
841
+ return G([...r.value, ...a.items]), a;
842
+ } catch (a) {
843
+ throw console.error("Error in getContent:", a), a;
797
844
  }
798
845
  }
799
- async function F(t) {
800
- let o = 0;
801
- const u = s.retryMaxAttempts;
802
- let p = s.retryInitialDelayMs;
846
+ async function rt(e) {
847
+ let a = 0;
848
+ const i = l.retryMaxAttempts;
849
+ let m = l.retryInitialDelayMs;
803
850
  for (; ; )
804
851
  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;
852
+ const x = await e();
853
+ return a > 0 && P("retry:stop", { attempt: a, success: !0 }), x;
854
+ } catch (x) {
855
+ if (a++, a > i)
856
+ throw P("retry:stop", { attempt: a - 1, success: !1 }), x;
857
+ P("retry:start", { attempt: a, max: i, totalMs: m }), await We(m, (j, Y) => {
858
+ P("retry:tick", { attempt: a, remainingMs: j, totalMs: Y });
859
+ }), m += l.retryBackoffStepMs;
813
860
  }
814
861
  }
815
- async function R(t) {
816
- if (!m.value) {
817
- W.value = !1, m.value = !0;
862
+ async function we(e) {
863
+ if (!g.value) {
864
+ F.value = !1, g.value = !0;
818
865
  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;
866
+ const a = r.value.length;
867
+ if (F.value) return;
868
+ const i = await pe(e);
869
+ return F.value ? void 0 : (p.value = e, o.value.push(i.nextPage), await ve(a), i);
870
+ } catch (a) {
871
+ throw console.error("Error loading page:", a), a;
825
872
  } finally {
826
- m.value = !1;
873
+ g.value = !1;
827
874
  }
828
875
  }
829
876
  }
830
- async function q() {
831
- if (!m.value) {
832
- W.value = !1, m.value = !0;
877
+ async function se() {
878
+ if (!g.value) {
879
+ F.value = !1, g.value = !0;
833
880
  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;
881
+ const e = r.value.length;
882
+ if (F.value) return;
883
+ const a = o.value[o.value.length - 1], i = await pe(a);
884
+ return F.value ? void 0 : (p.value = a, o.value.push(i.nextPage), await ve(e), i);
885
+ } catch (e) {
886
+ throw console.error("Error loading next page:", e), e;
840
887
  } finally {
841
- m.value = !1;
888
+ g.value = !1;
842
889
  }
843
890
  }
844
891
  }
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;
892
+ async function be() {
893
+ if (console.log("[Masonry] refreshCurrentPage called, isLoading:", g.value, "currentPage:", p.value), !g.value) {
894
+ F.value = !1, g.value = !0;
848
895
  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);
896
+ const e = p.value;
897
+ if (console.log("[Masonry] pageToRefresh:", e), e == null) {
898
+ console.warn("[Masonry] No current page to refresh - currentPage:", p.value, "paginationHistory:", o.value);
852
899
  return;
853
900
  }
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;
901
+ r.value = [], T.value = 0, o.value = [e], await R();
902
+ const a = await pe(e);
903
+ if (F.value) return;
904
+ p.value = e, o.value.push(a.nextPage);
905
+ const i = r.value.length;
906
+ return await ve(i), a;
907
+ } catch (e) {
908
+ throw console.error("[Masonry] Error refreshing current page:", e), e;
862
909
  } finally {
863
- m.value = !1;
910
+ g.value = !1;
864
911
  }
865
912
  }
866
913
  }
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();
914
+ async function fe(e) {
915
+ const a = r.value.filter((i) => i.id !== e.id);
916
+ if (r.value = a, await R(), console.log("[Masonry] remove - next.length:", a.length, "paginationHistory.length:", o.value.length), a.length === 0 && o.value.length > 0) {
917
+ if (l.autoRefreshOnEmpty)
918
+ console.log("[Masonry] All items removed, calling refreshCurrentPage"), await be();
872
919
  else {
873
920
  console.log("[Masonry] All items removed, calling loadNext and forcing backfill");
874
921
  try {
875
- await q(), await le(0, !0);
922
+ await se(), await ve(0, !0);
876
923
  } catch {
877
924
  }
878
925
  }
879
926
  return;
880
927
  }
881
- await new Promise((u) => requestAnimationFrame(() => u())), requestAnimationFrame(() => {
882
- C(o);
928
+ await new Promise((i) => requestAnimationFrame(() => i())), requestAnimationFrame(() => {
929
+ G(a);
883
930
  });
884
931
  }
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();
932
+ async function it(e) {
933
+ if (!e || e.length === 0) return;
934
+ const a = new Set(e.map((m) => m.id)), i = r.value.filter((m) => !a.has(m.id));
935
+ if (r.value = i, await R(), i.length === 0 && o.value.length > 0) {
936
+ if (l.autoRefreshOnEmpty)
937
+ await be();
891
938
  else
892
939
  try {
893
- await q(), await le(0, !0);
940
+ await se(), await ve(0, !0);
894
941
  } catch {
895
942
  }
896
943
  return;
897
944
  }
898
- await new Promise((p) => requestAnimationFrame(() => p())), requestAnimationFrame(() => {
899
- C(u);
945
+ await new Promise((m) => requestAnimationFrame(() => m())), requestAnimationFrame(() => {
946
+ G(i);
900
947
  });
901
948
  }
902
- function ye(t) {
903
- c.value && c.value.scrollTo({
949
+ function De(e) {
950
+ f.value && f.value.scrollTo({
904
951
  top: 0,
905
- behavior: (t == null ? void 0 : t.behavior) ?? "smooth",
906
- ...t
952
+ behavior: (e == null ? void 0 : e.behavior) ?? "smooth",
953
+ ...e
907
954
  });
908
955
  }
909
- async function We() {
910
- ye({ behavior: "smooth" }), n.value = [], d.value = 0, await J(), a("remove-all:complete");
956
+ async function st() {
957
+ De({ behavior: "smooth" }), r.value = [], T.value = 0, await R(), P("remove-all:complete");
911
958
  }
912
- function Oe() {
913
- h.value = ve(v.value), C(n.value), c.value && (E.value = c.value.scrollTop, i.value = c.value.clientHeight);
959
+ function ut() {
960
+ $.value = me(h.value), G(r.value), f.value && (V.value = f.value.scrollTop, U.value = f.value.clientHeight);
914
961
  }
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;
962
+ let he = !1;
963
+ const F = k(!1);
964
+ async function ve(e, a = !1) {
965
+ if (!a && !l.backfillEnabled || he || F.value) return;
966
+ const i = (e || 0) + (l.pageSize || 0);
967
+ if (!(!l.pageSize || l.pageSize <= 0 || o.value[o.value.length - 1] == null) && !(r.value.length >= i)) {
968
+ he = !0;
922
969
  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
970
+ let x = 0;
971
+ for (P("backfill:start", { target: i, fetched: r.value.length, calls: x }); r.value.length < i && x < l.backfillMaxCalls && o.value[o.value.length - 1] != null && !F.value && (await We(l.backfillDelayMs, (Y, ue) => {
972
+ P("backfill:tick", {
973
+ fetched: r.value.length,
974
+ target: i,
975
+ calls: x,
976
+ remainingMs: Y,
977
+ totalMs: ue
931
978
  });
932
- }), !W.value); ) {
933
- const j = f.value[f.value.length - 1];
979
+ }), !F.value); ) {
980
+ const j = o.value[o.value.length - 1];
934
981
  try {
935
- m.value = !0;
936
- const G = await x(j);
937
- if (W.value) break;
938
- f.value.push(G.nextPage);
982
+ g.value = !0;
983
+ const Y = await pe(j);
984
+ if (F.value) break;
985
+ o.value.push(Y.nextPage);
939
986
  } finally {
940
- m.value = !1;
987
+ g.value = !1;
941
988
  }
942
- y++;
989
+ x++;
943
990
  }
944
- a("backfill:stop", { fetched: n.value.length, calls: y });
991
+ P("backfill:stop", { fetched: r.value.length, calls: x });
945
992
  } finally {
946
- ie = !1;
993
+ he = !1;
947
994
  }
948
995
  }
949
996
  }
950
- function he() {
951
- W.value = !0, m.value = !1, ie = !1;
997
+ function Ae() {
998
+ F.value = !0, g.value = !1, he = !1;
952
999
  }
953
- function je() {
954
- he(), W.value = !1, c.value && c.value.scrollTo({
1000
+ function ct() {
1001
+ Ae(), F.value = !1, f.value && f.value.scrollTo({
955
1002
  top: 0,
956
1003
  behavior: "smooth"
957
- }), n.value = [], d.value = 0, T.value = s.loadAtPage, f.value = [s.loadAtPage], I.value = {
1004
+ }), r.value = [], T.value = 0, p.value = l.loadAtPage, o.value = [l.loadAtPage], ee.value = {
958
1005
  distanceToTrigger: 0,
959
1006
  isNearTrigger: !1
960
1007
  };
961
1008
  }
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();
1009
+ const xe = Ge(async () => {
1010
+ if (d.value) return;
1011
+ f.value && (V.value = f.value.scrollTop, U.value = f.value.clientHeight), Q.value = !0, await R(), await new Promise((a) => requestAnimationFrame(() => a())), Q.value = !1;
1012
+ const e = Ne(r.value, $.value);
1013
+ lt(e), M(e);
1014
+ }, 200), Oe = Ge(ut, 200);
1015
+ function ze(e) {
1016
+ d.value && (y.value = !0, D.value = e.touches[0].clientY, S.value = L.value, e.preventDefault());
1017
+ }
1018
+ function Be(e) {
1019
+ if (!d.value || !y.value) return;
1020
+ const a = e.touches[0].clientY - D.value;
1021
+ L.value = S.value + a, e.preventDefault();
1022
+ }
1023
+ function Fe(e) {
1024
+ if (!d.value || !y.value) return;
1025
+ y.value = !1;
1026
+ const a = L.value - S.value;
1027
+ Math.abs(a) > 100 ? a > 0 && b.value ? _e() : a < 0 && N.value ? Re() : X() : X(), e.preventDefault();
1028
+ }
1029
+ function je(e) {
1030
+ d.value && (y.value = !0, D.value = e.clientY, S.value = L.value, e.preventDefault());
1031
+ }
1032
+ function Me(e) {
1033
+ if (!d.value || !y.value) return;
1034
+ const a = e.clientY - D.value;
1035
+ L.value = S.value + a, e.preventDefault();
1036
+ }
1037
+ function Te(e) {
1038
+ if (!d.value || !y.value) return;
1039
+ y.value = !1;
1040
+ const a = L.value - S.value;
1041
+ Math.abs(a) > 100 ? a > 0 && b.value ? _e() : a < 0 && N.value ? Re() : X() : X(), e.preventDefault();
969
1042
  }
970
- return He(
971
- v,
1043
+ function Re() {
1044
+ if (!N.value) {
1045
+ se();
1046
+ return;
1047
+ }
1048
+ v.value++, X(), v.value >= r.value.length - 5 && se();
1049
+ }
1050
+ function _e() {
1051
+ b.value && (v.value--, X());
1052
+ }
1053
+ function X() {
1054
+ if (!z.value) return;
1055
+ const e = z.value.clientHeight;
1056
+ L.value = -v.value * e;
1057
+ }
1058
+ function Ce() {
1059
+ n.value ? c.value = n.value.clientWidth : typeof window < "u" && (c.value = window.innerWidth), !d.value && v.value > 0 && (v.value = 0, L.value = 0), d.value && r.value.length === 0 && !g.value && we(o.value[0]), d.value && X();
1060
+ }
1061
+ function ft(e, a, i) {
1062
+ p.value = a, o.value = [a], o.value.push(i), ae(e, "init"), d.value ? (r.value = [...r.value, ...e], v.value === 0 && r.value.length > 0 && (L.value = 0)) : (G([...r.value, ...e]), M());
1063
+ }
1064
+ return le(
1065
+ h,
972
1066
  () => {
973
- c.value && (h.value = ve(v.value), C(n.value));
1067
+ d.value || f.value && ($.value = me(h.value, c.value), G(r.value));
974
1068
  },
975
1069
  { deep: !0 }
976
- ), Se(async () => {
977
- var t;
1070
+ ), le(d, (e) => {
1071
+ R(() => {
1072
+ e ? (document.addEventListener("mousemove", Me), document.addEventListener("mouseup", Te), v.value = 0, L.value = 0, r.value.length > 0 && X()) : (document.removeEventListener("mousemove", Me), document.removeEventListener("mouseup", Te), f.value && n.value && (c.value = n.value.clientWidth, f.value.removeEventListener("scroll", xe), f.value.addEventListener("scroll", xe, { passive: !0 }), r.value.length > 0 && ($.value = me(h.value, c.value), G(r.value), V.value = f.value.scrollTop, U.value = f.value.clientHeight, M())));
1073
+ });
1074
+ }, { immediate: !0 }), le(z, (e) => {
1075
+ e && (e.addEventListener("touchstart", ze, { passive: !1 }), e.addEventListener("touchmove", Be, { passive: !1 }), e.addEventListener("touchend", Fe), e.addEventListener("mousedown", je));
1076
+ }), le(() => r.value.length, (e, a) => {
1077
+ d.value && e > 0 && a === 0 && (v.value = 0, R(() => X()));
1078
+ }), le(n, (e) => {
1079
+ w && (w.disconnect(), w = null), e && typeof ResizeObserver < "u" ? (w = new ResizeObserver((a) => {
1080
+ for (const i of a) {
1081
+ const m = i.contentRect.width;
1082
+ c.value !== m && (c.value = m);
1083
+ }
1084
+ }), w.observe(e), c.value = e.clientWidth) : e && (c.value = e.clientWidth);
1085
+ }, { immediate: !0 }), le(c, (e, a) => {
1086
+ e !== a && e > 0 && !d.value && f.value && r.value.length > 0 && R(() => {
1087
+ $.value = me(h.value, e), G(r.value), M();
1088
+ });
1089
+ }), Ke(async () => {
978
1090
  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;
1091
+ await R(), n.value ? c.value = n.value.clientWidth : typeof window < "u" && (c.value = window.innerWidth), d.value || ($.value = me(h.value, c.value), f.value && (V.value = f.value.scrollTop, U.value = f.value.clientHeight));
1092
+ const e = l.loadAtPage;
1093
+ o.value = [e], l.skipInitialLoad || await we(o.value[0]), d.value ? R(() => X()) : M();
1094
+ } catch (e) {
1095
+ console.error("Error during component initialization:", e), g.value = !1;
984
1096
  }
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
1097
+ window.addEventListener("resize", Oe), window.addEventListener("resize", Ce);
1098
+ }), Qe(() => {
1099
+ var e;
1100
+ w && (w.disconnect(), w = null), (e = f.value) == null || e.removeEventListener("scroll", xe), window.removeEventListener("resize", Oe), window.removeEventListener("resize", Ce), z.value && (z.value.removeEventListener("touchstart", ze), z.value.removeEventListener("touchmove", Be), z.value.removeEventListener("touchend", Fe), z.value.removeEventListener("mousedown", je)), document.removeEventListener("mousemove", Me), document.removeEventListener("mouseup", Te);
1101
+ }), (e, a) => (O(), A("div", {
1102
+ ref_key: "wrapper",
1103
+ ref: n,
1104
+ class: "w-full h-full flex flex-col relative"
993
1105
  }, [
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 })
1106
+ d.value ? (O(), A("div", {
1107
+ key: 0,
1108
+ class: K(["overflow-hidden w-full flex-1 swipe-container touch-none select-none", { "force-motion": l.forceMotion, "cursor-grab": !y.value, "cursor-grabbing": y.value }]),
1109
+ ref_key: "swipeContainer",
1110
+ ref: z,
1111
+ style: { height: "100%", "max-height": "100%", position: "relative" }
1112
+ }, [
1113
+ W("div", {
1114
+ class: "relative w-full",
1115
+ style: ke({
1116
+ transform: `translateY(${L.value}px)`,
1117
+ transition: y.value ? "none" : `transform ${t.transitionDurationMs}ms ${t.transitionEasing}`,
1118
+ height: `${r.value.length * 100}%`
1119
+ })
1120
+ }, [
1121
+ (O(!0), A(Ie, null, Ee(r.value, (i, m) => (O(), A("div", {
1122
+ key: `${i.page}-${i.id}`,
1123
+ class: "absolute top-0 left-0 w-full",
1124
+ style: ke({
1125
+ top: `${m * (100 / r.value.length)}%`,
1126
+ height: `${100 / r.value.length}%`
1127
+ })
1128
+ }, [
1129
+ W("div", ia, [
1130
+ W("div", sa, [
1131
+ $e(e.$slots, "default", {
1132
+ item: i,
1133
+ remove: fe
1134
+ }, () => [
1135
+ Le(ye, {
1136
+ item: i,
1137
+ remove: fe
1138
+ }, null, 8, ["item"])
1139
+ ], !0)
1140
+ ])
1141
+ ])
1142
+ ], 4))), 128))
1143
+ ], 4),
1144
+ r.value.length > 1 ? (O(), A("div", ua, [
1145
+ (O(!0), A(Ie, null, Ee(r.value.slice(0, Math.min(10, r.value.length)), (i, m) => (O(), A("div", {
1146
+ key: `dot-${i.id}`,
1147
+ class: K(["w-1.5 h-1.5 rounded-full transition-all duration-300", m === v.value ? "bg-white w-4" : "bg-white/40"])
1148
+ }, null, 2))), 128))
1149
+ ])) : Z("", !0),
1150
+ W("div", ca, ce(v.value + 1) + " / " + ce(r.value.length), 1)
1151
+ ], 2)) : (O(), A("div", {
1152
+ key: 1,
1153
+ class: K(["overflow-auto w-full flex-1 masonry-container", { "force-motion": l.forceMotion }]),
1154
+ ref_key: "container",
1155
+ ref: f
997
1156
  }, [
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 }])
1157
+ W("div", {
1158
+ class: "relative",
1159
+ style: ke({ height: `${T.value}px`, "--masonry-duration": `${t.transitionDurationMs}ms`, "--masonry-leave-duration": `${t.leaveDurationMs}ms`, "--masonry-ease": t.transitionEasing })
1030
1160
  }, [
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));
1161
+ Le(mt, {
1162
+ name: "masonry",
1163
+ css: !1,
1164
+ onEnter: ie,
1165
+ onBeforeEnter: q,
1166
+ onLeave: at,
1167
+ onBeforeLeave: tt
1168
+ }, {
1169
+ default: pt(() => [
1170
+ (O(!0), A(Ie, null, Ee(nt.value, (i, m) => (O(), A("div", ht({
1171
+ key: `${i.page}-${i.id}`,
1172
+ class: "absolute masonry-item",
1173
+ ref_for: !0
1174
+ }, gt(Ut)(i, m), {
1175
+ style: { paddingTop: `${h.value.header}px`, paddingBottom: `${h.value.footer}px` }
1176
+ }), [
1177
+ $e(e.$slots, "default", {
1178
+ item: i,
1179
+ remove: fe
1180
+ }, () => [
1181
+ Le(ye, {
1182
+ item: i,
1183
+ remove: fe
1184
+ }, null, 8, ["item"])
1185
+ ], !0)
1186
+ ], 16))), 128))
1187
+ ]),
1188
+ _: 3
1189
+ }),
1190
+ T.value > 0 ? (O(), A("div", {
1191
+ key: 0,
1192
+ class: K(["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": !ee.value.isNearTrigger, "opacity-100": ee.value.isNearTrigger }])
1193
+ }, [
1194
+ W("span", null, ce(r.value.length) + " items", 1),
1195
+ a[0] || (a[0] = W("span", { class: "mx-2" }, "|", -1)),
1196
+ W("span", null, ce(ee.value.distanceToTrigger) + "px to load", 1)
1197
+ ], 2)) : Z("", !0)
1198
+ ], 4)
1199
+ ], 2))
1200
+ ], 512));
1037
1201
  }
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);
1202
+ }), va = (t, s) => {
1203
+ const u = t.__vccOpts || t;
1204
+ for (const [l, I] of s)
1205
+ u[l] = I;
1206
+ return u;
1207
+ }, Xe = /* @__PURE__ */ va(fa, [["__scopeId", "data-v-919154a5"]]), ma = {
1208
+ install(t) {
1209
+ t.component("WyxosMasonry", Xe), t.component("WMasonry", Xe), t.component("WyxosMasonryItem", ye), t.component("WMasonryItem", ye);
1046
1210
  }
1047
1211
  };
1048
1212
  export {
1049
- Ee as Masonry,
1050
- pe as MasonryItem,
1051
- zt as default
1213
+ Xe as Masonry,
1214
+ ye as MasonryItem,
1215
+ ma as default
1052
1216
  };