@wyxos/vibe 5.5.5 → 5.6.0

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
@@ -54,10 +54,10 @@ var R = {
54
54
  key: 0,
55
55
  class: "load-more-status",
56
56
  role: "status"
57
- }, B = ["disabled"], V = {
57
+ }, B = ["disabled"], ee = {
58
58
  key: 2,
59
59
  class: "end-feed"
60
- }, H = ["disabled"], ee = /* @__PURE__ */ d({
60
+ }, V = ["disabled"], H = /* @__PURE__ */ d({
61
61
  __name: "GalleryFooter",
62
62
  props: {
63
63
  canRetryEnd: { type: Boolean },
@@ -80,7 +80,7 @@ var R = {
80
80
  type: "button",
81
81
  disabled: e.loadMoreLocked,
82
82
  onClick: i
83
- }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, B)) : (b(), s("div", V, [n[1] ||= c("p", {
83
+ }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, B)) : (b(), s("div", ee, [n[1] ||= c("p", {
84
84
  class: "end-feed-message",
85
85
  role: "status"
86
86
  }, " You've reached the end. ", -1), c("button", {
@@ -89,7 +89,7 @@ var R = {
89
89
  type: "button",
90
90
  disabled: e.loadMoreLocked,
91
91
  onClick: n[0] ||= (e) => t.$emit("retryEnd")
92
- }, " Check for more ", 8, H)]))])) : o("", !0);
92
+ }, " Check for more ", 8, V)]))])) : o("", !0);
93
93
  }
94
94
  }), U = /* @__PURE__ */ d({
95
95
  __name: "FeedFooter",
@@ -128,7 +128,7 @@ var R = {
128
128
  "can-retry-end",
129
129
  "show-load-more",
130
130
  "state"
131
- ])) : (b(), a(ee, {
131
+ ])) : (b(), a(H, {
132
132
  key: 1,
133
133
  "can-retry-end": e.canRetryEnd,
134
134
  "has-error": e.hasError,
@@ -186,29 +186,29 @@ var R = {
186
186
  ])) : o("", !0)], 8, W));
187
187
  }
188
188
  });
