@wyxos/vibe 4.2.0 → 4.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -138,7 +138,7 @@ var I = {
138
138
  "load-more-locked"
139
139
  ]));
140
140
  }
141
- }), W = ["role"], ee = { class: "gallery-status" }, G = /* @__PURE__ */ u({
141
+ }), W = ["role"], ee = { class: "gallery-status" }, te = /* @__PURE__ */ u({
142
142
  __name: "FeedStatus",
143
143
  props: {
144
144
  actions: {},
@@ -178,33 +178,33 @@ var I = {
178
178
  ])) : a("", !0)], 8, W));
179
179
  }
180
180
  });
181
- function K(e) {
181
+ function G(e) {
182
182
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
183
183
  }
184
184
  //#endregion
185
185
  //#region src/core/masonry.ts
186
- function te(e) {
186
+ function ne(e) {
187
187
  let t = e.preview.width ?? e.width, n = e.preview.height ?? e.height;
188
188
  return !t || !n || t <= 0 || n <= 0 ? 1 : n / t;
189
189
  }
190
- function ne(e) {
190
+ function K(e) {
191
191
  return e.reduce((t, n, r) => n < e[t] ? r : t, 0);
192
192
  }
193
- function re(e) {
193
+ function q(e) {
194
194
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
195
195
  }
196
- function q(e, t) {
196
+ function J(e, t) {
197
197
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
198
198
  return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
199
199
  }
200
- function J(e, t, n) {
200
+ function Y(e, t, n) {
201
201
  if (t <= 0 || e.length === 0) return {
202
202
  columns: 0,
203
203
  height: 0,
204
204
  items: []
205
205
  };
206
206
  let r = Math.max(0, n.gap), i = Number.isFinite(n.additionalHeight) ? Math.max(0, n.additionalHeight ?? 0) : 0, a = Math.max(1, n.minColumnWidth), o = Math.max(1, Math.floor((t + r) / (a + r))), s = (t - r * (o - 1)) / o, c = Array.from({ length: o }, () => 0), l = e.map((e) => {
207
- let t = ne(c), n = s * te(e) + i, a = {
207
+ let t = K(c), n = s * ne(e) + i, a = {
208
208
  x: t * (s + r),
209
209
  y: c[t],
210
210
  width: s,
@@ -220,10 +220,10 @@ function J(e, t, n) {
220
220
  }
221
221
  //#endregion
222
222
  //#region src/core/scrollbar.ts
223
- function Y(e, t, n) {
223
+ function X(e, t, n) {
224
224
  return Math.min(n, Math.max(t, e));
225
225
  }
226
- function ie({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
226
+ function re({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
227
227
  let a = Math.max(0, e), o = Math.max(0, r), s = Math.max(0, i), c = Math.max(0, a - s);
228
228
  if (!(c > 0 && o > 0)) return {
229
229
  maximumScrollPosition: c,
@@ -232,18 +232,18 @@ function ie({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
232
232
  thumbSize: o,
233
233
  thumbTravel: 0
234
234
  };
235
- let l = Y(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
235
+ let l = X(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
236
236
  return {
237
237
  maximumScrollPosition: c,
238
238
  scrollable: !0,
239
- thumbOffset: u * (Y(n, 0, c) / c),
239
+ thumbOffset: u * (X(n, 0, c) / c),
240
240
  thumbSize: l,
241
241
  thumbTravel: u
242
242
  };
243
243
  }
244
244
  //#endregion
245
245
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
246
- var ae = ["aria-hidden"], X = [
246
+ var ie = ["aria-hidden"], ae = [
247
247
  "aria-controls",
248
248
  "aria-valuemax",
249
249
  "aria-valuenow",
@@ -277,7 +277,7 @@ var ae = ["aria-hidden"], X = [
277
277
  }
278
278
  function j() {
279
279
  let e = t.scrollElement, n = i.value;
280
- return !e || !n ? r : ie({
280
+ return !e || !n ? r : re({
281
281
  contentSize: e.scrollHeight,
282
282
  minimumThumbSize: Z,
283
283
  scrollPosition: e.scrollTop,
@@ -378,7 +378,7 @@ var ae = ["aria-hidden"], X = [
378
378
  onPointerdown: I,
379
379
  onPointermove: L,
380
380
  onPointerup: R
381
- }, null, 44, X)], 42, ae));
381
+ }, null, 44, ae)], 42, ie));
382
382
  }
383
383
  }), le = (e) => {
384
384
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
@@ -637,7 +637,9 @@ var ke = /* @__PURE__ */ u({
637
637
  }), Re = [
638
638
  "data-post-id",
639
639
  "data-media-index",
640
+ "aria-hidden",
640
641
  "aria-busy",
642
+ "inert",
641
643
  "role",
642
644
  "tabindex"
643
645
  ], ze = { class: "media-card-content" }, Be = ["data-media-direction"], Ve = ["data-media-index"], He = {
@@ -669,6 +671,7 @@ var ke = /* @__PURE__ */ u({
669
671
  item: {},
670
672
  itemStyle: {},
671
673
  interactive: { type: Boolean },
674
+ leaving: { type: Boolean },
672
675
  layout: {},
673
676
  loadedCount: {},
674
677
  mediaIndex: {},
@@ -692,41 +695,41 @@ var ke = /* @__PURE__ */ u({
692
695
  function ee(e) {
693
696
  return e.detail === 0 ? "keyboard" : "pointer";
694
697
  }
695
- function G(e, t) {
698
+ function te(e, t) {
696
699
  let n = S.value.length, r = (e + n) % n;
697
700
  r !== E.value && (v.value = e < E.value ? "previous" : "next", b("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
698
701
  }
699
- function K(e, t, n) {
702
+ function G(e, t, n) {
700
703
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
701
704
  }
702
- function te() {
705
+ function ne() {
703
706
  d = 0, f = !1, u !== null && clearTimeout(u), u = null;
704
707
  }
705
- function ne() {
706
- u !== null && clearTimeout(u), u = setTimeout(te, Ze);
708
+ function K() {
709
+ u !== null && clearTimeout(u), u = setTimeout(ne, Ze);
707
710
  }
708
- function re(e) {
711
+ function q(e) {
709
712
  if (S.value.length <= 1) return;
710
- let t = e.currentTarget?.clientWidth || 1, n = K(e.deltaX, e.deltaMode, t);
711
- if (n === 0 || (e.preventDefault(), ne(), f) || (d += n, Math.abs(d) < Qe)) return;
713
+ let t = e.currentTarget?.clientWidth || 1, n = G(e.deltaX, e.deltaMode, t);
714
+ if (n === 0 || (e.preventDefault(), K(), f) || (d += n, Math.abs(d) < Qe)) return;
712
715
  let r = Math.sign(d);
713
- d = 0, f = !0, G(E.value + r);
716
+ d = 0, f = !0, te(E.value + r);
714
717
  }
715
- function q(e) {
718
+ function J(e) {
716
719
  let t = e.touches[0];
717
720
  c.layout !== "reel" || !t || (p = t.clientX, h = t.clientY);
718
721
  }
719
- function J(e) {
722
+ function Y(e) {
720
723
  let t = e.changedTouches[0];
721
724
  if (p === null || h === null || !t) return;
722
725
  let n = p - t.clientX, r = h - t.clientY;
723
- p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Xe || G(E.value + Math.sign(n)));
726
+ p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Xe || te(E.value + Math.sign(n)));
724
727
  }
725
- let Y = n(() => Oe(P.value));
726
- function ie(e) {
727
- c.layout === "reel" && (e.stopPropagation(), ae());
728
+ let X = n(() => Oe(P.value));
729
+ function re(e) {
730
+ c.layout === "reel" && (e.stopPropagation(), ie());
728
731
  }
729
- async function ae() {
732
+ async function ie() {
730
733
  if (L.value) {
731
734
  if (V.value) {
732
735
  L.value.pause();
@@ -739,12 +742,12 @@ var ke = /* @__PURE__ */ u({
739
742
  }
740
743
  }
741
744
  }
742
- function X(e) {
745
+ function ae(e) {
743
746
  return Number.isFinite(e) ? Math.max(0, e) : 0;
744
747
  }
745
748
  function Z(e) {
746
749
  let t = e?.currentTarget ?? L.value;
747
- t && (R.value = X(t.currentTime), z.value = X(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
750
+ t && (R.value = ae(t.currentTime), z.value = ae(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
748
751
  }
749
752
  function oe(e) {
750
753
  Z(e), b("ready", E.value);
@@ -754,7 +757,7 @@ var ke = /* @__PURE__ */ u({
754
757
  }
755
758
  function ce(e) {
756
759
  let t = L.value;
757
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(X(t.duration), Math.max(0, e)), R.value = t.currentTime);
760
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(ae(t.duration), Math.max(0, e)), R.value = t.currentTime);
758
761
  }
759
762
  function le(e) {
760
763
  let t = L.value;
@@ -767,18 +770,22 @@ var ke = /* @__PURE__ */ u({
767
770
  e && (e.muted && e.volume === 0 && (e.volume = U), e.muted = !e.muted, Z());
768
771
  }
769
772
  return _(() => {
770
- te();
773
+ ne();
771
774
  }), (n, r) => (y(), o("article", {
772
775
  "data-post-id": e.item.postId,
773
776
  "data-media-index": E.value,
774
777
  class: m(["media-card", {
775
778
  "media-card--entering": e.entering,
776
- "media-card--error": e.previewState === "error"
779
+ "media-card--leaving": e.leaving,
780
+ "media-card--error": e.previewState === "error",
781
+ "media-card--transparent-chrome": e.cardHeader?.background === "transparent" || e.cardFooter?.background === "transparent"
777
782
  }]),
778
783
  style: g(e.itemStyle),
784
+ "aria-hidden": e.leaving || void 0,
779
785
  "aria-busy": e.previewState === "loading",
780
- role: e.interactive && !W.value ? "button" : void 0,
781
- tabindex: e.interactive && !W.value ? 0 : void 0,
786
+ inert: e.leaving || void 0,
787
+ role: e.interactive && !e.leaving && !W.value ? "button" : void 0,
788
+ tabindex: e.interactive && !e.leaving && !W.value ? 0 : void 0,
782
789
  onClick: r[11] ||= (t) => x(e.interactive && !W.value, ee(t)),
783
790
  onKeydown: [r[12] ||= k((t) => x(e.interactive && !W.value, "keyboard"), ["enter"]), r[13] ||= k(A((t) => x(e.interactive && !W.value, "keyboard"), ["prevent"]), ["space"])]
784
791
  }, [s("div", ze, [
@@ -806,9 +813,9 @@ var ke = /* @__PURE__ */ u({
806
813
  s("div", {
807
814
  class: m(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && S.value.length > 1 }]),
808
815
  "data-media-direction": v.value,
809
- onWheel: re,
810
- onTouchstartPassive: q,
811
- onTouchendPassive: J
816
+ onWheel: q,
817
+ onTouchstartPassive: J,
818
+ onTouchendPassive: Y
812
819
  }, [
813
820
  l(t, { name: `media-slide-${v.value}` }, {
814
821
  default: O(() => [(y(), o("div", {
@@ -821,7 +828,7 @@ var ke = /* @__PURE__ */ u({
821
828
  class: "media-error",
822
829
  role: "img",
823
830
  "aria-label": `${T(Te)(P.value)} ${T(Ee)(P.value)}`
824
- }, [s("strong", We, w(T(Te)(P.value)), 1), s("span", null, w(T(Ee)(P.value)), 1)], 8, Ue)) : a("", !0), Y.value ? (y(), o("video", {
831
+ }, [s("strong", We, w(T(Te)(P.value)), 1), s("span", null, w(T(Ee)(P.value)), 1)], 8, Ue)) : a("", !0), X.value ? (y(), o("video", {
825
832
  key: 2,
826
833
  ref_key: "videoElement",
827
834
  ref: L,
@@ -844,7 +851,7 @@ var ke = /* @__PURE__ */ u({
844
851
  onPlaying: r[0] ||= (e) => V.value = !0,
845
852
  onPause: r[1] ||= (e) => V.value = !1,
846
853
  onEnded: se,
847
- onClick: ie,
854
+ onClick: re,
848
855
  onError: r[2] ||= (e) => n.$emit("error", E.value)
849
856
  }, null, 42, Ge)) : (y(), o("img", {
850
857
  key: 3,
@@ -861,7 +868,7 @@ var ke = /* @__PURE__ */ u({
861
868
  }, null, 42, Ke))], 8, Ve))]),
862
869
  _: 1
863
870
  }, 8, ["name"]),
864
- Y.value && e.previewState === "ready" ? (y(), i(Le, {
871
+ X.value && e.previewState === "ready" ? (y(), i(Le, {
865
872
  key: 0,
866
873
  "current-time": R.value,
867
874
  duration: z.value,
@@ -871,7 +878,7 @@ var ke = /* @__PURE__ */ u({
871
878
  volume: H.value,
872
879
  onSeek: ce,
873
880
  onToggleMute: ue,
874
- onTogglePlayback: ae,
881
+ onTogglePlayback: ie,
875
882
  onVolumeChange: le
876
883
  }, null, 8, [
877
884
  "current-time",
@@ -889,13 +896,13 @@ var ke = /* @__PURE__ */ u({
889
896
  type: "button",
890
897
  class: "media-carousel-control media-carousel-control--previous",
891
898
  "aria-label": `Previous media for post ${e.item.postId}`,
892
- onClick: r[5] ||= A((e) => G(E.value - 1, e), ["stop"]),
899
+ onClick: r[5] ||= A((e) => te(E.value - 1, e), ["stop"]),
893
900
  onKeydown: r[6] ||= A(() => {}, ["stop"])
894
901
  }, [l(T(ve), { size: 20 })], 40, qe), s("button", {
895
902
  type: "button",
896
903
  class: "media-carousel-control media-carousel-control--next",
897
904
  "aria-label": `Next media for post ${e.item.postId}`,
898
- onClick: r[7] ||= A((e) => G(E.value + 1, e), ["stop"]),
905
+ onClick: r[7] ||= A((e) => te(E.value + 1, e), ["stop"]),
899
906
  onKeydown: r[8] ||= A(() => {}, ["stop"])
900
907
  }, [l(T(ye), { size: 20 })], 40, Je)], 2)) : a("", !0),
901
908
  W.value ? (y(), o("button", {
@@ -935,6 +942,8 @@ var ke = /* @__PURE__ */ u({
935
942
  props: {
936
943
  enteringPostIds: {},
937
944
  entryDelays: {},
945
+ leavingPostIds: { default: () => /* @__PURE__ */ new Set() },
946
+ removalDelays: { default: () => /* @__PURE__ */ new Map() },
938
947
  suspended: { type: Boolean },
939
948
  canRetryEnd: { type: Boolean },
940
949
  cardFooter: {},
@@ -961,82 +970,98 @@ var ke = /* @__PURE__ */ u({
961
970
  "retryEnd"
962
971
  ],
963
972
  setup(t, { expose: r, emit: a }) {
964
- let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(rt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => J(c.items, h.value, {
973
+ let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(rt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => Y(c.items, h.value, {
965
974
  additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
966
975
  gap: v.value,
967
976
  minColumnWidth: nt
968
- })), M = n(() => ({ height: `${j.value.height}px` })), N = n(() => {
977
+ })), M = n(() => {
978
+ let e = j.value;
979
+ if (c.leavingPostIds.size === 0) return e;
980
+ let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n = Y(t, h.value, {
981
+ additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
982
+ gap: v.value,
983
+ minColumnWidth: nt
984
+ }), r = new Map(t.map((e, t) => [e.postId, n.items[t]]));
985
+ return {
986
+ ...n,
987
+ items: c.items.map((t, n) => c.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
988
+ };
989
+ }), N = n(() => ({ height: `${c.leavingPostIds.size === 0 ? M.value.height : j.value.height}px` })), F = n(() => {
969
990
  let e = Math.max(at, S.value * ot), t = {
970
991
  scrollTop: b.value - w.value,
971
992
  viewportHeight: S.value
972
- }, n = q(j.value.items, {
993
+ }, n = J(M.value.items, {
994
+ ...t,
995
+ overscan: e
996
+ }), r = c.leavingPostIds.size === 0 ? [] : J(j.value.items, {
973
997
  ...t,
974
998
  overscan: e
975
- }), r = new Set(q(j.value.items, {
999
+ }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = J(M.value.items, {
976
1000
  ...t,
977
1001
  overscan: 0
978
- }));
979
- return n.flatMap((e) => {
1002
+ }), o = c.leavingPostIds.size === 0 ? [] : J(j.value.items, {
1003
+ ...t,
1004
+ overscan: 0
1005
+ }), s = new Set([...a, ...o]);
1006
+ return i.flatMap((e) => {
980
1007
  let t = c.items[e];
981
1008
  return t ? [{
982
- fetchPriority: r.has(e) ? "high" : "low",
1009
+ fetchPriority: s.has(e) ? "high" : "low",
983
1010
  index: e,
984
1011
  item: t
985
1012
  }] : [];
986
1013
  });
987
1014
  });
988
- function F(e) {
989
- let t = j.value.items[e], n = c.items[e]?.postId;
1015
+ function I(e) {
1016
+ let t = M.value.items[e], n = c.items[e]?.postId;
990
1017
  if (!t) return {};
991
- let r = n !== void 0 && c.enteringPostIds.has(n) ? re({
1018
+ let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ? q({
992
1019
  containerHeight: j.value.height,
993
1020
  gap: v.value
994
- }) : 0;
1021
+ }) : 0, o = n === void 0 ? 0 : i ? c.removalDelays.get(n) ?? 0 : r ? c.entryDelays.get(n) ?? 0 : 0;
995
1022
  return {
996
- "--masonry-entry-delay": `${n === void 0 ? 0 : c.entryDelays.get(n) ?? 0}ms`,
997
- top: `${t.y}px`,
998
- left: `${t.x}px`,
1023
+ "--masonry-entry-delay": `${o}ms`,
999
1024
  width: `${t.width}px`,
1000
1025
  height: `${t.height}px`,
1001
- transform: `translate3d(0, ${r}px, 0)`
1026
+ transform: `translate3d(${t.x}px, ${t.y + a}px, 0)`
1002
1027
  };
1003
1028
  }
1004
- function I() {
1029
+ function L() {
1005
1030
  let e = d.value;
1006
1031
  if (!e) return;
1007
1032
  b.value = e.scrollTop, S.value = e.clientHeight;
1008
1033
  let t = p.value;
1009
1034
  t && (w.value = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop);
1010
1035
  }
1011
- function L(e) {
1036
+ function R(e) {
1012
1037
  let t = e.ownerDocument.documentElement.clientWidth;
1013
- h.value = e.clientWidth, v.value = Math.min(it, Math.max(rt, t * .0075)), I();
1038
+ h.value = e.clientWidth, v.value = Math.min(it, Math.max(rt, t * .0075)), L();
1014
1039
  }
1015
- function R(e) {
1040
+ function z(e) {
1016
1041
  let t = e.currentTarget;
1017
- t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && K(t) && u("loadMore"));
1042
+ t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && G(t) && u("loadMore"));
1018
1043
  }
1019
- function z() {
1044
+ function B() {
1020
1045
  let e = d.value;
1021
- !c.loadMoreLocked && e && K(e) && u("loadMore");
1046
+ !c.loadMoreLocked && e && G(e) && u("loadMore");
1022
1047
  }
1023
- function B() {
1048
+ function V() {
1024
1049
  return d.value;
1025
1050
  }
1026
1051
  return D(p, (e) => {
1027
- O?.disconnect(), O = null, A !== null && cancelAnimationFrame(A), e && (L(e), !(typeof ResizeObserver > "u") && (O = new ResizeObserver(([t]) => {
1052
+ O?.disconnect(), O = null, A !== null && cancelAnimationFrame(A), e && (R(e), !(typeof ResizeObserver > "u") && (O = new ResizeObserver(([t]) => {
1028
1053
  let n = t?.contentRect.width ?? e.clientWidth;
1029
1054
  Math.abs(n - h.value) < .5 || (A = requestAnimationFrame(() => {
1030
- A = null, L(e);
1055
+ A = null, R(e);
1031
1056
  }));
1032
1057
  }), O.observe(e)));
1033
1058
  }), D(d, (e) => {
1034
- k?.disconnect(), k = null, e && (I(), !(typeof ResizeObserver > "u") && (k = new ResizeObserver(I), k.observe(e)));
1059
+ k?.disconnect(), k = null, e && (L(), !(typeof ResizeObserver > "u") && (k = new ResizeObserver(L), k.observe(e)));
1035
1060
  }), _(() => {
1036
1061
  O?.disconnect(), k?.disconnect(), A !== null && cancelAnimationFrame(A);
1037
1062
  }), r({
1038
- getScrollElement: B,
1039
- loadIfNearBottom: z
1063
+ getScrollElement: V,
1064
+ loadIfNearBottom: B
1040
1065
  }), (n, r) => (y(), o("div", et, [s("main", {
1041
1066
  id: f,
1042
1067
  ref_key: "galleryElement",
@@ -1045,23 +1070,24 @@ var ke = /* @__PURE__ */ u({
1045
1070
  "data-layout-mode": "masonry",
1046
1071
  "aria-hidden": t.suspended || void 0,
1047
1072
  inert: t.suspended || void 0,
1048
- onScrollPassive: R
1073
+ onScrollPassive: z
1049
1074
  }, [s("section", {
1050
1075
  ref_key: "masonryElement",
1051
1076
  ref: p,
1052
1077
  class: m(["masonry", { "masonry--ready": h.value > 0 }]),
1053
- style: g(M.value),
1078
+ style: g(N.value),
1054
1079
  "aria-label": "Media gallery"
1055
- }, [(y(!0), o(e, null, x(N.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i($e, {
1080
+ }, [(y(!0), o(e, null, x(F.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i($e, {
1056
1081
  key: n.postId,
1057
1082
  class: "masonry-item",
1058
1083
  entering: t.enteringPostIds.has(n.postId),
1084
+ leaving: t.leavingPostIds.has(n.postId),
1059
1085
  "fetch-priority": e,
1060
1086
  "card-footer": t.cardFooter,
1061
1087
  "card-header": t.cardHeader,
1062
1088
  index: r,
1063
1089
  item: n,
1064
- "item-style": F(r),
1090
+ "item-style": I(r),
1065
1091
  interactive: "",
1066
1092
  layout: "masonry",
1067
1093
  "loaded-count": t.items.length,
@@ -1074,6 +1100,7 @@ var ke = /* @__PURE__ */ u({
1074
1100
  onError: (e) => u("error", n.postId, e)
1075
1101
  }, null, 8, [
1076
1102
  "entering",
1103
+ "leaving",
1077
1104
  "fetch-priority",
1078
1105
  "card-footer",
1079
1106
  "card-header",
@@ -1111,7 +1138,7 @@ var ke = /* @__PURE__ */ u({
1111
1138
  "load-more-locked",
1112
1139
  "state"
1113
1140
  ])], 42, tt), l(ce, {
1114
- "content-size": j.value.height,
1141
+ "content-size": M.value.height,
1115
1142
  "controls-id": f,
1116
1143
  "scroll-element": d.value,
1117
1144
  suspended: t.suspended
@@ -1205,40 +1232,40 @@ var ke = /* @__PURE__ */ u({
1205
1232
  function ee(e) {
1206
1233
  return { gridRow: `${e + 1}` };
1207
1234
  }
1208
- function G(e) {
1235
+ function te(e) {
1209
1236
  let t = w || e.clientHeight;
1210
1237
  return t <= 0 || u.items.length === 0 ? 0 : Math.min(u.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1211
1238
  }
1212
- function te(e) {
1239
+ function ne(e) {
1213
1240
  let t = e.currentTarget;
1214
- t && (S.value || (b.value = G(t)), !u.loadMoreLocked && u.infiniteScroll && K(t) && d("loadMore"));
1241
+ t && (S.value || (b.value = te(t)), !u.loadMoreLocked && u.infiniteScroll && G(t) && d("loadMore"));
1215
1242
  }
1216
- function ne() {
1243
+ function K() {
1217
1244
  let e = f.value;
1218
- e && (J(!0), w = e.clientHeight, e.scrollTop = b.value * w, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1245
+ e && (Y(!0), w = e.clientHeight, e.scrollTop = b.value * w, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1219
1246
  e.scrollTop = b.value * e.clientHeight, w = e.clientHeight, O = null;
1220
- }), re());
1247
+ }), q());
1221
1248
  }
1222
- function re() {
1249
+ function q() {
1223
1250
  k !== null && clearTimeout(k), k = setTimeout(() => {
1224
1251
  k = null;
1225
1252
  let e = f.value;
1226
- e && (w = e.clientHeight, e.scrollTop = b.value * w), J(!1);
1253
+ e && (w = e.clientHeight, e.scrollTop = b.value * w), Y(!1);
1227
1254
  }, 120);
1228
1255
  }
1229
- function q() {
1230
- J(!0);
1256
+ function J() {
1257
+ Y(!0);
1231
1258
  let e = f.value;
1232
- e && (w = e.clientHeight, e.scrollTop = b.value * w), re();
1259
+ e && (w = e.clientHeight, e.scrollTop = b.value * w), q();
1233
1260
  }
1234
- function J(e) {
1261
+ function Y(e) {
1235
1262
  S.value = e, f.value?.toggleAttribute("data-resizing", e);
1236
1263
  }
1237
- function Y() {
1264
+ function X() {
1238
1265
  let e = f.value;
1239
- !u.loadMoreLocked && e && K(e) && d("loadMore");
1266
+ !u.loadMoreLocked && e && G(e) && d("loadMore");
1240
1267
  }
1241
- function ie(e) {
1268
+ function re(e) {
1242
1269
  let t = I.value;
1243
1270
  if (!t) return !1;
1244
1271
  let n = j(t).length;
@@ -1246,18 +1273,18 @@ var ke = /* @__PURE__ */ u({
1246
1273
  let r = (L.value + e + n) % n;
1247
1274
  return d("mediaChange", t.postId, r), !0;
1248
1275
  }
1249
- function ae(e) {
1276
+ function ie(e) {
1250
1277
  let t = b.value + e;
1251
1278
  return !f.value || t < 0 || t >= u.items.length ? !1 : (Z(t), !0);
1252
1279
  }
1253
- function X() {
1280
+ function ae() {
1254
1281
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1255
1282
  }
1256
1283
  function Z(e) {
1257
1284
  let t = f.value;
1258
1285
  if (!t) return;
1259
1286
  let n = e * (w || t.clientHeight);
1260
- if (b.value = e, !X() && typeof t.scrollTo == "function") {
1287
+ if (b.value = e, !ae() && typeof t.scrollTo == "function") {
1261
1288
  t.scrollTo({
1262
1289
  behavior: "smooth",
1263
1290
  top: n
@@ -1285,21 +1312,21 @@ var ke = /* @__PURE__ */ u({
1285
1312
  !u.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || oe();
1286
1313
  }
1287
1314
  return D(f, (e) => {
1288
- E?.disconnect(), E = null, e && (w = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(ne), E.observe(e)));
1315
+ E?.disconnect(), E = null, e && (w = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(K), E.observe(e)));
1289
1316
  }), D(() => u.items.length, async (e) => {
1290
- b.value = Math.min(b.value, Math.max(0, e - 1)), await p(), ne();
1317
+ b.value = Math.min(b.value, Math.max(0, e - 1)), await p(), K();
1291
1318
  }), D(F, (e) => {
1292
1319
  e !== void 0 && d("activeChange", e);
1293
1320
  }, { immediate: !0 }), v(() => {
1294
- window.addEventListener("resize", q), window.addEventListener("orientationchange", q), h >= 0 && p(ne);
1321
+ window.addEventListener("resize", J), window.addEventListener("orientationchange", J), h >= 0 && p(K);
1295
1322
  }), _(() => {
1296
- window.removeEventListener("resize", q), window.removeEventListener("orientationchange", q), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1323
+ window.removeEventListener("resize", J), window.removeEventListener("orientationchange", J), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1297
1324
  }), r({
1298
1325
  activeIndex: b,
1299
1326
  activePostId: F,
1300
- changeActiveMedia: ie,
1301
- loadIfNearBottom: Y,
1302
- moveActivePost: ae
1327
+ changeActiveMedia: re,
1328
+ loadIfNearBottom: X,
1329
+ moveActivePost: ie
1303
1330
  }), (n, r) => (y(), o("main", {
1304
1331
  class: m(["reel-shell", {
1305
1332
  "reel-shell--has-footer": !!t.cardFooter,
@@ -1333,7 +1360,7 @@ var ke = /* @__PURE__ */ u({
1333
1360
  class: "gallery-shell reel-feed",
1334
1361
  "data-active-post-id": F.value,
1335
1362
  "data-active-media-index": L.value,
1336
- onScrollPassive: te
1363
+ onScrollPassive: ne
1337
1364
  }, [s("section", {
1338
1365
  class: "reel-track",
1339
1366
  style: g(A.value),
@@ -1597,7 +1624,7 @@ var ke = /* @__PURE__ */ u({
1597
1624
  _: 1
1598
1625
  })], 10, pt));
1599
1626
  }
1600
- }), vt = 35, yt = /* @__PURE__ */ u({
1627
+ }), vt = 35, yt = 420, bt = /* @__PURE__ */ u({
1601
1628
  __name: "VibeSurface",
1602
1629
  props: {
1603
1630
  canRetryEnd: { type: Boolean },
@@ -1617,84 +1644,93 @@ var ke = /* @__PURE__ */ u({
1617
1644
  "retryEnd"
1618
1645
  ],
1619
1646
  setup(r, { expose: s, emit: c }) {
1620
- let u = r, d = c, f = C(null), m = C(null), h = C(null), b = C(null), x = C({}), S = C(!1), w = C(/* @__PURE__ */ new Set()), T = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Map()), k = C(/* @__PURE__ */ new Map()), A = C(/* @__PURE__ */ new Map()), j = n(() => F(u.state)), N = n(() => u.state.reelMediaSource === "original" ? A.value : k.value), I = new Set(u.state.items.map((e) => e.postId)), L = null, R = null, z = !1;
1621
- function B() {
1647
+ let u = r, d = c, f = C(null), m = C(null), h = C(null), b = C(null), x = C({}), S = C(!1), w = C(/* @__PURE__ */ new Set()), T = C(/* @__PURE__ */ new Map()), E = C(/* @__PURE__ */ new Set()), k = C(/* @__PURE__ */ new Map()), A = C(/* @__PURE__ */ new Map()), j = C(/* @__PURE__ */ new Map()), N = C(/* @__PURE__ */ new Map()), I = n(() => F(u.state)), L = n(() => u.state.reelMediaSource === "original" ? N.value : j.value), R = new Set(u.state.items.map((e) => e.postId)), z = null, B = null, V = !1;
1648
+ function H() {
1622
1649
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1623
1650
  }
1624
- function V() {
1625
- L !== null && cancelAnimationFrame(L), L = requestAnimationFrame(() => {
1626
- L = requestAnimationFrame(() => {
1627
- L = null, w.value = /* @__PURE__ */ new Set();
1651
+ function U() {
1652
+ z !== null && cancelAnimationFrame(z), z = requestAnimationFrame(() => {
1653
+ z = requestAnimationFrame(() => {
1654
+ z = null, w.value = /* @__PURE__ */ new Set();
1628
1655
  });
1629
1656
  });
1630
1657
  }
1631
- function H(e, t, n) {
1658
+ function W(e, t, n) {
1632
1659
  let r = P(e, t);
1633
- k.value.get(r) !== n && (k.value = new Map(k.value).set(r, n));
1660
+ j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
1634
1661
  }
1635
- function U(e, t, n) {
1662
+ function ee(e, t, n) {
1636
1663
  let r = P(e, t);
1637
- A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1664
+ N.value.get(r) !== n && (N.value = new Map(N.value).set(r, n));
1638
1665
  }
1639
- function W(e, t) {
1640
- H(e, t, "error");
1666
+ function G(e, t) {
1667
+ W(e, t, "error");
1641
1668
  }
1642
- function ee(e, t) {
1643
- H(e, t, "ready");
1669
+ function ne(e, t) {
1670
+ W(e, t, "ready");
1644
1671
  }
1645
1672
  function K(e, t) {
1646
- U(e, t, "error");
1673
+ ee(e, t, "error");
1647
1674
  }
1648
- function te(e, t) {
1649
- U(e, t, "ready");
1675
+ function q(e, t) {
1676
+ ee(e, t, "ready");
1650
1677
  }
1651
- function ne(e, t) {
1678
+ function J(e, t) {
1652
1679
  if (u.state.reelMediaSource === "original") {
1653
1680
  K(e, t);
1654
1681
  return;
1655
1682
  }
1656
- W(e, t);
1683
+ G(e, t);
1657
1684
  }
1658
- function re(e, t) {
1685
+ function Y(e, t) {
1659
1686
  if (u.state.reelMediaSource === "original") {
1660
- te(e, t);
1687
+ q(e, t);
1661
1688
  return;
1662
1689
  }
1663
- ee(e, t);
1690
+ ne(e, t);
1664
1691
  }
1665
- function q(e, t) {
1692
+ function X(e, t) {
1666
1693
  let n = u.state.items.find((t) => t.postId === e);
1667
1694
  if (!n) return;
1668
1695
  let r = M(n, t);
1669
- (E.value.get(e) ?? 0) !== r && (E.value = new Map(E.value).set(e, r));
1696
+ (A.value.get(e) ?? 0) !== r && (A.value = new Map(A.value).set(e, r));
1670
1697
  }
1671
- async function J() {
1698
+ async function re() {
1672
1699
  await p(), (u.state.layout === "reel" || u.state.reelOrigin === "masonry" ? m.value : f.value)?.loadIfNearBottom();
1673
1700
  }
1674
- function Y(e) {
1701
+ function ie(e) {
1675
1702
  return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.changeActiveMedia?.(e) ?? !1;
1676
1703
  }
1677
- function ie(e) {
1704
+ function ae(e) {
1678
1705
  return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.moveActivePost?.(e) ?? !1;
1679
1706
  }
1680
- function ae() {
1707
+ function Z() {
1681
1708
  return u.state.layout !== "masonry" || u.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1682
1709
  }
1683
- function X(e, t) {
1684
- R = e, z = t === "keyboard", x.value = se(e), d("openReel", e), p(() => h.value?.focus());
1710
+ function oe(e, t) {
1711
+ B = e, V = t === "keyboard", x.value = ue(e), d("openReel", e), p(() => h.value?.focus());
1685
1712
  }
1686
- function Z(e) {
1713
+ function se(e) {
1687
1714
  let t = b.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1688
1715
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
1689
1716
  }
1690
- function oe(e, t) {
1691
- let n = Z(e), r = n?.querySelector(".media-card-activator") ?? n;
1717
+ function ce(e) {
1718
+ if (u.state.layout !== "masonry" || u.state.reelOrigin !== null || H()) return 0;
1719
+ let t = [...new Set(e)], n = t.filter(se);
1720
+ if (n.length === 0) return 0;
1721
+ let r = new Map(k.value);
1722
+ return n.forEach((e, t) => {
1723
+ r.set(e, t * vt);
1724
+ }), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, yt + (n.length - 1) * vt;
1725
+ }
1726
+ function le(e, t) {
1727
+ let n = se(e), r = n?.querySelector(".media-card-activator") ?? n;
1692
1728
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
1693
1729
  r.classList.remove("media-card-focus-silent");
1694
1730
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
1695
1731
  }
1696
- function se(e) {
1697
- let t = b.value, n = Z(e);
1732
+ function ue(e) {
1733
+ let t = b.value, n = se(e);
1698
1734
  if (t === null || n === null) return {};
1699
1735
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
1700
1736
  return {
@@ -1704,19 +1740,19 @@ var ke = /* @__PURE__ */ u({
1704
1740
  "--vibe-reel-origin-left": `${Math.max(0, i.left - r.left)}px`
1705
1741
  };
1706
1742
  }
1707
- function ce() {
1708
- u.state.reelOrigin === "masonry" && (R ??= u.state.activeReelPostId, S.value = !0, d("closeReel"));
1743
+ function de() {
1744
+ u.state.reelOrigin === "masonry" && (B ??= u.state.activeReelPostId, S.value = !0, d("closeReel"));
1709
1745
  }
1710
- function le() {
1711
- let e = R, t = z;
1712
- S.value = !1, R = null, z = !1, x.value = {}, p(() => {
1713
- e !== null && oe(e, t);
1746
+ function fe() {
1747
+ let e = B, t = V;
1748
+ S.value = !1, B = null, V = !1, x.value = {}, p(() => {
1749
+ e !== null && le(e, t);
1714
1750
  });
1715
1751
  }
1716
- function ue(e) {
1752
+ function pe(e) {
1717
1753
  let t = u.state.layout === "reel" || u.state.reelOrigin === "masonry";
1718
1754
  if (e.key === "Escape" && u.state.reelOrigin === "masonry") {
1719
- e.preventDefault(), ce();
1755
+ e.preventDefault(), de();
1720
1756
  return;
1721
1757
  }
1722
1758
  if (e.key === "Escape" && t && u.state.reelInfoSheet.enabled) {
@@ -1734,32 +1770,33 @@ var ke = /* @__PURE__ */ u({
1734
1770
  r !== 0 && m.value?.changeActiveMedia?.(r) && e.preventDefault();
1735
1771
  }
1736
1772
  return D(() => u.state.items.map((e) => e.postId), (e) => {
1737
- let t = e.filter((e) => !I.has(e));
1738
- if (I = new Set(e), t.length === 0 || B()) return;
1739
- let n = /* @__PURE__ */ new Map();
1773
+ let t = e.filter((e) => !R.has(e)), n = new Set(e);
1774
+ if (R = new Set(e), E.value = new Set([...E.value].filter((e) => n.has(e))), k.value = new Map([...k.value].filter(([e]) => n.has(e))), t.length === 0 || H()) return;
1775
+ let r = /* @__PURE__ */ new Map();
1740
1776
  e.forEach((e) => {
1741
1777
  let t = T.value.get(e);
1742
- t !== void 0 && n.set(e, t);
1778
+ t !== void 0 && r.set(e, t);
1743
1779
  }), t.forEach((e, t) => {
1744
- n.set(e, t * vt);
1745
- }), T.value = n, w.value = new Set([...w.value, ...t]), V();
1746
- }, { flush: "sync" }), v(() => window.addEventListener("keydown", ue)), _(() => {
1747
- window.removeEventListener("keydown", ue), L !== null && cancelAnimationFrame(L);
1780
+ r.set(e, t * vt);
1781
+ }), T.value = r, w.value = new Set([...w.value, ...t]), U();
1782
+ }, { flush: "sync" }), v(() => window.addEventListener("keydown", pe)), _(() => {
1783
+ window.removeEventListener("keydown", pe), z !== null && cancelAnimationFrame(z);
1748
1784
  }), s({
1749
- changeActiveReelMedia: Y,
1750
- getAutoScrollElement: ae,
1751
- loadIfNearBottom: J,
1752
- moveActiveReelPost: ie
1785
+ changeActiveReelMedia: ie,
1786
+ getAutoScrollElement: Z,
1787
+ loadIfNearBottom: re,
1788
+ moveActiveReelPost: ae,
1789
+ startItemRemoval: ce
1753
1790
  }), (n, s) => (y(), o("div", {
1754
1791
  ref_key: "surfaceElement",
1755
1792
  ref: b,
1756
1793
  class: "vibe-surface"
1757
- }, [r.state.error || r.state.isLoading || r.state.items.length === 0 ? (y(), i(G, {
1794
+ }, [r.state.error || r.state.isLoading || r.state.items.length === 0 ? (y(), i(te, {
1758
1795
  key: 0,
1759
1796
  actions: r.feedFooterActions,
1760
1797
  "can-retry-end": r.canRetryEnd,
1761
1798
  "feed-footer": r.feedFooter,
1762
- state: j.value,
1799
+ state: I.value,
1763
1800
  onLoadMore: s[0] ||= (e) => d("loadMore"),
1764
1801
  onRetryEnd: s[1] ||= (e) => d("retryEnd")
1765
1802
  }, null, 8, [
@@ -1782,23 +1819,23 @@ var ke = /* @__PURE__ */ u({
1782
1819
  items: r.state.items,
1783
1820
  "load-more-locked": r.state.loadMoreLocked,
1784
1821
  "media-source": r.state.reelMediaSource,
1785
- "media-indices": E.value,
1822
+ "media-indices": A.value,
1786
1823
  "initial-post-id": r.state.activeReelPostId,
1787
1824
  "info-sheet": r.reelInfoSheet,
1788
1825
  "info-sheet-enabled": r.state.reelInfoSheet.enabled,
1789
1826
  "info-sheet-overlay": r.state.reelInfoSheetOverlay,
1790
1827
  "next-page-error": !!r.state.nextPageError,
1791
1828
  origin: "reel",
1792
- "preview-states": N.value,
1829
+ "preview-states": L.value,
1793
1830
  "reel-auto-advance": r.state.reelAutoAdvance,
1794
- state: j.value,
1831
+ state: I.value,
1795
1832
  total: r.state.total,
1796
1833
  onActiveChange: s[2] ||= (e) => d("activeReelChange", e),
1797
1834
  onCloseInfoSheet: s[3] ||= (e) => d("reelInfoSheetChange", !1),
1798
- onError: ne,
1835
+ onError: J,
1799
1836
  onLoadMore: s[4] ||= (e) => d("loadMore"),
1800
- onMediaChange: q,
1801
- onReady: re,
1837
+ onMediaChange: X,
1838
+ onReady: Y,
1802
1839
  onRetryEnd: s[5] ||= (e) => d("retryEnd")
1803
1840
  }, null, 8, [
1804
1841
  "can-retry-end",
@@ -1828,6 +1865,8 @@ var ke = /* @__PURE__ */ u({
1828
1865
  "can-retry-end": r.canRetryEnd,
1829
1866
  "entering-post-ids": w.value,
1830
1867
  "entry-delays": T.value,
1868
+ "leaving-post-ids": E.value,
1869
+ "removal-delays": k.value,
1831
1870
  "card-footer": r.cardFooter,
1832
1871
  "card-header": r.cardHeader,
1833
1872
  "feed-footer": r.feedFooter,
@@ -1837,22 +1876,24 @@ var ke = /* @__PURE__ */ u({
1837
1876
  "is-loading-more": r.state.isLoadingMore,
1838
1877
  items: r.state.items,
1839
1878
  "load-more-locked": r.state.loadMoreLocked,
1840
- "media-indices": E.value,
1879
+ "media-indices": A.value,
1841
1880
  "next-page-error": !!r.state.nextPageError,
1842
- "preview-states": k.value,
1881
+ "preview-states": j.value,
1843
1882
  suspended: r.state.reelOrigin === "masonry" || S.value,
1844
- state: j.value,
1883
+ state: I.value,
1845
1884
  total: r.state.total,
1846
- onActivate: X,
1847
- onError: W,
1885
+ onActivate: oe,
1886
+ onError: G,
1848
1887
  onLoadMore: s[6] ||= (e) => d("loadMore"),
1849
- onMediaChange: q,
1850
- onReady: ee,
1888
+ onMediaChange: X,
1889
+ onReady: ne,
1851
1890
  onRetryEnd: s[7] ||= (e) => d("retryEnd")
1852
1891
  }, null, 8, [
1853
1892
  "can-retry-end",
1854
1893
  "entering-post-ids",
1855
1894
  "entry-delays",
1895
+ "leaving-post-ids",
1896
+ "removal-delays",
1856
1897
  "card-footer",
1857
1898
  "card-header",
1858
1899
  "feed-footer",
@@ -1870,7 +1911,7 @@ var ke = /* @__PURE__ */ u({
1870
1911
  "total"
1871
1912
  ]), l(t, {
1872
1913
  name: "vibe-reel-viewer",
1873
- onAfterLeave: le
1914
+ onAfterLeave: fe
1874
1915
  }, {
1875
1916
  default: O(() => [r.state.reelOrigin === "masonry" ? (y(), o("section", {
1876
1917
  key: 0,
@@ -1899,20 +1940,20 @@ var ke = /* @__PURE__ */ u({
1899
1940
  "is-loading-more": r.state.isLoadingMore,
1900
1941
  items: r.state.items,
1901
1942
  "load-more-locked": r.state.loadMoreLocked,
1902
- "media-indices": E.value,
1943
+ "media-indices": A.value,
1903
1944
  "media-source": "original",
1904
1945
  "next-page-error": !!r.state.nextPageError,
1905
1946
  origin: "masonry",
1906
- "preview-states": A.value,
1947
+ "preview-states": N.value,
1907
1948
  "reel-auto-advance": r.state.reelAutoAdvance,
1908
- state: j.value,
1949
+ state: I.value,
1909
1950
  total: r.state.total,
1910
1951
  onActiveChange: s[8] ||= (e) => d("activeReelChange", e),
1911
1952
  onCloseInfoSheet: s[9] ||= (e) => d("reelInfoSheetChange", !1),
1912
1953
  onError: K,
1913
1954
  onLoadMore: s[10] ||= (e) => d("loadMore"),
1914
- onMediaChange: q,
1915
- onReady: te,
1955
+ onMediaChange: X,
1956
+ onReady: q,
1916
1957
  onRetryEnd: s[11] ||= (e) => d("retryEnd")
1917
1958
  }, null, 8, [
1918
1959
  "can-retry-end",
@@ -1942,7 +1983,7 @@ var ke = /* @__PURE__ */ u({
1942
1983
  });
1943
1984
  //#endregion
1944
1985
  //#region src/core/page.ts
1945
- function bt(e) {
1986
+ function xt(e) {
1946
1987
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
1947
1988
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
1948
1989
  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.");
@@ -1954,32 +1995,32 @@ function Q(e, t) {
1954
1995
  }
1955
1996
  //#endregion
1956
1997
  //#region src/core/requestDelay.ts
1957
- var xt = 2e3, St = 1e4, Ct = 250, wt = {
1998
+ var St = 2e3, Ct = 1e4, wt = 250, Tt = {
1958
1999
  delayRemainingMs: null,
1959
2000
  nextRequestAt: null
1960
2001
  };
1961
- function Tt(e, t) {
2002
+ function Et(e, t) {
1962
2003
  return e === void 0 ? t : Math.floor(e);
1963
2004
  }
1964
- function Et(e, t) {
2005
+ function Dt(e, t) {
1965
2006
  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.`);
1966
2007
  }
1967
- function Dt(e, t = {}) {
1968
- let n = Tt(t.delayStepMs, xt), r = Tt(t.delayMaxMs, St);
2008
+ function Ot(e, t = {}) {
2009
+ let n = Et(t.delayStepMs, St), r = Et(t.delayMaxMs, Ct);
1969
2010
  return Math.min(Math.max(0, e) * n, r);
1970
2011
  }
1971
2012
  function $(e) {
1972
- if (e == null || !Number.isFinite(e)) return { ...wt };
2013
+ if (e == null || !Number.isFinite(e)) return { ...Tt };
1973
2014
  let t = Math.max(0, Math.floor(e - Date.now()));
1974
2015
  return t > 0 ? {
1975
2016
  delayRemainingMs: t,
1976
2017
  nextRequestAt: e
1977
- } : { ...wt };
2018
+ } : { ...Tt };
1978
2019
  }
1979
- async function Ot({ delayMs: e, onChange: t, signal: n }) {
2020
+ async function kt({ delayMs: e, onChange: t, signal: n }) {
1980
2021
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
1981
2022
  if (e <= 0) {
1982
- t({ ...wt });
2023
+ t({ ...Tt });
1983
2024
  return;
1984
2025
  }
1985
2026
  let r = Date.now() + e;
@@ -1987,9 +2028,9 @@ async function Ot({ delayMs: e, onChange: t, signal: n }) {
1987
2028
  delayRemainingMs: e,
1988
2029
  nextRequestAt: r
1989
2030
  }), await new Promise((i, a) => {
1990
- let o = !1, s = setInterval(f, Ct), c = setTimeout(() => u(), e);
2031
+ let o = !1, s = setInterval(f, wt), c = setTimeout(() => u(), e);
1991
2032
  function l() {
1992
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...wt });
2033
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Tt });
1993
2034
  }
1994
2035
  function u(e) {
1995
2036
  o || (o = !0, l(), e ? a(e) : i());
@@ -2004,13 +2045,13 @@ async function Ot({ delayMs: e, onChange: t, signal: n }) {
2004
2045
  n.addEventListener("abort", d, { once: !0 });
2005
2046
  });
2006
2047
  }
2007
- var kt = class {
2048
+ var At = class {
2008
2049
  interval = null;
2009
2050
  constructor(e) {
2010
2051
  this.onChange = e;
2011
2052
  }
2012
2053
  clear() {
2013
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...wt });
2054
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Tt });
2014
2055
  }
2015
2056
  sync(e) {
2016
2057
  this.clear();
@@ -2018,22 +2059,22 @@ var kt = class {
2018
2059
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2019
2060
  let t = $(e);
2020
2061
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2021
- }, Ct));
2062
+ }, wt));
2022
2063
  }
2023
2064
  };
2024
- function At(e, t = !0) {
2065
+ function jt(e, t = !0) {
2025
2066
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2026
2067
  }
2027
- function jt(e) {
2068
+ function Mt(e) {
2028
2069
  return `${typeof e}:${String(e)}`;
2029
2070
  }
2030
- function Mt(e, t) {
2071
+ function Nt(e, t) {
2031
2072
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2032
2073
  }
2033
- function Nt(e) {
2074
+ function Pt(e) {
2034
2075
  if (!e) return;
2035
- if (Mt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2036
- Et(e, "frontend autofill");
2076
+ if (Nt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2077
+ Dt(e, "frontend autofill");
2037
2078
  let t = e.maxAdditionalPages;
2038
2079
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2039
2080
  return;
@@ -2045,7 +2086,7 @@ function Nt(e) {
2045
2086
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2046
2087
  }
2047
2088
  }
2048
- function Pt(e, t, n = !0) {
2089
+ function Ft(e, t, n = !0) {
2049
2090
  if (!e) return {
2050
2091
  cycleId: null,
2051
2092
  delayRemainingMs: null,
@@ -2079,7 +2120,7 @@ function Pt(e, t, n = !0) {
2079
2120
  strategy: e.strategy
2080
2121
  };
2081
2122
  }
2082
- function Ft(e) {
2123
+ function It(e) {
2083
2124
  return [
2084
2125
  "cancelling",
2085
2126
  "filling",
@@ -2087,9 +2128,9 @@ function Ft(e) {
2087
2128
  "waiting"
2088
2129
  ].includes(e.status);
2089
2130
  }
2090
- async function It(e, t, n) {
2131
+ async function Lt(e, t, n) {
2091
2132
  let r = t.autofill;
2092
- if (!Ft(r) || !r.cycleId) return;
2133
+ if (!It(r) || !r.cycleId) return;
2093
2134
  let i = {
2094
2135
  cycleId: r.cycleId,
2095
2136
  feedKey: r.feedKey ?? "",
@@ -2102,20 +2143,20 @@ async function It(e, t, n) {
2102
2143
  throw r.error = e, r.status = "error", e;
2103
2144
  }
2104
2145
  }
2105
- function Lt(e, t, n) {
2146
+ function Rt(e, t, n) {
2106
2147
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2107
2148
  }
2108
- async function Rt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2109
- let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? At(o), m = t, h = t, g = 0, _;
2149
+ async function zt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2150
+ let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? jt(o), m = t, h = t, g = 0, _;
2110
2151
  for (; g < p;) {
2111
- let e = jt(m);
2152
+ let e = Mt(m);
2112
2153
  if (f.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2113
- f.add(e), await Ot({
2114
- delayMs: Dt(c + g, o),
2154
+ f.add(e), await kt({
2155
+ delayMs: Ot(c + g, o),
2115
2156
  onChange: i,
2116
2157
  signal: l
2117
2158
  });
2118
- let t = bt(await n({
2159
+ let t = xt(await n({
2119
2160
  cursor: m,
2120
2161
  signal: l
2121
2162
  }));
@@ -2155,30 +2196,30 @@ async function Rt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequ
2155
2196
  total: _
2156
2197
  };
2157
2198
  }
2158
- var zt = 100;
2159
- function Bt(e, t) {
2199
+ var Bt = 100;
2200
+ function Vt(e, t) {
2160
2201
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2161
2202
  }
2162
- function Vt(e, t, n) {
2203
+ function Ht(e, t, n) {
2163
2204
  return Math.min(n, Math.max(t, e));
2164
2205
  }
2165
- function Ht(e) {
2206
+ function Ut(e) {
2166
2207
  if (!e) return;
2167
2208
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2168
- if (Bt("autoScroll.minSpeedPxPerSecond", t), Bt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2169
- e.speedPxPerSecond !== void 0 && Bt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2209
+ if (Vt("autoScroll.minSpeedPxPerSecond", t), Vt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2210
+ e.speedPxPerSecond !== void 0 && Vt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2170
2211
  }
2171
- function Ut(e) {
2212
+ function Wt(e) {
2172
2213
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2173
2214
  return {
2174
2215
  enabled: e?.enabled ?? !1,
2175
2216
  maxSpeedPxPerSecond: n,
2176
2217
  minSpeedPxPerSecond: t,
2177
2218
  paused: !1,
2178
- speedPxPerSecond: Vt(e?.speedPxPerSecond ?? 80, t, n)
2219
+ speedPxPerSecond: Ht(e?.speedPxPerSecond ?? 80, t, n)
2179
2220
  };
2180
2221
  }
2181
- var Wt = class {
2222
+ var Gt = class {
2182
2223
  frame = null;
2183
2224
  lastTimestamp = null;
2184
2225
  mounted = !1;
@@ -2198,9 +2239,9 @@ var Wt = class {
2198
2239
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2199
2240
  }
2200
2241
  setSpeed(e) {
2201
- Bt("auto-scroll speed", e);
2242
+ Vt("auto-scroll speed", e);
2202
2243
  let t = this.options.state;
2203
- t.speedPxPerSecond = Vt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2244
+ t.speedPxPerSecond = Ht(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2204
2245
  }
2205
2246
  tick = (e) => {
2206
2247
  this.frame = null;
@@ -2212,7 +2253,7 @@ var Wt = class {
2212
2253
  return;
2213
2254
  }
2214
2255
  if (this.lastTimestamp !== null) {
2215
- let r = Math.min(zt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2256
+ let r = Math.min(Bt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2216
2257
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2217
2258
  }
2218
2259
  this.lastTimestamp = e, this.schedule();
@@ -2226,7 +2267,7 @@ var Wt = class {
2226
2267
  };
2227
2268
  //#endregion
2228
2269
  //#region src/core/backendAutofill.ts
2229
- async function Gt(e, t, n, r) {
2270
+ async function Kt(e, t, n, r) {
2230
2271
  let i = await e.onUnderfilled(n);
2231
2272
  if (!r()) return;
2232
2273
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
@@ -2240,45 +2281,19 @@ async function Gt(e, t, n, r) {
2240
2281
  status: "waiting"
2241
2282
  });
2242
2283
  }
2243
- function Kt(e, t) {
2284
+ function qt(e, t) {
2244
2285
  ["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);
2245
2286
  }
2246
- function qt(e, t, n) {
2247
- let r = t.autofill;
2248
- return !Lt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Kt(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);
2249
- }
2250
2287
  function Jt(e, t, n) {
2251
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Pt(e, n), Kt(t, n), !0);
2252
- }
2253
- var Yt = 1.5;
2254
- function Xt(e) {
2255
- let t = Math.min(e.screenWidth, e.screenHeight);
2256
- if (t > 0 && t < 600) return !0;
2257
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Yt;
2258
- return !e.hasHover && n > 0 && n < 600 && r;
2259
- }
2260
- function Zt(e) {
2261
- return Xt(e) ? "reel" : "masonry";
2262
- }
2263
- function Qt(e) {
2264
- let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
2265
- return {
2266
- hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
2267
- screenHeight: t?.screen.height ?? 0,
2268
- screenWidth: t?.screen.width ?? 0,
2269
- viewportHeight: n.clientHeight,
2270
- viewportWidth: n.clientWidth
2271
- };
2272
- }
2273
- function $t(e) {
2274
- return Xt(Qt(e));
2288
+ let r = t.autofill;
2289
+ return !Rt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (qt(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);
2275
2290
  }
2276
- function en(e) {
2277
- return Zt(Qt(e));
2291
+ function Yt(e, t, n) {
2292
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Ft(e, n), qt(t, n), !0);
2278
2293
  }
2279
2294
  //#endregion
2280
2295
  //#region src/core/initialAutofill.ts
2281
- async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2296
+ async function Xt({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2282
2297
  let o = r.autofill;
2283
2298
  if (!o) return;
2284
2299
  let s = a.items.length;
@@ -2291,7 +2306,7 @@ async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2291
2306
  return;
2292
2307
  }
2293
2308
  if (o.strategy === "backend") {
2294
- await Gt(o, a, {
2309
+ await Kt(o, a, {
2295
2310
  cycleId: e,
2296
2311
  feedKey: o.feedKey,
2297
2312
  items: [...a.items],
@@ -2308,11 +2323,11 @@ async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2308
2323
  a.autofill.status = "exhausted";
2309
2324
  return;
2310
2325
  }
2311
- let c = await Rt({
2326
+ let c = await zt({
2312
2327
  existingItems: a.items,
2313
2328
  initialCursor: a.next,
2314
2329
  loadPage: r.loadPage,
2315
- maximumRequests: At(o, !1),
2330
+ maximumRequests: jt(o, !1),
2316
2331
  onDelayChange: (e) => {
2317
2332
  t() && Object.assign(a.autofill, e);
2318
2333
  },
@@ -2333,13 +2348,13 @@ async function tn({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signa
2333
2348
  }
2334
2349
  //#endregion
2335
2350
  //#region src/core/fill.ts
2336
- function nn(e) {
2351
+ function Zt(e) {
2337
2352
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2338
2353
  }
2339
- function rn(e) {
2354
+ function Qt(e) {
2340
2355
  return `${typeof e}:${String(e)}`;
2341
2356
  }
2342
- function an(e) {
2357
+ function $t(e) {
2343
2358
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2344
2359
  if ("pages" in e) {
2345
2360
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2348,20 +2363,20 @@ function an(e) {
2348
2363
  if ("until" in e && e.until === "end") return { until: "end" };
2349
2364
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2350
2365
  }
2351
- function on(e) {
2366
+ function en(e) {
2352
2367
  if (!e) return;
2353
2368
  if (e.strategy === "frontend") {
2354
- Et(e, "frontend fill");
2369
+ Dt(e, "frontend fill");
2355
2370
  return;
2356
2371
  }
2357
2372
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2358
2373
  let t = e.initialSession;
2359
2374
  if (t) {
2360
2375
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2361
- an(t.target);
2376
+ $t(t.target);
2362
2377
  }
2363
2378
  }
2364
- function sn(e, t, n = !0) {
2379
+ function tn(e, t, n = !0) {
2365
2380
  let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2366
2381
  return {
2367
2382
  completedPages: i?.completedPages ?? 0,
@@ -2375,10 +2390,10 @@ function sn(e, t, n = !0) {
2375
2390
  sessionId: i?.sessionId ?? null,
2376
2391
  status: i?.status ?? "idle",
2377
2392
  strategy: e?.strategy ?? null,
2378
- target: i ? nn(i.target) : null
2393
+ target: i ? Zt(i.target) : null
2379
2394
  };
2380
2395
  }
2381
- function cn(e) {
2396
+ function nn(e) {
2382
2397
  return [
2383
2398
  "cancelling",
2384
2399
  "filling",
@@ -2386,17 +2401,17 @@ function cn(e) {
2386
2401
  "waiting"
2387
2402
  ].includes(e.status);
2388
2403
  }
2389
- async function ln({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2404
+ async function rn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2390
2405
  let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2391
2406
  for (; p !== null;) {
2392
- let e = rn(f);
2407
+ let e = Qt(f);
2393
2408
  if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2394
- u.add(e), await Ot({
2395
- delayMs: Dt(d, a),
2409
+ u.add(e), await kt({
2410
+ delayMs: Ot(d, a),
2396
2411
  onChange: r,
2397
2412
  signal: o
2398
2413
  });
2399
- let t = bt(await n({
2414
+ let t = xt(await n({
2400
2415
  cursor: f,
2401
2416
  signal: o
2402
2417
  }));
@@ -2438,7 +2453,7 @@ async function ln({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
2438
2453
  }
2439
2454
  //#endregion
2440
2455
  //#region src/core/backendFill.ts
2441
- async function un(e, t, n, r) {
2456
+ async function an(e, t, n, r) {
2442
2457
  let i = await e.onStart(n);
2443
2458
  if (r()) {
2444
2459
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
@@ -2452,22 +2467,22 @@ async function un(e, t, n, r) {
2452
2467
  });
2453
2468
  }
2454
2469
  }
2455
- function dn(e, t, n) {
2470
+ function on(e, t, n) {
2456
2471
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2457
2472
  }
2458
- function fn(e) {
2473
+ function sn(e) {
2459
2474
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2460
2475
  }
2461
- function pn(e, t) {
2476
+ function cn(e, t) {
2462
2477
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2463
2478
  let n = e.fill.target;
2464
2479
  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;
2465
2480
  }
2466
- function mn(e, t, n) {
2481
+ function ln(e, t, n) {
2467
2482
  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));
2468
2483
  }
2469
- function hn(e, t, n, r) {
2470
- return !dn(e, t, n) || !fn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !pn(t, n) ? !1 : (mn(t, n, r), Object.assign(t.fill, {
2484
+ function un(e, t, n, r) {
2485
+ return !on(e, t, n) || !sn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !cn(t, n) ? !1 : (ln(t, n, r), Object.assign(t.fill, {
2471
2486
  ...$(n.status === "waiting" ? n.nextRequestAt : null),
2472
2487
  completedPages: n.completedPages,
2473
2488
  error: n.error ?? null,
@@ -2476,41 +2491,41 @@ function hn(e, t, n, r) {
2476
2491
  status: n.status
2477
2492
  }), !0);
2478
2493
  }
2479
- function gn(e, t, n, r) {
2494
+ function dn(e, t, n, r) {
2480
2495
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2481
2496
  let i = t.fill;
2482
- return t.fill = sn(e, n), !fn(n) || !pn(t, n) ? (t.fill = i, !1) : (mn(t, n, r), !0);
2497
+ return t.fill = tn(e, n), !sn(n) || !cn(t, n) ? (t.fill = i, !1) : (ln(t, n, r), !0);
2483
2498
  }
2484
2499
  //#endregion
2485
2500
  //#region src/core/fillController.ts
2486
- var _n = class {
2501
+ var fn = class {
2487
2502
  abortController = null;
2488
2503
  cycle = 0;
2489
2504
  delayCountdown;
2490
2505
  requestVersion = 0;
2491
2506
  constructor(e) {
2492
- this.options = e, this.delayCountdown = new kt((e) => {
2507
+ this.options = e, this.delayCountdown = new At((e) => {
2493
2508
  Object.assign(this.options.state.fill, e);
2494
2509
  }), this.syncBackendCountdown();
2495
2510
  }
2496
2511
  isActive() {
2497
- return cn(this.options.state.fill);
2512
+ return nn(this.options.state.fill);
2498
2513
  }
2499
2514
  applyUpdate(e) {
2500
- let t = hn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2515
+ let t = un(this.options.fill, this.options.state, e, this.options.onLastCursor);
2501
2516
  return t && this.syncBackendCountdown(), t;
2502
2517
  }
2503
2518
  restoreSession(e) {
2504
- let t = gn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2519
+ let t = dn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2505
2520
  return t && this.syncBackendCountdown(), t;
2506
2521
  }
2507
2522
  async start(e) {
2508
2523
  let t = this.options.fill;
2509
2524
  if (!t) throw Error("Vibe fill is not configured.");
2510
2525
  if (this.isActive()) throw Error("Vibe fill is already active.");
2511
- let n = an(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2526
+ let n = $t(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2512
2527
  if (this.options.state.fill = {
2513
- ...sn(t, void 0, !1),
2528
+ ...tn(t, void 0, !1),
2514
2529
  cycleId: r,
2515
2530
  status: "filling",
2516
2531
  target: n
@@ -2521,7 +2536,7 @@ var _n = class {
2521
2536
  let i = ++this.requestVersion, a = new AbortController();
2522
2537
  this.abortController = a;
2523
2538
  try {
2524
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await un(t, this.options.state, {
2539
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await an(t, this.options.state, {
2525
2540
  cycleId: r,
2526
2541
  feedKey: t.feedKey,
2527
2542
  items: [...this.options.state.items],
@@ -2539,7 +2554,7 @@ var _n = class {
2539
2554
  }
2540
2555
  async cancel() {
2541
2556
  let { fill: e, state: t } = this.options;
2542
- if (!cn(t.fill) || !t.fill.cycleId) return;
2557
+ if (!nn(t.fill) || !t.fill.cycleId) return;
2543
2558
  let n = {
2544
2559
  cycleId: t.fill.cycleId,
2545
2560
  feedKey: t.fill.feedKey ?? "",
@@ -2553,7 +2568,7 @@ var _n = class {
2553
2568
  }
2554
2569
  }
2555
2570
  reset() {
2556
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = sn(this.options.fill, void 0, !1);
2571
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = tn(this.options.fill, void 0, !1);
2557
2572
  }
2558
2573
  destroy() {
2559
2574
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2569,7 +2584,7 @@ var _n = class {
2569
2584
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2570
2585
  let a = this.options.state;
2571
2586
  a.isLoadingMore = !0;
2572
- let o = await ln({
2587
+ let o = await rn({
2573
2588
  existingItems: a.items,
2574
2589
  initialCursor: a.next,
2575
2590
  loadPage: i,
@@ -2596,7 +2611,7 @@ var _n = class {
2596
2611
  };
2597
2612
  //#endregion
2598
2613
  //#region src/core/feedFooter.ts
2599
- function vn(e) {
2614
+ function pn(e) {
2600
2615
  return {
2601
2616
  cancelAutofill: () => e.cancelAutofill(),
2602
2617
  loadMore: () => e.loadNext(),
@@ -2604,45 +2619,45 @@ function vn(e) {
2604
2619
  retryEnd: () => e.retryEnd()
2605
2620
  };
2606
2621
  }
2607
- function yn(e) {
2622
+ function mn(e) {
2608
2623
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2609
2624
  }
2610
- function bn(e) {
2611
- e?.intervalMs !== void 0 && yn(e.intervalMs);
2625
+ function hn(e) {
2626
+ e?.intervalMs !== void 0 && mn(e.intervalMs);
2612
2627
  }
2613
- function xn(e) {
2628
+ function gn(e) {
2614
2629
  return {
2615
2630
  enabled: e?.enabled ?? !1,
2616
2631
  includePostItems: e?.includePostItems ?? !1,
2617
2632
  intervalMs: e?.intervalMs ?? 5e3
2618
2633
  };
2619
2634
  }
2620
- function Sn(e, t) {
2635
+ function _n(e, t) {
2621
2636
  if (typeof t == "boolean") {
2622
2637
  e.enabled = t;
2623
2638
  return;
2624
2639
  }
2625
- bn(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);
2640
+ hn(t), t.enabled !== void 0 && (e.enabled = t.enabled), t.includePostItems !== void 0 && (e.includePostItems = t.includePostItems), t.intervalMs !== void 0 && (e.intervalMs = t.intervalMs);
2626
2641
  }
2627
2642
  //#endregion
2628
2643
  //#region src/core/reelInfoSheet.ts
2629
- function Cn(e) {
2644
+ function vn(e) {
2630
2645
  return { enabled: e?.enabled ?? !1 };
2631
2646
  }
2632
- function wn(e, t, n) {
2647
+ function yn(e, t, n) {
2633
2648
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2634
2649
  e.enabled = n;
2635
2650
  }
2636
2651
  //#endregion
2637
2652
  //#region src/core/initialRuntimeState.ts
2638
- function Tn(e, t) {
2653
+ function bn(e, t) {
2639
2654
  let n = e.initialPage;
2640
2655
  return {
2641
2656
  activeReelPostId: null,
2642
- autoScroll: Ut(e.autoScroll),
2643
- autofill: Pt(e.autofill),
2657
+ autoScroll: Wt(e.autoScroll),
2658
+ autofill: Ft(e.autofill),
2644
2659
  error: null,
2645
- fill: sn(e.fill),
2660
+ fill: tn(e.fill),
2646
2661
  infiniteScroll: e.infiniteScroll ?? !0,
2647
2662
  isLoading: !n,
2648
2663
  isLoadingMore: !1,
@@ -2651,8 +2666,8 @@ function Tn(e, t) {
2651
2666
  loadMoreLocked: !1,
2652
2667
  next: n?.next ?? null,
2653
2668
  nextPageError: null,
2654
- reelAutoAdvance: xn(e.reelAutoAdvance),
2655
- reelInfoSheet: Cn(e.reelInfoSheet),
2669
+ reelAutoAdvance: gn(e.reelAutoAdvance),
2670
+ reelInfoSheet: vn(e.reelInfoSheet),
2656
2671
  reelInfoSheetOverlay: !1,
2657
2672
  reelMediaSource: "original",
2658
2673
  reelOrigin: null,
@@ -2660,6 +2675,116 @@ function Tn(e, t) {
2660
2675
  };
2661
2676
  }
2662
2677
  //#endregion
2678
+ //#region src/core/itemPlacement.ts
2679
+ function xn(e, t) {
2680
+ let n = new Set(t);
2681
+ return e.flatMap((e, t) => n.has(e.postId) ? [{
2682
+ index: t,
2683
+ item: e
2684
+ }] : []);
2685
+ }
2686
+ function Sn(e, t) {
2687
+ let n = new Set(t.map(({ item: e }) => e.postId));
2688
+ return e.filter((e) => !n.has(e.postId));
2689
+ }
2690
+ function Cn(e, t) {
2691
+ t.forEach(({ index: e }) => {
2692
+ if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
2693
+ });
2694
+ let n = [...e], r = new Set(e.map((e) => e.postId));
2695
+ return [...t].sort((e, t) => e.index - t.index).forEach(({ index: e, item: t }) => {
2696
+ r.has(t.postId) || (n.splice(Math.min(e, n.length), 0, t), r.add(t.postId));
2697
+ }), n;
2698
+ }
2699
+ //#endregion
2700
+ //#region src/core/itemRemovalController.ts
2701
+ var wn = 20, Tn = class {
2702
+ generation = 0;
2703
+ historyLimit;
2704
+ metadata = /* @__PURE__ */ new WeakMap();
2705
+ state;
2706
+ history = [];
2707
+ itemOrder;
2708
+ stopItemsWatcher;
2709
+ constructor(e) {
2710
+ this.options = e, this.historyLimit = e.historyLimit ?? wn, this.state = e.state, this.itemOrder = this.state.items.map(({ postId: e }) => e), this.stopItemsWatcher = D(() => this.state.items, (e) => this.appendUnknownItems(e), { flush: "sync" });
2711
+ }
2712
+ destroy() {
2713
+ this.reset(), this.stopItemsWatcher();
2714
+ }
2715
+ async remove(e) {
2716
+ let t = this.collectOrderedPlacements(e), n = this.createRemoval(t);
2717
+ if (t.length === 0) return n;
2718
+ let r = t.map(({ item: e }) => e.postId), i = this.options.startRemoval(r);
2719
+ if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
2720
+ let a = this.state.items.findIndex((e) => e.postId === this.state.activeReelPostId);
2721
+ return this.state.items = Sn(this.state.items, t), this.options.onItemsRemoved(t, a), this.record(n), n;
2722
+ }
2723
+ reset() {
2724
+ this.generation += 1, this.history = [], this.itemOrder = [];
2725
+ }
2726
+ restoreItems(e) {
2727
+ let t = e;
2728
+ if (this.metadata.has(t)) {
2729
+ this.restoreRemoval(t);
2730
+ return;
2731
+ }
2732
+ let n = Cn(this.state.items, e);
2733
+ this.registerExternalPlacements(e), this.state.items = n;
2734
+ }
2735
+ restoreRemoval(e) {
2736
+ let t = this.metadata.get(e);
2737
+ if (!t) throw TypeError("Vibe removal does not belong to this instance.");
2738
+ return t.generation !== this.generation || t.restored ? !1 : (t.restored = !0, this.removeFromHistory(e), this.restoreOrderedPlacements(e));
2739
+ }
2740
+ undoLast() {
2741
+ for (; this.history.length > 0;) {
2742
+ let e = this.history.pop();
2743
+ if (this.restoreRemoval(e)) return e;
2744
+ }
2745
+ return null;
2746
+ }
2747
+ appendUnknownItems(e) {
2748
+ let t = new Set(this.itemOrder);
2749
+ e.forEach(({ postId: e }) => {
2750
+ t.has(e) || (this.itemOrder.push(e), t.add(e));
2751
+ });
2752
+ }
2753
+ collectOrderedPlacements(e) {
2754
+ let t = new Map(this.itemOrder.map((e, t) => [e, t]));
2755
+ return xn(this.state.items, e).map((e) => ({
2756
+ index: t.get(e.item.postId) ?? e.index,
2757
+ item: e.item
2758
+ }));
2759
+ }
2760
+ createRemoval(e) {
2761
+ let t = Object.freeze(e.map((e) => Object.freeze({ ...e })));
2762
+ return this.metadata.set(t, {
2763
+ generation: this.generation,
2764
+ restored: e.length === 0
2765
+ }), t;
2766
+ }
2767
+ record(e) {
2768
+ this.historyLimit !== 0 && (this.history.push(e), this.history.length > this.historyLimit && this.history.shift());
2769
+ }
2770
+ registerExternalPlacements(e) {
2771
+ let t = new Set(this.itemOrder);
2772
+ [...e].sort((e, t) => e.index - t.index).forEach(({ index: e, item: n }) => {
2773
+ t.has(n.postId) || (this.itemOrder.splice(Math.min(e, this.itemOrder.length), 0, n.postId), t.add(n.postId));
2774
+ });
2775
+ }
2776
+ removeFromHistory(e) {
2777
+ let t = this.history.indexOf(e);
2778
+ t >= 0 && this.history.splice(t, 1);
2779
+ }
2780
+ restoreOrderedPlacements(e) {
2781
+ let t = new Set(this.state.items.map(({ postId: e }) => e)), n = e.map(({ item: e }) => e).filter(({ postId: e }) => !t.has(e));
2782
+ if (n.length === 0) return !1;
2783
+ let r = new Map(this.itemOrder.map((e, t) => [e, t]));
2784
+ 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;
2785
+ }
2786
+ };
2787
+ //#endregion
2663
2788
  //#region src/core/options.ts
2664
2789
  function En(e, t) {
2665
2790
  if (t) {
@@ -2668,7 +2793,8 @@ function En(e, t) {
2668
2793
  }
2669
2794
  }
2670
2795
  function Dn(e) {
2671
- if (Ht(e.autoScroll), En("cardHeader", e.cardHeader), En("cardFooter", e.cardFooter), Nt(e.autofill), on(e.fill), bn(e.reelAutoAdvance), !e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2796
+ if (Ut(e.autoScroll), En("cardHeader", e.cardHeader), En("cardFooter", e.cardFooter), Pt(e.autofill), en(e.fill), hn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2797
+ if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2672
2798
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2673
2799
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
2674
2800
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
@@ -2680,9 +2806,63 @@ function On(e) {
2680
2806
  if (!t) throw Error(`Vibe target not found: ${e}`);
2681
2807
  return t;
2682
2808
  }
2809
+ var kn = 1.5;
2810
+ function An(e) {
2811
+ let t = Math.min(e.screenWidth, e.screenHeight);
2812
+ if (t > 0 && t < 600) return !0;
2813
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * kn;
2814
+ return !e.hasHover && n > 0 && n < 600 && r;
2815
+ }
2816
+ function jn(e) {
2817
+ return An(e) ? "reel" : "masonry";
2818
+ }
2819
+ function Mn(e) {
2820
+ let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
2821
+ return {
2822
+ hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
2823
+ screenHeight: t?.screen.height ?? 0,
2824
+ screenWidth: t?.screen.width ?? 0,
2825
+ viewportHeight: n.clientHeight,
2826
+ viewportWidth: n.clientWidth
2827
+ };
2828
+ }
2829
+ function Nn(e) {
2830
+ return An(Mn(e));
2831
+ }
2832
+ function Pn(e) {
2833
+ return jn(Mn(e));
2834
+ }
2683
2835
  //#endregion
2684
- //#region src/core/vibeRouting.ts
2685
- var kn = class {
2836
+ //#region src/core/responsiveLayoutController.ts
2837
+ var Fn = class {
2838
+ layoutMode;
2839
+ resizeObserver = null;
2840
+ target = null;
2841
+ constructor(e, t, n) {
2842
+ this.state = t, this.onFeedLayout = n, this.layoutMode = e;
2843
+ }
2844
+ mount(e) {
2845
+ this.target = e, this.handleResponsiveLayout();
2846
+ let t = e.ownerDocument.defaultView;
2847
+ t?.addEventListener("resize", this.handleResponsiveLayout);
2848
+ let n = t?.ResizeObserver ?? globalThis.ResizeObserver;
2849
+ n !== void 0 && (this.resizeObserver = new n(this.handleResponsiveLayout), this.resizeObserver.observe(e));
2850
+ }
2851
+ destroy() {
2852
+ this.target?.ownerDocument.defaultView?.removeEventListener("resize", this.handleResponsiveLayout), this.resizeObserver?.disconnect(), this.resizeObserver = null, this.target = null;
2853
+ }
2854
+ setLayout(e) {
2855
+ e !== this.layoutMode && (this.layoutMode = e, e === "responsive" ? this.handleResponsiveLayout() : this.applyLayout(e));
2856
+ }
2857
+ applyLayout(e) {
2858
+ e !== this.state.layout && (e === "masonry" && (this.state.activeReelPostId = null, this.onFeedLayout()), this.state.reelOrigin = null, this.state.layout = e);
2859
+ }
2860
+ handleResponsiveLayout = () => {
2861
+ if (!this.target) return;
2862
+ let e = Pn(this.target);
2863
+ this.state.reelInfoSheetOverlay = Nn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
2864
+ };
2865
+ }, In = class {
2686
2866
  routedReelPostId = null;
2687
2867
  reelRouteIsActive = !1;
2688
2868
  constructor(e, t) {
@@ -2709,7 +2889,7 @@ var kn = class {
2709
2889
  let i = this.reelRouteIsActive ? "replace" : "push";
2710
2890
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
2711
2891
  }
2712
- }, An = class {
2892
+ }, Ln = class {
2713
2893
  app = null;
2714
2894
  autoScroll;
2715
2895
  autofillDelayCountdown;
@@ -2717,38 +2897,48 @@ var kn = class {
2717
2897
  abortController = null;
2718
2898
  pendingRequest = null;
2719
2899
  requestVersion = 0;
2720
- resizeObserver = null;
2900
+ responsiveLayout;
2721
2901
  routing;
2722
2902
  fillController;
2903
+ itemRemoval;
2723
2904
  surface = null;
2724
2905
  stopStateWatcher = null;
2725
- target = null;
2726
- layoutMode;
2727
2906
  lastLoadedCursor = null;
2728
2907
  state;
2729
2908
  constructor(e) {
2730
- this.options = e, Dn(e), this.layoutMode = e.layout ?? "masonry", this.state = b(Tn(e, this.layoutMode)), this.autoScroll = new Wt({
2909
+ this.options = e, Dn(e);
2910
+ let t = e.layout ?? "masonry";
2911
+ this.state = b(bn(e, t)), this.autoScroll = new Gt({
2731
2912
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
2732
2913
  state: this.state.autoScroll
2733
- }), this.autofillDelayCountdown = new kt((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new _n({
2914
+ }), this.autofillDelayCountdown = new At((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new fn({
2734
2915
  fill: e.fill,
2735
2916
  loadPage: e.loadPage,
2736
2917
  onLastCursor: (e) => {
2737
2918
  this.lastLoadedCursor = e;
2738
2919
  },
2739
2920
  state: this.state
2740
- }), this.routing = new kn(e.routing, this.state), this.startStateNotifications();
2921
+ }), this.routing = new In(e.routing, this.state), this.itemRemoval = new Tn({
2922
+ historyLimit: e.removalHistoryLimit,
2923
+ onItemsRemoved: (e, t) => {
2924
+ this.restoreActiveItemAfterRemoval(e, t);
2925
+ },
2926
+ startRemoval: (e) => this.surface?.startItemRemoval(e) ?? 0,
2927
+ state: this.state
2928
+ }), this.responsiveLayout = new Fn(t, this.state, () => {
2929
+ this.routing.syncFeed();
2930
+ }), this.startStateNotifications();
2741
2931
  }
2742
2932
  async mount() {
2743
2933
  if (this.app) throw Error("Vibe is already mounted.");
2744
2934
  this.startStateNotifications();
2745
2935
  let e = On(this.options.target);
2746
- this.target = e, this.startResponsiveLayout(), this.app = r(yt, {
2936
+ this.responsiveLayout.mount(e), this.app = r(bt, {
2747
2937
  canRetryEnd: !!this.options.loadPage,
2748
2938
  cardFooter: this.options.cardFooter,
2749
2939
  cardHeader: this.options.cardHeader,
2750
2940
  feedFooter: this.options.feedFooter,
2751
- feedFooterActions: vn(this),
2941
+ feedFooterActions: pn(this),
2752
2942
  reelInfoSheet: this.options.reelInfoSheet,
2753
2943
  state: this.state,
2754
2944
  onActiveReelChange: (e) => this.setActiveReelPost(e),
@@ -2764,11 +2954,23 @@ var kn = class {
2764
2954
  }), 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();
2765
2955
  }
2766
2956
  destroy() {
2767
- this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.stopResponsiveLayout(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null, this.target = null;
2957
+ this.autoScroll.destroy(), this.fillController.destroy(), this.cancelRequest(), this.itemRemoval.destroy(), this.responsiveLayout.destroy(), this.stopStateWatcher?.(), this.stopStateWatcher = null, this.app?.unmount(), this.app = null, this.surface = null;
2768
2958
  }
2769
2959
  getState() {
2770
2960
  return F(this.state);
2771
2961
  }
2962
+ removeItems(e) {
2963
+ return this.itemRemoval.remove(e);
2964
+ }
2965
+ restoreItems(e) {
2966
+ this.itemRemoval.restoreItems(e);
2967
+ }
2968
+ restoreRemoval(e) {
2969
+ return this.itemRemoval.restoreRemoval(e);
2970
+ }
2971
+ undoLastRemoval() {
2972
+ return this.itemRemoval.undoLast();
2973
+ }
2772
2974
  nextReelMediaItem() {
2773
2975
  return this.surface?.changeActiveReelMedia(1) ?? !1;
2774
2976
  }
@@ -2794,11 +2996,11 @@ var kn = class {
2794
2996
  this.autoScroll.setSpeed(e);
2795
2997
  }
2796
2998
  applyAutofillUpdate(e) {
2797
- let t = qt(this.options.autofill, this.state, e);
2999
+ let t = Jt(this.options.autofill, this.state, e);
2798
3000
  return t && this.syncAutofillCountdown(), t;
2799
3001
  }
2800
3002
  async cancelAutofill() {
2801
- await It(this.options.autofill, this.state, () => this.cancelRequest());
3003
+ await Lt(this.options.autofill, this.state, () => this.cancelRequest());
2802
3004
  }
2803
3005
  applyFillUpdate(e) {
2804
3006
  return this.fillController.applyUpdate(e);
@@ -2807,11 +3009,11 @@ var kn = class {
2807
3009
  return this.fillController.cancel();
2808
3010
  }
2809
3011
  async fill(e) {
2810
- if (this.pendingRequest || Ft(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3012
+ if (this.pendingRequest || It(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
2811
3013
  await this.fillController.start(e);
2812
3014
  }
2813
3015
  restoreAutofillSession(e) {
2814
- let t = Jt(this.options.autofill, this.state, e);
3016
+ let t = Yt(this.options.autofill, this.state, e);
2815
3017
  return t && this.syncAutofillCountdown(), t;
2816
3018
  }
2817
3019
  restoreFillSession(e) {
@@ -2819,15 +3021,15 @@ var kn = class {
2819
3021
  }
2820
3022
  async loadNext() {
2821
3023
  if (this.pendingRequest) return this.pendingRequest;
2822
- if (!this.state.loadMoreLocked && !(Ft(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);
3024
+ if (!this.state.loadMoreLocked && !(It(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);
2823
3025
  }
2824
3026
  async reload() {
2825
3027
  if (!this.options.loadPage) throw Error("Vibe cannot reload without loadPage.");
2826
- return Ft(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Pt(this.options.autofill, void 0, !1), this.fillController.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(null, !1);
3028
+ return It(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Ft(this.options.autofill, void 0, !1), this.fillController.reset(), this.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(null, !1);
2827
3029
  }
2828
3030
  async retryEnd() {
2829
3031
  if (this.pendingRequest) return this.pendingRequest;
2830
- if (!this.state.loadMoreLocked && !(Ft(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);
3032
+ if (!this.state.loadMoreLocked && !(It(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);
2831
3033
  }
2832
3034
  setInfiniteScroll(e) {
2833
3035
  this.state.infiniteScroll = e, e && p(() => this.surface?.loadIfNearBottom());
@@ -2836,36 +3038,27 @@ var kn = class {
2836
3038
  this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
2837
3039
  }
2838
3040
  setReelAutoAdvance(e) {
2839
- Sn(this.state.reelAutoAdvance, e);
3041
+ _n(this.state.reelAutoAdvance, e);
2840
3042
  }
2841
3043
  setReelInfoSheet(e) {
2842
- wn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3044
+ yn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
2843
3045
  }
2844
3046
  setLayout(e) {
2845
- e !== this.layoutMode && (this.layoutMode = e, e === "responsive" ? this.handleResponsiveLayout() : this.applyLayout(e));
2846
- }
2847
- applyLayout(e) {
2848
- e !== this.state.layout && (e === "masonry" && (this.state.activeReelPostId = null, this.routing.syncFeed()), this.state.reelOrigin = null, this.state.layout = e);
2849
- }
2850
- handleResponsiveLayout = () => {
2851
- if (!this.target) return;
2852
- let e = en(this.target);
2853
- this.state.reelInfoSheetOverlay = $t(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
2854
- };
2855
- startResponsiveLayout() {
2856
- if (!this.target) return;
2857
- this.handleResponsiveLayout();
2858
- let e = this.target.ownerDocument.defaultView;
2859
- e?.addEventListener("resize", this.handleResponsiveLayout);
2860
- let t = e?.ResizeObserver ?? globalThis.ResizeObserver;
2861
- t !== void 0 && (this.resizeObserver = new t(this.handleResponsiveLayout), this.resizeObserver.observe(this.target));
2862
- }
2863
- stopResponsiveLayout() {
2864
- this.target?.ownerDocument.defaultView?.removeEventListener("resize", this.handleResponsiveLayout), this.resizeObserver?.disconnect(), this.resizeObserver = null;
3047
+ this.responsiveLayout.setLayout(e);
2865
3048
  }
2866
3049
  closeMasonryReel() {
2867
3050
  this.state.reelOrigin === "masonry" && (this.state.activeReelPostId = null, this.state.reelOrigin = null, this.routing.syncFeed());
2868
3051
  }
3052
+ restoreActiveItemAfterRemoval(e, t) {
3053
+ let n = new Set(e.map(({ item: e }) => e.postId));
3054
+ if (this.state.activeReelPostId === null || !n.has(this.state.activeReelPostId)) return;
3055
+ if (this.state.reelOrigin === "masonry") {
3056
+ this.closeMasonryReel();
3057
+ return;
3058
+ }
3059
+ let r = this.state.items[Math.min(Math.max(t, 0), this.state.items.length - 1)];
3060
+ this.state.activeReelPostId = r?.postId ?? null, r ? this.routing.syncReel(r.postId) : this.routing.syncFeed();
3061
+ }
2869
3062
  openMasonryReel(e) {
2870
3063
  this.state.layout === "masonry" && this.state.items.some((t) => t.postId === e) && (this.state.activeReelPostId = e, this.state.reelOrigin = "masonry", this.routing.syncReel(e));
2871
3064
  }
@@ -2882,7 +3075,7 @@ var kn = class {
2882
3075
  this.abortController = i;
2883
3076
  try {
2884
3077
  if (a?.strategy === "frontend") {
2885
- let o = await Rt({
3078
+ let o = await zt({
2886
3079
  existingItems: t ? this.state.items : [],
2887
3080
  initialCursor: e,
2888
3081
  loadPage: n,
@@ -2904,7 +3097,7 @@ var kn = class {
2904
3097
  });
2905
3098
  return;
2906
3099
  }
2907
- let c = bt(await n({
3100
+ let c = xt(await n({
2908
3101
  cursor: e,
2909
3102
  signal: i.signal
2910
3103
  }));
@@ -2919,7 +3112,7 @@ var kn = class {
2919
3112
  this.state.autofill.status = "complete";
2920
3113
  return;
2921
3114
  }
2922
- await Gt(a, this.state, {
3115
+ await Kt(a, this.state, {
2923
3116
  cycleId: o,
2924
3117
  feedKey: a.feedKey,
2925
3118
  items: u.slice(l.length),
@@ -2944,7 +3137,7 @@ var kn = class {
2944
3137
  this.autofillDelayCountdown.clear();
2945
3138
  let t = `vibe-autofill-${Date.now().toString(36)}-${++this.autofillCycle}`;
2946
3139
  return this.state.autofill = {
2947
- ...Pt(e, void 0, !1),
3140
+ ...Ft(e, void 0, !1),
2948
3141
  cycleId: t,
2949
3142
  status: "filling"
2950
3143
  }, t;
@@ -2962,7 +3155,7 @@ var kn = class {
2962
3155
  startInitialAutofill() {
2963
3156
  let e = ++this.requestVersion, t = new AbortController(), n = this.beginAutofillCycle();
2964
3157
  this.abortController = t, this.state.isLoadingMore = !0;
2965
- let r = tn({
3158
+ let r = Xt({
2966
3159
  cycleId: n,
2967
3160
  isCurrent: () => e === this.requestVersion,
2968
3161
  onLastCursor: (e) => {
@@ -2986,8 +3179,8 @@ var kn = class {
2986
3179
  }));
2987
3180
  }
2988
3181
  };
2989
- function jn(e) {
2990
- return new An(e);
3182
+ function Rn(e) {
3183
+ return new Ln(e);
2991
3184
  }
2992
3185
  //#endregion
2993
- export { jn as createVibe };
3186
+ export { Rn as createVibe };