@wyxos/vibe 4.5.1 → 4.5.2

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
@@ -1326,8 +1326,9 @@ var Oe = /* @__PURE__ */ u({
1326
1326
  }
1327
1327
  return D(d, (e) => {
1328
1328
  E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(G), E.observe(e)));
1329
- }), D(() => l.items.length, async (e) => {
1330
- h.value = Math.min(h.value, Math.max(0, e - 1)), await p(), G();
1329
+ }), D([() => l.items.length, () => l.initialPostId], async ([e, t]) => {
1330
+ let n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1331
+ h.value = n >= 0 ? n : Math.min(h.value, Math.max(0, e - 1)), await p(), G();
1331
1332
  }), D(F, (e) => {
1332
1333
  e !== void 0 && u("activeChange", e);
1333
1334
  }, { immediate: !0 }), v(() => {
@@ -1796,7 +1797,7 @@ var Oe = /* @__PURE__ */ u({
1796
1797
  function fe(e) {
1797
1798
  let t = u.state.layout === "reel" || u.state.reelOrigin === "masonry";
1798
1799
  if (e.key === "Escape" && u.state.reelOrigin === "masonry") {
1799
- e.preventDefault(), ue();
1800
+ e.preventDefault(), u.state.reelInfoSheetOverlay && u.state.reelInfoSheet.enabled && d("reelInfoSheetChange", !1), ue();
1800
1801
  return;
1801
1802
  }
1802
1803
  if (e.key === "Escape" && t && u.state.reelInfoSheet.enabled) {
@@ -2411,163 +2412,14 @@ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2411
2412
  }));
2412
2413
  }
2413
2414
  //#endregion
2414
- //#region src/core/activeItemRemoval.ts
2415
- function Zt(e, t, n, r, i) {
2416
- let a = new Set(n.map(({ item: e }) => e.postId));
2417
- if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
2418
- if (e.reelOrigin === "masonry") {
2419
- i();
2420
- return;
2421
- }
2422
- let o = e.items[Math.min(Math.max(r, 0), e.items.length - 1)];
2423
- e.activeReelPostId = o?.postId ?? null, o ? t.syncReel(o.postId) : t.syncFeed();
2424
- }
2425
- //#endregion
2426
- //#region src/core/exactMediaRemovalController.ts
2427
- function Qt(e, t) {
2428
- let [n, ...r] = t;
2429
- if (!n) throw Error("Vibe items must contain at least one media asset.");
2430
- return {
2431
- ...e,
2432
- ...n,
2433
- items: r
2434
- };
2435
- }
2436
- function $t(e) {
2437
- if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
2438
- }
2439
- var en = class {
2440
- forward = null;
2441
- forwardPromise = null;
2442
- forwardVersion = 0;
2443
- generation = 0;
2444
- metadata = /* @__PURE__ */ new WeakMap();
2445
- state;
2446
- constructor(e) {
2447
- this.options = e, this.state = e.state;
2448
- }
2449
- remove(e) {
2450
- $t(e);
2451
- let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
2452
- if (!n) return null;
2453
- let r = [...j(n)], i = r[e.mediaIndex];
2454
- if (!i) return null;
2455
- let a = Object.freeze({
2456
- media: i,
2457
- mediaIndex: e.mediaIndex,
2458
- postId: e.postId,
2459
- postIndex: t
2460
- });
2461
- this.metadata.set(a, {
2462
- generation: this.generation,
2463
- originalItem: n,
2464
- restored: !1
2465
- });
2466
- let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
2467
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Qt(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
2468
- }
2469
- reset() {
2470
- this.generation += 1, this.forwardVersion += 1, this.forward = null, this.forwardPromise = null, this.clearForwardState();
2471
- }
2472
- restore(e) {
2473
- let t = this.metadata.get(e);
2474
- if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
2475
- if (t.generation !== this.generation || t.restored) return !1;
2476
- t.restored = !0;
2477
- let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
2478
- return n >= 0 ? this.restoreIntoPost(n, e) : this.state.items.splice(Math.min(e.postIndex, this.state.items.length), 0, t.originalItem), this.forward?.removal === e && this.state.reelForward.status !== "idle" && (this.forwardVersion += 1, this.forward = null, this.clearForwardState(), this.state.mediaIndices.set(e.postId, e.mediaIndex), this.options.onActivate(e.postId)), !0;
2479
- }
2480
- retryForward() {
2481
- return !this.forward || this.state.reelForward.status === "idle" ? Promise.resolve() : (this.state.nextPageError = null, this.state.reelForward = {
2482
- error: null,
2483
- status: "loading"
2484
- }, this.startForwardRequest(this.state.next === null));
2485
- }
2486
- advanceFromRemovedPost(e, t) {
2487
- let n = this.state.items[e.postIndex];
2488
- if (n) {
2489
- this.options.onActivate(n.postId);
2490
- return;
2491
- }
2492
- this.forward = {
2493
- postIndex: e.postIndex,
2494
- removal: e,
2495
- version: ++this.forwardVersion
2496
- }, this.state.reelForward = {
2497
- error: null,
2498
- status: "loading"
2499
- }, this.state.reelForwardIndex = e.postIndex, this.state.reelForwardItem = t, this.startForwardRequest(!1);
2500
- }
2501
- clearForwardState() {
2502
- this.state.reelForward = {
2503
- error: null,
2504
- status: "idle"
2505
- }, this.state.reelForwardIndex = null, this.state.reelForwardItem = null;
2506
- }
2507
- isReelOpen() {
2508
- return this.state.layout === "reel" || this.state.reelOrigin === "masonry";
2509
- }
2510
- restoreIntoPost(e, t) {
2511
- let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
2512
- if (r.splice(i, 0, t.media), this.state.items[e] = Qt(n, r), this.state.activeReelPostId !== t.postId) return;
2513
- let a = this.state.mediaIndices.get(t.postId) ?? 0;
2514
- a >= i && this.state.mediaIndices.set(t.postId, a + 1);
2515
- }
2516
- startForwardRequest(e) {
2517
- if (this.forwardPromise) return this.forwardPromise;
2518
- let t = this.loadForward(e);
2519
- return this.forwardPromise = t, t.finally(() => {
2520
- this.forwardPromise === t && (this.forwardPromise = null, this.forward && this.state.reelForward.status === "loading" && this.startForwardRequest(!1));
2521
- });
2522
- }
2523
- async loadForward(e) {
2524
- let t = this.forward;
2525
- if (t) for (e && await this.options.retryEnd(); this.forward === t && t.version === this.forwardVersion;) {
2526
- let e = this.state.items[t.postIndex];
2527
- if (e) {
2528
- this.forward = null, this.clearForwardState(), this.options.onActivate(e.postId);
2529
- return;
2530
- }
2531
- if (this.state.nextPageError) {
2532
- this.state.reelForward = {
2533
- error: this.state.nextPageError,
2534
- status: "error"
2535
- };
2536
- return;
2537
- }
2538
- if (this.state.next === null) {
2539
- this.state.reelForward = {
2540
- error: null,
2541
- status: "end"
2542
- };
2543
- return;
2544
- }
2545
- let n = this.state.next;
2546
- if (await this.options.loadNext(), this.state.next === n && !this.state.nextPageError && !this.state.items[t.postIndex]) {
2547
- this.state.reelForward = {
2548
- error: /* @__PURE__ */ Error("Vibe could not advance while page loading is unavailable."),
2549
- status: "error"
2550
- };
2551
- return;
2552
- }
2553
- }
2554
- }
2555
- updateMediaIndexAfterRemoval(e, t, n) {
2556
- let r = this.state.items.find((t) => t.postId === e);
2557
- if (!r) return;
2558
- let i = j(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
2559
- n ? o = t < i ? t : 0 : t < a && (o = a - 1), this.state.mediaIndices.set(e, Math.min(o, i - 1));
2560
- }
2561
- };
2562
- //#endregion
2563
2415
  //#region src/core/fill.ts
2564
- function tn(e) {
2416
+ function Zt(e) {
2565
2417
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2566
2418
  }
2567
- function nn(e) {
2419
+ function Qt(e) {
2568
2420
  return `${typeof e}:${String(e)}`;
2569
2421
  }
2570
- function rn(e) {
2422
+ function $t(e) {
2571
2423
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2572
2424
  if ("pages" in e) {
2573
2425
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2576,7 +2428,7 @@ function rn(e) {
2576
2428
  if ("until" in e && e.until === "end") return { until: "end" };
2577
2429
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2578
2430
  }
2579
- function an(e) {
2431
+ function en(e) {
2580
2432
  if (!e) return;
2581
2433
  if (e.strategy === "frontend") {
2582
2434
  Dt(e, "frontend fill");
@@ -2586,10 +2438,10 @@ function an(e) {
2586
2438
  let t = e.initialSession;
2587
2439
  if (t) {
2588
2440
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2589
- rn(t.target);
2441
+ $t(t.target);
2590
2442
  }
2591
2443
  }
2592
- function on(e, t, n = !0) {
2444
+ function tn(e, t, n = !0) {
2593
2445
  let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2594
2446
  return {
2595
2447
  completedPages: i?.completedPages ?? 0,
@@ -2603,10 +2455,10 @@ function on(e, t, n = !0) {
2603
2455
  sessionId: i?.sessionId ?? null,
2604
2456
  status: i?.status ?? "idle",
2605
2457
  strategy: e?.strategy ?? null,
2606
- target: i ? tn(i.target) : null
2458
+ target: i ? Zt(i.target) : null
2607
2459
  };
2608
2460
  }
2609
- function sn(e) {
2461
+ function nn(e) {
2610
2462
  return [
2611
2463
  "cancelling",
2612
2464
  "filling",
@@ -2614,10 +2466,10 @@ function sn(e) {
2614
2466
  "waiting"
2615
2467
  ].includes(e.status);
2616
2468
  }
2617
- async function cn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2469
+ async function rn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2618
2470
  let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2619
2471
  for (; p !== null;) {
2620
- let e = nn(f);
2472
+ let e = Qt(f);
2621
2473
  if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2622
2474
  u.add(e), await kt({
2623
2475
  delayMs: Ot(d, a),
@@ -2666,7 +2518,7 @@ async function cn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
2666
2518
  }
2667
2519
  //#endregion
2668
2520
  //#region src/core/backendFill.ts
2669
- async function ln(e, t, n, r) {
2521
+ async function an(e, t, n, r) {
2670
2522
  let i = await e.onStart(n);
2671
2523
  if (r()) {
2672
2524
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
@@ -2680,22 +2532,22 @@ async function ln(e, t, n, r) {
2680
2532
  });
2681
2533
  }
2682
2534
  }
2683
- function un(e, t, n) {
2535
+ function on(e, t, n) {
2684
2536
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2685
2537
  }
2686
- function dn(e) {
2538
+ function sn(e) {
2687
2539
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2688
2540
  }
2689
- function fn(e, t) {
2541
+ function cn(e, t) {
2690
2542
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2691
2543
  let n = e.fill.target;
2692
2544
  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;
2693
2545
  }
2694
- function pn(e, t, n) {
2546
+ function ln(e, t, n) {
2695
2547
  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));
2696
2548
  }
2697
- function mn(e, t, n, r) {
2698
- return !un(e, t, n) || !dn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !fn(t, n) ? !1 : (pn(t, n, r), Object.assign(t.fill, {
2549
+ function un(e, t, n, r) {
2550
+ return !on(e, t, n) || !sn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !cn(t, n) ? !1 : (ln(t, n, r), Object.assign(t.fill, {
2699
2551
  ...$(n.status === "waiting" ? n.nextRequestAt : null),
2700
2552
  completedPages: n.completedPages,
2701
2553
  error: n.error ?? null,
@@ -2704,14 +2556,14 @@ function mn(e, t, n, r) {
2704
2556
  status: n.status
2705
2557
  }), !0);
2706
2558
  }
2707
- function hn(e, t, n, r) {
2559
+ function dn(e, t, n, r) {
2708
2560
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2709
2561
  let i = t.fill;
2710
- return t.fill = on(e, n), !dn(n) || !fn(t, n) ? (t.fill = i, !1) : (pn(t, n, r), !0);
2562
+ return t.fill = tn(e, n), !sn(n) || !cn(t, n) ? (t.fill = i, !1) : (ln(t, n, r), !0);
2711
2563
  }
2712
2564
  //#endregion
2713
2565
  //#region src/core/fillController.ts
2714
- var gn = class {
2566
+ var fn = class {
2715
2567
  abortController = null;
2716
2568
  cycle = 0;
2717
2569
  delayCountdown;
@@ -2722,23 +2574,23 @@ var gn = class {
2722
2574
  }), this.syncBackendCountdown();
2723
2575
  }
2724
2576
  isActive() {
2725
- return sn(this.options.state.fill);
2577
+ return nn(this.options.state.fill);
2726
2578
  }
2727
2579
  applyUpdate(e) {
2728
- let t = mn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2580
+ let t = un(this.options.fill, this.options.state, e, this.options.onLastCursor);
2729
2581
  return t && this.syncBackendCountdown(), t;
2730
2582
  }
2731
2583
  restoreSession(e) {
2732
- let t = hn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2584
+ let t = dn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2733
2585
  return t && this.syncBackendCountdown(), t;
2734
2586
  }
2735
2587
  async start(e) {
2736
2588
  let t = this.options.fill;
2737
2589
  if (!t) throw Error("Vibe fill is not configured.");
2738
2590
  if (this.isActive()) throw Error("Vibe fill is already active.");
2739
- let n = rn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2591
+ let n = $t(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2740
2592
  if (this.options.state.fill = {
2741
- ...on(t, void 0, !1),
2593
+ ...tn(t, void 0, !1),
2742
2594
  cycleId: r,
2743
2595
  status: "filling",
2744
2596
  target: n
@@ -2749,7 +2601,7 @@ var gn = class {
2749
2601
  let i = ++this.requestVersion, a = new AbortController();
2750
2602
  this.abortController = a;
2751
2603
  try {
2752
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await ln(t, this.options.state, {
2604
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await an(t, this.options.state, {
2753
2605
  cycleId: r,
2754
2606
  feedKey: t.feedKey,
2755
2607
  items: [...this.options.state.items],
@@ -2767,7 +2619,7 @@ var gn = class {
2767
2619
  }
2768
2620
  async cancel() {
2769
2621
  let { fill: e, state: t } = this.options;
2770
- if (!sn(t.fill) || !t.fill.cycleId) return;
2622
+ if (!nn(t.fill) || !t.fill.cycleId) return;
2771
2623
  let n = {
2772
2624
  cycleId: t.fill.cycleId,
2773
2625
  feedKey: t.fill.feedKey ?? "",
@@ -2781,7 +2633,7 @@ var gn = class {
2781
2633
  }
2782
2634
  }
2783
2635
  reset() {
2784
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = on(this.options.fill, void 0, !1);
2636
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = tn(this.options.fill, void 0, !1);
2785
2637
  }
2786
2638
  destroy() {
2787
2639
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2797,7 +2649,7 @@ var gn = class {
2797
2649
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2798
2650
  let a = this.options.state;
2799
2651
  a.isLoadingMore = !0;
2800
- let o = await cn({
2652
+ let o = await rn({
2801
2653
  existingItems: a.items,
2802
2654
  initialCursor: a.next,
2803
2655
  loadPage: i,
@@ -2824,7 +2676,7 @@ var gn = class {
2824
2676
  };
2825
2677
  //#endregion
2826
2678
  //#region src/core/feedFooter.ts
2827
- function _n(e) {
2679
+ function pn(e) {
2828
2680
  return {
2829
2681
  cancelAutofill: () => e.cancelAutofill(),
2830
2682
  loadMore: () => e.loadNext(),
@@ -2832,45 +2684,45 @@ function _n(e) {
2832
2684
  retryEnd: () => e.retryEnd()
2833
2685
  };
2834
2686
  }
2835
- function vn(e) {
2687
+ function mn(e) {
2836
2688
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2837
2689
  }
2838
- function yn(e) {
2839
- e?.intervalMs !== void 0 && vn(e.intervalMs);
2690
+ function hn(e) {
2691
+ e?.intervalMs !== void 0 && mn(e.intervalMs);
2840
2692
  }
2841
- function bn(e) {
2693
+ function gn(e) {
2842
2694
  return {
2843
2695
  enabled: e?.enabled ?? !1,
2844
2696
  includePostItems: e?.includePostItems ?? !1,
2845
2697
  intervalMs: e?.intervalMs ?? 5e3
2846
2698
  };
2847
2699
  }
2848
- function xn(e, t) {
2700
+ function _n(e, t) {
2849
2701
  if (typeof t == "boolean") {
2850
2702
  e.enabled = t;
2851
2703
  return;
2852
2704
  }
2853
- yn(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);
2705
+ hn(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);
2854
2706
  }
2855
2707
  //#endregion
2856
2708
  //#region src/core/reelInfoSheet.ts
2857
- function Sn(e) {
2709
+ function vn(e) {
2858
2710
  return { enabled: e?.enabled ?? !1 };
2859
2711
  }
2860
- function Cn(e, t, n) {
2712
+ function yn(e, t, n) {
2861
2713
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2862
2714
  e.enabled = n;
2863
2715
  }
2864
2716
  //#endregion
2865
2717
  //#region src/core/initialRuntimeState.ts
2866
- function wn(e, t) {
2718
+ function bn(e, t) {
2867
2719
  let n = e.initialPage;
2868
2720
  return {
2869
2721
  activeReelPostId: null,
2870
2722
  autoScroll: Wt(e.autoScroll),
2871
2723
  autofill: Ft(e.autofill),
2872
2724
  error: null,
2873
- fill: on(e.fill),
2725
+ fill: tn(e.fill),
2874
2726
  infiniteScroll: e.infiniteScroll ?? !0,
2875
2727
  isLoading: !n,
2876
2728
  isLoadingMore: !1,
@@ -2880,14 +2732,14 @@ function wn(e, t) {
2880
2732
  mediaIndices: /* @__PURE__ */ new Map(),
2881
2733
  next: n?.next ?? null,
2882
2734
  nextPageError: null,
2883
- reelAutoAdvance: bn(e.reelAutoAdvance),
2735
+ reelAutoAdvance: gn(e.reelAutoAdvance),
2884
2736
  reelForward: {
2885
2737
  error: null,
2886
2738
  status: "idle"
2887
2739
  },
2888
2740
  reelForwardIndex: null,
2889
2741
  reelForwardItem: null,
2890
- reelInfoSheet: Sn(e.reelInfoSheet),
2742
+ reelInfoSheet: vn(e.reelInfoSheet),
2891
2743
  reelInfoSheetOverlay: !1,
2892
2744
  reelMediaSource: "original",
2893
2745
  reelOrigin: null,
@@ -2895,19 +2747,136 @@ function wn(e, t) {
2895
2747
  };
2896
2748
  }
2897
2749
  //#endregion
2750
+ //#region src/core/options.ts
2751
+ function xn(e, t) {
2752
+ if (t) {
2753
+ if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
2754
+ if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
2755
+ }
2756
+ }
2757
+ function Sn(e, t) {
2758
+ if (t) {
2759
+ if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
2760
+ 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.`);
2761
+ }
2762
+ }
2763
+ function Cn(e) {
2764
+ if (Ut(e.autoScroll), xn("cardHeader", e.cardHeader), xn("cardFooter", e.cardFooter), Sn("header", e.mediaCard?.header), Sn("footer", e.mediaCard?.footer), Pt(e.autofill), en(e.fill), hn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2765
+ if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2766
+ if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2767
+ if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
2768
+ if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
2769
+ }
2770
+ function wn(e) {
2771
+ if (typeof e != "string") return e;
2772
+ if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
2773
+ let t = document.querySelector(e);
2774
+ if (!t) throw Error(`Vibe target not found: ${e}`);
2775
+ return t;
2776
+ }
2777
+ //#endregion
2778
+ //#region src/core/activeItemRemoval.ts
2779
+ function Tn(e, t, n, r, i) {
2780
+ let a = new Set(t.map(({ item: e }) => e.postId));
2781
+ if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
2782
+ let o = e.items[Math.max(n, 0)];
2783
+ if (o) {
2784
+ r(o.postId);
2785
+ return;
2786
+ }
2787
+ let s = t.find(({ item: t }) => t.postId === e.activeReelPostId)?.item;
2788
+ s && i(Math.max(n, 0), s);
2789
+ }
2790
+ //#endregion
2791
+ //#region src/core/exactMediaRemovalController.ts
2792
+ function En(e, t) {
2793
+ let [n, ...r] = t;
2794
+ if (!n) throw Error("Vibe items must contain at least one media asset.");
2795
+ return {
2796
+ ...e,
2797
+ ...n,
2798
+ items: r
2799
+ };
2800
+ }
2801
+ function Dn(e) {
2802
+ if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
2803
+ }
2804
+ var On = class {
2805
+ generation = 0;
2806
+ metadata = /* @__PURE__ */ new WeakMap();
2807
+ state;
2808
+ constructor(e) {
2809
+ this.options = e, this.state = e.state;
2810
+ }
2811
+ remove(e) {
2812
+ Dn(e);
2813
+ let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
2814
+ if (!n) return null;
2815
+ let r = [...j(n)], i = r[e.mediaIndex];
2816
+ if (!i) return null;
2817
+ let a = Object.freeze({
2818
+ media: i,
2819
+ mediaIndex: e.mediaIndex,
2820
+ postId: e.postId,
2821
+ postIndex: t
2822
+ });
2823
+ this.metadata.set(a, {
2824
+ generation: this.generation,
2825
+ originalItem: n,
2826
+ restored: !1
2827
+ });
2828
+ let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
2829
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = En(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
2830
+ }
2831
+ reset() {
2832
+ this.generation += 1;
2833
+ }
2834
+ restore(e) {
2835
+ let t = this.metadata.get(e);
2836
+ if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
2837
+ if (t.generation !== this.generation || t.restored) return !1;
2838
+ t.restored = !0;
2839
+ let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
2840
+ return n >= 0 ? this.restoreIntoPost(n, e) : this.state.items.splice(Math.min(e.postIndex, this.state.items.length), 0, t.originalItem), this.options.reelForward.cancel(e) && (this.state.mediaIndices.set(e.postId, e.mediaIndex), this.options.onActivate(e.postId)), !0;
2841
+ }
2842
+ advanceFromRemovedPost(e, t) {
2843
+ let n = this.state.items[e.postIndex];
2844
+ if (n) {
2845
+ this.options.onActivate(n.postId);
2846
+ return;
2847
+ }
2848
+ this.options.reelForward.start(e, e.postIndex, t);
2849
+ }
2850
+ isReelOpen() {
2851
+ return this.state.layout === "reel" || this.state.reelOrigin === "masonry";
2852
+ }
2853
+ restoreIntoPost(e, t) {
2854
+ let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
2855
+ if (r.splice(i, 0, t.media), this.state.items[e] = En(n, r), this.state.activeReelPostId !== t.postId) return;
2856
+ let a = this.state.mediaIndices.get(t.postId) ?? 0;
2857
+ a >= i && this.state.mediaIndices.set(t.postId, a + 1);
2858
+ }
2859
+ updateMediaIndexAfterRemoval(e, t, n) {
2860
+ let r = this.state.items.find((t) => t.postId === e);
2861
+ if (!r) return;
2862
+ let i = j(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
2863
+ n ? o = t < i ? t : 0 : t < a && (o = a - 1), this.state.mediaIndices.set(e, Math.min(o, i - 1));
2864
+ }
2865
+ };
2866
+ //#endregion
2898
2867
  //#region src/core/itemPlacement.ts
2899
- function Tn(e, t) {
2868
+ function kn(e, t) {
2900
2869
  let n = new Set(t);
2901
2870
  return e.flatMap((e, t) => n.has(e.postId) ? [{
2902
2871
  index: t,
2903
2872
  item: e
2904
2873
  }] : []);
2905
2874
  }
2906
- function En(e, t) {
2875
+ function An(e, t) {
2907
2876
  let n = new Set(t.map(({ item: e }) => e.postId));
2908
2877
  return e.filter((e) => !n.has(e.postId));
2909
2878
  }
2910
- function Dn(e, t) {
2879
+ function jn(e, t) {
2911
2880
  t.forEach(({ index: e }) => {
2912
2881
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
2913
2882
  });
@@ -2918,7 +2887,7 @@ function Dn(e, t) {
2918
2887
  }
2919
2888
  //#endregion
2920
2889
  //#region src/core/itemRemovalController.ts
2921
- var On = 20, kn = class {
2890
+ var Mn = 20, Nn = class {
2922
2891
  generation = 0;
2923
2892
  historyLimit;
2924
2893
  metadata = /* @__PURE__ */ new WeakMap();
@@ -2927,7 +2896,7 @@ var On = 20, kn = class {
2927
2896
  itemOrder;
2928
2897
  stopItemsWatcher;
2929
2898
  constructor(e) {
2930
- this.options = e, this.historyLimit = e.historyLimit ?? On, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
2899
+ this.options = e, this.historyLimit = e.historyLimit ?? Mn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
2931
2900
  }
2932
2901
  destroy() {
2933
2902
  this.reset(), this.stopItemsWatcher();
@@ -2937,8 +2906,8 @@ var On = 20, kn = class {
2937
2906
  if (t.length === 0) return n;
2938
2907
  let r = t.map(({ item: e }) => e.postId), i = this.options.startRemoval(r);
2939
2908
  if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
2940
- let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId);
2941
- return this.state.items = En(this.state.items, t), this.options.onItemsRemoved(t, a), this.record(n), n;
2909
+ let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), o = new Set(t.map(({ item: e }) => e.postId)), s = a < 0 ? 0 : this.state.items.slice(0, a).filter(({ postId: e }) => o.has(e)).length, c = Math.max(a - s, 0);
2910
+ return this.state.items = An(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
2942
2911
  }
2943
2912
  reset() {
2944
2913
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -2949,13 +2918,16 @@ var On = 20, kn = class {
2949
2918
  this.restoreRemoval(t);
2950
2919
  return;
2951
2920
  }
2952
- let n = Dn(this.state.items, e);
2921
+ let n = jn(this.state.items, e);
2953
2922
  this.registerExternalPlacements(e), this.state.items = n;
2954
2923
  }
2955
2924
  restoreRemoval(e) {
2956
2925
  let t = this.metadata.get(e);
2957
2926
  if (!t) throw TypeError("Vibe removal does not belong to this instance.");
2958
- return t.generation !== this.generation || t.restored ? !1 : (t.restored = !0, this.removeFromHistory(e), this.restoreOrderedPlacements(e));
2927
+ if (t.generation !== this.generation || t.restored) return !1;
2928
+ t.restored = !0, this.removeFromHistory(e);
2929
+ let n = this.restoreOrderedPlacements(e);
2930
+ return n && this.options.onRemovalRestored(e), n;
2959
2931
  }
2960
2932
  undoLast() {
2961
2933
  for (; this.history.length > 0;) {
@@ -2972,7 +2944,7 @@ var On = 20, kn = class {
2972
2944
  }
2973
2945
  collectOrderedPlacements(e) {
2974
2946
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
2975
- return Tn(this.state.items, e).map((e) => ({
2947
+ return kn(this.state.items, e).map((e) => ({
2976
2948
  index: t.get(e.item.postId) ?? e.index,
2977
2949
  item: e.item
2978
2950
  }));
@@ -3003,46 +2975,121 @@ var On = 20, kn = class {
3003
2975
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
3004
2976
  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;
3005
2977
  }
3006
- };
3007
- //#endregion
3008
- //#region src/core/options.ts
3009
- function An(e, t) {
3010
- if (t) {
3011
- if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
3012
- if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
2978
+ }, Pn = class {
2979
+ forward = null;
2980
+ forwardPromise = null;
2981
+ forwardVersion = 0;
2982
+ state;
2983
+ constructor(e) {
2984
+ this.options = e, this.state = e.state;
3013
2985
  }
3014
- }
3015
- function jn(e, t) {
3016
- if (t) {
3017
- if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
3018
- 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.`);
2986
+ start(e, t, n) {
2987
+ this.forward = {
2988
+ item: n,
2989
+ postIndex: t,
2990
+ token: e,
2991
+ version: ++this.forwardVersion
2992
+ }, this.state.reelForward = {
2993
+ error: null,
2994
+ status: "loading"
2995
+ }, this.state.reelForwardIndex = t, this.state.reelForwardItem = n, this.startForwardRequest(!1);
3019
2996
  }
3020
- }
3021
- function Mn(e) {
3022
- if (Ut(e.autoScroll), An("cardHeader", e.cardHeader), An("cardFooter", e.cardFooter), jn("header", e.mediaCard?.header), jn("footer", e.mediaCard?.footer), Pt(e.autofill), an(e.fill), yn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
3023
- if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
3024
- if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
3025
- if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
3026
- if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
3027
- }
3028
- function Nn(e) {
3029
- if (typeof e != "string") return e;
3030
- if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
3031
- let t = document.querySelector(e);
3032
- if (!t) throw Error(`Vibe target not found: ${e}`);
3033
- return t;
3034
- }
3035
- var Pn = 1.5;
2997
+ cancel(e) {
2998
+ if (this.forward?.token !== e || this.state.reelForward.status === "idle") return null;
2999
+ let t = this.forward.item;
3000
+ return this.forwardVersion += 1, this.forward = null, this.clearState(), t;
3001
+ }
3002
+ reset() {
3003
+ this.forwardVersion += 1, this.forward = null, this.forwardPromise = null, this.clearState();
3004
+ }
3005
+ retry() {
3006
+ return !this.forward || this.state.reelForward.status === "idle" ? Promise.resolve() : (this.state.nextPageError = null, this.state.reelForward = {
3007
+ error: null,
3008
+ status: "loading"
3009
+ }, this.startForwardRequest(this.state.next === null));
3010
+ }
3011
+ clearState() {
3012
+ this.state.reelForward = {
3013
+ error: null,
3014
+ status: "idle"
3015
+ }, this.state.reelForwardIndex = null, this.state.reelForwardItem = null;
3016
+ }
3017
+ startForwardRequest(e) {
3018
+ if (this.forwardPromise) return this.forwardPromise;
3019
+ let t = this.loadForward(e);
3020
+ return this.forwardPromise = t, t.finally(() => {
3021
+ this.forwardPromise === t && (this.forwardPromise = null, this.forward && this.state.reelForward.status === "loading" && this.startForwardRequest(!1));
3022
+ });
3023
+ }
3024
+ async loadForward(e) {
3025
+ let t = this.forward;
3026
+ if (t) for (e && await this.options.retryEnd(); this.forward === t && t.version === this.forwardVersion;) {
3027
+ let e = this.state.items[t.postIndex];
3028
+ if (e) {
3029
+ this.forward = null, this.clearState(), this.options.onActivate(e.postId);
3030
+ return;
3031
+ }
3032
+ if (this.state.nextPageError) {
3033
+ this.state.reelForward = {
3034
+ error: this.state.nextPageError,
3035
+ status: "error"
3036
+ };
3037
+ return;
3038
+ }
3039
+ if (this.state.next === null) {
3040
+ this.state.reelForward = {
3041
+ error: null,
3042
+ status: "end"
3043
+ };
3044
+ return;
3045
+ }
3046
+ let n = this.state.next;
3047
+ if (await this.options.loadNext(), this.state.next === n && !this.state.nextPageError && !this.state.items[t.postIndex]) {
3048
+ this.state.reelForward = {
3049
+ error: /* @__PURE__ */ Error("Vibe could not advance while page loading is unavailable."),
3050
+ status: "error"
3051
+ };
3052
+ return;
3053
+ }
3054
+ }
3055
+ }
3056
+ };
3057
+ //#endregion
3058
+ //#region src/core/removalControllers.ts
3036
3059
  function Fn(e) {
3060
+ let t = new Pn(e);
3061
+ return {
3062
+ exactMediaRemoval: new On({
3063
+ onActivate: e.onActivate,
3064
+ reelForward: t,
3065
+ state: e.state
3066
+ }),
3067
+ itemRemoval: new Nn({
3068
+ historyLimit: e.historyLimit,
3069
+ onItemsRemoved: (n, r, i) => {
3070
+ Tn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3071
+ },
3072
+ onRemovalRestored: (n) => {
3073
+ let r = t.cancel(n);
3074
+ r && e.onActivate(r.postId);
3075
+ },
3076
+ startRemoval: e.startRemoval,
3077
+ state: e.state
3078
+ }),
3079
+ reelForward: t
3080
+ };
3081
+ }
3082
+ var In = 1.5;
3083
+ function Ln(e) {
3037
3084
  let t = Math.min(e.screenWidth, e.screenHeight);
3038
3085
  if (t > 0 && t < 600) return !0;
3039
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Pn;
3086
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * In;
3040
3087
  return !e.hasHover && n > 0 && n < 600 && r;
3041
3088
  }
3042
- function In(e) {
3043
- return Fn(e) ? "reel" : "masonry";
3089
+ function Rn(e) {
3090
+ return Ln(e) ? "reel" : "masonry";
3044
3091
  }
3045
- function Ln(e) {
3092
+ function zn(e) {
3046
3093
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3047
3094
  return {
3048
3095
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3052,15 +3099,15 @@ function Ln(e) {
3052
3099
  viewportWidth: n.clientWidth
3053
3100
  };
3054
3101
  }
3055
- function Rn(e) {
3056
- return Fn(Ln(e));
3102
+ function Bn(e) {
3103
+ return Ln(zn(e));
3057
3104
  }
3058
- function zn(e) {
3059
- return In(Ln(e));
3105
+ function Vn(e) {
3106
+ return Rn(zn(e));
3060
3107
  }
3061
3108
  //#endregion
3062
3109
  //#region src/core/responsiveLayoutController.ts
3063
- var Bn = class {
3110
+ var Hn = class {
3064
3111
  layoutMode;
3065
3112
  resizeObserver = null;
3066
3113
  target = null;
@@ -3085,10 +3132,10 @@ var Bn = class {
3085
3132
  }
3086
3133
  handleResponsiveLayout = () => {
3087
3134
  if (!this.target) return;
3088
- let e = zn(this.target);
3089
- this.state.reelInfoSheetOverlay = Rn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3135
+ let e = Vn(this.target);
3136
+ this.state.reelInfoSheetOverlay = Bn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3090
3137
  };
3091
- }, Vn = class {
3138
+ }, Un = class {
3092
3139
  routedReelPostId = null;
3093
3140
  reelRouteIsActive = !1;
3094
3141
  constructor(e, t) {
@@ -3115,7 +3162,7 @@ var Bn = class {
3115
3162
  let i = this.reelRouteIsActive ? "replace" : "push";
3116
3163
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3117
3164
  }
3118
- }, Hn = class {
3165
+ }, Wn = class {
3119
3166
  app = null;
3120
3167
  autoScroll;
3121
3168
  autofillDelayCountdown;
@@ -3128,53 +3175,53 @@ var Bn = class {
3128
3175
  fillController;
3129
3176
  exactMediaRemoval;
3130
3177
  itemRemoval;
3178
+ reelForward;
3131
3179
  surface = null;
3132
3180
  stopStateWatcher = null;
3133
3181
  lastLoadedCursor = null;
3134
3182
  state;
3135
3183
  constructor(e) {
3136
- this.options = e, Mn(e);
3184
+ this.options = e, Cn(e);
3137
3185
  let t = e.layout ?? "masonry";
3138
- this.state = b(wn(e, t)), this.autoScroll = new Gt({
3186
+ this.state = b(bn(e, t)), this.autoScroll = new Gt({
3139
3187
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
3140
3188
  state: this.state.autoScroll
3141
- }), this.autofillDelayCountdown = new At((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new gn({
3189
+ }), this.autofillDelayCountdown = new At((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new fn({
3142
3190
  fill: e.fill,
3143
3191
  loadPage: e.loadPage,
3144
3192
  onLastCursor: (e) => {
3145
3193
  this.lastLoadedCursor = e;
3146
3194
  },
3147
3195
  state: this.state
3148
- }), this.routing = new Vn(e.routing, this.state), this.exactMediaRemoval = new en({
3196
+ }), this.routing = new Un(e.routing, this.state);
3197
+ let n = Fn({
3198
+ historyLimit: e.removalHistoryLimit,
3149
3199
  loadNext: () => this.loadNext(),
3150
3200
  onActivate: (e) => this.setActiveReelPost(e),
3151
3201
  retryEnd: () => this.retryEnd(),
3152
- state: this.state
3153
- }), this.itemRemoval = new kn({
3154
- historyLimit: e.removalHistoryLimit,
3155
- onItemsRemoved: (e, t) => {
3156
- Zt(this.state, this.routing, e, t, () => this.closeMasonryReel());
3157
- },
3158
3202
  startRemoval: (e) => this.surface?.startItemRemoval(e) ?? 0,
3159
3203
  state: this.state
3160
- }), this.responsiveLayout = new Bn(t, this.state, () => {
3204
+ });
3205
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.responsiveLayout = new Hn(t, this.state, () => {
3161
3206
  this.routing.syncFeed();
3162
3207
  }), this.startStateNotifications();
3163
3208
  }
3164
3209
  async mount() {
3165
3210
  if (this.app) throw Error("Vibe is already mounted.");
3166
3211
  this.startStateNotifications();
3167
- let e = Nn(this.options.target);
3212
+ let e = wn(this.options.target);
3168
3213
  this.responsiveLayout.mount(e), this.app = r(bt, {
3169
3214
  canRetryEnd: !!this.options.loadPage,
3170
3215
  cardFooter: this.options.cardFooter,
3171
3216
  cardHeader: this.options.cardHeader,
3172
3217
  feedFooter: this.options.feedFooter,
3173
- feedFooterActions: _n(this),
3218
+ feedFooterActions: pn(this),
3174
3219
  mediaCard: this.options.mediaCard,
3175
3220
  reelInfoSheet: this.options.reelInfoSheet,
3176
3221
  state: this.state,
3177
- onActiveReelChange: (e) => this.setActiveReelPost(e),
3222
+ onActiveReelChange: (e) => {
3223
+ this.state.reelForward.status === "idle" && this.setActiveReelPost(e);
3224
+ },
3178
3225
  onCloseReel: () => this.closeMasonryReel(),
3179
3226
  onLoadMore: () => {
3180
3227
  this.loadNext();
@@ -3190,7 +3237,7 @@ var Bn = class {
3190
3237
  }), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && await this.startInitialAutofill() : await this.reload();
3191
3238
  }
3192
3239
  destroy() {
3193
- this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3240
+ this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3194
3241
  }
3195
3242
  getState() {
3196
3243
  return F(this.state);
@@ -3211,7 +3258,7 @@ var Bn = class {
3211
3258
  return this.itemRemoval.restoreRemoval(e);
3212
3259
  }
3213
3260
  retryReelForward() {
3214
- return this.exactMediaRemoval.retryForward();
3261
+ return this.reelForward.retry();
3215
3262
  }
3216
3263
  undoLastRemoval() {
3217
3264
  return this.itemRemoval.undoLast();
@@ -3276,7 +3323,7 @@ var Bn = class {
3276
3323
  }
3277
3324
  async replaceFeed(e, t) {
3278
3325
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
3279
- return It(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Ft(this.options.autofill, void 0, !1), this.fillController.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3326
+ return It(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Ft(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3280
3327
  }
3281
3328
  async retryEnd() {
3282
3329
  if (this.pendingRequest) return this.pendingRequest;
@@ -3289,10 +3336,10 @@ var Bn = class {
3289
3336
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
3290
3337
  }
3291
3338
  setReelAutoAdvance(e) {
3292
- xn(this.state.reelAutoAdvance, e);
3339
+ _n(this.state.reelAutoAdvance, e);
3293
3340
  }
3294
3341
  setReelInfoSheet(e) {
3295
- Cn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3342
+ yn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3296
3343
  }
3297
3344
  setLayout(e) {
3298
3345
  this.responsiveLayout.setLayout(e);
@@ -3420,8 +3467,8 @@ var Bn = class {
3420
3467
  }));
3421
3468
  }
3422
3469
  };
3423
- function Un(e) {
3424
- return new Hn(e);
3470
+ function Gn(e) {
3471
+ return new Wn(e);
3425
3472
  }
3426
3473
  //#endregion
3427
- export { Un as createVibe };
3474
+ export { Gn as createVibe };