@wyxos/vibe 5.0.3 → 5.2.1

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
@@ -13,8 +13,39 @@ function F(e, t) {
13
13
  return `${String(e)}:${t}`;
14
14
  }
15
15
  //#endregion
16
+ //#region src/core/mediaLifecycle.ts
17
+ function I(e, t, n, r, i) {
18
+ let a = e.items.findIndex((e) => e.postId === t), o = e.items[a];
19
+ if (!o) return null;
20
+ let s = N(o, n), c = P(o, s);
21
+ return {
22
+ item: o,
23
+ layout: r,
24
+ media: c,
25
+ mediaId: c.mediaId ?? null,
26
+ mediaIndex: s,
27
+ origin: i,
28
+ postId: o.postId,
29
+ postIndex: a
30
+ };
31
+ }
32
+ function L(e, t) {
33
+ O(() => {
34
+ let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null;
35
+ return {
36
+ mediaIndex: t === null ? 0 : e.mediaIndices.get(t) ?? 0,
37
+ origin: e.reelOrigin ?? "reel",
38
+ postId: t
39
+ };
40
+ }, (n, r) => {
41
+ if (n.postId === null || n.postId === r?.postId && n.mediaIndex === r.mediaIndex && n.origin === r.origin) return;
42
+ let i = I(e, n.postId, n.mediaIndex, "reel", n.origin);
43
+ i && t(i);
44
+ }, { flush: "sync" });
45
+ }
46
+ //#endregion
16
47
  //#region src/core/runtime.ts
