@wyxos/vibe 5.1.0 → 5.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -282,7 +282,7 @@ var le = ["aria-hidden"], J = [
282
282
  "aria-valuemax",
283
283
  "aria-valuenow",
284
284
  "tabindex"
285
- ], ue = 32, de = 40, Y = 120, fe = /* @__PURE__ */ d({
285
+ ], ue = 32, de = 40, fe = 120, pe = /* @__PURE__ */ d({
286
286
  __name: "GalleryScrollbar",
287
287
  props: {
288
288
  contentSize: {},
@@ -304,7 +304,7 @@ var le = ["aria-hidden"], J = [
304
304
  function k() {
305
305
  g !== null && clearTimeout(g), g = setTimeout(() => {
306
306
  g = null, o.value || (l.value = !1);
307
- }, Y);
307
+ }, fe);
308
308
  }
309
309
  function A() {
310
310
  l.value = !0, k();
@@ -414,13 +414,13 @@ var le = ["aria-hidden"], J = [
414
414
  onPointerup: R
415
415
  }, null, 44, J)], 42, le));
416
416
  }
417
- }), X = (e) => {
417
+ }), Y = (e) => {
418
418
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
419
419
  return !1;
420
- }, Z = (e) => e === "", pe = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), me = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), he = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), ge = (e) => {
421
- let t = he(e);
420
+ }, X = (e) => e === "", me = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), he = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), ge = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), _e = (e) => {
421
+ let t = ge(e);
422
422
  return t.charAt(0).toUpperCase() + t.slice(1);
423
- }, _e = {
423
+ }, ve = {
424
424
  xmlns: "http://www.w3.org/2000/svg",
425
425
  width: 24,
426
426
  height: 24,
@@ -430,27 +430,27 @@ var le = ["aria-hidden"], J = [
430
430
  "stroke-width": 2,
431
431
  "stroke-linecap": "round",
432
432
  "stroke-linejoin": "round"
433
- }, ve = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = _e.width, color: s = _e.stroke, ...c }, { slots: l }) => p("svg", {
434
- ..._e,
433
+ }, ye = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = ve.width, color: s = ve.stroke, ...c }, { slots: l }) => p("svg", {
434
+ ...ve,
435
435
  ...c,
436
436
  width: o,
437
437
  height: o,
438
438
  stroke: s,
439
- "stroke-width": Z(n) || Z(r) || n === !0 || r === !0 ? Number(i || a || _e["stroke-width"]) * 24 / Number(o) : i || a || _e["stroke-width"],
440
- class: pe("lucide", c.class, ...e ? [`lucide-${me(ge(e))}-icon`, `lucide-${me(e)}`] : ["lucide-icon"]),
441
- ...!l.default && !X(c) && { "aria-hidden": "true" }
442
- }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), ye = (e, t) => (n, { slots: r, attrs: i }) => p(ve, {
439
+ "stroke-width": X(n) || X(r) || n === !0 || r === !0 ? Number(i || a || ve["stroke-width"]) * 24 / Number(o) : i || a || ve["stroke-width"],
440
+ class: me("lucide", c.class, ...e ? [`lucide-${he(_e(e))}-icon`, `lucide-${he(e)}`] : ["lucide-icon"]),
441
+ ...!l.default && !Y(c) && { "aria-hidden": "true" }
442
+ }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), be = (e, t) => (n, { slots: r, attrs: i }) => p(ye, {
443
443
  ...i,
444
444
  ...n,
445
445
  iconNode: t,
446
446
  name: e
447
- }, r), be = ye("chevron-left", [["path", {
447
+ }, r), xe = be("chevron-left", [["path", {
448
448
  d: "m15 18-6-6 6-6",
449
449
  key: "1wnfg3"
450
- }]]), xe = ye("chevron-right", [["path", {
450
+ }]]), Se = be("chevron-right", [["path", {
451
451
  d: "m9 18 6-6-6-6",
452
452
  key: "mthhwq"
453
- }]]), Se = ye("pause", [["rect", {
453
+ }]]), Ce = be("pause", [["rect", {
454
454
  x: "14",
455
455
  y: "3",
456
456
  width: "5",
@@ -464,10 +464,10 @@ var le = ["aria-hidden"], J = [
464
464
  height: "18",
465
465
  rx: "1",
466
466
  key: "1wsw3u"
467
- }]]), Ce = ye("play", [["path", {
467
+ }]]), we = be("play", [["path", {
468
468
  d: "M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",
469
469
  key: "10ikf1"
470
- }]]), we = ye("volume-2", [
470
+ }]]), Te = be("volume-2", [
471
471
  ["path", {
472
472
  d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
473
473
  key: "uqj9uw"
@@ -480,7 +480,7 @@ var le = ["aria-hidden"], J = [
480
480
  d: "M19.364 18.364a9 9 0 0 0 0-12.728",
481
481
  key: "ijwkga"
482
482
  }]
483
- ]), Te = ye("volume-x", [
483
+ ]), Ee = be("volume-x", [
484
484
  ["path", {
485
485
  d: "M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",
486
486
  key: "uqj9uw"
@@ -499,32 +499,32 @@ var le = ["aria-hidden"], J = [
499
499
  y2: "15",
500
500
  key: "5ykzw1"
501
501
  }]
502
- ]), Ee = {
502
+ ]), De = {
503
503
  401: "Authentication required",
504
504
  403: "Access forbidden",
505
505
  404: "Preview not found",
506
506
  419: "Session expired",
507
507
  500: "Server error"
508
508
  };
509
- function De(e) {
509
+ function Oe(e) {
510
510
  return e.match(/\/demo-errors\/(401|403|404|419|500)\//)?.[1] ?? "Error";
511
511
  }
512
- function Oe(e) {
513
- return Ee[De(e)] ?? "Preview unavailable";
512
+ function ke(e) {
513
+ return De[Oe(e)] ?? "Preview unavailable";
514
514
  }
515
515
  //#endregion
516
516
  //#region src/core/mediaType.ts
517
- var ke = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
518
- function Ae(e) {
517
+ var Ae = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
518
+ function je(e) {
519
519
  try {
520
- return ke.test(new URL(e).pathname);
520
+ return Ae.test(new URL(e).pathname);
521
521
  } catch {
522
- return ke.test(e.split("?")[0] ?? e);
522
+ return Ae.test(e.split("?")[0] ?? e);
523
523
  }
524
524
  }
525
525
  //#endregion
526
526
  //#region src/components/CardRegion.vue
527
- var je = /* @__PURE__ */ d({
527
+ var Me = /* @__PURE__ */ d({
528
528
  __name: "CardRegion",
529
529
  props: {
530
530
  index: {},
@@ -571,18 +571,18 @@ var je = /* @__PURE__ */ d({
571
571
  "total"
572
572
  ]))], 38));
573
573
  }
574
- }), Me = [
574
+ }), Ne = [
575
575
  "max",
576
576
  "value",
577
577
  "aria-valuetext",
578
578
  "disabled"
579
- ], Ne = {
579
+ ], Pe = {
580
580
  key: 0,
581
581
  class: "media-controls-row"
582
- }, Pe = ["aria-label", "title"], Fe = { class: "media-controls-audio" }, Ie = ["aria-label", "title"], Le = ["value", "aria-valuetext"], Re = {
582
+ }, Fe = ["aria-label", "title"], Ie = { class: "media-controls-audio" }, Le = ["aria-label", "title"], Re = ["value", "aria-valuetext"], ze = {
583
583
  class: "media-control-time",
584
584
  "aria-live": "off"
585
- }, ze = /* @__PURE__ */ d({
585
+ }, Be = /* @__PURE__ */ d({
586
586
  __name: "MediaControls",
587
587
  props: {
588
588
  currentTime: {},
@@ -630,35 +630,35 @@ var je = /* @__PURE__ */ d({
630
630
  "aria-valuetext": `${u(p.value)} of ${u(f.value)}`,
631
631
  disabled: f.value <= 0,
632
632
  onInput: n[0] ||= (e) => i("seek", d(e))
633
- }, null, 44, Me), e.layout === "reel" ? (b(), s("div", Ne, [
633
+ }, null, 44, Ne), e.layout === "reel" ? (b(), s("div", Pe, [
634
634
  c("button", {
635
635
  type: "button",
636
636
  class: "media-control-button media-control-playback",
637
637
  "aria-label": e.playing ? "Pause video" : "Play video",
638
638
  title: e.playing ? "Pause" : "Play",
639
639
  onClick: n[1] ||= (e) => i("togglePlayback")
640
- }, [e.playing ? (b(), a(E(Se), {
640
+ }, [e.playing ? (b(), a(E(Ce), {
641
641
  key: 0,
642
642
  size: 18,
643
643
  fill: "currentColor"
644
- })) : (b(), a(E(Ce), {
644
+ })) : (b(), a(E(we), {
645
645
  key: 1,
646
646
  size: 18,
647
647
  fill: "currentColor"
648
- }))], 8, Pe),
649
- c("div", Fe, [c("button", {
648
+ }))], 8, Fe),
649
+ c("div", Ie, [c("button", {
650
650
  type: "button",
651
651
  class: "media-control-button",
652
652
  "aria-label": e.muted ? "Unmute video" : "Mute video",
653
653
  title: e.muted ? "Unmute" : "Mute",
654
654
  onClick: n[2] ||= (e) => i("toggleMute")
655
- }, [e.muted || e.volume === 0 ? (b(), a(E(Te), {
655
+ }, [e.muted || e.volume === 0 ? (b(), a(E(Ee), {
656
656
  key: 0,
657
657
  size: 18
658
- })) : (b(), a(E(we), {
658
+ })) : (b(), a(E(Te), {
659
659
  key: 1,
660
660
  size: 18
661
- }))], 8, Ie), c("input", {
661
+ }))], 8, Le), c("input", {
662
662
  class: "media-control-range media-control-volume",
663
663
  type: "range",
664
664
  min: "0",
@@ -669,14 +669,14 @@ var je = /* @__PURE__ */ d({
669
669
  "aria-label": "Video volume",
670
670
  "aria-valuetext": `${Math.round(e.volume * 100)} percent`,
671
671
  onInput: n[3] ||= (e) => i("volumeChange", d(e))
672
- }, null, 44, Le)]),
673
- c("output", Re, T(u(p.value)) + " / " + T(u(f.value)), 1)
672
+ }, null, 44, Re)]),
673
+ c("output", ze, T(u(p.value)) + " / " + T(u(f.value)), 1)
674
674
  ])) : o("", !0)], 34));
675
675
  }
676
676
  });
677
677
  //#endregion
678
678
  //#region src/components/useReelVideoActivity.ts
679
- function Be(e) {
679
+ function Ve(e) {
680
680
  let t = r(() => e.layout() !== "reel" || e.active() === !0), n = r(() => t.value ? e.videoIsMuted.value : !0);
681
681
  function i() {
682
682
  if (!t.value) {
@@ -710,7 +710,7 @@ function Be(e) {
710
710
  }
711
711
  //#endregion
712
712
  //#region src/components/MediaCard.vue?vue&type=script&setup=true&lang.ts
713
- var Ve = [
713
+ var He = [
714
714
  "data-post-id",
715
715
  "data-media-index",
716
716
  "aria-hidden",
@@ -718,12 +718,12 @@ var Ve = [
718
718
  "inert",
719
719
  "role",
720
720
  "tabindex"
721
- ], He = { class: "media-card-content" }, Ue = ["data-media-direction"], We = ["data-media-index"], Ge = {
721
+ ], Ue = { class: "media-card-content" }, We = ["data-media-direction"], Ge = ["data-media-index"], Ke = {
722
722
  key: 0,
723
723
  "data-test": "media-loading",
724
724
  class: "media-loading",
725
725
  "aria-hidden": "true"
726
- }, Ke = ["aria-label"], qe = { class: "media-error-code" }, Je = [
726
+ }, qe = ["aria-label"], Je = { class: "media-error-code" }, Ye = [
727
727
  "src",
728
728
  "width",
729
729
  "height",
@@ -731,12 +731,12 @@ var Ve = [
731
731
  "loop",
732
732
  "muted",
733
733
  "preload"
734
- ], Ye = [
734
+ ], Xe = [
735
735
  "src",
736
736
  "width",
737
737
  "height",
738
738
  "fetchpriority"
739
- ], Xe = ["aria-label"], Ze = ["aria-label"], Qe = ["aria-label"], $e = 40, et = 160, tt = 24, nt = /* @__PURE__ */ d({
739
+ ], Ze = ["aria-label"], Qe = ["aria-label"], $e = ["aria-label"], et = 40, tt = 160, nt = 24, rt = /* @__PURE__ */ d({
740
740
  __name: "MediaCard",
741
741
  props: {
742
742
  active: { type: Boolean },
@@ -772,7 +772,7 @@ var Ve = [
772
772
  function S(e = !1, t = "pointer") {
773
773
  e && x("activate", t);
774
774
  }
775
- let C = r(() => M(l.item)), D = r(() => N(l.item, l.mediaIndex)), O = r(() => P(l.item, D.value)), F = r(() => l.mediaSource === "original" ? O.value.src : O.value.preview.src), I = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), L = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), R = w(null), z = w(0), B = w(0), V = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), H = w(!1), ee = w(1), te = 1, { effectiveMuted: ne, onPlaying: re, playbackAllowed: ie } = Be({
775
+ let C = r(() => M(l.item)), D = r(() => N(l.item, l.mediaIndex)), O = r(() => P(l.item, D.value)), F = r(() => l.mediaSource === "original" ? O.value.src : O.value.preview.src), I = r(() => l.mediaSource === "original" ? O.value.width : O.value.preview.width), L = r(() => l.mediaSource === "original" ? O.value.height : O.value.preview.height), R = w(null), z = w(0), B = w(0), V = w(l.mediaCard?.videoMuted ?? l.layout === "masonry"), H = w(!1), ee = w(1), te = 1, { effectiveMuted: ne, onPlaying: re, playbackAllowed: ie } = Ve({
776
776
  active: () => l.active,
777
777
  layout: () => l.layout,
778
778
  videoElement: R,
@@ -793,12 +793,12 @@ var Ve = [
793
793
  f = 0, p = !1, d !== null && clearTimeout(d), d = null;
794
794
  }
795
795
  function G() {
796
- d !== null && clearTimeout(d), d = setTimeout(se, et);
796
+ d !== null && clearTimeout(d), d = setTimeout(se, tt);
797
797
  }
798
798
  function K(e) {
799
799
  if (C.value.length <= 1) return;
800
800
  let t = e.currentTarget?.clientWidth || 1, n = oe(e.deltaX, e.deltaMode, t);
801
- if (n === 0 || (e.preventDefault(), G(), p) || (f += n, Math.abs(f) < tt)) return;
801
+ if (n === 0 || (e.preventDefault(), G(), p) || (f += n, Math.abs(f) < nt)) return;
802
802
  let r = Math.sign(f);
803
803
  f = 0, p = !0, W(D.value + r);
804
804
  }
@@ -810,13 +810,13 @@ var Ve = [
810
810
  let t = e.changedTouches[0];
811
811
  if (m === null || g === null || !t) return;
812
812
  let n = m - t.clientX, r = g - t.clientY;
813
- m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < $e || W(D.value + Math.sign(n)));
813
+ m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < et || W(D.value + Math.sign(n)));
814
814
  }
815
- let le = r(() => Ae(F.value)), J = r(() => l.layout === "reel" && l.stationaryReelControls === !0), ue = r(() => le.value && l.previewState === "ready" && (!J.value || !!(l.active && l.reelControlsTarget))), de = r(() => `${l.item.postId}:${D.value}:${F.value}`);
816
- function Y(e) {
817
- l.layout === "reel" && (e.stopPropagation(), fe());
815
+ let le = r(() => je(F.value)), J = r(() => l.layout === "reel" && l.stationaryReelControls === !0), ue = r(() => le.value && l.previewState === "ready" && (!J.value || !!(l.active && l.reelControlsTarget))), de = r(() => `${l.item.postId}:${D.value}:${F.value}`);
816
+ function fe(e) {
817
+ l.layout === "reel" && (e.stopPropagation(), pe());
818
818
  }
819
- async function fe() {
819
+ async function pe() {
820
820
  if (!(!R.value || !ie.value)) {
821
821
  if (H.value) {
822
822
  R.value.pause();
@@ -829,32 +829,32 @@ var Ve = [
829
829
  }
830
830
  }
831
831
  }
832
- function X(e) {
832
+ function Y(e) {
833
833
  return Number.isFinite(e) ? Math.max(0, e) : 0;
834
834
  }
835
- function Z(e) {
835
+ function X(e) {
836
836
  let t = e?.currentTarget ?? R.value;
837
- t && (z.value = X(t.currentTime), B.value = X(t.duration), ie.value && (V.value = t.muted), ee.value = t.volume, t.volume > 0 && (te = t.volume));
837
+ t && (z.value = Y(t.currentTime), B.value = Y(t.duration), ie.value && (V.value = t.muted), ee.value = t.volume, t.volume > 0 && (te = t.volume));
838
838
  }
839
- function pe(e) {
840
- Z(e), x("ready", D.value);
839
+ function me(e) {
840
+ X(e), x("ready", D.value);
841
841
  }
842
- function me() {
842
+ function he() {
843
843
  H.value = !1, x("ended", D.value);
844
844
  }
845
- function he(e) {
845
+ function ge(e) {
846
846
  let t = R.value;
847
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(X(t.duration), Math.max(0, e)), z.value = t.currentTime);
847
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(Y(t.duration), Math.max(0, e)), z.value = t.currentTime);
848
848
  }
849
- function ge(e) {
849
+ function _e(e) {
850
850
  let t = R.value;
851
851
  if (!t || !Number.isFinite(e)) return;
852
852
  let n = Math.min(1, Math.max(0, e));
853
- t.volume = n, t.muted = n === 0, n > 0 && (te = n), Z();
853
+ t.volume = n, t.muted = n === 0, n > 0 && (te = n), X();
854
854
  }
855
- function _e() {
855
+ function ve() {
856
856
  let e = R.value;
857
- e && (e.muted && e.volume === 0 && (e.volume = te), e.muted = !e.muted, Z());
857
+ e && (e.muted && e.volume === 0 && (e.volume = te), e.muted = !e.muted, X());
858
858
  }
859
859
  return v(() => {
860
860
  se();
@@ -875,8 +875,8 @@ var Ve = [
875
875
  tabindex: e.interactive && !e.leaving && !U.value ? 0 : void 0,
876
876
  onClick: i[11] ||= (t) => S(e.interactive && !U.value, ae(t)),
877
877
  onKeydown: [i[12] ||= A((t) => S(e.interactive && !U.value, "keyboard"), ["enter"]), i[13] ||= A(j((t) => S(e.interactive && !U.value, "keyboard"), ["prevent"]), ["space"])]
878
- }, [c("div", He, [
879
- e.cardHeader ? (b(), a(je, {
878
+ }, [c("div", Ue, [
879
+ e.cardHeader ? (b(), a(Me, {
880
880
  key: 0,
881
881
  index: e.index,
882
882
  item: e.item,
@@ -911,13 +911,13 @@ var Ve = [
911
911
  key: `${e.item.postId}:${O.value.src}:${e.mediaSource ?? "preview"}`,
912
912
  class: "media-card-frame",
913
913
  "data-media-index": D.value
914
- }, [e.previewState === "loading" ? (b(), s("div", Ge, [...i[14] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (b(), s("div", {
914
+ }, [e.previewState === "loading" ? (b(), s("div", Ke, [...i[14] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (b(), s("div", {
915
915
  key: 1,
916
916
  "data-test": "media-error",
917
917
  class: "media-error",
918
918
  role: "img",
919
- "aria-label": `${E(De)(F.value)} ${E(Oe)(F.value)}`
920
- }, [c("strong", qe, T(E(De)(F.value)), 1), c("span", null, T(E(Oe)(F.value)), 1)], 8, Ke)) : o("", !0), le.value ? (b(), s("video", {
919
+ "aria-label": `${E(Oe)(F.value)} ${E(ke)(F.value)}`
920
+ }, [c("strong", Je, T(E(Oe)(F.value)), 1), c("span", null, T(E(ke)(F.value)), 1)], 8, qe)) : o("", !0), le.value ? (b(), s("video", {
921
921
  key: 2,
922
922
  ref_key: "videoElement",
923
923
  ref: R,
@@ -933,16 +933,16 @@ var Ve = [
933
933
  muted: E(ne),
934
934
  playsinline: "",
935
935
  preload: e.fetchPriority === "high" ? "auto" : "metadata",
936
- onLoadedmetadata: pe,
937
- onDurationchange: Z,
938
- onTimeupdate: Z,
939
- onVolumechange: Z,
936
+ onLoadedmetadata: me,
937
+ onDurationchange: X,
938
+ onTimeupdate: X,
939
+ onVolumechange: X,
940
940
  onPlaying: i[0] ||= (...e) => E(re) && E(re)(...e),
941
941
  onPause: i[1] ||= (e) => H.value = !1,
942
- onEnded: me,
943
- onClick: Y,
942
+ onEnded: he,
943
+ onClick: fe,
944
944
  onError: i[2] ||= (e) => r.$emit("error", D.value)
945
- }, null, 42, Je)) : (b(), s("img", {
945
+ }, null, 42, Ye)) : (b(), s("img", {
946
946
  key: 3,
947
947
  class: h(["media-preview", { "media-preview--ready": e.previewState === "ready" }]),
948
948
  src: F.value,
@@ -954,7 +954,7 @@ var Ve = [
954
954
  loading: "eager",
955
955
  onLoad: i[3] ||= (e) => r.$emit("ready", D.value),
956
956
  onError: i[4] ||= (e) => r.$emit("error", D.value)
957
- }, null, 42, Ye))], 8, We))]),
957
+ }, null, 42, Xe))], 8, Ge))]),
958
958
  _: 1
959
959
  }, 8, ["name"]),
960
960
  (b(), a(t, {
@@ -964,7 +964,7 @@ var Ve = [
964
964
  name: "vibe-reel-media-controls",
965
965
  css: J.value
966
966
  }, {
967
- default: k(() => [ue.value ? (b(), a(ze, {
967
+ default: k(() => [ue.value ? (b(), a(Be, {
968
968
  key: de.value,
969
969
  "current-time": z.value,
970
970
  "data-control-post-id": J.value ? e.item.postId : void 0,
@@ -973,10 +973,10 @@ var Ve = [
973
973
  muted: V.value,
974
974
  playing: H.value,
975
975
  volume: ee.value,
976
- onSeek: he,
977
- onToggleMute: _e,
978
- onTogglePlayback: fe,
979
- onVolumeChange: ge
976
+ onSeek: ge,
977
+ onToggleMute: ve,
978
+ onTogglePlayback: pe,
979
+ onVolumeChange: _e
980
980
  }, null, 8, [
981
981
  "current-time",
982
982
  "data-control-post-id",
@@ -998,13 +998,13 @@ var Ve = [
998
998
  "aria-label": `Previous media for post ${e.item.postId}`,
999
999
  onClick: i[5] ||= j((e) => W(D.value - 1, e), ["stop"]),
1000
1000
  onKeydown: i[6] ||= j(() => {}, ["stop"])
1001
- }, [u(E(be), { size: 20 })], 40, Xe), c("button", {
1001
+ }, [u(E(xe), { size: 20 })], 40, Ze), c("button", {
1002
1002
  type: "button",
1003
1003
  class: "media-carousel-control media-carousel-control--next",
1004
1004
  "aria-label": `Next media for post ${e.item.postId}`,
1005
1005
  onClick: i[7] ||= j((e) => W(D.value + 1, e), ["stop"]),
1006
1006
  onKeydown: i[8] ||= j(() => {}, ["stop"])
1007
- }, [u(E(xe), { size: 20 })], 40, Ze)], 2)) : o("", !0),
1007
+ }, [u(E(Se), { size: 20 })], 40, Qe)], 2)) : o("", !0),
1008
1008
  U.value ? (b(), s("button", {
1009
1009
  key: 1,
1010
1010
  class: "media-card-activator",
@@ -1012,9 +1012,9 @@ var Ve = [
1012
1012
  "aria-label": `Open post ${e.item.postId}`,
1013
1013
  onClick: i[9] ||= j((e) => r.$emit("activate", ae(e)), ["stop"]),
1014
1014
  onKeydown: i[10] ||= j(() => {}, ["stop"])
1015
- }, null, 40, Qe)) : o("", !0)
1016
- ], 42, Ue),
1017
- e.cardFooter ? (b(), a(je, {
1015
+ }, null, 40, $e)) : o("", !0)
1016
+ ], 42, We),
1017
+ e.cardFooter ? (b(), a(Me, {
1018
1018
  key: 1,
1019
1019
  index: e.index,
1020
1020
  item: e.item,
@@ -1037,9 +1037,9 @@ var Ve = [
1037
1037
  "style",
1038
1038
  "total"
1039
1039
  ])) : o("", !0)
1040
- ])], 46, Ve));
1040
+ ])], 46, He));
1041
1041
  }
1042
- }), rt = { class: "masonry-feed-shell" }, it = ["aria-hidden", "inert"], at = 240, ot = 6, st = 12, ct = 800, lt = 1.5, ut = /* @__PURE__ */ d({
1042
+ }), it = { class: "masonry-feed-shell" }, at = ["aria-hidden", "inert"], ot = 240, st = 6, ct = 12, lt = 800, ut = 1.5, dt = /* @__PURE__ */ d({
1043
1043
  __name: "MasonryFeed",
1044
1044
  props: {
1045
1045
  enteringPostIds: {},
@@ -1073,24 +1073,24 @@ var Ve = [
1073
1073
  "retryEnd"
1074
1074
  ],
1075
1075
  setup(t, { expose: n, emit: i }) {
1076
- let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(ot), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => K(o.items, m.value, {
1076
+ let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(st), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => K(o.items, m.value, {
1077
1077
  additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1078
1078
  gap: g.value,
1079
- minColumnWidth: at
1079
+ minColumnWidth: ot
1080
1080
  })), M = r(() => {
1081
1081
  let e = j.value;
1082
1082
  if (o.leavingPostIds.size === 0) return e;
1083
1083
  let t = o.items.filter((e) => !o.leavingPostIds.has(e.postId)), n = K(t, m.value, {
1084
1084
  additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1085
1085
  gap: g.value,
1086
- minColumnWidth: at
1086
+ minColumnWidth: ot
1087
1087
  }), r = new Map(t.map((e, t) => [e.postId, n.items[t]]));
1088
1088
  return {
1089
1089
  ...n,
1090
1090
  items: o.items.map((t, n) => o.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
1091
1091
  };
1092
1092
  }), N = r(() => ({ height: `${o.leavingPostIds.size === 0 ? M.value.height : j.value.height}px` })), P = r(() => !o.infiniteScroll || x.value > 0 && C.value + M.value.height <= x.value + 1), I = r(() => {
1093
- let e = Math.max(ct, x.value * lt), t = {
1093
+ let e = Math.max(lt, x.value * ut), t = {
1094
1094
  scrollTop: y.value - C.value,
1095
1095
  viewportHeight: x.value
1096
1096
  }, n = G(M.value.items, {
@@ -1138,7 +1138,7 @@ var Ve = [
1138
1138
  }
1139
1139
  function z(e) {
1140
1140
  let t = e.ownerDocument.documentElement.clientWidth;
1141
- m.value = e.clientWidth, g.value = Math.min(st, Math.max(ot, t * .0075)), R();
1141
+ m.value = e.clientWidth, g.value = Math.min(ct, Math.max(st, t * .0075)), R();
1142
1142
  }
1143
1143
  function B(e) {
1144
1144
  let t = e.currentTarget;
@@ -1165,7 +1165,7 @@ var Ve = [
1165
1165
  }), n({
1166
1166
  getScrollElement: H,
1167
1167
  loadIfNearBottom: V
1168
- }), (n, r) => (b(), s("div", rt, [c("main", {
1168
+ }), (n, r) => (b(), s("div", it, [c("main", {
1169
1169
  id: f,
1170
1170
  ref_key: "galleryElement",
1171
1171
  ref: d,
@@ -1180,7 +1180,7 @@ var Ve = [
1180
1180
  class: h(["masonry", { "masonry--ready": m.value > 0 }]),
1181
1181
  style: _(N.value),
1182
1182
  "aria-label": "Media gallery"
1183
- }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(nt, {
1183
+ }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(rt, {
1184
1184
  key: n.postId,
1185
1185
  class: "masonry-item",
1186
1186
  entering: t.enteringPostIds.has(n.postId),
@@ -1242,7 +1242,7 @@ var Ve = [
1242
1242
  "load-more-locked",
1243
1243
  "show-load-more",
1244
1244
  "state"
1245
- ])], 42, it), u(fe, {
1245
+ ])], 42, at), u(pe, {
1246
1246
  "content-size": M.value.height,
1247
1247
  "controls-id": f,
1248
1248
  "scroll-element": d.value,
@@ -1253,8 +1253,8 @@ var Ve = [
1253
1253
  "suspended"
1254
1254
  ])]));
1255
1255
  }
1256
- }), dt = 300;
1257
- function ft(e, t, n) {
1256
+ }), ft = 300;
1257
+ function pt(e, t, n) {
1258
1258
  let r = e.scrollTop;
1259
1259
  if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
1260
1260
  e.setAttribute("data-transitioning", "");
@@ -1262,7 +1262,7 @@ function ft(e, t, n) {
1262
1262
  return new Promise((n) => {
1263
1263
  let o = (s) => {
1264
1264
  a += 1;
1265
- let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / dt), u = 1 - (1 - l) ** 3;
1265
+ let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / ft), u = 1 - (1 - l) ** 3;
1266
1266
  if (e.scrollTop = r + (t - r) * u, l < 1) {
1267
1267
  requestAnimationFrame(o);
1268
1268
  return;
@@ -1274,7 +1274,7 @@ function ft(e, t, n) {
1274
1274
  }
1275
1275
  //#endregion
1276
1276
  //#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
1277
- var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1277
+ var mt = ["aria-label"], ht = /* @__PURE__ */ d({
1278
1278
  __name: "ReelAutoAdvanceProgress",
1279
1279
  props: {
1280
1280
  durationMs: {},
@@ -1292,9 +1292,9 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1292
1292
  class: "reel-auto-advance-progress",
1293
1293
  style: _(a.value),
1294
1294
  onAnimationend: n[0] ||= (e) => i("complete")
1295
- }, null, 36)], 8, pt));
1295
+ }, null, 36)], 8, mt));
1296
1296
  }
1297
- }), ht = { class: "reel-viewport" }, gt = ["data-active-post-id", "data-active-media-index"], _t = ["role", "data-status"], vt = 2, yt = 300, bt = /* @__PURE__ */ d({
1297
+ }), gt = { class: "reel-viewport" }, _t = ["data-active-post-id", "data-active-media-index"], vt = ["role", "data-status"], yt = 2, bt = 300, xt = /* @__PURE__ */ d({
1298
1298
  __name: "ReelFeed",
1299
1299
  props: {
1300
1300
  initialPostId: {},
@@ -1332,7 +1332,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1332
1332
  ],
1333
1333
  setup(t, { expose: n, emit: i }) {
1334
1334
  let l = t, u = i, d = w(null), f = w(null), p = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId), g = w(Math.max(0, p)), x = w(!1), C = w(!1), D = 0, k = null, A = null, j = null, N = r(() => ({ gridTemplateRows: `repeat(${l.items.length}, 100cqh)` })), I = r(() => {
1335
- let e = Math.max(0, g.value - vt), t = Math.min(l.items.length - 1, g.value + vt);
1335
+ let e = Math.max(0, g.value - yt), t = Math.min(l.items.length - 1, g.value + yt);
1336
1336
  return l.items.slice(e, t + 1).map((t, n) => ({
1337
1337
  fetchPriority: e + n === g.value ? "high" : "low",
1338
1338
  index: e + n,
@@ -1349,7 +1349,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1349
1349
  if (!e) return "";
1350
1350
  let t = P(e, z.value);
1351
1351
  return l.mediaSource === "original" ? t.src : t.preview.src;
1352
- }), H = r(() => B.value === "ready" && Ae(V.value)), ee = r(() => [
1352
+ }), H = r(() => B.value === "ready" && je(V.value)), ee = r(() => [
1353
1353
  L.value,
1354
1354
  z.value,
1355
1355
  l.items.length,
@@ -1409,32 +1409,32 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1409
1409
  }
1410
1410
  function ue(e) {
1411
1411
  let t = g.value + e;
1412
- return !d.value || t < 0 || t >= l.items.length ? !1 : (X(t), !0);
1412
+ return !d.value || t < 0 || t >= l.items.length ? !1 : (Y(t), !0);
1413
1413
  }
1414
1414
  function de(e, t) {
1415
1415
  let n = l.items.findIndex((t) => t.postId === e), r = l.items[n];
1416
- return !d.value || !r || t < 0 || t > r.items.length ? !1 : ((l.mediaIndices.get(e) ?? 0) !== t && u("mediaChange", e, t), n !== g.value && X(n), !0);
1416
+ return !d.value || !r || t < 0 || t > r.items.length ? !1 : ((l.mediaIndices.get(e) ?? 0) !== t && u("mediaChange", e, t), n !== g.value && Y(n), !0);
1417
1417
  }
1418
- function Y() {
1418
+ function fe() {
1419
1419
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1420
1420
  }
1421
- function fe(e) {
1421
+ function pe(e) {
1422
1422
  let t = d.value;
1423
1423
  if (!t) return Promise.resolve();
1424
1424
  let n = e * (D || t.clientHeight);
1425
- return g.value = e, ft(t, n, Y());
1425
+ return g.value = e, pt(t, n, fe());
1426
1426
  }
1427
- function X(e) {
1428
- fe(e);
1427
+ function Y(e) {
1428
+ pe(e);
1429
1429
  }
1430
- async function Z(e) {
1430
+ async function X(e) {
1431
1431
  let t = l.items.findIndex((t) => t.postId === e);
1432
- return t < 0 || t === g.value ? !1 : (await fe(t), !0);
1432
+ return t < 0 || t === g.value ? !1 : (await pe(t), !0);
1433
1433
  }
1434
- async function pe(e) {
1435
- return J(e) ? (Y() || await new Promise((e) => setTimeout(e, yt)), !0) : !1;
1434
+ async function me(e) {
1435
+ return J(e) ? (fe() || await new Promise((e) => setTimeout(e, bt)), !0) : !1;
1436
1436
  }
1437
- function me() {
1437
+ function he() {
1438
1438
  if (!l.reelAutoAdvance.enabled) return;
1439
1439
  let e = R.value;
1440
1440
  if (!e) return;
@@ -1447,10 +1447,10 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1447
1447
  l.hasNext && !l.loadMoreLocked && u("loadMore");
1448
1448
  return;
1449
1449
  }
1450
- l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), X(t);
1450
+ l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), Y(t);
1451
1451
  }
1452
- function he(e, t) {
1453
- !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || me();
1452
+ function ge(e, t) {
1453
+ !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || he();
1454
1454
  }
1455
1455
  return O(d, (e) => {
1456
1456
  k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(G), k.observe(e)));
@@ -1470,8 +1470,8 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1470
1470
  loadIfNearBottom: le,
1471
1471
  moveActivePost: ue,
1472
1472
  navigateToItem: de,
1473
- transitionActiveMedia: pe,
1474
- transitionActivePost: Z
1473
+ transitionActiveMedia: me,
1474
+ transitionActivePost: X
1475
1475
  }), (n, r) => (b(), s("main", {
1476
1476
  class: h(["reel-shell", {
1477
1477
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1479,7 +1479,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1479
1479
  }]),
1480
1480
  "data-layout-mode": "reel"
1481
1481
  }, [
1482
- t.cardHeader && R.value && t.reelForward.status === "idle" ? (b(), a(je, {
1482
+ t.cardHeader && R.value && t.reelForward.status === "idle" ? (b(), a(Me, {
1483
1483
  key: 0,
1484
1484
  index: g.value,
1485
1485
  item: R.value,
@@ -1501,7 +1501,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1501
1501
  "style",
1502
1502
  "total"
1503
1503
  ])) : o("", !0),
1504
- c("div", ht, [c("div", {
1504
+ c("div", gt, [c("div", {
1505
1505
  ref_key: "galleryElement",
1506
1506
  ref: d,
1507
1507
  class: "gallery-shell reel-feed",
@@ -1513,7 +1513,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1513
1513
  class: "reel-track",
1514
1514
  style: _(N.value),
1515
1515
  "aria-label": "Media gallery"
1516
- }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(nt, {
1516
+ }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a(rt, {
1517
1517
  key: n.postId,
1518
1518
  active: r === g.value && !x.value,
1519
1519
  "advance-on-media-end": l.reelAutoAdvance.enabled && r === g.value,
@@ -1533,7 +1533,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1533
1533
  "stationary-reel-controls": "",
1534
1534
  total: t.total,
1535
1535
  onMediaChange: (e) => u("mediaChange", n.postId, e),
1536
- onEnded: (e) => he(n.postId, e),
1536
+ onEnded: (e) => ge(n.postId, e),
1537
1537
  onReady: (e) => u("ready", n.postId, e),
1538
1538
  onError: (e) => u("error", n.postId, e)
1539
1539
  }, null, 8, [
@@ -1564,7 +1564,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1564
1564
  class: "reel-forward-retry",
1565
1565
  type: "button",
1566
1566
  onClick: r[0] ||= (e) => u("retryForward")
1567
- }, " Retry ")) : o("", !0)], 8, _t)), t.reelForward.status === "idle" ? (b(), a(ne, {
1567
+ }, " Retry ")) : o("", !0)], 8, vt)), t.reelForward.status === "idle" ? (b(), a(ne, {
1568
1568
  key: 2,
1569
1569
  actions: t.feedFooterActions,
1570
1570
  "can-retry-end": t.canRetryEnd,
@@ -1587,13 +1587,13 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1587
1587
  "load-more-locked",
1588
1588
  "show-load-more",
1589
1589
  "state"
1590
- ])) : o("", !0)], 40, gt), c("div", {
1590
+ ])) : o("", !0)], 40, _t), c("div", {
1591
1591
  ref_key: "reelControlsElement",
1592
1592
  ref: f,
1593
1593
  class: "reel-media-controls-host",
1594
1594
  "data-test": "reel-media-controls-host"
1595
1595
  }, null, 512)]),
1596
- t.cardFooter && R.value && t.reelForward.status === "idle" ? (b(), a(je, {
1596
+ t.cardFooter && R.value && t.reelForward.status === "idle" ? (b(), a(Me, {
1597
1597
  key: 1,
1598
1598
  index: g.value,
1599
1599
  item: R.value,
@@ -1615,24 +1615,24 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1615
1615
  "style",
1616
1616
  "total"
1617
1617
  ])) : o("", !0),
1618
- re.value ? (b(), a(mt, {
1618
+ re.value ? (b(), a(ht, {
1619
1619
  key: ee.value,
1620
1620
  "duration-ms": t.reelAutoAdvance.intervalMs,
1621
1621
  label: te.value,
1622
- onComplete: me
1622
+ onComplete: he
1623
1623
  }, null, 8, ["duration-ms", "label"])) : o("", !0)
1624
1624
  ], 2));
1625
1625
  }
1626
- }), xt = ["data-info-sheet-open", "data-info-sheet-mode"], St = ["aria-hidden", "inert"], Ct = {
1626
+ }), St = ["data-info-sheet-open", "data-info-sheet-mode"], Ct = ["aria-hidden", "inert"], wt = {
1627
1627
  key: 0,
1628
1628
  class: "reel-info-sheet-layer",
1629
1629
  "data-test": "reel-info-sheet"
1630
- }, wt = [
1630
+ }, Tt = [
1631
1631
  "role",
1632
1632
  "aria-modal",
1633
1633
  "tabindex",
1634
1634
  "data-active-post-id"
1635
- ], Tt = /* @__PURE__ */ d({
1635
+ ], Et = /* @__PURE__ */ d({
1636
1636
  __name: "ReelLayout",
1637
1637
  props: {
1638
1638
  forwardIndex: { default: null },
@@ -1757,7 +1757,7 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1757
1757
  class: "reel-layout-main",
1758
1758
  "aria-hidden": e.infoSheetOverlay && A.value || void 0,
1759
1759
  inert: e.infoSheetOverlay && A.value || void 0
1760
- }, [u(bt, {
1760
+ }, [u(xt, {
1761
1761
  ref_key: "reelFeed",
1762
1762
  ref: p,
1763
1763
  "can-retry-end": e.canRetryEnd,
@@ -1808,8 +1808,8 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1808
1808
  "reel-forward",
1809
1809
  "state",
1810
1810
  "total"
1811
- ])], 8, St), u(n, { name: "vibe-info-sheet" }, {
1812
- default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", Ct, [c("aside", {
1811
+ ])], 8, Ct), u(n, { name: "vibe-info-sheet" }, {
1812
+ default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", wt, [c("aside", {
1813
1813
  ref_key: "sheetElement",
1814
1814
  ref: _,
1815
1815
  class: "reel-info-sheet",
@@ -1818,20 +1818,20 @@ var pt = ["aria-label"], mt = /* @__PURE__ */ d({
1818
1818
  "aria-modal": e.infoSheetOverlay ? "true" : void 0,
1819
1819
  tabindex: e.infoSheetOverlay ? -1 : void 0,
1820
1820
  "data-active-post-id": T.value?.postId
1821
- }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, wt)])) : o("", !0)]),
1821
+ }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, Tt)])) : o("", !0)]),
1822
1822
  _: 1
1823
- })], 10, xt));
1823
+ })], 10, St));
1824
1824
  }
1825
- }), Et = [];
1826
- function Dt(e) {
1827
- return Et.push(e), () => {
1828
- let t = Et.indexOf(e);
1829
- t >= 0 && Et.splice(t, 1);
1825
+ }), Dt = [];
1826
+ function Ot(e) {
1827
+ return Dt.push(e), () => {
1828
+ let t = Dt.indexOf(e);
1829
+ t >= 0 && Dt.splice(t, 1);
1830
1830
  };
1831
1831
  }
1832
- function Ot(e) {
1832
+ function kt(e) {
1833
1833
  if (!e.isActive()) return !1;
1834
- let t = Et.filter((e) => e.isActive()), n = e.element();
1834
+ let t = Dt.filter((e) => e.isActive()), n = e.element();
1835
1835
  return n !== null && t.some((t) => {
1836
1836
  if (t === e) return !1;
1837
1837
  let r = t.element();
@@ -1847,14 +1847,14 @@ function Ot(e) {
1847
1847
  }
1848
1848
  //#endregion
1849
1849
  //#region src/components/useReelKeyboard.ts
1850
- function kt(e) {
1850
+ function At(e) {
1851
1851
  let t = {
1852
1852
  element: e.element,
1853
1853
  isActive: () => e.state.layout === "reel" || e.state.reelOrigin === "masonry"
1854
1854
  }, n = null;
1855
1855
  function r(n) {
1856
1856
  let r = t.isActive();
1857
- if (n.key === "Escape" && r && !Ot(t)) return;
1857
+ if (n.key === "Escape" && r && !kt(t)) return;
1858
1858
  if (n.key === "Escape" && e.state.reelOrigin === "masonry") {
1859
1859
  n.preventDefault(), e.state.reelInfoSheetOverlay && e.state.reelInfoSheet.enabled && e.setReelInfoSheet(!1), e.closeMasonryReel();
1860
1860
  return;
@@ -1874,14 +1874,14 @@ function kt(e) {
1874
1874
  a !== 0 && e.reelRenderer()?.changeActiveMedia?.(a) && n.preventDefault();
1875
1875
  }
1876
1876
  y(() => {
1877
- n = Dt(t), window.addEventListener("keydown", r);
1877
+ n = Ot(t), window.addEventListener("keydown", r);
1878
1878
  }), v(() => {
1879
1879
  window.removeEventListener("keydown", r), n?.(), n = null;
1880
1880
  });
1881
1881
  }
1882
1882
  //#endregion
1883
1883
  //#region src/components/VibeSurface.vue?vue&type=script&setup=true&lang.ts
1884
- var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
1884
+ var jt = 35, Mt = 420, Nt = /* @__PURE__ */ d({
1885
1885
  __name: "VibeSurface",
1886
1886
  props: {
1887
1887
  canRetryEnd: { type: Boolean },
@@ -1973,29 +1973,29 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
1973
1973
  return l.state.layout !== "masonry" || l.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1974
1974
  }
1975
1975
  function de(e, t) {
1976
- V = e, H = t === "keyboard", y.value = Z(e), d("openReel", e), m(() => h.value?.focus());
1976
+ V = e, H = t === "keyboard", y.value = X(e), d("openReel", e), m(() => h.value?.focus());
1977
1977
  }
1978
- function Y(e) {
1978
+ function fe(e) {
1979
1979
  let t = g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1980
1980
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
1981
1981
  }
1982
- function fe(e) {
1982
+ function pe(e) {
1983
1983
  if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || ee()) return 0;
1984
- let t = [...new Set(e)], n = t.filter(Y);
1984
+ let t = [...new Set(e)], n = t.filter(fe);
1985
1985
  if (n.length === 0) return 0;
1986
1986
  let r = new Map(E.value);
1987
1987
  return n.forEach((e, t) => {
1988
- r.set(e, t * At);
1989
- }), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), E.value = r, jt + (n.length - 1) * At;
1988
+ r.set(e, t * jt);
1989
+ }), S.value = new Set([...S.value].filter((e) => !n.includes(e))), T.value = new Set([...T.value, ...t]), E.value = r, Mt + (n.length - 1) * jt;
1990
1990
  }
1991
- function X(e, t) {
1992
- let n = Y(e), r = n?.querySelector(".media-card-activator") ?? n;
1991
+ function Y(e, t) {
1992
+ let n = fe(e), r = n?.querySelector(".media-card-activator") ?? n;
1993
1993
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
1994
1994
  r.classList.remove("media-card-focus-silent");
1995
1995
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
1996
1996
  }
1997
- function Z(e) {
1998
- let t = g.value, n = Y(e);
1997
+ function X(e) {
1998
+ let t = g.value, n = fe(e);
1999
1999
  if (t === null || n === null) return {};
2000
2000
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
2001
2001
  return {
@@ -2005,17 +2005,17 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2005
2005
  "--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
2006
2006
  };
2007
2007
  }
2008
- function pe() {
2008
+ function me() {
2009
2009
  l.state.reelOrigin === "masonry" && (V ??= l.state.activeReelPostId, x.value = !0, d("closeReel"));
2010
2010
  }
2011
- function me() {
2011
+ function he() {
2012
2012
  let e = V, t = H;
2013
2013
  x.value = !1, V = null, H = !1, y.value = {}, m(() => {
2014
- e !== null && X(e, t);
2014
+ e !== null && Y(e, t);
2015
2015
  });
2016
2016
  }
2017
- return kt({
2018
- closeMasonryReel: pe,
2017
+ return At({
2018
+ closeMasonryReel: me,
2019
2019
  element: () => g.value,
2020
2020
  isReelLeaving: () => x.value,
2021
2021
  reelRenderer: () => p.value,
@@ -2029,7 +2029,7 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2029
2029
  let t = C.value.get(e);
2030
2030
  t !== void 0 && r.set(e, t);
2031
2031
  }), t.forEach((e, t) => {
2032
- r.set(e, t * At);
2032
+ r.set(e, t * jt);
2033
2033
  }), C.value = r, S.value = new Set([...S.value, ...t]), te();
2034
2034
  }, { flush: "sync" }), v(() => {
2035
2035
  B !== null && cancelAnimationFrame(B);
@@ -2039,14 +2039,14 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2039
2039
  loadIfNearBottom: q,
2040
2040
  moveActiveReelPost: le,
2041
2041
  navigateToReelItem: J,
2042
- startItemRemoval: fe,
2042
+ startItemRemoval: pe,
2043
2043
  transitionActiveReelMedia: (e) => p.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
2044
2044
  transitionActiveReelPost: (e) => p.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
2045
2045
  }), (r, i) => (b(), s("div", {
2046
2046
  ref_key: "surfaceElement",
2047
2047
  ref: g,
2048
2048
  class: "vibe-surface"
2049
- }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(Tt, {
2049
+ }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(Et, {
2050
2050
  key: 0,
2051
2051
  ref_key: "reelRenderer",
2052
2052
  ref: p,
@@ -2123,7 +2123,7 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2123
2123
  "can-retry-end",
2124
2124
  "feed-footer",
2125
2125
  "state"
2126
- ])) : (b(), s(e, { key: 2 }, [u(ut, {
2126
+ ])) : (b(), s(e, { key: 2 }, [u(dt, {
2127
2127
  ref_key: "masonryRenderer",
2128
2128
  ref: f,
2129
2129
  "can-retry-end": t.canRetryEnd,
@@ -2177,7 +2177,7 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2177
2177
  "total"
2178
2178
  ]), u(n, {
2179
2179
  name: "vibe-reel-viewer",
2180
- onAfterLeave: me
2180
+ onAfterLeave: he
2181
2181
  }, {
2182
2182
  default: k(() => [t.state.reelOrigin === "masonry" ? (b(), s("section", {
2183
2183
  key: 0,
@@ -2189,7 +2189,7 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2189
2189
  "aria-modal": "true",
2190
2190
  tabindex: "-1",
2191
2191
  style: _(y.value)
2192
- }, [u(Tt, {
2192
+ }, [u(Et, {
2193
2193
  ref_key: "reelRenderer",
2194
2194
  ref: p,
2195
2195
  "can-retry-end": t.canRetryEnd,
@@ -2258,44 +2258,44 @@ var At = 35, jt = 420, Mt = /* @__PURE__ */ d({
2258
2258
  });
2259
2259
  //#endregion
2260
2260
  //#region src/core/page.ts
2261
- function Nt(e) {
2261
+ function Pt(e) {
2262
2262
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
2263
2263
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
2264
2264
  if (e.total !== void 0 && (!Number.isFinite(e.total) || e.total < 0)) throw TypeError("Vibe page total must be a non-negative number when provided.");
2265
2265
  return e;
2266
2266
  }
2267
- function Q(e, t) {
2267
+ function Z(e, t) {
2268
2268
  let n = new Set(e.map((e) => e.postId));
2269
2269
  return [...e, ...t.filter((e) => n.has(e.postId) ? !1 : (n.add(e.postId), !0))];
2270
2270
  }
2271
2271
  //#endregion
2272
2272
  //#region src/core/requestDelay.ts
2273
- var Pt = 2e3, Ft = 1e4, It = 250, Lt = {
2273
+ var Ft = 2e3, It = 1e4, Lt = 250, Rt = {
2274
2274
  delayRemainingMs: null,
2275
2275
  nextRequestAt: null
2276
2276
  };
2277
- function Rt(e, t) {
2277
+ function zt(e, t) {
2278
2278
  return e === void 0 ? t : Math.floor(e);
2279
2279
  }
2280
- function zt(e, t) {
2280
+ function Bt(e, t) {
2281
2281
  for (let [n, r] of [["delayStepMs", e.delayStepMs], ["delayMaxMs", e.delayMaxMs]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe ${t} ${n} must be a non-negative number.`);
2282
2282
  }
2283
- function Bt(e, t = {}) {
2284
- let n = Rt(t.delayStepMs, Pt), r = Rt(t.delayMaxMs, Ft);
2283
+ function Vt(e, t = {}) {
2284
+ let n = zt(t.delayStepMs, Ft), r = zt(t.delayMaxMs, It);
2285
2285
  return Math.min(Math.max(0, e) * n, r);
2286
2286
  }
2287
- function $(e) {
2288
- if (e == null || !Number.isFinite(e)) return { ...Lt };
2287
+ function Q(e) {
2288
+ if (e == null || !Number.isFinite(e)) return { ...Rt };
2289
2289
  let t = Math.max(0, Math.floor(e - Date.now()));
2290
2290
  return t > 0 ? {
2291
2291
  delayRemainingMs: t,
2292
2292
  nextRequestAt: e
2293
- } : { ...Lt };
2293
+ } : { ...Rt };
2294
2294
  }
2295
- async function Vt({ delayMs: e, onChange: t, signal: n }) {
2295
+ async function Ht({ delayMs: e, onChange: t, signal: n }) {
2296
2296
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2297
2297
  if (e <= 0) {
2298
- t({ ...Lt });
2298
+ t({ ...Rt });
2299
2299
  return;
2300
2300
  }
2301
2301
  let r = Date.now() + e;
@@ -2303,9 +2303,9 @@ async function Vt({ delayMs: e, onChange: t, signal: n }) {
2303
2303
  delayRemainingMs: e,
2304
2304
  nextRequestAt: r
2305
2305
  }), await new Promise((i, a) => {
2306
- let o = !1, s = setInterval(f, It), c = setTimeout(() => u(), e);
2306
+ let o = !1, s = setInterval(f, Lt), c = setTimeout(() => u(), e);
2307
2307
  function l() {
2308
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Lt });
2308
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Rt });
2309
2309
  }
2310
2310
  function u(e) {
2311
2311
  o || (o = !0, l(), e ? a(e) : i());
@@ -2314,42 +2314,42 @@ async function Vt({ delayMs: e, onChange: t, signal: n }) {
2314
2314
  u(new DOMException("Aborted", "AbortError"));
2315
2315
  }
2316
2316
  function f() {
2317
- let e = $(r);
2317
+ let e = Q(r);
2318
2318
  t(e), e.delayRemainingMs === null && u();
2319
2319
  }
2320
2320
  n.addEventListener("abort", d, { once: !0 });
2321
2321
  });
2322
2322
  }
2323
- var Ht = class {
2323
+ var Ut = class {
2324
2324
  interval = null;
2325
2325
  constructor(e) {
2326
2326
  this.onChange = e;
2327
2327
  }
2328
2328
  clear() {
2329
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Lt });
2329
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Rt });
2330
2330
  }
2331
2331
  sync(e) {
2332
2332
  this.clear();
2333
- let t = $(e);
2333
+ let t = Q(e);
2334
2334
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2335
- let t = $(e);
2335
+ let t = Q(e);
2336
2336
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2337
- }, It));
2337
+ }, Lt));
2338
2338
  }
2339
2339
  };
2340
- function Ut(e, t = !0) {
2340
+ function Wt(e, t = !0) {
2341
2341
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2342
2342
  }
2343
- function Wt(e) {
2343
+ function Gt(e) {
2344
2344
  return `${typeof e}:${String(e)}`;
2345
2345
  }
2346
- function Gt(e, t) {
2346
+ function Kt(e, t) {
2347
2347
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2348
2348
  }
2349
- function Kt(e) {
2349
+ function qt(e) {
2350
2350
  if (!e) return;
2351
- if (Gt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2352
- zt(e, "frontend autofill");
2351
+ if (Kt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2352
+ Bt(e, "frontend autofill");
2353
2353
  let t = e.maxAdditionalPages;
2354
2354
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2355
2355
  return;
@@ -2361,7 +2361,7 @@ function Kt(e) {
2361
2361
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2362
2362
  }
2363
2363
  }
2364
- function qt(e, t, n = !0) {
2364
+ function Jt(e, t, n = !0) {
2365
2365
  if (!e) return {
2366
2366
  cycleId: null,
2367
2367
  delayRemainingMs: null,
@@ -2378,7 +2378,7 @@ function qt(e, t, n = !0) {
2378
2378
  status: "idle",
2379
2379
  strategy: null
2380
2380
  };
2381
- let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = $(r?.nextRequestAt);
2381
+ let r = e.strategy === "backend" ? t ?? (n ? e.initialSession : void 0) : void 0, i = r?.received ?? 0, a = Q(r?.nextRequestAt);
2382
2382
  return {
2383
2383
  cycleId: r?.cycleId ?? null,
2384
2384
  ...a,
@@ -2395,7 +2395,7 @@ function qt(e, t, n = !0) {
2395
2395
  strategy: e.strategy
2396
2396
  };
2397
2397
  }
2398
- function Jt(e) {
2398
+ function Yt(e) {
2399
2399
  return [
2400
2400
  "cancelling",
2401
2401
  "filling",
@@ -2403,9 +2403,9 @@ function Jt(e) {
2403
2403
  "waiting"
2404
2404
  ].includes(e.status);
2405
2405
  }
2406
- async function Yt(e, t, n) {
2406
+ async function Xt(e, t, n) {
2407
2407
  let r = t.autofill;
2408
- if (!Jt(r) || !r.cycleId) return;
2408
+ if (!Yt(r) || !r.cycleId) return;
2409
2409
  let i = {
2410
2410
  cycleId: r.cycleId,
2411
2411
  feedKey: r.feedKey ?? "",
@@ -2418,26 +2418,31 @@ async function Yt(e, t, n) {
2418
2418
  throw r.error = e, r.status = "error", e;
2419
2419
  }
2420
2420
  }
2421
- function Xt(e, t, n) {
2421
+ function Zt(e, t, n) {
2422
2422
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2423
2423
  }
2424
- async function Zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2425
- let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? Ut(s), h = t, g = t, _ = 0, v;
2424
+ async function Qt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2425
+ let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? Wt(s), h = t, g = t, _ = 0, v = [], y;
2426
2426
  for (; _ < m;) {
2427
- let e = Wt(h);
2427
+ let e = Gt(h);
2428
2428
  if (p.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2429
- p.add(e), await Vt({
2430
- delayMs: Bt(l + _, s),
2429
+ p.add(e), await Ht({
2430
+ delayMs: Vt(l + _, s),
2431
2431
  onChange: a,
2432
2432
  signal: u
2433
2433
  });
2434
- let t = Nt(await n({
2434
+ let t = Pt(await n({
2435
2435
  cursor: h,
2436
2436
  signal: u
2437
2437
  }));
2438
2438
  _ += 1;
2439
- let r = Q(f, t.items).slice(f.length);
2440
- f.push(...r), d.push(...r), g = t.next, t.total !== void 0 && (v = t.total);
2439
+ let r = Z(f, t.items).slice(f.length);
2440
+ v.push({
2441
+ contributionIds: r.map(({ postId: e }) => e),
2442
+ cursor: h,
2443
+ next: t.next,
2444
+ returnedIds: t.items.map(({ postId: e }) => e)
2445
+ }), f.push(...r), d.push(...r), g = t.next, t.total !== void 0 && (y = t.total);
2441
2446
  let m = {
2442
2447
  missing: Math.max(0, s.pageSize - c - d.length),
2443
2448
  next: g,
@@ -2445,18 +2450,20 @@ async function Zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2445
2450
  requests: l + _
2446
2451
  };
2447
2452
  o(m);
2448
- let y = {
2453
+ let b = {
2449
2454
  ...m,
2450
2455
  items: [...d],
2451
2456
  lastCursor: h,
2452
- total: v
2457
+ total: y
2453
2458
  };
2454
- if (i(y), m.missing === 0) return {
2455
- ...y,
2459
+ if (i(b), m.missing === 0) return {
2460
+ ...b,
2461
+ pages: v,
2456
2462
  status: "complete"
2457
2463
  };
2458
2464
  if (g === null) return {
2459
- ...y,
2465
+ ...b,
2466
+ pages: v,
2460
2467
  status: "exhausted"
2461
2468
  };
2462
2469
  h = g;
@@ -2466,20 +2473,21 @@ async function Zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2466
2473
  lastCursor: h,
2467
2474
  missing: Math.max(0, s.pageSize - c - d.length),
2468
2475
  next: g,
2476
+ pages: v,
2469
2477
  received: c + d.length,
2470
2478
  requests: l + _,
2471
2479
  status: "exhausted",
2472
- total: v
2480
+ total: y
2473
2481
  };
2474
2482
  }
2475
2483
  //#endregion
2476
2484
  //#region src/core/autofillController.ts
2477
- var Qt = class {
2485
+ var $t = class {
2478
2486
  collection = null;
2479
2487
  cycle = 0;
2480
2488
  delayCountdown;
2481
2489
  constructor(e) {
2482
- this.context = e, this.delayCountdown = new Ht((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2490
+ this.context = e, this.delayCountdown = new Ut((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2483
2491
  }
2484
2492
  beginCycle() {
2485
2493
  let { options: e, state: t } = this.context;
@@ -2487,14 +2495,14 @@ var Qt = class {
2487
2495
  this.clear();
2488
2496
  let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
2489
2497
  return t.autofill = {
2490
- ...qt(e, void 0, !1),
2498
+ ...Jt(e, void 0, !1),
2491
2499
  cycleId: n,
2492
2500
  status: "filling"
2493
2501
  }, n;
2494
2502
  }
2495
2503
  async cancel() {
2496
2504
  let { cancelRequest: e, options: t, state: n } = this.context;
2497
- await Yt(t, n, e), this.commitCollection();
2505
+ await Xt(t, n, e), this.commitCollection();
2498
2506
  }
2499
2507
  captureCollection(e, t) {
2500
2508
  t && (this.collection = e);
@@ -2516,36 +2524,36 @@ var Qt = class {
2516
2524
  let { onLastCursor: e, options: t, state: n } = this.context;
2517
2525
  if (t?.strategy !== "frontend") return;
2518
2526
  let r = this.collection;
2519
- this.collection = null, r && (n.items = Q(n.items, r.items), e(r.lastCursor), n.next = r.next, r.total !== void 0 && (n.total = r.total), Object.assign(n.autofill, {
2527
+ this.collection = null, r && (n.items = Z(n.items, r.items), e(r.lastCursor), n.next = r.next, r.total !== void 0 && (n.total = r.total), Object.assign(n.autofill, {
2520
2528
  missing: r.missing,
2521
2529
  received: r.received,
2522
2530
  requests: r.requests
2523
2531
  }));
2524
2532
  }
2525
- }, $t = 100;
2526
- function en(e, t) {
2533
+ }, en = 100;
2534
+ function tn(e, t) {
2527
2535
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2528
2536
  }
2529
- function tn(e, t, n) {
2537
+ function nn(e, t, n) {
2530
2538
  return Math.min(n, Math.max(t, e));
2531
2539
  }
2532
- function nn(e) {
2540
+ function rn(e) {
2533
2541
  if (!e) return;
2534
2542
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2535
- if (en("autoScroll.minSpeedPxPerSecond", t), en("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2536
- e.speedPxPerSecond !== void 0 && en("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2543
+ if (tn("autoScroll.minSpeedPxPerSecond", t), tn("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2544
+ e.speedPxPerSecond !== void 0 && tn("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2537
2545
  }
2538
- function rn(e) {
2546
+ function an(e) {
2539
2547
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2540
2548
  return {
2541
2549
  enabled: e?.enabled ?? !1,
2542
2550
  maxSpeedPxPerSecond: n,
2543
2551
  minSpeedPxPerSecond: t,
2544
2552
  paused: !1,
2545
- speedPxPerSecond: tn(e?.speedPxPerSecond ?? 80, t, n)
2553
+ speedPxPerSecond: nn(e?.speedPxPerSecond ?? 80, t, n)
2546
2554
  };
2547
2555
  }
2548
- var an = class {
2556
+ var on = class {
2549
2557
  frame = null;
2550
2558
  lastTimestamp = null;
2551
2559
  mounted = !1;
@@ -2565,9 +2573,9 @@ var an = class {
2565
2573
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2566
2574
  }
2567
2575
  setSpeed(e) {
2568
- en("auto-scroll speed", e);
2576
+ tn("auto-scroll speed", e);
2569
2577
  let t = this.options.state;
2570
- t.speedPxPerSecond = tn(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2578
+ t.speedPxPerSecond = nn(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2571
2579
  }
2572
2580
  tick = (e) => {
2573
2581
  this.frame = null;
@@ -2579,7 +2587,7 @@ var an = class {
2579
2587
  return;
2580
2588
  }
2581
2589
  if (this.lastTimestamp !== null) {
2582
- let r = Math.min($t, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2590
+ let r = Math.min(en, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2583
2591
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2584
2592
  }
2585
2593
  this.lastTimestamp = e, this.schedule();
@@ -2593,13 +2601,13 @@ var an = class {
2593
2601
  };
2594
2602
  //#endregion
2595
2603
  //#region src/core/backendAutofill.ts
2596
- async function on(e, t, n, r) {
2604
+ async function sn(e, t, n, r) {
2597
2605
  let i = await e.onUnderfilled(n);
2598
2606
  if (!r()) return;
2599
2607
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
2600
2608
  let a = Math.max(n.received, i.received ?? n.received);
2601
2609
  Object.assign(t.autofill, {
2602
- ...$(i.nextRequestAt),
2610
+ ...Q(i.nextRequestAt),
2603
2611
  missing: Math.max(0, e.pageSize - a),
2604
2612
  received: a,
2605
2613
  sequence: i.sequence ?? 0,
@@ -2607,81 +2615,81 @@ async function on(e, t, n, r) {
2607
2615
  status: "waiting"
2608
2616
  });
2609
2617
  }
2610
- function sn(e, t) {
2611
- ["complete", "exhausted"].includes(t.status) && t.items && (e.items = Q(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
2618
+ function cn(e, t) {
2619
+ ["complete", "exhausted"].includes(t.status) && t.items && (e.items = Z(e.items, t.items)), t.next !== void 0 && (e.next = t.next), t.total !== void 0 && (e.total = t.total);
2612
2620
  }
2613
- function cn(e, t, n) {
2621
+ function ln(e, t, n) {
2614
2622
  let r = t.autofill;
2615
- return !Xt(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);
2623
+ return !Zt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (cn(t, n), Object.assign(r, Q(n.status === "waiting" ? n.nextRequestAt : null)), r.error = n.error ?? null, r.missing = Math.max(0, (r.pageSize ?? 0) - n.received), r.received = n.received, n.requests !== void 0 && (r.requests = n.requests), r.sequence = n.sequence, r.status = n.status, !0);
2616
2624
  }
2617
- function ln(e, t, n) {
2618
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = qt(e, n), sn(t, n), !0);
2625
+ function un(e, t, n) {
2626
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Jt(e, n), cn(t, n), !0);
2619
2627
  }
2620
2628
  //#endregion
2621
2629
  //#region src/core/initialAutofill.ts
2622
- async function un({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, options: i, signal: a, state: o }) {
2623
- let s = i.autofill;
2624
- if (!s) return;
2625
- let c = o.items.length;
2626
- if (Object.assign(o.autofill, {
2627
- missing: Math.max(0, s.pageSize - c),
2628
- received: c,
2630
+ async function dn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, onPages: i, options: a, signal: o, state: s }) {
2631
+ let c = a.autofill;
2632
+ if (!c) return;
2633
+ let l = s.items.length;
2634
+ if (Object.assign(s.autofill, {
2635
+ missing: Math.max(0, c.pageSize - l),
2636
+ received: l,
2629
2637
  requests: 1
2630
- }), c >= s.pageSize) {
2631
- o.autofill.status = "complete";
2638
+ }), l >= c.pageSize) {
2639
+ s.autofill.status = "complete";
2632
2640
  return;
2633
2641
  }
2634
- if (s.strategy === "backend") {
2635
- await on(s, o, {
2642
+ if (c.strategy === "backend") {
2643
+ await sn(c, s, {
2636
2644
  cycleId: e,
2637
- feedKey: s.feedKey,
2638
- items: [...o.items],
2639
- missing: s.pageSize - c,
2640
- next: o.next,
2641
- pageSize: s.pageSize,
2642
- received: c,
2643
- signal: a,
2644
- total: o.total
2645
+ feedKey: c.feedKey,
2646
+ items: [...s.items],
2647
+ missing: c.pageSize - l,
2648
+ next: s.next,
2649
+ pageSize: c.pageSize,
2650
+ received: l,
2651
+ signal: o,
2652
+ total: s.total
2645
2653
  }, t);
2646
2654
  return;
2647
2655
  }
2648
- if (!i.loadPage || o.next === null) {
2649
- o.autofill.status = "exhausted";
2656
+ if (!a.loadPage || s.next === null) {
2657
+ s.autofill.status = "exhausted";
2650
2658
  return;
2651
2659
  }
2652
- let l = await Zt({
2653
- existingItems: o.items,
2654
- initialCursor: o.next,
2655
- loadPage: i.loadPage,
2656
- maximumRequests: Ut(s, !1),
2660
+ let u = await Qt({
2661
+ existingItems: s.items,
2662
+ initialCursor: s.next,
2663
+ loadPage: a.loadPage,
2664
+ maximumRequests: Wt(c, !1),
2657
2665
  onCollection: n,
2658
2666
  onDelayChange: (e) => {
2659
- t() && Object.assign(o.autofill, e);
2667
+ t() && Object.assign(s.autofill, e);
2660
2668
  },
2661
2669
  onProgress: (e) => {
2662
- t() && Object.assign(o.autofill, e, { status: "filling" });
2670
+ t() && Object.assign(s.autofill, e, { status: "filling" });
2663
2671
  },
2664
- options: s,
2665
- receivedOffset: c,
2672
+ options: c,
2673
+ receivedOffset: l,
2666
2674
  requestOffset: 1,
2667
- signal: a
2675
+ signal: o
2668
2676
  });
2669
- t() && (o.items = Q(o.items, l.items), o.next = l.next, l.total !== void 0 && (o.total = l.total), r(l.lastCursor), Object.assign(o.autofill, {
2670
- missing: l.missing,
2671
- received: l.received,
2672
- requests: l.requests,
2673
- status: l.status
2677
+ t() && (s.items = Z(s.items, u.items), s.next = u.next, u.total !== void 0 && (s.total = u.total), r(u.lastCursor), i(u.pages), Object.assign(s.autofill, {
2678
+ missing: u.missing,
2679
+ received: u.received,
2680
+ requests: u.requests,
2681
+ status: u.status
2674
2682
  }));
2675
2683
  }
2676
2684
  //#endregion
2677
2685
  //#region src/core/fill.ts
2678
- function dn(e) {
2686
+ function fn(e) {
2679
2687
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2680
2688
  }
2681
- function fn(e) {
2689
+ function pn(e) {
2682
2690
  return `${typeof e}:${String(e)}`;
2683
2691
  }
2684
- function pn(e) {
2692
+ function mn(e) {
2685
2693
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2686
2694
  if ("pages" in e) {
2687
2695
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2690,21 +2698,21 @@ function pn(e) {
2690
2698
  if ("until" in e && e.until === "end") return { until: "end" };
2691
2699
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2692
2700
  }
2693
- function mn(e) {
2701
+ function hn(e) {
2694
2702
  if (!e) return;
2695
2703
  if (e.strategy === "frontend") {
2696
- zt(e, "frontend fill");
2704
+ Bt(e, "frontend fill");
2697
2705
  return;
2698
2706
  }
2699
2707
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2700
2708
  let t = e.initialSession;
2701
2709
  if (t) {
2702
2710
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2703
- pn(t.target);
2711
+ mn(t.target);
2704
2712
  }
2705
2713
  }
2706
- function hn(e, t, n = !0) {
2707
- let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2714
+ function gn(e, t, n = !0) {
2715
+ let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = Q(i?.nextRequestAt);
2708
2716
  return {
2709
2717
  completedPages: i?.completedPages ?? 0,
2710
2718
  cycleId: i?.cycleId ?? null,
@@ -2717,10 +2725,10 @@ function hn(e, t, n = !0) {
2717
2725
  sessionId: i?.sessionId ?? null,
2718
2726
  status: i?.status ?? "idle",
2719
2727
  strategy: e?.strategy ?? null,
2720
- target: i ? dn(i.target) : null
2728
+ target: i ? fn(i.target) : null
2721
2729
  };
2722
2730
  }
2723
- function gn(e) {
2731
+ function _n(e) {
2724
2732
  return [
2725
2733
  "cancelling",
2726
2734
  "filling",
@@ -2728,64 +2736,72 @@ function gn(e) {
2728
2736
  "waiting"
2729
2737
  ].includes(e.status);
2730
2738
  }
2731
- async function _n({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2732
- let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2733
- for (; p !== null;) {
2734
- let e = fn(f);
2735
- if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2736
- u.add(e), await Vt({
2737
- delayMs: Bt(d, a),
2739
+ async function vn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2740
+ let c = [], l = [], u = [...e], d = /* @__PURE__ */ new Set(), f = 0, p = t, m = t, h = 0, g;
2741
+ for (; m !== null;) {
2742
+ let e = pn(p);
2743
+ if (d.has(e)) throw Error("Vibe fill received a repeated cursor.");
2744
+ d.add(e), await Ht({
2745
+ delayMs: Vt(f, a),
2738
2746
  onChange: r,
2739
2747
  signal: o
2740
2748
  });
2741
- let t = Nt(await n({
2742
- cursor: f,
2749
+ let t = Pt(await n({
2750
+ cursor: p,
2743
2751
  signal: o
2744
2752
  }));
2745
- d += 1;
2746
- let g = Q(l, t.items).slice(l.length);
2747
- if (l.push(...g), c.push(...g), m = c.length, p = t.next, t.total !== void 0 && (h = t.total), i({
2748
- completedPages: d,
2749
- next: p,
2750
- received: m
2751
- }), "pages" in s && d >= s.pages) return {
2752
- completedPages: d,
2753
+ f += 1;
2754
+ let _ = Z(u, t.items).slice(u.length);
2755
+ if (l.push({
2756
+ contributionIds: _.map(({ postId: e }) => e),
2757
+ cursor: p,
2758
+ next: t.next,
2759
+ returnedIds: t.items.map(({ postId: e }) => e)
2760
+ }), u.push(..._), c.push(..._), h = c.length, m = t.next, t.total !== void 0 && (g = t.total), i({
2761
+ completedPages: f,
2762
+ next: m,
2763
+ received: h
2764
+ }), "pages" in s && f >= s.pages) return {
2765
+ completedPages: f,
2753
2766
  items: c,
2754
- lastCursor: f,
2755
- next: p,
2756
- received: m,
2767
+ lastCursor: p,
2768
+ next: m,
2769
+ pages: l,
2770
+ received: h,
2757
2771
  status: "complete",
2758
- total: h
2772
+ total: g
2759
2773
  };
2760
- if (p === null) return {
2761
- completedPages: d,
2774
+ if (m === null) return {
2775
+ completedPages: f,
2762
2776
  items: c,
2763
- lastCursor: f,
2764
- next: p,
2765
- received: m,
2777
+ lastCursor: p,
2778
+ next: m,
2779
+ pages: l,
2780
+ received: h,
2766
2781
  status: "pages" in s ? "exhausted" : "complete",
2767
- total: h
2782
+ total: g
2768
2783
  };
2769
- f = p;
2784
+ p = m;
2770
2785
  }
2771
2786
  return {
2772
- completedPages: d,
2787
+ completedPages: f,
2773
2788
  items: c,
2774
- lastCursor: f,
2789
+ lastCursor: p,
2775
2790
  next: null,
2776
- received: m,
2791
+ pages: l,
2792
+ received: h,
2777
2793
  status: "pages" in s ? "exhausted" : "complete",
2778
- total: h
2794
+ total: g
2779
2795
  };
2780
2796
  }
2781
2797
  //#endregion
2782
2798
  //#region src/core/backendFill.ts
2783
- async function vn(e, t, n, r) {
2799
+ async function yn(e, t, n, r) {
2784
2800
  let i = await e.onStart(n);
2785
2801
  if (r()) {
2786
2802
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
2787
2803
  Object.assign(t.fill, {
2788
- ...$(i.nextRequestAt),
2804
+ ...Q(i.nextRequestAt),
2789
2805
  completedPages: i.completedPages ?? 0,
2790
2806
  received: i.received ?? 0,
2791
2807
  sequence: i.sequence ?? 0,
@@ -2794,23 +2810,23 @@ async function vn(e, t, n, r) {
2794
2810
  });
2795
2811
  }
2796
2812
  }
2797
- function yn(e, t, n) {
2813
+ function bn(e, t, n) {
2798
2814
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2799
2815
  }
2800
- function bn(e) {
2816
+ function xn(e) {
2801
2817
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2802
2818
  }
2803
- function xn(e, t) {
2819
+ function Sn(e, t) {
2804
2820
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2805
2821
  let n = e.fill.target;
2806
2822
  return !n || !Array.isArray(t.items) || t.next === void 0 || t.lastCursor === void 0 ? !1 : t.status === "exhausted" ? "pages" in n && t.completedPages < n.pages && t.next === null : "pages" in n ? t.completedPages === n.pages : t.next === null;
2807
2823
  }
2808
- function Sn(e, t, n) {
2809
- t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Q(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
2824
+ function Cn(e, t, n) {
2825
+ t.total !== void 0 && (e.total = t.total), ["complete", "exhausted"].includes(t.status) && (e.items = Z(e.items, t.items ?? []), e.next = t.next ?? null, n(t.lastCursor ?? null));
2810
2826
  }
2811
- function Cn(e, t, n, r) {
2812
- return !yn(e, t, n) || !bn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !xn(t, n) ? !1 : (Sn(t, n, r), Object.assign(t.fill, {
2813
- ...$(n.status === "waiting" ? n.nextRequestAt : null),
2827
+ function wn(e, t, n, r) {
2828
+ return !bn(e, t, n) || !xn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !Sn(t, n) ? !1 : (Cn(t, n, r), Object.assign(t.fill, {
2829
+ ...Q(n.status === "waiting" ? n.nextRequestAt : null),
2814
2830
  completedPages: n.completedPages,
2815
2831
  error: n.error ?? null,
2816
2832
  received: n.received,
@@ -2818,41 +2834,41 @@ function Cn(e, t, n, r) {
2818
2834
  status: n.status
2819
2835
  }), !0);
2820
2836
  }
2821
- function wn(e, t, n, r) {
2837
+ function Tn(e, t, n, r) {
2822
2838
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2823
2839
  let i = t.fill;
2824
- return t.fill = hn(e, n), !bn(n) || !xn(t, n) ? (t.fill = i, !1) : (Sn(t, n, r), !0);
2840
+ return t.fill = gn(e, n), !xn(n) || !Sn(t, n) ? (t.fill = i, !1) : (Cn(t, n, r), !0);
2825
2841
  }
2826
2842
  //#endregion
2827
2843
  //#region src/core/fillController.ts
2828
- var Tn = class {
2844
+ var En = class {
2829
2845
  abortController = null;
2830
2846
  cycle = 0;
2831
2847
  delayCountdown;
2832
2848
  requestVersion = 0;
2833
2849
  constructor(e) {
2834
- this.options = e, this.delayCountdown = new Ht((e) => {
2850
+ this.options = e, this.delayCountdown = new Ut((e) => {
2835
2851
  Object.assign(this.options.state.fill, e);
2836
2852
  }), this.syncBackendCountdown();
2837
2853
  }
2838
2854
  isActive() {
2839
- return gn(this.options.state.fill);
2855
+ return _n(this.options.state.fill);
2840
2856
  }
2841
2857
  applyUpdate(e) {
2842
- let t = Cn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2858
+ let t = wn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2843
2859
  return t && this.syncBackendCountdown(), t;
2844
2860
  }
2845
2861
  restoreSession(e) {
2846
- let t = wn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2862
+ let t = Tn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2847
2863
  return t && this.syncBackendCountdown(), t;
2848
2864
  }
2849
2865
  async start(e) {
2850
2866
  let t = this.options.fill;
2851
2867
  if (!t) throw Error("Vibe fill is not configured.");
2852
2868
  if (this.isActive()) throw Error("Vibe fill is already active.");
2853
- let n = pn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2869
+ let n = mn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2854
2870
  if (this.options.state.fill = {
2855
- ...hn(t, void 0, !1),
2871
+ ...gn(t, void 0, !1),
2856
2872
  cycleId: r,
2857
2873
  status: "filling",
2858
2874
  target: n
@@ -2863,7 +2879,7 @@ var Tn = class {
2863
2879
  let i = ++this.requestVersion, a = new AbortController();
2864
2880
  this.abortController = a;
2865
2881
  try {
2866
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await vn(t, this.options.state, {
2882
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await yn(t, this.options.state, {
2867
2883
  cycleId: r,
2868
2884
  feedKey: t.feedKey,
2869
2885
  items: [...this.options.state.items],
@@ -2881,7 +2897,7 @@ var Tn = class {
2881
2897
  }
2882
2898
  async cancel() {
2883
2899
  let { fill: e, state: t } = this.options;
2884
- if (!gn(t.fill) || !t.fill.cycleId) return;
2900
+ if (!_n(t.fill) || !t.fill.cycleId) return;
2885
2901
  let n = {
2886
2902
  cycleId: t.fill.cycleId,
2887
2903
  feedKey: t.fill.feedKey ?? "",
@@ -2895,7 +2911,7 @@ var Tn = class {
2895
2911
  }
2896
2912
  }
2897
2913
  reset() {
2898
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = hn(this.options.fill, void 0, !1);
2914
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = gn(this.options.fill, void 0, !1);
2899
2915
  }
2900
2916
  destroy() {
2901
2917
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2911,7 +2927,7 @@ var Tn = class {
2911
2927
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2912
2928
  let a = this.options.state;
2913
2929
  a.isLoadingMore = !0;
2914
- let o = await _n({
2930
+ let o = await vn({
2915
2931
  existingItems: a.items,
2916
2932
  initialCursor: a.next,
2917
2933
  loadPage: i,
@@ -2925,7 +2941,7 @@ var Tn = class {
2925
2941
  signal: n.signal,
2926
2942
  target: t
2927
2943
  });
2928
- this.isCurrent(r) && (a.items = Q(a.items, o.items), a.next = o.next, o.total !== void 0 && (a.total = o.total), this.options.onLastCursor(o.lastCursor), Object.assign(a.fill, {
2944
+ this.isCurrent(r) && (a.items = Z(a.items, o.items), a.next = o.next, o.total !== void 0 && (a.total = o.total), this.options.onLastCursor(o.lastCursor), this.options.onPages(o.pages), Object.assign(a.fill, {
2929
2945
  completedPages: o.completedPages,
2930
2946
  received: o.received,
2931
2947
  status: o.status
@@ -2938,7 +2954,7 @@ var Tn = class {
2938
2954
  };
2939
2955
  //#endregion
2940
2956
  //#region src/core/feedFooter.ts
2941
- function En(e) {
2957
+ function Dn(e) {
2942
2958
  return {
2943
2959
  cancelAutofill: () => e.cancelAutofill(),
2944
2960
  loadMore: () => e.loadNext(),
@@ -2946,62 +2962,62 @@ function En(e) {
2946
2962
  retryEnd: () => e.retryEnd()
2947
2963
  };
2948
2964
  }
2949
- function Dn(e) {
2950
- if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2951
- }
2952
2965
  function On(e) {
2953
- e?.intervalMs !== void 0 && Dn(e.intervalMs);
2966
+ if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2954
2967
  }
2955
2968
  function kn(e) {
2969
+ e?.intervalMs !== void 0 && On(e.intervalMs);
2970
+ }
2971
+ function An(e) {
2956
2972
  return {
2957
2973
  enabled: e?.enabled ?? !1,
2958
2974
  includePostItems: e?.includePostItems ?? !1,
2959
2975
  intervalMs: e?.intervalMs ?? 5e3
2960
2976
  };
2961
2977
  }
2962
- function An(e, t) {
2978
+ function jn(e, t) {
2963
2979
  if (typeof t == "boolean") {
2964
2980
  e.enabled = t;
2965
2981
  return;
2966
2982
  }
2967
- On(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
2983
+ kn(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
2968
2984
  }
2969
2985
  //#endregion
2970
2986
  //#region src/core/reelInfoSheet.ts
2971
- function jn(e) {
2987
+ function Mn(e) {
2972
2988
  return { enabled: e?.enabled ?? !1 };
2973
2989
  }
2974
- function Mn(e, t, n) {
2990
+ function Nn(e, t, n) {
2975
2991
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2976
2992
  e.enabled = n;
2977
2993
  }
2978
2994
  //#endregion
2979
2995
  //#region src/core/initialRuntimeState.ts
2980
- function Nn(e, t) {
2996
+ function Pn(e, t) {
2981
2997
  let n = e.initialPage;
2982
2998
  return {
2983
2999
  activeReelPostId: null,
2984
- autoScroll: rn(e.autoScroll),
2985
- autofill: qt(e.autofill),
3000
+ autoScroll: an(e.autoScroll),
3001
+ autofill: Jt(e.autofill),
2986
3002
  error: null,
2987
- fill: hn(e.fill),
3003
+ fill: gn(e.fill),
2988
3004
  infiniteScroll: e.infiniteScroll ?? !0,
2989
3005
  isLoading: !n,
2990
3006
  isLoadingMore: !1,
2991
- items: n ? Q([], n.items) : [],
3007
+ items: n ? Z([], n.items) : [],
2992
3008
  layout: t === "reel" ? "reel" : "masonry",
2993
3009
  loadMoreLocked: !1,
2994
3010
  mediaIndices: /* @__PURE__ */ new Map(),
2995
3011
  next: n?.next ?? null,
2996
3012
  nextPageError: null,
2997
- reelAutoAdvance: kn(e.reelAutoAdvance),
3013
+ reelAutoAdvance: An(e.reelAutoAdvance),
2998
3014
  reelForward: {
2999
3015
  error: null,
3000
3016
  status: "idle"
3001
3017
  },
3002
3018
  reelForwardIndex: null,
3003
3019
  reelForwardItem: null,
3004
- reelInfoSheet: jn(e.reelInfoSheet),
3020
+ reelInfoSheet: Mn(e.reelInfoSheet),
3005
3021
  reelInfoSheetOverlay: !1,
3006
3022
  reelMediaSource: "original",
3007
3023
  reelOrigin: null,
@@ -3010,26 +3026,34 @@ function Nn(e, t) {
3010
3026
  }
3011
3027
  //#endregion
3012
3028
  //#region src/core/options.ts
3013
- function Pn(e, t) {
3029
+ function Fn(e, t) {
3014
3030
  if (t) {
3015
3031
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
3016
3032
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
3017
3033
  }
3018
3034
  }
3019
- function Fn(e, t) {
3035
+ function In(e, t) {
3020
3036
  if (t) {
3021
3037
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
3022
3038
  for (let [n, r] of [["paddingX", t.paddingX], ["paddingY", t.paddingY]]) if (r !== void 0 && (!Number.isFinite(r) || r < 0)) throw TypeError(`Vibe mediaCard ${e} ${n} must be a non-negative number.`);
3023
3039
  }
3024
3040
  }
3025
- function In(e) {
3026
- if (nn(e.autoScroll), Pn("cardHeader", e.cardHeader), Pn("cardFooter", e.cardFooter), Fn("header", e.mediaCard?.header), Fn("footer", e.mediaCard?.footer), Kt(e.autofill), mn(e.fill), On(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
3041
+ function Ln(e) {
3042
+ if (rn(e.autoScroll), Fn("cardHeader", e.cardHeader), Fn("cardFooter", e.cardFooter), In("header", e.mediaCard?.header), In("footer", e.mediaCard?.footer), qt(e.autofill), hn(e.fill), kn(e.reelAutoAdvance), e.removalReconciliation) {
3043
+ if (!Number.isInteger(e.removalReconciliation.pageSize) || e.removalReconciliation.pageSize <= 0) throw TypeError("Vibe removalReconciliation pageSize must be a positive integer.");
3044
+ let t = e.removalReconciliation.maxReplayPages ?? 5;
3045
+ if (!Number.isInteger(t) || t <= 0) throw TypeError("Vibe removalReconciliation maxReplayPages must be a positive integer.");
3046
+ if (!e.loadPage) throw TypeError("Vibe removalReconciliation requires loadPage.");
3047
+ if (e.autofill?.strategy === "backend") throw TypeError("Vibe removalReconciliation does not support backend autofill.");
3048
+ if (e.fill?.strategy === "backend") throw TypeError("Vibe removalReconciliation does not support backend fill.");
3049
+ }
3050
+ if (e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
3027
3051
  if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
3028
3052
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
3029
3053
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
3030
3054
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
3031
3055
  }
3032
- function Ln(e) {
3056
+ function Rn(e) {
3033
3057
  if (typeof e != "string") return e;
3034
3058
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
3035
3059
  let t = document.querySelector(e);
@@ -3037,8 +3061,172 @@ function Ln(e) {
3037
3061
  return t;
3038
3062
  }
3039
3063
  //#endregion
3064
+ //#region src/core/pageRequest.ts
3065
+ async function zn({ append: e, autofillController: t, cursor: n, isCurrent: r, loadPage: i, onLastCursor: a, onPages: o, options: s, signal: c, state: l }) {
3066
+ let u = s.autofill, d = u ? t.beginCycle() : null, f = !1;
3067
+ try {
3068
+ if (u?.strategy === "frontend") {
3069
+ let s = await Qt({
3070
+ existingItems: e ? l.items : [],
3071
+ initialCursor: n,
3072
+ loadPage: i,
3073
+ onCollection: (e) => t.captureCollection(e, r()),
3074
+ onDelayChange: (e) => {
3075
+ r() && Object.assign(l.autofill, e);
3076
+ },
3077
+ onProgress: (e) => {
3078
+ r() && Object.assign(l.autofill, e, { status: "filling" });
3079
+ },
3080
+ options: u,
3081
+ signal: c
3082
+ });
3083
+ if (!r()) return;
3084
+ l.items = e ? Z(l.items, s.items) : [...s.items], a(s.lastCursor), l.next = s.next, s.total !== void 0 && (l.total = s.total), Object.assign(l.autofill, {
3085
+ missing: s.missing,
3086
+ received: s.received,
3087
+ requests: s.requests,
3088
+ status: s.status
3089
+ }), o(s.pages), t.clearCollection();
3090
+ return;
3091
+ }
3092
+ let s = Pt(await i({
3093
+ cursor: n,
3094
+ signal: c
3095
+ }));
3096
+ if (!r()) return;
3097
+ let p = e ? l.items : [], m = Z(p, s.items), h = m.length - p.length;
3098
+ if (l.items = m, a(n), o([{
3099
+ contributionIds: m.slice(p.length).map(({ postId: e }) => e),
3100
+ cursor: n,
3101
+ next: s.next,
3102
+ returnedIds: s.items.map(({ postId: e }) => e)
3103
+ }]), l.next = s.next, s.total !== void 0 && (l.total = s.total), f = !0, u?.strategy === "backend" && d) {
3104
+ if (Object.assign(l.autofill, {
3105
+ missing: Math.max(0, u.pageSize - h),
3106
+ received: h,
3107
+ requests: 1
3108
+ }), h >= u.pageSize) {
3109
+ l.autofill.status = "complete";
3110
+ return;
3111
+ }
3112
+ await sn(u, l, {
3113
+ cycleId: d,
3114
+ feedKey: u.feedKey,
3115
+ items: m.slice(p.length),
3116
+ missing: u.pageSize - h,
3117
+ next: s.next,
3118
+ pageSize: u.pageSize,
3119
+ received: h,
3120
+ signal: c,
3121
+ total: l.total
3122
+ }, r), t.syncCountdown();
3123
+ }
3124
+ } catch (t) {
3125
+ if (c.aborted || !r()) return;
3126
+ u && (l.autofill.error = t, l.autofill.status = "error"), f || (e ? l.nextPageError = t : l.error = t);
3127
+ } finally {
3128
+ r() && (t.clearCollection(), l.isLoading = !1, l.isLoadingMore = !1);
3129
+ }
3130
+ }
3131
+ //#endregion
3132
+ //#region src/core/removalReconciliationController.ts
3133
+ function $(e) {
3134
+ return `${typeof e}:${String(e)}`;
3135
+ }
3136
+ function Bn(e) {
3137
+ return `${typeof e}:${String(e)}`;
3138
+ }
3139
+ function Vn(e) {
3140
+ return e.map(({ postId: e }) => e);
3141
+ }
3142
+ var Hn = class {
3143
+ delay;
3144
+ enabled;
3145
+ maxReplayPages;
3146
+ pageSize;
3147
+ pages = [];
3148
+ tombstones = /* @__PURE__ */ new Set();
3149
+ constructor(e) {
3150
+ let t = e.removalReconciliation;
3151
+ this.enabled = !!t, this.maxReplayPages = t?.maxReplayPages ?? 5, this.pageSize = t?.pageSize ?? 0, this.delay = e.autofill?.strategy === "frontend" ? e.autofill : {
3152
+ delayMaxMs: 0,
3153
+ delayStepMs: 0
3154
+ };
3155
+ }
3156
+ completeReconciliation(e) {
3157
+ this.pages = [...this.pages.slice(0, e.replaceFrom), ...e.pages].slice(-this.maxReplayPages);
3158
+ }
3159
+ filterItems(e) {
3160
+ return !this.enabled || this.tombstones.size === 0 ? [...e] : e.filter(({ postId: e }) => !this.tombstones.has($(e)));
3161
+ }
3162
+ needsReconciliation(e) {
3163
+ return this.findUnderfilledPage(e) >= 0;
3164
+ }
3165
+ recordPages(e) {
3166
+ !this.enabled || e.length === 0 || (e.forEach((e) => this.recordPage(e)), this.pages = this.pages.slice(-this.maxReplayPages));
3167
+ }
3168
+ remove(e) {
3169
+ this.enabled && e.forEach((e) => this.tombstones.add($(e)));
3170
+ }
3171
+ reset() {
3172
+ this.pages = [], this.tombstones.clear();
3173
+ }
3174
+ restore(e) {
3175
+ this.enabled && e.forEach((e) => this.tombstones.delete($(e)));
3176
+ }
3177
+ async reconcile({ existingItems: e, loadPage: t, signal: n }) {
3178
+ let r = this.findUnderfilledPage(e), i = r < 0 ? [] : this.pages.slice(r), a = i[0];
3179
+ if (!a) throw Error("Vibe has no underfilled provider page to reconcile.");
3180
+ let o = new Set(i.flatMap(({ contributionIds: e }) => e.map($))), s = new Set(e.map(({ postId: e }) => $(e)).filter((e) => !o.has(e))), c = new Set(e.map(({ postId: e }) => $(e))), l = new Set(s), u = new Set(c), d = [], f = [], p = /* @__PURE__ */ new Set(), m = a.cursor, h = m, g = m, _;
3181
+ for (let e = 0; e < i.length; e += 1) {
3182
+ let r = Bn(m);
3183
+ if (p.has(r)) throw Error("Vibe removal reconciliation received a repeated cursor.");
3184
+ p.add(r), await Ht({
3185
+ delayMs: Vt(e, this.delay),
3186
+ onChange: () => void 0,
3187
+ signal: n
3188
+ });
3189
+ let i = Pt(await t({
3190
+ cursor: m,
3191
+ signal: n
3192
+ })), a = this.filterItems(i.items), o = [];
3193
+ if (a.forEach((e) => {
3194
+ let t = $(e.postId);
3195
+ l.has(t) || (l.add(t), o.push(e.postId)), u.has(t) || (u.add(t), d.push(e));
3196
+ }), f.push({
3197
+ contributionIds: o,
3198
+ cursor: m,
3199
+ next: i.next,
3200
+ returnedIds: Vn(a)
3201
+ }), h = m, g = i.next, i.total !== void 0 && (_ = i.total), g === null) break;
3202
+ m = g;
3203
+ }
3204
+ return {
3205
+ items: d,
3206
+ lastCursor: h,
3207
+ next: g,
3208
+ pages: f,
3209
+ replaceFrom: r,
3210
+ total: _
3211
+ };
3212
+ }
3213
+ findUnderfilledPage(e) {
3214
+ if (!this.enabled || this.pages.length === 0) return -1;
3215
+ let t = new Set(e.map(({ postId: e }) => $(e)));
3216
+ return this.pages.findIndex(({ contributionIds: e }) => e.filter((e) => t.has($(e))).length < this.pageSize);
3217
+ }
3218
+ recordPage(e) {
3219
+ let t = Bn(e.cursor), n = this.pages.findIndex(({ cursor: e }) => Bn(e) === t);
3220
+ n >= 0 && (this.pages = this.pages.slice(0, n)), this.pages.push({
3221
+ ...e,
3222
+ contributionIds: [...e.contributionIds],
3223
+ returnedIds: [...e.returnedIds]
3224
+ });
3225
+ }
3226
+ };
3227
+ //#endregion
3040
3228
  //#region src/core/activeItemRemoval.ts
3041
- function Rn(e, t, n, r, i) {
3229
+ function Un(e, t, n, r, i) {
3042
3230
  let a = new Set(t.map(({ item: e }) => e.postId));
3043
3231
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
3044
3232
  let o = e.items[Math.max(n, 0)];
@@ -3051,7 +3239,7 @@ function Rn(e, t, n, r, i) {
3051
3239
  }
3052
3240
  //#endregion
3053
3241
  //#region src/core/exactMediaRemovalController.ts
3054
- function zn(e, t) {
3242
+ function Wn(e, t) {
3055
3243
  let [n, ...r] = t;
3056
3244
  if (!n) throw Error("Vibe items must contain at least one media asset.");
3057
3245
  return {
@@ -3060,10 +3248,10 @@ function zn(e, t) {
3060
3248
  items: r
3061
3249
  };
3062
3250
  }
3063
- function Bn(e) {
3251
+ function Gn(e) {
3064
3252
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
3065
3253
  }
3066
- var Vn = class {
3254
+ var Kn = class {
3067
3255
  generation = 0;
3068
3256
  metadata = /* @__PURE__ */ new WeakMap();
3069
3257
  state;
@@ -3071,7 +3259,7 @@ var Vn = class {
3071
3259
  this.options = e, this.state = e.state;
3072
3260
  }
3073
3261
  remove(e) {
3074
- Bn(e);
3262
+ Gn(e);
3075
3263
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
3076
3264
  if (!n) return null;
3077
3265
  let r = [...M(n)], i = r[e.mediaIndex];
@@ -3088,7 +3276,7 @@ var Vn = class {
3088
3276
  restored: !1
3089
3277
  });
3090
3278
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
3091
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = zn(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
3279
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Wn(n, r), this.updateMediaIndexAfterRemoval(n.postId, e.mediaIndex, c), a) : (this.state.items.splice(t, 1), this.options.onPostRemoved(n.postId), this.state.mediaIndices.delete(n.postId), s && this.advanceFromRemovedPost(a, n), a);
3092
3280
  }
3093
3281
  reset() {
3094
3282
  this.generation += 1;
@@ -3097,7 +3285,7 @@ var Vn = class {
3097
3285
  let t = this.metadata.get(e);
3098
3286
  if (!t) throw TypeError("Vibe media removal does not belong to this instance.");
3099
3287
  if (t.generation !== this.generation || t.restored) return !1;
3100
- t.restored = !0;
3288
+ t.restored = !0, this.options.onPostRestored(e.postId);
3101
3289
  let n = this.state.items.findIndex(({ postId: t }) => t === e.postId);
3102
3290
  return n >= 0 ? this.restoreIntoPost(n, e) : this.state.items.splice(Math.min(e.postIndex, this.state.items.length), 0, t.originalItem), this.options.reelForward.cancel(e) && (this.state.mediaIndices.set(e.postId, e.mediaIndex), this.options.onActivate(e.postId)), !0;
3103
3291
  }
@@ -3114,7 +3302,7 @@ var Vn = class {
3114
3302
  }
3115
3303
  restoreIntoPost(e, t) {
3116
3304
  let n = this.state.items[e], r = [...M(n)], i = Math.min(t.mediaIndex, r.length);
3117
- if (r.splice(i, 0, t.media), this.state.items[e] = zn(n, r), this.state.activeReelPostId !== t.postId) return;
3305
+ if (r.splice(i, 0, t.media), this.state.items[e] = Wn(n, r), this.state.activeReelPostId !== t.postId) return;
3118
3306
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
3119
3307
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
3120
3308
  }
@@ -3127,18 +3315,18 @@ var Vn = class {
3127
3315
  };
3128
3316
  //#endregion
3129
3317
  //#region src/core/itemPlacement.ts
3130
- function Hn(e, t) {
3318
+ function qn(e, t) {
3131
3319
  let n = new Set(t);
3132
3320
  return e.flatMap((e, t) => n.has(e.postId) ? [{
3133
3321
  index: t,
3134
3322
  item: e
3135
3323
  }] : []);
3136
3324
  }
3137
- function Un(e, t) {
3325
+ function Jn(e, t) {
3138
3326
  let n = new Set(t.map(({ item: e }) => e.postId));
3139
3327
  return e.filter((e) => !n.has(e.postId));
3140
3328
  }
3141
- function Wn(e, t) {
3329
+ function Yn(e, t) {
3142
3330
  t.forEach(({ index: e }) => {
3143
3331
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
3144
3332
  });
@@ -3149,7 +3337,7 @@ function Wn(e, t) {
3149
3337
  }
3150
3338
  //#endregion
3151
3339
  //#region src/core/itemRemovalController.ts
3152
- var Gn = 20, Kn = class {
3340
+ var Xn = 20, Zn = class {
3153
3341
  generation = 0;
3154
3342
  historyLimit;
3155
3343
  metadata = /* @__PURE__ */ new WeakMap();
@@ -3158,7 +3346,7 @@ var Gn = 20, Kn = class {
3158
3346
  itemOrder;
3159
3347
  stopItemsWatcher;
3160
3348
  constructor(e) {
3161
- this.options = e, this.historyLimit = e.historyLimit ?? Gn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
3349
+ this.options = e, this.historyLimit = e.historyLimit ?? Xn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = O(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
3162
3350
  }
3163
3351
  destroy() {
3164
3352
  this.reset(), this.stopItemsWatcher();
@@ -3171,7 +3359,7 @@ var Gn = 20, Kn = class {
3171
3359
  let i = this.options.startRemoval(r);
3172
3360
  if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
3173
3361
  let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId), o = new Set(t.map(({ item: e }) => e.postId)), s = a < 0 ? 0 : this.state.items.slice(0, a).filter(({ postId: e }) => o.has(e)).length, c = Math.max(a - s, 0);
3174
- return this.state.items = Un(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3362
+ return this.state.items = Jn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3175
3363
  }
3176
3364
  reset() {
3177
3365
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -3182,7 +3370,7 @@ var Gn = 20, Kn = class {
3182
3370
  this.restoreRemoval(t);
3183
3371
  return;
3184
3372
  }
3185
- let n = Wn(this.state.items, e);
3373
+ let n = Yn(this.state.items, e);
3186
3374
  this.registerExternalPlacements(e), this.state.items = n;
3187
3375
  }
3188
3376
  restoreRemoval(e) {
@@ -3208,7 +3396,7 @@ var Gn = 20, Kn = class {
3208
3396
  }
3209
3397
  collectOrderedPlacements(e) {
3210
3398
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
3211
- return Hn(this.state.items, e).map((e) => ({
3399
+ return qn(this.state.items, e).map((e) => ({
3212
3400
  index: t.get(e.item.postId) ?? e.index,
3213
3401
  item: e.item
3214
3402
  }));
@@ -3239,7 +3427,7 @@ var Gn = 20, Kn = class {
3239
3427
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
3240
3428
  return this.state.items = [...this.state.items, ...n].sort((e, t) => (r.get(e.postId) ?? 2 ** 53 - 1) - (r.get(t.postId) ?? 2 ** 53 - 1)), !0;
3241
3429
  }
3242
- }, qn = class {
3430
+ }, Qn = class {
3243
3431
  forward = null;
3244
3432
  forwardPromise = null;
3245
3433
  forwardVersion = 0;
@@ -3317,7 +3505,7 @@ var Gn = 20, Kn = class {
3317
3505
  }
3318
3506
  }
3319
3507
  }
3320
- }, Jn = class {
3508
+ }, $n = class {
3321
3509
  generation = 0;
3322
3510
  pending = Promise.resolve();
3323
3511
  constructor(e) {
@@ -3367,24 +3555,27 @@ var Gn = 20, Kn = class {
3367
3555
  };
3368
3556
  //#endregion
3369
3557
  //#region src/core/removalControllers.ts
3370
- function Yn(e) {
3371
- let t = new qn(e), n = new Jn({
3558
+ function er(e) {
3559
+ let t = new Qn(e), n = new $n({
3372
3560
  state: e.state,
3373
3561
  transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
3374
3562
  transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
3375
3563
  });
3376
3564
  return {
3377
- exactMediaRemoval: new Vn({
3565
+ exactMediaRemoval: new Kn({
3378
3566
  onActivate: e.onActivate,
3567
+ onPostRemoved: (t) => e.onItemsRemoved([t]),
3568
+ onPostRestored: (t) => e.onItemsRestored([t]),
3379
3569
  reelForward: t,
3380
3570
  state: e.state
3381
3571
  }),
3382
- itemRemoval: new Kn({
3572
+ itemRemoval: new Zn({
3383
3573
  historyLimit: e.historyLimit,
3384
3574
  onItemsRemoved: (n, r, i) => {
3385
- Rn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3575
+ e.onItemsRemoved(r.map(({ item: e }) => e.postId)), Un(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3386
3576
  },
3387
3577
  onRemovalRestored: (n) => {
3578
+ e.onItemsRestored(n.map(({ item: e }) => e.postId));
3388
3579
  let r = t.cancel(n);
3389
3580
  r && e.onActivate(r.postId);
3390
3581
  },
@@ -3396,17 +3587,17 @@ function Yn(e) {
3396
3587
  reelRemoval: n
3397
3588
  };
3398
3589
  }
3399
- var Xn = 1.5;
3400
- function Zn(e) {
3590
+ var tr = 1.5;
3591
+ function nr(e) {
3401
3592
  let t = Math.min(e.screenWidth, e.screenHeight);
3402
3593
  if (t > 0 && t < 600) return !0;
3403
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Xn;
3594
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * tr;
3404
3595
  return !e.hasHover && n > 0 && n < 600 && r;
3405
3596
  }
3406
- function Qn(e) {
3407
- return Zn(e) ? "reel" : "masonry";
3597
+ function rr(e) {
3598
+ return nr(e) ? "reel" : "masonry";
3408
3599
  }
3409
- function $n(e) {
3600
+ function ir(e) {
3410
3601
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3411
3602
  return {
3412
3603
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3416,15 +3607,15 @@ function $n(e) {
3416
3607
  viewportWidth: n.clientWidth
3417
3608
  };
3418
3609
  }
3419
- function er(e) {
3420
- return Zn($n(e));
3610
+ function ar(e) {
3611
+ return nr(ir(e));
3421
3612
  }
3422
- function tr(e) {
3423
- return Qn($n(e));
3613
+ function or(e) {
3614
+ return rr(ir(e));
3424
3615
  }
3425
3616
  //#endregion
3426
3617
  //#region src/core/responsiveLayoutController.ts
3427
- var nr = class {
3618
+ var sr = class {
3428
3619
  layoutMode;
3429
3620
  resizeObserver = null;
3430
3621
  target = null;
@@ -3449,10 +3640,10 @@ var nr = class {
3449
3640
  }
3450
3641
  handleResponsiveLayout = () => {
3451
3642
  if (!this.target) return;
3452
- let e = tr(this.target);
3453
- this.state.reelInfoSheetOverlay = er(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3643
+ let e = or(this.target);
3644
+ this.state.reelInfoSheetOverlay = ar(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3454
3645
  };
3455
- }, rr = class {
3646
+ }, cr = class {
3456
3647
  routedReelPostId = null;
3457
3648
  reelRouteIsActive = !1;
3458
3649
  constructor(e, t) {
@@ -3479,7 +3670,7 @@ var nr = class {
3479
3670
  let i = this.reelRouteIsActive ? "replace" : "push";
3480
3671
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3481
3672
  }
3482
- }, ir = class {
3673
+ }, lr = class {
3483
3674
  app = null;
3484
3675
  autoScroll;
3485
3676
  autofillController;
@@ -3491,6 +3682,7 @@ var nr = class {
3491
3682
  fillController;
3492
3683
  exactMediaRemoval;
3493
3684
  itemRemoval;
3685
+ removalReconciliation;
3494
3686
  reelForward;
3495
3687
  reelRemoval;
3496
3688
  surface = null;
@@ -3498,48 +3690,51 @@ var nr = class {
3498
3690
  lastLoadedCursor = null;
3499
3691
  state;
3500
3692
  constructor(e) {
3501
- this.options = e, In(e);
3693
+ this.options = e, Ln(e);
3502
3694
  let t = e.layout ?? "masonry";
3503
- this.state = x(Nn(e, t)), this.autoScroll = new an({
3695
+ this.state = x(Pn(e, t)), this.autoScroll = new on({
3504
3696
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
3505
3697
  state: this.state.autoScroll
3506
- }), this.autofillController = new Qt({
3698
+ }), this.autofillController = new $t({
3507
3699
  cancelRequest: () => this.cancelRequest(),
3508
3700
  onLastCursor: (e) => {
3509
3701
  this.lastLoadedCursor = e;
3510
3702
  },
3511
3703
  options: e.autofill,
3512
3704
  state: this.state
3513
- }), this.fillController = new Tn({
3705
+ }), this.removalReconciliation = new Hn(e), this.fillController = new En({
3514
3706
  fill: e.fill,
3515
- loadPage: e.loadPage,
3707
+ loadPage: e.loadPage ? (e) => this.loadFilteredPage(e) : void 0,
3516
3708
  onLastCursor: (e) => {
3517
3709
  this.lastLoadedCursor = e;
3518
3710
  },
3711
+ onPages: (e) => this.removalReconciliation.recordPages(e),
3519
3712
  state: this.state
3520
- }), this.routing = new rr(e.routing, this.state);
3521
- let n = Yn({
3713
+ }), this.routing = new cr(e.routing, this.state);
3714
+ let n = er({
3522
3715
  historyLimit: e.removalHistoryLimit,
3523
3716
  loadNext: () => this.loadNext(),
3524
3717
  onActivate: (e) => this.setActiveReelPost(e),
3718
+ onItemsRemoved: (e) => this.removalReconciliation.remove(e),
3719
+ onItemsRestored: (e) => this.removalReconciliation.restore(e),
3525
3720
  retryEnd: () => this.retryEnd(),
3526
3721
  state: this.state,
3527
3722
  surface: () => this.surface
3528
3723
  });
3529
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new nr(t, this.state, () => {
3724
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new sr(t, this.state, () => {
3530
3725
  this.routing.syncFeed();
3531
3726
  }), this.startStateNotifications();
3532
3727
  }
3533
3728
  async mount() {
3534
3729
  if (this.app) throw Error("Vibe is already mounted.");
3535
3730
  this.startStateNotifications();
3536
- let e = Ln(this.options.target);
3537
- this.responsiveLayout.mount(e), this.app = i(Mt, {
3731
+ let e = Rn(this.options.target);
3732
+ this.responsiveLayout.mount(e), this.app = i(Nt, {
3538
3733
  canRetryEnd: !!this.options.loadPage,
3539
3734
  cardFooter: this.options.cardFooter,
3540
3735
  cardHeader: this.options.cardHeader,
3541
3736
  feedFooter: this.options.feedFooter,
3542
- feedFooterActions: En(this),
3737
+ feedFooterActions: Dn(this),
3543
3738
  mediaCard: this.options.mediaCard,
3544
3739
  onMediaReady: this.options.onMediaReady,
3545
3740
  onReelMediaChange: this.options.onReelMediaChange,
@@ -3563,7 +3758,7 @@ var nr = class {
3563
3758
  }), this.surface = this.app.mount(e), this.autoScroll.mount(), this.options.initialPage ? this.options.autofill && this.state.autofill.status === "idle" && !this.fillController.isActive() && await this.startInitialAutofill() : await this.reload();
3564
3759
  }
3565
3760
  destroy() {
3566
- this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3761
+ this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.destroy(), this.removalReconciliation.reset(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
3567
3762
  }
3568
3763
  getState() {
3569
3764
  return R(this.state);
@@ -3620,7 +3815,7 @@ var nr = class {
3620
3815
  this.autoScroll.setSpeed(e);
3621
3816
  }
3622
3817
  applyAutofillUpdate(e) {
3623
- let t = cn(this.options.autofill, this.state, e);
3818
+ let t = ln(this.options.autofill, this.state, e);
3624
3819
  return t && this.autofillController.syncCountdown(), t;
3625
3820
  }
3626
3821
  cancelAutofill() {
@@ -3633,11 +3828,11 @@ var nr = class {
3633
3828
  return this.fillController.cancel();
3634
3829
  }
3635
3830
  async fill(e) {
3636
- if (this.pendingRequest || Jt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3831
+ if (this.pendingRequest || Yt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3637
3832
  await this.fillController.start(e);
3638
3833
  }
3639
3834
  restoreAutofillSession(e) {
3640
- let t = ln(this.options.autofill, this.state, e);
3835
+ let t = un(this.options.autofill, this.state, e);
3641
3836
  return t && this.autofillController.syncCountdown(), t;
3642
3837
  }
3643
3838
  restoreFillSession(e) {
@@ -3645,7 +3840,12 @@ var nr = class {
3645
3840
  }
3646
3841
  async loadNext() {
3647
3842
  if (this.pendingRequest) return this.pendingRequest;
3648
- if (!this.state.loadMoreLocked && !(Jt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next === null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.state.next, !0);
3843
+ if (this.state.loadMoreLocked || Yt(this.state.autofill) || this.fillController.isActive() || !this.options.loadPage || this.state.next === null && !this.removalReconciliation.needsReconciliation(this.state.items)) return;
3844
+ this.state.isLoadingMore = !0, this.state.nextPageError = null;
3845
+ let e = this.loadNextSequence();
3846
+ return this.pendingRequest = e, e.finally(() => {
3847
+ this.pendingRequest === e && (this.pendingRequest = null), this.state.isLoadingMore = !1;
3848
+ });
3649
3849
  }
3650
3850
  async refresh() {
3651
3851
  return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
@@ -3655,11 +3855,41 @@ var nr = class {
3655
3855
  }
3656
3856
  async replaceFeed(e, t) {
3657
3857
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
3658
- return Jt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = qt(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3858
+ return Yt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Jt(this.options.autofill, void 0, !1), this.fillController.reset(), this.reelForward.reset(), this.reelRemoval.reset(), this.exactMediaRemoval.reset(), this.itemRemoval.reset(), this.removalReconciliation.reset(), this.state.error = null, this.state.isLoading = !0, this.state.items = [], this.state.next = null, this.state.nextPageError = null, this.state.total = null, this.startRequest(e, !1);
3859
+ }
3860
+ async loadFilteredPage(e) {
3861
+ let t = this.options.loadPage;
3862
+ if (!t) throw Error("Vibe cannot load a page without loadPage.");
3863
+ let n = Pt(await t(e));
3864
+ return {
3865
+ ...n,
3866
+ items: this.removalReconciliation.filterItems(n.items)
3867
+ };
3868
+ }
3869
+ async loadNextSequence() {
3870
+ this.removalReconciliation.needsReconciliation(this.state.items) && !await this.reconcileBeforeNext() || this.state.next !== null && await this.fetchPage(this.state.next, !0);
3871
+ }
3872
+ async reconcileBeforeNext() {
3873
+ let e = this.options.loadPage;
3874
+ if (!e) return !1;
3875
+ let t = ++this.requestVersion, n = new AbortController();
3876
+ this.abortController = n;
3877
+ try {
3878
+ let r = await this.removalReconciliation.reconcile({
3879
+ existingItems: this.state.items,
3880
+ loadPage: e,
3881
+ signal: n.signal
3882
+ });
3883
+ return t === this.requestVersion ? (this.state.items = Z(this.state.items, r.items), this.state.next = r.next, this.lastLoadedCursor = r.lastCursor, r.total !== void 0 && (this.state.total = r.total), this.removalReconciliation.completeReconciliation(r), !0) : !1;
3884
+ } catch (e) {
3885
+ return !n.signal.aborted && t === this.requestVersion && (this.state.nextPageError = e), !1;
3886
+ } finally {
3887
+ this.abortController === n && (this.abortController = null);
3888
+ }
3659
3889
  }
3660
3890
  async retryEnd() {
3661
3891
  if (this.pendingRequest) return this.pendingRequest;
3662
- if (!this.state.loadMoreLocked && !(Jt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
3892
+ if (!this.state.loadMoreLocked && !(Yt(this.state.autofill) || this.fillController.isActive()) && !(this.state.next !== null || !this.options.loadPage)) return this.state.isLoadingMore = !0, this.state.nextPageError = null, this.startRequest(this.lastLoadedCursor, !0);
3663
3893
  }
3664
3894
  setInfiniteScroll(e) {
3665
3895
  this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
@@ -3668,10 +3898,10 @@ var nr = class {
3668
3898
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && m(() => this.surface?.loadIfNearBottom()));
3669
3899
  }
3670
3900
  setReelAutoAdvance(e) {
3671
- An(this.state.reelAutoAdvance, e);
3901
+ jn(this.state.reelAutoAdvance, e);
3672
3902
  }
3673
3903
  setReelInfoSheet(e) {
3674
- Mn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3904
+ Nn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3675
3905
  }
3676
3906
  setLayout(e) {
3677
3907
  this.responsiveLayout.setLayout(e);
@@ -3689,68 +3919,22 @@ var nr = class {
3689
3919
  this.autofillController.clearCountdown(), this.requestVersion += 1, this.abortController?.abort(), this.abortController = null, this.pendingRequest = null, this.state.isLoading = !1, this.state.isLoadingMore = !1;
3690
3920
  }
3691
3921
  async fetchPage(e, t) {
3692
- let n = this.options.loadPage;
3693
- if (!n) return;
3694
- let r = ++this.requestVersion, i = new AbortController(), a = this.options.autofill, o = a ? this.autofillController.beginCycle() : null, s = !1;
3695
- this.abortController = i;
3696
- try {
3697
- if (a?.strategy === "frontend") {
3698
- let o = await Zt({
3699
- existingItems: t ? this.state.items : [],
3700
- initialCursor: e,
3701
- loadPage: n,
3702
- onCollection: (e) => this.autofillController.captureCollection(e, r === this.requestVersion),
3703
- onDelayChange: (e) => {
3704
- r === this.requestVersion && Object.assign(this.state.autofill, e);
3705
- },
3706
- onProgress: (e) => {
3707
- r === this.requestVersion && Object.assign(this.state.autofill, e, { status: "filling" });
3708
- },
3709
- options: a,
3710
- signal: i.signal
3711
- });
3712
- if (r !== this.requestVersion) return;
3713
- this.state.items = t ? Q(this.state.items, o.items) : [...o.items], this.lastLoadedCursor = o.lastCursor, this.state.next = o.next, o.total !== void 0 && (this.state.total = o.total), Object.assign(this.state.autofill, {
3714
- missing: o.missing,
3715
- received: o.received,
3716
- requests: o.requests,
3717
- status: o.status
3718
- }), this.autofillController.clearCollection();
3719
- return;
3720
- }
3721
- let c = Nt(await n({
3722
- cursor: e,
3723
- signal: i.signal
3724
- }));
3725
- if (r !== this.requestVersion) return;
3726
- let l = t ? this.state.items : [], u = Q(l, c.items), d = u.length - l.length;
3727
- if (this.state.items = u, this.lastLoadedCursor = e, this.state.next = c.next, c.total !== void 0 && (this.state.total = c.total), s = !0, a?.strategy === "backend" && o) {
3728
- if (Object.assign(this.state.autofill, {
3729
- missing: Math.max(0, a.pageSize - d),
3730
- received: d,
3731
- requests: 1
3732
- }), d >= a.pageSize) {
3733
- this.state.autofill.status = "complete";
3734
- return;
3735
- }
3736
- await on(a, this.state, {
3737
- cycleId: o,
3738
- feedKey: a.feedKey,
3739
- items: u.slice(l.length),
3740
- missing: a.pageSize - d,
3741
- next: c.next,
3742
- pageSize: a.pageSize,
3743
- received: d,
3744
- signal: i.signal,
3745
- total: this.state.total
3746
- }, () => r === this.requestVersion), this.autofillController.syncCountdown();
3747
- }
3748
- } catch (e) {
3749
- if (i.signal.aborted || r !== this.requestVersion) return;
3750
- a && (this.state.autofill.error = e, this.state.autofill.status = "error"), s || (t ? this.state.nextPageError = e : this.state.error = e);
3751
- } finally {
3752
- r === this.requestVersion && (this.autofillController.clearCollection(), this.abortController = null, this.state.isLoading = !1, this.state.isLoadingMore = !1);
3753
- }
3922
+ if (!this.options.loadPage) return;
3923
+ let n = ++this.requestVersion, r = new AbortController();
3924
+ this.abortController = r, await zn({
3925
+ append: t,
3926
+ autofillController: this.autofillController,
3927
+ cursor: e,
3928
+ isCurrent: () => n === this.requestVersion,
3929
+ loadPage: (e) => this.loadFilteredPage(e),
3930
+ onLastCursor: (e) => {
3931
+ this.lastLoadedCursor = e;
3932
+ },
3933
+ onPages: (e) => this.removalReconciliation.recordPages(e),
3934
+ options: this.options,
3935
+ signal: r.signal,
3936
+ state: this.state
3937
+ }), n === this.requestVersion && (this.abortController = null);
3754
3938
  }
3755
3939
  startRequest(e, t) {
3756
3940
  let n = this.fetchPage(e, t);
@@ -3761,13 +3945,14 @@ var nr = class {
3761
3945
  startInitialAutofill() {
3762
3946
  let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
3763
3947
  this.abortController = t, this.state.isLoadingMore = !0;
3764
- let r = un({
3948
+ let r = dn({
3765
3949
  cycleId: n,
3766
3950
  isCurrent: () => e === this.requestVersion,
3767
3951
  onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
3768
3952
  onLastCursor: (e) => {
3769
3953
  this.lastLoadedCursor = e;
3770
3954
  },
3955
+ onPages: (e) => this.removalReconciliation.recordPages(e),
3771
3956
  options: this.options,
3772
3957
  signal: t.signal,
3773
3958
  state: this.state
@@ -3786,8 +3971,8 @@ var nr = class {
3786
3971
  }));
3787
3972
  }
3788
3973
  };
3789
- function ar(e) {
3790
- return new ir(e);
3974
+ function ur(e) {
3975
+ return new lr(e);
3791
3976
  }
3792
3977
  //#endregion
3793
- export { ar as createVibe };
3978
+ export { ur as createVibe };