189
- function K(e) {
189
+ function ne(e) {
190
190
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
191
191
  }
192
192
  //#endregion
193
193
  //#region src/core/masonry.ts
194
- function ne(e) {
194
+ function re(e) {
195
195
  let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
196
196
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
197
197
  }
198
- function q(e) {
198
+ function K(e) {
199
199
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
200
200
  }
201
- function re(e) {
201
+ function ie(e) {
202
202
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
203
203
  }
204
- function ie(e, t, n) {
204
+ function ae(e, t, n) {
205
205
  if (t <= 0 || e.length === 0) return {
206
206
  columns: 0,
207
207
  height: 0,
208
208
  items: []
209
209
  };
210
210
  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) => {
211
- let t = q(c), n = s * ne(e) + i, a = {
211
+ let t = K(c), n = s * re(e) + i, a = {
212
212
  x: t * (s + r),
213
213
  y: c[t],
214
214
  width: s,
@@ -224,7 +224,7 @@ function ie(e, t, n) {
224
224
  }
225
225
  //#endregion
226
226
  //#region src/core/masonryViewportIndex.ts
227
- function ae(e, t) {
227
+ function oe(e, t) {
228
228
  let n = /* @__PURE__ */ new Map();
229
229
  return e.forEach((e, r) => {
230
230
  let i = n.get(e.x) ?? [];
@@ -235,7 +235,7 @@ function ae(e, t) {
235
235
  }), n.set(e.x, i);
236
236
  }), { columns: [...n.entries()].sort(([e], [t]) => e - t).map(([, e]) => e.sort((e, t) => e.top - t.top || e.index - t.index)) };
237
237
  }
238
- function oe(e, t) {
238
+ function q(e, t) {
239
239
  let n = 0, r = 0, i = e.length;
240
240
  for (; r < i;) {
241
241
  let a = Math.floor((r + i) / 2);
@@ -249,7 +249,7 @@ function oe(e, t) {
249
249
  function se(e, t) {
250
250
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n, a = [], o = 0;
251
251
  return e.columns.forEach((e) => {
252
- let t = oe(e, r);
252
+ let t = q(e, r);
253
253
  o += t.inspected;
254
254
  for (let n = t.index; n < e.length; n += 1) {
255
255
  let t = e[n];
@@ -261,14 +261,14 @@ function se(e, t) {
261
261
  inspected: o
262
262
  };
263
263
  }
264
- function ce(e) {
264
+ function J(e) {
265
265
  return e?.minColumnWidth ?? 240;
266
266
  }
267
- function le(e, t) {
267
+ function Y(e, t) {
268
268
  let n = e?.overscan?.minimumPx ?? 800, r = e?.overscan?.viewportMultiplier ?? 1.5, i = Math.max(n, t * r), a = e?.overscan?.maximumPx;
269
269
  return a === void 0 ? i : Math.min(i, a);
270
270
  }
271
- function J(e) {
271
+ function X(e) {
272
272
  if (e?.minColumnWidth !== void 0 && (!Number.isFinite(e.minColumnWidth) || e.minColumnWidth <= 0)) throw TypeError("Vibe masonry minColumnWidth must be a positive number.");
273
273
  let t = e?.overscan;
274
274
  if (t) {
@@ -282,10 +282,10 @@ function J(e) {
282
282
  }
283
283
  //#endregion
284
284
  //#region src/core/scrollbar.ts
285
- function ue(e, t, n) {
285
+ function Z(e, t, n) {
286
286
  return Math.min(n, Math.max(t, e));
287
287
  }
288
- function Y({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
288
+ function ce({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
289
289
  let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
290
290
  if (!(c > 0 && o > 0)) return {
291
291
  maximumScrollPosition: c,
@@ -294,23 +294,23 @@ function Y({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
294
294
  thumbSize: o,
295
295
  thumbTravel: 0
296
296
  };
297
- let l = ue(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
297
+ let l = Z(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
298
298
  return {
299
299
  maximumScrollPosition: c,
300
300
  scrollable: !0,
301
- thumbOffset: u * (ue(n, 0, c) / c),
301
+ thumbOffset: u * (Z(n, 0, c) / c),
302
302
  thumbSize: l,
303
303
  thumbTravel: u
304
304
  };
305
305
  }
306
306
  //#endregion
307
307
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
308
- var de = ["aria-hidden"], fe = [
308
+ var le = ["aria-hidden"], ue = [
309
309
  "aria-controls",
310
310
  "aria-valuemax",
311
311
  "aria-valuenow",
312
312
  "tabindex"
313
- ], pe = 32, me = 40, he = 120, X = /* @__PURE__ */ d({
313
+ ], de = 32, fe = 40, pe = 120, me = /* @__PURE__ */ d({
314
314
  __name: "GalleryScrollbar",
315
315
  props: {
316
316
  contentSize: {},
@@ -332,16 +332,16 @@ var de = ["aria-hidden"], fe = [
332
332
  function k() {
333
333
  g !== null && clearTimeout(g), g = setTimeout(() => {
334
334
  g = null, o.value || (l.value = !1);
335
- }, he);
335
+ }, pe);
336
336
  }
337
337
  function A() {
338
338
  l.value = !0, k();
339
339
  }
340
340
  function j() {
341
341
  let e = t.scrollElement, r = i.value;
342
- return !e || !r ? n : Y({
342
+ return !e || !r ? n : ce({
343
343
  contentSize: e.scrollHeight,
344
- minimumThumbSize: pe,
344
+ minimumThumbSize: de,
345
345
  scrollPosition: e.scrollTop,
346
346
  trackSize: r.clientHeight,
347
347
  viewportSize: e.clientHeight
@@ -394,7 +394,7 @@ var de = ["aria-hidden"], fe = [
394
394
  }
395
395
  function z(e) {
396
396
  if (!E.value) return;
397
- let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - me : e.key === "ArrowDown" ? r + me : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
397
+ let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - fe : e.key === "ArrowDown" ? r + fe : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
398
398
  i !== null && (e.preventDefault(), A(), P(i));
399
399
  }
400
400
  function B(e) {
@@ -440,15 +440,15 @@ var de = ["aria-hidden"], fe = [
440
440
  onPointerdown: I,
441
441
  onPointermove: L,
442
442
  onPointerup: R
443
- }, null, 44, fe)], 42, de));
443
+ }, null, 44, ue)], 42, le));
444
444
  }
445
- }), ge = (e) => {
445
+ }), he = (e) => {
446
446
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
447
447
  return !1;
448
- }, _e = (e) => e === "", ve = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), ye = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), be = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), xe = (e) => {
449
- let t = be(e);
448
+ }, ge = (e) => e === "", _e = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), ve = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ye = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), be = (e) => {
449
+ let t = ye(e);
450
450
  return t.charAt(0).toUpperCase() + t.slice(1);
451
- }, Se = {
451
+ }, xe = {
452
452
  xmlns: "http://www.w3.org/2000/svg",
453
453
  width: 24,
454
454
  height: 24,
@@ -458,27 +458,27 @@ var de = ["aria-hidden"], fe = [
458
458
  "stroke-width": 2,
459
459
  "stroke-linecap": "round",
460
460
  "stroke-linejoin": "round"
461
- }, Ce = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = Se.width, color: s = Se.stroke, ...c }, { slots: l }) => p("svg", {
462
- ...Se,
461
+ }, Se = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = xe.width, color: s = xe.stroke, ...c }, { slots: l }) => p("svg", {
462
+ ...xe,
463
463
  ...c,
464
464
  width: o,
465
465
  height: o,
466
466
  stroke: s,
467
- "stroke-width": _e(n) || _e(r) || n === !0 || r === !0 ? Number(i || a || Se["stroke-width"]) * 24 / Number(o) : i || a || Se["stroke-width"],
468
- class: ve("lucide", c.class, ...e ? [`lucide-${ye(xe(e))}-icon`, `lucide-${ye(e)}`] : ["lucide-icon"]),
469
- ...!l.default && !ge(c) && { "aria-hidden": "true" }
470
- }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), we = (e, t) => (n, { slots: r, attrs: i }) => p(Ce, {
467
+ "stroke-width": ge(n) || ge(r) || n === !0 || r === !0 ? Number(i || a || xe["stroke-width"]) * 24 / Number(o) : i || a || xe["stroke-width"],
468
+ class: _e("lucide", c.class, ...e ? [`lucide-${ve(be(e))}-icon`, `lucide-${ve(e)}`] : ["lucide-icon"]),
469
+ ...!l.default && !he(c) && { "aria-hidden": "true" }
470
+ }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), Ce = (e, t) => (n, { slots: r, attrs: i }) => p(Se, {
471
471
  ...i,
472
472
  ...n,
473
473
  iconNode: t,
474
474
  name: e
475
- }, r), Te = we("chevron-left", [["path", {
475
+ }, r), we = Ce("chevron-left", [["path", {
476
476
  d: "m15 18-6-6 6-6",
477
477
  key: "1wnfg3"
478
- }]]), Ee = we("chevron-right", [["path", {
478
+ }]]), Te = Ce("chevron-right", [["path", {
479
479
  d: "m9 18 6-6-6-6",
480
480
  key: "mthhwq"
481
- }]]), De = we("pause", [["rect", {
481
+ }]]), Ee = Ce("pause", [["rect", {
482
482
  x: "14",
483
483
  y: "3",
484
484
  width: "5",
@@ -492,10 +492,10 @@ var de = ["aria-hidden"], fe = [
492
492
  height: "18",
493
493
  rx: "1",
494
494
  key: "1wsw3u"
495
- }]]), Oe = we("play", [["path", {
495
+ }]]), De = Ce("play", [["path", {
496
496
  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",
497
497
  key: "10ikf1"
498
- }]]), ke = we("volume-2", [
498
+ }]]), Oe = Ce("volume-2", [
499
499
  ["path", {
500
500
  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",
501
501
  key: "uqj9uw"
@@ -508,7 +508,7 @@ var de = ["aria-hidden"], fe = [
508
508
  d: "M19.364 18.364a9 9 0 0 0 0-12.728",
509
509
  key: "ijwkga"
510
510
  }]
511
- ]), Ae = we("volume-x", [
511
+ ]), ke = Ce("volume-x", [
512
512
  ["path", {
513
513
  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",
514
514
  key: "uqj9uw"
@@ -527,22 +527,22 @@ var de = ["aria-hidden"], fe = [
527
527
  y2: "15",
528
528
  key: "5ykzw1"
529
529
  }]
530
- ]), je = {
530
+ ]), Ae = {
531
531
  401: "Authentication required",
532
532
  403: "Access forbidden",
533
533
  404: "Preview not found",
534
534
  419: "Session expired",
535
535
  500: "Server error"
536
536
  };
537
- function Me(e) {
537
+ function je(e) {
538
538
  return e.match(/\/demo-errors\/(401|403|404|419|500)\//)?.[1] ?? "Error";
539
539
  }
540
- function Ne(e) {
541
- return je[Me(e)] ?? "Preview unavailable";
540
+ function Me(e) {
541
+ return Ae[je(e)] ?? "Preview unavailable";
542
542
  }
543
543
  //#endregion
544
544
  //#region src/components/CardRegion.vue
545
- var Pe = /* @__PURE__ */ d({
545
+ var Ne = /* @__PURE__ */ d({
546
546
  __name: "CardRegion",
547
547
  props: {
548
548
  index: {},
@@ -589,18 +589,18 @@ var Pe = /* @__PURE__ */ d({
589
589
  "total"
590
590
  ]))], 38));
591
591
  }
592
- }), Fe = [
592
+ }), Pe = [
593
593
  "max",
594
594
  "value",
595
595
  "aria-valuetext",
596
596
  "disabled"
597
- ], Ie = {
597
+ ], Fe = {
598
598
  key: 0,
599
599
  class: "media-controls-row"
600
- }, Le = ["aria-label", "title"], Re = { class: "media-controls-audio" }, ze = ["aria-label", "title"], Be = ["value", "aria-valuetext"], Ve = {
600
+ }, Ie = ["aria-label", "title"], Le = { class: "media-controls-audio" }, Re = ["aria-label", "title"], ze = ["value", "aria-valuetext"], Be = {
601
601
  class: "media-control-time",
602
602
  "aria-live": "off"
603
- }, He = /* @__PURE__ */ d({
603
+ }, Ve = /* @__PURE__ */ d({
604
604
  __name: "MediaControls",
605
605
  props: {
606
606
  currentTime: {},
@@ -648,35 +648,35 @@ var Pe = /* @__PURE__ */ d({
648
648
  "aria-valuetext": `${u(p.value)} of ${u(f.value)}`,
649
649
  disabled: f.value <= 0,
650
650
  onInput: n[0] ||= (e) => i("seek", d(e))
651
- }, null, 44, Fe), e.layout === "reel" ? (b(), s("div", Ie, [
651
+ }, null, 44, Pe), e.layout === "reel" ? (b(), s("div", Fe, [
652
652
  c("button", {
653
653
  type: "button",
654
654
  class: "media-control-button media-control-playback",
655
655
  "aria-label": e.playing ? "Pause video" : "Play video",
656
656
  title: e.playing ? "Pause" : "Play",
657
657
  onClick: n[1] ||= (e) => i("togglePlayback")
658
- }, [e.playing ? (b(), a(E(De), {
658
+ }, [e.playing ? (b(), a(E(Ee), {
659
659
  key: 0,
660
660
  size: 18,
661
661
  fill: "currentColor"
662
- })) : (b(), a(E(Oe), {
662
+ })) : (b(), a(E(De), {
663
663
  key: 1,
664
664
  size: 18,
665
665
  fill: "currentColor"
666
- }))], 8, Le),
667
- c("div", Re, [c("button", {
666
+ }))], 8, Ie),
667
+ c("div", Le, [c("button", {
668
668
  type: "button",
669
669
  class: "media-control-button",
670
670
  "aria-label": e.muted ? "Unmute video" : "Mute video",
671
671
  title: e.muted ? "Unmute" : "Mute",
672
672
  onClick: n[2] ||= (e) => i("toggleMute")
673
- }, [e.muted || e.volume === 0 ? (b(), a(E(Ae), {
673
+ }, [e.muted || e.volume === 0 ? (b(), a(E(ke), {
674
674
  key: 0,
675
675
  size: 18
676
- })) : (b(), a(E(ke), {
676
+ })) : (b(), a(E(Oe), {
677
677
  key: 1,
678
678
  size: 18
679
- }))], 8, ze), c("input", {
679
+ }))], 8, Re), c("input", {
680
680
  class: "media-control-range media-control-volume",
681
681
  type: "range",
682
682
  min: "0",
@@ -687,14 +687,14 @@ var Pe = /* @__PURE__ */ d({
687
687
  "aria-label": "Video volume",
688
688
  "aria-valuetext": `${Math.round(e.volume * 100)} percent`,
689
689
  onInput: n[3] ||= (e) => i("volumeChange", d(e))
690
- }, null, 44, Be)]),
691
- c("output", Ve, T(u(p.value)) + " / " + T(u(f.value)), 1)
690
+ }, null, 44, ze)]),
691
+ c("output", Be, T(u(p.value)) + " / " + T(u(f.value)), 1)
692
692
  ])) : o("", !0)], 34));
693
693
  }
694
694
  });
695
695
  //#endregion
696
696
  //#region src/components/useReelVideoActivity.ts
697
- function Ue(e) {
697
+ function He(e) {
698
698
  let t = r(() => e.layout() !== "reel" || e.active() === !0), n = r(() => t.value ? e.videoIsMuted.value : !0);
699
699
  function i() {
700
700
  if (!t.value) {
@@ -728,18 +728,21 @@ function Ue(e) {
728
728
  }
729
729
  //#endregion
730
730
  //#region src/core/mediaType.ts
731
- var We = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
732
- function Ge(e) {
731
+ var Ue = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
732
+ function We(e) {
733
733
  try {
734
- return We.test(new URL(e).pathname);
734
+ return Ue.test(new URL(e).pathname);
735
735
  } catch {
736
- return We.test(e.split("?")[0] ?? e);
736
+ return Ue.test(e.split("?")[0] ?? e);
737
737
  }
738
738
  }
739
+ function Ge(e, t) {
740
+ return e === void 0 ? We(t) : e === "video";
741
+ }
739
742
  //#endregion
740
743
  //#region src/components/useMediaLoading.ts
741
744
  function Ke(e) {
742
- let t = r(() => Ge(e.mediaSource())), n = r(() => e.layout() === "masonry" && e.fetchPriority() === "low" ? "lazy" : "eager"), i = r(() => e.fetchPriority() === "high" ? "auto" : e.layout() === "masonry" ? "none" : "metadata");
745
+ let t = r(() => Ge(e.mediaType(), e.mediaSource())), n = r(() => e.layout() === "masonry" && e.fetchPriority() === "low" ? "lazy" : "eager"), i = r(() => e.layout() === "reel" && !e.active() ? "none" : e.fetchPriority() === "high" ? "auto" : e.layout() === "masonry" ? "none" : "metadata");
743
746
  return O(i, (t, n) => {
744
747
  n !== "none" || t === "none" || m(() => e.videoElement.value?.load());
745
748
  }), {
@@ -749,8 +752,65 @@ function Ke(e) {
749
752
  };
750
753
  }
751
754
  //#endregion
755
+ //#region src/components/useMediaReadiness.ts
756
+ function qe(e) {
757
+ let t = w(null), n = w(null), i = w(0), a = w(0), o = w(!0), s = w(!1), c = null, l = !1, u = r(() => s.value ? "error" : o.value ? "loading" : e.previewState());
758
+ function d() {
759
+ c !== null && clearTimeout(c), c = null;
760
+ }
761
+ function f(e) {
762
+ return Number(e.currentTarget.dataset.sourceGeneration) === i.value;
763
+ }
764
+ function p() {
765
+ d(), c = setTimeout(() => _(), 15e3);
766
+ }
767
+ function h(t) {
768
+ t && !f(t) || (d(), o.value = !1, s.value = !1, e.onReady(e.mediaIndex()));
769
+ }
770
+ function g() {
771
+ let e = t.value;
772
+ if (e?.complete) {
773
+ e.naturalWidth > 0 ? h() : _();
774
+ return;
775
+ }
776
+ let r = n.value;
777
+ if (r && r.readyState >= HTMLMediaElement.HAVE_METADATA) {
778
+ h();
779
+ return;
780
+ }
781
+ p();
782
+ }
783
+ function _(t) {
784
+ if (!(t && !f(t))) {
785
+ if (d(), !t && a.value === 0) {
786
+ a.value = 1, i.value += 1, o.value = !0, m(g);
787
+ return;
788
+ }
789
+ o.value = !1, s.value = !0, e.onError(e.mediaIndex());
790
+ }
791
+ }
792
+ function y() {
793
+ a.value = 0, s.value = !1, o.value = !0, i.value += 1, m(g);
794
+ }
795
+ function b(e) {
796
+ f(e) && o.value && p();
797
+ }
798
+ return O(e.identity, () => {
799
+ d(), i.value += 1, a.value = 0, o.value = l || e.previewState() === "loading", s.value = !1, l = !0, m(g);
800
+ }, { immediate: !0 }), v(d), {
801
+ effectivePreviewState: u,
802
+ failSourceAttempt: _,
803
+ imageElement: t,
804
+ markSourceReady: h,
805
+ noteSourceActivity: b,
806
+ retrySource: y,
807
+ sourceGeneration: i,
808
+ videoElement: n
809
+ };
810
+ }
811
+ //#endregion
752
812
  //#region src/components/MediaCard.vue?vue&type=script&setup=true&lang.ts
753
- var qe = [
813
+ var Je = [
754
814
  "data-post-id",
755
815
  "data-media-index",
756
816
  "aria-hidden",
@@ -758,12 +818,13 @@ var qe = [
758
818
  "inert",
759
819
  "role",
760
820
  "tabindex"
761
- ], Je = { class: "media-card-content" }, Ye = ["data-media-direction"], Xe = ["data-media-index"], Ze = {
821
+ ], Ye = { class: "media-card-content" }, Xe = ["data-media-direction"], Ze = ["data-media-index"], Qe = {
762
822
  key: 0,
763
823
  "data-test": "media-loading",
764
824
  class: "media-loading",
765
825
  "aria-hidden": "true"
766
- }, Qe = ["aria-label"], $e = { class: "media-error-code" }, et = [
826
+ }, $e = ["aria-label"], et = { class: "media-error-code" }, tt = [
827
+ "data-source-generation",
767
828
  "src",
768
829
  "width",
769
830
  "height",
@@ -771,13 +832,14 @@ var qe = [
771
832
  "loop",
772
833
  "muted",
773
834
  "preload"
774
- ], tt = [
835
+ ], nt = [
836
+ "data-source-generation",
775
837
  "src",
776
838
  "width",
777
839
  "height",
778
840
  "fetchpriority",
779
841
  "loading"
780
- ], nt = ["aria-label"], rt = ["aria-label"], it = ["aria-label"], at = 40, ot = 160, st = 24, ct = /* @__PURE__ */ d({
842
+ ], rt = ["aria-label"], it = ["aria-label"], at = ["aria-label"], ot = 40, st = 160, ct = 24, lt = /* @__PURE__ */ d({
781
843
  __name: "MediaCard",
782
844
  props: {
783
845
  active: { type: Boolean },
@@ -813,116 +875,124 @@ var qe = [
813
875
  function S(e = !1, t = "pointer") {
814
876
  e && x("activate", t);
815
877
  }
816
- 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), U = 1, { effectiveMuted: W, onPlaying: G, playbackAllowed: te } = Ue({
878
+ 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.type : O.value.preview.type ?? O.value.type), L = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), R = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), { effectivePreviewState: z, failSourceAttempt: B, imageElement: ee, markSourceReady: V, noteSourceActivity: H, retrySource: U, sourceGeneration: W, videoElement: G } = qe({
879
+ identity: () => `${l.item.postId}:${D.value}:${l.mediaSource ?? "preview"}:${F.value}:${I.value ?? ""}`,
880
+ mediaIndex: () => D.value,
881
+ onError: (e) => x("error", e),
882
+ onReady: (e) => x("ready", e),
883
+ previewState: () => l.previewState
884
+ }), te = w(0), ne = w(0), re = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), K = w(!1), ie = w(1), ae = 1, { effectiveMuted: oe, onPlaying: q, playbackAllowed: se } = He({
817
885
  active: () => l.active,
818
886
  layout: () => l.layout,
819
- videoElement: R,
820
- videoIsMuted: V,
821
- videoIsPlaying: H
822
- }), K = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
823
- function ne(e) {
887
+ videoElement: G,
888
+ videoIsMuted: re,
889
+ videoIsPlaying: K
890
+ }), J = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
891
+ function Y(e) {
824
892
  return e.detail === 0 ? "keyboard" : "pointer";
825
893
  }
826
- function q(e, t) {
894
+ function X(e, t) {
827
895
  let n = C.value.length, r = (e + n) % n;
828
896
  r !== D.value && (y.value = e < D.value ? "previous" : "next", x("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
829
897
  }
830
- function re(e, t, n) {
898
+ function Z(e, t, n) {
831
899
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
832
900
  }
833
- function ie() {
901
+ function ce() {
834
902
  f = 0, p = !1, d !== null && clearTimeout(d), d = null;
835
903
  }
836
- function ae() {
837
- d !== null && clearTimeout(d), d = setTimeout(ie, ot);
904
+ function le() {
905
+ d !== null && clearTimeout(d), d = setTimeout(ce, st);
838
906
  }
839
- function oe(e) {
907
+ function ue(e) {
840
908
  if (C.value.length <= 1) return;
841
- let t = e.currentTarget?.clientWidth || 1, n = re(e.deltaX, e.deltaMode, t);
842
- if (n === 0 || (e.preventDefault(), ae(), p) || (f += n, Math.abs(f) < st)) return;
909
+ let t = e.currentTarget?.clientWidth || 1, n = Z(e.deltaX, e.deltaMode, t);
910
+ if (n === 0 || (e.preventDefault(), le(), p) || (f += n, Math.abs(f) < ct)) return;
843
911
  let r = Math.sign(f);
844
- f = 0, p = !0, q(D.value + r);
912
+ f = 0, p = !0, X(D.value + r);
845
913
  }
846
- function se(e) {
914
+ function de(e) {
847
915
  let t = e.touches[0];
848
916
  l.layout !== "reel" || !t || (m = t.clientX, g = t.clientY);
849
917
  }
850
- function ce(e) {
918
+ function fe(e) {
851
919
  let t = e.changedTouches[0];
852
920
  if (m === null || g === null || !t) return;
853
921
  let n = m - t.clientX, r = g - t.clientY;
854
- m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < at || q(D.value + Math.sign(n)));
922
+ m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < ot || X(D.value + Math.sign(n)));
855
923
  }
856
- let { imageLoading: le, mediaIsTimed: J, videoPreload: ue } = Ke({
924
+ let { imageLoading: pe, mediaIsTimed: me, videoPreload: he } = Ke({
925
+ active: () => l.active,
857
926
  fetchPriority: () => l.fetchPriority,
858
927
  layout: () => l.layout,
859
928
  mediaSource: () => F.value,
860
- videoElement: R
861
- }), Y = r(() => l.layout === "reel" && l.stationaryReelControls === !0), de = r(() => J.value && l.previewState === "ready" && (!Y.value || !!(l.active && l.reelControlsTarget))), fe = r(() => `${l.item.postId}:${D.value}:${F.value}`);
862
- function pe(e) {
863
- l.layout === "reel" && (e.stopPropagation(), me());
929
+ mediaType: () => I.value,
930
+ videoElement: G
931
+ }), ge = r(() => l.layout === "reel" && l.stationaryReelControls === !0), _e = r(() => me.value && z.value === "ready" && (!ge.value || !!(l.active && l.reelControlsTarget))), ve = r(() => `${l.item.postId}:${D.value}:${F.value}`);
932
+ function ye(e) {
933
+ l.layout === "reel" && (e.stopPropagation(), be());
864
934
  }
865
- async function me() {
866
- if (!(!R.value || !te.value)) {
867
- if (H.value) {
868
- R.value.pause();
935
+ async function be() {
936
+ if (!(!G.value || !se.value)) {
937
+ if (K.value) {
938
+ G.value.pause();
869
939
  return;
870
940
  }
871
941
  try {
872
- await R.value.play();
942
+ await G.value.play();
873
943
  } catch {
874
- H.value = !1;
944
+ K.value = !1;
875
945
  }
876
946
  }
877
947
  }
878
- function he(e) {
948
+ function xe(e) {
879
949
  return Number.isFinite(e) ? Math.max(0, e) : 0;
880
950
  }
881
- function X(e) {
882
- let t = e?.currentTarget ?? R.value;
883
- t && (z.value = he(t.currentTime), B.value = he(t.duration), te.value && (V.value = t.muted), ee.value = t.volume, t.volume > 0 && (U = t.volume));
951
+ function Se(e) {
952
+ let t = e?.currentTarget ?? G.value;
953
+ t && (te.value = xe(t.currentTime), ne.value = xe(t.duration), se.value && (re.value = t.muted), ie.value = t.volume, t.volume > 0 && (ae = t.volume));
884
954
  }
885
- function ge(e) {
886
- X(e), x("ready", D.value);
955
+ function Ce(e) {
956
+ Se(e), V(e);
887
957
  }
888
- function _e() {
889
- H.value = !1, x("ended", D.value);
958
+ function Ee() {
959
+ K.value = !1, x("ended", D.value);
890
960
  }
891
- function ve(e) {
892
- let t = R.value;
893
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(he(t.duration), Math.max(0, e)), z.value = t.currentTime);
961
+ function De(e) {
962
+ let t = G.value;
963
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(xe(t.duration), Math.max(0, e)), te.value = t.currentTime);
894
964
  }
895
- function ye(e) {
896
- let t = R.value;
965
+ function Oe(e) {
966
+ let t = G.value;
897
967
  if (!t || !Number.isFinite(e)) return;
898
968
  let n = Math.min(1, Math.max(0, e));
899
- t.volume = n, t.muted = n === 0, n > 0 && (U = n), X();
969
+ t.volume = n, t.muted = n === 0, n > 0 && (ae = n), Se();
900
970
  }
901
- function be() {
902
- let e = R.value;
903
- e && (e.muted && e.volume === 0 && (e.volume = U), e.muted = !e.muted, X());
971
+ function ke() {
972
+ let e = G.value;
973
+ e && (e.muted && e.volume === 0 && (e.volume = ae), e.muted = !e.muted, Se());
904
974
  }
905
975
  return v(() => {
906
- ie();
976
+ ce();
907
977
  }), (r, i) => (b(), s("article", {
908
978
  "data-post-id": e.item.postId,
909
979
  "data-media-index": D.value,
910
980
  class: h(["media-card", {
911
981
  "media-card--entering": e.entering,
912
982
  "media-card--leaving": e.leaving,
913
- "media-card--error": e.previewState === "error",
983
+ "media-card--error": E(z) === "error",
914
984
  "media-card--transparent-chrome": e.mediaCard?.header?.background === "transparent" || e.mediaCard?.footer?.background === "transparent" || e.cardHeader?.background === "transparent" || e.cardFooter?.background === "transparent"
915
985
  }]),
916
986
  style: _(e.itemStyle),
917
987
  "aria-hidden": e.leaving || void 0,
918
- "aria-busy": e.previewState === "loading",
988
+ "aria-busy": E(z) === "loading",
919
989
  inert: e.leaving || void 0,
920
- role: e.interactive && !e.leaving && !K.value ? "button" : void 0,
921
- tabindex: e.interactive && !e.leaving && !K.value ? 0 : void 0,
922
- onClick: i[11] ||= (t) => S(e.interactive && !K.value, ne(t)),
923
- 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"])]
924
- }, [c("div", Je, [
925
- e.cardHeader ? (b(), a(Pe, {
990
+ role: e.interactive && !e.leaving && !J.value ? "button" : void 0,
991
+ tabindex: e.interactive && !e.leaving && !J.value ? 0 : void 0,
992
+ onClick: i[15] ||= (t) => S(e.interactive && !J.value, Y(t)),
993
+ onKeydown: [i[16] ||= A((t) => S(e.interactive && !J.value, "keyboard"), ["enter"]), i[17] ||= A(j((t) => S(e.interactive && !J.value, "keyboard"), ["prevent"]), ["space"])]
994
+ }, [c("div", Ye, [
995
+ e.cardHeader ? (b(), a(Ne, {
926
996
  key: 0,
927
997
  index: e.index,
928
998
  item: e.item,
@@ -948,81 +1018,96 @@ var qe = [
948
1018
  c("div", {
949
1019
  class: h(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && C.value.length > 1 }]),
950
1020
  "data-media-direction": y.value,
951
- onWheel: oe,
952
- onTouchstartPassive: se,
953
- onTouchendPassive: ce
1021
+ onWheel: ue,
1022
+ onTouchstartPassive: de,
1023
+ onTouchendPassive: fe
954
1024
  }, [
955
1025
  u(n, { name: `media-slide-${y.value}` }, {
956
1026
  default: k(() => [(b(), s("div", {
957
- key: `${e.item.postId}:${O.value.src}:${e.mediaSource ?? "preview"}`,
1027
+ key: `${e.item.postId}:${O.value.src}:${e.mediaSource ?? "preview"}:${E(W)}`,
958
1028
  class: "media-card-frame",
959
1029
  "data-media-index": D.value
960
- }, [e.previewState === "loading" ? (b(), s("div", Ze, [...i[14] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (b(), s("div", {
1030
+ }, [E(z) === "loading" ? (b(), s("div", Qe, [...i[18] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : E(z) === "error" ? (b(), s("div", {
961
1031
  key: 1,
962
1032
  "data-test": "media-error",
963
1033
  class: "media-error",
964
1034
  role: "img",
965
- "aria-label": `${E(Me)(F.value)} ${E(Ne)(F.value)}`
966
- }, [c("strong", $e, T(E(Me)(F.value)), 1), c("span", null, T(E(Ne)(F.value)), 1)], 8, Qe)) : o("", !0), E(J) ? (b(), s("video", {
1035
+ "aria-label": `${E(je)(F.value)} ${E(Me)(F.value)}`
1036
+ }, [
1037
+ c("strong", et, T(E(je)(F.value)), 1),
1038
+ c("span", null, T(E(Me)(F.value)), 1),
1039
+ c("button", {
1040
+ type: "button",
1041
+ "data-test": "media-retry",
1042
+ onClick: i[0] ||= j((...e) => E(U) && E(U)(...e), ["stop"])
1043
+ }, "Retry")
1044
+ ], 8, $e)) : o("", !0), E(me) ? (b(), s("video", {
967
1045
  key: 2,
968
1046
  ref_key: "videoElement",
969
- ref: R,
1047
+ ref: G,
1048
+ "data-source-generation": E(W),
970
1049
  class: h(["media-preview", {
971
- "media-preview--ready": e.previewState === "ready",
1050
+ "media-preview--ready": E(z) === "ready",
972
1051
  "media-preview--reel-video": e.layout === "reel"
973
1052
  }]),
974
1053
  src: F.value,
975
- width: I.value ?? void 0,
976
- height: L.value ?? void 0,
977
- autoplay: E(te),
1054
+ width: L.value ?? void 0,
1055
+ height: R.value ?? void 0,
1056
+ autoplay: E(se),
978
1057
  loop: !e.advanceOnMediaEnd,
979
- muted: E(W),
1058
+ muted: E(oe),
980
1059
  playsinline: "",
981
- preload: E(ue),
982
- onLoadedmetadata: ge,
983
- onDurationchange: X,
984
- onTimeupdate: X,
985
- onVolumechange: X,
986
- onPlaying: i[0] ||= (...e) => E(G) && E(G)(...e),
987
- onPause: i[1] ||= (e) => H.value = !1,
988
- onEnded: _e,
989
- onClick: pe,
990
- onError: i[2] ||= (e) => r.$emit("error", D.value)
991
- }, null, 42, et)) : (b(), s("img", {
1060
+ preload: E(he),
1061
+ onLoadedmetadata: Ce,
1062
+ onProgress: i[1] ||= (...e) => E(H) && E(H)(...e),
1063
+ onLoadeddata: i[2] ||= (...e) => E(H) && E(H)(...e),
1064
+ onCanplay: i[3] ||= (...e) => E(H) && E(H)(...e),
1065
+ onDurationchange: Se,
1066
+ onTimeupdate: Se,
1067
+ onVolumechange: Se,
1068
+ onPlaying: i[4] ||= (...e) => E(q) && E(q)(...e),
1069
+ onPause: i[5] ||= (e) => K.value = !1,
1070
+ onEnded: Ee,
1071
+ onClick: ye,
1072
+ onError: i[6] ||= (...e) => E(B) && E(B)(...e)
1073
+ }, null, 42, tt)) : (b(), s("img", {
992
1074
  key: 3,
993
- class: h(["media-preview", { "media-preview--ready": e.previewState === "ready" }]),
1075
+ ref_key: "imageElement",
1076
+ ref: ee,
1077
+ "data-source-generation": E(W),
1078
+ class: h(["media-preview", { "media-preview--ready": E(z) === "ready" }]),
994
1079
  src: F.value,
995
- width: I.value ?? void 0,
996
- height: L.value ?? void 0,
1080
+ width: L.value ?? void 0,
1081
+ height: R.value ?? void 0,
997
1082
  fetchpriority: e.fetchPriority,
998
1083
  alt: "",
999
1084
  decoding: "async",
1000
- loading: E(le),
1001
- onLoad: i[3] ||= (e) => r.$emit("ready", D.value),
1002
- onError: i[4] ||= (e) => r.$emit("error", D.value)
1003
- }, null, 42, tt))], 8, Xe))]),
1085
+ loading: E(pe),
1086
+ onLoad: i[7] ||= (...e) => E(V) && E(V)(...e),
1087
+ onError: i[8] ||= (...e) => E(B) && E(B)(...e)
1088
+ }, null, 42, nt))], 8, Ze))]),
1004
1089
  _: 1
1005
1090
  }, 8, ["name"]),
1006
1091
  (b(), a(t, {
1007
- disabled: !Y.value || !e.reelControlsTarget,
1092
+ disabled: !ge.value || !e.reelControlsTarget,
1008
1093
  to: e.reelControlsTarget ?? "body"
1009
1094
  }, [u(n, {
1010
1095
  name: "vibe-reel-media-controls",
1011
- css: Y.value
1096
+ css: ge.value
1012
1097
  }, {
1013
- default: k(() => [de.value ? (b(), a(He, {
1014
- key: fe.value,
1015
- "current-time": z.value,
1016
- "data-control-post-id": Y.value ? e.item.postId : void 0,
1017
- duration: B.value,
1098
+ default: k(() => [_e.value ? (b(), a(Ve, {
1099
+ key: ve.value,
1100
+ "current-time": te.value,
1101
+ "data-control-post-id": ge.value ? e.item.postId : void 0,
1102
+ duration: ne.value,
1018
1103
  layout: e.layout,
1019
- muted: V.value,
1020
- playing: H.value,
1021
- volume: ee.value,
1022
- onSeek: ve,
1023
- onToggleMute: be,
1024
- onTogglePlayback: me,
1025
- onVolumeChange: ye
1104
+ muted: re.value,
1105
+ playing: K.value,
1106
+ volume: ie.value,
1107
+ onSeek: De,
1108
+ onToggleMute: ke,
1109
+ onTogglePlayback: be,
1110
+ onVolumeChange: Oe
1026
1111
  }, null, 8, [
1027
1112
  "current-time",
1028
1113
  "data-control-post-id",
@@ -1042,25 +1127,25 @@ var qe = [
1042
1127
  type: "button",
1043
1128
  class: "media-carousel-control media-carousel-control--previous",
1044
1129
  "aria-label": `Previous media for post ${e.item.postId}`,
1045
- onClick: i[5] ||= j((e) => q(D.value - 1, e), ["stop"]),
1046
- onKeydown: i[6] ||= j(() => {}, ["stop"])
1047
- }, [u(E(Te), { size: 20 })], 40, nt), c("button", {
1130
+ onClick: i[9] ||= j((e) => X(D.value - 1, e), ["stop"]),
1131
+ onKeydown: i[10] ||= j(() => {}, ["stop"])
1132
+ }, [u(E(we), { size: 20 })], 40, rt), c("button", {
1048
1133
  type: "button",
1049
1134
  class: "media-carousel-control media-carousel-control--next",
1050
1135
  "aria-label": `Next media for post ${e.item.postId}`,
1051
- onClick: i[7] ||= j((e) => q(D.value + 1, e), ["stop"]),
1052
- onKeydown: i[8] ||= j(() => {}, ["stop"])
1053
- }, [u(E(Ee), { size: 20 })], 40, rt)], 2)) : o("", !0),
1054
- K.value ? (b(), s("button", {
1136
+ onClick: i[11] ||= j((e) => X(D.value + 1, e), ["stop"]),
1137
+ onKeydown: i[12] ||= j(() => {}, ["stop"])
1138
+ }, [u(E(Te), { size: 20 })], 40, it)], 2)) : o("", !0),
1139
+ J.value ? (b(), s("button", {
1055
1140
  key: 1,
1056
1141
  class: "media-card-activator",
1057
1142
  type: "button",
1058
1143
  "aria-label": `Open post ${e.item.postId}`,
1059
- onClick: i[9] ||= j((e) => r.$emit("activate", ne(e)), ["stop"]),
1060
- onKeydown: i[10] ||= j(() => {}, ["stop"])
1061
- }, null, 40, it)) : o("", !0)
1062
- ], 42, Ye),
1063
- e.cardFooter ? (b(), a(Pe, {
1144
+ onClick: i[13] ||= j((e) => r.$emit("activate", Y(e)), ["stop"]),
1145
+ onKeydown: i[14] ||= j(() => {}, ["stop"])
1146
+ }, null, 40, at)) : o("", !0)
1147
+ ], 42, Xe),
1148
+ e.cardFooter ? (b(), a(Ne, {
1064
1149
  key: 1,
1065
1150
  index: e.index,
1066
1151
  item: e.item,
@@ -1083,12 +1168,12 @@ var qe = [
1083
1168
  "style",
1084
1169
  "total"
1085
1170
  ])) : o("", !0)
1086
- ])], 46, qe));
1171
+ ])], 46, Je));
1087
1172
  }
1088
- }), lt = { class: "masonry-feed-shell" }, ut = ["aria-hidden", "inert"], dt = {
1173
+ }), ut = { class: "masonry-feed-shell" }, dt = ["aria-hidden", "inert"], ft = {
1089
1174
  key: 0,
1090
1175
  class: "masonry-feed-status-overlay"
1091
- }, ft = 6, pt = 12, mt = /* @__PURE__ */ d({
1176
+ }, pt = 6, mt = 12, ht = 250, gt = /* @__PURE__ */ d({
1092
1177
  __name: "MasonryFeed",
1093
1178
  props: {
1094
1179
  enteringPostIds: {},
@@ -1124,79 +1209,79 @@ var qe = [
1124
1209
  "visible"
1125
1210
  ],
1126
1211
  setup(t, { expose: n, emit: i }) {
1127
- let l = t, d = i, f = w(null), p = `vibe-masonry-${D()}`, m = w(null), g = w(0), y = w(ft), x = w(0), C = w(0), T = w(0), k = w([]), A = w([]), j = 0, M = null, N = null, P = null, I = null, L = r(() => ie(l.items, g.value, {
1128
- additionalHeight: (l.cardHeader?.height ?? 0) + (l.cardFooter?.height ?? 0),
1129
- gap: y.value,
1130
- minColumnWidth: ce(l.masonry)
1131
- })), R = r(() => {
1132
- if (l.leavingPostIds.size === 0) return null;
1133
- let e = l.items.flatMap((e, t) => l.leavingPostIds.has(e.postId) ? [] : [{
1212
+ let l = 0, d = t, f = i, p = w(null), m = `vibe-masonry-${D()}`, g = w(null), y = w(0), x = w(pt), C = w(0), T = w(0), k = w(0), A = w([]), j = w([]), M = 0, N = null, P = null, I = null, L = null, R = r(() => ae(d.items, y.value, {
1213
+ additionalHeight: (d.cardHeader?.height ?? 0) + (d.cardFooter?.height ?? 0),
1214
+ gap: x.value,
1215
+ minColumnWidth: J(d.masonry)
1216
+ })), z = r(() => {
1217
+ if (d.leavingPostIds.size === 0) return null;
1218
+ let e = d.items.flatMap((e, t) => d.leavingPostIds.has(e.postId) ? [] : [{
1134
1219
  index: t,
1135
1220
  item: e
1136
- }]), t = ie(e.map(({ item: e }) => e), g.value, {
1137
- additionalHeight: (l.cardHeader?.height ?? 0) + (l.cardFooter?.height ?? 0),
1138
- gap: y.value,
1139
- minColumnWidth: ce(l.masonry)
1221
+ }]), t = ae(e.map(({ item: e }) => e), y.value, {
1222
+ additionalHeight: (d.cardHeader?.height ?? 0) + (d.cardFooter?.height ?? 0),
1223
+ gap: x.value,
1224
+ minColumnWidth: J(d.masonry)
1140
1225
  });
1141
1226
  return {
1142
1227
  indices: e.map(({ index: e }) => e),
1143
1228
  layout: t,
1144
1229
  positions: new Map(e.map(({ item: e }, n) => [e.postId, t.items[n]]))
1145
1230
  };
1146
- }), z = r(() => {
1147
- let e = L.value, t = R.value;
1231
+ }), B = r(() => {
1232
+ let e = R.value, t = z.value;
1148
1233
  return t ? {
1149
1234
  ...t.layout,
1150
- items: l.items.map((n, r) => l.leavingPostIds.has(n.postId) ? e.items[r] : t.positions.get(n.postId) ?? e.items[r])
1235
+ items: d.items.map((n, r) => d.leavingPostIds.has(n.postId) ? e.items[r] : t.positions.get(n.postId) ?? e.items[r])
1151
1236
  } : e;
1152
- }), B = r(() => ae(L.value.items)), V = r(() => {
1153
- let e = R.value;
1154
- return e ? ae(e.layout.items, e.indices) : null;
1155
- }), H = r(() => Math.max(C.value, l.leavingPostIds.size === 0 ? z.value.height : L.value.height)), ee = r(() => ({ height: `${H.value}px` })), W = r(() => !l.infiniteScroll || x.value > 0 && T.value + z.value.height <= x.value + 1), G = r(() => new Set(k.value)), te = r(() => A.value.flatMap((e) => {
1156
- let t = l.items[e];
1237
+ }), ee = r(() => oe(R.value.items)), V = r(() => {
1238
+ let e = z.value;
1239
+ return e ? oe(e.layout.items, e.indices) : null;
1240
+ }), H = r(() => Math.max(T.value, d.leavingPostIds.size === 0 ? B.value.height : R.value.height)), W = r(() => ({ height: `${H.value}px` })), G = r(() => !d.infiniteScroll || C.value > 0 && k.value + B.value.height <= C.value + 1), te = r(() => new Set(A.value)), re = r(() => j.value.flatMap((e) => {
1241
+ let t = d.items[e];
1157
1242
  return t ? [{
1158
- fetchPriority: G.value.has(e) ? "high" : "low",
1243
+ fetchPriority: te.value.has(e) ? "high" : "low",
1159
1244
  index: e,
1160
1245
  item: t
1161
1246
  }] : [];
1162
1247
  }));
1163
- function ne(e, t) {
1248
+ function K(e, t) {
1164
1249
  return [...new Set([...e, ...t])].sort((e, t) => e - t);
1165
1250
  }
1166
1251
  function q(e, t) {
1167
1252
  return e.length === t.length && e.every((e, n) => e === t[n]);
1168
1253
  }
1169
- function oe(e) {
1254
+ function X(e) {
1170
1255
  let t = {
1171
- scrollTop: j - T.value,
1172
- viewportHeight: x.value
1173
- }, n = V.value, r = se(n ?? B.value, {
1256
+ scrollTop: M - k.value,
1257
+ viewportHeight: C.value
1258
+ }, n = V.value, r = se(n ?? ee.value, {
1174
1259
  ...t,
1175
1260
  overscan: e
1176
1261
  }).indices;
1177
- return ne(r, l.leavingPostIds.size === 0 ? [] : se(B.value, {
1262
+ return K(r, d.leavingPostIds.size === 0 ? [] : se(ee.value, {
1178
1263
  ...t,
1179
1264
  overscan: e
1180
1265
  }).indices);
1181
1266
  }
1182
- function J() {
1183
- let e = l.suspended ? [] : oe(0), t = oe(le(l.masonry, x.value));
1184
- q(k.value, e) || (k.value = e), q(A.value, t) || (A.value = t);
1267
+ function Z() {
1268
+ let e = d.suspended ? [] : X(0), t = X(Y(d.masonry, C.value));
1269
+ q(A.value, e) || (A.value = e), q(j.value, t) || (j.value = t);
1185
1270
  }
1186
- function ue() {
1187
- if (I !== null) return;
1188
- I = -1;
1271
+ function ce() {
1272
+ if (L !== null) return;
1273
+ L = -1;
1189
1274
  let e = requestAnimationFrame(() => {
1190
- I = null, J();
1275
+ L = null, Z();
1191
1276
  });
1192
- I !== null && (I = e);
1277
+ L !== null && (L = e);
1193
1278
  }
1194
- let Y = /* @__PURE__ */ new Set();
1195
- O(() => [...G.value].flatMap((e) => {
1196
- let t = l.items[e];
1279
+ let le = /* @__PURE__ */ new Set();
1280
+ O(() => [...te.value].flatMap((e) => {
1281
+ let t = d.items[e];
1197
1282
  if (!t) return [];
1198
- let n = l.mediaIndices.get(t.postId) ?? 0, r = F(t.postId, n);
1199
- return l.previewStates.get(r) === "ready" ? [{
1283
+ let n = d.mediaIndices.get(t.postId) ?? 0, r = F(t.postId, n);
1284
+ return d.previewStates.get(r) === "ready" ? [{
1200
1285
  key: r,
1201
1286
  mediaIndex: n,
1202
1287
  postId: t.postId
@@ -1204,19 +1289,19 @@ var qe = [
1204
1289
  }), (e) => {
1205
1290
  let t = new Set(e.map(({ key: e }) => e));
1206
1291
  e.forEach(({ key: e, mediaIndex: t, postId: n }) => {
1207
- Y.has(e) || d("visible", n, t);
1208
- }), Y = t;
1292
+ le.has(e) || f("visible", n, t);
1293
+ }), le = t;
1209
1294
  }, {
1210
1295
  immediate: !0,
1211
1296
  flush: "post"
1212
1297
  });
1213
- function de(e) {
1214
- let t = z.value.items[e], n = l.items[e]?.postId;
1298
+ function ue(e) {
1299
+ let t = B.value.items[e], n = d.items[e]?.postId;
1215
1300
  if (!t) return {};
1216
- let r = n !== void 0 && l.enteringPostIds.has(n), i = n !== void 0 && l.leavingPostIds.has(n), a = r || i ? re({
1217
- containerHeight: Math.max(C.value, L.value.height),
1218
- gap: y.value
1219
- }) : 0, o = n === void 0 ? 0 : i ? l.removalDelays.get(n) ?? 0 : r ? l.entryDelays.get(n) ?? 0 : 0;
1301
+ let r = n !== void 0 && d.enteringPostIds.has(n), i = n !== void 0 && d.leavingPostIds.has(n), a = r || i ? ie({
1302
+ containerHeight: Math.max(T.value, R.value.height),
1303
+ gap: x.value
1304
+ }) : 0, o = n === void 0 ? 0 : i ? d.removalDelays.get(n) ?? 0 : r ? d.entryDelays.get(n) ?? 0 : 0;
1220
1305
  return {
1221
1306
  "--masonry-entry-delay": `${o}ms`,
1222
1307
  width: `${t.width}px`,
@@ -1224,66 +1309,69 @@ var qe = [
1224
1309
  transform: `translate3d(${t.x}px, ${t.y + a}px, 0)`
1225
1310
  };
1226
1311
  }
1227
- function fe() {
1228
- let e = f.value;
1312
+ function de() {
1313
+ let e = p.value;
1229
1314
  if (!e) return;
1230
- j = e.scrollTop, x.value = e.clientHeight;
1315
+ M = e.scrollTop, C.value = e.clientHeight;
1231
1316
  let t = e.ownerDocument.defaultView?.getComputedStyle(e), n = (Number.parseFloat(t?.paddingTop ?? "") || 0) + (Number.parseFloat(t?.paddingBottom ?? "") || 0);
1232
- C.value = Math.max(0, e.clientHeight - n);
1233
- let r = m.value;
1234
- r && (T.value = r.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop, J());
1317
+ T.value = Math.max(0, e.clientHeight - n);
1318
+ let r = g.value;
1319
+ r && (k.value = r.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop, Z());
1235
1320
  }
1236
- function pe(e) {
1321
+ function fe(e) {
1237
1322
  let t = e.ownerDocument.documentElement.clientWidth;
1238
- g.value = e.clientWidth, y.value = Math.min(pt, Math.max(ft, t * .0075)), fe();
1323
+ y.value = e.clientWidth, x.value = Math.min(mt, Math.max(pt, t * .0075)), de();
1239
1324
  }
1240
- function me(e) {
1325
+ function pe(e) {
1241
1326
  let t = e.currentTarget;
1242
- t && (j = t.scrollTop, ue(), !l.loadMoreLocked && l.infiniteScroll && K(t) && d("loadMore"));
1327
+ t && (M = t.scrollTop, ce(), Date.now() >= l && !d.loadMoreLocked && d.infiniteScroll && ne(t) && f("loadMore"));
1243
1328
  }
1244
1329
  function he() {
1245
- let e = f.value;
1246
- !l.loadMoreLocked && e && K(e) && d("loadMore");
1330
+ let e = p.value;
1331
+ Date.now() >= l && !d.loadMoreLocked && e && ne(e) && f("loadMore");
1247
1332
  }
1333
+ O(() => d.items.length, (e, t) => {
1334
+ e > 0 && e < t && (l = Date.now() + ht);
1335
+ });
1248
1336
  function ge() {
1249
- return f.value;
1337
+ return p.value;
1250
1338
  }
1251
- return O(m, (e) => {
1252
- M?.disconnect(), M = null, P !== null && cancelAnimationFrame(P), e && (pe(e), !(typeof ResizeObserver > "u") && (M = new ResizeObserver(([t]) => {
1339
+ return O(g, (e) => {
1340
+ N?.disconnect(), N = null, I !== null && cancelAnimationFrame(I), e && (fe(e), !(typeof ResizeObserver > "u") && (N = new ResizeObserver(([t]) => {
1253
1341
  let n = t?.contentRect.width ?? e.clientWidth;
1254
- Math.abs(n - g.value) < .5 || (P = requestAnimationFrame(() => {
1255
- P = null, pe(e);
1342
+ Math.abs(n - y.value) < .5 || (I = requestAnimationFrame(() => {
1343
+ I = null, fe(e);
1256
1344
  }));
1257
- }), M.observe(e)));
1258
- }), O(f, (e) => {
1259
- N?.disconnect(), N = null, e && (fe(), !(typeof ResizeObserver > "u") && (N = new ResizeObserver(fe), N.observe(e)));
1345
+ }), N.observe(e)));
1346
+ }), O(p, (e) => {
1347
+ P?.disconnect(), P = null, e && (de(), !(typeof ResizeObserver > "u") && (P = new ResizeObserver(de), P.observe(e)));
1260
1348
  }), O([
1261
- L,
1262
- z,
1263
- () => l.suspended,
1264
- () => l.masonry
1265
- ], J, { flush: "post" }), v(() => {
1266
- M?.disconnect(), N?.disconnect(), P !== null && cancelAnimationFrame(P), I !== null && cancelAnimationFrame(I);
1349
+ R,
1350
+ B,
1351
+ () => d.suspended,
1352
+ () => d.masonry
1353
+ ], Z, { flush: "post" }), v(() => {
1354
+ N?.disconnect(), P?.disconnect(), I !== null && cancelAnimationFrame(I), L !== null && cancelAnimationFrame(L);
1267
1355
  }), n({
1268
1356
  getScrollElement: ge,
1269
1357
  loadIfNearBottom: he
1270
- }), (n, r) => (b(), s("div", lt, [
1358
+ }), (n, r) => (b(), s("div", ut, [
1271
1359
  c("main", {
1272
- id: p,
1360
+ id: m,
1273
1361
  ref_key: "galleryElement",
1274
- ref: f,
1362
+ ref: p,
1275
1363
  class: h(["gallery-shell masonry-feed", { "masonry-feed--suspended": t.suspended }]),
1276
1364
  "data-layout-mode": "masonry",
1277
1365
  "aria-hidden": t.suspended || void 0,
1278
1366
  inert: t.suspended || void 0,
1279
- onScrollPassive: me
1367
+ onScrollPassive: pe
1280
1368
  }, [c("section", {
1281
1369
  ref_key: "masonryElement",
1282
- ref: m,
1283
- class: h(["masonry", { "masonry--ready": g.value > 0 }]),
1284
- style: _(ee.value),
1370
+ ref: g,
1371
+ class: h(["masonry", { "masonry--ready": y.value > 0 }]),
1372
+ style: _(W.value),
1285
1373
  "aria-label": "Media gallery"
1286
- }, [(b(!0), s(e, null, S(te.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(ct, {
1374
+ }, [(b(!0), s(e, null, S(re.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(lt, {
1287
1375
  key: n.postId,
1288
1376
  class: "masonry-item",
1289
1377
  entering: t.enteringPostIds.has(n.postId),
@@ -1294,17 +1382,17 @@ var qe = [
1294
1382
  "media-card": t.mediaCard,
1295
1383
  index: r,
1296
1384
  item: n,
1297
- "item-style": de(r),
1385
+ "item-style": ue(r),
1298
1386
  interactive: "",
1299
1387
  layout: "masonry",
1300
1388
  "loaded-count": t.items.length,
1301
1389
  "media-index": t.mediaIndices.get(n.postId) ?? 0,
1302
1390
  "preview-state": t.previewStates.get(E(F)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1303
1391
  total: t.total,
1304
- onActivate: (e) => d("activate", n.postId, e),
1305
- onMediaChange: (e) => d("mediaChange", n.postId, e),
1306
- onReady: (e) => d("ready", n.postId, e),
1307
- onError: (e) => d("error", n.postId, e)
1392
+ onActivate: (e) => f("activate", n.postId, e),
1393
+ onMediaChange: (e) => f("mediaChange", n.postId, e),
1394
+ onReady: (e) => f("ready", n.postId, e),
1395
+ onError: (e) => f("error", n.postId, e)
1308
1396
  }, null, 8, [
1309
1397
  "entering",
1310
1398
  "leaving",
@@ -1323,8 +1411,8 @@ var qe = [
1323
1411
  "onMediaChange",
1324
1412
  "onReady",
1325
1413
  "onError"
1326
- ]))), 128))], 6)], 42, ut),
1327
- t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && W.value || !t.hasNext && t.canRetryEnd ? (b(), s("div", dt, [u(U, {
1414
+ ]))), 128))], 6)], 42, dt),
1415
+ t.feedFooter || t.isLoadingMore || t.nextPageError || t.hasNext && G.value || !t.hasNext && t.canRetryEnd ? (b(), s("div", ft, [u(U, {
1328
1416
  actions: t.feedFooterActions,
1329
1417
  "can-retry-end": t.canRetryEnd,
1330
1418
  "feed-footer": t.feedFooter,
@@ -1332,10 +1420,10 @@ var qe = [
1332
1420
  "has-next": t.hasNext,
1333
1421
  "is-loading": t.isLoadingMore,
1334
1422
  "load-more-locked": t.loadMoreLocked,
1335
- "show-load-more": W.value,
1423
+ "show-load-more": G.value,
1336
1424
  state: t.state,
1337
- onLoadMore: r[0] ||= (e) => d("loadMore"),
1338
- onRetryEnd: r[1] ||= (e) => d("retryEnd")
1425
+ onLoadMore: r[0] ||= (e) => f("loadMore"),
1426
+ onRetryEnd: r[1] ||= (e) => f("retryEnd")
1339
1427
  }, null, 8, [
1340
1428
  "actions",
1341
1429
  "can-retry-end",
@@ -1347,10 +1435,10 @@ var qe = [
1347
1435
  "show-load-more",
1348
1436
  "state"
1349
1437
  ])])) : o("", !0),
1350
- u(X, {
1351
- "content-size": z.value.height,
1352
- "controls-id": p,
1353
- "scroll-element": f.value,
1438
+ u(me, {
1439
+ "content-size": B.value.height,
1440
+ "controls-id": m,
1441
+ "scroll-element": p.value,
1354
1442
  suspended: t.suspended
1355
1443
  }, null, 8, [
1356
1444
  "content-size",
@@ -1359,8 +1447,8 @@ var qe = [
1359
1447
  ])
1360
1448
  ]));
1361
1449
  }
1362
- }), ht = 300;
1363
- function gt(e, t, n) {
1450
+ }), _t = 300;
1451
+ function vt(e, t, n) {
1364
1452
  let r = e.scrollTop;
1365
1453
  if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
1366
1454
  e.setAttribute("data-transitioning", "");
@@ -1368,7 +1456,7 @@ function gt(e, t, n) {
1368
1456
  return new Promise((n) => {
1369
1457
  let o = (s) => {
1370
1458
  a += 1;
1371
- let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / ht), u = 1 - (1 - l) ** 3;
1459
+ let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / _t), u = 1 - (1 - l) ** 3;
1372
1460
  if (e.scrollTop = r + (t - r) * u, l < 1) {
1373
1461
  requestAnimationFrame(o);
1374
1462
  return;
@@ -1380,7 +1468,7 @@ function gt(e, t, n) {
1380
1468
  }
1381
1469
  //#endregion
1382
1470
  //#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
1383
- var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1471
+ var yt = ["aria-label"], bt = /* @__PURE__ */ d({
1384
1472
  __name: "ReelAutoAdvanceProgress",
1385
1473
  props: {
1386
1474
  durationMs: {},
@@ -1398,9 +1486,9 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1398
1486
  class: "reel-auto-advance-progress",
1399
1487
  style: _(a.value),
1400
1488
  onAnimationend: n[0] ||= (e) => i("complete")
1401
- }, null, 36)], 8, _t));
1489
+ }, null, 36)], 8, yt));
1402
1490
  }
1403
- }), yt = { class: "reel-viewport" }, bt = ["data-active-post-id", "data-active-media-index"], xt = ["role", "data-status"], St = 2, Ct = 300, wt = /* @__PURE__ */ d({
1491
+ }), xt = { class: "reel-viewport" }, St = ["data-active-post-id", "data-active-media-index"], Ct = ["role", "data-status"], wt = 2, Tt = 300, Et = 250, Dt = /* @__PURE__ */ d({
1404
1492
  __name: "ReelFeed",
1405
1493
  props: {
1406
1494
  initialPostId: {},
@@ -1437,147 +1525,145 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1437
1525
  "retryForward"
1438
1526
  ],
1439
1527
  setup(t, { expose: n, emit: i }) {
1440
- 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(() => {
1441
- let e = Math.max(0, g.value - St), t = Math.min(l.items.length - 1, g.value + St);
1442
- return l.items.slice(e, t + 1).map((t, n) => ({
1443
- fetchPriority: e + n === g.value ? "high" : "low",
1528
+ let l = 0, u = t, d = i, f = w(null), p = w(null), g = u.initialPostId === null || u.initialPostId === void 0 ? -1 : u.items.findIndex((e) => e.postId === u.initialPostId), x = w(Math.max(0, g)), C = w(!1), D = w(!1), k = 0, A = null, j = null, N = null, I = r(() => ({ gridTemplateRows: `repeat(${u.items.length}, 100cqh)` })), L = r(() => {
1529
+ let e = Math.max(0, x.value - wt), t = Math.min(u.items.length - 1, x.value + wt);
1530
+ return u.items.slice(e, t + 1).map((t, n) => ({
1531
+ fetchPriority: e + n === x.value ? "high" : "low",
1444
1532
  index: e + n,
1445
1533
  item: t
1446
1534
  }));
1447
- }), L = r(() => l.items[g.value]?.postId), R = r(() => l.items[g.value]), z = r(() => {
1448
- let e = L.value;
1449
- return e === void 0 ? 0 : l.mediaIndices.get(e) ?? 0;
1450
- }), B = r(() => {
1451
- let e = L.value;
1452
- return e === void 0 ? "loading" : l.previewStates.get(F(e, z.value)) ?? "loading";
1453
- }), V = r(() => {
1535
+ }), R = r(() => u.items[x.value]?.postId), z = r(() => u.items[x.value]), B = r(() => {
1536
+ let e = R.value;
1537
+ return e === void 0 ? 0 : u.mediaIndices.get(e) ?? 0;
1538
+ }), ee = r(() => {
1454
1539
  let e = R.value;
1455
- if (!e) return "";
1456
- let t = P(e, z.value);
1457
- return l.mediaSource === "original" ? t.src : t.preview.src;
1458
- }), H = r(() => B.value === "ready" && Ge(V.value)), ee = r(() => [
1459
- L.value,
1460
- z.value,
1461
- l.items.length,
1462
- l.loadMoreLocked,
1463
- l.reelAutoAdvance.enabled,
1464
- l.reelAutoAdvance.includePostItems,
1465
- l.reelAutoAdvance.intervalMs
1466
- ].join(":")), W = r(() => {
1467
- let e = R.value, t = !!(e && l.reelAutoAdvance.includePostItems && z.value < M(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
1540
+ return e === void 0 ? "loading" : u.previewStates.get(F(e, B.value)) ?? "loading";
1541
+ }), V = r(() => z.value ? P(z.value, B.value) : null), H = r(() => ee.value === "ready" && !!(V.value && Ge(u.mediaSource === "original" ? V.value.type : V.value.preview.type ?? V.value.type, u.mediaSource === "original" ? V.value.src : V.value.preview.src))), W = r(() => [
1542
+ R.value,
1543
+ B.value,
1544
+ u.items.length,
1545
+ u.loadMoreLocked,
1546
+ u.reelAutoAdvance.enabled,
1547
+ u.reelAutoAdvance.includePostItems,
1548
+ u.reelAutoAdvance.intervalMs
1549
+ ].join(":")), G = r(() => {
1550
+ let e = z.value, t = !!(e && u.reelAutoAdvance.includePostItems && B.value < M(e).length - 1), n = u.reelAutoAdvance.intervalMs / 1e3;
1468
1551
  return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
1469
- }), G = r(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && R.value !== void 0 && B.value !== "loading" && !H.value), te = 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.");
1470
- function q(e) {
1552
+ }), te = r(() => u.reelAutoAdvance.enabled && u.reelForward.status === "idle" && z.value !== void 0 && ee.value !== "loading" && !H.value), re = r(() => !u.infiniteScroll || u.items.length <= 1), K = r(() => u.reelForward.status === "loading" ? "Loading the next media…" : u.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1553
+ function ie(e) {
1471
1554
  return { gridRow: `${e + 1}` };
1472
1555
  }
1473
- function re(e) {
1474
- let t = D || e.clientHeight;
1475
- return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1556
+ function ae(e) {
1557
+ let t = k || e.clientHeight;
1558
+ return t <= 0 || u.items.length === 0 ? 0 : Math.min(u.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1476
1559
  }
1477
- function ie(e) {
1560
+ function oe(e) {
1478
1561
  let t = e.currentTarget;
1479
1562
  if (!t) return;
1480
- let n = D || t.clientHeight, r = Math.max(0, l.items.length - 1) * n;
1481
- x.value = l.items.length > 0 && t.scrollTop > r + 1, C.value || (g.value = re(t)), !l.loadMoreLocked && l.infiniteScroll && K(t) && u("loadMore");
1563
+ let n = k || t.clientHeight, r = Math.max(0, u.items.length - 1) * n;
1564
+ C.value = u.items.length > 0 && t.scrollTop > r + 1, D.value || (x.value = ae(t)), Date.now() >= l && !u.loadMoreLocked && u.infiniteScroll && ne(t) && d("loadMore");
1482
1565
  }
1483
- function ae() {
1484
- let e = d.value;
1485
- e && (x.value = !1, ce(!0), D = e.clientHeight, e.scrollTop = g.value * D, A !== null && cancelAnimationFrame(A), A = requestAnimationFrame(() => {
1486
- e.scrollTop = g.value * e.clientHeight, D = e.clientHeight, A = null;
1487
- }), oe());
1566
+ function q() {
1567
+ let e = f.value;
1568
+ e && (C.value = !1, Y(!0), k = e.clientHeight, e.scrollTop = x.value * k, j !== null && cancelAnimationFrame(j), j = requestAnimationFrame(() => {
1569
+ e.scrollTop = x.value * e.clientHeight, k = e.clientHeight, j = null;
1570
+ }), se());
1488
1571
  }
1489
- function oe() {
1490
- j !== null && clearTimeout(j), j = setTimeout(() => {
1491
- j = null;
1492
- let e = d.value;
1493
- e && (D = e.clientHeight, e.scrollTop = g.value * D), ce(!1);
1572
+ function se() {
1573
+ N !== null && clearTimeout(N), N = setTimeout(() => {
1574
+ N = null;
1575
+ let e = f.value;
1576
+ e && (k = e.clientHeight, e.scrollTop = x.value * k), Y(!1);
1494
1577
  }, 120);
1495
1578
  }
1496
- function se() {
1497
- ce(!0);
1498
- let e = d.value;
1499
- e && (D = e.clientHeight, e.scrollTop = g.value * D), oe();
1579
+ function J() {
1580
+ Y(!0);
1581
+ let e = f.value;
1582
+ e && (k = e.clientHeight, e.scrollTop = x.value * k), se();
1500
1583
  }
1501
- function ce(e) {
1502
- C.value = e, d.value?.toggleAttribute("data-resizing", e);
1584
+ function Y(e) {
1585
+ D.value = e, f.value?.toggleAttribute("data-resizing", e);
1503
1586
  }
1504
- function le() {
1505
- let e = d.value;
1506
- !l.loadMoreLocked && e && K(e) && u("loadMore");
1587
+ function X() {
1588
+ let e = f.value;
1589
+ Date.now() >= l && !u.loadMoreLocked && e && ne(e) && d("loadMore");
1507
1590
  }
1508
- function J(e) {
1509
- let t = R.value;
1591
+ O(() => u.items.length, (e, t) => {
1592
+ e > 0 && e < t && (l = Date.now() + Et);
1593
+ });
1594
+ function Z(e) {
1595
+ let t = z.value;
1510
1596
  if (!t) return !1;
1511
1597
  let n = M(t).length;
1512
1598
  if (n <= 1) return !1;
1513
- let r = (z.value + e + n) % n;
1514
- return u("mediaChange", t.postId, r), !0;
1599
+ let r = (B.value + e + n) % n;
1600
+ return d("mediaChange", t.postId, r), !0;
1515
1601
  }
1516
- function ue(e) {
1517
- let t = g.value + e;
1518
- return !d.value || t < 0 || t >= l.items.length ? !1 : (pe(t), !0);
1602
+ function ce(e) {
1603
+ let t = x.value + e;
1604
+ return !f.value || t < 0 || t >= u.items.length ? !1 : (fe(t), !0);
1519
1605
  }
1520
- function Y(e, t) {
1521
- let n = l.items.findIndex((t) => t.postId === e), r = l.items[n];
1522
- return !d.value || !r || t < 0 || t > r.items.length ? !1 : ((l.mediaIndices.get(e) ?? 0) !== t && u("mediaChange", e, t), n !== g.value && pe(n), !0);
1606
+ function le(e, t) {
1607
+ let n = u.items.findIndex((t) => t.postId === e), r = u.items[n];
1608
+ return !f.value || !r || t < 0 || t > r.items.length ? !1 : ((u.mediaIndices.get(e) ?? 0) !== t && d("mediaChange", e, t), n !== x.value && fe(n), !0);
1523
1609
  }
1524
- function de() {
1610
+ function ue() {
1525
1611
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1526
1612
  }
1527
- function fe(e) {
1528
- let t = d.value;
1613
+ function de(e) {
1614
+ let t = f.value;
1529
1615
  if (!t) return Promise.resolve();
1530
- let n = e * (D || t.clientHeight);
1531
- return g.value = e, gt(t, n, de());
1616
+ let n = e * (k || t.clientHeight);
1617
+ return x.value = e, vt(t, n, ue());
1532
1618
  }
1533
- function pe(e) {
1534
- fe(e);
1619
+ function fe(e) {
1620
+ de(e);
1535
1621
  }
1536
- async function me(e) {
1537
- let t = l.items.findIndex((t) => t.postId === e);
1538
- return t < 0 || t === g.value ? !1 : (await fe(t), !0);
1622
+ async function pe(e) {
1623
+ let t = u.items.findIndex((t) => t.postId === e);
1624
+ return t < 0 || t === x.value ? !1 : (await de(t), !0);
1539
1625
  }
1540
- async function he(e) {
1541
- return J(e) ? (de() || await new Promise((e) => setTimeout(e, Ct)), !0) : !1;
1626
+ async function me(e) {
1627
+ return Z(e) ? (ue() || await new Promise((e) => setTimeout(e, Tt)), !0) : !1;
1542
1628
  }
1543
- function X() {
1544
- if (!l.reelAutoAdvance.enabled) return;
1545
- let e = R.value;
1629
+ function he() {
1630
+ if (!u.reelAutoAdvance.enabled) return;
1631
+ let e = z.value;
1546
1632
  if (!e) return;
1547
- if (l.reelAutoAdvance.includePostItems && z.value < M(e).length - 1) {
1548
- u("mediaChange", e.postId, z.value + 1);
1633
+ if (u.reelAutoAdvance.includePostItems && B.value < M(e).length - 1) {
1634
+ d("mediaChange", e.postId, B.value + 1);
1549
1635
  return;
1550
1636
  }
1551
- let t = g.value + 1, n = l.items[t];
1637
+ let t = x.value + 1, n = u.items[t];
1552
1638
  if (!n) {
1553
- l.hasNext && !l.loadMoreLocked && u("loadMore");
1639
+ u.hasNext && !u.loadMoreLocked && d("loadMore");
1554
1640
  return;
1555
1641
  }
1556
- l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), pe(t);
1642
+ u.reelAutoAdvance.includePostItems && (u.mediaIndices.get(n.postId) ?? 0) !== 0 && d("mediaChange", n.postId, 0), fe(t);
1557
1643
  }
1558
1644
  function ge(e, t) {
1559
- !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || X();
1645
+ !u.reelAutoAdvance.enabled || e !== R.value || t !== B.value || !H.value || he();
1560
1646
  }
1561
- return O(d, (e) => {
1562
- k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(ae), k.observe(e)));
1563
- }), O(() => l.items.length, async (e) => {
1564
- let t = l.initialPostId, n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1565
- g.value = n >= 0 ? n : Math.min(g.value, Math.max(0, e - 1)), await m(), ae();
1566
- }), O(L, (e) => {
1567
- e !== void 0 && u("activeChange", e);
1647
+ return O(f, (e) => {
1648
+ A?.disconnect(), A = null, e && (k = e.clientHeight, !(typeof ResizeObserver > "u") && (A = new ResizeObserver(q), A.observe(e)));
1649
+ }), O(() => u.items.length, async (e) => {
1650
+ let t = u.initialPostId, n = t == null ? -1 : u.items.findIndex(({ postId: e }) => e === t);
1651
+ x.value = n >= 0 ? n : Math.min(x.value, Math.max(0, e - 1)), await m(), q();
1652
+ }), O(R, (e) => {
1653
+ e !== void 0 && d("activeChange", e);
1568
1654
  }, { immediate: !0 }), y(() => {
1569
- window.addEventListener("resize", se), window.addEventListener("orientationchange", se), p >= 0 && m(ae);
1655
+ window.addEventListener("resize", J), window.addEventListener("orientationchange", J), g >= 0 && m(q);
1570
1656
  }), v(() => {
1571
- window.removeEventListener("resize", se), window.removeEventListener("orientationchange", se), k?.disconnect(), A !== null && cancelAnimationFrame(A), j !== null && clearTimeout(j);
1657
+ window.removeEventListener("resize", J), window.removeEventListener("orientationchange", J), A?.disconnect(), j !== null && cancelAnimationFrame(j), N !== null && clearTimeout(N);
1572
1658
  }), n({
1573
- activeIndex: g,
1574
- activePostId: L,
1575
- changeActiveMedia: J,
1576
- loadIfNearBottom: le,
1577
- moveActivePost: ue,
1578
- navigateToItem: Y,
1579
- transitionActiveMedia: he,
1580
- transitionActivePost: me
1659
+ activeIndex: x,
1660
+ activePostId: R,
1661
+ changeActiveMedia: Z,
1662
+ loadIfNearBottom: X,
1663
+ moveActivePost: ce,
1664
+ navigateToItem: le,
1665
+ transitionActiveMedia: me,
1666
+ transitionActivePost: pe
1581
1667
  }), (n, r) => (b(), s("main", {
1582
1668
  class: h(["reel-shell", {
1583
1669
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1585,13 +1671,13 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1585
1671
  }]),
1586
1672
  "data-layout-mode": "reel"
1587
1673
  }, [
1588
- t.cardHeader && R.value && t.reelForward.status === "idle" ? (b(), a(Pe, {
1674
+ t.cardHeader && z.value && t.reelForward.status === "idle" ? (b(), a(Ne, {
1589
1675
  key: 0,
1590
- index: g.value,
1591
- item: R.value,
1676
+ index: x.value,
1677
+ item: z.value,
1592
1678
  layout: "reel",
1593
1679
  "loaded-count": t.items.length,
1594
- "media-index": z.value,
1680
+ "media-index": B.value,
1595
1681
  "media-source": t.mediaSource,
1596
1682
  placement: "header",
1597
1683
  region: t.cardHeader,
@@ -1607,41 +1693,41 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1607
1693
  "style",
1608
1694
  "total"
1609
1695
  ])) : o("", !0),
1610
- c("div", yt, [c("div", {
1696
+ c("div", xt, [c("div", {
1611
1697
  ref_key: "galleryElement",
1612
- ref: d,
1698
+ ref: f,
1613
1699
  class: "gallery-shell reel-feed",
1614
- "data-active-post-id": L.value,
1615
- "data-active-media-index": z.value,
1616
- onScrollPassive: ie
1700
+ "data-active-post-id": R.value,
1701
+ "data-active-media-index": B.value,
1702
+ onScrollPassive: oe
1617
1703
  }, [t.reelForward.status === "idle" ? (b(), s("section", {
1618
1704
  key: 1,
1619
1705
  class: "reel-track",
1620
- style: _(N.value),
1706
+ style: _(I.value),
1621
1707
  "aria-label": "Media gallery"
1622
- }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(ct, {
1708
+ }, [(b(!0), s(e, null, S(L.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(lt, {
1623
1709
  key: n.postId,
1624
- active: r === g.value && !x.value,
1625
- "advance-on-media-end": l.reelAutoAdvance.enabled && r === g.value,
1710
+ active: r === x.value && !C.value,
1711
+ "advance-on-media-end": u.reelAutoAdvance.enabled && r === x.value,
1626
1712
  class: "reel-item",
1627
1713
  entering: !1,
1628
1714
  "fetch-priority": e,
1629
1715
  index: r,
1630
1716
  item: n,
1631
- "item-style": q(r),
1717
+ "item-style": ie(r),
1632
1718
  "media-card": t.mediaCard,
1633
1719
  layout: "reel",
1634
1720
  "loaded-count": t.items.length,
1635
1721
  "media-index": t.mediaIndices.get(n.postId) ?? 0,
1636
1722
  "media-source": t.mediaSource,
1637
1723
  "preview-state": t.previewStates.get(E(F)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1638
- "reel-controls-target": f.value,
1724
+ "reel-controls-target": p.value,
1639
1725
  "stationary-reel-controls": "",
1640
1726
  total: t.total,
1641
- onMediaChange: (e) => u("mediaChange", n.postId, e),
1727
+ onMediaChange: (e) => d("mediaChange", n.postId, e),
1642
1728
  onEnded: (e) => ge(n.postId, e),
1643
- onReady: (e) => u("ready", n.postId, e),
1644
- onError: (e) => u("error", n.postId, e)
1729
+ onReady: (e) => d("ready", n.postId, e),
1730
+ onError: (e) => d("error", n.postId, e)
1645
1731
  }, null, 8, [
1646
1732
  "active",
1647
1733
  "advance-on-media-end",
@@ -1665,12 +1751,12 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1665
1751
  class: "reel-forward-status",
1666
1752
  role: t.reelForward.status === "error" ? "alert" : "status",
1667
1753
  "data-status": t.reelForward.status
1668
- }, [c("p", null, T(ne.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1754
+ }, [c("p", null, T(K.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1669
1755
  key: 0,
1670
1756
  class: "reel-forward-retry",
1671
1757
  type: "button",
1672
- onClick: r[0] ||= (e) => u("retryForward")
1673
- }, " Retry ")) : o("", !0)], 8, xt)), t.reelForward.status === "idle" ? (b(), a(U, {
1758
+ onClick: r[0] ||= (e) => d("retryForward")
1759
+ }, " Retry ")) : o("", !0)], 8, Ct)), t.reelForward.status === "idle" ? (b(), a(U, {
1674
1760
  key: 2,
1675
1761
  actions: t.feedFooterActions,
1676
1762
  "can-retry-end": t.canRetryEnd,
@@ -1679,10 +1765,10 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1679
1765
  "has-next": t.hasNext,
1680
1766
  "is-loading": t.isLoadingMore,
1681
1767
  "load-more-locked": t.loadMoreLocked,
1682
- "show-load-more": te.value,
1768
+ "show-load-more": re.value,
1683
1769
  state: t.state,
1684
- onLoadMore: r[1] ||= (e) => u("loadMore"),
1685
- onRetryEnd: r[2] ||= (e) => u("retryEnd")
1770
+ onLoadMore: r[1] ||= (e) => d("loadMore"),
1771
+ onRetryEnd: r[2] ||= (e) => d("retryEnd")
1686
1772
  }, null, 8, [
1687
1773
  "actions",
1688
1774
  "can-retry-end",
@@ -1693,19 +1779,19 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1693
1779
  "load-more-locked",
1694
1780
  "show-load-more",
1695
1781
  "state"
1696
- ])) : o("", !0)], 40, bt), c("div", {
1782
+ ])) : o("", !0)], 40, St), c("div", {
1697
1783
  ref_key: "reelControlsElement",
1698
- ref: f,
1784
+ ref: p,
1699
1785
  class: "reel-media-controls-host",
1700
1786
  "data-test": "reel-media-controls-host"
1701
1787
  }, null, 512)]),
1702
- t.cardFooter && R.value && t.reelForward.status === "idle" ? (b(), a(Pe, {
1788
+ t.cardFooter && z.value && t.reelForward.status === "idle" ? (b(), a(Ne, {
1703
1789
  key: 1,
1704
- index: g.value,
1705
- item: R.value,
1790
+ index: x.value,
1791
+ item: z.value,
1706
1792
  layout: "reel",
1707
1793
  "loaded-count": t.items.length,
1708
- "media-index": z.value,
1794
+ "media-index": B.value,
1709
1795
  "media-source": t.mediaSource,
1710
1796
  placement: "footer",
1711
1797
  region: t.cardFooter,
@@ -1721,24 +1807,24 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1721
1807
  "style",
1722
1808
  "total"
1723
1809
  ])) : o("", !0),
1724
- G.value ? (b(), a(vt, {
1725
- key: ee.value,
1810
+ te.value ? (b(), a(bt, {
1811
+ key: W.value,
1726
1812
  "duration-ms": t.reelAutoAdvance.intervalMs,
1727
- label: W.value,
1728
- onComplete: X
1813
+ label: G.value,
1814
+ onComplete: he
1729
1815
  }, null, 8, ["duration-ms", "label"])) : o("", !0)
1730
1816
  ], 2));
1731
1817
  }
1732
- }), Tt = ["data-info-sheet-open", "data-info-sheet-mode"], Et = ["aria-hidden", "inert"], Dt = {
1818
+ }), Ot = ["data-info-sheet-open", "data-info-sheet-mode"], kt = ["aria-hidden", "inert"], At = {
1733
1819
  key: 0,
1734
1820
  class: "reel-info-sheet-layer",
1735
1821
  "data-test": "reel-info-sheet"
1736
- }, Ot = [
1822
+ }, jt = [
1737
1823
  "role",
1738
1824
  "aria-modal",
1739
1825
  "tabindex",
1740
1826
  "data-active-post-id"
1741
- ], kt = /* @__PURE__ */ d({
1827
+ ], Mt = /* @__PURE__ */ d({
1742
1828
  __name: "ReelLayout",
1743
1829
  props: {
1744
1830
  forwardIndex: { default: null },
@@ -1825,13 +1911,13 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1825
1911
  function B(e) {
1826
1912
  return p.value?.transitionActivePost(e) ?? Promise.resolve(!1);
1827
1913
  }
1828
- function V(e, t) {
1914
+ function ee(e, t) {
1829
1915
  d("error", e, t);
1830
1916
  }
1831
- function H(e, t) {
1917
+ function V(e, t) {
1832
1918
  d("mediaChange", e, t);
1833
1919
  }
1834
- function ee(e, t) {
1920
+ function H(e, t) {
1835
1921
  d("ready", e, t);
1836
1922
  }
1837
1923
  return O(() => ({
@@ -1863,7 +1949,7 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1863
1949
  class: "reel-layout-main",
1864
1950
  "aria-hidden": e.infoSheetOverlay && A.value || void 0,
1865
1951
  inert: e.infoSheetOverlay && A.value || void 0
1866
- }, [u(wt, {
1952
+ }, [u(Dt, {
1867
1953
  ref_key: "reelFeed",
1868
1954
  ref: p,
1869
1955
  "can-retry-end": e.canRetryEnd,
@@ -1887,10 +1973,10 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1887
1973
  state: e.state,
1888
1974
  total: e.total,
1889
1975
  onActiveChange: r[0] ||= (e) => d("activeChange", e),
1890
- onError: V,
1976
+ onError: ee,
1891
1977
  onLoadMore: r[1] ||= (e) => d("loadMore"),
1892
- onMediaChange: H,
1893
- onReady: ee,
1978
+ onMediaChange: V,
1979
+ onReady: H,
1894
1980
  onRetryEnd: r[2] ||= (e) => d("retryEnd"),
1895
1981
  onRetryForward: r[3] ||= (e) => d("retryForward")
1896
1982
  }, null, 8, [
@@ -1914,8 +2000,8 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1914
2000
  "reel-forward",
1915
2001
  "state",
1916
2002
  "total"
1917
- ])], 8, Et), u(n, { name: "vibe-info-sheet" }, {
1918
- default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", Dt, [c("aside", {
2003
+ ])], 8, kt), u(n, { name: "vibe-info-sheet" }, {
2004
+ default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", At, [c("aside", {
1919
2005
  ref_key: "sheetElement",
1920
2006
  ref: _,
1921
2007
  class: "reel-info-sheet",
@@ -1924,14 +2010,14 @@ var _t = ["aria-label"], vt = /* @__PURE__ */ d({
1924
2010
  "aria-modal": e.infoSheetOverlay ? "true" : void 0,
1925
2011
  tabindex: e.infoSheetOverlay ? -1 : void 0,
1926
2012
  "data-active-post-id": T.value?.postId
1927
- }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, Ot)])) : o("", !0)]),
2013
+ }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, jt)])) : o("", !0)]),
1928
2014
  _: 1
1929
- })], 10, Tt));
2015
+ })], 10, Ot));
1930
2016
  }
1931
2017
  });
1932
2018
  //#endregion
1933
2019
  //#region src/core/mediaLifecycle.ts
1934
- function At(e, t, n, r, i) {
2020
+ function Nt(e, t, n, r, i) {
1935
2021
  let a = e.items.findIndex((e) => e.postId === t), o = e.items[a];
1936
2022
  if (!o) return null;
1937
2023
  let s = N(o, n), c = P(o, s);
@@ -1947,7 +2033,7 @@ function At(e, t, n, r, i) {
1947
2033
  postIndex: a
1948
2034
  };
1949
2035
  }
1950
- function jt(e, t) {
2036
+ function Pt(e, t) {
1951
2037
  O(() => {
1952
2038
  let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null;
1953
2039
  return {
@@ -1957,20 +2043,20 @@ function jt(e, t) {
1957
2043
  };
1958
2044
  }, (n, r) => {
1959
2045
  if (n.postId === null || n.postId === r?.postId && n.mediaIndex === r.mediaIndex && n.origin === r.origin) return;
1960
- let i = At(e, n.postId, n.mediaIndex, "reel", n.origin);
2046
+ let i = Nt(e, n.postId, n.mediaIndex, "reel", n.origin);
1961
2047
  i && t(i);
1962
2048
  }, { flush: "sync" });
1963
2049
  }
1964
2050
  //#endregion
1965
2051
  //#region src/components/useMediaLifecycle.ts
1966
- function Mt(e, t) {
2052
+ function Ft(e, t) {
1967
2053
  let n = w(/* @__PURE__ */ new Map()), i = w(/* @__PURE__ */ new Map()), a = r(() => e.reelMediaSource === "original" ? i.value : n.value);
1968
2054
  function o(e, t, n, r) {
1969
2055
  let i = F(t, n);
1970
2056
  e.value.get(i) !== r && (e.value = new Map(e.value).set(i, r));
1971
2057
  }
1972
2058
  function s(t, n, r, i) {
1973
- return At(e, t, n, r, i);
2059
+ return Nt(e, t, n, r, i);
1974
2060
  }
1975
2061
  function c(e, n, r, i) {
1976
2062
  let a = s(e, n, r, i);
@@ -1992,7 +2078,7 @@ function Mt(e, t) {
1992
2078
  let r = s(e, n, "masonry", null);
1993
2079
  r && t.visible(r);
1994
2080
  }
1995
- return jt(e, t.reelChange), O(() => {
2081
+ return Pt(e, t.reelChange), O(() => {
1996
2082
  let t = e.layout === "reel" || e.reelOrigin === "masonry" ? e.activeReelPostId : null, n = t === null ? 0 : e.mediaIndices.get(t) ?? 0;
1997
2083
  return {
1998
2084
  mediaIndex: n,
@@ -2017,16 +2103,16 @@ function Mt(e, t) {
2017
2103
  }
2018
2104
  //#endregion
2019
2105
  //#region src/core/reelEscapeStack.ts
2020
- var Nt = [];
2021
- function Pt(e) {
2022
- return Nt.push(e), () => {
2023
- let t = Nt.indexOf(e);
2024
- t >= 0 && Nt.splice(t, 1);
2106
+ var It = [];
2107
+ function Lt(e) {
2108
+ return It.push(e), () => {
2109
+ let t = It.indexOf(e);
2110
+ t >= 0 && It.splice(t, 1);
2025
2111
  };
2026
2112
  }
2027
- function Ft(e) {
2113
+ function Rt(e) {
2028
2114
  if (!e.isActive()) return !1;
2029
- let t = Nt.filter((e) => e.isActive()), n = e.element();
2115
+ let t = It.filter((e) => e.isActive()), n = e.element();
2030
2116
  return n !== null && t.some((t) => {
2031
2117
  if (t === e) return !1;
2032
2118
  let r = t.element();
@@ -2042,14 +2128,14 @@ function Ft(e) {
2042
2128
  }
2043
2129
  //#endregion
2044
2130
  //#region src/components/useReelKeyboard.ts
2045
- function It(e) {
2131
+ function zt(e) {
2046
2132
  let t = {
2047
2133
  element: e.element,
2048
2134
  isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
2049
2135
  }, n = null;
2050
2136
  function r(n) {
2051
2137
  let r = t.isActive();
2052
- if (n.key === "Escape" && r && !Ft(t)) return;
2138
+ if (n.key === "Escape" && r && !Rt(t)) return;
2053
2139
  if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
2054
2140
  n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
2055
2141
  return;
@@ -2069,14 +2155,14 @@ function It(e) {
2069
2155
  a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
2070
2156
  }
2071
2157
  y(() => {
2072
- n = Pt(t), window.addEventListener("keydown", r);
2158
+ n = Lt(t), window.addEventListener("keydown", r);
2073
2159
  }), v(() => {
2074
2160
  window.removeEventListener("keydown", r), n?.(), n = null;
2075
2161
  });
2076
2162
  }
2077
2163
  //#endregion
2078
2164
  //#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
2079
- var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2165
+ var Bt = 35, Vt = 420, Ht = /* @__PURE__ */ d({
2080
2166
  __name: "VibeSurface",
2081
2167
  props: {
2082
2168
  canRetryEnd: { type: Boolean },
@@ -2102,37 +2188,37 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2102
2188
  "retryForward"
2103
2189
  ],
2104
2190
  setup(t, { expose: i, emit: c }) {
2105
- 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()), D = w(/* @__PURE__ */ new Map()), A = r(() => Object.freeze([...l.state.items])), j = r(() => L(l.state, A.value)), { markMasonryVisible: P, markPreviewError: F, markPreviewReady: I, markReelError: R, markReelReady: z, originalStates: B, previewStates: V, reelStates: H } = Mt(l.state, {
2191
+ 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()), D = w(/* @__PURE__ */ new Map()), A = r(() => Object.freeze([...l.state.items])), j = r(() => L(l.state, A.value)), { markMasonryVisible: P, markPreviewError: F, markPreviewReady: I, markReelError: R, markReelReady: z, originalStates: B, previewStates: ee, reelStates: V } = Ft(l.state, {
2106
2192
  ready: (e) => d("mediaReady", e),
2107
2193
  reelChange: (e) => d("reelMediaChange", e),
2108
2194
  visible: (e) => d("mediaVisible", e)
2109
- }), ee = new Set(l.state.items.map((e) => e.postId)), U = null, W = null, G = !1;
2110
- function K() {
2195
+ }), H = new Set(l.state.items.map((e) => e.postId)), U = null, W = null, G = !1;
2196
+ function ne() {
2111
2197
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2112
2198
  }
2113
- function ne() {
2199
+ function re() {
2114
2200
  U !== null && cancelAnimationFrame(U), U = requestAnimationFrame(() => {
2115
2201
  U = requestAnimationFrame(() => {
2116
2202
  U = null, S.value = /* @__PURE__ */ new Set();
2117
2203
  });
2118
2204
  });
2119
2205
  }
2120
- function q(e, t) {
2206
+ function K(e, t) {
2121
2207
  let n = l.state.items.find((t) => t.postId === e);
2122
2208
  if (!n) return;
2123
2209
  let r = N(n, t);
2124
2210
  (l.state.mediaIndices.get(e) ?? 0) !== r && (l.state.mediaIndices = new Map(l.state.mediaIndices).set(e, r));
2125
2211
  }
2126
- async function re() {
2212
+ async function ie() {
2127
2213
  await m(), (l.state.layout === "reel" || l.state.reelOrigin === "masonry" ? p.value : f.value)?.loadIfNearBottom();
2128
2214
  }
2129
- function ie(e) {
2215
+ function ae(e) {
2130
2216
  return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.changeActiveMedia?.(e) ?? !1;
2131
2217
  }
2132
- function ae(e) {
2218
+ function oe(e) {
2133
2219
  return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.moveActivePost?.(e) ?? !1;
2134
2220
  }
2135
- function oe(e) {
2221
+ function q(e) {
2136
2222
  if (!(l.state.layout === "reel" || l.state.reelOrigin === "masonry") || l.state.isLoading) return "reel-inactive";
2137
2223
  let t = l.state.items.find((t) => t.postId === e.postId);
2138
2224
  if (!t) return "not-found";
@@ -2142,30 +2228,30 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2142
2228
  function se() {
2143
2229
  return l.state.layout !== "masonry" || l.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
2144
2230
  }
2145
- function ce(e, t) {
2146
- W = e, G = t === "keyboard", y.value = Y(e), d("openReel", e), m(() => h.value?.focus());
2231
+ function J(e, t) {
2232
+ W = e, G = t === "keyboard", y.value = ce(e), d("openReel", e), m(() => h.value?.focus());
2147
2233
  }
2148
- function le(e) {
2234
+ function Y(e) {
2149
2235
  let t = g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
2150
2236
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
2151
2237
  }
2152
- function J(e, t) {
2153
- if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || K()) return 0;
2154
- let n = [...new Set(e)], r = n.filter(le);
2238
+ function X(e, t) {
2239
+ if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || ne()) return 0;
2240
+ let n = [...new Set(e)], r = n.filter(Y);
2155
2241
  if (r.length === 0) return 0;
2156
- let i = new Map(D.value), a = t?.staggerMs ?? Lt;
2242
+ let i = new Map(D.value), a = t?.staggerMs ?? Bt;
2157
2243
  return r.forEach((e, t) => {
2158
2244
  i.set(e, t * a);
2159
- }), S.value = new Set([...S.value].filter((e) => !r.includes(e))), T.value = new Set([...T.value, ...n]), D.value = i, Rt + (r.length - 1) * a;
2245
+ }), S.value = new Set([...S.value].filter((e) => !r.includes(e))), T.value = new Set([...T.value, ...n]), D.value = i, Vt + (r.length - 1) * a;
2160
2246
  }
2161
- function ue(e, t) {
2162
- let n = le(e), r = n?.querySelector(".media-card-activator") ?? n;
2247
+ function Z(e, t) {
2248
+ let n = Y(e), r = n?.querySelector(".media-card-activator") ?? n;
2163
2249
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
2164
2250
  r.classList.remove("media-card-focus-silent");
2165
2251
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
2166
2252
  }
2167
- function Y(e) {
2168
- let t = g.value, n = le(e);
2253
+ function ce(e) {
2254
+ let t = g.value, n = Y(e);
2169
2255
  if (t === null || n === null) return {};
2170
2256
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
2171
2257
  return {
@@ -2175,48 +2261,48 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2175
2261
  "--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
2176
2262
  };
2177
2263
  }
2178
- function de() {
2264
+ function le() {
2179
2265
  l.state.reelOrigin === "masonry" && (W ??= l.state.activeReelPostId, x.value = !0, d("closeReel"));
2180
2266
  }
2181
- function fe() {
2267
+ function ue() {
2182
2268
  let e = W, t = G;
2183
2269
  x.value = !1, W = null, G = !1, y.value = {}, m(() => {
2184
- e !== null && ue(e, t);
2270
+ e !== null && Z(e, t);
2185
2271
  });
2186
2272
  }
2187
- return It({
2188
- closeMasonryReel: de,
2273
+ return zt({
2274
+ closeMasonryReel: le,
2189
2275
  element: () => g.value,
2190
2276
  isReelLeaving: () => x.value,
2191
2277
  reelRenderer: () => p.value,
2192
2278
  setReelInfoSheet: (e) => d("reelInfoSheetChange", e),
2193
2279
  state: l.state
2194
2280
  }), O(() => l.state.items.map((e) => e.postId), (e) => {
2195
- let t = e.filter((e) => !ee.has(e)), n = new Set(e);
2196
- if (ee = new Set(e), T.value = new Set([...T.value].filter((e) => n.has(e))), D.value = new Map([...D.value].filter(([e]) => n.has(e))), t.length === 0 || K()) return;
2281
+ let t = e.filter((e) => !H.has(e)), n = new Set(e);
2282
+ if (H = new Set(e), T.value = new Set([...T.value].filter((e) => n.has(e))), D.value = new Map([...D.value].filter(([e]) => n.has(e))), t.length === 0 || ne()) return;
2197
2283
  let r = /* @__PURE__ */ new Map();
2198
2284
  e.forEach((e) => {
2199
2285
  let t = C.value.get(e);
2200
2286
  t !== void 0 && r.set(e, t);
2201
2287
  }), t.forEach((e, t) => {
2202
- r.set(e, t * Lt);
2203
- }), C.value = r, S.value = new Set([...S.value, ...t]), ne();
2288
+ r.set(e, t * Bt);
2289
+ }), C.value = r, S.value = new Set([...S.value, ...t]), re();
2204
2290
  }, { flush: "sync" }), v(() => {
2205
2291
  U !== null && cancelAnimationFrame(U);
2206
2292
  }), i({
2207
- changeActiveReelMedia: ie,
2293
+ changeActiveReelMedia: ae,
2208
2294
  getAutoScrollElement: se,
2209
- loadIfNearBottom: re,
2210
- moveActiveReelPost: ae,
2211
- navigateToReelItem: oe,
2212
- startItemRemoval: J,
2295
+ loadIfNearBottom: ie,
2296
+ moveActiveReelPost: oe,
2297
+ navigateToReelItem: q,
2298
+ startItemRemoval: X,
2213
2299
  transitionActiveReelMedia: (e) => p.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
2214
2300
  transitionActiveReelPost: (e) => p.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
2215
2301
  }), (r, i) => (b(), s("div", {
2216
2302
  ref_key: "surfaceElement",
2217
2303
  ref: g,
2218
2304
  class: "vibe-surface"
2219
- }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(kt, {
2305
+ }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(Mt, {
2220
2306
  key: 0,
2221
2307
  ref_key: "reelRenderer",
2222
2308
  ref: p,
@@ -2241,7 +2327,7 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2241
2327
  "info-sheet-overlay": t.state.reelInfoSheetOverlay,
2242
2328
  "next-page-error": !!t.state.nextPageError,
2243
2329
  origin: "reel",
2244
- "preview-states": E(H),
2330
+ "preview-states": E(V),
2245
2331
  "reel-auto-advance": t.state.reelAutoAdvance,
2246
2332
  "reel-forward": t.state.reelForward,
2247
2333
  state: j.value,
@@ -2250,7 +2336,7 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2250
2336
  onCloseInfoSheet: i[1] ||= (e) => d("reelInfoSheetChange", !1),
2251
2337
  onError: E(R),
2252
2338
  onLoadMore: i[2] ||= (e) => d("loadMore"),
2253
- onMediaChange: q,
2339
+ onMediaChange: K,
2254
2340
  onReady: E(z),
2255
2341
  onRetryEnd: i[3] ||= (e) => d("retryEnd"),
2256
2342
  onRetryForward: i[4] ||= (e) => d("retryForward")
@@ -2267,7 +2353,7 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2267
2353
  "can-retry-end",
2268
2354
  "feed-footer",
2269
2355
  "state"
2270
- ])) : (b(), s(e, { key: 2 }, [u(mt, {
2356
+ ])) : (b(), s(e, { key: 2 }, [u(gt, {
2271
2357
  ref_key: "masonryRenderer",
2272
2358
  ref: f,
2273
2359
  "can-retry-end": t.canRetryEnd,
@@ -2288,14 +2374,14 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2288
2374
  "load-more-locked": t.state.loadMoreLocked,
2289
2375
  "media-indices": t.state.mediaIndices,
2290
2376
  "next-page-error": !!t.state.nextPageError,
2291
- "preview-states": E(V),
2377
+ "preview-states": E(ee),
2292
2378
  suspended: t.state.reelOrigin === "masonry" || x.value,
2293
2379
  state: j.value,
2294
2380
  total: t.state.total,
2295
- onActivate: ce,
2381
+ onActivate: J,
2296
2382
  onError: E(F),
2297
2383
  onLoadMore: i[7] ||= (e) => d("loadMore"),
2298
- onMediaChange: q,
2384
+ onMediaChange: K,
2299
2385
  onReady: E(I),
2300
2386
  onRetryEnd: i[8] ||= (e) => d("retryEnd"),
2301
2387
  onVisible: E(P)
@@ -2327,7 +2413,7 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2327
2413
  "onVisible"
2328
2414
  ]), u(n, {
2329
2415
  name: "vibe-reel-viewer",
2330
- onAfterLeave: fe
2416
+ onAfterLeave: ue
2331
2417
  }, {
2332
2418
  default: k(() => [t.state.reelOrigin === "masonry" ? (b(), s("section", {
2333
2419
  key: 0,
@@ -2339,7 +2425,7 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2339
2425
  "aria-modal": "true",
2340
2426
  tabindex: "-1",
2341
2427
  style: _(y.value)
2342
- }, [u(kt, {
2428
+ }, [u(Mt, {
2343
2429
  ref_key: "reelRenderer",
2344
2430
  ref: p,
2345
2431
  "can-retry-end": t.canRetryEnd,
@@ -2372,7 +2458,7 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2372
2458
  onCloseInfoSheet: i[10] ||= (e) => d("reelInfoSheetChange", !1),
2373
2459
  onError: E(R),
2374
2460
  onLoadMore: i[11] ||= (e) => d("loadMore"),
2375
- onMediaChange: q,
2461
+ onMediaChange: K,
2376
2462
  onReady: E(z),
2377
2463
  onRetryEnd: i[12] ||= (e) => d("retryEnd"),
2378
2464
  onRetryForward: i[13] ||= (e) => d("retryForward")
@@ -2383,48 +2469,83 @@ var Lt = 35, Rt = 420, zt = /* @__PURE__ */ d({
2383
2469
  });
2384
2470
  //#endregion
2385
2471
  //#region src/core/page.ts
2386
- function Bt(e) {
2472
+ function Ut(e) {
2387
2473
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
2388
2474
  if (e.current !== void 0 && e.current !== null && typeof e.current != "string" && typeof e.current != "number") throw TypeError("Vibe page current must be a string, number, null, or undefined.");
2389
2475
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
2390
2476
  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.");
2391
2477
  return e;
2392
2478
  }
2393
- function Z(e, t) {
2479
+ function Q(e, t) {
2394
2480
  let n = new Set(e.map((e) => e.postId));
2395
2481
  return [...e, ...t.filter((e) => n.has(e.postId) ? !1 : (n.add(e.postId), !0))];
2396
2482
  }
2397
- function Vt(e) {
2483
+ function Wt(e) {
2484
+ return `${typeof e}:${String(e)}`;
2485
+ }
2486
+ function Gt(e) {
2487
+ return e.mediaId === void 0 ? `source:${e.src}\u0000${e.preview.src}` : `id:${Wt(e.mediaId)}`;
2488
+ }
2489
+ function Kt(e, t) {
2490
+ let n = [...e], r = new Map(e.map((e, t) => [Wt(e.postId), t]));
2491
+ return t.forEach((e) => {
2492
+ let t = Wt(e.postId), i = r.get(t);
2493
+ if (i === void 0) {
2494
+ r.set(t, n.length), n.push(e);
2495
+ return;
2496
+ }
2497
+ let a = n[i], o = new Set([a, ...a.items].map(Gt)), s = [e, ...e.items].filter((e) => {
2498
+ let t = Gt(e);
2499
+ return o.has(t) ? !1 : (o.add(t), !0);
2500
+ });
2501
+ s.length > 0 && (n[i] = {
2502
+ ...a,
2503
+ items: [...a.items, ...s]
2504
+ });
2505
+ }), n;
2506
+ }
2507
+ function qt(e) {
2398
2508
  return Object.prototype.hasOwnProperty.call(e, "current") ? e.current ?? null : e.next;
2399
2509
  }
2400
2510
  //#endregion
2511
+ //#region src/core/appendPage.ts
2512
+ function Jt(e, t, n, r) {
2513
+ let i = Ut(e), a = n.filterItems(i.items), o = qt(i);
2514
+ t.items = Kt(t.items, a), t.next = i.next, i.total !== void 0 && (t.total = i.total), r(o), n.recordPages([{
2515
+ contributionIds: a.map(({ postId: e }) => e),
2516
+ cursor: o,
2517
+ next: i.next,
2518
+ returnedIds: a.map(({ postId: e }) => e)
2519
+ }]);
2520
+ }
2521
+ //#endregion
2401
2522
  //#region src/core/requestDelay.ts
2402
- var Ht = 2e3, Ut = 1e4, Wt = 250, Gt = {
2523
+ var Yt = 2e3, Xt = 1e4, Zt = 250, Qt = {
2403
2524
  delayRemainingMs: null,
2404
2525
  nextRequestAt: null
2405
2526
  };
2406
- function Kt(e, t) {
2527
+ function $t(e, t) {
2407
2528
  return e === void 0 ? t : Math.floor(e);
2408
2529
  }
2409
- function qt(e, t) {
2530
+ function en(e, t) {
2410
2531
  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.`);
2411
2532
  }
2412
- function Jt(e, t = {}) {
2413
- let n = Kt(t.delayStepMs, Ht), r = Kt(t.delayMaxMs, Ut);
2533
+ function tn(e, t = {}) {
2534
+ let n = $t(t.delayStepMs, Yt), r = $t(t.delayMaxMs, Xt);
2414
2535
  return Math.min(Math.max(0, e) * n, r);
2415
2536
  }
2416
- function Q(e) {
2417
- if (e == null || !Number.isFinite(e)) return { ...Gt };
2537
+ function $(e) {
2538
+ if (e == null || !Number.isFinite(e)) return { ...Qt };
2418
2539
  let t = Math.max(0, Math.floor(e - Date.now()));
2419
2540
  return t > 0 ? {
2420
2541
  delayRemainingMs: t,
2421
2542
  nextRequestAt: e
2422
- } : { ...Gt };
2543
+ } : { ...Qt };
2423
2544
  }
2424
- async function Yt({ delayMs: e, onChange: t, signal: n }) {
2545
+ async function nn({ delayMs: e, onChange: t, signal: n }) {
2425
2546
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2426
2547
  if (e <= 0) {
2427
- t({ ...Gt });
2548
+ t({ ...Qt });
2428
2549
  return;
2429
2550
  }
2430
2551
  let r = Date.now() + e;
@@ -2432,9 +2553,9 @@ async function Yt({ delayMs: e, onChange: t, signal: n }) {
2432
2553
  delayRemainingMs: e,
2433
2554
  nextRequestAt: r
2434
2555
  }), await new Promise((i, a) => {
2435
- let o = !1, s = setInterval(f, Wt), c = setTimeout(() => u(), e);
2556
+ let o = !1, s = setInterval(f, Zt), c = setTimeout(() => u(), e);
2436
2557
  function l() {
2437
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Gt });
2558
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Qt });
2438
2559
  }
2439
2560
  function u(e) {
2440
2561
  o || (o = !0, l(), e ? a(e) : i());
@@ -2443,42 +2564,42 @@ async function Yt({ delayMs: e, onChange: t, signal: n }) {
2443
2564
  u(new DOMException("Aborted", "AbortError"));
2444
2565
  }
2445
2566
  function f() {
2446
- let e = Q(r);
2567
+ let e = $(r);
2447
2568
  t(e), e.delayRemainingMs === null && u();
2448
2569
  }
2449
2570
  n.addEventListener("abort", d, { once: !0 });
2450
2571
  });
2451
2572
  }
2452
- var Xt = class {
2573
+ var rn = class {
2453
2574
  interval = null;
2454
2575
  constructor(e) {
2455
2576
  this.onChange = e;
2456
2577
  }
2457
2578
  clear() {
2458
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Gt });
2579
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Qt });
2459
2580
  }
2460
2581
  sync(e) {
2461
2582
  this.clear();
2462
- let t = Q(e);
2583
+ let t = $(e);
2463
2584
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2464
- let t = Q(e);
2585
+ let t = $(e);
2465
2586
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2466
- }, Wt));
2587
+ }, Zt));
2467
2588
  }
2468
2589
  };
2469
- function Zt(e, t = !0) {
2590
+ function an(e, t = !0) {
2470
2591
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2471
2592
  }
2472
- function Qt(e) {
2593
+ function on(e) {
2473
2594
  return `${typeof e}:${String(e)}`;
2474
2595
  }
2475
- function $t(e, t) {
2596
+ function sn(e, t) {
2476
2597
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2477
2598
  }
2478
- function en(e) {
2599
+ function cn(e) {
2479
2600
  if (!e) return;
2480
- if ($t(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2481
- qt(e, "frontend autofill");
2601
+ if (sn(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2602
+ en(e, "frontend autofill");
2482
2603
  let t = e.maxAdditionalPages;
2483
2604
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2484
2605
  return;
@@ -2490,7 +2611,7 @@ function en(e) {
2490
2611
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2491
2612
  }
2492
2613
  }
2493
- function tn(e, t, n = !0) {
2614
+ function ln(e, t, n = !0) {
2494
2615
  if (!e) return {
2495
2616
  cycleId: null,
2496
2617
  delayRemainingMs: null,
@@ -2507,7 +2628,7 @@ function tn(e, t, n = !0) {
2507
2628
  status: "idle",
2508
2629
  strategy: null
2509
2630
  };
2510
- let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = Q(r?.nextRequestAt);
2631
+ let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = $(r?.nextRequestAt);
2511
2632
  return {
2512
2633
  cycleId: r?.cycleId ?? null,
2513
2634
  ...a,
@@ -2524,7 +2645,7 @@ function tn(e, t, n = !0) {
2524
2645
  strategy: e.strategy
2525
2646
  };
2526
2647
  }
2527
- function nn(e) {
2648
+ function un(e) {
2528
2649
  return [
2529
2650
  "cancelling",
2530
2651
  "filling",
@@ -2532,9 +2653,9 @@ function nn(e) {
2532
2653
  "waiting"
2533
2654
  ].includes(e.status);
2534
2655
  }
2535
- async function rn(e, t, n) {
2656
+ async function dn(e, t, n) {
2536
2657
  let r = t.autofill;
2537
- if (!nn(r) || !r.cycleId) return;
2658
+ if (!un(r) || !r.cycleId) return;
2538
2659
  let i = {
2539
2660
  cycleId: r.cycleId,
2540
2661
  feedKey: r.feedKey ?? "",
@@ -2547,16 +2668,16 @@ async function rn(e, t, n) {
2547
2668
  throw r.error = e, r.status = "error", e;
2548
2669
  }
2549
2670
  }
2550
- function an(e, t, n) {
2671
+ function fn(e, t, n) {
2551
2672
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2552
2673
  }
2553
- async function on({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, shouldPause: u = () => !1, signal: d }) {
2554
- let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ?? Zt(s), g = t, _ = t, v = t, y = 0, b = [], x;
2674
+ async function pn({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, shouldPause: u = () => !1, signal: d }) {
2675
+ let f = [], p = [...e], m = /* @__PURE__ */ new Set(), h = r ?? an(s), g = t, _ = t, v = t, y = 0, b = [], x;
2555
2676
  for (; y < h;) {
2556
- let e = Qt(g);
2677
+ let e = on(g);
2557
2678
  if (m.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2558
- if (m.add(e), await Yt({
2559
- delayMs: Jt(l + y, s),
2679
+ if (m.add(e), await nn({
2680
+ delayMs: tn(l + y, s),
2560
2681
  onChange: a,
2561
2682
  signal: d
2562
2683
  }), y > 0 && u()) return {
@@ -2570,12 +2691,12 @@ async function on({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2570
2691
  status: "paused",
2571
2692
  total: x
2572
2693
  };
2573
- let t = Bt(await n({
2694
+ let t = Ut(await n({
2574
2695
  cursor: g,
2575
2696
  signal: d
2576
2697
  }));
2577
2698
  y += 1, _ = g;
2578
- let r = Z(p, t.items).slice(p.length);
2699
+ let r = Q(p, t.items).slice(p.length);
2579
2700
  b.push({
2580
2701
  contributionIds: r.map(({ postId: e }) => e),
2581
2702
  cursor: g,
@@ -2627,12 +2748,12 @@ async function on({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2627
2748
  }
2628
2749
  //#endregion
2629
2750
  //#region src/core/autofillController.ts
2630
- var sn = class {
2751
+ var mn = class {
2631
2752
  collection = null;
2632
2753
  cycle = 0;
2633
2754
  delayCountdown;
2634
2755
  constructor(e) {
2635
- this.context = e, this.delayCountdown = new Xt((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2756
+ this.context = e, this.delayCountdown = new rn((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2636
2757
  }
2637
2758
  beginCycle() {
2638
2759
  let { options: e, state: t } = this.context;
@@ -2640,14 +2761,14 @@ var sn = class {
2640
2761
  this.clear();
2641
2762
  let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
2642
2763
  return t.autofill = {
2643
- ...tn(e, void 0, !1),
2764
+ ...ln(e, void 0, !1),
2644
2765
  cycleId: n,
2645
2766
  status: "filling"
2646
2767
  }, n;
2647
2768
  }
2648
2769
  async cancel() {
2649
2770
  let { cancelRequest: e, options: t, state: n } = this.context;
2650
- await rn(t, n, e), this.commitCollection();
2771
+ await dn(t, n, e), this.commitCollection();
2651
2772
  }
2652
2773
  captureCollection(e, t) {
2653
2774
  t && (this.collection = e);
@@ -2669,36 +2790,36 @@ var sn = class {
2669
2790
  let { onLastCursor: e, options: t, state: n } = this.context;
2670
2791
  if (t?.strategy !== "frontend") return !1;
2671
2792
  let r = this.collection;
2672
- return this.collection = null, r ? (n.items = Z(n.items, r.items), e(r.lastCursor), this.context.onPages(r.pages), n.next = r.next, r.total !== void 0 && (n.total = r.total), Object.assign(n.autofill, {
2793
+ return this.collection = null, r ? (n.items = Q(n.items, r.items), e(r.lastCursor), this.context.onPages(r.pages), n.next = r.next, r.total !== void 0 && (n.total = r.total), Object.assign(n.autofill, {
2673
2794
  missing: r.missing,
2674
2795
  received: r.received,
2675
2796
  requests: r.requests
2676
2797
  }), !0) : !1;
2677
2798
  }
2678
- }, cn = 100;
2679
- function ln(e, t) {
2799
+ }, hn = 100;
2800
+ function gn(e, t) {
2680
2801
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2681
2802
  }
2682
- function un(e, t, n) {
2803
+ function _n(e, t, n) {
2683
2804
  return Math.min(n, Math.max(t, e));
2684
2805
  }
2685
- function dn(e) {
2806
+ function vn(e) {
2686
2807
  if (!e) return;
2687
2808
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2688
- if (ln("autoScroll.minSpeedPxPerSecond", t), ln("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2689
- e.speedPxPerSecond !== void 0 && ln("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2809
+ if (gn("autoScroll.minSpeedPxPerSecond", t), gn("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2810
+ e.speedPxPerSecond !== void 0 && gn("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2690
2811
  }
2691
- function fn(e) {
2812
+ function yn(e) {
2692
2813
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2693
2814
  return {
2694
2815
  enabled: e?.enabled ?? !1,
2695
2816
  maxSpeedPxPerSecond: n,
2696
2817
  minSpeedPxPerSecond: t,
2697
2818
  paused: !1,
2698
- speedPxPerSecond: un(e?.speedPxPerSecond ?? 80, t, n)
2819
+ speedPxPerSecond: _n(e?.speedPxPerSecond ?? 80, t, n)
2699
2820
  };
2700
2821
  }
2701
- var pn = class {
2822
+ var bn = class {
2702
2823
  frame = null;
2703
2824
  lastTimestamp = null;
2704
2825
  mounted = !1;
@@ -2718,9 +2839,9 @@ var pn = class {
2718
2839
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2719
2840
  }
2720
2841
  setSpeed(e) {
2721
- ln("auto-scroll speed", e);
2842
+ gn("auto-scroll speed", e);
2722
2843
  let t = this.options.state;
2723
- t.speedPxPerSecond = un(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2844
+ t.speedPxPerSecond = _n(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2724
2845
  }
2725
2846
  tick = (e) => {
2726
2847
  this.frame = null;
@@ -2732,7 +2853,7 @@ var pn = class {
2732
2853
  return;
2733
2854
  }
2734
2855
  if (this.lastTimestamp !== null) {
2735
- let r = Math.min(cn, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2856
+ let r = Math.min(hn, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2736
2857
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2737
2858
  }
2738
2859
  this.lastTimestamp = e, this.schedule();
@@ -2746,13 +2867,13 @@ var pn = class {
2746
2867
  };
2747
2868
  //#endregion
2748
2869
  //#region src/core/backendAutofill.ts
2749
- async function mn(e, t, n, r) {
2870
+ async function xn(e, t, n, r) {
2750
2871
  let i = await e.onUnderfilled(n);
2751
2872
  if (!r()) return;
2752
2873
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
2753
2874
  let a = Math.max(n.received, i.received ?? n.received);
2754
2875
  Object.assign(t.autofill, {
2755
- ...Q(i.nextRequestAt),
2876
+ ...$(i.nextRequestAt),
2756
2877
  missing: Math.max(0, e.pageSize - a),
2757
2878
  received: a,
2758
2879
  sequence: i.sequence ?? 0,
@@ -2760,19 +2881,34 @@ async function mn(e, t, n, r) {
2760
2881
  status: "waiting"
2761
2882
  });
2762
2883
  }
2763
- function hn(e, t) {
2764
- ["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);
2884
+ function Sn(e, t) {
2885
+ ["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);
2765
2886
  }
2766
- function gn(e, t, n) {
2887
+ function Cn(e, t, n) {
2767
2888
  let r = t.autofill;
2768
- return !an(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (hn(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);
2889
+ return !fn(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Sn(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);
2769
2890
  }
2770
- function _n(e, t, n) {
2771
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = tn(e, n), hn(t, n), !0);
2891
+ function wn(e, t, n) {
2892
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = ln(e, n), Sn(t, n), !0);
2893
+ }
2894
+ //#endregion
2895
+ //#region src/core/backlogRestore.ts
2896
+ async function Tn(e, t, n) {
2897
+ if (!e) return;
2898
+ let r = new AbortController();
2899
+ n(r);
2900
+ try {
2901
+ await e({
2902
+ appendPage: t,
2903
+ signal: r.signal
2904
+ });
2905
+ } finally {
2906
+ n(null);
2907
+ }
2772
2908
  }
2773
2909
  //#endregion
2774
2910
  //#region src/core/initialAutofill.ts
2775
- async function vn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
2911
+ async function En({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
2776
2912
  let c = a.autofill;
2777
2913
  if (!c) return;
2778
2914
  let l = s.items.length;
@@ -2785,7 +2921,7 @@ async function vn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2785
2921
  return;
2786
2922
  }
2787
2923
  if (c.strategy === "backend") {
2788
- await mn(c, s, {
2924
+ await xn(c, s, {
2789
2925
  cycleId: e,
2790
2926
  feedKey: c.feedKey,
2791
2927
  items: [...s.items],
@@ -2802,11 +2938,11 @@ async function vn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2802
2938
  s.autofill.status = "exhausted";
2803
2939
  return;
2804
2940
  }
2805
- let u = await on({
2941
+ let u = await pn({
2806
2942
  existingItems: s.items,
2807
2943
  initialCursor: s.next,
2808
2944
  loadPage: a.loadPage,
2809
- maximumRequests: Zt(c, !1),
2945
+ maximumRequests: an(c, !1),
2810
2946
  onCollection: n,
2811
2947
  onDelayChange: (e) => {
2812
2948
  t() && Object.assign(s.autofill, e);
@@ -2820,7 +2956,7 @@ async function vn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2820
2956
  shouldPause: () => s.loadMoreLocked,
2821
2957
  signal: o
2822
2958
  });
2823
- 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, {
2959
+ t() && (s.items = Q(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, {
2824
2960
  missing: u.missing,
2825
2961
  received: u.received,
2826
2962
  requests: u.requests,
@@ -2829,36 +2965,40 @@ async function vn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r,
2829
2965
  }
2830
2966
  //#endregion
2831
2967
  //#region src/core/fill.ts
2832
- function yn(e) {
2833
- return "pages" in e ? { pages: e.pages } : { until: "end" };
2968
+ function Dn(e) {
2969
+ return "items" in e ? { items: e.items } : "pages" in e ? { pages: e.pages } : { until: "end" };
2834
2970
  }
2835
- function bn(e) {
2971
+ function On(e) {
2836
2972
  return `${typeof e}:${String(e)}`;
2837
2973
  }
2838
- function xn(e) {
2974
+ function kn(e) {
2839
2975
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2840
2976
  if ("pages" in e) {
2841
2977
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
2842
2978
  return { pages: e.pages };
2843
2979
  }
2980
+ if ("items" in e) {
2981
+ if (!Number.isInteger(e.items) || e.items <= 0) throw TypeError("Vibe fill items must be a positive integer.");
2982
+ return { items: e.items };
2983
+ }
2844
2984
  if ("until" in e && e.until === "end") return { until: "end" };
2845
- throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2985
+ throw TypeError("Vibe fill target must be { items }, { pages }, or { until: 'end' }.");
2846
2986
  }
2847
- function Sn(e) {
2987
+ function An(e) {
2848
2988
  if (!e) return;
2849
2989
  if (e.strategy === "frontend") {
2850
- qt(e, "frontend fill");
2990
+ en(e, "frontend fill");
2851
2991
  return;
2852
2992
  }
2853
2993
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2854
2994
  let t = e.initialSession;
2855
2995
  if (t) {
2856
2996
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2857
- xn(t.target);
2997
+ kn(t.target);
2858
2998
  }
2859
2999
  }
2860
- function Cn(e, t, n = !0) {
2861
- let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = Q(i?.nextRequestAt);
3000
+ function jn(e, t, n = !0) {
3001
+ let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2862
3002
  return {
2863
3003
  completedPages: i?.completedPages ?? 0,
2864
3004
  cycleId: i?.cycleId ?? null,
@@ -2871,10 +3011,10 @@ function Cn(e, t, n = !0) {
2871
3011
  sessionId: i?.sessionId ?? null,
2872
3012
  status: i?.status ?? "idle",
2873
3013
  strategy: e?.strategy ?? null,
2874
- target: i ? yn(i.target) : null
3014
+ target: i ? Dn(i.target) : null
2875
3015
  };
2876
3016
  }
2877
- function wn(e) {
3017
+ function Mn(e) {
2878
3018
  return [
2879
3019
  "cancelling",
2880
3020
  "filling",
@@ -2882,13 +3022,22 @@ function wn(e) {
2882
3022
  "waiting"
2883
3023
  ].includes(e.status);
2884
3024
  }
2885
- async function Tn({ existingItems: e, initialCursor: t, loadPage: n, onCollection: r = () => void 0, onDelayChange: i, onProgress: a, options: o, shouldPause: s = () => !1, signal: c, target: l }) {
3025
+ async function Nn({ existingItems: e, initialCursor: t, loadPage: n, onCollection: r = () => void 0, onDelayChange: i, onProgress: a, options: o, shouldPause: s = () => !1, signal: c, target: l }) {
2886
3026
  let u = [], d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = 0, h = t, g = t, _ = t, v = 0, y;
3027
+ if ("items" in l && f.length >= l.items) return {
3028
+ completedPages: m,
3029
+ items: u,
3030
+ lastCursor: g,
3031
+ next: _,
3032
+ pages: d,
3033
+ received: v,
3034
+ status: "complete"
3035
+ };
2887
3036
  for (; _ !== null;) {
2888
- let e = bn(h);
3037
+ let e = On(h);
2889
3038
  if (p.has(e)) throw Error("Vibe fill received a repeated cursor.");
2890
- if (p.add(e), await Yt({
2891
- delayMs: Jt(m, o),
3039
+ if (p.add(e), await nn({
3040
+ delayMs: tn(m, o),
2892
3041
  onChange: i,
2893
3042
  signal: c
2894
3043
  }), m > 0 && s()) return {
@@ -2901,12 +3050,12 @@ async function Tn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
2901
3050
  status: "paused",
2902
3051
  total: y
2903
3052
  };
2904
- let t = Bt(await n({
3053
+ let t = Ut(await n({
2905
3054
  cursor: h,
2906
3055
  signal: c
2907
3056
  }));
2908
3057
  m += 1, g = h;
2909
- let b = Z(f, t.items).slice(f.length);
3058
+ let b = Q(f, t.items).slice(f.length);
2910
3059
  if (d.push({
2911
3060
  contributionIds: b.map(({ postId: e }) => e),
2912
3061
  cursor: h,
@@ -2924,7 +3073,7 @@ async function Tn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
2924
3073
  pages: [...d],
2925
3074
  received: v,
2926
3075
  total: y
2927
- }), "pages" in l && m >= l.pages) return {
3076
+ }), "items" in l && f.length >= l.items || "pages" in l && m >= l.pages) return {
2928
3077
  completedPages: m,
2929
3078
  items: u,
2930
3079
  lastCursor: h,
@@ -2941,7 +3090,7 @@ async function Tn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
2941
3090
  next: _,
2942
3091
  pages: d,
2943
3092
  received: v,
2944
- status: "pages" in l ? "exhausted" : "complete",
3093
+ status: "until" in l ? "complete" : "exhausted",
2945
3094
  total: y
2946
3095
  };
2947
3096
  if (s()) return {
@@ -2963,18 +3112,18 @@ async function Tn({ existingItems: e, initialCursor: t, loadPage: n, onCollectio
2963
3112
  next: null,
2964
3113
  pages: d,
2965
3114
  received: v,
2966
- status: "pages" in l ? "exhausted" : "complete",
3115
+ status: "until" in l ? "complete" : "exhausted",
2967
3116
  total: y
2968
3117
  };
2969
3118
  }
2970
3119
  //#endregion
2971
3120
  //#region src/core/backendFill.ts
2972
- async function En(e, t, n, r) {
3121
+ async function Pn(e, t, n, r) {
2973
3122
  let i = await e.onStart(n);
2974
3123
  if (r()) {
2975
3124
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
2976
3125
  Object.assign(t.fill, {
2977
- ...Q(i.nextRequestAt),
3126
+ ...$(i.nextRequestAt),
2978
3127
  completedPages: i.completedPages ?? 0,
2979
3128
  received: i.received ?? 0,
2980
3129
  sequence: i.sequence ?? 0,
@@ -2983,23 +3132,23 @@ async function En(e, t, n, r) {
2983
3132
  });
2984
3133
  }
2985
3134
  }
2986
- function Dn(e, t, n) {
3135
+ function Fn(e, t, n) {
2987
3136
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2988
3137
  }
2989
- function On(e) {
3138
+ function In(e) {
2990
3139
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2991
3140
  }
2992
- function kn(e, t) {
3141
+ function Ln(e, t) {
2993
3142
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2994
3143
  let n = e.fill.target;
2995
3144
  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;
2996
3145
  }
2997
- function An(e, t, n) {
2998
- 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));
3146
+ function Rn(e, t, n) {
3147
+ 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));
2999
3148
  }
3000
- function jn(e, t, n, r) {
3001
- return !Dn(e, t, n) || !On(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !kn(t, n) ? !1 : (An(t, n, r), Object.assign(t.fill, {
3002
- ...Q(n.status === "waiting" ? n.nextRequestAt : null),
3149
+ function zn(e, t, n, r) {
3150
+ return !Fn(e, t, n) || !In(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !Ln(t, n) ? !1 : (Rn(t, n, r), Object.assign(t.fill, {
3151
+ ...$(n.status === "waiting" ? n.nextRequestAt : null),
3003
3152
  completedPages: n.completedPages,
3004
3153
  error: n.error ?? null,
3005
3154
  received: n.received,
@@ -3007,58 +3156,58 @@ function jn(e, t, n, r) {
3007
3156
  status: n.status
3008
3157
  }), !0);
3009
3158
  }
3010
- function Mn(e, t, n, r) {
3159
+ function Bn(e, t, n, r) {
3011
3160
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
3012
3161
  let i = t.fill;
3013
- return t.fill = Cn(e, n), !On(n) || !kn(t, n) ? (t.fill = i, !1) : (An(t, n, r), !0);
3162
+ return t.fill = jn(e, n), !In(n) || !Ln(t, n) ? (t.fill = i, !1) : (Rn(t, n, r), !0);
3014
3163
  }
3015
3164
  //#endregion
3016
3165
  //#region src/core/fillController.ts
3017
- var Nn = class {
3166
+ var Vn = class {
3018
3167
  abortController = null;
3019
3168
  cycle = 0;
3020
3169
  delayCountdown;
3021
3170
  requestVersion = 0;
3022
3171
  collection = null;
3023
3172
  constructor(e) {
3024
- this.options = e, this.delayCountdown = new Xt((e) => {
3173
+ this.options = e, this.delayCountdown = new rn((e) => {
3025
3174
  Object.assign(this.options.state.fill, e);
3026
3175
  }), this.syncBackendCountdown();
3027
3176
  }
3028
3177
  isActive() {
3029
- return wn(this.options.state.fill);
3178
+ return Mn(this.options.state.fill);
3030
3179
  }
3031
3180
  applyUpdate(e) {
3032
- let t = jn(this.options.fill, this.options.state, e, this.options.onLastCursor);
3181
+ let t = zn(this.options.fill, this.options.state, e, this.options.onLastCursor);
3033
3182
  return t && this.syncBackendCountdown(), t;
3034
3183
  }
3035
3184
  restoreSession(e) {
3036
- let t = Mn(this.options.fill, this.options.state, e, this.options.onLastCursor);
3185
+ let t = Bn(this.options.fill, this.options.state, e, this.options.onLastCursor);
3037
3186
  return t && this.syncBackendCountdown(), t;
3038
3187
  }
3039
3188
  async start(e, t = {}) {
3040
3189
  let n = this.options.fill;
3041
3190
  if (!n) throw Error("Vibe fill is not configured.");
3042
3191
  if (this.isActive()) throw Error("Vibe fill is already active.");
3043
- let r = xn(e), i = xn(t.target ?? r), a = t.progressOffset ?? {
3192
+ let r = kn(e), i = kn(t.target ?? r), a = t.progressOffset ?? {
3044
3193
  completedPages: 0,
3045
3194
  received: 0
3046
3195
  }, o = t.cycleId ?? `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
3047
3196
  if (this.options.state.fill = {
3048
- ...Cn(n, void 0, !1),
3197
+ ...jn(n, void 0, !1),
3049
3198
  completedPages: a.completedPages,
3050
3199
  cycleId: o,
3051
3200
  received: a.received,
3052
3201
  status: "filling",
3053
3202
  target: i
3054
3203
  }, n.strategy === "backend" && this.options.state.next === null) {
3055
- this.options.state.fill.status = "pages" in r ? "exhausted" : "complete";
3204
+ this.options.state.fill.status = "until" in r ? "complete" : "exhausted";
3056
3205
  return;
3057
3206
  }
3058
3207
  let s = ++this.requestVersion, c = new AbortController();
3059
3208
  this.abortController = c;
3060
3209
  try {
3061
- n.strategy === "frontend" ? await this.startFrontend(n, r, c, s, t.prepareFrontend !== !1, a) : (await En(n, this.options.state, {
3210
+ n.strategy === "frontend" ? await this.startFrontend(n, r, c, s, t.prepareFrontend !== !1, a) : (await Pn(n, this.options.state, {
3062
3211
  cycleId: o,
3063
3212
  feedKey: n.feedKey,
3064
3213
  items: [...this.options.state.items],
@@ -3069,14 +3218,14 @@ var Nn = class {
3069
3218
  }, () => this.isCurrent(s)), this.syncBackendCountdown());
3070
3219
  } catch (e) {
3071
3220
  if (c.signal.aborted || !this.isCurrent(s)) return;
3072
- throw this.options.state.fill.error = e, this.options.state.fill.status = "error", e;
3221
+ throw this.commitCollection(), this.options.state.fill.error = e, this.options.state.fill.status = "error", e;
3073
3222
  } finally {
3074
3223
  this.isCurrent(s) && (this.abortController = null, this.options.state.isLoadingMore = !1);
3075
3224
  }
3076
3225
  }
3077
3226
  async cancel() {
3078
3227
  let { fill: e, state: t } = this.options;
3079
- if (!wn(t.fill) || !t.fill.cycleId) return;
3228
+ if (!Mn(t.fill) || !t.fill.cycleId) return;
3080
3229
  let n = {
3081
3230
  cycleId: t.fill.cycleId,
3082
3231
  feedKey: t.fill.feedKey ?? "",
@@ -3094,7 +3243,7 @@ var Nn = class {
3094
3243
  if (t.status !== "paused" || !t.target) return Promise.resolve();
3095
3244
  let n = t.target, r = "pages" in n ? n.pages - t.completedPages : null;
3096
3245
  if (r !== null && r <= 0) return t.status = "complete", Promise.resolve();
3097
- let i = r === null ? { until: "end" } : { pages: r };
3246
+ let i = r === null ? n : { pages: r };
3098
3247
  return t.strategy === "backend" ? this.start(i) : this.start(i, {
3099
3248
  cycleId: t.cycleId ?? void 0,
3100
3249
  prepareFrontend: e,
@@ -3105,8 +3254,22 @@ var Nn = class {
3105
3254
  target: n
3106
3255
  });
3107
3256
  }
3257
+ retry(e) {
3258
+ let { fill: t } = this.options.state;
3259
+ if (t.status !== "error" || !t.target) return Promise.resolve();
3260
+ let n = t.target, r = "pages" in n ? n.pages - t.completedPages : null;
3261
+ return r !== null && r <= 0 ? (t.status = "complete", Promise.resolve()) : this.start(r === null ? n : { pages: r }, {
3262
+ cycleId: t.cycleId ?? void 0,
3263
+ prepareFrontend: e,
3264
+ progressOffset: {
3265
+ completedPages: t.completedPages,
3266
+ received: t.received
3267
+ },
3268
+ target: n
3269
+ });
3270
+ }
3108
3271
  reset() {
3109
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = Cn(this.options.fill, void 0, !1), this.collection = null;
3272
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = jn(this.options.fill, void 0, !1), this.collection = null;
3110
3273
  }
3111
3274
  destroy() {
3112
3275
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -3138,10 +3301,10 @@ var Nn = class {
3138
3301
  s.fill.status = "filling";
3139
3302
  }
3140
3303
  if (s.next === null) {
3141
- s.fill.status = "pages" in t ? "exhausted" : "complete";
3304
+ s.fill.status = "until" in t ? "complete" : "exhausted";
3142
3305
  return;
3143
3306
  }
3144
- let c = await Tn({
3307
+ let c = await Nn({
3145
3308
  existingItems: s.items,
3146
3309
  initialCursor: s.next,
3147
3310
  loadPage: o,
@@ -3150,7 +3313,7 @@ var Nn = class {
3150
3313
  ...e,
3151
3314
  completedPages: a.completedPages + e.completedPages,
3152
3315
  received: a.received + e.received
3153
- });
3316
+ }, this.commitCollection());
3154
3317
  },
3155
3318
  onDelayChange: (e) => {
3156
3319
  this.isCurrent(r) && Object.assign(s.fill, e);
@@ -3167,7 +3330,7 @@ var Nn = class {
3167
3330
  signal: n.signal,
3168
3331
  target: t
3169
3332
  });
3170
- this.isCurrent(r) && (s.items = Z(s.items, c.items), s.next = c.next, c.total !== void 0 && (s.total = c.total), this.options.onLastCursor(c.lastCursor), this.options.onPages(c.pages), Object.assign(s.fill, {
3333
+ this.isCurrent(r) && (s.items = Q(s.items, c.items), s.next = c.next, c.total !== void 0 && (s.total = c.total), this.options.onLastCursor(c.lastCursor), Object.assign(s.fill, {
3171
3334
  completedPages: a.completedPages + c.completedPages,
3172
3335
  received: a.received + c.received,
3173
3336
  status: c.status
@@ -3177,7 +3340,7 @@ var Nn = class {
3177
3340
  let e = this.collection;
3178
3341
  if (this.collection = null, !e || this.options.fill?.strategy !== "frontend") return;
3179
3342
  let t = this.options.state;
3180
- t.items = Z(t.items, e.items), t.next = e.next, e.total !== void 0 && (t.total = e.total), this.options.onLastCursor(e.lastCursor), this.options.onPages(e.pages), Object.assign(t.fill, {
3343
+ t.items = Q(t.items, e.items), t.next = e.next, e.total !== void 0 && (t.total = e.total), this.options.onLastCursor(e.lastCursor), this.options.onPages(e.pages), Object.assign(t.fill, {
3181
3344
  completedPages: e.completedPages,
3182
3345
  received: e.received
3183
3346
  });
@@ -3189,7 +3352,7 @@ var Nn = class {
3189
3352
  };
3190
3353
  //#endregion
3191
3354
  //#region src/core/fillReconciliation.ts
3192
- async function Pn({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r, setLastCursor: i, signal: a, state: o }) {
3355
+ async function Hn({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r, setLastCursor: i, signal: a, state: o }) {
3193
3356
  if (!e.needsReconciliation(o.items)) return "skipped";
3194
3357
  let s = await e.reconcile({
3195
3358
  existingItems: o.items,
@@ -3198,11 +3361,11 @@ async function Pn({ controller: e, isCurrent: t, loadPage: n, onDelayChange: r,
3198
3361
  shouldPause: () => o.loadMoreLocked,
3199
3362
  signal: a
3200
3363
  });
3201
- return t() ? (o.items = Z(o.items, s.items), o.next = s.next, i(s.lastCursor), s.total !== void 0 && (o.total = s.total), e.completeReconciliation(s), s.status) : s.status;
3364
+ return t() ? (o.items = Q(o.items, s.items), o.next = s.next, i(s.lastCursor), s.total !== void 0 && (o.total = s.total), e.completeReconciliation(s), s.status) : s.status;
3202
3365
  }
3203
3366
  //#endregion
3204
3367
  //#region src/core/feedFooter.ts
3205
- function Fn(e) {
3368
+ function Un(e) {
3206
3369
  return {
3207
3370
  cancelAutofill: () => e.cancelAutofill(),
3208
3371
  loadMore: () => e.loadNext(),
@@ -3210,67 +3373,68 @@ function Fn(e) {
3210
3373
  let t = e.getState();
3211
3374
  return t.autofill.strategy === "frontend" && t.autofill.status === "error" && t.items.length > 0 && t.next !== null ? e.loadNext() : e.reload();
3212
3375
  },
3213
- retryEnd: () => e.retryEnd()
3376
+ retryEnd: () => e.retryEnd(),
3377
+ retryFill: () => e.retryFill()
3214
3378
  };
3215
3379
  }
3216
- function In(e) {
3380
+ function Wn(e) {
3217
3381
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
3218
3382
  }
3219
- function Ln(e) {
3220
- e?.intervalMs !== void 0 && In(e.intervalMs);
3383
+ function Gn(e) {
3384
+ e?.intervalMs !== void 0 && Wn(e.intervalMs);
3221
3385
  }
3222
- function Rn(e) {
3386
+ function Kn(e) {
3223
3387
  return {
3224
3388
  enabled: e?.enabled ?? !1,
3225
3389
  includePostItems: e?.includePostItems ?? !1,
3226
3390
  intervalMs: e?.intervalMs ?? 5e3
3227
3391
  };
3228
3392
  }
3229
- function zn(e, t) {
3393
+ function qn(e, t) {
3230
3394
  if (typeof t == "boolean") {
3231
3395
  e.enabled = t;
3232
3396
  return;
3233
3397
  }
3234
- Ln(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);
3398
+ Gn(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);
3235
3399
  }
3236
3400
  //#endregion
3237
3401
  //#region src/core/reelInfoSheet.ts
3238
- function Bn(e) {
3402
+ function Jn(e) {
3239
3403
  return { enabled: e?.enabled ?? !1 };
3240
3404
  }
3241
- function Vn(e, t, n) {
3405
+ function Yn(e, t, n) {
3242
3406
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
3243
3407
  e.enabled = n;
3244
3408
  }
3245
3409
  //#endregion
3246
3410
  //#region src/core/initialRuntimeState.ts
3247
- function Hn(e, t) {
3411
+ function Xn(e, t) {
3248
3412
  let n = e.initialPage;
3249
3413
  return {
3250
3414
  activeReelPostId: null,
3251
- autoScroll: fn(e.autoScroll),
3252
- autofill: tn(e.autofill),
3415
+ autoScroll: yn(e.autoScroll),
3416
+ autofill: ln(e.autofill),
3253
3417
  current: n?.current ?? null,
3254
3418
  error: null,
3255
- fill: Cn(e.fill),
3419
+ fill: jn(e.fill),
3256
3420
  infiniteScroll: e.infiniteScroll ?? !0,
3257
3421
  isLoading: !n,
3258
3422
  isLoadingMore: !1,
3259
- items: n ? Z([], n.items) : [],
3423
+ items: n ? Q([], n.items) : [],
3260
3424
  layout: t === "reel" ? "reel" : "masonry",
3261
3425
  loadMoreLocked: !1,
3262
3426
  mediaIndices: /* @__PURE__ */ new Map(),
3263
3427
  next: n?.next ?? null,
3264
3428
  nextPageError: null,
3265
3429
  phoneMode: !1,
3266
- reelAutoAdvance: Rn(e.reelAutoAdvance),
3430
+ reelAutoAdvance: Kn(e.reelAutoAdvance),
3267
3431
  reelForward: {
3268
3432
  error: null,
3269
3433
  status: "idle"
3270
3434
  },
3271
3435
  reelForwardIndex: null,
3272
3436
  reelForwardItem: null,
3273
- reelInfoSheet: Bn(e.reelInfoSheet),
3437
+ reelInfoSheet: Jn(e.reelInfoSheet),
3274
3438
  reelInfoSheetOverlay: !1,
3275
3439
  reelMediaSource: "original",
3276
3440
  reelOrigin: null,
@@ -3279,20 +3443,20 @@ function Hn(e, t) {
3279
3443
  }
3280
3444
  //#endregion
3281
3445
  //#region src/core/options.ts
3282
- function Un(e, t) {
3446
+ function Zn(e, t) {
3283
3447
  if (t) {
3284
3448
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
3285
3449
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
3286
3450
  }
3287
3451
  }
3288
- function Wn(e, t) {
3452
+ function Qn(e, t) {
3289
3453
  if (t) {
3290
3454
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
3291
3455
  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.`);
3292
3456
  }
3293
3457
  }
3294
- function Gn(e) {
3295
- if (dn(e.autoScroll), Un("cardHeader", e.cardHeader), Un("cardFooter", e.cardFooter), Wn("header", e.mediaCard?.header), Wn("footer", e.mediaCard?.footer), en(e.autofill), Sn(e.fill), J(e.masonry), Ln(e.reelAutoAdvance), e.removalReconciliation) {
3458
+ function $n(e) {
3459
+ if (vn(e.autoScroll), Zn("cardHeader", e.cardHeader), Zn("cardFooter", e.cardFooter), Qn("header", e.mediaCard?.header), Qn("footer", e.mediaCard?.footer), cn(e.autofill), An(e.fill), X(e.masonry), Gn(e.reelAutoAdvance), e.removalReconciliation) {
3296
3460
  if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
3297
3461
  let t = e.removalReconciliation.maxReplayPages ?? 5;
3298
3462
  if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
@@ -3307,7 +3471,7 @@ function Gn(e) {
3307
3471
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
3308
3472
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
3309
3473
  }
3310
- function Kn(e) {
3474
+ function er(e) {
3311
3475
  if (typeof e != "string") return e;
3312
3476
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
3313
3477
  let t = document.querySelector(e);
@@ -3316,7 +3480,7 @@ function Kn(e) {
3316
3480
  }
3317
3481
  //#endregion
3318
3482
  //#region src/core/pageRequest.ts
3319
- async function qn({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
3483
+ async function tr({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
3320
3484
  let u = s.autofill, d = e && u?.strategy === "frontend" && (l.autofill.status === "paused" || l.autofill.status === "error"), f = d ? {
3321
3485
  received: l.autofill.received,
3322
3486
  requests: l.autofill.requests
@@ -3328,11 +3492,11 @@ async function qn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
3328
3492
  let m = !1;
3329
3493
  try {
3330
3494
  if (u?.strategy === "frontend") {
3331
- let s = await on({
3495
+ let s = await pn({
3332
3496
  existingItems: e ? l.items : [],
3333
3497
  initialCursor: n,
3334
3498
  loadPage: i,
3335
- maximumRequests: f ? Math.max(0, Zt(u) - f.requests) : void 0,
3499
+ maximumRequests: f ? Math.max(0, an(u) - f.requests) : void 0,
3336
3500
  onCollection: (e) => t.captureCollection(e, r()),
3337
3501
  onDelayChange: (e) => {
3338
3502
  r() && Object.assign(l.autofill, e);
@@ -3347,7 +3511,7 @@ async function qn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
3347
3511
  signal: c
3348
3512
  });
3349
3513
  if (!r()) return;
3350
- 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, {
3514
+ l.items = e ? Q(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, {
3351
3515
  missing: s.missing,
3352
3516
  received: s.received,
3353
3517
  requests: s.requests,
@@ -3355,12 +3519,12 @@ async function qn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
3355
3519
  }), o(s.pages), t.clearCollection();
3356
3520
  return;
3357
3521
  }
3358
- let s = Bt(await i({
3522
+ let s = Ut(await i({
3359
3523
  cursor: n,
3360
3524
  signal: c
3361
3525
  }));
3362
3526
  if (!r()) return;
3363
- let d = e ? l.items : [], h = Z(d, s.items), g = h.length - d.length;
3527
+ let d = e ? l.items : [], h = Q(d, s.items), g = h.length - d.length;
3364
3528
  if (l.items = h, a(n), o([{
3365
3529
  contributionIds: h.slice(d.length).map(({ postId: e }) => e),
3366
3530
  cursor: n,
@@ -3375,7 +3539,7 @@ async function qn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
3375
3539
  l.autofill.status = "complete";
3376
3540
  return;
3377
3541
  }
3378
- await mn(u, l, {
3542
+ await xn(u, l, {
3379
3543
  cycleId: p,
3380
3544
  feedKey: u.feedKey,
3381
3545
  items: h.slice(d.length),
@@ -3397,16 +3561,16 @@ async function qn({ append: e, autofillController: t, cursor: n, isCurrent: r, l
3397
3561
  }
3398
3562
  //#endregion
3399
3563
  //#region src/core/removalReconciliationController.ts
3400
- function $(e) {
3564
+ function nr(e) {
3401
3565
  return `${typeof e}:${String(e)}`;
3402
3566
  }
3403
- function Jn(e) {
3567
+ function rr(e) {
3404
3568
  return `${typeof e}:${String(e)}`;
3405
3569
  }
3406
- function Yn(e) {
3570
+ function ir(e) {
3407
3571
  return e.map(({ postId: e }) => e);
3408
3572
  }
3409
- var Xn = class {
3573
+ var ar = class {
3410
3574
  delay;
3411
3575
  enabled;
3412
3576
  maxReplayPages;
@@ -3425,7 +3589,7 @@ var Xn = class {
3425
3589
  e.status === "complete" && (this.pages = [...this.pages.slice(0, e.replaceFrom), ...e.pages].slice(-this.maxReplayPages), this.pending = null);
3426
3590
  }
3427
3591
  filterItems(e) {
3428
- return !this.enabled || this.tombstones.size === 0 ? [...e] : e.filter(({ postId: e }) => !this.tombstones.has($(e)));
3592
+ return this.tombstones.size === 0 ? [...e] : e.filter(({ postId: e }) => !this.tombstones.has(nr(e)));
3429
3593
  }
3430
3594
  needsReconciliation(e) {
3431
3595
  return this.pending !== null || this.findUnderfilledPage(e) >= 0;
@@ -3438,45 +3602,45 @@ var Xn = class {
3438
3602
  }
3439
3603
  recordInitialPage(e) {
3440
3604
  e && this.recordPages([{
3441
- contributionIds: Yn(e.items),
3442
- cursor: Vt(e),
3605
+ contributionIds: ir(e.items),
3606
+ cursor: qt(e),
3443
3607
  next: e.next,
3444
- returnedIds: Yn(e.items)
3608
+ returnedIds: ir(e.items)
3445
3609
  }]);
3446
3610
  }
3447
3611
  remove(e) {
3448
- this.enabled && e.forEach((e) => this.tombstones.add($(e)));
3612
+ e.forEach((e) => this.tombstones.add(nr(e)));
3449
3613
  }
3450
3614
  reset() {
3451
3615
  this.pages = [], this.pending = null, this.tombstones.clear();
3452
3616
  }
3453
3617
  restore(e) {
3454
- this.enabled && e.forEach((e) => this.tombstones.delete($(e)));
3618
+ e.forEach((e) => this.tombstones.delete(nr(e)));
3455
3619
  }
3456
3620
  async reconcile({ existingItems: e, loadPage: t, onDelayChange: n = () => void 0, shouldPause: r = () => !1, signal: i }) {
3457
3621
  let a = this.pending ?? this.createSession(e);
3458
3622
  for (this.pending = a; a.remainingRequests > 0;) {
3459
- let e = Jn(a.cursor);
3623
+ let e = rr(a.cursor);
3460
3624
  if (a.seenCursors.has(e)) throw Error("Vibe removal reconciliation received a repeated cursor.");
3461
- if (await Yt({
3462
- delayMs: Jt(a.pages.length, this.delay),
3625
+ if (await nn({
3626
+ delayMs: tn(a.pages.length, this.delay),
3463
3627
  onChange: n,
3464
3628
  signal: i
3465
3629
  }), a.pages.length > 0 && r()) return this.result(a, "paused");
3466
- let o = Bt(await t({
3630
+ let o = Ut(await t({
3467
3631
  cursor: a.cursor,
3468
3632
  signal: i
3469
3633
  }));
3470
3634
  a.seenCursors.add(e);
3471
3635
  let s = this.filterItems(o.items), c = [];
3472
3636
  if (s.forEach((e) => {
3473
- let t = $(e.postId);
3637
+ let t = nr(e.postId);
3474
3638
  a.attributed.has(t) || (a.attributed.add(t), c.push(e.postId)), a.appended.has(t) || (a.appended.add(t), a.items.push(e));
3475
3639
  }), a.pages.push({
3476
3640
  contributionIds: c,
3477
3641
  cursor: a.cursor,
3478
3642
  next: o.next,
3479
- returnedIds: Yn(s)
3643
+ returnedIds: ir(s)
3480
3644
  }), a.lastCursor = a.cursor, a.next = o.next, --a.remainingRequests, o.total !== void 0 && (a.total = o.total), a.next === null ? a.remainingRequests = 0 : a.cursor = a.next, a.remainingRequests > 0 && r()) return this.result(a, "paused");
3481
3645
  }
3482
3646
  return this.result(a, "complete");
@@ -3484,9 +3648,9 @@ var Xn = class {
3484
3648
  createSession(e) {
3485
3649
  let t = this.findUnderfilledPage(e), n = t < 0 ? [] : this.pages.slice(t), r = n[0];
3486
3650
  if (!r) throw Error("Vibe has no underfilled provider page to reconcile.");
3487
- let i = new Set(n.flatMap(({ contributionIds: e }) => e.map($))), a = new Set(e.map(({ postId: e }) => $(e)).filter((e) => !i.has(e)));
3651
+ let i = new Set(n.flatMap(({ contributionIds: e }) => e.map(nr))), a = new Set(e.map(({ postId: e }) => nr(e)).filter((e) => !i.has(e)));
3488
3652
  return {
3489
- appended: new Set(e.map(({ postId: e }) => $(e))),
3653
+ appended: new Set(e.map(({ postId: e }) => nr(e))),
3490
3654
  attributed: new Set(a),
3491
3655
  cursor: r.cursor,
3492
3656
  items: [],
@@ -3511,11 +3675,11 @@ var Xn = class {
3511
3675
  }
3512
3676
  findUnderfilledPage(e) {
3513
3677
  if (!this.enabled || this.pages.length === 0) return -1;
3514
- let t = new Set(e.map(({ postId: e }) => $(e)));
3515
- return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has($(e))).length < this.pageSize);
3678
+ let t = new Set(e.map(({ postId: e }) => nr(e)));
3679
+ return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has(nr(e))).length < this.pageSize);
3516
3680
  }
3517
3681
  recordPage(e) {
3518
- let t = Jn(e.cursor), n = this.pages.findIndex(({ cursor: e }) => Jn(e) === t);
3682
+ let t = rr(e.cursor), n = this.pages.findIndex(({ cursor: e }) => rr(e) === t);
3519
3683
  n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
3520
3684
  ...e,
3521
3685
  contributionIds: [...e.contributionIds],
@@ -3525,7 +3689,7 @@ var Xn = class {
3525
3689
  };
3526
3690
  //#endregion
3527
3691
  //#region src/core/activeItemRemoval.ts
3528
- function Zn(e, t, n, r, i) {
3692
+ function or(e, t, n, r, i) {
3529
3693
  let a = new Set(t.map(({ item: e }) => e.postId));
3530
3694
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
3531
3695
  let o = e.items[Math.max(n, 0)];
@@ -3538,7 +3702,7 @@ function Zn(e, t, n, r, i) {
3538
3702
  }
3539
3703
  //#endregion
3540
3704
  //#region src/core/exactMediaRemovalController.ts
3541
- function Qn(e, t) {
3705
+ function sr(e, t) {
3542
3706
  let [n, ...r] = t;
3543
3707
  if (!n) throw Error("Vibe items must contain at least one media asset.");
3544
3708
  return {
@@ -3547,10 +3711,10 @@ function Qn(e, t) {
3547
3711
  items: r
3548
3712
  };
3549
3713
  }
3550
- function $n(e) {
3714
+ function cr(e) {
3551
3715
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
3552
3716
  }
3553
- var er = class {
3717
+ var lr = class {
3554
3718
  generation = 0;
3555
3719
  metadata = /* @__PURE__ */ new WeakMap();
3556
3720
  state;
@@ -3558,7 +3722,7 @@ var er = class {
3558
3722
  this.options = e, this.state = e.state;
3559
3723
  }
3560
3724
  remove(e) {
3561
- $n(e);
3725
+ cr(e);
3562
3726
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
3563
3727
  if (!n) return null;
3564
3728
  let r = [...M(n)], i = r[e.mediaIndex];
@@ -3575,7 +3739,7 @@ var er = class {
3575
3739
  restored: !1
3576
3740
  });
3577
3741
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
3578
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Qn(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);
3742
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = sr(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);
3579
3743
  }
3580
3744
  reset() {
3581
3745
  this.generation += 1;
@@ -3601,7 +3765,7 @@ var er = class {
3601
3765
  }
3602
3766
  restoreIntoPost(e, t) {
3603
3767
  let n = this.state.items[e], r = [...M(n)], i = Math.min(t.mediaIndex, r.length);
3604
- if (r.splice(i, 0, t.media), this.state.items[e] = Qn(n, r), this.state.activeReelPostId !== t.postId) return;
3768
+ if (r.splice(i, 0, t.media), this.state.items[e] = sr(n, r), this.state.activeReelPostId !== t.postId) return;
3605
3769
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
3606
3770
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
3607
3771
  }
@@ -3614,18 +3778,18 @@ var er = class {
3614
3778
  };
3615
3779
  //#endregion
3616
3780
  //#region src/core/itemPlacement.ts
3617
- function tr(e, t) {
3781
+ function ur(e, t) {
3618
3782
  let n = new Set(t);
3619
3783
  return e.flatMap((e, t) => n.has(e.postId) ? [{
3620
3784
  index: t,
3621
3785
  item: e
3622
3786
  }] : []);
3623
3787
  }
3624
- function nr(e, t) {
3788
+ function dr(e, t) {
3625
3789
  let n = new Set(t.map(({ item: e }) => e.postId));
3626
3790
  return e.filter((e) => !n.has(e.postId));
3627
3791
  }
3628
- function rr(e, t) {
3792
+ function fr(e, t) {
3629
3793
  t.forEach(({ index: e }) => {
3630
3794
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
3631
3795
  });
@@ -3636,7 +3800,7 @@ function rr(e, t) {
3636
3800
  }
3637
3801
  //#endregion
3638
3802
  //#region src/core/itemRemovalController.ts
3639
- var ir = 20, ar = class {
3803
+ var pr = 20, mr = class {
3640
3804
  generation = 0;
3641
3805
  historyLimit;
3642
3806
  metadata = /* @__PURE__ */ new WeakMap();
@@ -3645,7 +3809,7 @@ var ir = 20, ar = class {
3645
3809
  itemOrder;
3646
3810
  stopItemsWatcher;
3647
3811
  constructor(e) {
3648
- this.options = e, this.historyLimit = e.historyLimit ?? ir, 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" });
3812
+ this.options = e, this.historyLimit = e.historyLimit ?? pr, 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" });
3649
3813
  }
3650
3814
  destroy() {
3651
3815
  this.reset(), this.stopItemsWatcher();
@@ -3659,7 +3823,7 @@ var ir = 20, ar = class {
3659
3823
  let a = this.options.startRemoval(i, t);
3660
3824
  if (a > 0 && await new Promise((e) => setTimeout(e, a)), this.metadata.get(r)?.generation !== this.generation) return r;
3661
3825
  let o = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), s = new Set(n.map(({ item: e }) => e.postId)), c = o < 0 ? 0 : this.state.items.slice(0, o).filter(({ postId: e }) => s.has(e)).length, l = Math.max(o - c, 0);
3662
- return this.state.items = nr(this.state.items, n), this.options.onItemsRemoved(r, n, l), this.record(r), r;
3826
+ return this.state.items = dr(this.state.items, n), this.options.onItemsRemoved(r, n, l), this.record(r), r;
3663
3827
  }
3664
3828
  reset() {
3665
3829
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -3670,7 +3834,7 @@ var ir = 20, ar = class {
3670
3834
  this.restoreRemoval(t);
3671
3835
  return;
3672
3836
  }
3673
- let n = new Set(this.state.items.map(({ postId: e }) => e)), r = e.filter(({ item: e }) => n.has(e.postId) ? !1 : (n.add(e.postId), !0)), i = rr(this.state.items, r);
3837
+ let n = new Set(this.state.items.map(({ postId: e }) => e)), r = e.filter(({ item: e }) => n.has(e.postId) ? !1 : (n.add(e.postId), !0)), i = fr(this.state.items, r);
3674
3838
  this.registerExternalPlacements(r), this.state.items = i, r.length > 0 && this.options.onRemovalRestored(r);
3675
3839
  }
3676
3840
  restoreRemoval(e) {
@@ -3696,7 +3860,7 @@ var ir = 20, ar = class {
3696
3860
  }
3697
3861
  collectOrderedPlacements(e) {
3698
3862
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
3699
- return tr(this.state.items, e).map((e) => ({
3863
+ return ur(this.state.items, e).map((e) => ({
3700
3864
  index: t.get(e.item.postId) ?? e.index,
3701
3865
  item: e.item
3702
3866
  }));
@@ -3727,7 +3891,7 @@ var ir = 20, ar = class {
3727
3891
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
3728
3892
  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;
3729
3893
  }
3730
- }, or = class {
3894
+ }, hr = class {
3731
3895
  forward = null;
3732
3896
  forwardPromise = null;
3733
3897
  forwardVersion = 0;
@@ -3814,7 +3978,7 @@ var ir = 20, ar = class {
3814
3978
  }
3815
3979
  }
3816
3980
  }
3817
- }, sr = class {
3981
+ }, gr = class {
3818
3982
  generation = 0;
3819
3983
  pending = Promise.resolve();
3820
3984
  constructor(e) {
@@ -3864,24 +4028,24 @@ var ir = 20, ar = class {
3864
4028
  };
3865
4029
  //#endregion
3866
4030
  //#region src/core/removalControllers.ts
3867
- function cr(e) {
3868
- let t = new or(e), n = new sr({
4031
+ function _r(e) {
4032
+ let t = new hr(e), n = new gr({
3869
4033
  state: e.state,
3870
4034
  transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
3871
4035
  transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
3872
4036
  });
3873
4037
  return {
3874
- exactMediaRemoval: new er({
4038
+ exactMediaRemoval: new lr({
3875
4039
  onActivate: e.onActivate,
3876
4040
  onPostRemoved: (t) => e.onItemsRemoved([t]),
3877
4041
  onPostRestored: (t) => e.onItemsRestored([t]),
3878
4042
  reelForward: t,
3879
4043
  state: e.state
3880
4044
  }),
3881
- itemRemoval: new ar({
4045
+ itemRemoval: new mr({
3882
4046
  historyLimit: e.historyLimit,
3883
4047
  onItemsRemoved: (n, r, i) => {
3884
- e.onItemsRemoved(r.map(({ item: e }) => e.postId)), Zn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
4048
+ e.onItemsRemoved(r.map(({ item: e }) => e.postId)), or(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3885
4049
  },
3886
4050
  onRemovalRestored: (n) => {
3887
4051
  e.onItemsRestored(n.map(({ item: e }) => e.postId));
@@ -3896,17 +4060,17 @@ function cr(e) {
3896
4060
  reelRemoval: n
3897
4061
  };
3898
4062
  }
3899
- var lr = 1.5;
3900
- function ur(e) {
4063
+ var vr = 1.5;
4064
+ function yr(e) {
3901
4065
  let t = Math.min(e.screenWidth, e.screenHeight);
3902
4066
  if (t > 0 && t < 600) return !0;
3903
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * lr;
4067
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * vr;
3904
4068
  return !e.hasHover && n > 0 && n < 600 && r;
3905
4069
  }
3906
- function dr(e) {
3907
- return ur(e) ? "reel" : "masonry";
4070
+ function br(e) {
4071
+ return yr(e) ? "reel" : "masonry";
3908
4072
  }
3909
- function fr(e) {
4073
+ function xr(e) {
3910
4074
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3911
4075
  return {
3912
4076
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3916,15 +4080,15 @@ function fr(e) {
3916
4080
  viewportWidth: n.clientWidth
3917
4081
  };
3918
4082
  }
3919
- function pr(e) {
3920
- return ur(fr(e));
4083
+ function Sr(e) {
4084
+ return yr(xr(e));
3921
4085
  }
3922
- function mr(e) {
3923
- return dr(fr(e));
4086
+ function Cr(e) {
4087
+ return br(xr(e));
3924
4088
  }
3925
4089
  //#endregion
3926
4090
  //#region src/core/responsiveLayoutController.ts
3927
- var hr = class {
4091
+ var wr = class {
3928
4092
  layoutMode;
3929
4093
  resizeObserver = null;
3930
4094
  target = null;
@@ -3949,10 +4113,10 @@ var hr = class {
3949
4113
  }
3950
4114
  handleResponsiveLayout = () => {
3951
4115
  if (!this.target) return;
3952
- let e = mr(this.target);
3953
- this.state.phoneMode = pr(this.target), this.state.reelInfoSheetOverlay = this.state.phoneMode, this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
4116
+ let e = Cr(this.target);
4117
+ this.state.phoneMode = Sr(this.target), this.state.reelInfoSheetOverlay = this.state.phoneMode, this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3954
4118
  };
3955
- }, gr = class {
4119
+ }, Tr = class {
3956
4120
  routedReelPostId = null;
3957
4121
  reelRouteIsActive = !1;
3958
4122
  constructor(e, t) {
@@ -3979,13 +4143,14 @@ var hr = class {
3979
4143
  let i = this.reelRouteIsActive ? "replace" : "push";
3980
4144
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3981
4145
  }
3982
- }, _r = class {
4146
+ }, Er = class {
3983
4147
  app = null;
3984
4148
  autoScroll;
3985
4149
  autofillController;
3986
4150
  abortController = null;
3987
4151
  pendingRequest = null;
3988
4152
  requestVersion = 0;
4153
+ restoreController = null;
3989
4154
  responsiveLayout;
3990
4155
  routing;
3991
4156
  fillController;
@@ -4000,24 +4165,24 @@ var hr = class {
4000
4165
  notificationItems;
4001
4166
  state;
4002
4167
  constructor(e) {
4003
- this.options = e, Gn(e);
4168
+ this.options = e, $n(e);
4004
4169
  let t = e.layout ?? "masonry";
4005
- this.state = x(Hn(e, t)), this.lastLoadedCursor = e.initialPage ? Vt(e.initialPage) : null, this.notificationItems = I(this.state), this.autoScroll = new pn({
4170
+ this.state = x(Xn(e, t)), this.lastLoadedCursor = e.initialPage ? qt(e.initialPage) : null, this.notificationItems = I(this.state), this.autoScroll = new bn({
4006
4171
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
4007
4172
  state: this.state.autoScroll
4008
- }), this.autofillController = new sn({
4173
+ }), this.autofillController = new mn({
4009
4174
  cancelRequest: () => this.cancelRequest(),
4010
4175
  onLastCursor: (e) => this.setCurrentCursor(e),
4011
4176
  onPages: (e) => this.removalReconciliation.recordPages(e),
4012
4177
  options: e.autofill,
4013
4178
  state: this.state
4014
- }), this.removalReconciliation = new Xn(e), this.removalReconciliation.recordInitialPage(e.initialPage), this.fillController = new Nn({
4179
+ }), this.removalReconciliation = new ar(e), this.removalReconciliation.recordInitialPage(e.initialPage), this.fillController = new Vn({
4015
4180
  fill: e.fill,
4016
4181
  loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
4017
4182
  needsFrontendPreparation: () => this.removalReconciliation.needsReconciliation(this.state.items),
4018
4183
  onLastCursor: (e) => this.setCurrentCursor(e),
4019
4184
  onPages: (e) => this.removalReconciliation.recordPages(e),
4020
- prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) => Pn({
4185
+ prepareFrontend: ({ isCurrent: t, onDelayChange: n, signal: r }) => Hn({
4021
4186
  controller: this.removalReconciliation,
4022
4187
  isCurrent: t,
4023
4188
  loadPage: e.loadPage,
@@ -4027,8 +4192,8 @@ var hr = class {
4027
4192
  state: this.state
4028
4193
  }),
4029
4194
  state: this.state
4030
- }), this.routing = new gr(e.routing, this.state);
4031
- let n = cr({
4195
+ }), this.routing = new Tr(e.routing, this.state);
4196
+ let n = _r({
4032
4197
  historyLimit: e.removalHistoryLimit,
4033
4198
  onActivate: (e) => this.setActiveReelPost(e),
4034
4199
  onItemsRemoved: (e) => this.removalReconciliation.remove(e),
@@ -4037,20 +4202,20 @@ var hr = class {
4037
4202
  state: this.state,
4038
4203
  surface: () => this.surface
4039
4204
  });
4040
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new hr(t, this.state, () => {
4205
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new wr(t, this.state, () => {
4041
4206
  this.routing.syncFeed();
4042
4207
  }), this.startStateNotifications();
4043
4208
  }
4044
4209
  async mount() {
4045
4210
  if (this.app) throw Error("Vibe is already mounted.");
4046
4211
  this.startStateNotifications();
4047
- let e = Kn(this.options.target);
4048
- this.responsiveLayout.mount(e), this.app = i(zt, {
4212
+ let e = er(this.options.target);
4213
+ this.responsiveLayout.mount(e), this.app = i(Ht, {
4049
4214
  canRetryEnd: !!this.options.loadPage,
4050
4215
  cardFooter: this.options.cardFooter,
4051
4216
  cardHeader: this.options.cardHeader,
4052
4217
  feedFooter: this.options.feedFooter,
4053
- feedFooterActions: Fn(this),
4218
+ feedFooterActions: Un(this),
4054
4219
  mediaCard: this.options.mediaCard,
4055
4220
  masonry: this.options.masonry,
4056
4221
  onMediaReady: this.options.onMediaReady,
@@ -4073,10 +4238,12 @@ var hr = class {
4073
4238
  onRetryForward: () => {
4074
4239
  this.retryReelForward();
4075
4240
  }
4076
- }), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && !this.state.loadMoreLocked && await this.startInitialAutofill() : await this.reload();
4241
+ }), this.surface = this.app.mount(e), this.autoScroll.mount(), await Tn(this.options.restoreBacklog, (e) => this.appendPage(e), (e) => {
4242
+ this.restoreController = e;
4243
+ }), !this.options.initialPage && this.state.items.length === 0 ? await this.reload() : this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && !this.state.loadMoreLocked && await this.startInitialAutofill();
4077
4244
  }
4078
4245
  destroy() {
4079
- 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;
4246
+ this.restoreController?.abort(), this.restoreController = null, 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;
4080
4247
  }
4081
4248
  getState() {
4082
4249
  return L(this.state);
@@ -4102,6 +4269,9 @@ var hr = class {
4102
4269
  retryReelForward() {
4103
4270
  return this.reelForward.retry();
4104
4271
  }
4272
+ retryFill() {
4273
+ return this.fillController.retry(this.removalReconciliation.hasPendingSession());
4274
+ }
4105
4275
  undoLastRemoval() {
4106
4276
  return this.itemRemoval.undoLast();
4107
4277
  }
@@ -4133,7 +4303,7 @@ var hr = class {
4133
4303
  this.autoScroll.setSpeed(e);
4134
4304
  }
4135
4305
  applyAutofillUpdate(e) {
4136
- let t = gn(this.options.autofill, this.state, e);
4306
+ let t = Cn(this.options.autofill, this.state, e);
4137
4307
  return t && this.autofillController.syncCountdown(), t;
4138
4308
  }
4139
4309
  cancelAutofill() {
@@ -4144,7 +4314,7 @@ var hr = class {
4144
4314
  await this.cancelFill();
4145
4315
  return;
4146
4316
  }
4147
- if (nn(this.state.autofill)) {
4317
+ if (un(this.state.autofill)) {
4148
4318
  await this.cancelAutofill();
4149
4319
  return;
4150
4320
  }
@@ -4158,12 +4328,12 @@ var hr = class {
4158
4328
  }
4159
4329
  async fill(e) {
4160
4330
  if (!this.state.loadMoreLocked) {
4161
- if (this.pendingRequest || nn(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
4331
+ if (this.pendingRequest || un(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
4162
4332
  await this.fillController.start(e);
4163
4333
  }
4164
4334
  }
4165
4335
  restoreAutofillSession(e) {
4166
- let t = _n(this.options.autofill, this.state, e);
4336
+ let t = wn(this.options.autofill, this.state, e);
4167
4337
  return t && this.autofillController.syncCountdown(), t;
4168
4338
  }
4169
4339
  restoreFillSession(e) {
@@ -4172,12 +4342,15 @@ var hr = class {
4172
4342
  loadNext() {
4173
4343
  return this.startLoadMore(() => this.loadNextSequence());
4174
4344
  }
4345
+ appendPage(e) {
4346
+ Jt(e, this.state, this.removalReconciliation, (e) => this.setCurrentCursor(e));
4347
+ }
4175
4348
  replenishAfterRemoval() {
4176
4349
  return this.startLoadMore(() => this.replenishAfterRemovalSequence());
4177
4350
  }
4178
4351
  async startLoadMore(e) {
4179
4352
  if (this.pendingRequest) return this.pendingRequest;
4180
- if (this.state.loadMoreLocked || nn(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
4353
+ if (this.state.loadMoreLocked || un(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
4181
4354
  this.state.isLoadingMore = !0, this.state.nextPageError = null;
4182
4355
  let t = e();
4183
4356
  return this.pendingRequest = t, t.finally(() => {
@@ -4192,12 +4365,12 @@ var hr = class {
4192
4365
  }
4193
4366
  async replaceFeed(e, t) {
4194
4367
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
4195
- return nn(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = tn(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.current = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
4368
+ return un(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = ln(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.current = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
4196
4369
  }
4197
4370
  async loadFilteredPage(e) {
4198
4371
  let t = this.options.loadPage;
4199
4372
  if (!t) throw Error("Vibe cannot load a page without loadPage.");
4200
- let n = Bt(await t(e));
4373
+ let n = Ut(await t(e));
4201
4374
  return {
4202
4375
  ...n,
4203
4376
  items: this.removalReconciliation.filterItems(n.items)
@@ -4216,7 +4389,7 @@ var hr = class {
4216
4389
  let t = ++this.requestVersion, n = new AbortController();
4217
4390
  this.abortController = n;
4218
4391
  try {
4219
- let r = await Pn({
4392
+ let r = await Hn({
4220
4393
  controller: this.removalReconciliation,
4221
4394
  isCurrent: () => t === this.requestVersion,
4222
4395
  loadPage: e,
@@ -4234,7 +4407,7 @@ var hr = class {
4234
4407
  }
4235
4408
  async retryEnd() {
4236
4409
  if (this.pendingRequest) return this.pendingRequest;
4237
- if (!this.state.loadMoreLocked && !(nn(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);
4410
+ if (!this.state.loadMoreLocked && !(un(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);
4238
4411
  }
4239
4412
  setInfiniteScroll(e) {
4240
4413
  this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
@@ -4258,10 +4431,10 @@ var hr = class {
4258
4431
  this.state.total = e;
4259
4432
  }
4260
4433
  setReelAutoAdvance(e) {
4261
- zn(this.state.reelAutoAdvance, e);
4434
+ qn(this.state.reelAutoAdvance, e);
4262
4435
  }
4263
4436
  setReelInfoSheet(e) {
4264
- Vn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
4437
+ Yn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
4265
4438
  }
4266
4439
  setLayout(e) {
4267
4440
  this.responsiveLayout.setLayout(e);
@@ -4281,7 +4454,7 @@ var hr = class {
4281
4454
  async fetchPage(e, t) {
4282
4455
  if (!this.options.loadPage) return;
4283
4456
  let n = ++this.requestVersion, r = new AbortController();
4284
- this.abortController = r, await qn({
4457
+ this.abortController = r, await tr({
4285
4458
  append: t,
4286
4459
  autofillController: this.autofillController,
4287
4460
  cursor: e,
@@ -4303,7 +4476,7 @@ var hr = class {
4303
4476
  startInitialAutofill() {
4304
4477
  let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
4305
4478
  this.abortController = t, this.state.isLoadingMore = !0;
4306
- let r = vn({
4479
+ let r = En({
4307
4480
  cycleId: n,
4308
4481
  isCurrent: () => e === this.requestVersion,
4309
4482
  onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
@@ -4330,8 +4503,8 @@ var hr = class {
4330
4503
  this.lastLoadedCursor = e, this.state.current = e;
4331
4504
  }
4332
4505
  };
4333
- function vr(e) {
4334
- return new _r(e);
4506
+ function Dr(e) {
4507
+ return new Er(e);
4335
4508
  }
4336
4509
  //#endregion
4337
- export { vr as createVibe };
4510
+ export { Dr as createVibe };