@wyxos/vibe 2.1.2 → 2.1.4

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,5 +1,5 @@
1
- import { defineComponent as it, ref as h, computed as T, onMounted as ut, onUnmounted as ct, createElementBlock as S, openBlock as P, normalizeStyle as $, createCommentVNode as te, createElementVNode as R, normalizeClass as Je, mergeDefaults as Tt, useAttrs as Rt, useSlots as At, shallowRef as Et, watch as W, mergeProps as _t, toDisplayString as Qe, Fragment as Ze, renderList as et, createVNode as tt, renderSlot as ve, nextTick as nt } from "vue";
2
- const Nt = {
1
+ import { defineComponent as pe, ref as h, computed as S, onMounted as Be, onUnmounted as gt, createElementBlock as F, openBlock as x, normalizeStyle as V, createCommentVNode as oe, createElementVNode as _, normalizeClass as st, mergeDefaults as Ht, useAttrs as Lt, shallowRef as lt, provide as zt, watch as U, mergeProps as qt, renderSlot as $t, toDisplayString as rt, Fragment as it, renderList as ut, createBlock as he, createVNode as ge, unref as ne, nextTick as ct, inject as Ot } from "vue";
2
+ const Dt = {
3
3
  mode: "default",
4
4
  pageSize: 20,
5
5
  backfillRequestDelayMs: 2e3,
@@ -11,69 +11,80 @@ const Nt = {
11
11
  headerHeight: 0,
12
12
  footerHeight: 0,
13
13
  overscanPx: 600
14
- }, Ct = {
14
+ }, Vt = {
15
15
  key: 0,
16
16
  "data-testid": "masonry-loader-spinner",
17
17
  class: "absolute inset-0 flex items-center justify-center"
18
- }, Ht = {
18
+ }, Yt = {
19
19
  key: 1,
20
20
  "data-testid": "masonry-loader-error",
21
21
  class: "absolute inset-0 flex flex-col items-center justify-center gap-2 p-3"
22
- }, Lt = ["src", "width", "height", "alt"], zt = ["poster"], qt = ["src"], at = /* @__PURE__ */ it({
22
+ }, Xt = ["src", "width", "height", "alt"], jt = ["poster"], Wt = ["src"], ft = /* @__PURE__ */ pe({
23
23
  __name: "MasonryLoader",
24
24
  props: {
25
- item: {}
25
+ item: {},
26
+ timeoutMs: { default: 15e3 }
26
27
  },
27
28
  emits: ["success", "error"],
28
- setup(o, { emit: k }) {
29
- const u = o, l = k, r = h(null), p = h(!1), d = h(!1), i = h(!1), g = h(0), b = T(() => {
30
- const x = u.item?.width, M = u.item?.height;
31
- return { aspectRatio: `${x} / ${M}` };
32
- }), I = T(() => u.item?.type === "image");
33
- let F = null;
34
- function A() {
35
- p.value || (p.value = !0, d.value = !1, i.value = !1);
29
+ setup(o, { emit: g }) {
30
+ const i = o, l = g, u = h(null), p = h(!1), c = h(!1), r = h(!1), b = h(0), M = S(() => {
31
+ const R = i.item?.width, B = i.item?.height;
32
+ return { aspectRatio: `${R} / ${B}` };
33
+ }), I = S(() => i.item?.type === "image");
34
+ let P = null, T = null;
35
+ function E() {
36
+ T != null && (window.clearTimeout(T), T = null);
37
+ }
38
+ function k() {
39
+ E();
40
+ const R = typeof i.timeoutMs == "number" && Number.isFinite(i.timeoutMs) ? i.timeoutMs : 0;
41
+ R <= 0 || (T = window.setTimeout(() => {
42
+ p.value && (c.value || r.value || z(new Error("timeout")));
43
+ }, R));
36
44
  }
37
- ut(() => {
45
+ function L() {
46
+ p.value || (p.value = !0, c.value = !1, r.value = !1, k());
47
+ }
48
+ Be(() => {
38
49
  if (typeof IntersectionObserver > "u") {
39
- A();
50
+ L();
40
51
  return;
41
52
  }
42
- F = new IntersectionObserver(
43
- (x) => {
44
- for (const M of x)
45
- if (M.isIntersecting && !((M.intersectionRatio ?? 0) < 0.5)) {
46
- A(), F?.disconnect(), F = null;
53
+ P = new IntersectionObserver(
54
+ (R) => {
55
+ for (const B of R)
56
+ if (B.isIntersecting && !((B.intersectionRatio ?? 0) < 0.5)) {
57
+ L(), P?.disconnect(), P = null;
47
58
  return;
48
59
  }
49
60
  },
50
61
  { threshold: [0, 0.5, 1] }
51
- ), r.value && F.observe(r.value);
52
- }), ct(() => {
53
- F?.disconnect(), F = null;
62
+ ), u.value && P.observe(u.value);
63
+ }), gt(() => {
64
+ P?.disconnect(), P = null, E();
54
65
  });
55
- function E() {
56
- d.value || (d.value = !0, i.value = !1, l("success", u.item));
66
+ function A() {
67
+ c.value || (c.value = !0, r.value = !1, E(), l("success", i.item));
57
68
  }
58
- function B(x) {
59
- i.value || (d.value = !1, i.value = !0, l("error", { item: u.item, error: x }));
69
+ function z(R) {
70
+ r.value || (c.value = !1, r.value = !0, E(), l("error", { item: i.item, error: R }));
60
71
  }
61
- function H() {
62
- p.value && (d.value = !1, i.value = !1, g.value += 1);
72
+ function C() {
73
+ p.value && (c.value = !1, r.value = !1, b.value += 1, k());
63
74
  }
64
- return (x, M) => (P(), S("div", {
75
+ return (R, B) => (x(), F("div", {
65
76
  ref_key: "rootEl",
66
- ref: r,
77
+ ref: u,
67
78
  class: "relative bg-slate-100",
68
- style: $(b.value)
79
+ style: V(M.value)
69
80
  }, [
70
- p.value && !d.value && !i.value ? (P(), S("div", Ct, M[2] || (M[2] = [
71
- R("svg", {
81
+ p.value && !c.value && !r.value ? (x(), F("div", Vt, B[2] || (B[2] = [
82
+ _("svg", {
72
83
  class: "h-5 w-5 animate-spin text-slate-500",
73
84
  viewBox: "0 0 24 24",
74
85
  "aria-hidden": "true"
75
86
  }, [
76
- R("circle", {
87
+ _("circle", {
77
88
  class: "opacity-25",
78
89
  cx: "12",
79
90
  cy: "12",
@@ -82,161 +93,161 @@ const Nt = {
82
93
  stroke: "currentColor",
83
94
  "stroke-width": "4"
84
95
  }),
85
- R("path", {
96
+ _("path", {
86
97
  class: "opacity-75",
87
98
  fill: "currentColor",
88
99
  d: "M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"
89
100
  })
90
101
  ], -1)
91
- ]))) : p.value && i.value ? (P(), S("div", Ht, [
92
- M[3] || (M[3] = R("p", { class: "text-center text-xs font-medium text-red-700" }, "Failed to load", -1)),
93
- R("button", {
102
+ ]))) : p.value && r.value ? (x(), F("div", Yt, [
103
+ B[3] || (B[3] = _("p", { class: "text-center text-xs font-medium text-red-700" }, "Failed to load", -1)),
104
+ _("button", {
94
105
  type: "button",
95
106
  "data-testid": "masonry-loader-retry",
96
107
  class: "inline-flex items-center rounded-md border border-slate-200 bg-white px-2 py-1 text-xs font-medium text-slate-700",
97
- onClick: H
108
+ onClick: C
98
109
  }, " Retry ")
99
- ])) : te("", !0),
100
- p.value && I.value && !i.value ? (P(), S("img", {
101
- key: u.item.id + ":img:" + g.value,
102
- class: Je([
110
+ ])) : oe("", !0),
111
+ p.value && I.value && !r.value ? (x(), F("img", {
112
+ key: i.item.id + ":img:" + b.value,
113
+ class: st([
103
114
  "h-full w-full object-cover transition-opacity duration-300",
104
- d.value ? "opacity-100" : "opacity-0"
115
+ c.value ? "opacity-100" : "opacity-0"
105
116
  ]),
106
- src: u.item.preview,
107
- width: u.item.width,
108
- height: u.item.height,
117
+ src: i.item.preview,
118
+ width: i.item.width,
119
+ height: i.item.height,
109
120
  loading: "lazy",
110
- alt: u.item.id,
111
- onLoad: E,
112
- onError: M[0] || (M[0] = (L) => B(L))
113
- }, null, 42, Lt)) : p.value && !i.value ? (P(), S("video", {
114
- key: u.item.id + ":vid:" + g.value,
115
- class: Je([
121
+ alt: i.item.id,
122
+ onLoad: A,
123
+ onError: B[0] || (B[0] = (O) => z(O))
124
+ }, null, 42, Xt)) : p.value && !r.value ? (x(), F("video", {
125
+ key: i.item.id + ":vid:" + b.value,
126
+ class: st([
116
127
  "h-full w-full object-cover transition-opacity duration-300",
117
- d.value ? "opacity-100" : "opacity-0"
128
+ c.value ? "opacity-100" : "opacity-0"
118
129
  ]),
119
- poster: u.item.preview,
130
+ poster: i.item.preview,
120
131
  controls: "",
121
132
  preload: "metadata",
122
- onLoadedmetadata: E,
123
- onError: M[1] || (M[1] = (L) => B(L))
133
+ onLoadedmetadata: A,
134
+ onError: B[1] || (B[1] = (O) => z(O))
124
135
  }, [
125
- R("source", {
126
- src: u.item.original,
136
+ _("source", {
137
+ src: i.item.original,
127
138
  type: "video/mp4"
128
- }, null, 8, qt)
129
- ], 42, zt)) : te("", !0)
139
+ }, null, 8, Wt)
140
+ ], 42, jt)) : oe("", !0)
130
141
  ], 4));
131
142
  }
132
- });
133
- function $t(o, k) {
134
- return !o || o <= 0 || !k || k <= 0 ? 1 : Math.max(1, Math.floor(o / k));
143
+ }), pt = Symbol("masonryItemRegistry");
144
+ function Gt(o, g) {
145
+ return !o || o <= 0 || !g || g <= 0 ? 1 : Math.max(1, Math.floor(o / g));
135
146
  }
136
- function Ot(o, k, u, l = 0) {
137
- if (!o || o <= 0 || !k || k <= 0) return u;
138
- const r = typeof l == "number" && l > 0 ? l : 0, p = Math.max(0, k - 1) * r, d = o - p;
139
- return !d || d <= 0 ? u : d / k;
147
+ function Ut(o, g, i, l = 0) {
148
+ if (!o || o <= 0 || !g || g <= 0) return i;
149
+ const u = typeof l == "number" && l > 0 ? l : 0, p = Math.max(0, g - 1) * u, c = o - p;
150
+ return !c || c <= 0 ? i : c / g;
140
151
  }
141
- function Vt(o, k) {
142
- const u = o?.width, l = o?.height;
143
- return typeof u == "number" && typeof l == "number" && u > 0 && l > 0 ? l / u * k : k;
152
+ function Kt(o, g) {
153
+ const i = o?.width, l = o?.height;
154
+ return typeof i == "number" && typeof l == "number" && i > 0 && l > 0 ? l / i * g : g;
144
155
  }
145
- function ft(o) {
156
+ function yt(o) {
146
157
  return Number.isFinite(o) && o > 0 ? Math.floor(o) : 1;
147
158
  }
148
- function ke(o) {
159
+ function Te(o) {
149
160
  return Number.isFinite(o) && o > 0 ? Math.floor(o) : 0;
150
161
  }
151
- function Yt(o) {
152
- async function k(l) {
153
- const r = ke(l);
154
- if (r <= 0) return;
162
+ function Jt(o) {
163
+ async function g(l) {
164
+ const u = Te(l);
165
+ if (u <= 0) return;
155
166
  o.stats.value = {
156
167
  ...o.stats.value,
157
- cooldownMsTotal: r,
158
- cooldownMsRemaining: r
168
+ cooldownMsTotal: u,
169
+ cooldownMsRemaining: u
159
170
  };
160
- const p = Date.now(), d = 100;
161
- await new Promise((i) => {
162
- const g = setInterval(() => {
163
- const b = Date.now() - p, I = Math.max(0, r - b);
171
+ const p = Date.now(), c = 100;
172
+ await new Promise((r) => {
173
+ const b = setInterval(() => {
174
+ const M = Date.now() - p, I = Math.max(0, u - M);
164
175
  o.stats.value = {
165
176
  ...o.stats.value,
166
- cooldownMsTotal: r,
177
+ cooldownMsTotal: u,
167
178
  cooldownMsRemaining: I
168
- }, I <= 0 && (clearInterval(g), i());
169
- }, d);
179
+ }, I <= 0 && (clearInterval(b), r());
180
+ }, c);
170
181
  });
171
182
  }
172
- async function u(l) {
173
- const r = ft(o.getPageSize()), p = o.isEnabled(), d = ke(o.getRequestDelayMs()), i = [];
174
- let g = 0;
175
- o.buffer.value.length && (g = o.buffer.value.length, i.push(...o.buffer.value), o.buffer.value = []), o.stats.value = {
183
+ async function i(l) {
184
+ const u = yt(o.getPageSize()), p = o.isEnabled(), c = Te(o.getRequestDelayMs()), r = [];
185
+ let b = 0;
186
+ o.buffer.value.length && (b = o.buffer.value.length, r.push(...o.buffer.value), o.buffer.value = []), o.stats.value = {
176
187
  ...o.stats.value,
177
188
  enabled: p,
178
189
  isBackfillActive: !1,
179
190
  isRequestInFlight: !1,
180
191
  requestPage: null,
181
- cooldownMsTotal: d,
192
+ cooldownMsTotal: c,
182
193
  cooldownMsRemaining: 0,
183
194
  progress: {
184
195
  collected: 0,
185
196
  target: 0
186
197
  },
187
- pageSize: r,
198
+ pageSize: u,
188
199
  bufferSize: 0
189
200
  };
190
- const b = [];
191
- let I = l, F = 0, A = !1;
192
- for (; i.length < r && I != null; ) {
193
- const H = I;
194
- A && (o.stats.value = {
201
+ const M = [];
202
+ let I = l, P = 0, T = !1;
203
+ for (; r.length < u && I != null; ) {
204
+ const L = I;
205
+ T && (o.stats.value = {
195
206
  ...o.stats.value,
196
207
  enabled: p,
197
208
  isBackfillActive: !0,
198
209
  isRequestInFlight: !0,
199
- requestPage: H,
210
+ requestPage: L,
200
211
  progress: {
201
- collected: Math.min(i.length, r),
202
- target: r
212
+ collected: Math.min(r.length, u),
213
+ target: u
203
214
  },
204
- cooldownMsTotal: d,
215
+ cooldownMsTotal: c,
205
216
  cooldownMsRemaining: 0,
206
- pageSize: r
217
+ pageSize: u
207
218
  });
208
- const x = await o.getContent(H);
209
- b.push(H), A && (o.stats.value = {
219
+ const A = await o.getContent(L);
220
+ M.push(L), T && (o.stats.value = {
210
221
  ...o.stats.value,
211
222
  enabled: p,
212
223
  isBackfillActive: !0,
213
224
  isRequestInFlight: !1,
214
225
  requestPage: null
215
- }), F += x.items.length, o.markEnterFromLeft(x.items), i.push(...x.items), I = x.nextPage, !A && i.length < r && I != null ? (A = !0, o.stats.value = {
226
+ }), P += A.items.length, o.markEnterFromLeft(A.items), r.push(...A.items), I = A.nextPage, !T && r.length < u && I != null ? (T = !0, o.stats.value = {
216
227
  ...o.stats.value,
217
228
  enabled: p,
218
229
  isBackfillActive: !0,
219
230
  isRequestInFlight: !1,
220
231
  requestPage: null,
221
232
  progress: {
222
- collected: Math.min(i.length, r),
223
- target: r
233
+ collected: Math.min(r.length, u),
234
+ target: u
224
235
  },
225
- cooldownMsTotal: d,
236
+ cooldownMsTotal: c,
226
237
  cooldownMsRemaining: 0,
227
- pageSize: r
228
- }) : A && (o.stats.value = {
238
+ pageSize: u
239
+ }) : T && (o.stats.value = {
229
240
  ...o.stats.value,
230
241
  enabled: p,
231
242
  isBackfillActive: !0,
232
243
  progress: {
233
- collected: Math.min(i.length, r),
234
- target: r
244
+ collected: Math.min(r.length, u),
245
+ target: u
235
246
  }
236
- }), A && i.length < r && I != null && await k(d);
247
+ }), T && r.length < u && I != null && await g(c);
237
248
  }
238
- const E = i.slice(0, r), B = i.slice(r);
239
- return o.buffer.value = B, o.stats.value = {
249
+ const E = r.slice(0, u), k = r.slice(u);
250
+ return o.buffer.value = k, o.stats.value = {
240
251
  ...o.stats.value,
241
252
  enabled: p,
242
253
  isBackfillActive: !1,
@@ -246,72 +257,72 @@ function Yt(o) {
246
257
  collected: 0,
247
258
  target: 0
248
259
  },
249
- cooldownMsTotal: d,
260
+ cooldownMsTotal: c,
250
261
  cooldownMsRemaining: 0,
251
- pageSize: r,
252
- bufferSize: B.length,
262
+ pageSize: u,
263
+ bufferSize: k.length,
253
264
  lastBatch: {
254
265
  startPage: l,
255
- pages: b,
256
- usedFromBuffer: g,
257
- fetchedFromNetwork: F,
258
- collectedTotal: i.length,
266
+ pages: M,
267
+ usedFromBuffer: b,
268
+ fetchedFromNetwork: P,
269
+ collectedTotal: r.length,
259
270
  emitted: E.length,
260
- carried: B.length
271
+ carried: k.length
261
272
  },
262
273
  totals: {
263
- pagesFetched: o.stats.value.totals.pagesFetched + b.length,
264
- itemsFetchedFromNetwork: o.stats.value.totals.itemsFetchedFromNetwork + F
274
+ pagesFetched: o.stats.value.totals.pagesFetched + M.length,
275
+ itemsFetchedFromNetwork: o.stats.value.totals.itemsFetchedFromNetwork + P
265
276
  }
266
- }, { batchItems: E, pages: b, nextPage: I };
277
+ }, { batchItems: E, pages: M, nextPage: I };
267
278
  }
268
- return { loadBackfillBatch: u };
279
+ return { loadBackfillBatch: i };
269
280
  }
270
- function Dt(o) {
271
- const k = o.columnCount, u = o.columnWidth, l = o.gapX, r = o.gapY, p = o.headerHeight, d = o.footerHeight, i = o.bucketPx, g = Array.from({ length: k }, () => 0), b = new Array(o.items.length), I = new Array(o.items.length), F = /* @__PURE__ */ new Map(), A = /* @__PURE__ */ new Map();
281
+ function Qt(o) {
282
+ const g = o.columnCount, i = o.columnWidth, l = o.gapX, u = o.gapY, p = o.headerHeight, c = o.footerHeight, r = o.bucketPx, b = Array.from({ length: g }, () => 0), M = new Array(o.items.length), I = new Array(o.items.length), P = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
272
283
  let E = 0;
273
- for (let B = 0; B < o.items.length; B += 1) {
274
- const H = o.items[B];
275
- H?.id && A.set(H.id, B);
276
- let x = 0;
277
- for (let _ = 1; _ < g.length; _ += 1)
278
- g[_] < g[x] && (x = _);
279
- const M = x * (u + l), L = g[x], Y = Vt(H, u) + p + d;
280
- b[B] = { x: M, y: L }, I[B] = Y, g[x] = L + Y + r, E = Math.max(E, L + Y);
281
- const re = Math.floor(L / i), ie = Math.floor((L + Y) / i);
282
- for (let _ = re; _ <= ie; _ += 1) {
283
- const G = F.get(_);
284
- G ? G.push(B) : F.set(_, [B]);
284
+ for (let k = 0; k < o.items.length; k += 1) {
285
+ const L = o.items[k];
286
+ L?.id && T.set(L.id, k);
287
+ let A = 0;
288
+ for (let q = 1; q < b.length; q += 1)
289
+ b[q] < b[A] && (A = q);
290
+ const z = A * (i + l), C = b[A], R = Kt(L, i) + p + c;
291
+ M[k] = { x: z, y: C }, I[k] = R, b[A] = C + R + u, E = Math.max(E, C + R);
292
+ const B = Math.floor(C / r), O = Math.floor((C + R) / r);
293
+ for (let q = B; q <= O; q += 1) {
294
+ const ae = P.get(q);
295
+ ae ? ae.push(k) : P.set(q, [k]);
285
296
  }
286
297
  }
287
- return { positions: b, heights: I, buckets: F, contentHeight: E, indexById: A };
298
+ return { positions: M, heights: I, buckets: P, contentHeight: E, indexById: T };
288
299
  }
289
- function Xt(o) {
290
- const k = o.itemCount;
291
- if (!k) return [];
292
- if (o.viewportHeight <= 0) return Array.from({ length: k }, (g, b) => b);
293
- const u = Math.max(0, o.scrollTop - o.overscanPx), l = o.scrollTop + o.viewportHeight + o.overscanPx, r = Math.floor(u / o.bucketPx), p = Math.floor(l / o.bucketPx), d = /* @__PURE__ */ new Set();
294
- for (let g = r; g <= p; g += 1) {
295
- const b = o.buckets.get(g);
296
- if (b)
297
- for (const I of b) d.add(I);
300
+ function Zt(o) {
301
+ const g = o.itemCount;
302
+ if (!g) return [];
303
+ if (o.viewportHeight <= 0) return Array.from({ length: g }, (b, M) => M);
304
+ const i = Math.max(0, o.scrollTop - o.overscanPx), l = o.scrollTop + o.viewportHeight + o.overscanPx, u = Math.floor(i / o.bucketPx), p = Math.floor(l / o.bucketPx), c = /* @__PURE__ */ new Set();
305
+ for (let b = u; b <= p; b += 1) {
306
+ const M = o.buckets.get(b);
307
+ if (M)
308
+ for (const I of M) c.add(I);
298
309
  }
299
- const i = Array.from(d);
300
- return i.sort((g, b) => g - b), i;
310
+ const r = Array.from(c);
311
+ return r.sort((b, M) => b - M), r;
301
312
  }
302
- const jt = {
313
+ const en = { class: "hidden" }, tn = {
303
314
  key: 0,
304
315
  class: "flex h-full items-center justify-center"
305
- }, Wt = {
316
+ }, nn = {
306
317
  key: 1,
307
318
  class: "text-sm font-medium text-red-700"
308
- }, Gt = { class: "mt-4 pb-2 text-center text-xs text-slate-600" }, Ut = {
319
+ }, on = { class: "mt-4 pb-2 text-center text-xs text-slate-600" }, an = {
309
320
  key: 0,
310
321
  class: "inline-flex items-center justify-center gap-2"
311
- }, Kt = { key: 1 }, Jt = { key: 2 }, Qt = 200, ot = 600, st = 300, lt = 600, rt = 600, Zt = 5, en = 1e3, tn = /* @__PURE__ */ it({
322
+ }, sn = { key: 1 }, ln = { key: 2 }, rn = 200, dt = 600, vt = 300, mt = 600, ht = 600, un = 5, cn = 1e3, fn = /* @__PURE__ */ pe({
312
323
  inheritAttrs: !1,
313
324
  __name: "Masonry",
314
- props: /* @__PURE__ */ Tt({
325
+ props: /* @__PURE__ */ Ht({
315
326
  getContent: {},
316
327
  mode: {},
317
328
  pageSize: {},
@@ -326,63 +337,88 @@ const jt = {
326
337
  headerHeight: {},
327
338
  footerHeight: {},
328
339
  overscanPx: {}
329
- }, Nt),
340
+ }, Dt),
330
341
  emits: ["update:items"],
331
- setup(o, { expose: k, emit: u }) {
332
- const l = o, r = u, p = Rt(), d = At(), i = T(() => {
342
+ setup(o, { expose: g, emit: i }) {
343
+ const l = o, u = i, p = Lt(), c = pe({
344
+ name: "SlotRenderer",
345
+ props: {
346
+ slotFn: {
347
+ type: Function,
348
+ required: !1
349
+ },
350
+ slotProps: {
351
+ type: Object,
352
+ required: !0
353
+ }
354
+ },
355
+ setup(e) {
356
+ return () => {
357
+ const n = e.slotFn;
358
+ return n ? n(e.slotProps) : null;
359
+ };
360
+ }
361
+ }), r = lt(null);
362
+ zt(pt, (e) => {
363
+ r.value || (r.value = e);
364
+ }), Be(() => {
365
+ if (!r.value)
366
+ throw new Error("[Masonry] Missing <MasonryItem> definition. Add <MasonryItem> as a child of <Masonry>.");
367
+ });
368
+ const b = S(() => {
333
369
  const { class: e, ...n } = p;
334
370
  return n;
335
- }), g = h(null), b = h(0), I = h(0), F = h(0);
336
- let A;
337
- const E = T(() => l.gapX), B = T(() => l.gapY);
338
- function H(e) {
371
+ }), M = h(null), I = h(0), P = h(0), T = h(0);
372
+ let E;
373
+ const k = S(() => l.gapX), L = S(() => l.gapY);
374
+ function A(e) {
339
375
  if (!e) return 0;
340
- const n = Math.max(0, E.value);
376
+ const n = Math.max(0, k.value);
341
377
  return Math.max(0, e.clientWidth - n);
342
378
  }
343
- const x = T(() => l.headerHeight), M = T(() => l.footerHeight), L = T(() => !!d.itemHeader), Y = T(() => !!d.itemFooter), re = T(() => {
344
- if (x.value > 0) return { height: `${x.value}px` };
345
- }), ie = T(() => {
346
- if (M.value > 0) return { height: `${M.value}px` };
347
- }), _ = h([]), G = h([]), Me = h(/* @__PURE__ */ new Map()), Ie = h(0), ue = h(/* @__PURE__ */ new Map());
348
- function Se(e) {
379
+ const z = S(() => l.headerHeight), C = S(() => l.footerHeight), R = S(() => r.value?.header), B = S(() => r.value?.footer), O = S(() => r.value?.default), q = S(() => !!R.value), ae = S(() => !!B.value), Re = S(() => {
380
+ if (z.value > 0) return { height: `${z.value}px` };
381
+ }), _e = S(() => {
382
+ if (C.value > 0) return { height: `${C.value}px` };
383
+ }), se = h([]), ye = h([]), Ae = h(/* @__PURE__ */ new Map()), Ee = h(0), fe = h(/* @__PURE__ */ new Map());
384
+ function Ne(e) {
349
385
  const n = typeof e == "number" && Number.isFinite(e) ? e : 0;
350
- return Ye.value + Math.max(0, n);
386
+ return Je.value + Math.max(0, n);
351
387
  }
352
- const D = h(/* @__PURE__ */ new Set()), U = h(/* @__PURE__ */ new Set()), ce = /* @__PURE__ */ new Set(), fe = h(/* @__PURE__ */ new Map()), O = h(/* @__PURE__ */ new Set()), V = h([]);
353
- function dt(e) {
354
- const n = fe.value.get(e);
388
+ const j = h(/* @__PURE__ */ new Set()), K = h(/* @__PURE__ */ new Set()), de = /* @__PURE__ */ new Set(), ve = h(/* @__PURE__ */ new Map()), Y = h(/* @__PURE__ */ new Set()), X = h([]);
389
+ function wt(e) {
390
+ const n = ve.value.get(e);
355
391
  return n || { dx: 0, dy: 0 };
356
392
  }
357
- function vt(e) {
358
- if (U.value.has(e)) return `transform ${lt}ms ease-out`;
359
- if (O.value.has(e)) return `transform ${st}ms ease-out`;
393
+ function xt(e) {
394
+ if (K.value.has(e)) return `transform ${mt}ms ease-out`;
395
+ if (Y.value.has(e)) return `transform ${vt}ms ease-out`;
360
396
  }
361
- function mt(e) {
362
- const t = c.value[e]?.id, a = _.value[e] ?? { x: 0, y: 0 }, s = G.value[e] ?? 0, f = s > 0 ? s : se.value, v = a.x, y = t && D.value.has(t) ? Se(f) : a.y, w = t ? dt(t) : { dx: 0, dy: 0 };
397
+ function bt(e) {
398
+ const t = f.value[e]?.id, a = se.value[e] ?? { x: 0, y: 0 }, s = ye.value[e] ?? 0, d = s > 0 ? s : ue.value, v = a.x, y = t && j.value.has(t) ? Ne(d) : a.y, w = t ? wt(t) : { dx: 0, dy: 0 };
363
399
  return `translate3d(${v + w.dx}px,${y + w.dy}px,0)`;
364
400
  }
365
- function K(e) {
401
+ function J(e) {
366
402
  (typeof requestAnimationFrame == "function" ? requestAnimationFrame : (t) => setTimeout(() => t(0), 0))(() => e());
367
403
  }
368
- function ht(e) {
369
- K(() => K(e));
404
+ function Mt(e) {
405
+ J(() => J(e));
370
406
  }
371
- const Pe = /* @__PURE__ */ new Set();
372
- function Fe(e) {
407
+ const Ce = /* @__PURE__ */ new Set();
408
+ function He(e) {
373
409
  return typeof e == "number" && Number.isFinite(e) && e > 0;
374
410
  }
375
- function me(e) {
411
+ function we(e) {
376
412
  if (!Array.isArray(e) || e.length === 0) return;
377
- const n = new Set(D.value);
413
+ const n = new Set(j.value);
378
414
  let t = !1;
379
415
  for (const a of e) {
380
416
  const s = a?.id;
381
417
  if (s) {
382
- if (!Pe.has(s)) {
383
- const f = a?.width, v = a?.height;
384
- (!Fe(f) || !Fe(v)) && (Pe.add(s), console.warn(
385
- `[Masonry] Item "${s}" has invalid dimensions (width=${String(f)}, height=${String(
418
+ if (!Ce.has(s)) {
419
+ const d = a?.width, v = a?.height;
420
+ (!He(d) || !He(v)) && (Ce.add(s), console.warn(
421
+ `[Masonry] Item "${s}" has invalid dimensions (width=${String(d)}, height=${String(
386
422
  v
387
423
  )}); layout expects { id, width, height }.`
388
424
  ));
@@ -390,88 +426,88 @@ const jt = {
390
426
  n.has(s) || (n.add(s), t = !0);
391
427
  }
392
428
  }
393
- t && (D.value = n);
429
+ t && (j.value = n);
394
430
  }
395
- function Be() {
431
+ function Le() {
396
432
  const e = /* @__PURE__ */ new Map();
397
- for (const n of xe.value) {
398
- const a = c.value[n]?.id;
433
+ for (const n of Fe.value) {
434
+ const a = f.value[n]?.id;
399
435
  if (!a) continue;
400
- const s = _.value[n];
436
+ const s = se.value[n];
401
437
  s && e.set(a, { x: s.x, y: s.y });
402
438
  }
403
439
  return e;
404
440
  }
405
- function Te(e, n) {
441
+ function ze(e, n) {
406
442
  if (!e.size) return;
407
443
  const t = /* @__PURE__ */ new Map(), a = [];
408
- for (const [f, v] of e.entries()) {
409
- if (n?.has(f)) continue;
410
- const y = ue.value.get(f);
444
+ for (const [d, v] of e.entries()) {
445
+ if (n?.has(d)) continue;
446
+ const y = fe.value.get(d);
411
447
  if (y == null) continue;
412
- const w = _.value[y];
448
+ const w = se.value[y];
413
449
  if (!w) continue;
414
- const m = v.x - w.x, z = v.y - w.y;
415
- (m || z) && (t.set(f, { dx: m, dy: z }), a.push(f));
450
+ const m = v.x - w.x, $ = v.y - w.y;
451
+ (m || $) && (t.set(d, { dx: m, dy: $ }), a.push(d));
416
452
  }
417
453
  if (!t.size) return;
418
- fe.value = t;
419
- const s = new Set(O.value);
420
- for (const f of a) s.delete(f);
421
- O.value = s, K(() => {
422
- O.value = /* @__PURE__ */ new Set([...O.value, ...a]), K(() => {
423
- fe.value = /* @__PURE__ */ new Map();
454
+ ve.value = t;
455
+ const s = new Set(Y.value);
456
+ for (const d of a) s.delete(d);
457
+ Y.value = s, J(() => {
458
+ Y.value = /* @__PURE__ */ new Set([...Y.value, ...a]), J(() => {
459
+ ve.value = /* @__PURE__ */ new Map();
424
460
  });
425
461
  }), setTimeout(() => {
426
- const f = new Set(O.value);
427
- for (const v of a) f.delete(v);
428
- O.value = f;
429
- }, st);
462
+ const d = new Set(Y.value);
463
+ for (const v of a) d.delete(v);
464
+ Y.value = d;
465
+ }, vt);
430
466
  }
431
- const ne = h(!0), ae = h(!1), J = h("");
467
+ const le = h(!0), re = h(!1), Q = h("");
432
468
  let N = 0;
433
- function Re(e) {
469
+ function qe(e) {
434
470
  return e instanceof Error && e.name === "AbortError";
435
471
  }
436
- function Ae() {
472
+ function $e() {
437
473
  const e = new Error("aborted");
438
474
  return e.name = "AbortError", e;
439
475
  }
440
- function gt(e) {
476
+ function kt(e) {
441
477
  return new Promise((n) => setTimeout(n, e));
442
478
  }
443
- async function Ee(e, n) {
479
+ async function Oe(e, n) {
444
480
  let t = 0;
445
481
  for (; ; ) {
446
- if (n !== N) throw Ae();
482
+ if (n !== N) throw $e();
447
483
  try {
448
484
  return await l.getContent(e);
449
485
  } catch (a) {
450
- if (n !== N) throw Ae();
451
- if (t >= Zt) throw a;
452
- t += 1, await gt(t * en);
486
+ if (n !== N) throw $e();
487
+ if (t >= un) throw a;
488
+ t += 1, await kt(t * cn);
453
489
  }
454
490
  }
455
491
  }
456
- const q = h([]), _e = h([]), he = h([]), C = h(l.page), ge = h([]);
457
- let Q = null, Z = null, de = 0;
458
- function pt(e) {
492
+ const D = h([]), De = h([]), xe = h([]), H = h(l.page), be = h([]);
493
+ let Z = null, ee = null, me = 0;
494
+ function It(e) {
459
495
  let n = -1;
460
496
  for (const t of e) {
461
497
  const a = t?.originalIndex;
462
- oe(a) && a > n && (n = a);
498
+ ie(a) && a > n && (n = a);
463
499
  }
464
- de = n + 1;
500
+ me = n + 1;
465
501
  }
466
- function ee(e) {
502
+ function te(e) {
467
503
  for (const n of e)
468
- !n || typeof n != "object" || n.id && n.originalIndex == null && (n.originalIndex = de, de += 1);
504
+ !n || typeof n != "object" || n.id && n.originalIndex == null && (n.originalIndex = me, me += 1);
469
505
  }
470
- const X = /* @__PURE__ */ new Map(), j = [];
471
- function oe(e) {
506
+ const W = /* @__PURE__ */ new Map(), G = [];
507
+ function ie(e) {
472
508
  return typeof e == "number" && Number.isFinite(e);
473
509
  }
474
- function yt(e, n) {
510
+ function St(e, n) {
475
511
  if (!n.length) return e;
476
512
  const t = /* @__PURE__ */ new Set();
477
513
  for (const v of e) {
@@ -485,75 +521,75 @@ const jt = {
485
521
  }
486
522
  if (!a.length) return e;
487
523
  const s = a.slice().sort((v, y) => {
488
- const w = oe(v.originalIndex) ? v.originalIndex : Number.POSITIVE_INFINITY, m = oe(y.originalIndex) ? y.originalIndex : Number.POSITIVE_INFINITY;
524
+ const w = ie(v.originalIndex) ? v.originalIndex : Number.POSITIVE_INFINITY, m = ie(y.originalIndex) ? y.originalIndex : Number.POSITIVE_INFINITY;
489
525
  return w - m;
490
- }), f = e.slice();
526
+ }), d = e.slice();
491
527
  for (const v of s) {
492
528
  const y = v.originalIndex;
493
- if (!oe(y)) {
494
- f.push(v);
529
+ if (!ie(y)) {
530
+ d.push(v);
495
531
  continue;
496
532
  }
497
- let w = 0, m = f.length;
533
+ let w = 0, m = d.length;
498
534
  for (; w < m; ) {
499
- const z = w + m >> 1, le = f[z]?.originalIndex;
500
- (oe(le) ? le : Number.POSITIVE_INFINITY) <= y ? w = z + 1 : m = z;
535
+ const $ = w + m >> 1, ce = d[$]?.originalIndex;
536
+ (ie(ce) ? ce : Number.POSITIVE_INFINITY) <= y ? w = $ + 1 : m = $;
501
537
  }
502
- f.splice(w, 0, v);
538
+ d.splice(w, 0, v);
503
539
  }
504
- return f;
540
+ return d;
505
541
  }
506
- async function Ne(e) {
542
+ async function Ve(e) {
507
543
  if (!e.length) return;
508
- me(e);
509
- const n = Be();
510
- c.value = yt(c.value, e), await nt(), Te(n);
544
+ we(e);
545
+ const n = Le();
546
+ f.value = St(f.value, e), await ct(), ze(n);
511
547
  }
512
- async function Ce(e) {
513
- const t = (Array.isArray(e) ? e : [e]).map(we).filter(Boolean);
548
+ async function Ye(e) {
549
+ const t = (Array.isArray(e) ? e : [e]).map(Ie).filter(Boolean);
514
550
  if (!t.length) return;
515
551
  const a = [];
516
552
  for (const s of t) {
517
- const f = X.get(s);
518
- f && a.push(f);
553
+ const d = W.get(s);
554
+ d && a.push(d);
519
555
  }
520
556
  if (a.length) {
521
- await Ne(a);
557
+ await Ve(a);
522
558
  for (const s of a)
523
- s?.id && X.delete(s.id);
559
+ s?.id && W.delete(s.id);
524
560
  }
525
561
  }
526
- async function He() {
527
- const e = j.pop();
562
+ async function Xe() {
563
+ const e = G.pop();
528
564
  if (!e?.length) return;
529
565
  const n = [];
530
566
  for (const t of e) {
531
- const a = X.get(t);
567
+ const a = W.get(t);
532
568
  a && n.push(a);
533
569
  }
534
570
  if (n.length) {
535
- await Ne(n);
571
+ await Ve(n);
536
572
  for (const t of n)
537
- t?.id && X.delete(t.id);
573
+ t?.id && W.delete(t.id);
538
574
  }
539
575
  }
540
- async function wt(e) {
541
- return Ce(e);
576
+ async function Ft(e) {
577
+ return Ye(e);
542
578
  }
543
- async function xt() {
544
- return He();
579
+ async function Pt() {
580
+ return Xe();
545
581
  }
546
- function Le(e) {
547
- const t = (Array.isArray(e) ? e : [e]).map(we).filter(Boolean);
582
+ function je(e) {
583
+ const t = (Array.isArray(e) ? e : [e]).map(Ie).filter(Boolean);
548
584
  if (!t.length) return;
549
585
  const a = new Set(t);
550
- for (const s of a) X.delete(s);
551
- for (let s = j.length - 1; s >= 0; s -= 1) {
552
- const v = j[s].filter((y) => !a.has(y));
553
- v.length ? j[s] = v : j.splice(s, 1);
586
+ for (const s of a) W.delete(s);
587
+ for (let s = G.length - 1; s >= 0; s -= 1) {
588
+ const v = G[s].filter((y) => !a.has(y));
589
+ v.length ? G[s] = v : G.splice(s, 1);
554
590
  }
555
591
  }
556
- const pe = Et({
592
+ const Me = lt({
557
593
  enabled: !1,
558
594
  isBackfillActive: !1,
559
595
  isRequestInFlight: !1,
@@ -571,187 +607,187 @@ const jt = {
571
607
  pagesFetched: 0,
572
608
  itemsFetchedFromNetwork: 0
573
609
  }
574
- }), ze = Yt({
575
- getContent: (e) => Ee(e, N),
576
- markEnterFromLeft: me,
577
- buffer: ge,
578
- stats: pe,
610
+ }), We = Jt({
611
+ getContent: (e) => Oe(e, N),
612
+ markEnterFromLeft: we,
613
+ buffer: be,
614
+ stats: Me,
579
615
  isEnabled: () => l.mode === "backfill",
580
616
  getPageSize: () => l.pageSize,
581
617
  getRequestDelayMs: () => l.backfillRequestDelayMs
582
- }), ye = T(() => l.items !== void 0);
583
- W(
618
+ }), ke = S(() => l.items !== void 0);
619
+ U(
584
620
  () => l.items,
585
621
  (e) => {
586
- ye.value && (he.value = Array.isArray(e) ? e : []);
622
+ ke.value && (xe.value = Array.isArray(e) ? e : []);
587
623
  },
588
624
  { immediate: !0 }
589
625
  );
590
- const c = T({
626
+ const f = S({
591
627
  get() {
592
- return ye.value ? he.value : _e.value;
628
+ return ke.value ? xe.value : De.value;
593
629
  },
594
630
  set(e) {
595
- ye.value ? (he.value = e, r("update:items", e)) : _e.value = e;
631
+ ke.value ? (xe.value = e, u("update:items", e)) : De.value = e;
596
632
  }
597
633
  });
598
- async function qe(e) {
599
- const n = await Ee(e, N);
600
- return ee(n.items), me(n.items), { items: n.items, nextPage: n.nextPage };
634
+ async function Ge(e) {
635
+ const n = await Oe(e, N);
636
+ return te(n.items), we(n.items), { items: n.items, nextPage: n.nextPage };
601
637
  }
602
- function we(e) {
638
+ function Ie(e) {
603
639
  return e ? typeof e == "string" ? e : e?.id : null;
604
640
  }
605
- async function $e(e) {
606
- const t = (Array.isArray(e) ? e : [e]).map(we).filter(Boolean);
641
+ async function Ue(e) {
642
+ const t = (Array.isArray(e) ? e : [e]).map(Ie).filter(Boolean);
607
643
  if (!t.length) return;
608
644
  const a = new Set(t), s = [];
609
645
  for (const w of a) {
610
- const m = ue.value.get(w);
646
+ const m = fe.value.get(w);
611
647
  if (m == null) continue;
612
- const z = c.value[m];
613
- z && (X.set(w, z), s.push(w));
648
+ const $ = f.value[m];
649
+ $ && (W.set(w, $), s.push(w));
614
650
  }
615
- s.length && j.push(s);
616
- const f = Be(), v = se.value, y = [];
651
+ s.length && G.push(s);
652
+ const d = Le(), v = ue.value, y = [];
617
653
  for (const w of a) {
618
- const m = ue.value.get(w);
654
+ const m = fe.value.get(w);
619
655
  if (m == null) continue;
620
- const z = c.value[m];
621
- if (!z) continue;
622
- const le = _.value[m] ?? { x: 0, y: 0 }, Ke = G.value[m] ?? v;
656
+ const $ = f.value[m];
657
+ if (!$) continue;
658
+ const ce = se.value[m] ?? { x: 0, y: 0 }, at = ye.value[m] ?? v;
623
659
  y.push({
624
660
  id: w,
625
- item: z,
626
- fromX: le.x,
627
- fromY: le.y,
661
+ item: $,
662
+ fromX: ce.x,
663
+ fromY: ce.y,
628
664
  width: v,
629
- height: Ke,
665
+ height: at,
630
666
  leaving: !0
631
667
  });
632
668
  }
633
- if (y.length && (V.value = [...V.value, ...y]), c.value = c.value.filter((w) => {
669
+ if (y.length && (X.value = [...X.value, ...y]), f.value = f.value.filter((w) => {
634
670
  const m = w?.id;
635
671
  return !m || !a.has(m);
636
- }), await nt(), Te(f, a), y.length) {
672
+ }), await ct(), ze(d, a), y.length) {
637
673
  const w = new Set(y.map((m) => m.id));
638
- K(() => {
639
- V.value = V.value.map(
674
+ J(() => {
675
+ X.value = X.value.map(
640
676
  (m) => w.has(m.id) ? { ...m, leaving: !1 } : m
641
677
  ), setTimeout(() => {
642
- V.value = V.value.filter((m) => !w.has(m.id));
643
- }, rt);
678
+ X.value = X.value.filter((m) => !w.has(m.id));
679
+ }, ht);
644
680
  });
645
681
  }
646
682
  }
647
- async function Oe(e) {
648
- return $e(e);
683
+ async function Se(e) {
684
+ return Ue(e);
649
685
  }
650
- k({
651
- remove: $e,
652
- restore: wt,
653
- undo: xt,
654
- forget: Le,
655
- pagesLoaded: q,
656
- nextPage: C,
686
+ g({
687
+ remove: Ue,
688
+ restore: Ft,
689
+ undo: Pt,
690
+ forget: je,
691
+ pagesLoaded: D,
692
+ nextPage: H,
657
693
  // Aliases (kept for now; can be removed if you want strictly short API only).
658
- restoreRemoved: Ce,
659
- undoLastRemoval: He,
660
- forgetRemoved: Le,
661
- backfillStats: pe
694
+ restoreRemoved: Ye,
695
+ undoLastRemoval: Xe,
696
+ forgetRemoved: je,
697
+ backfillStats: Me
662
698
  });
663
- function Ve() {
664
- const e = Dt({
665
- items: c.value,
666
- columnCount: be.value,
667
- columnWidth: se.value,
668
- gapX: E.value,
669
- gapY: B.value,
670
- headerHeight: x.value,
671
- footerHeight: M.value,
672
- bucketPx: ot
699
+ function Ke() {
700
+ const e = Qt({
701
+ items: f.value,
702
+ columnCount: Pe.value,
703
+ columnWidth: ue.value,
704
+ gapX: k.value,
705
+ gapY: L.value,
706
+ headerHeight: z.value,
707
+ footerHeight: C.value,
708
+ bucketPx: dt
673
709
  });
674
- _.value = e.positions, G.value = e.heights, Me.value = e.buckets, Ie.value = e.contentHeight, ue.value = e.indexById;
710
+ se.value = e.positions, ye.value = e.heights, Ae.value = e.buckets, Ee.value = e.contentHeight, fe.value = e.indexById;
675
711
  }
676
- const Ye = T(() => Math.max(Ie.value, I.value) + Qt), xe = T(() => Xt({
677
- itemCount: c.value.length,
678
- viewportHeight: I.value,
679
- scrollTop: F.value,
712
+ const Je = S(() => Math.max(Ee.value, P.value) + rn), Fe = S(() => Zt({
713
+ itemCount: f.value.length,
714
+ viewportHeight: P.value,
715
+ scrollTop: T.value,
680
716
  overscanPx: l.overscanPx,
681
- bucketPx: ot,
682
- buckets: Me.value
717
+ bucketPx: dt,
718
+ buckets: Ae.value
683
719
  }));
684
- W(
685
- xe,
720
+ U(
721
+ Fe,
686
722
  (e) => {
687
723
  if (!e?.length) return;
688
724
  const n = [];
689
725
  for (const t of e) {
690
- const a = c.value[t]?.id;
691
- a && D.value.has(a) && (ce.has(a) || (ce.add(a), n.push(a)));
726
+ const a = f.value[t]?.id;
727
+ a && j.value.has(a) && (de.has(a) || (de.add(a), n.push(a)));
692
728
  }
693
- n.length && (K(() => {
694
- const t = new Set(U.value);
729
+ n.length && (J(() => {
730
+ const t = new Set(K.value);
695
731
  for (const a of n) t.add(a);
696
- U.value = t;
697
- }), ht(() => {
698
- const t = new Set(D.value);
732
+ K.value = t;
733
+ }), Mt(() => {
734
+ const t = new Set(j.value);
699
735
  for (const a of n) t.delete(a);
700
- D.value = t, setTimeout(() => {
701
- const a = new Set(U.value);
736
+ j.value = t, setTimeout(() => {
737
+ const a = new Set(K.value);
702
738
  for (const s of n)
703
- a.delete(s), ce.delete(s);
704
- U.value = a;
705
- }, lt);
739
+ a.delete(s), de.delete(s);
740
+ K.value = a;
741
+ }, mt);
706
742
  }));
707
743
  },
708
744
  { flush: "post" }
709
745
  );
710
- async function bt() {
711
- if (Q) return Q;
712
- if (ne.value || ae.value || l.mode !== "backfill" && C.value == null || l.mode === "backfill" && C.value == null && ge.value.length === 0)
746
+ async function Bt() {
747
+ if (Z) return Z;
748
+ if (le.value || re.value || l.mode !== "backfill" && H.value == null || l.mode === "backfill" && H.value == null && be.value.length === 0)
713
749
  return;
714
750
  const e = N;
715
751
  let n = null;
716
752
  return n = (async () => {
717
753
  try {
718
- if (ae.value = !0, J.value = "", l.mode === "backfill") {
719
- const s = await ze.loadBackfillBatch(C.value);
754
+ if (re.value = !0, Q.value = "", l.mode === "backfill") {
755
+ const s = await We.loadBackfillBatch(H.value);
720
756
  if (e !== N) return;
721
- s.pages.length && (q.value = [...q.value, ...s.pages]), ee(s.batchItems), c.value = [...c.value, ...s.batchItems], C.value = s.nextPage;
757
+ s.pages.length && (D.value = [...D.value, ...s.pages]), te(s.batchItems), f.value = [...f.value, ...s.batchItems], H.value = s.nextPage;
722
758
  return;
723
759
  }
724
- const t = C.value;
760
+ const t = H.value;
725
761
  if (t == null) return;
726
- const a = await qe(t);
762
+ const a = await Ge(t);
727
763
  if (e !== N) return;
728
- q.value = [...q.value, t], ee(a.items), c.value = [...c.value, ...a.items], C.value = a.nextPage;
764
+ D.value = [...D.value, t], te(a.items), f.value = [...f.value, ...a.items], H.value = a.nextPage;
729
765
  } catch (t) {
730
- if (e !== N || Re(t)) return;
731
- J.value = t instanceof Error ? t.message : String(t);
766
+ if (e !== N || qe(t)) return;
767
+ Q.value = t instanceof Error ? t.message : String(t);
732
768
  } finally {
733
- e === N && (ae.value = !1), Q === n && (Q = null);
769
+ e === N && (re.value = !1), Z === n && (Z = null);
734
770
  }
735
- })(), Q = n, n;
771
+ })(), Z = n, n;
736
772
  }
737
- function kt() {
738
- const e = g.value;
773
+ function Tt() {
774
+ const e = M.value;
739
775
  if (!e) return;
740
- F.value = e.scrollTop, I.value = e.clientHeight, e.scrollHeight - (e.scrollTop + e.clientHeight) <= l.prefetchThresholdPx && bt();
776
+ T.value = e.scrollTop, P.value = e.clientHeight, e.scrollHeight - (e.scrollTop + e.clientHeight) <= l.prefetchThresholdPx && Bt();
741
777
  }
742
- function De() {
743
- return g.value;
778
+ function Qe() {
779
+ return M.value;
744
780
  }
745
- function Xe(e) {
746
- b.value = H(e), I.value = e.clientHeight;
781
+ function Ze(e) {
782
+ I.value = A(e), P.value = e.clientHeight;
747
783
  }
748
- function Mt() {
749
- typeof ResizeObserver > "u" || (A = new ResizeObserver(() => {
750
- const e = De();
751
- e && Xe(e);
784
+ function Rt() {
785
+ typeof ResizeObserver > "u" || (E = new ResizeObserver(() => {
786
+ const e = Qe();
787
+ e && Ze(e);
752
788
  }));
753
789
  }
754
- function It() {
790
+ function _t() {
755
791
  return {
756
792
  enabled: l.mode === "backfill",
757
793
  isBackfillActive: !1,
@@ -762,8 +798,8 @@ const jt = {
762
798
  target: 0
763
799
  },
764
800
  cooldownMsRemaining: 0,
765
- cooldownMsTotal: ke(l.backfillRequestDelayMs),
766
- pageSize: ft(l.pageSize),
801
+ cooldownMsTotal: Te(l.backfillRequestDelayMs),
802
+ pageSize: yt(l.pageSize),
767
803
  bufferSize: 0,
768
804
  lastBatch: null,
769
805
  totals: {
@@ -772,22 +808,22 @@ const jt = {
772
808
  }
773
809
  };
774
810
  }
775
- function je() {
776
- N += 1, Q = null, Z = null, de = 0, X.clear(), j.length = 0, D.value = /* @__PURE__ */ new Set(), U.value = /* @__PURE__ */ new Set(), ce.clear(), fe.value = /* @__PURE__ */ new Map(), O.value = /* @__PURE__ */ new Set(), V.value = [], q.value = [], C.value = null, ge.value = [], pe.value = It(), ne.value = !0, ae.value = !1, J.value = "";
811
+ function et() {
812
+ N += 1, Z = null, ee = null, me = 0, W.clear(), G.length = 0, j.value = /* @__PURE__ */ new Set(), K.value = /* @__PURE__ */ new Set(), de.clear(), ve.value = /* @__PURE__ */ new Map(), Y.value = /* @__PURE__ */ new Set(), X.value = [], D.value = [], H.value = null, be.value = [], Me.value = _t(), le.value = !0, re.value = !1, Q.value = "";
777
813
  }
778
- function We(e) {
779
- je(), c.value = [], C.value = e;
814
+ function tt(e) {
815
+ et(), f.value = [], H.value = e;
780
816
  }
781
- function St(e) {
817
+ function At(e) {
782
818
  const n = Array.isArray(e) ? e : [e], t = [], a = /* @__PURE__ */ new Set();
783
819
  for (const s of n) {
784
820
  if (s == null) continue;
785
- const f = typeof s == "string" ? `s:${s}` : `n:${String(s)}`;
786
- a.has(f) || (a.add(f), t.push(s));
821
+ const d = typeof s == "string" ? `s:${s}` : `n:${String(s)}`;
822
+ a.has(d) || (a.add(d), t.push(s));
787
823
  }
788
824
  return t;
789
825
  }
790
- function Pt(e) {
826
+ function Et(e) {
791
827
  const n = [];
792
828
  for (const t of e) {
793
829
  if (typeof t == "number" && Number.isFinite(t)) {
@@ -801,103 +837,106 @@ const jt = {
801
837
  }
802
838
  return n.length ? Math.max(...n) + 1 : null;
803
839
  }
804
- function Ge(e) {
805
- je();
806
- const n = St(e);
807
- q.value = n, C.value = Pt(n), ne.value = !1, pt(c.value), ee(c.value);
840
+ function nt(e) {
841
+ et();
842
+ const n = At(e);
843
+ D.value = n, H.value = Et(n), le.value = !1, It(f.value), te(f.value);
808
844
  }
809
- async function Ue(e) {
810
- if (Z) return Z;
845
+ async function ot(e) {
846
+ if (ee) return ee;
811
847
  const n = N;
812
848
  let t = null;
813
849
  return t = (async () => {
814
850
  try {
815
851
  if (l.mode === "backfill") {
816
- const a = await ze.loadBackfillBatch(e);
852
+ const a = await We.loadBackfillBatch(e);
817
853
  if (n !== N) return;
818
- q.value = a.pages.length ? a.pages : [e], ee(a.batchItems), c.value = a.batchItems, C.value = a.nextPage;
854
+ D.value = a.pages.length ? a.pages : [e], te(a.batchItems), f.value = a.batchItems, H.value = a.nextPage;
819
855
  } else {
820
- const a = await qe(e);
856
+ const a = await Ge(e);
821
857
  if (n !== N) return;
822
- q.value = [e], ee(a.items), c.value = a.items, C.value = a.nextPage;
858
+ D.value = [e], te(a.items), f.value = a.items, H.value = a.nextPage;
823
859
  }
824
860
  } catch (a) {
825
- if (n !== N || Re(a)) return;
826
- J.value = a instanceof Error ? a.message : String(a);
861
+ if (n !== N || qe(a)) return;
862
+ Q.value = a instanceof Error ? a.message : String(a);
827
863
  } finally {
828
- n === N && (ne.value = !1), Z === t && (Z = null);
864
+ n === N && (le.value = !1), ee === t && (ee = null);
829
865
  }
830
- })(), Z = t, t;
866
+ })(), ee = t, t;
831
867
  }
832
- function Ft() {
833
- const e = De();
834
- e && (Xe(e), F.value = e.scrollTop, A?.observe(e));
868
+ function Nt() {
869
+ const e = Qe();
870
+ e && (Ze(e), T.value = e.scrollTop, E?.observe(e));
835
871
  }
836
- ut(async () => {
837
- if (Mt(), Ft(), l.restoredPagesLoaded != null) {
838
- Ge(l.restoredPagesLoaded);
872
+ Be(async () => {
873
+ if (Rt(), Nt(), l.restoredPagesLoaded != null) {
874
+ nt(l.restoredPagesLoaded);
839
875
  return;
840
876
  }
841
- We(l.page), await Ue(l.page);
842
- }), ct(() => {
843
- A?.disconnect();
844
- }), W(
877
+ tt(l.page), await ot(l.page);
878
+ }), gt(() => {
879
+ E?.disconnect();
880
+ }), U(
845
881
  () => l.page,
846
882
  async (e) => {
847
- l.restoredPagesLoaded == null && (We(e), await Ue(e));
883
+ l.restoredPagesLoaded == null && (tt(e), await ot(e));
848
884
  }
849
- ), W(
885
+ ), U(
850
886
  () => l.restoredPagesLoaded,
851
887
  (e) => {
852
- e && Ge(e);
888
+ e && nt(e);
853
889
  }
854
- ), W(
855
- E,
890
+ ), U(
891
+ k,
856
892
  () => {
857
- const e = g.value;
858
- e && (b.value = H(e));
893
+ const e = M.value;
894
+ e && (I.value = A(e));
859
895
  },
860
896
  { immediate: !1 }
861
897
  );
862
- const be = T(() => $t(b.value, l.itemWidth)), se = T(
863
- () => Ot(b.value, be.value, l.itemWidth, E.value)
898
+ const Pe = S(() => Gt(I.value, l.itemWidth)), ue = S(
899
+ () => Ut(I.value, Pe.value, l.itemWidth, k.value)
864
900
  );
865
- W(
866
- [be, se, E, B, x, M],
901
+ U(
902
+ [Pe, ue, k, L, z, C],
867
903
  () => {
868
- Ve();
904
+ Ke();
869
905
  },
870
906
  { immediate: !0 }
871
- ), W(
907
+ ), U(
872
908
  // Performance note: this component targets very large arrays (e.g. 10k items).
873
909
  // Avoid deep watchers over items; rebuild layout only when the list structure
874
910
  // changes (new array reference or length change). This keeps metadata-only
875
911
  // updates (e.g. reactions) cheap.
876
- () => [c.value, c.value.length],
877
- () => Ve(),
912
+ () => [f.value, f.value.length],
913
+ () => Ke(),
878
914
  { immediate: !0 }
879
915
  );
880
- const Bt = T(() => [
916
+ const Ct = S(() => [
881
917
  "mt-8 flex min-h-0 flex-1 flex-col rounded-2xl border border-slate-200/70 bg-white/70 p-5 shadow-sm backdrop-blur",
882
918
  p.class
883
919
  ]);
884
- return (e, n) => (P(), S("section", _t(i.value, { class: Bt.value }), [
885
- R("div", {
920
+ return (e, n) => (x(), F("section", qt(b.value, { class: Ct.value }), [
921
+ _("div", en, [
922
+ $t(e.$slots, "default")
923
+ ]),
924
+ _("div", {
886
925
  ref_key: "scrollViewportRef",
887
- ref: g,
926
+ ref: M,
888
927
  "data-testid": "items-scroll-container",
889
928
  class: "mt-4 min-h-0 flex-1 overflow-auto",
890
- style: $({ paddingRight: E.value + "px" }),
891
- onScroll: kt
929
+ style: V({ paddingRight: k.value + "px" }),
930
+ onScroll: Tt
892
931
  }, [
893
- ne.value ? (P(), S("div", jt, n[0] || (n[0] = [
894
- R("div", { class: "inline-flex items-center gap-3 text-sm text-slate-600" }, [
895
- R("svg", {
932
+ le.value ? (x(), F("div", tn, n[0] || (n[0] = [
933
+ _("div", { class: "inline-flex items-center gap-3 text-sm text-slate-600" }, [
934
+ _("svg", {
896
935
  class: "h-5 w-5 animate-spin text-slate-500",
897
936
  viewBox: "0 0 24 24",
898
937
  "aria-hidden": "true"
899
938
  }, [
900
- R("circle", {
939
+ _("circle", {
901
940
  class: "opacity-25",
902
941
  cx: "12",
903
942
  cy: "12",
@@ -906,102 +945,113 @@ const jt = {
906
945
  stroke: "currentColor",
907
946
  "stroke-width": "4"
908
947
  }),
909
- R("path", {
948
+ _("path", {
910
949
  class: "opacity-75",
911
950
  fill: "currentColor",
912
951
  d: "M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"
913
952
  })
914
953
  ]),
915
- R("span", null, "Loading…")
954
+ _("span", null, "Loading…")
916
955
  ], -1)
917
- ]))) : J.value ? (P(), S("p", Wt, "Error: " + Qe(J.value), 1)) : (P(), S("div", {
956
+ ]))) : Q.value ? (x(), F("p", nn, "Error: " + rt(Q.value), 1)) : (x(), F("div", {
918
957
  key: 2,
919
958
  class: "relative",
920
- style: $({ height: Ye.value + "px" })
959
+ style: V({ height: Je.value + "px" })
921
960
  }, [
922
- (P(!0), S(Ze, null, et(xe.value, (t) => (P(), S("article", {
923
- key: c.value[t].id,
961
+ (x(!0), F(it, null, ut(Fe.value, (t) => (x(), F("article", {
962
+ key: f.value[t].id,
924
963
  "data-testid": "item-card",
925
964
  class: "absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",
926
- style: $({
927
- width: se.value + "px",
928
- transition: vt(c.value[t].id),
929
- transform: mt(t)
965
+ style: V({
966
+ width: ue.value + "px",
967
+ transition: xt(f.value[t].id),
968
+ transform: bt(t)
930
969
  })
931
970
  }, [
932
- L.value || x.value > 0 ? (P(), S("div", {
971
+ q.value || z.value > 0 ? (x(), F("div", {
933
972
  key: 0,
934
973
  "data-testid": "item-header-container",
935
974
  class: "w-full",
936
- style: $(re.value)
975
+ style: V(Re.value)
937
976
  }, [
938
- ve(e.$slots, "itemHeader", {
939
- item: c.value[t],
940
- remove: () => Oe(c.value[t])
941
- })
942
- ], 4)) : te("", !0),
943
- tt(at, {
944
- item: c.value[t]
945
- }, null, 8, ["item"]),
946
- Y.value || M.value > 0 ? (P(), S("div", {
977
+ ge(ne(c), {
978
+ "slot-fn": R.value,
979
+ "slot-props": { item: f.value[t], remove: () => Se(f.value[t]) }
980
+ }, null, 8, ["slot-fn", "slot-props"])
981
+ ], 4)) : oe("", !0),
982
+ O.value ? (x(), he(ne(c), {
947
983
  key: 1,
984
+ "slot-fn": O.value,
985
+ "slot-props": { item: f.value[t], remove: () => Se(f.value[t]) }
986
+ }, null, 8, ["slot-fn", "slot-props"])) : (x(), he(ft, {
987
+ key: 2,
988
+ item: f.value[t]
989
+ }, null, 8, ["item"])),
990
+ ae.value || C.value > 0 ? (x(), F("div", {
991
+ key: 3,
948
992
  "data-testid": "item-footer-container",
949
993
  class: "w-full",
950
- style: $(ie.value)
994
+ style: V(_e.value)
951
995
  }, [
952
- ve(e.$slots, "itemFooter", {
953
- item: c.value[t],
954
- remove: () => Oe(c.value[t])
955
- })
956
- ], 4)) : te("", !0)
996
+ ge(ne(c), {
997
+ "slot-fn": B.value,
998
+ "slot-props": { item: f.value[t], remove: () => Se(f.value[t]) }
999
+ }, null, 8, ["slot-fn", "slot-props"])
1000
+ ], 4)) : oe("", !0)
957
1001
  ], 4))), 128)),
958
- (P(!0), S(Ze, null, et(V.value, (t) => (P(), S("article", {
1002
+ (x(!0), F(it, null, ut(X.value, (t) => (x(), F("article", {
959
1003
  key: t.id + ":leaving",
960
1004
  "data-testid": "item-card-leaving",
961
1005
  class: "pointer-events-none absolute overflow-hidden rounded-xl border border-slate-200/60 bg-white shadow-sm",
962
- style: $({
1006
+ style: V({
963
1007
  width: t.width + "px",
964
- transition: "transform " + rt + "ms ease-out",
965
- transform: t.leaving ? "translate3d(" + t.fromX + "px," + t.fromY + "px,0)" : "translate3d(" + t.fromX + "px," + Se(t.height) + "px,0)"
1008
+ transition: "transform " + ht + "ms ease-out",
1009
+ transform: t.leaving ? "translate3d(" + t.fromX + "px," + t.fromY + "px,0)" : "translate3d(" + t.fromX + "px," + Ne(t.height) + "px,0)"
966
1010
  })
967
1011
  }, [
968
- L.value || x.value > 0 ? (P(), S("div", {
1012
+ q.value || z.value > 0 ? (x(), F("div", {
969
1013
  key: 0,
970
1014
  "data-testid": "item-header-container",
971
1015
  class: "w-full",
972
- style: $(re.value)
1016
+ style: V(Re.value)
973
1017
  }, [
974
- ve(e.$slots, "itemHeader", {
975
- item: t.item,
976
- remove: () => {
977
- }
978
- })
979
- ], 4)) : te("", !0),
980
- tt(at, {
981
- item: t.item
982
- }, null, 8, ["item"]),
983
- Y.value || M.value > 0 ? (P(), S("div", {
1018
+ ge(ne(c), {
1019
+ "slot-fn": R.value,
1020
+ "slot-props": { item: t.item, remove: () => {
1021
+ } }
1022
+ }, null, 8, ["slot-fn", "slot-props"])
1023
+ ], 4)) : oe("", !0),
1024
+ O.value ? (x(), he(ne(c), {
984
1025
  key: 1,
1026
+ "slot-fn": O.value,
1027
+ "slot-props": { item: t.item, remove: () => {
1028
+ } }
1029
+ }, null, 8, ["slot-fn", "slot-props"])) : (x(), he(ft, {
1030
+ key: 2,
1031
+ item: t.item
1032
+ }, null, 8, ["item"])),
1033
+ ae.value || C.value > 0 ? (x(), F("div", {
1034
+ key: 3,
985
1035
  "data-testid": "item-footer-container",
986
1036
  class: "w-full",
987
- style: $(ie.value)
1037
+ style: V(_e.value)
988
1038
  }, [
989
- ve(e.$slots, "itemFooter", {
990
- item: t.item,
991
- remove: () => {
992
- }
993
- })
994
- ], 4)) : te("", !0)
1039
+ ge(ne(c), {
1040
+ "slot-fn": B.value,
1041
+ "slot-props": { item: t.item, remove: () => {
1042
+ } }
1043
+ }, null, 8, ["slot-fn", "slot-props"])
1044
+ ], 4)) : oe("", !0)
995
1045
  ], 4))), 128))
996
1046
  ], 4)),
997
- R("div", Gt, [
998
- ae.value ? (P(), S("span", Ut, n[1] || (n[1] = [
999
- R("svg", {
1047
+ _("div", on, [
1048
+ re.value ? (x(), F("span", an, n[1] || (n[1] = [
1049
+ _("svg", {
1000
1050
  class: "h-4 w-4 animate-spin text-slate-500",
1001
1051
  viewBox: "0 0 24 24",
1002
1052
  "aria-hidden": "true"
1003
1053
  }, [
1004
- R("circle", {
1054
+ _("circle", {
1005
1055
  class: "opacity-25",
1006
1056
  cx: "12",
1007
1057
  cy: "12",
@@ -1010,25 +1060,36 @@ const jt = {
1010
1060
  stroke: "currentColor",
1011
1061
  "stroke-width": "4"
1012
1062
  }),
1013
- R("path", {
1063
+ _("path", {
1014
1064
  class: "opacity-75",
1015
1065
  fill: "currentColor",
1016
1066
  d: "M4 12a8 8 0 0 1 8-8v4a4 4 0 0 0-4 4H4z"
1017
1067
  })
1018
1068
  ], -1),
1019
- R("span", null, "Loading more…", -1)
1020
- ]))) : C.value == null ? (P(), S("span", Kt, "End of list")) : (P(), S("span", Jt, "Scroll to load page " + Qe(C.value), 1))
1069
+ _("span", null, "Loading more…", -1)
1070
+ ]))) : H.value == null ? (x(), F("span", sn, "End of list")) : (x(), F("span", ln, "Scroll to load page " + rt(H.value), 1))
1021
1071
  ])
1022
1072
  ], 36)
1023
1073
  ], 16));
1024
1074
  }
1025
- }), an = {
1075
+ }), dn = pe({
1076
+ name: "MasonryItem",
1077
+ setup(o, { slots: g }) {
1078
+ const i = Ot(pt, null);
1079
+ return i ? (i({
1080
+ header: g.header,
1081
+ default: g.default,
1082
+ footer: g.footer
1083
+ }), () => null) : () => null;
1084
+ }
1085
+ }), mn = {
1026
1086
  install(o) {
1027
- o.component("Masonry", tn);
1087
+ o.component("Masonry", fn), o.component("MasonryItem", dn);
1028
1088
  }
1029
1089
  };
1030
1090
  export {
1031
- tn as Masonry,
1032
- an as VibePlugin,
1033
- Nt as masonryDefaults
1091
+ fn as Masonry,
1092
+ dn as MasonryItem,
1093
+ mn as VibePlugin,
1094
+ Dt as masonryDefaults
1034
1095
  };