17
- function I(e) {
48
+ function R(e) {
18
49
  return {
19
50
  activeReelPostId: e.activeReelPostId,
20
51
  autoScroll: { ...e.autoScroll },
@@ -42,17 +73,17 @@ function I(e) {
42
73
  }
43
74
  //#endregion
44
75
  //#region src/components/GalleryFooter.vue?vue&type=script&setup=true&lang.ts
45
- var L = {
76
+ var z = {
46
77
  key: 0,
47
78
  class: "gallery-footer"
48
- }, R = {
79
+ }, B = {
49
80
  key: 0,
50
81
  class: "load-more-status",
51
82
  role: "status"
52
- }, z = ["disabled"], B = {
83
+ }, V = ["disabled"], H = {
53
84
  key: 2,
54
85
  class: "end-feed"
55
- }, V = ["disabled"], H = /* @__PURE__ */ d({
86
+ }, ee = ["disabled"], te = /* @__PURE__ */ d({
56
87
  __name: "GalleryFooter",
57
88
  props: {
58
89
  canRetryEnd: { type: Boolean },
@@ -68,14 +99,14 @@ var L = {
68
99
  function i() {
69
100
  n.loadMoreLocked || (n.hasNext ? r("loadMore") : r("retryEnd"));
70
101
  }
71
- return (t, n) => e.isLoading || e.hasError || e.hasNext && e.showLoadMore || !e.hasNext && e.canRetryEnd ? (b(), s("footer", L, [e.isLoading ? (b(), s("p", R, " Loading more… ")) : e.hasError || e.hasNext && e.showLoadMore ? (b(), s("button", {
102
+ return (t, n) => e.isLoading || e.hasError || e.hasNext && e.showLoadMore || !e.hasNext && e.canRetryEnd ? (b(), s("footer", z, [e.isLoading ? (b(), s("p", B, " Loading more… ")) : e.hasError || e.hasNext && e.showLoadMore ? (b(), s("button", {
72
103
  key: 1,
73
104
  "data-test": "load-more",
74
105
  class: "load-more-button",
75
106
  type: "button",
76
107
  disabled: e.loadMoreLocked,
77
108
  onClick: i
78
- }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, z)) : (b(), s("div", B, [n[1] ||= c("p", {
109
+ }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, V)) : (b(), s("div", H, [n[1] ||= c("p", {
79
110
  class: "end-feed-message",
80
111
  role: "status"
81
112
  }, " You've reached the end. ", -1), c("button", {
@@ -84,9 +115,9 @@ var L = {
84
115
  type: "button",
85
116
  disabled: e.loadMoreLocked,
86
117
  onClick: n[0] ||= (e) => t.$emit("retryEnd")
87
- }, " Check for more ", 8, V)]))])) : o("", !0);
118
+ }, " Check for more ", 8, ee)]))])) : o("", !0);
88
119
  }
89
- }), U = /* @__PURE__ */ d({
120
+ }), ne = /* @__PURE__ */ d({
90
121
  __name: "FeedFooter",
91
122
  props: {
92
123
  actions: {},
@@ -123,7 +154,7 @@ var L = {
123
154
  "can-retry-end",
124
155
  "show-load-more",
125
156
  "state"
126
- ])) : (b(), a(H, {
157
+ ])) : (b(), a(te, {
127
158
  key: 1,
128
159
  "can-retry-end": e.canRetryEnd,
129
160
  "has-error": e.hasError,
@@ -142,7 +173,7 @@ var L = {
142
173
  "show-load-more"
143
174
  ]));
144
175
  }
145
- }), W = ["role"], ee = { class: "gallery-status" }, te = /* @__PURE__ */ d({
176
+ }), re = ["role"], ie = { class: "gallery-status" }, U = /* @__PURE__ */ d({
146
177
  __name: "FeedStatus",
147
178
  props: {
148
179
  actions: {},
@@ -156,7 +187,7 @@ var L = {
156
187
  return (n, u) => (b(), s("main", {
157
188
  class: "gallery-shell",
158
189
  role: r.state.error ? "alert" : r.state.isLoading ? "status" : void 0
159
- }, [c("p", ee, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(U, {
190
+ }, [c("p", ie, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(ne, {
160
191
  key: 0,
161
192
  actions: t.actions,
162
193
  "can-retry-end": t.canRetryEnd,
@@ -178,36 +209,36 @@ var L = {
178
209
  "is-loading",
179
210
  "load-more-locked",
180
211
  "state"
181
- ])) : o("", !0)], 8, W));
212
+ ])) : o("", !0)], 8, re));
182
213
  }
183
214
  });
184
- function G(e) {
215
+ function ae(e) {
185
216
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
186
217
  }
187
218
  //#endregion
188
219
  //#region src/core/masonry.ts
189
- function K(e) {
220
+ function W(e) {
190
221
  let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
191
222
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
192
223
  }
193
- function ne(e) {
224
+ function oe(e) {
194
225
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
195
226
  }
196
- function q(e) {
227
+ function se(e) {
197
228
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
198
229
  }
199
- function re(e, t) {
230
+ function G(e, t) {
200
231
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
201
232
  return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
202
233
  }
203
- function J(e, t, n) {
234
+ function K(e, t, n) {
204
235
  if (t <= 0 || e.length === 0) return {
205
236
  columns: 0,
206
237
  height: 0,
207
238
  items: []
208
239
  };
209
240
  let r = Math.max(0, n.gap), i = Number.isFinite(n.additionalHeight) ? Math.max(0, n.additionalHeight ?? 0) : 0, a = Math.max(1, n.minColumnWidth), o = Math.max(1, Math.floor((t + r) / (a + r))), s = (t - r * (o - 1)) / o, c = Array.from({ length: o }, () => 0), l = e.map((e) => {
210
- let t = ne(c), n = s * K(e) + i, a = {
241
+ let t = oe(c), n = s * W(e) + i, a = {
211
242
  x: t * (s + r),
212
243
  y: c[t],
213
244
  width: s,
@@ -223,10 +254,10 @@ function J(e, t, n) {
223
254
  }
224
255
  //#endregion
225
256
  //#region src/core/scrollbar.ts
226
- function ie(e, t, n) {
257
+ function q(e, t, n) {
227
258
  return Math.min(n, Math.max(t, e));
228
259
  }
229
- function ae({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
260
+ function ce({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
230
261
  let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
231
262
  if (!(c > 0 && o > 0)) return {
232
263
  maximumScrollPosition: c,
@@ -235,23 +266,23 @@ function ae({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
235
266
  thumbSize: o,
236
267
  thumbTravel: 0
237
268
  };
238
- let l = ie(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
269
+ let l = q(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
239
270
  return {
240
271
  maximumScrollPosition: c,
241
272
  scrollable: !0,
242
- thumbOffset: u * (ie(n, 0, c) / c),
273
+ thumbOffset: u * (q(n, 0, c) / c),
243
274
  thumbSize: l,
244
275
  thumbTravel: u
245
276
  };
246
277
  }
247
278
  //#endregion
248
279
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
249
- var oe = ["aria-hidden"], se = [
280
+ var le = ["aria-hidden"], J = [
250
281
  "aria-controls",
251
282
  "aria-valuemax",
252
283
  "aria-valuenow",
253
284
  "tabindex"
254
- ], ce = 32, Y = 40, le = 120, ue = /* @__PURE__ */ d({
285
+ ], ue = 32, de = 40, fe = 120, pe = /* @__PURE__ */ d({
255
286
  __name: "GalleryScrollbar",
256
287
  props: {
257
288
  contentSize: {},
@@ -273,16 +304,16 @@ var oe = ["aria-hidden"], se = [
273
304
  function k() {
274
305
  g !== null && clearTimeout(g), g = setTimeout(() => {
275
306
  g = null, o.value || (l.value = !1);
276
- }, le);
307
+ }, fe);
277
308
  }
278
309
  function A() {
279
310
  l.value = !0, k();
280
311
  }
281
312
  function j() {
282
313
  let e = t.scrollElement, r = i.value;
283
- return !e || !r ? n : ae({
314
+ return !e || !r ? n : ce({
284
315
  contentSize: e.scrollHeight,
285
- minimumThumbSize: ce,
316
+ minimumThumbSize: ue,
286
317
  scrollPosition: e.scrollTop,
287
318
  trackSize: r.clientHeight,
288
319
  viewportSize: e.clientHeight
@@ -335,7 +366,7 @@ var oe = ["aria-hidden"], se = [
335
366
  }
336
367
  function z(e) {
337
368
  if (!E.value) return;
338
- let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - Y : e.key === "ArrowDown" ? r + Y : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
369
+ let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - de : e.key === "ArrowDown" ? r + de : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
339
370
  i !== null && (e.preventDefault(), A(), P(i));
340
371
  }
341
372
  function B(e) {
@@ -381,15 +412,15 @@ var oe = ["aria-hidden"], se = [
381
412
  onPointerdown: I,
382
413
  onPointermove: L,
383
414
  onPointerup: R
384
- }, null, 44, se)], 42, oe));
415
+ }, null, 44, J)], 42, le));
385
416
  }
386
- }), de = (e) => {
417
+ }), Y = (e) => {
387
418
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
388
419
  return !1;
389
- }, fe = (e) => e === "", X = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), Z = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), pe = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), me = (e) => {
390
- let t = pe(e);
420
+ }, X = (e) => e === "", me = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), he = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ge = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), _e = (e) => {
421
+ let t = ge(e);
391
422
  return t.charAt(0).toUpperCase() + t.slice(1);
392
- }, he = {
423
+ }, ve = {
393
424
  xmlns: "http://www.w3.org/2000/svg",
394
425
  width: 24,
395
426
  height: 24,
@@ -399,27 +430,27 @@ var oe = ["aria-hidden"], se = [
399
430
  "stroke-width": 2,
400
431
  "stroke-linecap": "round",
401
432
  "stroke-linejoin": "round"
402
- }, ge = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = he.width, color: s = he.stroke, ...c }, { slots: l }) => p("svg", {
403
- ...he,
433
+ }, ye = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = ve.width, color: s = ve.stroke, ...c }, { slots: l }) => p("svg", {
434
+ ...ve,
404
435
  ...c,
405
436
  width: o,
406
437
  height: o,
407
438
  stroke: s,
408
- "stroke-width": fe(n) || fe(r) || n === !0 || r === !0 ? Number(i || a || he["stroke-width"]) * 24 / Number(o) : i || a || he["stroke-width"],
409
- class: X("lucide", c.class, ...e ? [`lucide-${Z(me(e))}-icon`, `lucide-${Z(e)}`] : ["lucide-icon"]),
410
- ...!l.default && !de(c) && { "aria-hidden": "true" }
411
- }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), _e = (e, t) => (n, { slots: r, attrs: i }) => p(ge, {
439
+ "stroke-width": X(n) || X(r) || n === !0 || r === !0 ? Number(i || a || ve["stroke-width"]) * 24 / Number(o) : i || a || ve["stroke-width"],
440
+ class: me("lucide", c.class, ...e ? [`lucide-${he(_e(e))}-icon`, `lucide-${he(e)}`] : ["lucide-icon"]),
441
+ ...!l.default && !Y(c) && { "aria-hidden": "true" }
442
+ }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), be = (e, t) => (n, { slots: r, attrs: i }) => p(ye, {
412
443
  ...i,
413
444
  ...n,
414
445
  iconNode: t,
415
446
  name: e
416
- }, r), ve = _e("chevron-left", [["path", {
447
+ }, r), xe = be("chevron-left", [["path", {
417
448
  d: "m15 18-6-6 6-6",
418
449
  key: "1wnfg3"
419
- }]]), ye = _e("chevron-right", [["path", {
450
+ }]]), Se = be("chevron-right", [["path", {
420
451
  d: "m9 18 6-6-6-6",
421
452
  key: "mthhwq"
422
- }]]), be = _e("pause", [["rect", {
453
+ }]]), Ce = be("pause", [["rect", {
423
454
  x: "14",
424
455
  y: "3",
425
456
  width: "5",
@@ -433,10 +464,10 @@ var oe = ["aria-hidden"], se = [
433
464
  height: "18",
434
465
  rx: "1",
435
466
  key: "1wsw3u"
436
- }]]), xe = _e("play", [["path", {
467
+ }]]), we = be("play", [["path", {
437
468
  d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
438
469
  key: "10ikf1"
439
- }]]), Se = _e("volume-2", [
470
+ }]]), Te = be("volume-2", [
440
471
  ["path", {
441
472
  d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
442
473
  key: "uqj9uw"
@@ -449,7 +480,7 @@ var oe = ["aria-hidden"], se = [
449
480
  d: "M19.364 18.364a9 9 0 0 0 0-12.728",
450
481
  key: "ijwkga"
451
482
  }]
452
- ]), Ce = _e("volume-x", [
483
+ ]), Ee = be("volume-x", [
453
484
  ["path", {
454
485
  d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
455
486
  key: "uqj9uw"
@@ -468,32 +499,32 @@ var oe = ["aria-hidden"], se = [
468
499
  y2: "15",
469
500
  key: "5ykzw1"
470
501
  }]
471
- ]), we = {
502
+ ]), De = {
472
503
  401: "Authentication required",
473
504
  403: "Access forbidden",
474
505
  404: "Preview not found",
475
506
  419: "Session expired",
476
507
  500: "Server error"
477
508
  };
478
- function Te(e) {
509
+ function Oe(e) {
479
510
  return e.match(/\/demo-errors\/(401|403|404|419|500)\//)?.[1] ?? "Error";
480
511
  }
481
- function Ee(e) {
482
- return we[Te(e)] ?? "Preview unavailable";
512
+ function ke(e) {
513
+ return De[Oe(e)] ?? "Preview unavailable";
483
514
  }
484
515
  //#endregion
485
516
  //#region src/core/mediaType.ts
486
- var De = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
487
- function Oe(e) {
517
+ var Ae = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
518
+ function je(e) {
488
519
  try {
489
- return De.test(new URL(e).pathname);
520
+ return Ae.test(new URL(e).pathname);
490
521
  } catch {
491
- return De.test(e.split("?")[0] ?? e);
522
+ return Ae.test(e.split("?")[0] ?? e);
492
523
  }
493
524
  }
494
525
  //#endregion
495
526
  //#region src/components/CardRegion.vue
496
- var ke = /* @__PURE__ */ d({
527
+ var Me = /* @__PURE__ */ d({
497
528
  __name: "CardRegion",
498
529
  props: {
499
530
  index: {},
@@ -540,18 +571,18 @@ var ke = /* @__PURE__ */ d({
540
571
  "total"
541
572
  ]))], 38));
542
573
  }
543
- }), Ae = [
574
+ }), Ne = [
544
575
  "max",
545
576
  "value",
546
577
  "aria-valuetext",
547
578
  "disabled"
548
- ], je = {
579
+ ], Pe = {
549
580
  key: 0,
550
581
  class: "media-controls-row"
551
- }, Me = ["aria-label", "title"], Ne = { class: "media-controls-audio" }, Pe = ["aria-label", "title"], Fe = ["value", "aria-valuetext"], Ie = {
582
+ }, Fe = ["aria-label", "title"], Ie = { class: "media-controls-audio" }, Le = ["aria-label", "title"], Re = ["value", "aria-valuetext"], ze = {
552
583
  class: "media-control-time",
553
584
  "aria-live": "off"
554
- }, Le = /* @__PURE__ */ d({
585
+ }, Be = /* @__PURE__ */ d({
555
586
  __name: "MediaControls",
556
587
  props: {
557
588
  currentTime: {},
@@ -599,35 +630,35 @@ var ke = /* @__PURE__ */ d({
599
630
  "aria-valuetext": `${u(p.value)} of ${u(f.value)}`,
600
631
  disabled: f.value <= 0,
601
632
  onInput: n[0] ||= (e) => i("seek", d(e))
602
- }, null, 44, Ae), e.layout === "reel" ? (b(), s("div", je, [
633
+ }, null, 44, Ne), e.layout === "reel" ? (b(), s("div", Pe, [
603
634
  c("button", {
604
635
  type: "button",
605
636
  class: "media-control-button media-control-playback",
606
637
  "aria-label": e.playing ? "Pause video" : "Play video",
607
638
  title: e.playing ? "Pause" : "Play",
608
639
  onClick: n[1] ||= (e) => i("togglePlayback")
609
- }, [e.playing ? (b(), a(E(be), {
640
+ }, [e.playing ? (b(), a(E(Ce), {
610
641
  key: 0,
611
642
  size: 18,
612
643
  fill: "currentColor"
613
- })) : (b(), a(E(xe), {
644
+ })) : (b(), a(E(we), {
614
645
  key: 1,
615
646
  size: 18,
616
647
  fill: "currentColor"
617
- }))], 8, Me),
618
- c("div", Ne, [c("button", {
648
+ }))], 8, Fe),
649
+ c("div", Ie, [c("button", {
619
650
  type: "button",
620
651
  class: "media-control-button",
621
652
  "aria-label": e.muted ? "Unmute video" : "Mute video",
622
653
  title: e.muted ? "Unmute" : "Mute",
623
654
  onClick: n[2] ||= (e) => i("toggleMute")
624
- }, [e.muted || e.volume === 0 ? (b(), a(E(Ce), {
655
+ }, [e.muted || e.volume === 0 ? (b(), a(E(Ee), {
625
656
  key: 0,
626
657
  size: 18
627
- })) : (b(), a(E(Se), {
658
+ })) : (b(), a(E(Te), {
628
659
  key: 1,
629
660
  size: 18
630
- }))], 8, Pe), c("input", {
661
+ }))], 8, Le), c("input", {
631
662
  class: "media-control-range media-control-volume",
632
663
  type: "range",
633
664
  min: "0",
@@ -638,14 +669,14 @@ var ke = /* @__PURE__ */ d({
638
669
  "aria-label": "Video volume",
639
670
  "aria-valuetext": `${Math.round(e.volume * 100)} percent`,
640
671
  onInput: n[3] ||= (e) => i("volumeChange", d(e))
641
- }, null, 44, Fe)]),
642
- c("output", Ie, T(u(p.value)) + " / " + T(u(f.value)), 1)
672
+ }, null, 44, Re)]),
673
+ c("output", ze, T(u(p.value)) + " / " + T(u(f.value)), 1)
643
674
  ])) : o("", !0)], 34));
644
675
  }
645
676
  });
646
677
  //#endregion
647
678
  //#region src/components/useReelVideoActivity.ts
648
- function Re(e) {
679
+ function Ve(e) {
649
680
  let t = r(() => e.layout() !== "reel" || e.active() === !0), n = r(() => t.value ? e.videoIsMuted.value : !0);
650
681
  function i() {
651
682
  if (!t.value) {
@@ -679,7 +710,7 @@ function Re(e) {
679
710
  }
680
711
  //#endregion
681
712
  //#region src/components/MediaCard.vue?vue&type=script&setup=true&lang.ts
682
- var ze = [
713
+ var He = [
683
714
  "data-post-id",
684
715
  "data-media-index",
685
716
  "aria-hidden",
@@ -687,12 +718,12 @@ var ze = [
687
718
  "inert",
688
719
  "role",
689
720
  "tabindex"
690
- ], Be = { class: "media-card-content" }, Ve = ["data-media-direction"], He = ["data-media-index"], Ue = {
721
+ ], Ue = { class: "media-card-content" }, We = ["data-media-direction"], Ge = ["data-media-index"], Ke = {
691
722
  key: 0,
692
723
  "data-test": "media-loading",
693
724
  class: "media-loading",
694
725
  "aria-hidden": "true"
695
- }, We = ["aria-label"], Ge = { class: "media-error-code" }, Ke = [
726
+ }, qe = ["aria-label"], Je = { class: "media-error-code" }, Ye = [
696
727
  "src",
697
728
  "width",
698
729
  "height",
@@ -700,12 +731,12 @@ var ze = [
700
731
  "loop",
701
732
  "muted",
702
733
  "preload"
703
- ], qe = [
734
+ ], Xe = [
704
735
  "src",
705
736
  "width",
706
737
  "height",
707
738
  "fetchpriority"
708
- ], Je = ["aria-label"], Ye = ["aria-label"], Xe = ["aria-label"], Ze = 40, Qe = 160, $e = 24, et = /* @__PURE__ */ d({
739
+ ], Ze = ["aria-label"], Qe = ["aria-label"], $e = ["aria-label"], et = 40, tt = 160, nt = 24, rt = /* @__PURE__ */ d({
709
740
  __name: "MediaCard",
710
741
  props: {
711
742
  active: { type: Boolean },
@@ -741,52 +772,52 @@ var ze = [
741
772
  function S(e = !1, t = "pointer") {
742
773
  e && x("activate", t);
743
774
  }
744
- let C = r(() => M(l.item)), D = r(() => N(l.item, l.mediaIndex)), O = r(() => P(l.item, D.value)), F = r(() => l.mediaSource === "original" ? O.value.src : O.value.preview.src), I = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), L = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), R = w(null), z = w(0), B = w(0), V = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), H = w(!1), U = w(1), W = 1, { effectiveMuted: ee, onPlaying: te, playbackAllowed: G } = Re({
775
+ let C = r(() => M(l.item)), D = r(() => N(l.item, l.mediaIndex)), O = r(() => P(l.item, D.value)), F = r(() => l.mediaSource === "original" ? O.value.src : O.value.preview.src), I = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), L = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), R = w(null), z = w(0), B = w(0), V = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), H = w(!1), ee = w(1), te = 1, { effectiveMuted: ne, onPlaying: re, playbackAllowed: ie } = Ve({
745
776
  active: () => l.active,
746
777
  layout: () => l.layout,
747
778
  videoElement: R,
748
779
  videoIsMuted: V,
749
780
  videoIsPlaying: H
750
- }), K = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
751
- function ne(e) {
781
+ }), U = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
782
+ function ae(e) {
752
783
  return e.detail === 0 ? "keyboard" : "pointer";
753
784
  }
754
- function q(e, t) {
785
+ function W(e, t) {
755
786
  let n = C.value.length, r = (e + n) % n;
756
787
  r !== D.value && (y.value = e < D.value ? "previous" : "next", x("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
757
788
  }
758
- function re(e, t, n) {
789
+ function oe(e, t, n) {
759
790
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
760
791
  }
761
- function J() {
792
+ function se() {
762
793
  f = 0, p = !1, d !== null && clearTimeout(d), d = null;
763
794
  }
764
- function ie() {
765
- d !== null && clearTimeout(d), d = setTimeout(J, Qe);
795
+ function G() {
796
+ d !== null && clearTimeout(d), d = setTimeout(se, tt);
766
797
  }
767
- function ae(e) {
798
+ function K(e) {
768
799
  if (C.value.length <= 1) return;
769
- let t = e.currentTarget?.clientWidth || 1, n = re(e.deltaX, e.deltaMode, t);
770
- if (n === 0 || (e.preventDefault(), ie(), p) || (f += n, Math.abs(f) < $e)) return;
800
+ let t = e.currentTarget?.clientWidth || 1, n = oe(e.deltaX, e.deltaMode, t);
801
+ if (n === 0 || (e.preventDefault(), G(), p) || (f += n, Math.abs(f) < nt)) return;
771
802
  let r = Math.sign(f);
772
- f = 0, p = !0, q(D.value + r);
803
+ f = 0, p = !0, W(D.value + r);
773
804
  }
774
- function oe(e) {
805
+ function q(e) {
775
806
  let t = e.touches[0];
776
807
  l.layout !== "reel" || !t || (m = t.clientX, g = t.clientY);
777
808
  }
778
- function se(e) {
809
+ function ce(e) {
779
810
  let t = e.changedTouches[0];
780
811
  if (m === null || g === null || !t) return;
781
812
  let n = m - t.clientX, r = g - t.clientY;
782
- m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ze || q(D.value + Math.sign(n)));
813
+ m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < et || W(D.value + Math.sign(n)));
783
814
  }
784
- let ce = r(() => Oe(F.value)), Y = r(() => l.layout === "reel" && l.stationaryReelControls === !0), le = r(() => ce.value && l.previewState === "ready" && (!Y.value || !!(l.active && l.reelControlsTarget))), ue = r(() => `${l.item.postId}:${D.value}:${F.value}`);
785
- function de(e) {
786
- l.layout === "reel" && (e.stopPropagation(), fe());
815
+ let le = r(() => je(F.value)), J = r(() => l.layout === "reel" && l.stationaryReelControls === !0), ue = r(() => le.value && l.previewState === "ready" && (!J.value || !!(l.active && l.reelControlsTarget))), de = r(() => `${l.item.postId}:${D.value}:${F.value}`);
816
+ function fe(e) {
817
+ l.layout === "reel" && (e.stopPropagation(), pe());
787
818
  }
788
- async function fe() {
789
- if (!(!R.value || !G.value)) {
819
+ async function pe() {
820
+ if (!(!R.value || !ie.value)) {
790
821
  if (H.value) {
791
822
  R.value.pause();
792
823
  return;
@@ -798,35 +829,35 @@ var ze = [
798
829
  }
799
830
  }
800
831
  }
801
- function X(e) {
832
+ function Y(e) {
802
833
  return Number.isFinite(e) ? Math.max(0, e) : 0;
803
834
  }
804
- function Z(e) {
835
+ function X(e) {
805
836
  let t = e?.currentTarget ?? R.value;
806
- t && (z.value = X(t.currentTime), B.value = X(t.duration), G.value && (V.value = t.muted), U.value = t.volume, t.volume > 0 && (W = t.volume));
837
+ t && (z.value = Y(t.currentTime), B.value = Y(t.duration), ie.value && (V.value = t.muted), ee.value = t.volume, t.volume > 0 && (te = t.volume));
807
838
  }
808
- function pe(e) {
809
- Z(e), x("ready", D.value);
839
+ function me(e) {
840
+ X(e), x("ready", D.value);
810
841
  }
811
- function me() {
842
+ function he() {
812
843
  H.value = !1, x("ended", D.value);
813
844
  }
814
- function he(e) {
845
+ function ge(e) {
815
846
  let t = R.value;
816
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(X(t.duration), Math.max(0, e)), z.value = t.currentTime);
847
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(Y(t.duration), Math.max(0, e)), z.value = t.currentTime);
817
848
  }
818
- function ge(e) {
849
+ function _e(e) {
819
850
  let t = R.value;
820
851
  if (!t || !Number.isFinite(e)) return;
821
852
  let n = Math.min(1, Math.max(0, e));
822
- t.volume = n, t.muted = n === 0, n > 0 && (W = n), Z();
853
+ t.volume = n, t.muted = n === 0, n > 0 && (te = n), X();
823
854
  }
824
- function _e() {
855
+ function ve() {
825
856
  let e = R.value;
826
- e && (e.muted && e.volume === 0 && (e.volume = W), e.muted = !e.muted, Z());
857
+ e && (e.muted && e.volume === 0 && (e.volume = te), e.muted = !e.muted, X());
827
858
  }
828
859
  return v(() => {
829
- J();
860
+ se();
830
861
  }), (r, i) => (b(), s("article", {
831
862
  "data-post-id": e.item.postId,
832
863
  "data-media-index": D.value,
@@ -840,12 +871,12 @@ var ze = [
840
871
  "aria-hidden": e.leaving || void 0,
841
872
  "aria-busy": e.previewState === "loading",
842
873
  inert: e.leaving || void 0,
843
- role: e.interactive && !e.leaving && !K.value ? "button" : void 0,
844
- tabindex: e.interactive && !e.leaving && !K.value ? 0 : void 0,
845
- onClick: i[11] ||= (t) => S(e.interactive && !K.value, ne(t)),
846
- onKeydown: [i[12] ||= A((t) => S(e.interactive && !K.value, "keyboard"), ["enter"]), i[13] ||= A(j((t) => S(e.interactive && !K.value, "keyboard"), ["prevent"]), ["space"])]
847
- }, [c("div", Be, [
848
- e.cardHeader ? (b(), a(ke, {
874
+ role: e.interactive && !e.leaving && !U.value ? "button" : void 0,
875
+ tabindex: e.interactive && !e.leaving && !U.value ? 0 : void 0,
876
+ onClick: i[11] ||= (t) => S(e.interactive && !U.value, ae(t)),
877
+ onKeydown: [i[12] ||= A((t) => S(e.interactive && !U.value, "keyboard"), ["enter"]), i[13] ||= A(j((t) => S(e.interactive && !U.value, "keyboard"), ["prevent"]), ["space"])]
878
+ }, [c("div", Ue, [
879
+ e.cardHeader ? (b(), a(Me, {
849
880
  key: 0,
850
881
  index: e.index,
851
882
  item: e.item,
@@ -871,22 +902,22 @@ var ze = [
871
902
  c("div", {
872
903
  class: h(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && C.value.length > 1 }]),
873
904
  "data-media-direction": y.value,
874
- onWheel: ae,
875
- onTouchstartPassive: oe,
876
- onTouchendPassive: se
905
+ onWheel: K,
906
+ onTouchstartPassive: q,
907
+ onTouchendPassive: ce
877
908
  }, [
878
909
  u(n, { name: `media-slide-${y.value}` }, {
879
910
  default: k(() => [(b(), s("div", {
880
911
  key: `${e.item.postId}:${O.value.src}:${e.mediaSource ?? "preview"}`,
881
912
  class: "media-card-frame",
882
913
  "data-media-index": D.value
883
- }, [e.previewState === "loading" ? (b(), s("div", Ue, [...i[14] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (b(), s("div", {
914
+ }, [e.previewState === "loading" ? (b(), s("div", Ke, [...i[14] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (b(), s("div", {
884
915
  key: 1,
885
916
  "data-test": "media-error",
886
917
  class: "media-error",
887
918
  role: "img",
888
- "aria-label": `${E(Te)(F.value)} ${E(Ee)(F.value)}`
889
- }, [c("strong", Ge, T(E(Te)(F.value)), 1), c("span", null, T(E(Ee)(F.value)), 1)], 8, We)) : o("", !0), ce.value ? (b(), s("video", {
919
+ "aria-label": `${E(Oe)(F.value)} ${E(ke)(F.value)}`
920
+ }, [c("strong", Je, T(E(Oe)(F.value)), 1), c("span", null, T(E(ke)(F.value)), 1)], 8, qe)) : o("", !0), le.value ? (b(), s("video", {
890
921
  key: 2,
891
922
  ref_key: "videoElement",
892
923
  ref: R,
@@ -897,21 +928,21 @@ var ze = [
897
928
  src: F.value,
898
929
  width: I.value ?? void 0,
899
930
  height: L.value ?? void 0,
900
- autoplay: E(G),
931
+ autoplay: E(ie),
901
932
  loop: !e.advanceOnMediaEnd,
902
- muted: E(ee),
933
+ muted: E(ne),
903
934
  playsinline: "",
904
935
  preload: e.fetchPriority === "high" ? "auto" : "metadata",
905
- onLoadedmetadata: pe,
906
- onDurationchange: Z,
907
- onTimeupdate: Z,
908
- onVolumechange: Z,
909
- onPlaying: i[0] ||= (...e) => E(te) && E(te)(...e),
936
+ onLoadedmetadata: me,
937
+ onDurationchange: X,
938
+ onTimeupdate: X,
939
+ onVolumechange: X,
940
+ onPlaying: i[0] ||= (...e) => E(re) && E(re)(...e),
910
941
  onPause: i[1] ||= (e) => H.value = !1,
911
- onEnded: me,
912
- onClick: de,
942
+ onEnded: he,
943
+ onClick: fe,
913
944
  onError: i[2] ||= (e) => r.$emit("error", D.value)
914
- }, null, 42, Ke)) : (b(), s("img", {
945
+ }, null, 42, Ye)) : (b(), s("img", {
915
946
  key: 3,
916
947
  class: h(["media-preview", { "media-preview--ready": e.previewState === "ready" }]),
917
948
  src: F.value,
@@ -923,29 +954,29 @@ var ze = [
923
954
  loading: "eager",
924
955
  onLoad: i[3] ||= (e) => r.$emit("ready", D.value),
925
956
  onError: i[4] ||= (e) => r.$emit("error", D.value)
926
- }, null, 42, qe))], 8, He))]),
957
+ }, null, 42, Xe))], 8, Ge))]),
927
958
  _: 1
928
959
  }, 8, ["name"]),
929
960
  (b(), a(t, {
930
- disabled: !Y.value || !e.reelControlsTarget,
961
+ disabled: !J.value || !e.reelControlsTarget,
931
962
  to: e.reelControlsTarget ?? "body"
932
963
  }, [u(n, {
933
964
  name: "vibe-reel-media-controls",
934
- css: Y.value
965
+ css: J.value
935
966
  }, {
936
- default: k(() => [le.value ? (b(), a(Le, {
937
- key: ue.value,
967
+ default: k(() => [ue.value ? (b(), a(Be, {
968
+ key: de.value,
938
969
  "current-time": z.value,
939
- "data-control-post-id": Y.value ? e.item.postId : void 0,
970
+ "data-control-post-id": J.value ? e.item.postId : void 0,
940
971
  duration: B.value,
941
972
  layout: e.layout,
942
973
  muted: V.value,
943
974
  playing: H.value,
944
- volume: U.value,
945
- onSeek: he,
946
- onToggleMute: _e,
947
- onTogglePlayback: fe,
948
- onVolumeChange: ge
975
+ volume: ee.value,
976
+ onSeek: ge,
977
+ onToggleMute: ve,
978
+ onTogglePlayback: pe,
979
+ onVolumeChange: _e
949
980
  }, null, 8, [
950
981
  "current-time",
951
982
  "data-control-post-id",
@@ -965,25 +996,25 @@ var ze = [
965
996
  type: "button",
966
997
  class: "media-carousel-control media-carousel-control--previous",
967
998
  "aria-label": `Previous media for post ${e.item.postId}`,
968
- onClick: i[5] ||= j((e) => q(D.value - 1, e), ["stop"]),
999
+ onClick: i[5] ||= j((e) => W(D.value - 1, e), ["stop"]),
969
1000
  onKeydown: i[6] ||= j(() => {}, ["stop"])
970
- }, [u(E(ve), { size: 20 })], 40, Je), c("button", {
1001
+ }, [u(E(xe), { size: 20 })], 40, Ze), c("button", {
971
1002
  type: "button",
972
1003
  class: "media-carousel-control media-carousel-control--next",
973
1004
  "aria-label": `Next media for post ${e.item.postId}`,
974
- onClick: i[7] ||= j((e) => q(D.value + 1, e), ["stop"]),
1005
+ onClick: i[7] ||= j((e) => W(D.value + 1, e), ["stop"]),
975
1006
  onKeydown: i[8] ||= j(() => {}, ["stop"])
976
- }, [u(E(ye), { size: 20 })], 40, Ye)], 2)) : o("", !0),
977
- K.value ? (b(), s("button", {
1007
+ }, [u(E(Se), { size: 20 })], 40, Qe)], 2)) : o("", !0),
1008
+ U.value ? (b(), s("button", {
978
1009
  key: 1,
979
1010
  class: "media-card-activator",
980
1011
  type: "button",
981
1012
  "aria-label": `Open post ${e.item.postId}`,
982
- onClick: i[9] ||= j((e) => r.$emit("activate", ne(e)), ["stop"]),
1013
+ onClick: i[9] ||= j((e) => r.$emit("activate", ae(e)), ["stop"]),
983
1014
  onKeydown: i[10] ||= j(() => {}, ["stop"])
984
- }, null, 40, Xe)) : o("", !0)
985
- ], 42, Ve),
986
- e.cardFooter ? (b(), a(ke, {
1015
+ }, null, 40, $e)) : o("", !0)
1016
+ ], 42, We),
1017
+ e.cardFooter ? (b(), a(Me, {
987
1018
  key: 1,
988
1019
  index: e.index,
989
1020
  item: e.item,
@@ -1006,9 +1037,9 @@ var ze = [
1006
1037
  "style",
1007
1038
  "total"
1008
1039
  ])) : o("", !0)
1009
- ])], 46, ze));
1040
+ ])], 46, He));
1010
1041
  }
1011
- }), tt = { class: "masonry-feed-shell" }, nt = ["aria-hidden", "inert"], rt = 240, it = 6, at = 12, ot = 800, st = 1.5, ct = /* @__PURE__ */ d({
1042
+ }), it = { class: "masonry-feed-shell" }, at = ["aria-hidden", "inert"], ot = 240, st = 6, ct = 12, lt = 800, ut = 1.5, dt = /* @__PURE__ */ d({
1012
1043
  __name: "MasonryFeed",
1013
1044
  props: {
1014
1045
  enteringPostIds: {},
@@ -1042,36 +1073,36 @@ var ze = [
1042
1073
  "retryEnd"
1043
1074
  ],
1044
1075
  setup(t, { expose: n, emit: i }) {
1045
- let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(it), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => J(o.items, m.value, {
1076
+ let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(st), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => K(o.items, m.value, {
1046
1077
  additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1047
1078
  gap: g.value,
1048
- minColumnWidth: rt
1079
+ minColumnWidth: ot
1049
1080
  })), M = r(() => {
1050
1081
  let e = j.value;
1051
1082
  if (o.leavingPostIds.size === 0) return e;
1052
- let t = o.items.filter((e) => !o.leavingPostIds.has(e.postId)), n = J(t, m.value, {
1083
+ let t = o.items.filter((e) => !o.leavingPostIds.has(e.postId)), n = K(t, m.value, {
1053
1084
  additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1054
1085
  gap: g.value,
1055
- minColumnWidth: rt
1086
+ minColumnWidth: ot
1056
1087
  }), r = new Map(t.map((e, t) => [e.postId, n.items[t]]));
1057
1088
  return {
1058
1089
  ...n,
1059
1090
  items: o.items.map((t, n) => o.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
1060
1091
  };
1061
1092
  }), N = r(() => ({ height: `${o.leavingPostIds.size === 0 ? M.value.height : j.value.height}px` })), P = r(() => !o.infiniteScroll || x.value > 0 && C.value + M.value.height <= x.value + 1), I = r(() => {
1062
- let e = Math.max(ot, x.value * st), t = {
1093
+ let e = Math.max(lt, x.value * ut), t = {
1063
1094
  scrollTop: y.value - C.value,
1064
1095
  viewportHeight: x.value
1065
- }, n = re(M.value.items, {
1096
+ }, n = G(M.value.items, {
1066
1097
  ...t,
1067
1098
  overscan: e
1068
- }), r = o.leavingPostIds.size === 0 ? [] : re(j.value.items, {
1099
+ }), r = o.leavingPostIds.size === 0 ? [] : G(j.value.items, {
1069
1100
  ...t,
1070
1101
  overscan: e
1071
- }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = re(M.value.items, {
1102
+ }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = G(M.value.items, {
1072
1103
  ...t,
1073
1104
  overscan: 0
1074
- }), s = o.leavingPostIds.size === 0 ? [] : re(j.value.items, {
1105
+ }), s = o.leavingPostIds.size === 0 ? [] : G(j.value.items, {
1075
1106
  ...t,
1076
1107
  overscan: 0
1077
1108
  }), c = new Set([...a, ...s]);
@@ -1087,7 +1118,7 @@ var ze = [
1087
1118
  function L(e) {
1088
1119
  let t = M.value.items[e], n = o.items[e]?.postId;
1089
1120
  if (!t) return {};
1090
- let r = n !== void 0 && o.enteringPostIds.has(n), i = n !== void 0 && o.leavingPostIds.has(n), a = r || i ? q({
1121
+ let r = n !== void 0 && o.enteringPostIds.has(n), i = n !== void 0 && o.leavingPostIds.has(n), a = r || i ? se({
1091
1122
  containerHeight: j.value.height,
1092
1123
  gap: g.value
1093
1124
  }) : 0, s = n === void 0 ? 0 : i ? o.removalDelays.get(n) ?? 0 : r ? o.entryDelays.get(n) ?? 0 : 0;
@@ -1107,15 +1138,15 @@ var ze = [
1107
1138
  }
1108
1139
  function z(e) {
1109
1140
  let t = e.ownerDocument.documentElement.clientWidth;
1110
- m.value = e.clientWidth, g.value = Math.min(at, Math.max(it, t * .0075)), R();
1141
+ m.value = e.clientWidth, g.value = Math.min(ct, Math.max(st, t * .0075)), R();
1111
1142
  }
1112
1143
  function B(e) {
1113
1144
  let t = e.currentTarget;
1114
- t && (y.value = t.scrollTop, !o.loadMoreLocked && o.infiniteScroll && G(t) && l("loadMore"));
1145
+ t && (y.value = t.scrollTop, !o.loadMoreLocked && o.infiniteScroll && ae(t) && l("loadMore"));
1115
1146
  }
1116
1147
  function V() {
1117
1148
  let e = d.value;
1118
- !o.loadMoreLocked && e && G(e) && l("loadMore");
1149
+ !o.loadMoreLocked && e && ae(e) && l("loadMore");
1119
1150
  }
1120
1151
  function H() {
1121
1152
  return d.value;
@@ -1134,7 +1165,7 @@ var ze = [
1134
1165
  }), n({
1135
1166
  getScrollElement: H,
1136
1167
  loadIfNearBottom: V
1137
- }), (n, r) => (b(), s("div", tt, [c("main", {
1168
+ }), (n, r) => (b(), s("div", it, [c("main", {
1138
1169
  id: f,
1139
1170
  ref_key: "galleryElement",
1140
1171
  ref: d,
@@ -1149,7 +1180,7 @@ var ze = [
1149
1180
  class: h(["masonry", { "masonry--ready": m.value > 0 }]),
1150
1181
  style: _(N.value),
1151
1182
  "aria-label": "Media gallery"
1152
- }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(et, {
1183
+ }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(rt, {
1153
1184
  key: n.postId,
1154
1185
  class: "masonry-item",
1155
1186
  entering: t.enteringPostIds.has(n.postId),
@@ -1189,7 +1220,7 @@ var ze = [
1189
1220
  "onMediaChange",
1190
1221
  "onReady",
1191
1222
  "onError"
1192
- ]))), 128))], 6), u(U, {
1223
+ ]))), 128))], 6), u(ne, {
1193
1224
  actions: t.feedFooterActions,
1194
1225
  "can-retry-end": t.canRetryEnd,
1195
1226
  "feed-footer": t.feedFooter,
@@ -1211,7 +1242,7 @@ var ze = [
1211
1242
  "load-more-locked",
1212
1243
  "show-load-more",
1213
1244
  "state"
1214
- ])], 42, nt), u(ue, {
1245
+ ])], 42, at), u(pe, {
1215
1246
  "content-size": M.value.height,
1216
1247
  "controls-id": f,
1217
1248
  "scroll-element": d.value,
@@ -1222,8 +1253,8 @@ var ze = [
1222
1253
  "suspended"
1223
1254
  ])]));
1224
1255
  }
1225
- }), lt = 300;
1226
- function ut(e, t, n) {
1256
+ }), ft = 300;
1257
+ function pt(e, t, n) {
1227
1258
  let r = e.scrollTop;
1228
1259
  if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
1229
1260
  e.setAttribute("data-transitioning", "");
@@ -1231,7 +1262,7 @@ function ut(e, t, n) {
1231
1262
  return new Promise((n) => {
1232
1263
  let o = (s) => {
1233
1264
  a += 1;
1234
- let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / lt), u = 1 - (1 - l) ** 3;
1265
+ let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / ft), u = 1 - (1 - l) ** 3;
1235
1266
  if (e.scrollTop = r + (t - r) * u, l < 1) {
1236
1267
  requestAnimationFrame(o);
1237
1268
  return;
@@ -1243,7 +1274,7 @@ function ut(e, t, n) {
1243
1274
  }
1244
1275
  //#endregion
1245
1276
  //#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
1246
- var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1277
+ var mt = ["aria-label"], ht = /* @__PURE__ */ d({
1247
1278
  __name: "ReelAutoAdvanceProgress",
1248
1279
  props: {
1249
1280
  durationMs: {},
@@ -1261,9 +1292,9 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1261
1292
  class: "reel-auto-advance-progress",
1262
1293
  style: _(a.value),
1263
1294
  onAnimationend: n[0] ||= (e) => i("complete")
1264
- }, null, 36)], 8, dt));
1295
+ }, null, 36)], 8, mt));
1265
1296
  }
1266
- }), pt = { class: "reel-viewport" }, mt = ["data-active-post-id", "data-active-media-index"], ht = ["role", "data-status"], gt = 2, _t = 300, vt = /* @__PURE__ */ d({
1297
+ }), gt = { class: "reel-viewport" }, _t = ["data-active-post-id", "data-active-media-index"], vt = ["role", "data-status"], yt = 2, bt = 300, xt = /* @__PURE__ */ d({
1267
1298
  __name: "ReelFeed",
1268
1299
  props: {
1269
1300
  initialPostId: {},
@@ -1301,7 +1332,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1301
1332
  ],
1302
1333
  setup(t, { expose: n, emit: i }) {
1303
1334
  let l = t, u = i, d = w(null), f = w(null), p = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId), g = w(Math.max(0, p)), x = w(!1), C = w(!1), D = 0, k = null, A = null, j = null, N = r(() => ({ gridTemplateRows: `repeat(${l.items.length}, 100cqh)` })), I = r(() => {
1304
- let e = Math.max(0, g.value - gt), t = Math.min(l.items.length - 1, g.value + gt);
1335
+ let e = Math.max(0, g.value - yt), t = Math.min(l.items.length - 1, g.value + yt);
1305
1336
  return l.items.slice(e, t + 1).map((t, n) => ({
1306
1337
  fetchPriority: e + n === g.value ? "high" : "low",
1307
1338
  index: e + n,
@@ -1318,7 +1349,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1318
1349
  if (!e) return "";
1319
1350
  let t = P(e, z.value);
1320
1351
  return l.mediaSource === "original" ? t.src : t.preview.src;
1321
- }), H = r(() => B.value === "ready" && Oe(V.value)), W = r(() => [
1352
+ }), H = r(() => B.value === "ready" && je(V.value)), ee = r(() => [
1322
1353
  L.value,
1323
1354
  z.value,
1324
1355
  l.items.length,
@@ -1326,49 +1357,49 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1326
1357
  l.reelAutoAdvance.enabled,
1327
1358
  l.reelAutoAdvance.includePostItems,
1328
1359
  l.reelAutoAdvance.intervalMs
1329
- ].join(":")), ee = r(() => {
1360
+ ].join(":")), te = r(() => {
1330
1361
  let e = R.value, t = !!(e && l.reelAutoAdvance.includePostItems && z.value < M(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
1331
1362
  return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
1332
- }), te = r(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && R.value !== void 0 && B.value !== "loading" && !H.value), K = r(() => !l.infiniteScroll || l.items.length <= 1), ne = r(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1333
- function q(e) {
1363
+ }), re = r(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && R.value !== void 0 && B.value !== "loading" && !H.value), ie = r(() => !l.infiniteScroll || l.items.length <= 1), U = r(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1364
+ function W(e) {
1334
1365
  return { gridRow: `${e + 1}` };
1335
1366
  }
1336
- function re(e) {
1367
+ function oe(e) {
1337
1368
  let t = D || e.clientHeight;
1338
1369
  return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1339
1370
  }
1340
- function J(e) {
1371
+ function se(e) {
1341
1372
  let t = e.currentTarget;
1342
1373
  if (!t) return;
1343
1374
  let n = D || t.clientHeight, r = Math.max(0, l.items.length - 1) * n;
1344
- x.value = l.items.length > 0 && t.scrollTop > r + 1, C.value || (g.value = re(t)), !l.loadMoreLocked && l.infiniteScroll && G(t) && u("loadMore");
1375
+ x.value = l.items.length > 0 && t.scrollTop > r + 1, C.value || (g.value = oe(t)), !l.loadMoreLocked && l.infiniteScroll && ae(t) && u("loadMore");
1345
1376
  }
1346
- function ie() {
1377
+ function G() {
1347
1378
  let e = d.value;
1348
- e && (x.value = !1, se(!0), D = e.clientHeight, e.scrollTop = g.value * D, A !== null && cancelAnimationFrame(A), A = requestAnimationFrame(() => {
1379
+ e && (x.value = !1, ce(!0), D = e.clientHeight, e.scrollTop = g.value * D, A !== null && cancelAnimationFrame(A), A = requestAnimationFrame(() => {
1349
1380
  e.scrollTop = g.value * e.clientHeight, D = e.clientHeight, A = null;
1350
- }), ae());
1381
+ }), K());
1351
1382
  }
1352
- function ae() {
1383
+ function K() {
1353
1384
  j !== null && clearTimeout(j), j = setTimeout(() => {
1354
1385
  j = null;
1355
1386
  let e = d.value;
1356
- e && (D = e.clientHeight, e.scrollTop = g.value * D), se(!1);
1387
+ e && (D = e.clientHeight, e.scrollTop = g.value * D), ce(!1);
1357
1388
  }, 120);
1358
1389
  }
1359
- function oe() {
1360
- se(!0);
1390
+ function q() {
1391
+ ce(!0);
1361
1392
  let e = d.value;
1362
- e && (D = e.clientHeight, e.scrollTop = g.value * D), ae();
1393
+ e && (D = e.clientHeight, e.scrollTop = g.value * D), K();
1363
1394
  }
1364
- function se(e) {
1395
+ function ce(e) {
1365
1396
  C.value = e, d.value?.toggleAttribute("data-resizing", e);
1366
1397
  }
1367
- function ce() {
1398
+ function le() {
1368
1399
  let e = d.value;
1369
- !l.loadMoreLocked && e && G(e) && u("loadMore");
1400
+ !l.loadMoreLocked && e && ae(e) && u("loadMore");
1370
1401
  }
1371
- function Y(e) {
1402
+ function J(e) {
1372
1403
  let t = R.value;
1373
1404
  if (!t) return !1;
1374
1405
  let n = M(t).length;
@@ -1376,34 +1407,34 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1376
1407
  let r = (z.value + e + n) % n;
1377
1408
  return u("mediaChange", t.postId, r), !0;
1378
1409
  }
1379
- function le(e) {
1410
+ function ue(e) {
1380
1411
  let t = g.value + e;
1381
- return !d.value || t < 0 || t >= l.items.length ? !1 : (X(t), !0);
1412
+ return !d.value || t < 0 || t >= l.items.length ? !1 : (Y(t), !0);
1382
1413
  }
1383
- function ue(e, t) {
1414
+ function de(e, t) {
1384
1415
  let n = l.items.findIndex((t) => t.postId === e), r = l.items[n];
1385
- return !d.value || !r || t < 0 || t > r.items.length ? !1 : ((l.mediaIndices.get(e) ?? 0) !== t && u("mediaChange", e, t), n !== g.value && X(n), !0);
1416
+ return !d.value || !r || t < 0 || t > r.items.length ? !1 : ((l.mediaIndices.get(e) ?? 0) !== t && u("mediaChange", e, t), n !== g.value && Y(n), !0);
1386
1417
  }
1387
- function de() {
1418
+ function fe() {
1388
1419
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1389
1420
  }
1390
- function fe(e) {
1421
+ function pe(e) {
1391
1422
  let t = d.value;
1392
1423
  if (!t) return Promise.resolve();
1393
1424
  let n = e * (D || t.clientHeight);
1394
- return g.value = e, ut(t, n, de());
1425
+ return g.value = e, pt(t, n, fe());
1395
1426
  }
1396
- function X(e) {
1397
- fe(e);
1427
+ function Y(e) {
1428
+ pe(e);
1398
1429
  }
1399
- async function Z(e) {
1430
+ async function X(e) {
1400
1431
  let t = l.items.findIndex((t) => t.postId === e);
1401
- return t < 0 || t === g.value ? !1 : (await fe(t), !0);
1432
+ return t < 0 || t === g.value ? !1 : (await pe(t), !0);
1402
1433
  }
1403
- async function pe(e) {
1404
- return Y(e) ? (de() || await new Promise((e) => setTimeout(e, _t)), !0) : !1;
1434
+ async function me(e) {
1435
+ return J(e) ? (fe() || await new Promise((e) => setTimeout(e, bt)), !0) : !1;
1405
1436
  }
1406
- function me() {
1437
+ function he() {
1407
1438
  if (!l.reelAutoAdvance.enabled) return;
1408
1439
  let e = R.value;
1409
1440
  if (!e) return;
@@ -1416,31 +1447,31 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1416
1447
  l.hasNext && !l.loadMoreLocked && u("loadMore");
1417
1448
  return;
1418
1449
  }
1419
- l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), X(t);
1450
+ l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), Y(t);
1420
1451
  }
1421
- function he(e, t) {
1422
- !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || me();
1452
+ function ge(e, t) {
1453
+ !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || he();
1423
1454
  }
1424
1455
  return O(d, (e) => {
1425
- k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(ie), k.observe(e)));
1456
+ k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(G), k.observe(e)));
1426
1457
  }), O(() => l.items.length, async (e) => {
1427
1458
  let t = l.initialPostId, n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1428
- g.value = n >= 0 ? n : Math.min(g.value, Math.max(0, e - 1)), await m(), ie();
1459
+ g.value = n >= 0 ? n : Math.min(g.value, Math.max(0, e - 1)), await m(), G();
1429
1460
  }), O(L, (e) => {
1430
1461
  e !== void 0 && u("activeChange", e);
1431
1462
  }, { immediate: !0 }), y(() => {
1432
- window.addEventListener("resize", oe), window.addEventListener("orientationchange", oe), p >= 0 && m(ie);
1463
+ window.addEventListener("resize", q), window.addEventListener("orientationchange", q), p >= 0 && m(G);
1433
1464
  }), v(() => {
1434
- window.removeEventListener("resize", oe), window.removeEventListener("orientationchange", oe), k?.disconnect(), A !== null && cancelAnimationFrame(A), j !== null && clearTimeout(j);
1465
+ window.removeEventListener("resize", q), window.removeEventListener("orientationchange", q), k?.disconnect(), A !== null && cancelAnimationFrame(A), j !== null && clearTimeout(j);
1435
1466
  }), n({
1436
1467
  activeIndex: g,
1437
1468
  activePostId: L,
1438
- changeActiveMedia: Y,
1439
- loadIfNearBottom: ce,
1440
- moveActivePost: le,
1441
- navigateToItem: ue,
1442
- transitionActiveMedia: pe,
1443
- transitionActivePost: Z
1469
+ changeActiveMedia: J,
1470
+ loadIfNearBottom: le,
1471
+ moveActivePost: ue,
1472
+ navigateToItem: de,
1473
+ transitionActiveMedia: me,
1474
+ transitionActivePost: X
1444
1475
  }), (n, r) => (b(), s("main", {
1445
1476
  class: h(["reel-shell", {
1446
1477
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1448,7 +1479,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1448
1479
  }]),
1449
1480
  "data-layout-mode": "reel"
1450
1481
  }, [
1451
- t.cardHeader && R.value && t.reelForward.status === "idle" ? (b(), a(ke, {
1482
+ t.cardHeader && R.value && t.reelForward.status === "idle" ? (b(), a(Me, {
1452
1483
  key: 0,
1453
1484
  index: g.value,
1454
1485
  item: R.value,
@@ -1470,19 +1501,19 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1470
1501
  "style",
1471
1502
  "total"
1472
1503
  ])) : o("", !0),
1473
- c("div", pt, [c("div", {
1504
+ c("div", gt, [c("div", {
1474
1505
  ref_key: "galleryElement",
1475
1506
  ref: d,
1476
1507
  class: "gallery-shell reel-feed",
1477
1508
  "data-active-post-id": L.value,
1478
1509
  "data-active-media-index": z.value,
1479
- onScrollPassive: J
1510
+ onScrollPassive: se
1480
1511
  }, [t.reelForward.status === "idle" ? (b(), s("section", {
1481
1512
  key: 1,
1482
1513
  class: "reel-track",
1483
1514
  style: _(N.value),
1484
1515
  "aria-label": "Media gallery"
1485
- }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(et, {
1516
+ }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(rt, {
1486
1517
  key: n.postId,
1487
1518
  active: r === g.value && !x.value,
1488
1519
  "advance-on-media-end": l.reelAutoAdvance.enabled && r === g.value,
@@ -1491,7 +1522,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1491
1522
  "fetch-priority": e,
1492
1523
  index: r,
1493
1524
  item: n,
1494
- "item-style": q(r),
1525
+ "item-style": W(r),
1495
1526
  "media-card": t.mediaCard,
1496
1527
  layout: "reel",
1497
1528
  "loaded-count": t.items.length,
@@ -1502,7 +1533,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1502
1533
  "stationary-reel-controls": "",
1503
1534
  total: t.total,
1504
1535
  onMediaChange: (e) => u("mediaChange", n.postId, e),
1505
- onEnded: (e) => he(n.postId, e),
1536
+ onEnded: (e) => ge(n.postId, e),
1506
1537
  onReady: (e) => u("ready", n.postId, e),
1507
1538
  onError: (e) => u("error", n.postId, e)
1508
1539
  }, null, 8, [
@@ -1528,12 +1559,12 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1528
1559
  class: "reel-forward-status",
1529
1560
  role: t.reelForward.status === "error" ? "alert" : "status",
1530
1561
  "data-status": t.reelForward.status
1531
- }, [c("p", null, T(ne.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1562
+ }, [c("p", null, T(U.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1532
1563
  key: 0,
1533
1564
  class: "reel-forward-retry",
1534
1565
  type: "button",
1535
1566
  onClick: r[0] ||= (e) => u("retryForward")
1536
- }, " Retry ")) : o("", !0)], 8, ht)), t.reelForward.status === "idle" ? (b(), a(U, {
1567
+ }, " Retry ")) : o("", !0)], 8, vt)), t.reelForward.status === "idle" ? (b(), a(ne, {
1537
1568
  key: 2,
1538
1569
  actions: t.feedFooterActions,
1539
1570
  "can-retry-end": t.canRetryEnd,
@@ -1542,7 +1573,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1542
1573
  "has-next": t.hasNext,
1543
1574
  "is-loading": t.isLoadingMore,
1544
1575
  "load-more-locked": t.loadMoreLocked,
1545
- "show-load-more": K.value,
1576
+ "show-load-more": ie.value,
1546
1577
  state: t.state,
1547
1578
  onLoadMore: r[1] ||= (e) => u("loadMore"),
1548
1579
  onRetryEnd: r[2] ||= (e) => u("retryEnd")
@@ -1556,13 +1587,13 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1556
1587
  "load-more-locked",
1557
1588
  "show-load-more",
1558
1589
  "state"
1559
- ])) : o("", !0)], 40, mt), c("div", {
1590
+ ])) : o("", !0)], 40, _t), c("div", {
1560
1591
  ref_key: "reelControlsElement",
1561
1592
  ref: f,
1562
1593
  class: "reel-media-controls-host",
1563
1594
  "data-test": "reel-media-controls-host"
1564
1595
  }, null, 512)]),
1565
- t.cardFooter && R.value && t.reelForward.status === "idle" ? (b(), a(ke, {
1596
+ t.cardFooter && R.value && t.reelForward.status === "idle" ? (b(), a(Me, {
1566
1597
  key: 1,
1567
1598
  index: g.value,
1568
1599
  item: R.value,
@@ -1584,24 +1615,24 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1584
1615
  "style",
1585
1616
  "total"
1586
1617
  ])) : o("", !0),
1587
- te.value ? (b(), a(ft, {
1588
- key: W.value,
1618
+ re.value ? (b(), a(ht, {
1619
+ key: ee.value,
1589
1620
  "duration-ms": t.reelAutoAdvance.intervalMs,
1590
- label: ee.value,
1591
- onComplete: me
1621
+ label: te.value,
1622
+ onComplete: he
1592
1623
  }, null, 8, ["duration-ms", "label"])) : o("", !0)
1593
1624
  ], 2));
1594
1625
  }
1595
- }), yt = ["data-info-sheet-open", "data-info-sheet-mode"], bt = ["aria-hidden", "inert"], xt = {
1626
+ }), St = ["data-info-sheet-open", "data-info-sheet-mode"], Ct = ["aria-hidden", "inert"], wt = {
1596
1627
  key: 0,
1597
1628
  class: "reel-info-sheet-layer",
1598
1629
  "data-test": "reel-info-sheet"
1599
- }, St = [
1630
+ }, Tt = [
1600
1631
  "role",
1601
1632
  "aria-modal",
1602
1633
  "tabindex",
1603
1634
  "data-active-post-id"
1604
- ], Ct = /* @__PURE__ */ d({
1635
+ ], Et = /* @__PURE__ */ d({
1605
1636
  __name: "ReelLayout",
1606
1637
  props: {
1607
1638
  forwardIndex: { default: null },
@@ -1694,7 +1725,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1694
1725
  function H(e, t) {
1695
1726
  d("mediaChange", e, t);
1696
1727
  }
1697
- function U(e, t) {
1728
+ function ee(e, t) {
1698
1729
  d("ready", e, t);
1699
1730
  }
1700
1731
  return O(() => ({
@@ -1726,7 +1757,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1726
1757
  class: "reel-layout-main",
1727
1758
  "aria-hidden": e.infoSheetOverlay && A.value || void 0,
1728
1759
  inert: e.infoSheetOverlay && A.value || void 0
1729
- }, [u(vt, {
1760
+ }, [u(xt, {
1730
1761
  ref_key: "reelFeed",
1731
1762
  ref: p,
1732
1763
  "can-retry-end": e.canRetryEnd,
@@ -1753,7 +1784,7 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1753
1784
  onError: V,
1754
1785
  onLoadMore: r[1] ||= (e) => d("loadMore"),
1755
1786
  onMediaChange: H,
1756
- onReady: U,
1787
+ onReady: ee,
1757
1788
  onRetryEnd: r[2] ||= (e) => d("retryEnd"),
1758
1789
  onRetryForward: r[3] ||= (e) => d("retryForward")
1759
1790
  }, null, 8, [
@@ -1777,8 +1808,8 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1777
1808
  "reel-forward",
1778
1809
  "state",
1779
1810
  "total"
1780
- ])], 8, bt), u(n, { name: "vibe-info-sheet" }, {
1781
- default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", xt, [c("aside", {
1811
+ ])], 8, Ct), u(n, { name: "vibe-info-sheet" }, {
1812
+ default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", wt, [c("aside", {
1782
1813
  ref_key: "sheetElement",
1783
1814
  ref: _,
1784
1815
  class: "reel-info-sheet",
@@ -1787,20 +1818,20 @@ var dt = ["aria-label"], ft = /* @__PURE__ */ d({
1787
1818
  "aria-modal": e.infoSheetOverlay ? "true" : void 0,
1788
1819
  tabindex: e.infoSheetOverlay ? -1 : void 0,
1789
1820
  "data-active-post-id": T.value?.postId
1790
- }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, St)])) : o("", !0)]),
1821
+ }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, Tt)])) : o("", !0)]),
1791
1822
  _: 1
1792
- })], 10, yt));
1823
+ })], 10, St));
1793
1824
  }
1794
- }), wt = [];
1795
- function Tt(e) {
1796
- return wt.push(e), () => {
1797
- let t = wt.indexOf(e);
1798
- t >= 0 && wt.splice(t, 1);
1825
+ }), Dt = [];
1826
+ function Ot(e) {
1827
+ return Dt.push(e), () => {
1828
+ let t = Dt.indexOf(e);
1829
+ t >= 0 && Dt.splice(t, 1);
1799
1830
  };
1800
1831
  }
1801
- function Et(e) {
1832
+ function kt(e) {
1802
1833
  if (!e.isActive()) return !1;
1803
- let t = wt.filter((e) => e.isActive()), n = e.element();
1834
+ let t = Dt.filter((e) => e.isActive()), n = e.element();
1804
1835
  return n !== null && t.some((t) => {
1805
1836
  if (t === e) return !1;
1806
1837
  let r = t.element();
@@ -1816,14 +1847,14 @@ function Et(e) {
1816
1847
  }
1817
1848
  //#endregion
1818
1849
  //#region src/components/useReelKeyboard.ts
1819
- function Dt(e) {
1850
+ function At(e) {
1820
1851
  let t = {
1821
1852
  element: e.element,
1822
1853
  isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
1823
1854
  }, n = null;
1824
1855
  function r(n) {
1825
1856
  let r = t.isActive();
1826
- if (n.key === "Escape" && r && !Et(t)) return;
1857
+ if (n.key === "Escape" && r && !kt(t)) return;
1827
1858
  if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
1828
1859
  n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
1829
1860
  return;
@@ -1843,14 +1874,14 @@ function Dt(e) {
1843
1874
  a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
1844
1875
  }
1845
1876
  y(() => {
1846
- n = Tt(t), window.addEventListener("keydown", r);
1877
+ n = Ot(t), window.addEventListener("keydown", r);
1847
1878
  }), v(() => {
1848
1879
  window.removeEventListener("keydown", r), n?.(), n = null;
1849
1880
  });
1850
1881
  }
1851
1882
  //#endregion
1852
1883
  //#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
1853
- var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
1884
+ var jt = 35, Mt = 420, Nt = /* @__PURE__ */ d({
1854
1885
  __name: "VibeSurface",
1855
1886
  props: {
1856
1887
  canRetryEnd: { type: Boolean },
@@ -1866,106 +1897,105 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
1866
1897
  "activeReelChange",
1867
1898
  "closeReel",
1868
1899
  "loadMore",
1900
+ "mediaReady",
1869
1901
  "openReel",
1902
+ "reelMediaChange",
1870
1903
  "reelInfoSheetChange",
1871
1904
  "retryEnd",
1872
1905
  "retryForward"
1873
1906
  ],
1874
1907
  setup(t, { expose: i, emit: c }) {
1875
- let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), y = w({}), x = w(!1), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = w(/* @__PURE__ */ new Set()), E = w(/* @__PURE__ */ new Map()), D = w(/* @__PURE__ */ new Map()), A = w(/* @__PURE__ */ new Map()), j = r(() => I(l.state)), P = r(() => l.state.reelMediaSource === "original" ? A.value : D.value), L = new Set(l.state.items.map((e) => e.postId)), R = null, z = null, B = !1;
1876
- function V() {
1908
+ let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), y = w({}), x = w(!1), S = w(/* @__PURE__ */ new Set()), C = w(/* @__PURE__ */ new Map()), T = w(/* @__PURE__ */ new Set()), E = w(/* @__PURE__ */ new Map()), D = w(/* @__PURE__ */ new Map()), A = w(/* @__PURE__ */ new Map()), j = r(() => R(l.state)), P = r(() => l.state.reelMediaSource === "original" ? A.value : D.value), z = new Set(l.state.items.map((e) => e.postId)), B = null, V = null, H = !1;
1909
+ function ee() {
1877
1910
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1878
1911
  }
1879
- function H() {
1880
- R !== null && cancelAnimationFrame(R), R = requestAnimationFrame(() => {
1881
- R = requestAnimationFrame(() => {
1882
- R = null, S.value = /* @__PURE__ */ new Set();
1912
+ function te() {
1913
+ B !== null && cancelAnimationFrame(B), B = requestAnimationFrame(() => {
1914
+ B = requestAnimationFrame(() => {
1915
+ B = null, S.value = /* @__PURE__ */ new Set();
1883
1916
  });
1884
1917
  });
1885
1918
  }
1886
- function U(e, t, n) {
1919
+ function ne(e, t, n) {
1887
1920
  let r = F(e, t);
1888
1921
  D.value.get(r) !== n && (D.value = new Map(D.value).set(r, n));
1889
1922
  }
1890
- function W(e, t, n) {
1923
+ function re(e, t, n) {
1891
1924
  let r = F(e, t);
1892
1925
  A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1893
1926
  }
1894
- function ee(e, t) {
1895
- U(e, t, "error");
1896
- }
1897
- function G(e, t) {
1898
- U(e, t, "ready");
1927
+ function ie(e, t) {
1928
+ ne(e, t, "error");
1899
1929
  }
1900
- function K(e, t) {
1901
- W(e, t, "error");
1930
+ function ae(e, t) {
1931
+ ne(e, t, "ready"), G(e, t, "masonry", null);
1902
1932
  }
1903
- function ne(e, t) {
1904
- W(e, t, "ready");
1933
+ function W(e, t) {
1934
+ re(e, t, "error");
1905
1935
  }
1906
- function q(e, t) {
1936
+ function oe(e, t) {
1907
1937
  if (l.state.reelMediaSource === "original") {
1908
- K(e, t);
1938
+ W(e, t);
1909
1939
  return;
1910
1940
  }
1911
- ee(e, t);
1941
+ ie(e, t);
1912
1942
  }
1913
- function re(e, t) {
1914
- if (l.state.reelMediaSource === "original") {
1915
- ne(e, t);
1916
- return;
1917
- }
1918
- G(e, t);
1943
+ function se(e, t) {
1944
+ l.state.reelMediaSource === "original" ? re(e, t, "ready") : ne(e, t, "ready"), G(e, t, "reel", l.state.reelOrigin ?? "reel");
1919
1945
  }
1920
- function J(e, t) {
1946
+ function G(e, t, n, r) {
1947
+ let i = I(l.state, e, t, n, r);
1948
+ i && d("mediaReady", i);
1949
+ }
1950
+ function K(e, t) {
1921
1951
  let n = l.state.items.find((t) => t.postId === e);
1922
1952
  if (!n) return;
1923
1953
  let r = N(n, t);
1924
1954
  (l.state.mediaIndices.get(e) ?? 0) !== r && (l.state.mediaIndices = new Map(l.state.mediaIndices).set(e, r));
1925
1955
  }
1926
- async function ie() {
1956
+ async function q() {
1927
1957
  await m(), (l.state.layout === "reel" || l.state.reelOrigin === "masonry" ? p.value : f.value)?.loadIfNearBottom();
1928
1958
  }
1929
- function ae(e) {
1959
+ function ce(e) {
1930
1960
  return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.changeActiveMedia?.(e) ?? !1;
1931
1961
  }
1932
- function oe(e) {
1962
+ function le(e) {
1933
1963
  return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.moveActivePost?.(e) ?? !1;
1934
1964
  }
1935
- function se(e) {
1965
+ function J(e) {
1936
1966
  if (!(l.state.layout === "reel" || l.state.reelOrigin === "masonry") || l.state.isLoading) return "reel-inactive";
1937
1967
  let t = l.state.items.find((t) => t.postId === e.postId);
1938
1968
  if (!t) return "not-found";
1939
1969
  let n = M(t).findIndex((t) => t.mediaId === e.mediaId);
1940
1970
  return n < 0 ? "not-found" : p.value?.navigateToItem?.(e.postId, n) ? "navigated" : "reel-inactive";
1941
1971
  }
1942
- function ce() {
1972
+ function ue() {
1943
1973
  return l.state.layout !== "masonry" || l.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1944
1974
  }
1945
- function Y(e, t) {
1946
- z = e, B = t === "keyboard", y.value = fe(e), d("openReel", e), m(() => h.value?.focus());
1975
+ function de(e, t) {
1976
+ V = e, H = t === "keyboard", y.value = X(e), d("openReel", e), m(() => h.value?.focus());
1947
1977
  }
1948
- function le(e) {
1978
+ function fe(e) {
1949
1979
  let t = g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1950
1980
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
1951
1981
  }
1952
- function ue(e) {
1953
- if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || V()) return 0;
1954
- let t = [...new Set(e)], n = t.filter(le);
1982
+ function pe(e) {
1983
+ if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || ee()) return 0;
1984
+ let t = [...new Set(e)], n = t.filter(fe);
1955
1985
  if (n.length === 0) return 0;
1956
1986
  let r = new Map(E.value);
1957
1987
  return n.forEach((e, t) => {
1958
- r.set(e, t * Ot);
1959
- }), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), E.value = r, kt + (n.length - 1) * Ot;
1988
+ r.set(e, t * jt);
1989
+ }), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), E.value = r, Mt + (n.length - 1) * jt;
1960
1990
  }
1961
- function de(e, t) {
1962
- let n = le(e), r = n?.querySelector(".media-card-activator") ?? n;
1991
+ function Y(e, t) {
1992
+ let n = fe(e), r = n?.querySelector(".media-card-activator") ?? n;
1963
1993
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
1964
1994
  r.classList.remove("media-card-focus-silent");
1965
1995
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
1966
1996
  }
1967
- function fe(e) {
1968
- let t = g.value, n = le(e);
1997
+ function X(e) {
1998
+ let t = g.value, n = fe(e);
1969
1999
  if (t === null || n === null) return {};
1970
2000
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
1971
2001
  return {
@@ -1975,48 +2005,48 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
1975
2005
  "--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
1976
2006
  };
1977
2007
  }
1978
- function X() {
1979
- l.state.reelOrigin === "masonry" && (z ??= l.state.activeReelPostId, x.value = !0, d("closeReel"));
2008
+ function me() {
2009
+ l.state.reelOrigin === "masonry" && (V ??= l.state.activeReelPostId, x.value = !0, d("closeReel"));
1980
2010
  }
1981
- function Z() {
1982
- let e = z, t = B;
1983
- x.value = !1, z = null, B = !1, y.value = {}, m(() => {
1984
- e !== null && de(e, t);
2011
+ function he() {
2012
+ let e = V, t = H;
2013
+ x.value = !1, V = null, H = !1, y.value = {}, m(() => {
2014
+ e !== null && Y(e, t);
1985
2015
  });
1986
2016
  }
1987
- return Dt({
1988
- closeMasonryReel: X,
2017
+ return At({
2018
+ closeMasonryReel: me,
1989
2019
  element: () => g.value,
1990
2020
  isReelLeaving: () => x.value,
1991
2021
  reelRenderer: () => p.value,
1992
2022
  setReelInfoSheet: (e) => d("reelInfoSheetChange", e),
1993
2023
  state: l.state
1994
- }), O(() => l.state.items.map((e) => e.postId), (e) => {
1995
- let t = e.filter((e) => !L.has(e)), n = new Set(e);
1996
- if (L = new Set(e), T.value = new Set([...T.value].filter((e) => n.has(e))), E.value = new Map([...E.value].filter(([e]) => n.has(e))), t.length === 0 || V()) return;
2024
+ }), L(l.state, (e) => d("reelMediaChange", e)), O(() => l.state.items.map((e) => e.postId), (e) => {
2025
+ let t = e.filter((e) => !z.has(e)), n = new Set(e);
2026
+ if (z = new Set(e), T.value = new Set([...T.value].filter((e) => n.has(e))), E.value = new Map([...E.value].filter(([e]) => n.has(e))), t.length === 0 || ee()) return;
1997
2027
  let r = /* @__PURE__ */ new Map();
1998
2028
  e.forEach((e) => {
1999
2029
  let t = C.value.get(e);
2000
2030
  t !== void 0 && r.set(e, t);
2001
2031
  }), t.forEach((e, t) => {
2002
- r.set(e, t * Ot);
2003
- }), C.value = r, S.value = new Set([...S.value, ...t]), H();
2032
+ r.set(e, t * jt);
2033
+ }), C.value = r, S.value = new Set([...S.value, ...t]), te();
2004
2034
  }, { flush: "sync" }), v(() => {
2005
- R !== null && cancelAnimationFrame(R);
2035
+ B !== null && cancelAnimationFrame(B);
2006
2036
  }), i({
2007
- changeActiveReelMedia: ae,
2008
- getAutoScrollElement: ce,
2009
- loadIfNearBottom: ie,
2010
- moveActiveReelPost: oe,
2011
- navigateToReelItem: se,
2012
- startItemRemoval: ue,
2037
+ changeActiveReelMedia: ce,
2038
+ getAutoScrollElement: ue,
2039
+ loadIfNearBottom: q,
2040
+ moveActiveReelPost: le,
2041
+ navigateToReelItem: J,
2042
+ startItemRemoval: pe,
2013
2043
  transitionActiveReelMedia: (e) => p.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
2014
2044
  transitionActiveReelPost: (e) => p.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
2015
2045
  }), (r, i) => (b(), s("div", {
2016
2046
  ref_key: "surfaceElement",
2017
2047
  ref: g,
2018
2048
  class: "vibe-surface"
2019
- }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(Ct, {
2049
+ }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(Et, {
2020
2050
  key: 0,
2021
2051
  ref_key: "reelRenderer",
2022
2052
  ref: p,
@@ -2048,10 +2078,10 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2048
2078
  total: t.state.total,
2049
2079
  onActiveChange: i[0] ||= (e) => d("activeReelChange", e),
2050
2080
  onCloseInfoSheet: i[1] ||= (e) => d("reelInfoSheetChange", !1),
2051
- onError: q,
2081
+ onError: oe,
2052
2082
  onLoadMore: i[2] ||= (e) => d("loadMore"),
2053
- onMediaChange: J,
2054
- onReady: re,
2083
+ onMediaChange: K,
2084
+ onReady: se,
2055
2085
  onRetryEnd: i[3] ||= (e) => d("retryEnd"),
2056
2086
  onRetryForward: i[4] ||= (e) => d("retryForward")
2057
2087
  }, null, 8, [
@@ -2080,7 +2110,7 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2080
2110
  "reel-forward",
2081
2111
  "state",
2082
2112
  "total"
2083
- ])) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(te, {
2113
+ ])) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(U, {
2084
2114
  key: 1,
2085
2115
  actions: t.feedFooterActions,
2086
2116
  "can-retry-end": t.canRetryEnd,
@@ -2093,7 +2123,7 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2093
2123
  "can-retry-end",
2094
2124
  "feed-footer",
2095
2125
  "state"
2096
- ])) : (b(), s(e, { key: 2 }, [u(ct, {
2126
+ ])) : (b(), s(e, { key: 2 }, [u(dt, {
2097
2127
  ref_key: "masonryRenderer",
2098
2128
  ref: f,
2099
2129
  "can-retry-end": t.canRetryEnd,
@@ -2117,11 +2147,11 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2117
2147
  suspended: t.state.reelOrigin === "masonry" || x.value,
2118
2148
  state: j.value,
2119
2149
  total: t.state.total,
2120
- onActivate: Y,
2121
- onError: ee,
2150
+ onActivate: de,
2151
+ onError: ie,
2122
2152
  onLoadMore: i[7] ||= (e) => d("loadMore"),
2123
- onMediaChange: J,
2124
- onReady: G,
2153
+ onMediaChange: K,
2154
+ onReady: ae,
2125
2155
  onRetryEnd: i[8] ||= (e) => d("retryEnd")
2126
2156
  }, null, 8, [
2127
2157
  "can-retry-end",
@@ -2147,7 +2177,7 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2147
2177
  "total"
2148
2178
  ]), u(n, {
2149
2179
  name: "vibe-reel-viewer",
2150
- onAfterLeave: Z
2180
+ onAfterLeave: he
2151
2181
  }, {
2152
2182
  default: k(() => [t.state.reelOrigin === "masonry" ? (b(), s("section", {
2153
2183
  key: 0,
@@ -2159,7 +2189,7 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2159
2189
  "aria-modal": "true",
2160
2190
  tabindex: "-1",
2161
2191
  style: _(y.value)
2162
- }, [u(Ct, {
2192
+ }, [u(Et, {
2163
2193
  ref_key: "reelRenderer",
2164
2194
  ref: p,
2165
2195
  "can-retry-end": t.canRetryEnd,
@@ -2190,10 +2220,10 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2190
2220
  total: t.state.total,
2191
2221
  onActiveChange: i[9] ||= (e) => d("activeReelChange", e),
2192
2222
  onCloseInfoSheet: i[10] ||= (e) => d("reelInfoSheetChange", !1),
2193
- onError: K,
2223
+ onError: W,
2194
2224
  onLoadMore: i[11] ||= (e) => d("loadMore"),
2195
- onMediaChange: J,
2196
- onReady: ne,
2225
+ onMediaChange: K,
2226
+ onReady: se,
2197
2227
  onRetryEnd: i[12] ||= (e) => d("retryEnd"),
2198
2228
  onRetryForward: i[13] ||= (e) => d("retryForward")
2199
2229
  }, null, 8, [
@@ -2228,44 +2258,44 @@ var Ot = 35, kt = 420, At = /* @__PURE__ */ d({
2228
2258
  });
2229
2259
  //#endregion
2230
2260
  //#region src/core/page.ts
2231
- function jt(e) {
2261
+ function Pt(e) {
2232
2262
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
2233
2263
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
2234
2264
  if (e.total !== void 0 && (!Number.isFinite(e.total) || e.total < 0)) throw TypeError("Vibe page total must be a non-negative number when provided.");
2235
2265
  return e;
2236
2266
  }
2237
- function Q(e, t) {
2267
+ function Z(e, t) {
2238
2268
  let n = new Set(e.map((e) => e.postId));
2239
2269
  return [...e, ...t.filter((e) => n.has(e.postId) ? !1 : (n.add(e.postId), !0))];
2240
2270
  }
2241
2271
  //#endregion
2242
2272
  //#region src/core/requestDelay.ts
2243
- var Mt = 2e3, Nt = 1e4, Pt = 250, Ft = {
2273
+ var Ft = 2e3, It = 1e4, Lt = 250, Rt = {
2244
2274
  delayRemainingMs: null,
2245
2275
  nextRequestAt: null
2246
2276
  };
2247
- function It(e, t) {
2277
+ function zt(e, t) {
2248
2278
  return e === void 0 ? t : Math.floor(e);
2249
2279
  }
2250
- function Lt(e, t) {
2280
+ function Bt(e, t) {
2251
2281
  for (let [n, r] of [["delayStepMs", e.delayStepMs], ["delayMaxMs", e.delayMaxMs]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe ${t} ${n} must be a non-negative number.`);
2252
2282
  }
2253
- function Rt(e, t = {}) {
2254
- let n = It(t.delayStepMs, Mt), r = It(t.delayMaxMs, Nt);
2283
+ function Vt(e, t = {}) {
2284
+ let n = zt(t.delayStepMs, Ft), r = zt(t.delayMaxMs, It);
2255
2285
  return Math.min(Math.max(0, e) * n, r);
2256
2286
  }
2257
- function $(e) {
2258
- if (e == null || !Number.isFinite(e)) return { ...Ft };
2287
+ function Q(e) {
2288
+ if (e == null || !Number.isFinite(e)) return { ...Rt };
2259
2289
  let t = Math.max(0, Math.floor(e - Date.now()));
2260
2290
  return t > 0 ? {
2261
2291
  delayRemainingMs: t,
2262
2292
  nextRequestAt: e
2263
- } : { ...Ft };
2293
+ } : { ...Rt };
2264
2294
  }
2265
- async function zt({ delayMs: e, onChange: t, signal: n }) {
2295
+ async function Ht({ delayMs: e, onChange: t, signal: n }) {
2266
2296
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2267
2297
  if (e <= 0) {
2268
- t({ ...Ft });
2298
+ t({ ...Rt });
2269
2299
  return;
2270
2300
  }
2271
2301
  let r = Date.now() + e;
@@ -2273,9 +2303,9 @@ async function zt({ delayMs: e, onChange: t, signal: n }) {
2273
2303
  delayRemainingMs: e,
2274
2304
  nextRequestAt: r
2275
2305
  }), await new Promise((i, a) => {
2276
- let o = !1, s = setInterval(f, Pt), c = setTimeout(() => u(), e);
2306
+ let o = !1, s = setInterval(f, Lt), c = setTimeout(() => u(), e);
2277
2307
  function l() {
2278
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Ft });
2308
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Rt });
2279
2309
  }
2280
2310
  function u(e) {
2281
2311
  o || (o = !0, l(), e ? a(e) : i());
@@ -2284,42 +2314,42 @@ async function zt({ delayMs: e, onChange: t, signal: n }) {
2284
2314
  u(new DOMException("Aborted", "AbortError"));
2285
2315
  }
2286
2316
  function f() {
2287
- let e = $(r);
2317
+ let e = Q(r);
2288
2318
  t(e), e.delayRemainingMs === null && u();
2289
2319
  }
2290
2320
  n.addEventListener("abort", d, { once: !0 });
2291
2321
  });
2292
2322
  }
2293
- var Bt = class {
2323
+ var Ut = class {
2294
2324
  interval = null;
2295
2325
  constructor(e) {
2296
2326
  this.onChange = e;
2297
2327
  }
2298
2328
  clear() {
2299
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Ft });
2329
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Rt });
2300
2330
  }
2301
2331
  sync(e) {
2302
2332
  this.clear();
2303
- let t = $(e);
2333
+ let t = Q(e);
2304
2334
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2305
- let t = $(e);
2335
+ let t = Q(e);
2306
2336
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2307
- }, Pt));
2337
+ }, Lt));
2308
2338
  }
2309
2339
  };
2310
- function Vt(e, t = !0) {
2340
+ function Wt(e, t = !0) {
2311
2341
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2312
2342
  }
2313
- function Ht(e) {
2343
+ function Gt(e) {
2314
2344
  return `${typeof e}:${String(e)}`;
2315
2345
  }
2316
- function Ut(e, t) {
2346
+ function Kt(e, t) {
2317
2347
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2318
2348
  }
2319
- function Wt(e) {
2349
+ function qt(e) {
2320
2350
  if (!e) return;
2321
- if (Ut(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2322
- Lt(e, "frontend autofill");
2351
+ if (Kt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2352
+ Bt(e, "frontend autofill");
2323
2353
  let t = e.maxAdditionalPages;
2324
2354
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2325
2355
  return;
@@ -2331,7 +2361,7 @@ function Wt(e) {
2331
2361
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2332
2362
  }
2333
2363
  }
2334
- function Gt(e, t, n = !0) {
2364
+ function Jt(e, t, n = !0) {
2335
2365
  if (!e) return {
2336
2366
  cycleId: null,
2337
2367
  delayRemainingMs: null,
@@ -2348,7 +2378,7 @@ function Gt(e, t, n = !0) {
2348
2378
  status: "idle",
2349
2379
  strategy: null
2350
2380
  };
2351
- let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = $(r?.nextRequestAt);
2381
+ let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = Q(r?.nextRequestAt);
2352
2382
  return {
2353
2383
  cycleId: r?.cycleId ?? null,
2354
2384
  ...a,
@@ -2365,7 +2395,7 @@ function Gt(e, t, n = !0) {
2365
2395
  strategy: e.strategy
2366
2396
  };
2367
2397
  }
2368
- function Kt(e) {
2398
+ function Yt(e) {
2369
2399
  return [
2370
2400
  "cancelling",
2371
2401
  "filling",
@@ -2373,9 +2403,9 @@ function Kt(e) {
2373
2403
  "waiting"
2374
2404
  ].includes(e.status);
2375
2405
  }
2376
- async function qt(e, t, n) {
2406
+ async function Xt(e, t, n) {
2377
2407
  let r = t.autofill;
2378
- if (!Kt(r) || !r.cycleId) return;
2408
+ if (!Yt(r) || !r.cycleId) return;
2379
2409
  let i = {
2380
2410
  cycleId: r.cycleId,
2381
2411
  feedKey: r.feedKey ?? "",
@@ -2388,26 +2418,31 @@ async function qt(e, t, n) {
2388
2418
  throw r.error = e, r.status = "error", e;
2389
2419
  }
2390
2420
  }
2391
- function Jt(e, t, n) {
2421
+ function Zt(e, t, n) {
2392
2422
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2393
2423
  }
2394
- async function Yt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2395
- let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? Vt(s), h = t, g = t, _ = 0, v;
2424
+ async function Qt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2425
+ let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? Wt(s), h = t, g = t, _ = 0, v = [], y;
2396
2426
  for (; _ < m;) {
2397
- let e = Ht(h);
2427
+ let e = Gt(h);
2398
2428
  if (p.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2399
- p.add(e), await zt({
2400
- delayMs: Rt(l + _, s),
2429
+ p.add(e), await Ht({
2430
+ delayMs: Vt(l + _, s),
2401
2431
  onChange: a,
2402
2432
  signal: u
2403
2433
  });
2404
- let t = jt(await n({
2434
+ let t = Pt(await n({
2405
2435
  cursor: h,
2406
2436
  signal: u
2407
2437
  }));
2408
2438
  _ += 1;
2409
- let r = Q(f, t.items).slice(f.length);
2410
- f.push(...r), d.push(...r), g = t.next, t.total !== void 0 && (v = t.total);
2439
+ let r = Z(f, t.items).slice(f.length);
2440
+ v.push({
2441
+ contributionIds: r.map(({ postId: e }) => e),
2442
+ cursor: h,
2443
+ next: t.next,
2444
+ returnedIds: t.items.map(({ postId: e }) => e)
2445
+ }), f.push(...r), d.push(...r), g = t.next, t.total !== void 0 && (y = t.total);
2411
2446
  let m = {
2412
2447
  missing: Math.max(0, s.pageSize - c - d.length),
2413
2448
  next: g,
@@ -2415,18 +2450,20 @@ async function Yt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2415
2450
  requests: l + _
2416
2451
  };
2417
2452
  o(m);
2418
- let y = {
2453
+ let b = {
2419
2454
  ...m,
2420
2455
  items: [...d],
2421
2456
  lastCursor: h,
2422
- total: v
2457
+ total: y
2423
2458
  };
2424
- if (i(y), m.missing === 0) return {
2425
- ...y,
2459
+ if (i(b), m.missing === 0) return {
2460
+ ...b,
2461
+ pages: v,
2426
2462
  status: "complete"
2427
2463
  };
2428
2464
  if (g === null) return {
2429
- ...y,
2465
+ ...b,
2466
+ pages: v,
2430
2467
  status: "exhausted"
2431
2468
  };
2432
2469
  h = g;
@@ -2436,20 +2473,21 @@ async function Yt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2436
2473
  lastCursor: h,
2437
2474
  missing: Math.max(0, s.pageSize - c - d.length),
2438
2475
  next: g,
2476
+ pages: v,
2439
2477
  received: c + d.length,
2440
2478
  requests: l + _,
2441
2479
  status: "exhausted",
2442
- total: v
2480
+ total: y
2443
2481
  };
2444
2482
  }
2445
2483
  //#endregion
2446
2484
  //#region src/core/autofillController.ts
2447
- var Xt = class {
2485
+ var $t = class {
2448
2486
  collection = null;
2449
2487
  cycle = 0;
2450
2488
  delayCountdown;
2451
2489
  constructor(e) {
2452
- this.context = e, this.delayCountdown = new Bt((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2490
+ this.context = e, this.delayCountdown = new Ut((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2453
2491
  }
2454
2492
  beginCycle() {
2455
2493
  let { options: e, state: t } = this.context;
@@ -2457,14 +2495,14 @@ var Xt = class {
2457
2495
  this.clear();
2458
2496
  let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
2459
2497
  return t.autofill = {
2460
- ...Gt(e, void 0, !1),
2498
+ ...Jt(e, void 0, !1),
2461
2499
  cycleId: n,
2462
2500
  status: "filling"
2463
2501
  }, n;
2464
2502
  }
2465
2503
  async cancel() {
2466
2504
  let { cancelRequest: e, options: t, state: n } = this.context;
2467
- await qt(t, n, e), this.commitCollection();
2505
+ await Xt(t, n, e), this.commitCollection();
2468
2506
  }
2469
2507
  captureCollection(e, t) {
2470
2508
  t && (this.collection = e);
@@ -2486,36 +2524,36 @@ var Xt = class {
2486
2524
  let { onLastCursor: e, options: t, state: n } = this.context;
2487
2525
  if (t?.strategy !== "frontend") return;
2488
2526
  let r = this.collection;
2489
- this.collection = null, r && (n.items = Q(n.items, r.items), e(r.lastCursor), n.next = r.next, r.total !== void 0 && (n.total = r.total), Object.assign(n.autofill, {
2527
+ this.collection = null, r && (n.items = Z(n.items, r.items), e(r.lastCursor), n.next = r.next, r.total !== void 0 && (n.total = r.total), Object.assign(n.autofill, {
2490
2528
  missing: r.missing,
2491
2529
  received: r.received,
2492
2530
  requests: r.requests
2493
2531
  }));
2494
2532
  }
2495
- }, Zt = 100;
2496
- function Qt(e, t) {
2533
+ }, en = 100;
2534
+ function tn(e, t) {
2497
2535
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2498
2536
  }
2499
- function $t(e, t, n) {
2537
+ function nn(e, t, n) {
2500
2538
  return Math.min(n, Math.max(t, e));
2501
2539
  }
2502
- function en(e) {
2540
+ function rn(e) {
2503
2541
  if (!e) return;
2504
2542
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2505
- if (Qt("autoScroll.minSpeedPxPerSecond", t), Qt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2506
- e.speedPxPerSecond !== void 0 && Qt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2543
+ if (tn("autoScroll.minSpeedPxPerSecond", t), tn("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2544
+ e.speedPxPerSecond !== void 0 && tn("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2507
2545
  }
2508
- function tn(e) {
2546
+ function an(e) {
2509
2547
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2510
2548
  return {
2511
2549
  enabled: e?.enabled ?? !1,
2512
2550
  maxSpeedPxPerSecond: n,
2513
2551
  minSpeedPxPerSecond: t,
2514
2552
  paused: !1,
2515
- speedPxPerSecond: $t(e?.speedPxPerSecond ?? 80, t, n)
2553
+ speedPxPerSecond: nn(e?.speedPxPerSecond ?? 80, t, n)
2516
2554
  };
2517
2555
  }
2518
- var nn = class {
2556
+ var on = class {
2519
2557
  frame = null;
2520
2558
  lastTimestamp = null;
2521
2559
  mounted = !1;
@@ -2535,9 +2573,9 @@ var nn = class {
2535
2573
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2536
2574
  }
2537
2575
  setSpeed(e) {
2538
- Qt("auto-scroll speed", e);
2576
+ tn("auto-scroll speed", e);
2539
2577
  let t = this.options.state;
2540
- t.speedPxPerSecond = $t(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2578
+ t.speedPxPerSecond = nn(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2541
2579
  }
2542
2580
  tick = (e) => {
2543
2581
  this.frame = null;
@@ -2549,7 +2587,7 @@ var nn = class {
2549
2587
  return;
2550
2588
  }
2551
2589
  if (this.lastTimestamp !== null) {
2552
- let r = Math.min(Zt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2590
+ let r = Math.min(en, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2553
2591
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2554
2592
  }
2555
2593
  this.lastTimestamp = e, this.schedule();
@@ -2563,13 +2601,13 @@ var nn = class {
2563
2601
  };
2564
2602
  //#endregion
2565
2603
  //#region src/core/backendAutofill.ts
2566
- async function rn(e, t, n, r) {
2604
+ async function sn(e, t, n, r) {
2567
2605
  let i = await e.onUnderfilled(n);
2568
2606
  if (!r()) return;
2569
2607
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
2570
2608
  let a = Math.max(n.received, i.received ?? n.received);
2571
2609
  Object.assign(t.autofill, {
2572
- ...$(i.nextRequestAt),
2610
+ ...Q(i.nextRequestAt),
2573
2611
  missing: Math.max(0, e.pageSize - a),
2574
2612
  received: a,
2575
2613
  sequence: i.sequence ?? 0,
@@ -2577,81 +2615,81 @@ async function rn(e, t, n, r) {
2577
2615
  status: "waiting"
2578
2616
  });
2579
2617
  }
2580
- function an(e, t) {
2581
- ["complete", "exhausted"].includes(t.status) && t.items && (e.items = Q(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
2618
+ function cn(e, t) {
2619
+ ["complete", "exhausted"].includes(t.status) && t.items && (e.items = Z(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
2582
2620
  }
2583
- function on(e, t, n) {
2621
+ function ln(e, t, n) {
2584
2622
  let r = t.autofill;
2585
- return !Jt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (an(t, n), Object.assign(r, $(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
2623
+ return !Zt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (cn(t, n), Object.assign(r, Q(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
2586
2624
  }
2587
- function sn(e, t, n) {
2588
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Gt(e, n), an(t, n), !0);
2625
+ function un(e, t, n) {
2626
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Jt(e, n), cn(t, n), !0);
2589
2627
  }
2590
2628
  //#endregion
2591
2629
  //#region src/core/initialAutofill.ts
2592
- async function cn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, options: i, signal: a, state: o }) {
2593
- let s = i.autofill;
2594
- if (!s) return;
2595
- let c = o.items.length;
2596
- if (Object.assign(o.autofill, {
2597
- missing: Math.max(0, s.pageSize - c),
2598
- received: c,
2630
+ async function dn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
2631
+ let c = a.autofill;
2632
+ if (!c) return;
2633
+ let l = s.items.length;
2634
+ if (Object.assign(s.autofill, {
2635
+ missing: Math.max(0, c.pageSize - l),
2636
+ received: l,
2599
2637
  requests: 1
2600
- }), c >= s.pageSize) {
2601
- o.autofill.status = "complete";
2638
+ }), l >= c.pageSize) {
2639
+ s.autofill.status = "complete";
2602
2640
  return;
2603
2641
  }
2604
- if (s.strategy === "backend") {
2605
- await rn(s, o, {
2642
+ if (c.strategy === "backend") {
2643
+ await sn(c, s, {
2606
2644
  cycleId: e,
2607
- feedKey: s.feedKey,
2608
- items: [...o.items],
2609
- missing: s.pageSize - c,
2610
- next: o.next,
2611
- pageSize: s.pageSize,
2612
- received: c,
2613
- signal: a,
2614
- total: o.total
2645
+ feedKey: c.feedKey,
2646
+ items: [...s.items],
2647
+ missing: c.pageSize - l,
2648
+ next: s.next,
2649
+ pageSize: c.pageSize,
2650
+ received: l,
2651
+ signal: o,
2652
+ total: s.total
2615
2653
  }, t);
2616
2654
  return;
2617
2655
  }
2618
- if (!i.loadPage || o.next === null) {
2619
- o.autofill.status = "exhausted";
2656
+ if (!a.loadPage || s.next === null) {
2657
+ s.autofill.status = "exhausted";
2620
2658
  return;
2621
2659
  }
2622
- let l = await Yt({
2623
- existingItems: o.items,
2624
- initialCursor: o.next,
2625
- loadPage: i.loadPage,
2626
- maximumRequests: Vt(s, !1),
2660
+ let u = await Qt({
2661
+ existingItems: s.items,
2662
+ initialCursor: s.next,
2663
+ loadPage: a.loadPage,
2664
+ maximumRequests: Wt(c, !1),
2627
2665
  onCollection: n,
2628
2666
  onDelayChange: (e) => {
2629
- t() && Object.assign(o.autofill, e);
2667
+ t() && Object.assign(s.autofill, e);
2630
2668
  },
2631
2669
  onProgress: (e) => {
2632
- t() && Object.assign(o.autofill, e, { status: "filling" });
2670
+ t() && Object.assign(s.autofill, e, { status: "filling" });
2633
2671
  },
2634
- options: s,
2635
- receivedOffset: c,
2672
+ options: c,
2673
+ receivedOffset: l,
2636
2674
  requestOffset: 1,
2637
- signal: a
2675
+ signal: o
2638
2676
  });
2639
- t() && (o.items = Q(o.items, l.items), o.next = l.next, l.total !== void 0 && (o.total = l.total), r(l.lastCursor), Object.assign(o.autofill, {
2640
- missing: l.missing,
2641
- received: l.received,
2642
- requests: l.requests,
2643
- status: l.status
2677
+ t() && (s.items = Z(s.items, u.items), s.next = u.next, u.total !== void 0 && (s.total = u.total), r(u.lastCursor), i(u.pages), Object.assign(s.autofill, {
2678
+ missing: u.missing,
2679
+ received: u.received,
2680
+ requests: u.requests,
2681
+ status: u.status
2644
2682
  }));
2645
2683
  }
2646
2684
  //#endregion
2647
2685
  //#region src/core/fill.ts
2648
- function ln(e) {
2686
+ function fn(e) {
2649
2687
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2650
2688
  }
2651
- function un(e) {
2689
+ function pn(e) {
2652
2690
  return `${typeof e}:${String(e)}`;
2653
2691
  }
2654
- function dn(e) {
2692
+ function mn(e) {
2655
2693
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2656
2694
  if ("pages" in e) {
2657
2695
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2660,21 +2698,21 @@ function dn(e) {
2660
2698
  if ("until" in e && e.until === "end") return { until: "end" };
2661
2699
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2662
2700
  }
2663
- function fn(e) {
2701
+ function hn(e) {
2664
2702
  if (!e) return;
2665
2703
  if (e.strategy === "frontend") {
2666
- Lt(e, "frontend fill");
2704
+ Bt(e, "frontend fill");
2667
2705
  return;
2668
2706
  }
2669
2707
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2670
2708
  let t = e.initialSession;
2671
2709
  if (t) {
2672
2710
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2673
- dn(t.target);
2711
+ mn(t.target);
2674
2712
  }
2675
2713
  }
2676
- function pn(e, t, n = !0) {
2677
- let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2714
+ function gn(e, t, n = !0) {
2715
+ let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = Q(i?.nextRequestAt);
2678
2716
  return {
2679
2717
  completedPages: i?.completedPages ?? 0,
2680
2718
  cycleId: i?.cycleId ?? null,
@@ -2687,10 +2725,10 @@ function pn(e, t, n = !0) {
2687
2725
  sessionId: i?.sessionId ?? null,
2688
2726
  status: i?.status ?? "idle",
2689
2727
  strategy: e?.strategy ?? null,
2690
- target: i ? ln(i.target) : null
2728
+ target: i ? fn(i.target) : null
2691
2729
  };
2692
2730
  }
2693
- function mn(e) {
2731
+ function _n(e) {
2694
2732
  return [
2695
2733
  "cancelling",
2696
2734
  "filling",
@@ -2698,64 +2736,72 @@ function mn(e) {
2698
2736
  "waiting"
2699
2737
  ].includes(e.status);
2700
2738
  }
2701
- async function hn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2702
- let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2703
- for (; p !== null;) {
2704
- let e = un(f);
2705
- if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2706
- u.add(e), await zt({
2707
- delayMs: Rt(d, a),
2739
+ async function vn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2740
+ let c = [], l = [], u = [...e], d = /* @__PURE__ */ new Set(), f = 0, p = t, m = t, h = 0, g;
2741
+ for (; m !== null;) {
2742
+ let e = pn(p);
2743
+ if (d.has(e)) throw Error("Vibe fill received a repeated cursor.");
2744
+ d.add(e), await Ht({
2745
+ delayMs: Vt(f, a),
2708
2746
  onChange: r,
2709
2747
  signal: o
2710
2748
  });
2711
- let t = jt(await n({
2712
- cursor: f,
2749
+ let t = Pt(await n({
2750
+ cursor: p,
2713
2751
  signal: o
2714
2752
  }));
2715
- d += 1;
2716
- let g = Q(l, t.items).slice(l.length);
2717
- if (l.push(...g), c.push(...g), m = c.length, p = t.next, t.total !== void 0 && (h = t.total), i({
2718
- completedPages: d,
2719
- next: p,
2720
- received: m
2721
- }), "pages" in s && d >= s.pages) return {
2722
- completedPages: d,
2753
+ f += 1;
2754
+ let _ = Z(u, t.items).slice(u.length);
2755
+ if (l.push({
2756
+ contributionIds: _.map(({ postId: e }) => e),
2757
+ cursor: p,
2758
+ next: t.next,
2759
+ returnedIds: t.items.map(({ postId: e }) => e)
2760
+ }), u.push(..._), c.push(..._), h = c.length, m = t.next, t.total !== void 0 && (g = t.total), i({
2761
+ completedPages: f,
2762
+ next: m,
2763
+ received: h
2764
+ }), "pages" in s && f >= s.pages) return {
2765
+ completedPages: f,
2723
2766
  items: c,
2724
- lastCursor: f,
2725
- next: p,
2726
- received: m,
2767
+ lastCursor: p,
2768
+ next: m,
2769
+ pages: l,
2770
+ received: h,
2727
2771
  status: "complete",
2728
- total: h
2772
+ total: g
2729
2773
  };
2730
- if (p === null) return {
2731
- completedPages: d,
2774
+ if (m === null) return {
2775
+ completedPages: f,
2732
2776
  items: c,
2733
- lastCursor: f,
2734
- next: p,
2735
- received: m,
2777
+ lastCursor: p,
2778
+ next: m,
2779
+ pages: l,
2780
+ received: h,
2736
2781
  status: "pages" in s ? "exhausted" : "complete",
2737
- total: h
2782
+ total: g
2738
2783
  };
2739
- f = p;
2784
+ p = m;
2740
2785
  }
2741
2786
  return {
2742
- completedPages: d,
2787
+ completedPages: f,
2743
2788
  items: c,
2744
- lastCursor: f,
2789
+ lastCursor: p,
2745
2790
  next: null,
2746
- received: m,
2791
+ pages: l,
2792
+ received: h,
2747
2793
  status: "pages" in s ? "exhausted" : "complete",
2748
- total: h
2794
+ total: g
2749
2795
  };
2750
2796
  }
2751
2797
  //#endregion
2752
2798
  //#region src/core/backendFill.ts
2753
- async function gn(e, t, n, r) {
2799
+ async function yn(e, t, n, r) {
2754
2800
  let i = await e.onStart(n);
2755
2801
  if (r()) {
2756
2802
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
2757
2803
  Object.assign(t.fill, {
2758
- ...$(i.nextRequestAt),
2804
+ ...Q(i.nextRequestAt),
2759
2805
  completedPages: i.completedPages ?? 0,
2760
2806
  received: i.received ?? 0,
2761
2807
  sequence: i.sequence ?? 0,
@@ -2764,23 +2810,23 @@ async function gn(e, t, n, r) {
2764
2810
  });
2765
2811
  }
2766
2812
  }
2767
- function _n(e, t, n) {
2813
+ function bn(e, t, n) {
2768
2814
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2769
2815
  }
2770
- function vn(e) {
2816
+ function xn(e) {
2771
2817
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2772
2818
  }
2773
- function yn(e, t) {
2819
+ function Sn(e, t) {
2774
2820
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2775
2821
  let n = e.fill.target;
2776
2822
  return !n || !Array.isArray(t.items) || t.next === void 0 || t.lastCursor === void 0 ? !1 : t.status === "exhausted" ? "pages" in n && t.completedPages < n.pages && t.next === null : "pages" in n ? t.completedPages === n.pages : t.next === null;
2777
2823
  }
2778
- function bn(e, t, n) {
2779
- t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Q(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
2824
+ function Cn(e, t, n) {
2825
+ t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Z(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
2780
2826
  }
2781
- function xn(e, t, n, r) {
2782
- return !_n(e, t, n) || !vn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !yn(t, n) ? !1 : (bn(t, n, r), Object.assign(t.fill, {
2783
- ...$(n.status === "waiting" ? n.nextRequestAt : null),
2827
+ function wn(e, t, n, r) {
2828
+ return !bn(e, t, n) || !xn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !Sn(t, n) ? !1 : (Cn(t, n, r), Object.assign(t.fill, {
2829
+ ...Q(n.status === "waiting" ? n.nextRequestAt : null),
2784
2830
  completedPages: n.completedPages,
2785
2831
  error: n.error ?? null,
2786
2832
  received: n.received,
@@ -2788,41 +2834,41 @@ function xn(e, t, n, r) {
2788
2834
  status: n.status
2789
2835
  }), !0);
2790
2836
  }
2791
- function Sn(e, t, n, r) {
2837
+ function Tn(e, t, n, r) {
2792
2838
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2793
2839
  let i = t.fill;
2794
- return t.fill = pn(e, n), !vn(n) || !yn(t, n) ? (t.fill = i, !1) : (bn(t, n, r), !0);
2840
+ return t.fill = gn(e, n), !xn(n) || !Sn(t, n) ? (t.fill = i, !1) : (Cn(t, n, r), !0);
2795
2841
  }
2796
2842
  //#endregion
2797
2843
  //#region src/core/fillController.ts
2798
- var Cn = class {
2844
+ var En = class {
2799
2845
  abortController = null;
2800
2846
  cycle = 0;
2801
2847
  delayCountdown;
2802
2848
  requestVersion = 0;
2803
2849
  constructor(e) {
2804
- this.options = e, this.delayCountdown = new Bt((e) => {
2850
+ this.options = e, this.delayCountdown = new Ut((e) => {
2805
2851
  Object.assign(this.options.state.fill, e);
2806
2852
  }), this.syncBackendCountdown();
2807
2853
  }
2808
2854
  isActive() {
2809
- return mn(this.options.state.fill);
2855
+ return _n(this.options.state.fill);
2810
2856
  }
2811
2857
  applyUpdate(e) {
2812
- let t = xn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2858
+ let t = wn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2813
2859
  return t && this.syncBackendCountdown(), t;
2814
2860
  }
2815
2861
  restoreSession(e) {
2816
- let t = Sn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2862
+ let t = Tn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2817
2863
  return t && this.syncBackendCountdown(), t;
2818
2864
  }
2819
2865
  async start(e) {
2820
2866
  let t = this.options.fill;
2821
2867
  if (!t) throw Error("Vibe fill is not configured.");
2822
2868
  if (this.isActive()) throw Error("Vibe fill is already active.");
2823
- let n = dn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2869
+ let n = mn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2824
2870
  if (this.options.state.fill = {
2825
- ...pn(t, void 0, !1),
2871
+ ...gn(t, void 0, !1),
2826
2872
  cycleId: r,
2827
2873
  status: "filling",
2828
2874
  target: n
@@ -2833,7 +2879,7 @@ var Cn = class {
2833
2879
  let i = ++this.requestVersion, a = new AbortController();
2834
2880
  this.abortController = a;
2835
2881
  try {
2836
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await gn(t, this.options.state, {
2882
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await yn(t, this.options.state, {
2837
2883
  cycleId: r,
2838
2884
  feedKey: t.feedKey,
2839
2885
  items: [...this.options.state.items],
@@ -2851,7 +2897,7 @@ var Cn = class {
2851
2897
  }
2852
2898
  async cancel() {
2853
2899
  let { fill: e, state: t } = this.options;
2854
- if (!mn(t.fill) || !t.fill.cycleId) return;
2900
+ if (!_n(t.fill) || !t.fill.cycleId) return;
2855
2901
  let n = {
2856
2902
  cycleId: t.fill.cycleId,
2857
2903
  feedKey: t.fill.feedKey ?? "",
@@ -2865,7 +2911,7 @@ var Cn = class {
2865
2911
  }
2866
2912
  }
2867
2913
  reset() {
2868
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = pn(this.options.fill, void 0, !1);
2914
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = gn(this.options.fill, void 0, !1);
2869
2915
  }
2870
2916
  destroy() {
2871
2917
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2881,7 +2927,7 @@ var Cn = class {
2881
2927
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2882
2928
  let a = this.options.state;
2883
2929
  a.isLoadingMore = !0;
2884
- let o = await hn({
2930
+ let o = await vn({
2885
2931
  existingItems: a.items,
2886
2932
  initialCursor: a.next,
2887
2933
  loadPage: i,
@@ -2895,7 +2941,7 @@ var Cn = class {
2895
2941
  signal: n.signal,
2896
2942
  target: t
2897
2943
  });
2898
- this.isCurrent(r) && (a.items = Q(a.items, o.items), a.next = o.next, o.total !== void 0 && (a.total = o.total), this.options.onLastCursor(o.lastCursor), Object.assign(a.fill, {
2944
+ this.isCurrent(r) && (a.items = Z(a.items, o.items), a.next = o.next, o.total !== void 0 && (a.total = o.total), this.options.onLastCursor(o.lastCursor), this.options.onPages(o.pages), Object.assign(a.fill, {
2899
2945
  completedPages: o.completedPages,
2900
2946
  received: o.received,
2901
2947
  status: o.status
@@ -2908,7 +2954,7 @@ var Cn = class {
2908
2954
  };
2909
2955
  //#endregion
2910
2956
  //#region src/core/feedFooter.ts
2911
- function wn(e) {
2957
+ function Dn(e) {
2912
2958
  return {
2913
2959
  cancelAutofill: () => e.cancelAutofill(),
2914
2960
  loadMore: () => e.loadNext(),
@@ -2916,62 +2962,62 @@ function wn(e) {
2916
2962
  retryEnd: () => e.retryEnd()
2917
2963
  };
2918
2964
  }
2919
- function Tn(e) {
2965
+ function On(e) {
2920
2966
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2921
2967
  }
2922
- function En(e) {
2923
- e?.intervalMs !== void 0 && Tn(e.intervalMs);
2968
+ function kn(e) {
2969
+ e?.intervalMs !== void 0 && On(e.intervalMs);
2924
2970
  }
2925
- function Dn(e) {
2971
+ function An(e) {
2926
2972
  return {
2927
2973
  enabled: e?.enabled ?? !1,
2928
2974
  includePostItems: e?.includePostItems ?? !1,
2929
2975
  intervalMs: e?.intervalMs ?? 5e3
2930
2976
  };
2931
2977
  }
2932
- function On(e, t) {
2978
+ function jn(e, t) {
2933
2979
  if (typeof t == "boolean") {
2934
2980
  e.enabled = t;
2935
2981
  return;
2936
2982
  }
2937
- En(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
2983
+ kn(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
2938
2984
  }
2939
2985
  //#endregion
2940
2986
  //#region src/core/reelInfoSheet.ts
2941
- function kn(e) {
2987
+ function Mn(e) {
2942
2988
  return { enabled: e?.enabled ?? !1 };
2943
2989
  }
2944
- function An(e, t, n) {
2990
+ function Nn(e, t, n) {
2945
2991
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2946
2992
  e.enabled = n;
2947
2993
  }
2948
2994
  //#endregion
2949
2995
  //#region src/core/initialRuntimeState.ts
2950
- function jn(e, t) {
2996
+ function Pn(e, t) {
2951
2997
  let n = e.initialPage;
2952
2998
  return {
2953
2999
  activeReelPostId: null,
2954
- autoScroll: tn(e.autoScroll),
2955
- autofill: Gt(e.autofill),
3000
+ autoScroll: an(e.autoScroll),
3001
+ autofill: Jt(e.autofill),
2956
3002
  error: null,
2957
- fill: pn(e.fill),
3003
+ fill: gn(e.fill),
2958
3004
  infiniteScroll: e.infiniteScroll ?? !0,
2959
3005
  isLoading: !n,
2960
3006
  isLoadingMore: !1,
2961
- items: n ? Q([], n.items) : [],
3007
+ items: n ? Z([], n.items) : [],
2962
3008
  layout: t === "reel" ? "reel" : "masonry",
2963
3009
  loadMoreLocked: !1,
2964
3010
  mediaIndices: /* @__PURE__ */ new Map(),
2965
3011
  next: n?.next ?? null,
2966
3012
  nextPageError: null,
2967
- reelAutoAdvance: Dn(e.reelAutoAdvance),
3013
+ reelAutoAdvance: An(e.reelAutoAdvance),
2968
3014
  reelForward: {
2969
3015
  error: null,
2970
3016
  status: "idle"
2971
3017
  },
2972
3018
  reelForwardIndex: null,
2973
3019
  reelForwardItem: null,
2974
- reelInfoSheet: kn(e.reelInfoSheet),
3020
+ reelInfoSheet: Mn(e.reelInfoSheet),
2975
3021
  reelInfoSheetOverlay: !1,
2976
3022
  reelMediaSource: "original",
2977
3023
  reelOrigin: null,
@@ -2980,26 +3026,34 @@ function jn(e, t) {
2980
3026
  }
2981
3027
  //#endregion
2982
3028
  //#region src/core/options.ts
2983
- function Mn(e, t) {
3029
+ function Fn(e, t) {
2984
3030
  if (t) {
2985
3031
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
2986
3032
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
2987
3033
  }
2988
3034
  }
2989
- function Nn(e, t) {
3035
+ function In(e, t) {
2990
3036
  if (t) {
2991
3037
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
2992
3038
  for (let [n, r] of [["paddingX", t.paddingX], ["paddingY", t.paddingY]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe mediaCard ${e} ${n} must be a non-negative number.`);
2993
3039
  }
2994
3040
  }
2995
- function Pn(e) {
2996
- if (en(e.autoScroll), Mn("cardHeader", e.cardHeader), Mn("cardFooter", e.cardFooter), Nn("header", e.mediaCard?.header), Nn("footer", e.mediaCard?.footer), Wt(e.autofill), fn(e.fill), En(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
3041
+ function Ln(e) {
3042
+ if (rn(e.autoScroll), Fn("cardHeader", e.cardHeader), Fn("cardFooter", e.cardFooter), In("header", e.mediaCard?.header), In("footer", e.mediaCard?.footer), qt(e.autofill), hn(e.fill), kn(e.reelAutoAdvance), e.removalReconciliation) {
3043
+ if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
3044
+ let t = e.removalReconciliation.maxReplayPages ?? 5;
3045
+ if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
3046
+ if (!e.loadPage) throw TypeError("Vibe removalReconciliation requires loadPage.");
3047
+ if (e.autofill?.strategy === "backend") throw TypeError("Vibe removalReconciliation does not support backend autofill.");
3048
+ if (e.fill?.strategy === "backend") throw TypeError("Vibe removalReconciliation does not support backend fill.");
3049
+ }
3050
+ if (e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2997
3051
  if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2998
3052
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2999
3053
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
3000
3054
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
3001
3055
  }
3002
- function Fn(e) {
3056
+ function Rn(e) {
3003
3057
  if (typeof e != "string") return e;
3004
3058
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
3005
3059
  let t = document.querySelector(e);
@@ -3007,8 +3061,172 @@ function Fn(e) {
3007
3061
  return t;
3008
3062
  }
3009
3063
  //#endregion
3064
+ //#region src/core/pageRequest.ts
3065
+ async function zn({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
3066
+ let u = s.autofill, d = u ? t.beginCycle() : null, f = !1;
3067
+ try {
3068
+ if (u?.strategy === "frontend") {
3069
+ let s = await Qt({
3070
+ existingItems: e ? l.items : [],
3071
+ initialCursor: n,
3072
+ loadPage: i,
3073
+ onCollection: (e) => t.captureCollection(e, r()),
3074
+ onDelayChange: (e) => {
3075
+ r() && Object.assign(l.autofill, e);
3076
+ },
3077
+ onProgress: (e) => {
3078
+ r() && Object.assign(l.autofill, e, { status: "filling" });
3079
+ },
3080
+ options: u,
3081
+ signal: c
3082
+ });
3083
+ if (!r()) return;
3084
+ l.items = e ? Z(l.items, s.items) : [...s.items], a(s.lastCursor), l.next = s.next, s.total !== void 0 && (l.total = s.total), Object.assign(l.autofill, {
3085
+ missing: s.missing,
3086
+ received: s.received,
3087
+ requests: s.requests,
3088
+ status: s.status
3089
+ }), o(s.pages), t.clearCollection();
3090
+ return;
3091
+ }
3092
+ let s = Pt(await i({
3093
+ cursor: n,
3094
+ signal: c
3095
+ }));
3096
+ if (!r()) return;
3097
+ let p = e ? l.items : [], m = Z(p, s.items), h = m.length - p.length;
3098
+ if (l.items = m, a(n), o([{
3099
+ contributionIds: m.slice(p.length).map(({ postId: e }) => e),
3100
+ cursor: n,
3101
+ next: s.next,
3102
+ returnedIds: s.items.map(({ postId: e }) => e)
3103
+ }]), l.next = s.next, s.total !== void 0 && (l.total = s.total), f = !0, u?.strategy === "backend" && d) {
3104
+ if (Object.assign(l.autofill, {
3105
+ missing: Math.max(0, u.pageSize - h),
3106
+ received: h,
3107
+ requests: 1
3108
+ }), h >= u.pageSize) {
3109
+ l.autofill.status = "complete";
3110
+ return;
3111
+ }
3112
+ await sn(u, l, {
3113
+ cycleId: d,
3114
+ feedKey: u.feedKey,
3115
+ items: m.slice(p.length),
3116
+ missing: u.pageSize - h,
3117
+ next: s.next,
3118
+ pageSize: u.pageSize,
3119
+ received: h,
3120
+ signal: c,
3121
+ total: l.total
3122
+ }, r), t.syncCountdown();
3123
+ }
3124
+ } catch (t) {
3125
+ if (c.aborted || !r()) return;
3126
+ u && (l.autofill.error = t, l.autofill.status = "error"), f || (e ? l.nextPageError = t : l.error = t);
3127
+ } finally {
3128
+ r() && (t.clearCollection(), l.isLoading = !1, l.isLoadingMore = !1);
3129
+ }
3130
+ }
3131
+ //#endregion
3132
+ //#region src/core/removalReconciliationController.ts
3133
+ function $(e) {
3134
+ return `${typeof e}:${String(e)}`;
3135
+ }
3136
+ function Bn(e) {
3137
+ return `${typeof e}:${String(e)}`;
3138
+ }
3139
+ function Vn(e) {
3140
+ return e.map(({ postId: e }) => e);
3141
+ }
3142
+ var Hn = class {
3143
+ delay;
3144
+ enabled;
3145
+ maxReplayPages;
3146
+ pageSize;
3147
+ pages = [];
3148
+ tombstones = /* @__PURE__ */ new Set();
3149
+ constructor(e) {
3150
+ let t = e.removalReconciliation;
3151
+ this.enabled = !!t, this.maxReplayPages = t?.maxReplayPages ?? 5, this.pageSize = t?.pageSize ?? 0, this.delay = e.autofill?.strategy === "frontend" ? e.autofill : {
3152
+ delayMaxMs: 0,
3153
+ delayStepMs: 0
3154
+ };
3155
+ }
3156
+ completeReconciliation(e) {
3157
+ this.pages = [...this.pages.slice(0, e.replaceFrom), ...e.pages].slice(-this.maxReplayPages);
3158
+ }
3159
+ filterItems(e) {
3160
+ return !this.enabled || this.tombstones.size === 0 ? [...e] : e.filter(({ postId: e }) => !this.tombstones.has($(e)));
3161
+ }
3162
+ needsReconciliation(e) {
3163
+ return this.findUnderfilledPage(e) >= 0;
3164
+ }
3165
+ recordPages(e) {
3166
+ !this.enabled || e.length === 0 || (e.forEach((e) => this.recordPage(e)), this.pages = this.pages.slice(-this.maxReplayPages));
3167
+ }
3168
+ remove(e) {
3169
+ this.enabled && e.forEach((e) => this.tombstones.add($(e)));
3170
+ }
3171
+ reset() {
3172
+ this.pages = [], this.tombstones.clear();
3173
+ }
3174
+ restore(e) {
3175
+ this.enabled && e.forEach((e) => this.tombstones.delete($(e)));
3176
+ }
3177
+ async reconcile({ existingItems: e, loadPage: t, signal: n }) {
3178
+ let r = this.findUnderfilledPage(e), i = r < 0 ? [] : this.pages.slice(r), a = i[0];
3179
+ if (!a) throw Error("Vibe has no underfilled provider page to reconcile.");
3180
+ let o = new Set(i.flatMap(({ contributionIds: e }) => e.map($))), s = new Set(e.map(({ postId: e }) => $(e)).filter((e) => !o.has(e))), c = new Set(e.map(({ postId: e }) => $(e))), l = new Set(s), u = new Set(c), d = [], f = [], p = /* @__PURE__ */ new Set(), m = a.cursor, h = m, g = m, _;
3181
+ for (let e = 0; e < i.length; e += 1) {
3182
+ let r = Bn(m);
3183
+ if (p.has(r)) throw Error("Vibe removal reconciliation received a repeated cursor.");
3184
+ p.add(r), await Ht({
3185
+ delayMs: Vt(e, this.delay),
3186
+ onChange: () => void 0,
3187
+ signal: n
3188
+ });
3189
+ let i = Pt(await t({
3190
+ cursor: m,
3191
+ signal: n
3192
+ })), a = this.filterItems(i.items), o = [];
3193
+ if (a.forEach((e) => {
3194
+ let t = $(e.postId);
3195
+ l.has(t) || (l.add(t), o.push(e.postId)), u.has(t) || (u.add(t), d.push(e));
3196
+ }), f.push({
3197
+ contributionIds: o,
3198
+ cursor: m,
3199
+ next: i.next,
3200
+ returnedIds: Vn(a)
3201
+ }), h = m, g = i.next, i.total !== void 0 && (_ = i.total), g === null) break;
3202
+ m = g;
3203
+ }
3204
+ return {
3205
+ items: d,
3206
+ lastCursor: h,
3207
+ next: g,
3208
+ pages: f,
3209
+ replaceFrom: r,
3210
+ total: _
3211
+ };
3212
+ }
3213
+ findUnderfilledPage(e) {
3214
+ if (!this.enabled || this.pages.length === 0) return -1;
3215
+ let t = new Set(e.map(({ postId: e }) => $(e)));
3216
+ return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has($(e))).length < this.pageSize);
3217
+ }
3218
+ recordPage(e) {
3219
+ let t = Bn(e.cursor), n = this.pages.findIndex(({ cursor: e }) => Bn(e) === t);
3220
+ n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
3221
+ ...e,
3222
+ contributionIds: [...e.contributionIds],
3223
+ returnedIds: [...e.returnedIds]
3224
+ });
3225
+ }
3226
+ };
3227
+ //#endregion
3010
3228
  //#region src/core/activeItemRemoval.ts
3011
- function In(e, t, n, r, i) {
3229
+ function Un(e, t, n, r, i) {
3012
3230
  let a = new Set(t.map(({ item: e }) => e.postId));
3013
3231
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
3014
3232
  let o = e.items[Math.max(n, 0)];
@@ -3021,7 +3239,7 @@ function In(e, t, n, r, i) {
3021
3239
  }
3022
3240
  //#endregion
3023
3241
  //#region src/core/exactMediaRemovalController.ts
3024
- function Ln(e, t) {
3242
+ function Wn(e, t) {
3025
3243
  let [n, ...r] = t;
3026
3244
  if (!n) throw Error("Vibe items must contain at least one media asset.");
3027
3245
  return {
@@ -3030,10 +3248,10 @@ function Ln(e, t) {
3030
3248
  items: r
3031
3249
  };
3032
3250
  }
3033
- function Rn(e) {
3251
+ function Gn(e) {
3034
3252
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
3035
3253
  }
3036
- var zn = class {
3254
+ var Kn = class {
3037
3255
  generation = 0;
3038
3256
  metadata = /* @__PURE__ */ new WeakMap();
3039
3257
  state;
@@ -3041,7 +3259,7 @@ var zn = class {
3041
3259
  this.options = e, this.state = e.state;
3042
3260
  }
3043
3261
  remove(e) {
3044
- Rn(e);
3262
+ Gn(e);
3045
3263
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
3046
3264
  if (!n) return null;
3047
3265
  let r = [...M(n)], i = r[e.mediaIndex];
@@ -3058,7 +3276,7 @@ var zn = class {
3058
3276
  restored: !1
3059
3277
  });
3060
3278
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
3061
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Ln(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
3279
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Wn(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.options.onPostRemoved(n.postId), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
3062
3280
  }
3063
3281
  reset() {
3064
3282
  this.generation += 1;
@@ -3067,7 +3285,7 @@ var zn = class {
3067
3285
  let t = this.metadata.get(e);
3068
3286
  if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
3069
3287
  if (t.generation !== this.generation || t.restored) return !1;
3070
- t.restored = !0;
3288
+ t.restored = !0, this.options.onPostRestored(e.postId);
3071
3289
  let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
3072
3290
  return n >= 0 ? this.restoreIntoPost(n, e) : this.state.items.splice(Math.min(e.postIndex, this.state.items.length), 0, t.originalItem), this.options.reelForward.cancel(e) && (this.state.mediaIndices.set(e.postId, e.mediaIndex), this.options.onActivate(e.postId)), !0;
3073
3291
  }
@@ -3084,7 +3302,7 @@ var zn = class {
3084
3302
  }
3085
3303
  restoreIntoPost(e, t) {
3086
3304
  let n = this.state.items[e], r = [...M(n)], i = Math.min(t.mediaIndex, r.length);
3087
- if (r.splice(i, 0, t.media), this.state.items[e] = Ln(n, r), this.state.activeReelPostId !== t.postId) return;
3305
+ if (r.splice(i, 0, t.media), this.state.items[e] = Wn(n, r), this.state.activeReelPostId !== t.postId) return;
3088
3306
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
3089
3307
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
3090
3308
  }
@@ -3097,18 +3315,18 @@ var zn = class {
3097
3315
  };
3098
3316
  //#endregion
3099
3317
  //#region src/core/itemPlacement.ts
3100
- function Bn(e, t) {
3318
+ function qn(e, t) {
3101
3319
  let n = new Set(t);
3102
3320
  return e.flatMap((e, t) => n.has(e.postId) ? [{
3103
3321
  index: t,
3104
3322
  item: e
3105
3323
  }] : []);
3106
3324
  }
3107
- function Vn(e, t) {
3325
+ function Jn(e, t) {
3108
3326
  let n = new Set(t.map(({ item: e }) => e.postId));
3109
3327
  return e.filter((e) => !n.has(e.postId));
3110
3328
  }
3111
- function Hn(e, t) {
3329
+ function Yn(e, t) {
3112
3330
  t.forEach(({ index: e }) => {
3113
3331
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
3114
3332
  });
@@ -3119,7 +3337,7 @@ function Hn(e, t) {
3119
3337
  }
3120
3338
  //#endregion
3121
3339
  //#region src/core/itemRemovalController.ts
3122
- var Un = 20, Wn = class {
3340
+ var Xn = 20, Zn = class {
3123
3341
  generation = 0;
3124
3342
  historyLimit;
3125
3343
  metadata = /* @__PURE__ */ new WeakMap();
@@ -3128,7 +3346,7 @@ var Un = 20, Wn = class {
3128
3346
  itemOrder;
3129
3347
  stopItemsWatcher;
3130
3348
  constructor(e) {
3131
- this.options = e, this.historyLimit = e.historyLimit ?? Un, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
3349
+ this.options = e, this.historyLimit = e.historyLimit ?? Xn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
3132
3350
  }
3133
3351
  destroy() {
3134
3352
  this.reset(), this.stopItemsWatcher();
@@ -3141,7 +3359,7 @@ var Un = 20, Wn = class {
3141
3359
  let i = this.options.startRemoval(r);
3142
3360
  if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
3143
3361
  let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), o = new Set(t.map(({ item: e }) => e.postId)), s = a < 0 ? 0 : this.state.items.slice(0, a).filter(({ postId: e }) => o.has(e)).length, c = Math.max(a - s, 0);
3144
- return this.state.items = Vn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3362
+ return this.state.items = Jn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3145
3363
  }
3146
3364
  reset() {
3147
3365
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -3152,7 +3370,7 @@ var Un = 20, Wn = class {
3152
3370
  this.restoreRemoval(t);
3153
3371
  return;
3154
3372
  }
3155
- let n = Hn(this.state.items, e);
3373
+ let n = Yn(this.state.items, e);
3156
3374
  this.registerExternalPlacements(e), this.state.items = n;
3157
3375
  }
3158
3376
  restoreRemoval(e) {
@@ -3178,7 +3396,7 @@ var Un = 20, Wn = class {
3178
3396
  }
3179
3397
  collectOrderedPlacements(e) {
3180
3398
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
3181
- return Bn(this.state.items, e).map((e) => ({
3399
+ return qn(this.state.items, e).map((e) => ({
3182
3400
  index: t.get(e.item.postId) ?? e.index,
3183
3401
  item: e.item
3184
3402
  }));
@@ -3209,7 +3427,7 @@ var Un = 20, Wn = class {
3209
3427
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
3210
3428
  return this.state.items = [...this.state.items, ...n].sort((e, t) => (r.get(e.postId) ?? 2 ** 53 - 1) - (r.get(t.postId) ?? 2 ** 53 - 1)), !0;
3211
3429
  }
3212
- }, Gn = class {
3430
+ }, Qn = class {
3213
3431
  forward = null;
3214
3432
  forwardPromise = null;
3215
3433
  forwardVersion = 0;
@@ -3287,7 +3505,7 @@ var Un = 20, Wn = class {
3287
3505
  }
3288
3506
  }
3289
3507
  }
3290
- }, Kn = class {
3508
+ }, $n = class {
3291
3509
  generation = 0;
3292
3510
  pending = Promise.resolve();
3293
3511
  constructor(e) {
@@ -3337,24 +3555,27 @@ var Un = 20, Wn = class {
3337
3555
  };
3338
3556
  //#endregion
3339
3557
  //#region src/core/removalControllers.ts
3340
- function qn(e) {
3341
- let t = new Gn(e), n = new Kn({
3558
+ function er(e) {
3559
+ let t = new Qn(e), n = new $n({
3342
3560
  state: e.state,
3343
3561
  transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
3344
3562
  transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
3345
3563
  });
3346
3564
  return {
3347
- exactMediaRemoval: new zn({
3565
+ exactMediaRemoval: new Kn({
3348
3566
  onActivate: e.onActivate,
3567
+ onPostRemoved: (t) => e.onItemsRemoved([t]),
3568
+ onPostRestored: (t) => e.onItemsRestored([t]),
3349
3569
  reelForward: t,
3350
3570
  state: e.state
3351
3571
  }),
3352
- itemRemoval: new Wn({
3572
+ itemRemoval: new Zn({
3353
3573
  historyLimit: e.historyLimit,
3354
3574
  onItemsRemoved: (n, r, i) => {
3355
- In(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3575
+ e.onItemsRemoved(r.map(({ item: e }) => e.postId)), Un(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3356
3576
  },
3357
3577
  onRemovalRestored: (n) => {
3578
+ e.onItemsRestored(n.map(({ item: e }) => e.postId));
3358
3579
  let r = t.cancel(n);
3359
3580
  r && e.onActivate(r.postId);
3360
3581
  },
@@ -3366,17 +3587,17 @@ function qn(e) {
3366
3587
  reelRemoval: n
3367
3588
  };
3368
3589
  }
3369
- var Jn = 1.5;
3370
- function Yn(e) {
3590
+ var tr = 1.5;
3591
+ function nr(e) {
3371
3592
  let t = Math.min(e.screenWidth, e.screenHeight);
3372
3593
  if (t > 0 && t < 600) return !0;
3373
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Jn;
3594
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * tr;
3374
3595
  return !e.hasHover && n > 0 && n < 600 && r;
3375
3596
  }
3376
- function Xn(e) {
3377
- return Yn(e) ? "reel" : "masonry";
3597
+ function rr(e) {
3598
+ return nr(e) ? "reel" : "masonry";
3378
3599
  }
3379
- function Zn(e) {
3600
+ function ir(e) {
3380
3601
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3381
3602
  return {
3382
3603
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3386,15 +3607,15 @@ function Zn(e) {
3386
3607
  viewportWidth: n.clientWidth
3387
3608
  };
3388
3609
  }
3389
- function Qn(e) {
3390
- return Yn(Zn(e));
3610
+ function ar(e) {
3611
+ return nr(ir(e));
3391
3612
  }
3392
- function $n(e) {
3393
- return Xn(Zn(e));
3613
+ function or(e) {
3614
+ return rr(ir(e));
3394
3615
  }
3395
3616
  //#endregion
3396
3617
  //#region src/core/responsiveLayoutController.ts
3397
- var er = class {
3618
+ var sr = class {
3398
3619
  layoutMode;
3399
3620
  resizeObserver = null;
3400
3621
  target = null;
@@ -3419,10 +3640,10 @@ var er = class {
3419
3640
  }
3420
3641
  handleResponsiveLayout = () => {
3421
3642
  if (!this.target) return;
3422
- let e = $n(this.target);
3423
- this.state.reelInfoSheetOverlay = Qn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3643
+ let e = or(this.target);
3644
+ this.state.reelInfoSheetOverlay = ar(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3424
3645
  };
3425
- }, tr = class {
3646
+ }, cr = class {
3426
3647
  routedReelPostId = null;
3427
3648
  reelRouteIsActive = !1;
3428
3649
  constructor(e, t) {
@@ -3449,7 +3670,7 @@ var er = class {
3449
3670
  let i = this.reelRouteIsActive ? "replace" : "push";
3450
3671
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3451
3672
  }
3452
- }, nr = class {
3673
+ }, lr = class {
3453
3674
  app = null;
3454
3675
  autoScroll;
3455
3676
  autofillController;
@@ -3461,6 +3682,7 @@ var er = class {
3461
3682
  fillController;
3462
3683
  exactMediaRemoval;
3463
3684
  itemRemoval;
3685
+ removalReconciliation;
3464
3686
  reelForward;
3465
3687
  reelRemoval;
3466
3688
  surface = null;
@@ -3468,49 +3690,54 @@ var er = class {
3468
3690
  lastLoadedCursor = null;
3469
3691
  state;
3470
3692
  constructor(e) {
3471
- this.options = e, Pn(e);
3693
+ this.options = e, Ln(e);
3472
3694
  let t = e.layout ?? "masonry";
3473
- this.state = x(jn(e, t)), this.autoScroll = new nn({
3695
+ this.state = x(Pn(e, t)), this.autoScroll = new on({
3474
3696
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
3475
3697
  state: this.state.autoScroll
3476
- }), this.autofillController = new Xt({
3698
+ }), this.autofillController = new $t({
3477
3699
  cancelRequest: () => this.cancelRequest(),
3478
3700
  onLastCursor: (e) => {
3479
3701
  this.lastLoadedCursor = e;
3480
3702
  },
3481
3703
  options: e.autofill,
3482
3704
  state: this.state
3483
- }), this.fillController = new Cn({
3705
+ }), this.removalReconciliation = new Hn(e), this.fillController = new En({
3484
3706
  fill: e.fill,
3485
- loadPage: e.loadPage,
3707
+ loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
3486
3708
  onLastCursor: (e) => {
3487
3709
  this.lastLoadedCursor = e;
3488
3710
  },
3711
+ onPages: (e) => this.removalReconciliation.recordPages(e),
3489
3712
  state: this.state
3490
- }), this.routing = new tr(e.routing, this.state);
3491
- let n = qn({
3713
+ }), this.routing = new cr(e.routing, this.state);
3714
+ let n = er({
3492
3715
  historyLimit: e.removalHistoryLimit,
3493
3716
  loadNext: () => this.loadNext(),
3494
3717
  onActivate: (e) => this.setActiveReelPost(e),
3718
+ onItemsRemoved: (e) => this.removalReconciliation.remove(e),
3719
+ onItemsRestored: (e) => this.removalReconciliation.restore(e),
3495
3720
  retryEnd: () => this.retryEnd(),
3496
3721
  state: this.state,
3497
3722
  surface: () => this.surface
3498
3723
  });
3499
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new er(t, this.state, () => {
3724
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new sr(t, this.state, () => {
3500
3725
  this.routing.syncFeed();
3501
3726
  }), this.startStateNotifications();
3502
3727
  }
3503
3728
  async mount() {
3504
3729
  if (this.app) throw Error("Vibe is already mounted.");
3505
3730
  this.startStateNotifications();
3506
- let e = Fn(this.options.target);
3507
- this.responsiveLayout.mount(e), this.app = i(At, {
3731
+ let e = Rn(this.options.target);
3732
+ this.responsiveLayout.mount(e), this.app = i(Nt, {
3508
3733
  canRetryEnd: !!this.options.loadPage,
3509
3734
  cardFooter: this.options.cardFooter,
3510
3735
  cardHeader: this.options.cardHeader,
3511
3736
  feedFooter: this.options.feedFooter,
3512
- feedFooterActions: wn(this),
3737
+ feedFooterActions: Dn(this),
3513
3738
  mediaCard: this.options.mediaCard,
3739
+ onMediaReady: this.options.onMediaReady,
3740
+ onReelMediaChange: this.options.onReelMediaChange,
3514
3741
  reelInfoSheet: this.options.reelInfoSheet,
3515
3742
  state: this.state,
3516
3743
  onActiveReelChange: (e) => {
@@ -3531,10 +3758,10 @@ var er = class {
3531
3758
  }), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && await this.startInitialAutofill() : await this.reload();
3532
3759
  }
3533
3760
  destroy() {
3534
- this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3761
+ this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.removalReconciliation.reset(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3535
3762
  }
3536
3763
  getState() {
3537
- return I(this.state);
3764
+ return R(this.state);
3538
3765
  }
3539
3766
  removeMedia(e) {
3540
3767
  return this.exactMediaRemoval.remove(e);
@@ -3588,7 +3815,7 @@ var er = class {
3588
3815
  this.autoScroll.setSpeed(e);
3589
3816
  }
3590
3817
  applyAutofillUpdate(e) {
3591
- let t = on(this.options.autofill, this.state, e);
3818
+ let t = ln(this.options.autofill, this.state, e);
3592
3819
  return t && this.autofillController.syncCountdown(), t;
3593
3820
  }
3594
3821
  cancelAutofill() {
@@ -3601,11 +3828,11 @@ var er = class {
3601
3828
  return this.fillController.cancel();
3602
3829
  }
3603
3830
  async fill(e) {
3604
- if (this.pendingRequest || Kt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3831
+ if (this.pendingRequest || Yt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3605
3832
  await this.fillController.start(e);
3606
3833
  }
3607
3834
  restoreAutofillSession(e) {
3608
- let t = sn(this.options.autofill, this.state, e);
3835
+ let t = un(this.options.autofill, this.state, e);
3609
3836
  return t && this.autofillController.syncCountdown(), t;
3610
3837
  }
3611
3838
  restoreFillSession(e) {
@@ -3613,7 +3840,12 @@ var er = class {
3613
3840
  }
3614
3841
  async loadNext() {
3615
3842
  if (this.pendingRequest) return this.pendingRequest;
3616
- if (!this.state.loadMoreLocked && !(Kt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next === null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.state.next, !0);
3843
+ if (this.state.loadMoreLocked || Yt(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
3844
+ this.state.isLoadingMore = !0, this.state.nextPageError = null;
3845
+ let e = this.loadNextSequence();
3846
+ return this.pendingRequest = e, e.finally(() => {
3847
+ this.pendingRequest === e && (this.pendingRequest = null), this.state.isLoadingMore = !1;
3848
+ });
3617
3849
  }
3618
3850
  async refresh() {
3619
3851
  return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
@@ -3623,11 +3855,41 @@ var er = class {
3623
3855
  }
3624
3856
  async replaceFeed(e, t) {
3625
3857
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
3626
- return Kt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Gt(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3858
+ return Yt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Jt(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.removalReconciliation.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3859
+ }
3860
+ async loadFilteredPage(e) {
3861
+ let t = this.options.loadPage;
3862
+ if (!t) throw Error("Vibe cannot load a page without loadPage.");
3863
+ let n = Pt(await t(e));
3864
+ return {
3865
+ ...n,
3866
+ items: this.removalReconciliation.filterItems(n.items)
3867
+ };
3868
+ }
3869
+ async loadNextSequence() {
3870
+ this.removalReconciliation.needsReconciliation(this.state.items) && !await this.reconcileBeforeNext() || this.state.next !== null && await this.fetchPage(this.state.next, !0);
3871
+ }
3872
+ async reconcileBeforeNext() {
3873
+ let e = this.options.loadPage;
3874
+ if (!e) return !1;
3875
+ let t = ++this.requestVersion, n = new AbortController();
3876
+ this.abortController = n;
3877
+ try {
3878
+ let r = await this.removalReconciliation.reconcile({
3879
+ existingItems: this.state.items,
3880
+ loadPage: e,
3881
+ signal: n.signal
3882
+ });
3883
+ return t === this.requestVersion ? (this.state.items = Z(this.state.items, r.items), this.state.next = r.next, this.lastLoadedCursor = r.lastCursor, r.total !== void 0 && (this.state.total = r.total), this.removalReconciliation.completeReconciliation(r), !0) : !1;
3884
+ } catch (e) {
3885
+ return !n.signal.aborted && t === this.requestVersion && (this.state.nextPageError = e), !1;
3886
+ } finally {
3887
+ this.abortController === n && (this.abortController = null);
3888
+ }
3627
3889
  }
3628
3890
  async retryEnd() {
3629
3891
  if (this.pendingRequest) return this.pendingRequest;
3630
- if (!this.state.loadMoreLocked && !(Kt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
3892
+ if (!this.state.loadMoreLocked && !(Yt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
3631
3893
  }
3632
3894
  setInfiniteScroll(e) {
3633
3895
  this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
@@ -3636,10 +3898,10 @@ var er = class {
3636
3898
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && m(() => this.surface?.loadIfNearBottom()));
3637
3899
  }
3638
3900
  setReelAutoAdvance(e) {
3639
- On(this.state.reelAutoAdvance, e);
3901
+ jn(this.state.reelAutoAdvance, e);
3640
3902
  }
3641
3903
  setReelInfoSheet(e) {
3642
- An(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3904
+ Nn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3643
3905
  }
3644
3906
  setLayout(e) {
3645
3907
  this.responsiveLayout.setLayout(e);
@@ -3657,68 +3919,22 @@ var er = class {
3657
3919
  this.autofillController.clearCountdown(), this.requestVersion += 1, this.abortController?.abort(), this.abortController = null, this.pendingRequest = null, this.state.isLoading = !1, this.state.isLoadingMore = !1;
3658
3920
  }
3659
3921
  async fetchPage(e, t) {
3660
- let n = this.options.loadPage;
3661
- if (!n) return;
3662
- let r = ++this.requestVersion, i = new AbortController(), a = this.options.autofill, o = a ? this.autofillController.beginCycle() : null, s = !1;
3663
- this.abortController = i;
3664
- try {
3665
- if (a?.strategy === "frontend") {
3666
- let o = await Yt({
3667
- existingItems: t ? this.state.items : [],
3668
- initialCursor: e,
3669
- loadPage: n,
3670
- onCollection: (e) => this.autofillController.captureCollection(e, r === this.requestVersion),
3671
- onDelayChange: (e) => {
3672
- r === this.requestVersion && Object.assign(this.state.autofill, e);
3673
- },
3674
- onProgress: (e) => {
3675
- r === this.requestVersion && Object.assign(this.state.autofill, e, { status: "filling" });
3676
- },
3677
- options: a,
3678
- signal: i.signal
3679
- });
3680
- if (r !== this.requestVersion) return;
3681
- this.state.items = t ? Q(this.state.items, o.items) : [...o.items], this.lastLoadedCursor = o.lastCursor, this.state.next = o.next, o.total !== void 0 && (this.state.total = o.total), Object.assign(this.state.autofill, {
3682
- missing: o.missing,
3683
- received: o.received,
3684
- requests: o.requests,
3685
- status: o.status
3686
- }), this.autofillController.clearCollection();
3687
- return;
3688
- }
3689
- let c = jt(await n({
3690
- cursor: e,
3691
- signal: i.signal
3692
- }));
3693
- if (r !== this.requestVersion) return;
3694
- let l = t ? this.state.items : [], u = Q(l, c.items), d = u.length - l.length;
3695
- if (this.state.items = u, this.lastLoadedCursor = e, this.state.next = c.next, c.total !== void 0 && (this.state.total = c.total), s = !0, a?.strategy === "backend" && o) {
3696
- if (Object.assign(this.state.autofill, {
3697
- missing: Math.max(0, a.pageSize - d),
3698
- received: d,
3699
- requests: 1
3700
- }), d >= a.pageSize) {
3701
- this.state.autofill.status = "complete";
3702
- return;
3703
- }
3704
- await rn(a, this.state, {
3705
- cycleId: o,
3706
- feedKey: a.feedKey,
3707
- items: u.slice(l.length),
3708
- missing: a.pageSize - d,
3709
- next: c.next,
3710
- pageSize: a.pageSize,
3711
- received: d,
3712
- signal: i.signal,
3713
- total: this.state.total
3714
- }, () => r === this.requestVersion), this.autofillController.syncCountdown();
3715
- }
3716
- } catch (e) {
3717
- if (i.signal.aborted || r !== this.requestVersion) return;
3718
- a && (this.state.autofill.error = e, this.state.autofill.status = "error"), s || (t ? this.state.nextPageError = e : this.state.error = e);
3719
- } finally {
3720
- r === this.requestVersion && (this.autofillController.clearCollection(), this.abortController = null, this.state.isLoading = !1, this.state.isLoadingMore = !1);
3721
- }
3922
+ if (!this.options.loadPage) return;
3923
+ let n = ++this.requestVersion, r = new AbortController();
3924
+ this.abortController = r, await zn({
3925
+ append: t,
3926
+ autofillController: this.autofillController,
3927
+ cursor: e,
3928
+ isCurrent: () => n === this.requestVersion,
3929
+ loadPage: (e) => this.loadFilteredPage(e),
3930
+ onLastCursor: (e) => {
3931
+ this.lastLoadedCursor = e;
3932
+ },
3933
+ onPages: (e) => this.removalReconciliation.recordPages(e),
3934
+ options: this.options,
3935
+ signal: r.signal,
3936
+ state: this.state
3937
+ }), n === this.requestVersion && (this.abortController = null);
3722
3938
  }
3723
3939
  startRequest(e, t) {
3724
3940
  let n = this.fetchPage(e, t);
@@ -3729,13 +3945,14 @@ var er = class {
3729
3945
  startInitialAutofill() {
3730
3946
  let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
3731
3947
  this.abortController = t, this.state.isLoadingMore = !0;
3732
- let r = cn({
3948
+ let r = dn({
3733
3949
  cycleId: n,
3734
3950
  isCurrent: () => e === this.requestVersion,
3735
3951
  onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
3736
3952
  onLastCursor: (e) => {
3737
3953
  this.lastLoadedCursor = e;
3738
3954
  },
3955
+ onPages: (e) => this.removalReconciliation.recordPages(e),
3739
3956
  options: this.options,
3740
3957
  signal: t.signal,
3741
3958
  state: this.state
@@ -3754,8 +3971,8 @@ var er = class {
3754
3971
  }));
3755
3972
  }
3756
3973
  };
3757
- function rr(e) {
3758
- return new nr(e);
3974
+ function ur(e) {
3975
+ return new lr(e);
3759
3976
  }
3760
3977
  //#endregion
3761
- export { rr as createVibe };
3978
+ export { ur as createVibe };