@wyxos/vibe 4.5.3 → 4.5.5

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
@@ -1,20 +1,20 @@
1
- import { Fragment as e, Transition as t, computed as n, createApp as r, createBlock as i, createCommentVNode as a, createElementBlock as o, createElementVNode as s, createTextVNode as c, createVNode as l, defineComponent as u, guardReactiveProps as d, h as f, nextTick as p, normalizeClass as m, normalizeProps as h, normalizeStyle as g, onBeforeUnmount as _, onMounted as v, openBlock as y, reactive as b, renderList as x, resolveDynamicComponent as S, shallowRef as C, toDisplayString as w, unref as T, useId as E, watch as D, withCtx as O, withKeys as k, withModifiers as A } from "vue";
1
+ import { Fragment as e, Teleport as t, Transition as n, computed as r, createApp as i, createBlock as a, createCommentVNode as o, createElementBlock as s, createElementVNode as c, createTextVNode as l, createVNode as u, defineComponent as d, guardReactiveProps as f, h as p, nextTick as m, normalizeClass as h, normalizeProps as g, normalizeStyle as _, onBeforeUnmount as v, onMounted as y, openBlock as b, reactive as x, renderList as S, resolveDynamicComponent as C, shallowRef as w, toDisplayString as T, unref as E, useId as D, watch as O, withCtx as k, withKeys as A, withModifiers as j } from "vue";
2
2
  //#region src/core/mediaAsset.ts
3
- function j(e) {
3
+ function M(e) {
4
4
  return [e, ...e.items];
5
5
  }
6
- function M(e, t) {
7
- return Math.min(e.items.length, Math.max(0, t));
8
- }
9
6
  function N(e, t) {
10
- return j(e)[M(e, t)] ?? e;
7
+ return Math.min(e.items.length, Math.max(0, t));
11
8
  }
12
9
  function P(e, t) {
10
+ return M(e)[N(e, t)] ?? e;
11
+ }
12
+ function F(e, t) {
13
13
  return `${String(e)}:${t}`;
14
14
  }
15
15
  //#endregion
16
16
  //#region src/core/runtime.ts
17
- function F(e) {
17
+ function I(e) {
18
18
  return {
19
19
  activeReelPostId: e.activeReelPostId,
20
20
  autoScroll: { ...e.autoScroll },
@@ -42,17 +42,17 @@ function F(e) {
42
42
  }
43
43
  //#endregion
44
44
  //#region src/components/GalleryFooter.vue?vue&type=script&setup=true&lang.ts
45
- var I = {
45
+ var L = {
46
46
  key: 0,
47
47
  class: "gallery-footer"
48
- }, L = {
48
+ }, R = {
49
49
  key: 0,
50
50
  class: "load-more-status",
51
51
  role: "status"
52
- }, R = ["disabled"], z = {
52
+ }, z = ["disabled"], B = {
53
53
  key: 2,
54
54
  class: "end-feed"
55
- }, B = ["disabled"], V = /* @__PURE__ */ u({
55
+ }, V = ["disabled"], H = /* @__PURE__ */ d({
56
56
  __name: "GalleryFooter",
57
57
  props: {
58
58
  canRetryEnd: { type: Boolean },
@@ -67,25 +67,25 @@ var I = {
67
67
  function i() {
68
68
  n.loadMoreLocked || (n.hasNext ? r("loadMore") : r("retryEnd"));
69
69
  }
70
- return (t, n) => e.hasNext || e.isLoading || e.hasError || e.canRetryEnd ? (y(), o("footer", I, [e.isLoading ? (y(), o("p", L, " Loading more… ")) : e.hasError || e.hasNext ? (y(), o("button", {
70
+ return (t, n) => e.hasNext || e.isLoading || e.hasError || e.canRetryEnd ? (b(), s("footer", L, [e.isLoading ? (b(), s("p", R, " Loading more… ")) : e.hasError || e.hasNext ? (b(), s("button", {
71
71
  key: 1,
72
72
  "data-test": "load-more",
73
73
  class: "load-more-button",
74
74
  type: "button",
75
75
  disabled: e.loadMoreLocked,
76
76
  onClick: i
77
- }, w(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, R)) : (y(), o("div", z, [n[1] ||= s("p", {
77
+ }, T(e.hasError ? "Try again" : e.loadMoreLocked ? "Loading paused" : "Load more"), 9, z)) : (b(), s("div", B, [n[1] ||= c("p", {
78
78
  class: "end-feed-message",
79
79
  role: "status"
80
- }, " You've reached the end. ", -1), s("button", {
80
+ }, " You've reached the end. ", -1), c("button", {
81
81
  "data-test": "retry-end",
82
82
  class: "load-more-button",
83
83
  type: "button",
84
84
  disabled: e.loadMoreLocked,
85
85
  onClick: n[0] ||= (e) => t.$emit("retryEnd")
86
- }, " Check for more ", 8, B)]))])) : a("", !0);
86
+ }, " Check for more ", 8, V)]))])) : o("", !0);
87
87
  }
88
- }), H = /* @__PURE__ */ u({
88
+ }), U = /* @__PURE__ */ d({
89
89
  __name: "FeedFooter",
90
90
  props: {
91
91
  actions: {},
@@ -100,18 +100,18 @@ var I = {
100
100
  emits: ["loadMore", "retryEnd"],
101
101
  setup(e, { emit: t }) {
102
102
  let n = e, r = t;
103
- function a() {
103
+ function i() {
104
104
  n.actions?.cancelAutofill();
105
105
  }
106
106
  function o() {
107
107
  n.actions?.retry();
108
108
  }
109
- return (t, n) => e.feedFooter && e.actions && e.state ? (y(), i(S(e.feedFooter.component), {
109
+ return (t, n) => e.feedFooter && e.actions && e.state ? (b(), a(C(e.feedFooter.component), {
110
110
  key: 0,
111
111
  actions: e.actions,
112
112
  "can-retry-end": e.canRetryEnd,
113
113
  state: e.state,
114
- onAutofillCancel: a,
114
+ onAutofillCancel: i,
115
115
  onLoadMore: n[0] ||= (e) => r("loadMore"),
116
116
  onRetry: o,
117
117
  onRetryEnd: n[1] ||= (e) => r("retryEnd")
@@ -119,7 +119,7 @@ var I = {
119
119
  "actions",
120
120
  "can-retry-end",
121
121
  "state"
122
- ])) : (y(), i(V, {
122
+ ])) : (b(), a(H, {
123
123
  key: 1,
124
124
  "can-retry-end": e.canRetryEnd,
125
125
  "has-error": e.hasError,
@@ -136,7 +136,7 @@ var I = {
136
136
  "load-more-locked"
137
137
  ]));
138
138
  }
139
- }), U = ["role"], W = { class: "gallery-status" }, ee = /* @__PURE__ */ u({
139
+ }), W = ["role"], G = { class: "gallery-status" }, ee = /* @__PURE__ */ d({
140
140
  __name: "FeedStatus",
141
141
  props: {
142
142
  actions: {},
@@ -146,11 +146,11 @@ var I = {
146
146
  },
147
147
  emits: ["loadMore", "retryEnd"],
148
148
  setup(t, { emit: n }) {
149
- let r = t, l = n;
150
- return (n, u) => (y(), o("main", {
149
+ let r = t, i = n;
150
+ return (n, u) => (b(), s("main", {
151
151
  class: "gallery-shell",
152
152
  role: r.state.error ? "alert" : r.state.isLoading ? "status" : void 0
153
- }, [s("p", W, [r.state.error ? (y(), o(e, { key: 0 }, [c(" Unable to load media. ")], 64)) : r.state.isLoading ? (y(), o(e, { key: 1 }, [c(" Loading media… ")], 64)) : (y(), o(e, { key: 2 }, [c(" No media found. ")], 64))]), t.feedFooter ? (y(), i(H, {
153
+ }, [c("p", G, [r.state.error ? (b(), s(e, { key: 0 }, [l(" Unable to load media. ")], 64)) : r.state.isLoading ? (b(), s(e, { key: 1 }, [l(" Loading media… ")], 64)) : (b(), s(e, { key: 2 }, [l(" No media found. ")], 64))]), t.feedFooter ? (b(), a(U, {
154
154
  key: 0,
155
155
  actions: t.actions,
156
156
  "can-retry-end": t.canRetryEnd,
@@ -160,8 +160,8 @@ var I = {
160
160
  "is-loading": t.state.isLoadingMore,
161
161
  "load-more-locked": t.state.loadMoreLocked,
162
162
  state: t.state,
163
- onLoadMore: u[0] ||= (e) => l("loadMore"),
164
- onRetryEnd: u[1] ||= (e) => l("retryEnd")
163
+ onLoadMore: u[0] ||= (e) => i("loadMore"),
164
+ onRetryEnd: u[1] ||= (e) => i("retryEnd")
165
165
  }, null, 8, [
166
166
  "actions",
167
167
  "can-retry-end",
@@ -171,10 +171,10 @@ var I = {
171
171
  "is-loading",
172
172
  "load-more-locked",
173
173
  "state"
174
- ])) : a("", !0)], 8, U));
174
+ ])) : o("", !0)], 8, W));
175
175
  }
176
176
  });
177
- function G(e) {
177
+ function K(e) {
178
178
  return e.scrollHeight - e.scrollTop - e.clientHeight <= 240;
179
179
  }
180
180
  //#endregion
@@ -189,11 +189,11 @@ function ne(e) {
189
189
  function re(e) {
190
190
  return Math.max(0, e.containerHeight) + Math.max(0, e.gap);
191
191
  }
192
- function K(e, t) {
192
+ function q(e, t) {
193
193
  let n = Math.max(0, t.overscan), r = t.scrollTop - n, i = t.scrollTop + Math.max(0, t.viewportHeight) + n;
194
194
  return e.reduce((e, t, n) => (t.y + t.height >= r && t.y <= i && e.push(n), e), []);
195
195
  }
196
- function q(e, t, n) {
196
+ function J(e, t, n) {
197
197
  if (t <= 0 || e.length === 0) return {
198
198
  columns: 0,
199
199
  height: 0,
@@ -216,7 +216,7 @@ function q(e, t, n) {
216
216
  }
217
217
  //#endregion
218
218
  //#region src/core/scrollbar.ts
219
- function J(e, t, n) {
219
+ function ie(e, t, n) {
220
220
  return Math.min(n, Math.max(t, e));
221
221
  }
222
222
  function Y({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize: r, viewportSize: i }) {
@@ -228,23 +228,23 @@ function Y({ contentSize: e, minimumThumbSize: t, scrollPosition: n, trackSize:
228
228
  thumbSize: o,
229
229
  thumbTravel: 0
230
230
  };
231
- let l = J(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
231
+ let l = ie(s / a * o, Math.min(Math.max(0, t), o), o), u = Math.max(0, o - l);
232
232
  return {
233
233
  maximumScrollPosition: c,
234
234
  scrollable: !0,
235
- thumbOffset: u * (J(n, 0, c) / c),
235
+ thumbOffset: u * (ie(n, 0, c) / c),
236
236
  thumbSize: l,
237
237
  thumbTravel: u
238
238
  };
239
239
  }
240
240
  //#endregion
241
241
  //#region src/components/GalleryScrollbar.vue?vue&type=script&setup=true&lang.ts
242
- var ie = ["aria-hidden"], ae = [
242
+ var X = ["aria-hidden"], ae = [
243
243
  "aria-controls",
244
244
  "aria-valuemax",
245
245
  "aria-valuenow",
246
246
  "tabindex"
247
- ], oe = 32, X = 40, Z = 120, se = /* @__PURE__ */ u({
247
+ ], oe = 32, se = 40, ce = 120, le = /* @__PURE__ */ d({
248
248
  __name: "GalleryScrollbar",
249
249
  props: {
250
250
  contentSize: {},
@@ -253,40 +253,40 @@ var ie = ["aria-hidden"], ae = [
253
253
  suspended: { type: Boolean }
254
254
  },
255
255
  setup(e) {
256
- let t = e, r = {
256
+ let t = e, n = {
257
257
  maximumScrollPosition: 0,
258
258
  scrollable: !1,
259
259
  thumbOffset: 0,
260
260
  thumbSize: 0,
261
261
  thumbTravel: 0
262
- }, i = C(null), a = C(r), c = C(!1), l = C(!1), u = C(!1), d = null, f = 0, h = 0, v = null, b = null, x = null, S = null, w = !1, T = null, E = n(() => a.value.scrollable && !t.suspended), O = n(() => ({
262
+ }, i = w(null), a = w(n), o = w(!1), l = w(!1), u = w(!1), d = null, f = 0, p = 0, g = null, y = null, x = null, S = null, C = !1, T = null, E = r(() => a.value.scrollable && !t.suspended), D = r(() => ({
263
263
  height: `${a.value.thumbSize}px`,
264
264
  transform: `translate3d(0, ${a.value.thumbOffset}px, 0)`
265
265
  }));
266
266
  function k() {
267
- v !== null && clearTimeout(v), v = setTimeout(() => {
268
- v = null, c.value || (l.value = !1);
269
- }, Z);
267
+ g !== null && clearTimeout(g), g = setTimeout(() => {
268
+ g = null, o.value || (l.value = !1);
269
+ }, ce);
270
270
  }
271
271
  function A() {
272
272
  l.value = !0, k();
273
273
  }
274
274
  function j() {
275
- let e = t.scrollElement, n = i.value;
276
- return !e || !n ? r : Y({
275
+ let e = t.scrollElement, r = i.value;
276
+ return !e || !r ? n : Y({
277
277
  contentSize: e.scrollHeight,
278
278
  minimumThumbSize: oe,
279
279
  scrollPosition: e.scrollTop,
280
- trackSize: n.clientHeight,
280
+ trackSize: r.clientHeight,
281
281
  viewportSize: e.clientHeight
282
282
  });
283
283
  }
284
284
  function M(e) {
285
- if (c.value && e !== "scroll") {
286
- w = !0;
285
+ if (o.value && e !== "scroll") {
286
+ C = !0;
287
287
  return;
288
288
  }
289
- if (c.value) {
289
+ if (o.value) {
290
290
  let e = t.scrollElement;
291
291
  if (!e || a.value.maximumScrollPosition <= 0) return;
292
292
  let n = Math.min(1, Math.max(0, e.scrollTop / a.value.maximumScrollPosition));
@@ -296,8 +296,8 @@ var ie = ["aria-hidden"], ae = [
296
296
  };
297
297
  return;
298
298
  }
299
- a.value = j(), !(u.value || b !== null) && (b = requestAnimationFrame(() => {
300
- b = null, u.value = !0;
299
+ a.value = j(), !(u.value || y !== null) && (y = requestAnimationFrame(() => {
300
+ y = null, u.value = !0;
301
301
  }));
302
302
  }
303
303
  function N() {
@@ -316,19 +316,19 @@ var ie = ["aria-hidden"], ae = [
316
316
  P(Math.min(1, Math.max(0, n / a.value.thumbTravel)) * a.value.maximumScrollPosition);
317
317
  }
318
318
  function I(e) {
319
- E.value && (e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture?.(e.pointerId), d = e.pointerId, f = e.clientY, h = t.scrollElement?.scrollTop ?? 0, c.value = !0, l.value = !0, v !== null && clearTimeout(v), v = null);
319
+ E.value && (e.preventDefault(), e.stopPropagation(), e.currentTarget.setPointerCapture?.(e.pointerId), d = e.pointerId, f = e.clientY, p = t.scrollElement?.scrollTop ?? 0, o.value = !0, l.value = !0, g !== null && clearTimeout(g), g = null);
320
320
  }
321
321
  function L(e) {
322
- if (!c.value || e.pointerId !== d || (e.preventDefault(), a.value.thumbTravel <= 0)) return;
322
+ if (!o.value || e.pointerId !== d || (e.preventDefault(), a.value.thumbTravel <= 0)) return;
323
323
  let t = (e.clientY - f) / a.value.thumbTravel * a.value.maximumScrollPosition;
324
- P(h + t);
324
+ P(p + t);
325
325
  }
326
326
  function R(e) {
327
- !c.value || e.pointerId !== d || (e.currentTarget.releasePointerCapture?.(e.pointerId), d = null, c.value = !1, w && (w = !1, M("content")), k());
327
+ !o.value || e.pointerId !== d || (e.currentTarget.releasePointerCapture?.(e.pointerId), d = null, o.value = !1, C && (C = !1, M("content")), k());
328
328
  }
329
329
  function z(e) {
330
330
  if (!E.value) return;
331
- let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - X : e.key === "ArrowDown" ? r + X : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
331
+ let n = t.scrollElement?.clientHeight ?? 0, r = t.scrollElement?.scrollTop ?? 0, i = e.key === "ArrowUp" ? r - se : e.key === "ArrowDown" ? r + se : e.key === "PageUp" ? r - n : e.key === "PageDown" ? r + n : e.key === "Home" ? 0 : e.key === "End" ? a.value.maximumScrollPosition : null;
332
332
  i !== null && (e.preventDefault(), A(), P(i));
333
333
  }
334
334
  function B(e) {
@@ -337,28 +337,28 @@ var ie = ["aria-hidden"], ae = [
337
337
  for (let t of e.children) S.observe(t);
338
338
  }
339
339
  }
340
- return D(() => t.scrollElement, (e, t) => {
340
+ return O(() => t.scrollElement, (e, t) => {
341
341
  t?.removeEventListener("scroll", N), x?.disconnect(), x = null, S?.disconnect(), S = null, T?.disconnect(), T = null, e?.addEventListener("scroll", N, { passive: !0 }), e && typeof ResizeObserver < "u" && (T = new ResizeObserver(() => {
342
342
  A(), M("resize");
343
343
  }), T.observe(e), B(e)), e && typeof MutationObserver < "u" && (x = new MutationObserver(() => {
344
344
  B(e), M("content");
345
- }), x.observe(e, { childList: !0 })), p(() => M("resize"));
346
- }, { immediate: !0 }), D(() => t.contentSize, () => {
347
- p(() => M("content"));
348
- }), _(() => {
349
- t.scrollElement?.removeEventListener("scroll", N), x?.disconnect(), S?.disconnect(), T?.disconnect(), v !== null && clearTimeout(v), b !== null && cancelAnimationFrame(b);
350
- }), (t, n) => (y(), o("div", {
345
+ }), x.observe(e, { childList: !0 })), m(() => M("resize"));
346
+ }, { immediate: !0 }), O(() => t.contentSize, () => {
347
+ m(() => M("content"));
348
+ }), v(() => {
349
+ t.scrollElement?.removeEventListener("scroll", N), x?.disconnect(), S?.disconnect(), T?.disconnect(), g !== null && clearTimeout(g), y !== null && cancelAnimationFrame(y);
350
+ }), (t, n) => (b(), s("div", {
351
351
  ref_key: "trackElement",
352
352
  ref: i,
353
- class: m(["gallery-scrollbar", {
354
- "gallery-scrollbar--dragging": c.value,
353
+ class: h(["gallery-scrollbar", {
354
+ "gallery-scrollbar--dragging": o.value,
355
355
  "gallery-scrollbar--interacting": l.value,
356
356
  "gallery-scrollbar--ready": u.value,
357
357
  "gallery-scrollbar--visible": E.value
358
358
  }]),
359
359
  "aria-hidden": !E.value || void 0,
360
360
  onPointerdown: F
361
- }, [s("div", {
361
+ }, [c("div", {
362
362
  class: "gallery-scrollbar-thumb",
363
363
  "aria-controls": e.controlsId,
364
364
  "aria-label": "Media gallery scroll position",
@@ -367,22 +367,22 @@ var ie = ["aria-hidden"], ae = [
367
367
  "aria-valuemin": "0",
368
368
  "aria-valuenow": Math.round(e.scrollElement?.scrollTop ?? 0),
369
369
  role: "scrollbar",
370
- style: g(O.value),
370
+ style: _(D.value),
371
371
  tabindex: E.value ? 0 : -1,
372
372
  onKeydown: z,
373
373
  onPointercancel: R,
374
374
  onPointerdown: I,
375
375
  onPointermove: L,
376
376
  onPointerup: R
377
- }, null, 44, ae)], 42, ie));
377
+ }, null, 44, ae)], 42, X));
378
378
  }
379
- }), ce = (e) => {
379
+ }), Z = (e) => {
380
380
  for (let t in e) if (t.startsWith("aria-") || t === "role" || t === "title") return !0;
381
381
  return !1;
382
- }, le = (e) => e === "", ue = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), de = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), fe = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), pe = (e) => {
383
- let t = fe(e);
382
+ }, ue = (e) => e === "", de = (...e) => e.filter((e, t, n) => !!e && e.trim() !== "" && n.indexOf(e) === t).join(" ").trim(), fe = (e) => e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), pe = (e) => e.replace(/^([A-Z])|[\s-_]+(\w)/g, (e, t, n) => n ? n.toUpperCase() : t.toLowerCase()), me = (e) => {
383
+ let t = pe(e);
384
384
  return t.charAt(0).toUpperCase() + t.slice(1);
385
- }, me = {
385
+ }, he = {
386
386
  xmlns: "http://www.w3.org/2000/svg",
387
387
  width: 24,
388
388
  height: 24,
@@ -392,27 +392,27 @@ var ie = ["aria-hidden"], ae = [
392
392
  "stroke-width": 2,
393
393
  "stroke-linecap": "round",
394
394
  "stroke-linejoin": "round"
395
- }, he = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = me.width, color: s = me.stroke, ...c }, { slots: l }) => f("svg", {
396
- ...me,
395
+ }, ge = ({ name: e, iconNode: t, absoluteStrokeWidth: n, "absolute-stroke-width": r, strokeWidth: i, "stroke-width": a, size: o = he.width, color: s = he.stroke, ...c }, { slots: l }) => p("svg", {
396
+ ...he,
397
397
  ...c,
398
398
  width: o,
399
399
  height: o,
400
400
  stroke: s,
401
- "stroke-width": le(n) || le(r) || n === !0 || r === !0 ? Number(i || a || me["stroke-width"]) * 24 / Number(o) : i || a || me["stroke-width"],
402
- class: ue("lucide", c.class, ...e ? [`lucide-${de(pe(e))}-icon`, `lucide-${de(e)}`] : ["lucide-icon"]),
403
- ...!l.default && !ce(c) && { "aria-hidden": "true" }
404
- }, [...t.map((e) => f(...e)), ...l.default ? [l.default()] : []]), ge = (e, t) => (n, { slots: r, attrs: i }) => f(he, {
401
+ "stroke-width": ue(n) || ue(r) || n === !0 || r === !0 ? Number(i || a || he["stroke-width"]) * 24 / Number(o) : i || a || he["stroke-width"],
402
+ class: de("lucide", c.class, ...e ? [`lucide-${fe(me(e))}-icon`, `lucide-${fe(e)}`] : ["lucide-icon"]),
403
+ ...!l.default && !Z(c) && { "aria-hidden": "true" }
404
+ }, [...t.map((e) => p(...e)), ...l.default ? [l.default()] : []]), _e = (e, t) => (n, { slots: r, attrs: i }) => p(ge, {
405
405
  ...i,
406
406
  ...n,
407
407
  iconNode: t,
408
408
  name: e
409
- }, r), _e = ge("chevron-left", [["path", {
409
+ }, r), ve = _e("chevron-left", [["path", {
410
410
  d: "m15 18-6-6 6-6",
411
411
  key: "1wnfg3"
412
- }]]), ve = ge("chevron-right", [["path", {
412
+ }]]), ye = _e("chevron-right", [["path", {
413
413
  d: "m9 18 6-6-6-6",
414
414
  key: "mthhwq"
415
- }]]), ye = ge("pause", [["rect", {
415
+ }]]), be = _e("pause", [["rect", {
416
416
  x: "14",
417
417
  y: "3",
418
418
  width: "5",
@@ -426,10 +426,10 @@ var ie = ["aria-hidden"], ae = [
426
426
  height: "18",
427
427
  rx: "1",
428
428
  key: "1wsw3u"
429
- }]]), be = ge("play", [["path", {
429
+ }]]), xe = _e("play", [["path", {
430
430
  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",
431
431
  key: "10ikf1"
432
- }]]), xe = ge("volume-2", [
432
+ }]]), Se = _e("volume-2", [
433
433
  ["path", {
434
434
  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",
435
435
  key: "uqj9uw"
@@ -442,7 +442,7 @@ var ie = ["aria-hidden"], ae = [
442
442
  d: "M19.364 18.364a9 9 0 0 0 0-12.728",
443
443
  key: "ijwkga"
444
444
  }]
445
- ]), Se = ge("volume-x", [
445
+ ]), Ce = _e("volume-x", [
446
446
  ["path", {
447
447
  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",
448
448
  key: "uqj9uw"
@@ -461,32 +461,32 @@ var ie = ["aria-hidden"], ae = [
461
461
  y2: "15",
462
462
  key: "5ykzw1"
463
463
  }]
464
- ]), Ce = {
464
+ ]), we = {
465
465
  401: "Authentication required",
466
466
  403: "Access forbidden",
467
467
  404: "Preview not found",
468
468
  419: "Session expired",
469
469
  500: "Server error"
470
470
  };
471
- function we(e) {
471
+ function Te(e) {
472
472
  return e.match(/\/demo-errors\/(401|403|404|419|500)\//)?.[1] ?? "Error";
473
473
  }
474
- function Te(e) {
475
- return Ce[we(e)] ?? "Preview unavailable";
474
+ function Ee(e) {
475
+ return we[Te(e)] ?? "Preview unavailable";
476
476
  }
477
477
  //#endregion
478
478
  //#region src/core/mediaType.ts
479
- var Ee = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
480
- function De(e) {
479
+ var De = /\.(aac|flac|m4a|mp3|mp4|mov|ogg|opus|wav|webm)$/i;
480
+ function Oe(e) {
481
481
  try {
482
- return Ee.test(new URL(e).pathname);
482
+ return De.test(new URL(e).pathname);
483
483
  } catch {
484
- return Ee.test(e.split("?")[0] ?? e);
484
+ return De.test(e.split("?")[0] ?? e);
485
485
  }
486
486
  }
487
487
  //#endregion
488
488
  //#region src/components/CardRegion.vue
489
- var Oe = /* @__PURE__ */ u({
489
+ var ke = /* @__PURE__ */ d({
490
490
  __name: "CardRegion",
491
491
  props: {
492
492
  index: {},
@@ -501,24 +501,24 @@ var Oe = /* @__PURE__ */ u({
501
501
  total: {}
502
502
  },
503
503
  setup(e) {
504
- let t = e, r = n(() => M(t.item, t.mediaIndex)), a = n(() => j(t.item)), s = n(() => N(t.item, r.value)), c = n(() => ({
504
+ let t = e, n = r(() => N(t.item, t.mediaIndex)), i = r(() => M(t.item)), o = r(() => P(t.item, n.value)), c = r(() => ({
505
505
  height: `${t.region.height}px`,
506
506
  paddingBlock: t.style?.paddingY === void 0 ? void 0 : `${t.style.paddingY}px`,
507
507
  paddingInline: t.style?.paddingX === void 0 ? void 0 : `${t.style.paddingX}px`
508
- })), l = n(() => t.style?.background ?? t.region.background);
509
- return (t, n) => (y(), o("div", {
510
- class: m(["media-card-region", [`media-card-${e.placement}`, { "media-card-region--transparent": l.value === "transparent" }]]),
511
- style: g(c.value),
512
- onClick: n[0] ||= A(() => {}, ["stop"]),
513
- onKeydown: n[1] ||= A(() => {}, ["stop"])
514
- }, [(y(), i(S(e.region.component), {
508
+ })), l = r(() => t.style?.background ?? t.region.background);
509
+ return (t, r) => (b(), s("div", {
510
+ class: h(["media-card-region", [`media-card-${e.placement}`, { "media-card-region--transparent": l.value === "transparent" }]]),
511
+ style: _(c.value),
512
+ onClick: r[0] ||= j(() => {}, ["stop"]),
513
+ onKeydown: r[1] ||= j(() => {}, ["stop"])
514
+ }, [(b(), a(C(e.region.component), {
515
515
  index: e.index,
516
516
  item: e.item,
517
517
  layout: e.layout,
518
518
  "loaded-count": e.loadedCount,
519
- "media-count": a.value.length,
520
- "media-index": r.value,
521
- "media-item": s.value,
519
+ "media-count": i.value.length,
520
+ "media-index": n.value,
521
+ "media-item": o.value,
522
522
  "media-source": e.mediaSource ?? "preview",
523
523
  total: e.total
524
524
  }, null, 8, [
@@ -533,18 +533,18 @@ var Oe = /* @__PURE__ */ u({
533
533
  "total"
534
534
  ]))], 38));
535
535
  }
536
- }), ke = [
536
+ }), Ae = [
537
537
  "max",
538
538
  "value",
539
539
  "aria-valuetext",
540
540
  "disabled"
541
- ], Ae = {
541
+ ], je = {
542
542
  key: 0,
543
543
  class: "media-controls-row"
544
- }, je = ["aria-label", "title"], Me = { class: "media-controls-audio" }, Ne = ["aria-label", "title"], Pe = ["value", "aria-valuetext"], Fe = {
544
+ }, Me = ["aria-label", "title"], Ne = { class: "media-controls-audio" }, Pe = ["aria-label", "title"], Fe = ["value", "aria-valuetext"], Ie = {
545
545
  class: "media-control-time",
546
546
  "aria-live": "off"
547
- }, Ie = /* @__PURE__ */ u({
547
+ }, Le = /* @__PURE__ */ d({
548
548
  __name: "MediaControls",
549
549
  props: {
550
550
  currentTime: {},
@@ -561,7 +561,7 @@ var Oe = /* @__PURE__ */ u({
561
561
  "volumeChange"
562
562
  ],
563
563
  setup(e, { emit: t }) {
564
- let r = e, c = t;
564
+ let n = e, i = t;
565
565
  function l(e, t = 1) {
566
566
  return Number.isFinite(e) ? Math.min(t, Math.max(0, e)) : 0;
567
567
  }
@@ -572,70 +572,70 @@ var Oe = /* @__PURE__ */ u({
572
572
  function d(e) {
573
573
  return Number(e.target.value);
574
574
  }
575
- let f = n(() => Math.max(0, r.duration)), p = n(() => l(r.currentTime, f.value)), h = n(() => ({ "--media-range-progress": `${f.value > 0 ? p.value / f.value * 100 : 0}%` })), _ = n(() => ({ "--media-range-progress": `${l(r.volume) * 100}%` }));
576
- return (t, n) => (y(), o("div", {
577
- class: m(["media-controls", `media-controls--${e.layout}`]),
575
+ let f = r(() => Math.max(0, n.duration)), p = r(() => l(n.currentTime, f.value)), m = r(() => ({ "--media-range-progress": `${f.value > 0 ? p.value / f.value * 100 : 0}%` })), g = r(() => ({ "--media-range-progress": `${l(n.volume) * 100}%` }));
576
+ return (t, n) => (b(), s("div", {
577
+ class: h(["media-controls", `media-controls--${e.layout}`]),
578
578
  "aria-label": "Video controls",
579
- onClick: n[4] ||= A(() => {}, ["stop"]),
580
- onDblclick: n[5] ||= A(() => {}, ["stop"]),
581
- onKeydown: n[6] ||= A(() => {}, ["stop"]),
582
- onWheel: n[7] ||= A(() => {}, ["stop"])
583
- }, [s("input", {
579
+ onClick: n[4] ||= j(() => {}, ["stop"]),
580
+ onDblclick: n[5] ||= j(() => {}, ["stop"]),
581
+ onKeydown: n[6] ||= j(() => {}, ["stop"]),
582
+ onWheel: n[7] ||= j(() => {}, ["stop"])
583
+ }, [c("input", {
584
584
  class: "media-control-range media-control-seek",
585
585
  type: "range",
586
586
  min: "0",
587
587
  max: f.value || 0,
588
588
  step: "0.1",
589
589
  value: p.value,
590
- style: g(h.value),
590
+ style: _(m.value),
591
591
  "aria-label": "Seek video",
592
592
  "aria-valuetext": `${u(p.value)} of ${u(f.value)}`,
593
593
  disabled: f.value <= 0,
594
- onInput: n[0] ||= (e) => c("seek", d(e))
595
- }, null, 44, ke), e.layout === "reel" ? (y(), o("div", Ae, [
596
- s("button", {
594
+ onInput: n[0] ||= (e) => i("seek", d(e))
595
+ }, null, 44, Ae), e.layout === "reel" ? (b(), s("div", je, [
596
+ c("button", {
597
597
  type: "button",
598
598
  class: "media-control-button media-control-playback",
599
599
  "aria-label": e.playing ? "Pause video" : "Play video",
600
600
  title: e.playing ? "Pause" : "Play",
601
- onClick: n[1] ||= (e) => c("togglePlayback")
602
- }, [e.playing ? (y(), i(T(ye), {
601
+ onClick: n[1] ||= (e) => i("togglePlayback")
602
+ }, [e.playing ? (b(), a(E(be), {
603
603
  key: 0,
604
604
  size: 18,
605
605
  fill: "currentColor"
606
- })) : (y(), i(T(be), {
606
+ })) : (b(), a(E(xe), {
607
607
  key: 1,
608
608
  size: 18,
609
609
  fill: "currentColor"
610
- }))], 8, je),
611
- s("div", Me, [s("button", {
610
+ }))], 8, Me),
611
+ c("div", Ne, [c("button", {
612
612
  type: "button",
613
613
  class: "media-control-button",
614
614
  "aria-label": e.muted ? "Unmute video" : "Mute video",
615
615
  title: e.muted ? "Unmute" : "Mute",
616
- onClick: n[2] ||= (e) => c("toggleMute")
617
- }, [e.muted || e.volume === 0 ? (y(), i(T(Se), {
616
+ onClick: n[2] ||= (e) => i("toggleMute")
617
+ }, [e.muted || e.volume === 0 ? (b(), a(E(Ce), {
618
618
  key: 0,
619
619
  size: 18
620
- })) : (y(), i(T(xe), {
620
+ })) : (b(), a(E(Se), {
621
621
  key: 1,
622
622
  size: 18
623
- }))], 8, Ne), s("input", {
623
+ }))], 8, Pe), c("input", {
624
624
  class: "media-control-range media-control-volume",
625
625
  type: "range",
626
626
  min: "0",
627
627
  max: "1",
628
628
  step: "0.05",
629
629
  value: e.volume,
630
- style: g(_.value),
630
+ style: _(g.value),
631
631
  "aria-label": "Video volume",
632
632
  "aria-valuetext": `${Math.round(e.volume * 100)} percent`,
633
- onInput: n[3] ||= (e) => c("volumeChange", d(e))
634
- }, null, 44, Pe)]),
635
- s("output", Fe, w(u(p.value)) + " / " + w(u(f.value)), 1)
636
- ])) : a("", !0)], 34));
633
+ onInput: n[3] ||= (e) => i("volumeChange", d(e))
634
+ }, null, 44, Fe)]),
635
+ c("output", Ie, T(u(p.value)) + " / " + T(u(f.value)), 1)
636
+ ])) : o("", !0)], 34));
637
637
  }
638
- }), Le = [
638
+ }), Re = [
639
639
  "data-post-id",
640
640
  "data-media-index",
641
641
  "aria-hidden",
@@ -643,26 +643,27 @@ var Oe = /* @__PURE__ */ u({
643
643
  "inert",
644
644
  "role",
645
645
  "tabindex"
646
- ], Re = { class: "media-card-content" }, ze = ["data-media-direction"], Be = ["data-media-index"], Ve = {
646
+ ], ze = { class: "media-card-content" }, Be = ["data-media-direction"], Ve = ["data-media-index"], He = {
647
647
  key: 0,
648
648
  "data-test": "media-loading",
649
649
  class: "media-loading",
650
650
  "aria-hidden": "true"
651
- }, He = ["aria-label"], Ue = { class: "media-error-code" }, We = [
651
+ }, Ue = ["aria-label"], We = { class: "media-error-code" }, Ge = [
652
652
  "src",
653
653
  "width",
654
654
  "height",
655
655
  "loop",
656
656
  "muted",
657
657
  "preload"
658
- ], Ge = [
658
+ ], Ke = [
659
659
  "src",
660
660
  "width",
661
661
  "height",
662
662
  "fetchpriority"
663
- ], Ke = ["aria-label"], qe = ["aria-label"], Je = ["aria-label"], Ye = 40, Xe = 160, Ze = 24, Qe = /* @__PURE__ */ u({
663
+ ], qe = ["aria-label"], Je = ["aria-label"], Ye = ["aria-label"], Xe = 40, Ze = 160, Qe = 24, $e = /* @__PURE__ */ d({
664
664
  __name: "MediaCard",
665
665
  props: {
666
+ active: { type: Boolean },
666
667
  advanceOnMediaEnd: { type: Boolean },
667
668
  cardFooter: {},
668
669
  cardHeader: {},
@@ -679,6 +680,8 @@ var Oe = /* @__PURE__ */ u({
679
680
  mediaCard: {},
680
681
  mediaSource: {},
681
682
  previewState: {},
683
+ reelControlsTarget: {},
684
+ stationaryReelControls: { type: Boolean },
682
685
  total: {}
683
686
  },
684
687
  emits: [
@@ -688,120 +691,120 @@ var Oe = /* @__PURE__ */ u({
688
691
  "mediaChange",
689
692
  "ready"
690
693
  ],
691
- setup(e, { emit: r }) {
692
- let c = e, u = null, d = 0, f = !1, p = null, h = null, v = C("next"), b = r;
693
- function x(e = !1, t = "pointer") {
694
- e && b("activate", t);
694
+ setup(e, { emit: i }) {
695
+ let l = e, d = null, f = 0, p = !1, m = null, g = null, y = w("next"), x = i;
696
+ function S(e = !1, t = "pointer") {
697
+ e && x("activate", t);
695
698
  }
696
- let S = n(() => j(c.item)), E = n(() => M(c.item, c.mediaIndex)), D = n(() => N(c.item, E.value)), P = n(() => c.mediaSource === "original" ? D.value.src : D.value.preview.src), F = n(() => c.mediaSource === "original" ? D.value.width : D.value.preview.width), I = n(() => c.mediaSource === "original" ? D.value.height : D.value.preview.height), L = C(null), R = C(0), z = C(0), B = C(!0), V = C(!1), H = C(1), U = 1, W = n(() => c.interactive && !!(c.cardHeader || c.cardFooter));
699
+ 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(!0), H = w(!1), U = w(1), W = 1, G = r(() => l.interactive && !!(l.cardHeader || l.cardFooter));
697
700
  function ee(e) {
698
701
  return e.detail === 0 ? "keyboard" : "pointer";
699
702
  }
700
- function G(e, t) {
701
- let n = S.value.length, r = (e + n) % n;
702
- r !== E.value && (v.value = e < E.value ? "previous" : "next", b("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
703
+ function K(e, t) {
704
+ let n = C.value.length, r = (e + n) % n;
705
+ r !== D.value && (y.value = e < D.value ? "previous" : "next", x("mediaChange", r), t && t.detail > 0 && t.currentTarget?.blur());
703
706
  }
704
707
  function te(e, t, n) {
705
708
  return t === 1 ? e * 16 : t === 2 ? e * n : e;
706
709
  }
707
710
  function ne() {
708
- d = 0, f = !1, u !== null && clearTimeout(u), u = null;
711
+ f = 0, p = !1, d !== null && clearTimeout(d), d = null;
709
712
  }
710
713
  function re() {
711
- u !== null && clearTimeout(u), u = setTimeout(ne, Xe);
714
+ d !== null && clearTimeout(d), d = setTimeout(ne, Ze);
712
715
  }
713
- function K(e) {
714
- if (S.value.length <= 1) return;
716
+ function q(e) {
717
+ if (C.value.length <= 1) return;
715
718
  let t = e.currentTarget?.clientWidth || 1, n = te(e.deltaX, e.deltaMode, t);
716
- if (n === 0 || (e.preventDefault(), re(), f) || (d += n, Math.abs(d) < Ze)) return;
717
- let r = Math.sign(d);
718
- d = 0, f = !0, G(E.value + r);
719
+ if (n === 0 || (e.preventDefault(), re(), p) || (f += n, Math.abs(f) < Qe)) return;
720
+ let r = Math.sign(f);
721
+ f = 0, p = !0, K(D.value + r);
719
722
  }
720
- function q(e) {
723
+ function J(e) {
721
724
  let t = e.touches[0];
722
- c.layout !== "reel" || !t || (p = t.clientX, h = t.clientY);
725
+ l.layout !== "reel" || !t || (m = t.clientX, g = t.clientY);
723
726
  }
724
- function J(e) {
727
+ function ie(e) {
725
728
  let t = e.changedTouches[0];
726
- if (p === null || h === null || !t) return;
727
- let n = p - t.clientX, r = h - t.clientY;
728
- p = null, h = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Ye || G(E.value + Math.sign(n)));
729
+ if (m === null || g === null || !t) return;
730
+ let n = m - t.clientX, r = g - t.clientY;
731
+ m = null, g = null, !(Math.abs(n) <= Math.abs(r)) && (Math.abs(n) < Xe || K(D.value + Math.sign(n)));
729
732
  }
730
- let Y = n(() => De(P.value));
731
- function ie(e) {
732
- c.layout === "reel" && (e.stopPropagation(), ae());
733
+ let Y = r(() => Oe(F.value)), X = r(() => l.layout === "reel" && l.stationaryReelControls === !0), ae = r(() => Y.value && l.previewState === "ready" && (!X.value || !!(l.active && l.reelControlsTarget))), oe = r(() => `${l.item.postId}:${D.value}:${F.value}`);
734
+ function se(e) {
735
+ l.layout === "reel" && (e.stopPropagation(), ce());
733
736
  }
734
- async function ae() {
735
- if (L.value) {
736
- if (V.value) {
737
- L.value.pause();
737
+ async function ce() {
738
+ if (R.value) {
739
+ if (H.value) {
740
+ R.value.pause();
738
741
  return;
739
742
  }
740
743
  try {
741
- await L.value.play();
744
+ await R.value.play();
742
745
  } catch {
743
- V.value = !1;
746
+ H.value = !1;
744
747
  }
745
748
  }
746
749
  }
747
- function oe(e) {
750
+ function le(e) {
748
751
  return Number.isFinite(e) ? Math.max(0, e) : 0;
749
752
  }
750
- function X(e) {
751
- let t = e?.currentTarget ?? L.value;
752
- t && (R.value = oe(t.currentTime), z.value = oe(t.duration), B.value = t.muted, H.value = t.volume, t.volume > 0 && (U = t.volume));
753
- }
754
753
  function Z(e) {
755
- X(e), b("ready", E.value);
754
+ let t = e?.currentTarget ?? R.value;
755
+ t && (z.value = le(t.currentTime), B.value = le(t.duration), V.value = t.muted, U.value = t.volume, t.volume > 0 && (W = t.volume));
756
756
  }
757
- function se() {
758
- V.value = !1, b("ended", E.value);
757
+ function ue(e) {
758
+ Z(e), x("ready", D.value);
759
759
  }
760
- function ce(e) {
761
- let t = L.value;
762
- !t || !Number.isFinite(e) || (t.currentTime = Math.min(oe(t.duration), Math.max(0, e)), R.value = t.currentTime);
760
+ function de() {
761
+ H.value = !1, x("ended", D.value);
763
762
  }
764
- function le(e) {
765
- let t = L.value;
763
+ function fe(e) {
764
+ let t = R.value;
765
+ !t || !Number.isFinite(e) || (t.currentTime = Math.min(le(t.duration), Math.max(0, e)), z.value = t.currentTime);
766
+ }
767
+ function pe(e) {
768
+ let t = R.value;
766
769
  if (!t || !Number.isFinite(e)) return;
767
770
  let n = Math.min(1, Math.max(0, e));
768
- t.volume = n, t.muted = n === 0, n > 0 && (U = n), X();
771
+ t.volume = n, t.muted = n === 0, n > 0 && (W = n), Z();
769
772
  }
770
- function ue() {
771
- let e = L.value;
772
- e && (e.muted && e.volume === 0 && (e.volume = U), e.muted = !e.muted, X());
773
+ function me() {
774
+ let e = R.value;
775
+ e && (e.muted && e.volume === 0 && (e.volume = W), e.muted = !e.muted, Z());
773
776
  }
774
- return _(() => {
777
+ return v(() => {
775
778
  ne();
776
- }), (n, r) => (y(), o("article", {
779
+ }), (r, i) => (b(), s("article", {
777
780
  "data-post-id": e.item.postId,
778
- "data-media-index": E.value,
779
- class: m(["media-card", {
781
+ "data-media-index": D.value,
782
+ class: h(["media-card", {
780
783
  "media-card--entering": e.entering,
781
784
  "media-card--leaving": e.leaving,
782
785
  "media-card--error": e.previewState === "error",
783
786
  "media-card--transparent-chrome": e.mediaCard?.header?.background === "transparent" || e.mediaCard?.footer?.background === "transparent" || e.cardHeader?.background === "transparent" || e.cardFooter?.background === "transparent"
784
787
  }]),
785
- style: g(e.itemStyle),
788
+ style: _(e.itemStyle),
786
789
  "aria-hidden": e.leaving || void 0,
787
790
  "aria-busy": e.previewState === "loading",
788
791
  inert: e.leaving || void 0,
789
- role: e.interactive && !e.leaving && !W.value ? "button" : void 0,
790
- tabindex: e.interactive && !e.leaving && !W.value ? 0 : void 0,
791
- onClick: r[11] ||= (t) => x(e.interactive && !W.value, ee(t)),
792
- 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"])]
793
- }, [s("div", Re, [
794
- e.cardHeader ? (y(), i(Oe, {
792
+ role: e.interactive && !e.leaving && !G.value ? "button" : void 0,
793
+ tabindex: e.interactive && !e.leaving && !G.value ? 0 : void 0,
794
+ onClick: i[11] ||= (t) => S(e.interactive && !G.value, ee(t)),
795
+ onKeydown: [i[12] ||= A((t) => S(e.interactive && !G.value, "keyboard"), ["enter"]), i[13] ||= A(j((t) => S(e.interactive && !G.value, "keyboard"), ["prevent"]), ["space"])]
796
+ }, [c("div", ze, [
797
+ e.cardHeader ? (b(), a(ke, {
795
798
  key: 0,
796
799
  index: e.index,
797
800
  item: e.item,
798
801
  layout: e.layout,
799
802
  "loaded-count": e.loadedCount,
800
- "media-index": E.value,
803
+ "media-index": D.value,
801
804
  "media-source": e.mediaSource,
802
805
  placement: "header",
803
806
  region: e.cardHeader,
804
- style: g(e.mediaCard?.header),
807
+ style: _(e.mediaCard?.header),
805
808
  total: e.total
806
809
  }, null, 8, [
807
810
  "index",
@@ -813,122 +816,133 @@ var Oe = /* @__PURE__ */ u({
813
816
  "region",
814
817
  "style",
815
818
  "total"
816
- ])) : a("", !0),
817
- s("div", {
818
- class: m(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && S.value.length > 1 }]),
819
- "data-media-direction": v.value,
820
- onWheel: K,
821
- onTouchstartPassive: q,
822
- onTouchendPassive: J
819
+ ])) : o("", !0),
820
+ c("div", {
821
+ class: h(["media-card-media", { "media-card-media--carousel": e.layout === "reel" && C.value.length > 1 }]),
822
+ "data-media-direction": y.value,
823
+ onWheel: q,
824
+ onTouchstartPassive: J,
825
+ onTouchendPassive: ie
823
826
  }, [
824
- l(t, { name: `media-slide-${v.value}` }, {
825
- default: O(() => [(y(), o("div", {
826
- key: `${e.item.postId}:${D.value.src}:${e.mediaSource ?? "preview"}`,
827
+ u(n, { name: `media-slide-${y.value}` }, {
828
+ default: k(() => [(b(), s("div", {
829
+ key: `${e.item.postId}:${O.value.src}:${e.mediaSource ?? "preview"}`,
827
830
  class: "media-card-frame",
828
- "data-media-index": E.value
829
- }, [e.previewState === "loading" ? (y(), o("div", Ve, [...r[14] ||= [s("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (y(), o("div", {
831
+ "data-media-index": D.value
832
+ }, [e.previewState === "loading" ? (b(), s("div", He, [...i[14] ||= [c("span", { class: "media-loading-shimmer" }, null, -1)]])) : e.previewState === "error" ? (b(), s("div", {
830
833
  key: 1,
831
834
  "data-test": "media-error",
832
835
  class: "media-error",
833
836
  role: "img",
834
- "aria-label": `${T(we)(P.value)} ${T(Te)(P.value)}`
835
- }, [s("strong", Ue, w(T(we)(P.value)), 1), s("span", null, w(T(Te)(P.value)), 1)], 8, He)) : a("", !0), Y.value ? (y(), o("video", {
837
+ "aria-label": `${E(Te)(F.value)} ${E(Ee)(F.value)}`
838
+ }, [c("strong", We, T(E(Te)(F.value)), 1), c("span", null, T(E(Ee)(F.value)), 1)], 8, Ue)) : o("", !0), Y.value ? (b(), s("video", {
836
839
  key: 2,
837
840
  ref_key: "videoElement",
838
- ref: L,
839
- class: m(["media-preview", {
841
+ ref: R,
842
+ class: h(["media-preview", {
840
843
  "media-preview--ready": e.previewState === "ready",
841
844
  "media-preview--reel-video": e.layout === "reel"
842
845
  }]),
843
- src: P.value,
844
- width: F.value ?? void 0,
845
- height: I.value ?? void 0,
846
+ src: F.value,
847
+ width: I.value ?? void 0,
848
+ height: L.value ?? void 0,
846
849
  autoplay: "",
847
850
  loop: !e.advanceOnMediaEnd,
848
- muted: B.value,
851
+ muted: V.value,
849
852
  playsinline: "",
850
853
  preload: e.fetchPriority === "high" ? "auto" : "metadata",
851
- onLoadedmetadata: Z,
852
- onDurationchange: X,
853
- onTimeupdate: X,
854
- onVolumechange: X,
855
- onPlaying: r[0] ||= (e) => V.value = !0,
856
- onPause: r[1] ||= (e) => V.value = !1,
857
- onEnded: se,
858
- onClick: ie,
859
- onError: r[2] ||= (e) => n.$emit("error", E.value)
860
- }, null, 42, We)) : (y(), o("img", {
854
+ onLoadedmetadata: ue,
855
+ onDurationchange: Z,
856
+ onTimeupdate: Z,
857
+ onVolumechange: Z,
858
+ onPlaying: i[0] ||= (e) => H.value = !0,
859
+ onPause: i[1] ||= (e) => H.value = !1,
860
+ onEnded: de,
861
+ onClick: se,
862
+ onError: i[2] ||= (e) => r.$emit("error", D.value)
863
+ }, null, 42, Ge)) : (b(), s("img", {
861
864
  key: 3,
862
- class: m(["media-preview", { "media-preview--ready": e.previewState === "ready" }]),
863
- src: P.value,
864
- width: F.value ?? void 0,
865
- height: I.value ?? void 0,
865
+ class: h(["media-preview", { "media-preview--ready": e.previewState === "ready" }]),
866
+ src: F.value,
867
+ width: I.value ?? void 0,
868
+ height: L.value ?? void 0,
866
869
  fetchpriority: e.fetchPriority,
867
870
  alt: "",
868
871
  decoding: "async",
869
872
  loading: "eager",
870
- onLoad: r[3] ||= (e) => n.$emit("ready", E.value),
871
- onError: r[4] ||= (e) => n.$emit("error", E.value)
872
- }, null, 42, Ge))], 8, Be))]),
873
+ onLoad: i[3] ||= (e) => r.$emit("ready", D.value),
874
+ onError: i[4] ||= (e) => r.$emit("error", D.value)
875
+ }, null, 42, Ke))], 8, Ve))]),
873
876
  _: 1
874
877
  }, 8, ["name"]),
875
- Y.value && e.previewState === "ready" ? (y(), i(Ie, {
878
+ (b(), a(t, {
879
+ disabled: !X.value || !e.reelControlsTarget,
880
+ to: e.reelControlsTarget ?? "body"
881
+ }, [u(n, {
882
+ name: "vibe-reel-media-controls",
883
+ css: X.value
884
+ }, {
885
+ default: k(() => [ae.value ? (b(), a(Le, {
886
+ key: oe.value,
887
+ "current-time": z.value,
888
+ "data-control-post-id": X.value ? e.item.postId : void 0,
889
+ duration: B.value,
890
+ layout: e.layout,
891
+ muted: V.value,
892
+ playing: H.value,
893
+ volume: U.value,
894
+ onSeek: fe,
895
+ onToggleMute: me,
896
+ onTogglePlayback: ce,
897
+ onVolumeChange: pe
898
+ }, null, 8, [
899
+ "current-time",
900
+ "data-control-post-id",
901
+ "duration",
902
+ "layout",
903
+ "muted",
904
+ "playing",
905
+ "volume"
906
+ ])) : o("", !0)]),
907
+ _: 1
908
+ }, 8, ["css"])], 8, ["disabled", "to"])),
909
+ C.value.length > 1 ? (b(), s("div", {
876
910
  key: 0,
877
- "current-time": R.value,
878
- duration: z.value,
879
- layout: e.layout,
880
- muted: B.value,
881
- playing: V.value,
882
- volume: H.value,
883
- onSeek: ce,
884
- onToggleMute: ue,
885
- onTogglePlayback: ae,
886
- onVolumeChange: le
887
- }, null, 8, [
888
- "current-time",
889
- "duration",
890
- "layout",
891
- "muted",
892
- "playing",
893
- "volume"
894
- ])) : a("", !0),
895
- S.value.length > 1 ? (y(), o("div", {
896
- key: 1,
897
- class: m(["media-carousel-controls", { "media-carousel-controls--persistent": e.layout === "reel" }]),
911
+ class: h(["media-carousel-controls", { "media-carousel-controls--persistent": e.layout === "reel" }]),
898
912
  "aria-label": "Media navigation"
899
- }, [s("button", {
913
+ }, [c("button", {
900
914
  type: "button",
901
915
  class: "media-carousel-control media-carousel-control--previous",
902
916
  "aria-label": `Previous media for post ${e.item.postId}`,
903
- onClick: r[5] ||= A((e) => G(E.value - 1, e), ["stop"]),
904
- onKeydown: r[6] ||= A(() => {}, ["stop"])
905
- }, [l(T(_e), { size: 20 })], 40, Ke), s("button", {
917
+ onClick: i[5] ||= j((e) => K(D.value - 1, e), ["stop"]),
918
+ onKeydown: i[6] ||= j(() => {}, ["stop"])
919
+ }, [u(E(ve), { size: 20 })], 40, qe), c("button", {
906
920
  type: "button",
907
921
  class: "media-carousel-control media-carousel-control--next",
908
922
  "aria-label": `Next media for post ${e.item.postId}`,
909
- onClick: r[7] ||= A((e) => G(E.value + 1, e), ["stop"]),
910
- onKeydown: r[8] ||= A(() => {}, ["stop"])
911
- }, [l(T(ve), { size: 20 })], 40, qe)], 2)) : a("", !0),
912
- W.value ? (y(), o("button", {
913
- key: 2,
923
+ onClick: i[7] ||= j((e) => K(D.value + 1, e), ["stop"]),
924
+ onKeydown: i[8] ||= j(() => {}, ["stop"])
925
+ }, [u(E(ye), { size: 20 })], 40, Je)], 2)) : o("", !0),
926
+ G.value ? (b(), s("button", {
927
+ key: 1,
914
928
  class: "media-card-activator",
915
929
  type: "button",
916
930
  "aria-label": `Open post ${e.item.postId}`,
917
- onClick: r[9] ||= A((e) => n.$emit("activate", ee(e)), ["stop"]),
918
- onKeydown: r[10] ||= A(() => {}, ["stop"])
919
- }, null, 40, Je)) : a("", !0)
920
- ], 42, ze),
921
- e.cardFooter ? (y(), i(Oe, {
931
+ onClick: i[9] ||= j((e) => r.$emit("activate", ee(e)), ["stop"]),
932
+ onKeydown: i[10] ||= j(() => {}, ["stop"])
933
+ }, null, 40, Ye)) : o("", !0)
934
+ ], 42, Be),
935
+ e.cardFooter ? (b(), a(ke, {
922
936
  key: 1,
923
937
  index: e.index,
924
938
  item: e.item,
925
939
  layout: e.layout,
926
940
  "loaded-count": e.loadedCount,
927
- "media-index": E.value,
941
+ "media-index": D.value,
928
942
  "media-source": e.mediaSource,
929
943
  placement: "footer",
930
944
  region: e.cardFooter,
931
- style: g(e.mediaCard?.footer),
945
+ style: _(e.mediaCard?.footer),
932
946
  total: e.total
933
947
  }, null, 8, [
934
948
  "index",
@@ -940,10 +954,10 @@ var Oe = /* @__PURE__ */ u({
940
954
  "region",
941
955
  "style",
942
956
  "total"
943
- ])) : a("", !0)
944
- ])], 46, Le));
957
+ ])) : o("", !0)
958
+ ])], 46, Re));
945
959
  }
946
- }), $e = { class: "masonry-feed-shell" }, et = ["aria-hidden", "inert"], tt = 240, nt = 6, rt = 12, it = 800, at = 1.5, ot = /* @__PURE__ */ u({
960
+ }), et = { class: "masonry-feed-shell" }, tt = ["aria-hidden", "inert"], nt = 240, rt = 6, it = 12, at = 800, ot = 1.5, st = /* @__PURE__ */ d({
947
961
  __name: "MasonryFeed",
948
962
  props: {
949
963
  enteringPostIds: {},
@@ -976,58 +990,58 @@ var Oe = /* @__PURE__ */ u({
976
990
  "ready",
977
991
  "retryEnd"
978
992
  ],
979
- setup(t, { expose: r, emit: a }) {
980
- let c = t, u = a, d = C(null), f = `vibe-masonry-${E()}`, p = C(null), h = C(0), v = C(nt), b = C(0), S = C(0), w = C(0), O = null, k = null, A = null, j = n(() => q(c.items, h.value, {
981
- additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
982
- gap: v.value,
983
- minColumnWidth: tt
984
- })), M = n(() => {
993
+ setup(t, { expose: n, emit: i }) {
994
+ let o = t, l = i, d = w(null), f = `vibe-masonry-${D()}`, p = w(null), m = w(0), g = w(rt), y = w(0), x = w(0), C = w(0), T = null, k = null, A = null, j = r(() => J(o.items, m.value, {
995
+ additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
996
+ gap: g.value,
997
+ minColumnWidth: nt
998
+ })), M = r(() => {
985
999
  let e = j.value;
986
- if (c.leavingPostIds.size === 0) return e;
987
- let t = c.items.filter((e) => !c.leavingPostIds.has(e.postId)), n = q(t, h.value, {
988
- additionalHeight: (c.cardHeader?.height ?? 0) + (c.cardFooter?.height ?? 0),
989
- gap: v.value,
990
- minColumnWidth: tt
1000
+ if (o.leavingPostIds.size === 0) return e;
1001
+ let t = o.items.filter((e) => !o.leavingPostIds.has(e.postId)), n = J(t, m.value, {
1002
+ additionalHeight: (o.cardHeader?.height ?? 0) + (o.cardFooter?.height ?? 0),
1003
+ gap: g.value,
1004
+ minColumnWidth: nt
991
1005
  }), r = new Map(t.map((e, t) => [e.postId, n.items[t]]));
992
1006
  return {
993
1007
  ...n,
994
- items: c.items.map((t, n) => c.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
1008
+ items: o.items.map((t, n) => o.leavingPostIds.has(t.postId) ? e.items[n] : r.get(t.postId) ?? e.items[n])
995
1009
  };
996
- }), N = n(() => ({ height: `${c.leavingPostIds.size === 0 ? M.value.height : j.value.height}px` })), F = n(() => {
997
- let e = Math.max(it, S.value * at), t = {
998
- scrollTop: b.value - w.value,
999
- viewportHeight: S.value
1000
- }, n = K(M.value.items, {
1010
+ }), N = r(() => ({ height: `${o.leavingPostIds.size === 0 ? M.value.height : j.value.height}px` })), P = r(() => {
1011
+ let e = Math.max(at, x.value * ot), t = {
1012
+ scrollTop: y.value - C.value,
1013
+ viewportHeight: x.value
1014
+ }, n = q(M.value.items, {
1001
1015
  ...t,
1002
1016
  overscan: e
1003
- }), r = c.leavingPostIds.size === 0 ? [] : K(j.value.items, {
1017
+ }), r = o.leavingPostIds.size === 0 ? [] : q(j.value.items, {
1004
1018
  ...t,
1005
1019
  overscan: e
1006
- }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = K(M.value.items, {
1020
+ }), i = [...new Set([...n, ...r])].sort((e, t) => e - t), a = q(M.value.items, {
1007
1021
  ...t,
1008
1022
  overscan: 0
1009
- }), o = c.leavingPostIds.size === 0 ? [] : K(j.value.items, {
1023
+ }), s = o.leavingPostIds.size === 0 ? [] : q(j.value.items, {
1010
1024
  ...t,
1011
1025
  overscan: 0
1012
- }), s = new Set([...a, ...o]);
1026
+ }), c = new Set([...a, ...s]);
1013
1027
  return i.flatMap((e) => {
1014
- let t = c.items[e];
1028
+ let t = o.items[e];
1015
1029
  return t ? [{
1016
- fetchPriority: s.has(e) ? "high" : "low",
1030
+ fetchPriority: c.has(e) ? "high" : "low",
1017
1031
  index: e,
1018
1032
  item: t
1019
1033
  }] : [];
1020
1034
  });
1021
1035
  });
1022
1036
  function I(e) {
1023
- let t = M.value.items[e], n = c.items[e]?.postId;
1037
+ let t = M.value.items[e], n = o.items[e]?.postId;
1024
1038
  if (!t) return {};
1025
- let r = n !== void 0 && c.enteringPostIds.has(n), i = n !== void 0 && c.leavingPostIds.has(n), a = r || i ? re({
1039
+ let r = n !== void 0 && o.enteringPostIds.has(n), i = n !== void 0 && o.leavingPostIds.has(n), a = r || i ? re({
1026
1040
  containerHeight: j.value.height,
1027
- gap: v.value
1028
- }) : 0, o = n === void 0 ? 0 : i ? c.removalDelays.get(n) ?? 0 : r ? c.entryDelays.get(n) ?? 0 : 0;
1041
+ gap: g.value
1042
+ }) : 0, s = n === void 0 ? 0 : i ? o.removalDelays.get(n) ?? 0 : r ? o.entryDelays.get(n) ?? 0 : 0;
1029
1043
  return {
1030
- "--masonry-entry-delay": `${o}ms`,
1044
+ "--masonry-entry-delay": `${s}ms`,
1031
1045
  width: `${t.width}px`,
1032
1046
  height: `${t.height}px`,
1033
1047
  transform: `translate3d(${t.x}px, ${t.y + a}px, 0)`
@@ -1036,55 +1050,55 @@ var Oe = /* @__PURE__ */ u({
1036
1050
  function L() {
1037
1051
  let e = d.value;
1038
1052
  if (!e) return;
1039
- b.value = e.scrollTop, S.value = e.clientHeight;
1053
+ y.value = e.scrollTop, x.value = e.clientHeight;
1040
1054
  let t = p.value;
1041
- t && (w.value = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop);
1055
+ t && (C.value = t.getBoundingClientRect().top - e.getBoundingClientRect().top + e.scrollTop);
1042
1056
  }
1043
1057
  function R(e) {
1044
1058
  let t = e.ownerDocument.documentElement.clientWidth;
1045
- h.value = e.clientWidth, v.value = Math.min(rt, Math.max(nt, t * .0075)), L();
1059
+ m.value = e.clientWidth, g.value = Math.min(it, Math.max(rt, t * .0075)), L();
1046
1060
  }
1047
1061
  function z(e) {
1048
1062
  let t = e.currentTarget;
1049
- t && (b.value = t.scrollTop, !c.loadMoreLocked && c.infiniteScroll && G(t) && u("loadMore"));
1063
+ t && (y.value = t.scrollTop, !o.loadMoreLocked && o.infiniteScroll && K(t) && l("loadMore"));
1050
1064
  }
1051
1065
  function B() {
1052
1066
  let e = d.value;
1053
- !c.loadMoreLocked && e && G(e) && u("loadMore");
1067
+ !o.loadMoreLocked && e && K(e) && l("loadMore");
1054
1068
  }
1055
1069
  function V() {
1056
1070
  return d.value;
1057
1071
  }
1058
- return D(p, (e) => {
1059
- O?.disconnect(), O = null, A !== null && cancelAnimationFrame(A), e && (R(e), !(typeof ResizeObserver > "u") && (O = new ResizeObserver(([t]) => {
1072
+ return O(p, (e) => {
1073
+ T?.disconnect(), T = null, A !== null && cancelAnimationFrame(A), e && (R(e), !(typeof ResizeObserver > "u") && (T = new ResizeObserver(([t]) => {
1060
1074
  let n = t?.contentRect.width ?? e.clientWidth;
1061
- Math.abs(n - h.value) < .5 || (A = requestAnimationFrame(() => {
1075
+ Math.abs(n - m.value) < .5 || (A = requestAnimationFrame(() => {
1062
1076
  A = null, R(e);
1063
1077
  }));
1064
- }), O.observe(e)));
1065
- }), D(d, (e) => {
1078
+ }), T.observe(e)));
1079
+ }), O(d, (e) => {
1066
1080
  k?.disconnect(), k = null, e && (L(), !(typeof ResizeObserver > "u") && (k = new ResizeObserver(L), k.observe(e)));
1067
- }), _(() => {
1068
- O?.disconnect(), k?.disconnect(), A !== null && cancelAnimationFrame(A);
1069
- }), r({
1081
+ }), v(() => {
1082
+ T?.disconnect(), k?.disconnect(), A !== null && cancelAnimationFrame(A);
1083
+ }), n({
1070
1084
  getScrollElement: V,
1071
1085
  loadIfNearBottom: B
1072
- }), (n, r) => (y(), o("div", $e, [s("main", {
1086
+ }), (n, r) => (b(), s("div", et, [c("main", {
1073
1087
  id: f,
1074
1088
  ref_key: "galleryElement",
1075
1089
  ref: d,
1076
- class: m(["gallery-shell masonry-feed", { "masonry-feed--suspended": t.suspended }]),
1090
+ class: h(["gallery-shell masonry-feed", { "masonry-feed--suspended": t.suspended }]),
1077
1091
  "data-layout-mode": "masonry",
1078
1092
  "aria-hidden": t.suspended || void 0,
1079
1093
  inert: t.suspended || void 0,
1080
1094
  onScrollPassive: z
1081
- }, [s("section", {
1095
+ }, [c("section", {
1082
1096
  ref_key: "masonryElement",
1083
1097
  ref: p,
1084
- class: m(["masonry", { "masonry--ready": h.value > 0 }]),
1085
- style: g(N.value),
1098
+ class: h(["masonry", { "masonry--ready": m.value > 0 }]),
1099
+ style: _(N.value),
1086
1100
  "aria-label": "Media gallery"
1087
- }, [(y(!0), o(e, null, x(F.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i(Qe, {
1101
+ }, [(b(!0), s(e, null, S(P.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a($e, {
1088
1102
  key: n.postId,
1089
1103
  class: "masonry-item",
1090
1104
  entering: t.enteringPostIds.has(n.postId),
@@ -1100,12 +1114,12 @@ var Oe = /* @__PURE__ */ u({
1100
1114
  layout: "masonry",
1101
1115
  "loaded-count": t.items.length,
1102
1116
  "media-index": t.mediaIndices.get(n.postId) ?? 0,
1103
- "preview-state": t.previewStates.get(T(P)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1117
+ "preview-state": t.previewStates.get(E(F)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1104
1118
  total: t.total,
1105
- onActivate: (e) => u("activate", n.postId, e),
1106
- onMediaChange: (e) => u("mediaChange", n.postId, e),
1107
- onReady: (e) => u("ready", n.postId, e),
1108
- onError: (e) => u("error", n.postId, e)
1119
+ onActivate: (e) => l("activate", n.postId, e),
1120
+ onMediaChange: (e) => l("mediaChange", n.postId, e),
1121
+ onReady: (e) => l("ready", n.postId, e),
1122
+ onError: (e) => l("error", n.postId, e)
1109
1123
  }, null, 8, [
1110
1124
  "entering",
1111
1125
  "leaving",
@@ -1124,7 +1138,7 @@ var Oe = /* @__PURE__ */ u({
1124
1138
  "onMediaChange",
1125
1139
  "onReady",
1126
1140
  "onError"
1127
- ]))), 128))], 6), l(H, {
1141
+ ]))), 128))], 6), u(U, {
1128
1142
  actions: t.feedFooterActions,
1129
1143
  "can-retry-end": t.canRetryEnd,
1130
1144
  "feed-footer": t.feedFooter,
@@ -1133,8 +1147,8 @@ var Oe = /* @__PURE__ */ u({
1133
1147
  "is-loading": t.isLoadingMore,
1134
1148
  "load-more-locked": t.loadMoreLocked,
1135
1149
  state: t.state,
1136
- onLoadMore: r[0] ||= (e) => u("loadMore"),
1137
- onRetryEnd: r[1] ||= (e) => u("retryEnd")
1150
+ onLoadMore: r[0] ||= (e) => l("loadMore"),
1151
+ onRetryEnd: r[1] ||= (e) => l("retryEnd")
1138
1152
  }, null, 8, [
1139
1153
  "actions",
1140
1154
  "can-retry-end",
@@ -1144,7 +1158,7 @@ var Oe = /* @__PURE__ */ u({
1144
1158
  "is-loading",
1145
1159
  "load-more-locked",
1146
1160
  "state"
1147
- ])], 42, et), l(se, {
1161
+ ])], 42, tt), u(le, {
1148
1162
  "content-size": M.value.height,
1149
1163
  "controls-id": f,
1150
1164
  "scroll-element": d.value,
@@ -1155,8 +1169,8 @@ var Oe = /* @__PURE__ */ u({
1155
1169
  "suspended"
1156
1170
  ])]));
1157
1171
  }
1158
- }), st = 300;
1159
- function ct(e, t, n) {
1172
+ }), ct = 300;
1173
+ function lt(e, t, n) {
1160
1174
  let r = e.scrollTop;
1161
1175
  if (n || Math.abs(r - t) <= 1) return e.scrollTop = t, Promise.resolve();
1162
1176
  e.setAttribute("data-transitioning", "");
@@ -1164,7 +1178,7 @@ function ct(e, t, n) {
1164
1178
  return new Promise((n) => {
1165
1179
  let o = (s) => {
1166
1180
  a += 1;
1167
- let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / st), u = 1 - (1 - l) ** 3;
1181
+ let c = Math.max(s - i, 1e3 / 60 * a), l = Math.min(1, c / ct), u = 1 - (1 - l) ** 3;
1168
1182
  if (e.scrollTop = r + (t - r) * u, l < 1) {
1169
1183
  requestAnimationFrame(o);
1170
1184
  return;
@@ -1176,7 +1190,7 @@ function ct(e, t, n) {
1176
1190
  }
1177
1191
  //#endregion
1178
1192
  //#region src/components/ReelAutoAdvanceProgress.vue?vue&type=script&setup=true&lang.ts
1179
- var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1193
+ var ut = ["aria-label"], dt = /* @__PURE__ */ d({
1180
1194
  __name: "ReelAutoAdvanceProgress",
1181
1195
  props: {
1182
1196
  durationMs: {},
@@ -1184,19 +1198,19 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1184
1198
  },
1185
1199
  emits: ["complete"],
1186
1200
  setup(e, { emit: t }) {
1187
- let r = e, i = t, a = n(() => ({ "--vibe-reel-auto-advance-duration": `${r.durationMs}ms` }));
1188
- return (t, n) => (y(), o("div", {
1201
+ let n = e, i = t, a = r(() => ({ "--vibe-reel-auto-advance-duration": `${n.durationMs}ms` }));
1202
+ return (t, n) => (b(), s("div", {
1189
1203
  class: "reel-auto-advance",
1190
1204
  "data-test": "reel-auto-advance",
1191
1205
  role: "timer",
1192
1206
  "aria-label": e.label
1193
- }, [s("span", {
1207
+ }, [c("span", {
1194
1208
  class: "reel-auto-advance-progress",
1195
- style: g(a.value),
1209
+ style: _(a.value),
1196
1210
  onAnimationend: n[0] ||= (e) => i("complete")
1197
- }, null, 36)], 8, lt));
1211
+ }, null, 36)], 8, ut));
1198
1212
  }
1199
- }), dt = ["data-active-post-id", "data-active-media-index"], ft = ["role", "data-status"], pt = 2, mt = 300, ht = /* @__PURE__ */ u({
1213
+ }), ft = { class: "reel-viewport" }, pt = ["data-active-post-id", "data-active-media-index"], mt = ["role", "data-status"], ht = 2, gt = 300, _t = /* @__PURE__ */ d({
1200
1214
  __name: "ReelFeed",
1201
1215
  props: {
1202
1216
  initialPostId: {},
@@ -1232,159 +1246,161 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1232
1246
  "retryEnd",
1233
1247
  "retryForward"
1234
1248
  ],
1235
- setup(t, { expose: r, emit: c }) {
1236
- let l = t, u = c, d = C(null), f = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId), h = C(Math.max(0, f)), b = C(!1), S = 0, E = null, O = null, k = null, A = n(() => ({ gridTemplateRows: `repeat(${l.items.length}, 100cqh)` })), M = n(() => {
1237
- let e = Math.max(0, h.value - pt), t = Math.min(l.items.length - 1, h.value + pt);
1249
+ setup(t, { expose: n, emit: i }) {
1250
+ 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(() => {
1251
+ let e = Math.max(0, g.value - ht), t = Math.min(l.items.length - 1, g.value + ht);
1238
1252
  return l.items.slice(e, t + 1).map((t, n) => ({
1239
- fetchPriority: e + n === h.value ? "high" : "low",
1253
+ fetchPriority: e + n === g.value ? "high" : "low",
1240
1254
  index: e + n,
1241
1255
  item: t
1242
1256
  }));
1243
- }), F = n(() => l.items[h.value]?.postId), I = n(() => l.items[h.value]), L = n(() => {
1244
- let e = F.value;
1257
+ }), L = r(() => l.items[g.value]?.postId), R = r(() => l.items[g.value]), z = r(() => {
1258
+ let e = L.value;
1245
1259
  return e === void 0 ? 0 : l.mediaIndices.get(e) ?? 0;
1246
- }), R = n(() => {
1247
- let e = F.value;
1248
- return e === void 0 ? "loading" : l.previewStates.get(P(e, L.value)) ?? "loading";
1249
- }), z = n(() => {
1250
- let e = I.value;
1260
+ }), B = r(() => {
1261
+ let e = L.value;
1262
+ return e === void 0 ? "loading" : l.previewStates.get(F(e, z.value)) ?? "loading";
1263
+ }), V = r(() => {
1264
+ let e = R.value;
1251
1265
  if (!e) return "";
1252
- let t = N(e, L.value);
1266
+ let t = P(e, z.value);
1253
1267
  return l.mediaSource === "original" ? t.src : t.preview.src;
1254
- }), B = n(() => R.value === "ready" && De(z.value)), V = n(() => [
1255
- F.value,
1268
+ }), H = r(() => B.value === "ready" && Oe(V.value)), W = r(() => [
1256
1269
  L.value,
1270
+ z.value,
1257
1271
  l.items.length,
1258
1272
  l.loadMoreLocked,
1259
1273
  l.reelAutoAdvance.enabled,
1260
1274
  l.reelAutoAdvance.includePostItems,
1261
1275
  l.reelAutoAdvance.intervalMs
1262
- ].join(":")), U = n(() => {
1263
- let e = I.value, t = !!(e && l.reelAutoAdvance.includePostItems && L.value < j(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
1276
+ ].join(":")), G = r(() => {
1277
+ let e = R.value, t = !!(e && l.reelAutoAdvance.includePostItems && z.value < M(e).length - 1), n = l.reelAutoAdvance.intervalMs / 1e3;
1264
1278
  return `Auto advance to the next ${t ? "post item" : "post"} in ${n}s`;
1265
- }), W = n(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && I.value !== void 0 && R.value !== "loading" && !B.value), ee = n(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1266
- function te(e) {
1279
+ }), ee = r(() => l.reelAutoAdvance.enabled && l.reelForward.status === "idle" && R.value !== void 0 && B.value !== "loading" && !H.value), te = r(() => l.reelForward.status === "loading" ? "Loading the next media…" : l.reelForward.status === "error" ? "Unable to load the next media." : "You reached the end of this feed.");
1280
+ function ne(e) {
1267
1281
  return { gridRow: `${e + 1}` };
1268
1282
  }
1269
- function ne(e) {
1270
- let t = S || e.clientHeight;
1283
+ function re(e) {
1284
+ let t = D || e.clientHeight;
1271
1285
  return t <= 0 || l.items.length === 0 ? 0 : Math.min(l.items.length - 1, Math.max(0, Math.round(e.scrollTop / t)));
1272
1286
  }
1273
- function re(e) {
1287
+ function q(e) {
1274
1288
  let t = e.currentTarget;
1275
- t && (b.value || (h.value = ne(t)), !l.loadMoreLocked && l.infiniteScroll && G(t) && u("loadMore"));
1289
+ if (!t) return;
1290
+ let n = D || t.clientHeight, r = Math.max(0, l.items.length - 1) * n;
1291
+ x.value = l.items.length > 0 && t.scrollTop > r + 1, C.value || (g.value = re(t)), !l.loadMoreLocked && l.infiniteScroll && K(t) && u("loadMore");
1276
1292
  }
1277
- function K() {
1293
+ function J() {
1278
1294
  let e = d.value;
1279
- e && (Y(!0), S = e.clientHeight, e.scrollTop = h.value * S, O !== null && cancelAnimationFrame(O), O = requestAnimationFrame(() => {
1280
- e.scrollTop = h.value * e.clientHeight, S = e.clientHeight, O = null;
1281
- }), q());
1295
+ e && (x.value = !1, X(!0), D = e.clientHeight, e.scrollTop = g.value * D, A !== null && cancelAnimationFrame(A), A = requestAnimationFrame(() => {
1296
+ e.scrollTop = g.value * e.clientHeight, D = e.clientHeight, A = null;
1297
+ }), ie());
1282
1298
  }
1283
- function q() {
1284
- k !== null && clearTimeout(k), k = setTimeout(() => {
1285
- k = null;
1299
+ function ie() {
1300
+ j !== null && clearTimeout(j), j = setTimeout(() => {
1301
+ j = null;
1286
1302
  let e = d.value;
1287
- e && (S = e.clientHeight, e.scrollTop = h.value * S), Y(!1);
1303
+ e && (D = e.clientHeight, e.scrollTop = g.value * D), X(!1);
1288
1304
  }, 120);
1289
1305
  }
1290
- function J() {
1291
- Y(!0);
1306
+ function Y() {
1307
+ X(!0);
1292
1308
  let e = d.value;
1293
- e && (S = e.clientHeight, e.scrollTop = h.value * S), q();
1309
+ e && (D = e.clientHeight, e.scrollTop = g.value * D), ie();
1294
1310
  }
1295
- function Y(e) {
1296
- b.value = e, d.value?.toggleAttribute("data-resizing", e);
1311
+ function X(e) {
1312
+ C.value = e, d.value?.toggleAttribute("data-resizing", e);
1297
1313
  }
1298
- function ie() {
1314
+ function ae() {
1299
1315
  let e = d.value;
1300
- !l.loadMoreLocked && e && G(e) && u("loadMore");
1316
+ !l.loadMoreLocked && e && K(e) && u("loadMore");
1301
1317
  }
1302
- function ae(e) {
1303
- let t = I.value;
1318
+ function oe(e) {
1319
+ let t = R.value;
1304
1320
  if (!t) return !1;
1305
- let n = j(t).length;
1321
+ let n = M(t).length;
1306
1322
  if (n <= 1) return !1;
1307
- let r = (L.value + e + n) % n;
1323
+ let r = (z.value + e + n) % n;
1308
1324
  return u("mediaChange", t.postId, r), !0;
1309
1325
  }
1310
- function oe(e) {
1311
- let t = h.value + e;
1312
- return !d.value || t < 0 || t >= l.items.length ? !1 : (se(t), !0);
1326
+ function se(e) {
1327
+ let t = g.value + e;
1328
+ return !d.value || t < 0 || t >= l.items.length ? !1 : (Z(t), !0);
1313
1329
  }
1314
- function X() {
1330
+ function ce() {
1315
1331
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1316
1332
  }
1317
- function Z(e) {
1333
+ function le(e) {
1318
1334
  let t = d.value;
1319
1335
  if (!t) return Promise.resolve();
1320
- let n = e * (S || t.clientHeight);
1321
- return h.value = e, ct(t, n, X());
1336
+ let n = e * (D || t.clientHeight);
1337
+ return g.value = e, lt(t, n, ce());
1322
1338
  }
1323
- function se(e) {
1324
- Z(e);
1339
+ function Z(e) {
1340
+ le(e);
1325
1341
  }
1326
- async function ce(e) {
1342
+ async function ue(e) {
1327
1343
  let t = l.items.findIndex((t) => t.postId === e);
1328
- return t < 0 || t === h.value ? !1 : (await Z(t), !0);
1344
+ return t < 0 || t === g.value ? !1 : (await le(t), !0);
1329
1345
  }
1330
- async function le(e) {
1331
- return ae(e) ? (X() || await new Promise((e) => setTimeout(e, mt)), !0) : !1;
1346
+ async function de(e) {
1347
+ return oe(e) ? (ce() || await new Promise((e) => setTimeout(e, gt)), !0) : !1;
1332
1348
  }
1333
- function ue() {
1349
+ function fe() {
1334
1350
  if (!l.reelAutoAdvance.enabled) return;
1335
- let e = I.value;
1351
+ let e = R.value;
1336
1352
  if (!e) return;
1337
- if (l.reelAutoAdvance.includePostItems && L.value < j(e).length - 1) {
1338
- u("mediaChange", e.postId, L.value + 1);
1353
+ if (l.reelAutoAdvance.includePostItems && z.value < M(e).length - 1) {
1354
+ u("mediaChange", e.postId, z.value + 1);
1339
1355
  return;
1340
1356
  }
1341
- let t = h.value + 1, n = l.items[t];
1357
+ let t = g.value + 1, n = l.items[t];
1342
1358
  if (!n) {
1343
1359
  l.hasNext && !l.loadMoreLocked && u("loadMore");
1344
1360
  return;
1345
1361
  }
1346
- l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), se(t);
1362
+ l.reelAutoAdvance.includePostItems && (l.mediaIndices.get(n.postId) ?? 0) !== 0 && u("mediaChange", n.postId, 0), Z(t);
1347
1363
  }
1348
- function de(e, t) {
1349
- !l.reelAutoAdvance.enabled || e !== F.value || t !== L.value || !B.value || ue();
1364
+ function pe(e, t) {
1365
+ !l.reelAutoAdvance.enabled || e !== L.value || t !== z.value || !H.value || fe();
1350
1366
  }
1351
- return D(d, (e) => {
1352
- E?.disconnect(), E = null, e && (S = e.clientHeight, !(typeof ResizeObserver > "u") && (E = new ResizeObserver(K), E.observe(e)));
1353
- }), D([() => l.items.length, () => l.initialPostId], async ([e, t]) => {
1354
- let n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1355
- h.value = n >= 0 ? n : Math.min(h.value, Math.max(0, e - 1)), await p(), K();
1356
- }), D(F, (e) => {
1367
+ return O(d, (e) => {
1368
+ k?.disconnect(), k = null, e && (D = e.clientHeight, !(typeof ResizeObserver > "u") && (k = new ResizeObserver(J), k.observe(e)));
1369
+ }), O(() => l.items.length, async (e) => {
1370
+ let t = l.initialPostId, n = t == null ? -1 : l.items.findIndex(({ postId: e }) => e === t);
1371
+ g.value = n >= 0 ? n : Math.min(g.value, Math.max(0, e - 1)), await m(), J();
1372
+ }), O(L, (e) => {
1357
1373
  e !== void 0 && u("activeChange", e);
1358
- }, { immediate: !0 }), v(() => {
1359
- window.addEventListener("resize", J), window.addEventListener("orientationchange", J), f >= 0 && p(K);
1360
- }), _(() => {
1361
- window.removeEventListener("resize", J), window.removeEventListener("orientationchange", J), E?.disconnect(), O !== null && cancelAnimationFrame(O), k !== null && clearTimeout(k);
1362
- }), r({
1363
- activeIndex: h,
1364
- activePostId: F,
1365
- changeActiveMedia: ae,
1366
- loadIfNearBottom: ie,
1367
- moveActivePost: oe,
1368
- transitionActiveMedia: le,
1369
- transitionActivePost: ce
1370
- }), (n, r) => (y(), o("main", {
1371
- class: m(["reel-shell", {
1374
+ }, { immediate: !0 }), y(() => {
1375
+ window.addEventListener("resize", Y), window.addEventListener("orientationchange", Y), p >= 0 && m(J);
1376
+ }), v(() => {
1377
+ window.removeEventListener("resize", Y), window.removeEventListener("orientationchange", Y), k?.disconnect(), A !== null && cancelAnimationFrame(A), j !== null && clearTimeout(j);
1378
+ }), n({
1379
+ activeIndex: g,
1380
+ activePostId: L,
1381
+ changeActiveMedia: oe,
1382
+ loadIfNearBottom: ae,
1383
+ moveActivePost: se,
1384
+ transitionActiveMedia: de,
1385
+ transitionActivePost: ue
1386
+ }), (n, r) => (b(), s("main", {
1387
+ class: h(["reel-shell", {
1372
1388
  "reel-shell--has-footer": !!t.cardFooter,
1373
1389
  "reel-shell--has-header": !!t.cardHeader
1374
1390
  }]),
1375
1391
  "data-layout-mode": "reel"
1376
1392
  }, [
1377
- t.cardHeader && I.value && t.reelForward.status === "idle" ? (y(), i(Oe, {
1393
+ t.cardHeader && R.value && t.reelForward.status === "idle" ? (b(), a(ke, {
1378
1394
  key: 0,
1379
- index: h.value,
1380
- item: I.value,
1395
+ index: g.value,
1396
+ item: R.value,
1381
1397
  layout: "reel",
1382
1398
  "loaded-count": t.items.length,
1383
- "media-index": L.value,
1399
+ "media-index": z.value,
1384
1400
  "media-source": t.mediaSource,
1385
1401
  placement: "header",
1386
1402
  region: t.cardHeader,
1387
- style: g(t.mediaCard?.header),
1403
+ style: _(t.mediaCard?.header),
1388
1404
  total: t.total
1389
1405
  }, null, 8, [
1390
1406
  "index",
@@ -1395,40 +1411,44 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1395
1411
  "region",
1396
1412
  "style",
1397
1413
  "total"
1398
- ])) : a("", !0),
1399
- s("div", {
1414
+ ])) : o("", !0),
1415
+ c("div", ft, [c("div", {
1400
1416
  ref_key: "galleryElement",
1401
1417
  ref: d,
1402
1418
  class: "gallery-shell reel-feed",
1403
- "data-active-post-id": F.value,
1404
- "data-active-media-index": L.value,
1405
- onScrollPassive: re
1406
- }, [t.reelForward.status === "idle" ? (y(), o("section", {
1419
+ "data-active-post-id": L.value,
1420
+ "data-active-media-index": z.value,
1421
+ onScrollPassive: q
1422
+ }, [t.reelForward.status === "idle" ? (b(), s("section", {
1407
1423
  key: 1,
1408
1424
  class: "reel-track",
1409
- style: g(A.value),
1425
+ style: _(N.value),
1410
1426
  "aria-label": "Media gallery"
1411
- }, [(y(!0), o(e, null, x(M.value, ({ fetchPriority: e, item: n, index: r }) => (y(), i(Qe, {
1427
+ }, [(b(!0), s(e, null, S(I.value, ({ fetchPriority: e, item: n, index: r }) => (b(), a($e, {
1412
1428
  key: n.postId,
1413
- "advance-on-media-end": l.reelAutoAdvance.enabled && r === h.value,
1429
+ active: r === g.value && !x.value,
1430
+ "advance-on-media-end": l.reelAutoAdvance.enabled && r === g.value,
1414
1431
  class: "reel-item",
1415
1432
  entering: !1,
1416
1433
  "fetch-priority": e,
1417
1434
  index: r,
1418
1435
  item: n,
1419
- "item-style": te(r),
1436
+ "item-style": ne(r),
1420
1437
  "media-card": t.mediaCard,
1421
1438
  layout: "reel",
1422
1439
  "loaded-count": t.items.length,
1423
1440
  "media-index": t.mediaIndices.get(n.postId) ?? 0,
1424
1441
  "media-source": t.mediaSource,
1425
- "preview-state": t.previewStates.get(T(P)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1442
+ "preview-state": t.previewStates.get(E(F)(n.postId, t.mediaIndices.get(n.postId) ?? 0)) ?? "loading",
1443
+ "reel-controls-target": f.value,
1444
+ "stationary-reel-controls": "",
1426
1445
  total: t.total,
1427
1446
  onMediaChange: (e) => u("mediaChange", n.postId, e),
1428
- onEnded: (e) => de(n.postId, e),
1447
+ onEnded: (e) => pe(n.postId, e),
1429
1448
  onReady: (e) => u("ready", n.postId, e),
1430
1449
  onError: (e) => u("error", n.postId, e)
1431
1450
  }, null, 8, [
1451
+ "active",
1432
1452
  "advance-on-media-end",
1433
1453
  "fetch-priority",
1434
1454
  "index",
@@ -1439,22 +1459,23 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1439
1459
  "media-index",
1440
1460
  "media-source",
1441
1461
  "preview-state",
1462
+ "reel-controls-target",
1442
1463
  "total",
1443
1464
  "onMediaChange",
1444
1465
  "onEnded",
1445
1466
  "onReady",
1446
1467
  "onError"
1447
- ]))), 128))], 4)) : (y(), o("div", {
1468
+ ]))), 128))], 4)) : (b(), s("div", {
1448
1469
  key: 0,
1449
1470
  class: "reel-forward-status",
1450
1471
  role: t.reelForward.status === "error" ? "alert" : "status",
1451
1472
  "data-status": t.reelForward.status
1452
- }, [s("p", null, w(ee.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (y(), o("button", {
1473
+ }, [c("p", null, T(te.value), 1), t.reelForward.status === "error" || t.reelForward.status === "end" ? (b(), s("button", {
1453
1474
  key: 0,
1454
1475
  class: "reel-forward-retry",
1455
1476
  type: "button",
1456
1477
  onClick: r[0] ||= (e) => u("retryForward")
1457
- }, " Retry ")) : a("", !0)], 8, ft)), t.reelForward.status === "idle" ? (y(), i(H, {
1478
+ }, " Retry ")) : o("", !0)], 8, mt)), t.reelForward.status === "idle" ? (b(), a(U, {
1458
1479
  key: 2,
1459
1480
  actions: t.feedFooterActions,
1460
1481
  "can-retry-end": t.canRetryEnd,
@@ -1475,18 +1496,23 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1475
1496
  "is-loading",
1476
1497
  "load-more-locked",
1477
1498
  "state"
1478
- ])) : a("", !0)], 40, dt),
1479
- t.cardFooter && I.value && t.reelForward.status === "idle" ? (y(), i(Oe, {
1499
+ ])) : o("", !0)], 40, pt), c("div", {
1500
+ ref_key: "reelControlsElement",
1501
+ ref: f,
1502
+ class: "reel-media-controls-host",
1503
+ "data-test": "reel-media-controls-host"
1504
+ }, null, 512)]),
1505
+ t.cardFooter && R.value && t.reelForward.status === "idle" ? (b(), a(ke, {
1480
1506
  key: 1,
1481
- index: h.value,
1482
- item: I.value,
1507
+ index: g.value,
1508
+ item: R.value,
1483
1509
  layout: "reel",
1484
1510
  "loaded-count": t.items.length,
1485
- "media-index": L.value,
1511
+ "media-index": z.value,
1486
1512
  "media-source": t.mediaSource,
1487
1513
  placement: "footer",
1488
1514
  region: t.cardFooter,
1489
- style: g(t.mediaCard?.footer),
1515
+ style: _(t.mediaCard?.footer),
1490
1516
  total: t.total
1491
1517
  }, null, 8, [
1492
1518
  "index",
@@ -1497,25 +1523,25 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1497
1523
  "region",
1498
1524
  "style",
1499
1525
  "total"
1500
- ])) : a("", !0),
1501
- W.value ? (y(), i(ut, {
1502
- key: V.value,
1526
+ ])) : o("", !0),
1527
+ ee.value ? (b(), a(dt, {
1528
+ key: W.value,
1503
1529
  "duration-ms": t.reelAutoAdvance.intervalMs,
1504
- label: U.value,
1505
- onComplete: ue
1506
- }, null, 8, ["duration-ms", "label"])) : a("", !0)
1530
+ label: G.value,
1531
+ onComplete: fe
1532
+ }, null, 8, ["duration-ms", "label"])) : o("", !0)
1507
1533
  ], 2));
1508
1534
  }
1509
- }), gt = ["data-info-sheet-open", "data-info-sheet-mode"], _t = ["aria-hidden", "inert"], vt = {
1535
+ }), vt = ["data-info-sheet-open", "data-info-sheet-mode"], yt = ["aria-hidden", "inert"], bt = {
1510
1536
  key: 0,
1511
1537
  class: "reel-info-sheet-layer",
1512
1538
  "data-test": "reel-info-sheet"
1513
- }, yt = [
1539
+ }, xt = [
1514
1540
  "role",
1515
1541
  "aria-modal",
1516
1542
  "tabindex",
1517
1543
  "data-active-post-id"
1518
- ], bt = /* @__PURE__ */ u({
1544
+ ], St = /* @__PURE__ */ d({
1519
1545
  __name: "ReelLayout",
1520
1546
  props: {
1521
1547
  forwardIndex: { default: null },
@@ -1558,87 +1584,87 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1558
1584
  "retryEnd",
1559
1585
  "retryForward"
1560
1586
  ],
1561
- setup(e, { expose: r, emit: c }) {
1562
- let u = e, f = c, g = C(null), v = C(null), b = null, x = n(() => {
1563
- let e = u.initialPostId === null || u.initialPostId === void 0 ? -1 : u.items.findIndex((e) => e.postId === u.initialPostId);
1587
+ setup(e, { expose: t, emit: i }) {
1588
+ let l = e, d = i, p = w(null), _ = w(null), y = null, x = r(() => {
1589
+ let e = l.initialPostId === null || l.initialPostId === void 0 ? -1 : l.items.findIndex((e) => e.postId === l.initialPostId);
1564
1590
  return Math.max(0, e);
1565
- }), w = n(() => u.items[x.value]), T = n(() => w.value ?? (u.reelForward.status === "idle" ? void 0 : u.forwardItem ?? void 0)), E = n(() => w.value ? x.value : u.forwardIndex ?? 0), k = n(() => {
1591
+ }), S = r(() => l.items[x.value]), T = r(() => S.value ?? (l.reelForward.status === "idle" ? void 0 : l.forwardItem ?? void 0)), E = r(() => S.value ? x.value : l.forwardIndex ?? 0), D = r(() => {
1566
1592
  let e = T.value?.postId;
1567
- return e === void 0 ? 0 : u.mediaIndices.get(e) ?? 0;
1568
- }), A = n(() => !!(u.infoSheet && u.infoSheetEnabled && T.value)), M = n(() => {
1593
+ return e === void 0 ? 0 : l.mediaIndices.get(e) ?? 0;
1594
+ }), A = r(() => !!(l.infoSheet && l.infoSheetEnabled && T.value)), j = r(() => {
1569
1595
  let e = T.value;
1570
1596
  return e ? {
1571
- close: P,
1597
+ close: N,
1572
1598
  index: E.value,
1573
1599
  item: e,
1574
1600
  layout: "reel",
1575
- loadedCount: u.items.length,
1576
- mediaCount: j(e).length,
1577
- mediaIndex: k.value,
1578
- mediaItem: N(e, k.value),
1579
- mediaSource: u.mediaSource ?? "preview",
1580
- origin: u.origin,
1581
- total: u.total
1601
+ loadedCount: l.items.length,
1602
+ mediaCount: M(e).length,
1603
+ mediaIndex: D.value,
1604
+ mediaItem: P(e, D.value),
1605
+ mediaSource: l.mediaSource ?? "preview",
1606
+ origin: l.origin,
1607
+ total: l.total
1582
1608
  } : null;
1583
1609
  });
1584
- function P() {
1585
- f("closeInfoSheet");
1610
+ function N() {
1611
+ d("closeInfoSheet");
1586
1612
  }
1587
1613
  function F(e) {
1588
- return g.value?.changeActiveMedia(e) ?? !1;
1614
+ return p.value?.changeActiveMedia(e) ?? !1;
1589
1615
  }
1590
1616
  function I() {
1591
- g.value?.loadIfNearBottom();
1617
+ p.value?.loadIfNearBottom();
1592
1618
  }
1593
1619
  function L(e) {
1594
- return g.value?.moveActivePost(e) ?? !1;
1620
+ return p.value?.moveActivePost(e) ?? !1;
1595
1621
  }
1596
1622
  function R(e) {
1597
- return g.value?.transitionActiveMedia(e) ?? Promise.resolve(!1);
1623
+ return p.value?.transitionActiveMedia(e) ?? Promise.resolve(!1);
1598
1624
  }
1599
1625
  function z(e) {
1600
- return g.value?.transitionActivePost(e) ?? Promise.resolve(!1);
1626
+ return p.value?.transitionActivePost(e) ?? Promise.resolve(!1);
1601
1627
  }
1602
1628
  function B(e, t) {
1603
- f("error", e, t);
1629
+ d("error", e, t);
1604
1630
  }
1605
1631
  function V(e, t) {
1606
- f("mediaChange", e, t);
1632
+ d("mediaChange", e, t);
1607
1633
  }
1608
1634
  function H(e, t) {
1609
- f("ready", e, t);
1635
+ d("ready", e, t);
1610
1636
  }
1611
- return D(() => ({
1612
- overlay: u.infoSheetOverlay,
1637
+ return O(() => ({
1638
+ overlay: l.infoSheetOverlay,
1613
1639
  visible: A.value
1614
1640
  }), async (e, t) => {
1615
1641
  if (e.visible && !t?.visible) {
1616
- b = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.overlay && (await p(), v.value?.focus({ preventScroll: !0 }));
1642
+ y = document.activeElement instanceof HTMLElement ? document.activeElement : null, e.overlay && (await m(), _.value?.focus({ preventScroll: !0 }));
1617
1643
  return;
1618
1644
  }
1619
- if (!e.visible && t?.visible && b?.isConnected) {
1620
- let e = b;
1621
- b = null, await p(), e.focus({ preventScroll: !0 });
1645
+ if (!e.visible && t?.visible && y?.isConnected) {
1646
+ let e = y;
1647
+ y = null, await m(), e.focus({ preventScroll: !0 });
1622
1648
  }
1623
- }), _(() => {
1624
- b = null;
1625
- }), r({
1649
+ }), v(() => {
1650
+ y = null;
1651
+ }), t({
1626
1652
  changeActiveMedia: F,
1627
1653
  loadIfNearBottom: I,
1628
1654
  moveActivePost: L,
1629
1655
  transitionActiveMedia: R,
1630
1656
  transitionActivePost: z
1631
- }), (n, r) => (y(), o("section", {
1632
- class: m(["reel-layout", `reel-layout--${e.infoSheetOverlay ? "overlay" : "layout"}`]),
1657
+ }), (t, r) => (b(), s("section", {
1658
+ class: h(["reel-layout", `reel-layout--${e.infoSheetOverlay ? "overlay" : "layout"}`]),
1633
1659
  "data-info-sheet-open": A.value || void 0,
1634
1660
  "data-info-sheet-mode": e.infoSheetOverlay ? "overlay" : "layout"
1635
- }, [s("div", {
1661
+ }, [c("div", {
1636
1662
  class: "reel-layout-main",
1637
1663
  "aria-hidden": e.infoSheetOverlay && A.value || void 0,
1638
1664
  inert: e.infoSheetOverlay && A.value || void 0
1639
- }, [l(ht, {
1665
+ }, [u(_t, {
1640
1666
  ref_key: "reelFeed",
1641
- ref: g,
1667
+ ref: p,
1642
1668
  "can-retry-end": e.canRetryEnd,
1643
1669
  "card-footer": e.cardFooter,
1644
1670
  "card-header": e.cardHeader,
@@ -1659,13 +1685,13 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1659
1685
  "reel-forward": e.reelForward,
1660
1686
  state: e.state,
1661
1687
  total: e.total,
1662
- onActiveChange: r[0] ||= (e) => f("activeChange", e),
1688
+ onActiveChange: r[0] ||= (e) => d("activeChange", e),
1663
1689
  onError: B,
1664
- onLoadMore: r[1] ||= (e) => f("loadMore"),
1690
+ onLoadMore: r[1] ||= (e) => d("loadMore"),
1665
1691
  onMediaChange: V,
1666
1692
  onReady: H,
1667
- onRetryEnd: r[2] ||= (e) => f("retryEnd"),
1668
- onRetryForward: r[3] ||= (e) => f("retryForward")
1693
+ onRetryEnd: r[2] ||= (e) => d("retryEnd"),
1694
+ onRetryForward: r[3] ||= (e) => d("retryForward")
1669
1695
  }, null, 8, [
1670
1696
  "can-retry-end",
1671
1697
  "card-footer",
@@ -1687,21 +1713,21 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1687
1713
  "reel-forward",
1688
1714
  "state",
1689
1715
  "total"
1690
- ])], 8, _t), l(t, { name: "vibe-info-sheet" }, {
1691
- default: O(() => [A.value && e.infoSheet && M.value ? (y(), o("div", vt, [s("aside", {
1716
+ ])], 8, yt), u(n, { name: "vibe-info-sheet" }, {
1717
+ default: k(() => [A.value && e.infoSheet && j.value ? (b(), s("div", bt, [c("aside", {
1692
1718
  ref_key: "sheetElement",
1693
- ref: v,
1719
+ ref: _,
1694
1720
  class: "reel-info-sheet",
1695
1721
  role: e.infoSheetOverlay ? "dialog" : "complementary",
1696
1722
  "aria-label": "Reel information",
1697
1723
  "aria-modal": e.infoSheetOverlay ? "true" : void 0,
1698
1724
  tabindex: e.infoSheetOverlay ? -1 : void 0,
1699
1725
  "data-active-post-id": T.value?.postId
1700
- }, [(y(), i(S(e.infoSheet.component), h(d(M.value)), null, 16))], 8, yt)])) : a("", !0)]),
1726
+ }, [(b(), a(C(e.infoSheet.component), g(f(j.value)), null, 16))], 8, xt)])) : o("", !0)]),
1701
1727
  _: 1
1702
- })], 10, gt));
1728
+ })], 10, vt));
1703
1729
  }
1704
- }), xt = 35, St = 420, Ct = /* @__PURE__ */ u({
1730
+ }), Ct = 35, wt = 420, Tt = /* @__PURE__ */ d({
1705
1731
  __name: "VibeSurface",
1706
1732
  props: {
1707
1733
  canRetryEnd: { type: Boolean },
@@ -1722,94 +1748,94 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1722
1748
  "retryEnd",
1723
1749
  "retryForward"
1724
1750
  ],
1725
- setup(r, { expose: s, emit: c }) {
1726
- 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 = n(() => F(u.state)), I = n(() => u.state.reelMediaSource === "original" ? j.value : A.value), L = new Set(u.state.items.map((e) => e.postId)), R = null, z = null, B = !1;
1751
+ setup(t, { expose: i, emit: c }) {
1752
+ let l = t, d = c, f = w(null), p = w(null), h = w(null), g = w(null), x = w({}), S = w(!1), C = w(/* @__PURE__ */ new Set()), T = w(/* @__PURE__ */ new Map()), E = w(/* @__PURE__ */ new Set()), D = w(/* @__PURE__ */ new Map()), A = w(/* @__PURE__ */ new Map()), j = w(/* @__PURE__ */ new Map()), M = r(() => I(l.state)), P = r(() => l.state.reelMediaSource === "original" ? j.value : A.value), L = new Set(l.state.items.map((e) => e.postId)), R = null, z = null, B = !1;
1727
1753
  function V() {
1728
1754
  return typeof window.matchMedia == "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
1729
1755
  }
1730
1756
  function H() {
1731
1757
  R !== null && cancelAnimationFrame(R), R = requestAnimationFrame(() => {
1732
1758
  R = requestAnimationFrame(() => {
1733
- R = null, w.value = /* @__PURE__ */ new Set();
1759
+ R = null, C.value = /* @__PURE__ */ new Set();
1734
1760
  });
1735
1761
  });
1736
1762
  }
1737
1763
  function U(e, t, n) {
1738
- let r = P(e, t);
1764
+ let r = F(e, t);
1739
1765
  A.value.get(r) !== n && (A.value = new Map(A.value).set(r, n));
1740
1766
  }
1741
1767
  function W(e, t, n) {
1742
- let r = P(e, t);
1768
+ let r = F(e, t);
1743
1769
  j.value.get(r) !== n && (j.value = new Map(j.value).set(r, n));
1744
1770
  }
1745
1771
  function G(e, t) {
1746
1772
  U(e, t, "error");
1747
1773
  }
1748
- function te(e, t) {
1774
+ function K(e, t) {
1749
1775
  U(e, t, "ready");
1750
1776
  }
1751
- function ne(e, t) {
1777
+ function te(e, t) {
1752
1778
  W(e, t, "error");
1753
1779
  }
1754
- function re(e, t) {
1780
+ function ne(e, t) {
1755
1781
  W(e, t, "ready");
1756
1782
  }
1757
- function K(e, t) {
1758
- if (u.state.reelMediaSource === "original") {
1759
- ne(e, t);
1783
+ function re(e, t) {
1784
+ if (l.state.reelMediaSource === "original") {
1785
+ te(e, t);
1760
1786
  return;
1761
1787
  }
1762
1788
  G(e, t);
1763
1789
  }
1764
1790
  function q(e, t) {
1765
- if (u.state.reelMediaSource === "original") {
1766
- re(e, t);
1791
+ if (l.state.reelMediaSource === "original") {
1792
+ ne(e, t);
1767
1793
  return;
1768
1794
  }
1769
- te(e, t);
1795
+ K(e, t);
1770
1796
  }
1771
1797
  function J(e, t) {
1772
- let n = u.state.items.find((t) => t.postId === e);
1798
+ let n = l.state.items.find((t) => t.postId === e);
1773
1799
  if (!n) return;
1774
- let r = M(n, t);
1775
- (u.state.mediaIndices.get(e) ?? 0) !== r && (u.state.mediaIndices = new Map(u.state.mediaIndices).set(e, r));
1800
+ let r = N(n, t);
1801
+ (l.state.mediaIndices.get(e) ?? 0) !== r && (l.state.mediaIndices = new Map(l.state.mediaIndices).set(e, r));
1776
1802
  }
1777
- async function Y() {
1778
- await p(), (u.state.layout === "reel" || u.state.reelOrigin === "masonry" ? m.value : f.value)?.loadIfNearBottom();
1803
+ async function ie() {
1804
+ await m(), (l.state.layout === "reel" || l.state.reelOrigin === "masonry" ? p.value : f.value)?.loadIfNearBottom();
1779
1805
  }
1780
- function ie(e) {
1781
- return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.changeActiveMedia?.(e) ?? !1;
1806
+ function Y(e) {
1807
+ return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.changeActiveMedia?.(e) ?? !1;
1782
1808
  }
1783
- function ae(e) {
1784
- return u.state.isLoading || u.state.items.length === 0 || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry" ? !1 : m.value?.moveActivePost?.(e) ?? !1;
1809
+ function X(e) {
1810
+ return l.state.isLoading || l.state.items.length === 0 || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry" ? !1 : p.value?.moveActivePost?.(e) ?? !1;
1785
1811
  }
1786
- function oe() {
1787
- return u.state.layout !== "masonry" || u.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1812
+ function ae() {
1813
+ return l.state.layout !== "masonry" || l.state.reelOrigin === "masonry" ? null : f.value?.getScrollElement?.() ?? null;
1788
1814
  }
1789
- function X(e, t) {
1790
- z = e, B = t === "keyboard", x.value = le(e), d("openReel", e), p(() => h.value?.focus());
1815
+ function oe(e, t) {
1816
+ z = e, B = t === "keyboard", x.value = Z(e), d("openReel", e), m(() => h.value?.focus());
1791
1817
  }
1792
- function Z(e) {
1793
- let t = b.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1818
+ function se(e) {
1819
+ let t = g.value?.querySelectorAll(".masonry-feed [data-post-id]") ?? [];
1794
1820
  return Array.from(t).find((t) => t.dataset.postId === String(e)) ?? null;
1795
1821
  }
1796
- function se(e) {
1797
- if (u.state.layout !== "masonry" || u.state.reelOrigin !== null || V()) return 0;
1798
- let t = [...new Set(e)], n = t.filter(Z);
1822
+ function ce(e) {
1823
+ if (l.state.layout !== "masonry" || l.state.reelOrigin !== null || V()) return 0;
1824
+ let t = [...new Set(e)], n = t.filter(se);
1799
1825
  if (n.length === 0) return 0;
1800
- let r = new Map(k.value);
1826
+ let r = new Map(D.value);
1801
1827
  return n.forEach((e, t) => {
1802
- r.set(e, t * xt);
1803
- }), w.value = new Set([...w.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), k.value = r, St + (n.length - 1) * xt;
1828
+ r.set(e, t * Ct);
1829
+ }), C.value = new Set([...C.value].filter((e) => !n.includes(e))), E.value = new Set([...E.value, ...t]), D.value = r, wt + (n.length - 1) * Ct;
1804
1830
  }
1805
- function ce(e, t) {
1806
- let n = Z(e), r = n?.querySelector(".media-card-activator") ?? n;
1831
+ function le(e, t) {
1832
+ let n = se(e), r = n?.querySelector(".media-card-activator") ?? n;
1807
1833
  r && (r.classList.toggle("media-card-focus-silent", !t), t || r.addEventListener("blur", () => {
1808
1834
  r.classList.remove("media-card-focus-silent");
1809
1835
  }, { once: !0 }), r?.focus({ preventScroll: !0 }));
1810
1836
  }
1811
- function le(e) {
1812
- let t = b.value, n = Z(e);
1837
+ function Z(e) {
1838
+ let t = g.value, n = se(e);
1813
1839
  if (t === null || n === null) return {};
1814
1840
  let r = t.getBoundingClientRect(), i = n.getBoundingClientRect();
1815
1841
  return {
@@ -1820,25 +1846,25 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1820
1846
  };
1821
1847
  }
1822
1848
  function ue() {
1823
- u.state.reelOrigin === "masonry" && (z ??= u.state.activeReelPostId, S.value = !0, d("closeReel"));
1849
+ l.state.reelOrigin === "masonry" && (z ??= l.state.activeReelPostId, S.value = !0, d("closeReel"));
1824
1850
  }
1825
1851
  function de() {
1826
1852
  let e = z, t = B;
1827
- S.value = !1, z = null, B = !1, x.value = {}, p(() => {
1828
- e !== null && ce(e, t);
1853
+ S.value = !1, z = null, B = !1, x.value = {}, m(() => {
1854
+ e !== null && le(e, t);
1829
1855
  });
1830
1856
  }
1831
1857
  function fe(e) {
1832
- let t = u.state.layout === "reel" || u.state.reelOrigin === "masonry";
1833
- if (e.key === "Escape" && u.state.reelOrigin === "masonry") {
1834
- e.preventDefault(), u.state.reelInfoSheetOverlay && u.state.reelInfoSheet.enabled && d("reelInfoSheetChange", !1), ue();
1858
+ let t = l.state.layout === "reel" || l.state.reelOrigin === "masonry";
1859
+ if (e.key === "Escape" && l.state.reelOrigin === "masonry") {
1860
+ e.preventDefault(), l.state.reelInfoSheetOverlay && l.state.reelInfoSheet.enabled && d("reelInfoSheetChange", !1), ue();
1835
1861
  return;
1836
1862
  }
1837
- if (e.key === "Escape" && t && u.state.reelInfoSheet.enabled) {
1863
+ if (e.key === "Escape" && t && l.state.reelInfoSheet.enabled) {
1838
1864
  e.preventDefault(), d("reelInfoSheetChange", !1);
1839
1865
  return;
1840
1866
  }
1841
- if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || S.value || u.state.layout !== "reel" && u.state.reelOrigin !== "masonry") return;
1867
+ if (e.defaultPrevented || e.altKey || e.ctrlKey || e.metaKey || e.shiftKey || S.value || l.state.layout !== "reel" && l.state.reelOrigin !== "masonry") return;
1842
1868
  let n = e.target;
1843
1869
  if (n instanceof HTMLElement && (n.isContentEditable || [
1844
1870
  "INPUT",
@@ -1846,70 +1872,70 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1846
1872
  "TEXTAREA"
1847
1873
  ].includes(n.tagName))) return;
1848
1874
  let r = e.key === "ArrowLeft" ? -1 : e.key === "ArrowRight" ? 1 : 0;
1849
- r !== 0 && m.value?.changeActiveMedia?.(r) && e.preventDefault();
1875
+ r !== 0 && p.value?.changeActiveMedia?.(r) && e.preventDefault();
1850
1876
  }
1851
- return D(() => u.state.items.map((e) => e.postId), (e) => {
1877
+ return O(() => l.state.items.map((e) => e.postId), (e) => {
1852
1878
  let t = e.filter((e) => !L.has(e)), n = new Set(e);
1853
- if (L = 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 || V()) return;
1879
+ if (L = new Set(e), E.value = new Set([...E.value].filter((e) => n.has(e))), D.value = new Map([...D.value].filter(([e]) => n.has(e))), t.length === 0 || V()) return;
1854
1880
  let r = /* @__PURE__ */ new Map();
1855
1881
  e.forEach((e) => {
1856
1882
  let t = T.value.get(e);
1857
1883
  t !== void 0 && r.set(e, t);
1858
1884
  }), t.forEach((e, t) => {
1859
- r.set(e, t * xt);
1860
- }), T.value = r, w.value = new Set([...w.value, ...t]), H();
1861
- }, { flush: "sync" }), v(() => window.addEventListener("keydown", fe)), _(() => {
1885
+ r.set(e, t * Ct);
1886
+ }), T.value = r, C.value = new Set([...C.value, ...t]), H();
1887
+ }, { flush: "sync" }), y(() => window.addEventListener("keydown", fe)), v(() => {
1862
1888
  window.removeEventListener("keydown", fe), R !== null && cancelAnimationFrame(R);
1863
- }), s({
1864
- changeActiveReelMedia: ie,
1865
- getAutoScrollElement: oe,
1866
- loadIfNearBottom: Y,
1867
- moveActiveReelPost: ae,
1868
- startItemRemoval: se,
1869
- transitionActiveReelMedia: (e) => m.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
1870
- transitionActiveReelPost: (e) => m.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
1871
- }), (n, s) => (y(), o("div", {
1889
+ }), i({
1890
+ changeActiveReelMedia: Y,
1891
+ getAutoScrollElement: ae,
1892
+ loadIfNearBottom: ie,
1893
+ moveActiveReelPost: X,
1894
+ startItemRemoval: ce,
1895
+ transitionActiveReelMedia: (e) => p.value?.transitionActiveMedia?.(e) ?? Promise.resolve(!1),
1896
+ transitionActiveReelPost: (e) => p.value?.transitionActivePost?.(e) ?? Promise.resolve(!1)
1897
+ }), (r, i) => (b(), s("div", {
1872
1898
  ref_key: "surfaceElement",
1873
- ref: b,
1899
+ ref: g,
1874
1900
  class: "vibe-surface"
1875
- }, [r.state.layout === "reel" && (r.state.items.length > 0 || r.state.reelForward.status !== "idle") ? (y(), i(bt, {
1901
+ }, [t.state.layout === "reel" && (t.state.items.length > 0 || t.state.reelForward.status !== "idle") ? (b(), a(St, {
1876
1902
  key: 0,
1877
1903
  ref_key: "reelRenderer",
1878
- ref: m,
1879
- "can-retry-end": r.canRetryEnd,
1880
- "has-next": r.state.next !== null,
1881
- "card-footer": r.cardFooter,
1882
- "card-header": r.cardHeader,
1883
- "feed-footer": r.feedFooter,
1884
- "feed-footer-actions": r.feedFooterActions,
1885
- "forward-index": r.state.reelForwardIndex,
1886
- "forward-item": r.state.reelForwardItem,
1887
- "media-card": r.mediaCard,
1888
- "infinite-scroll": r.state.infiniteScroll,
1889
- "is-loading-more": r.state.isLoadingMore,
1890
- items: r.state.items,
1891
- "load-more-locked": r.state.loadMoreLocked,
1892
- "media-source": r.state.reelMediaSource,
1893
- "media-indices": r.state.mediaIndices,
1894
- "initial-post-id": r.state.activeReelPostId,
1895
- "info-sheet": r.reelInfoSheet,
1896
- "info-sheet-enabled": r.state.reelInfoSheet.enabled,
1897
- "info-sheet-overlay": r.state.reelInfoSheetOverlay,
1898
- "next-page-error": !!r.state.nextPageError,
1904
+ ref: p,
1905
+ "can-retry-end": t.canRetryEnd,
1906
+ "has-next": t.state.next !== null,
1907
+ "card-footer": t.cardFooter,
1908
+ "card-header": t.cardHeader,
1909
+ "feed-footer": t.feedFooter,
1910
+ "feed-footer-actions": t.feedFooterActions,
1911
+ "forward-index": t.state.reelForwardIndex,
1912
+ "forward-item": t.state.reelForwardItem,
1913
+ "media-card": t.mediaCard,
1914
+ "infinite-scroll": t.state.infiniteScroll,
1915
+ "is-loading-more": t.state.isLoadingMore,
1916
+ items: t.state.items,
1917
+ "load-more-locked": t.state.loadMoreLocked,
1918
+ "media-source": t.state.reelMediaSource,
1919
+ "media-indices": t.state.mediaIndices,
1920
+ "initial-post-id": t.state.activeReelPostId,
1921
+ "info-sheet": t.reelInfoSheet,
1922
+ "info-sheet-enabled": t.state.reelInfoSheet.enabled,
1923
+ "info-sheet-overlay": t.state.reelInfoSheetOverlay,
1924
+ "next-page-error": !!t.state.nextPageError,
1899
1925
  origin: "reel",
1900
- "preview-states": I.value,
1901
- "reel-auto-advance": r.state.reelAutoAdvance,
1902
- "reel-forward": r.state.reelForward,
1903
- state: N.value,
1904
- total: r.state.total,
1905
- onActiveChange: s[0] ||= (e) => d("activeReelChange", e),
1906
- onCloseInfoSheet: s[1] ||= (e) => d("reelInfoSheetChange", !1),
1907
- onError: K,
1908
- onLoadMore: s[2] ||= (e) => d("loadMore"),
1926
+ "preview-states": P.value,
1927
+ "reel-auto-advance": t.state.reelAutoAdvance,
1928
+ "reel-forward": t.state.reelForward,
1929
+ state: M.value,
1930
+ total: t.state.total,
1931
+ onActiveChange: i[0] ||= (e) => d("activeReelChange", e),
1932
+ onCloseInfoSheet: i[1] ||= (e) => d("reelInfoSheetChange", !1),
1933
+ onError: re,
1934
+ onLoadMore: i[2] ||= (e) => d("loadMore"),
1909
1935
  onMediaChange: J,
1910
1936
  onReady: q,
1911
- onRetryEnd: s[3] ||= (e) => d("retryEnd"),
1912
- onRetryForward: s[4] ||= (e) => d("retryForward")
1937
+ onRetryEnd: i[3] ||= (e) => d("retryEnd"),
1938
+ onRetryForward: i[4] ||= (e) => d("retryForward")
1913
1939
  }, null, 8, [
1914
1940
  "can-retry-end",
1915
1941
  "has-next",
@@ -1936,49 +1962,49 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
1936
1962
  "reel-forward",
1937
1963
  "state",
1938
1964
  "total"
1939
- ])) : r.state.error || r.state.isLoading || r.state.items.length === 0 && r.state.reelForward.status === "idle" ? (y(), i(ee, {
1965
+ ])) : t.state.error || t.state.isLoading || t.state.items.length === 0 && t.state.reelForward.status === "idle" ? (b(), a(ee, {
1940
1966
  key: 1,
1941
- actions: r.feedFooterActions,
1942
- "can-retry-end": r.canRetryEnd,
1943
- "feed-footer": r.feedFooter,
1944
- state: N.value,
1945
- onLoadMore: s[5] ||= (e) => d("loadMore"),
1946
- onRetryEnd: s[6] ||= (e) => d("retryEnd")
1967
+ actions: t.feedFooterActions,
1968
+ "can-retry-end": t.canRetryEnd,
1969
+ "feed-footer": t.feedFooter,
1970
+ state: M.value,
1971
+ onLoadMore: i[5] ||= (e) => d("loadMore"),
1972
+ onRetryEnd: i[6] ||= (e) => d("retryEnd")
1947
1973
  }, null, 8, [
1948
1974
  "actions",
1949
1975
  "can-retry-end",
1950
1976
  "feed-footer",
1951
1977
  "state"
1952
- ])) : (y(), o(e, { key: 2 }, [l(ot, {
1978
+ ])) : (b(), s(e, { key: 2 }, [u(st, {
1953
1979
  ref_key: "masonryRenderer",
1954
1980
  ref: f,
1955
- "can-retry-end": r.canRetryEnd,
1956
- "entering-post-ids": w.value,
1981
+ "can-retry-end": t.canRetryEnd,
1982
+ "entering-post-ids": C.value,
1957
1983
  "entry-delays": T.value,
1958
1984
  "leaving-post-ids": E.value,
1959
- "removal-delays": k.value,
1960
- "card-footer": r.cardFooter,
1961
- "card-header": r.cardHeader,
1962
- "feed-footer": r.feedFooter,
1963
- "feed-footer-actions": r.feedFooterActions,
1964
- "media-card": r.mediaCard,
1965
- "has-next": r.state.next !== null,
1966
- "infinite-scroll": r.state.infiniteScroll,
1967
- "is-loading-more": r.state.isLoadingMore,
1968
- items: r.state.items,
1969
- "load-more-locked": r.state.loadMoreLocked,
1970
- "media-indices": r.state.mediaIndices,
1971
- "next-page-error": !!r.state.nextPageError,
1985
+ "removal-delays": D.value,
1986
+ "card-footer": t.cardFooter,
1987
+ "card-header": t.cardHeader,
1988
+ "feed-footer": t.feedFooter,
1989
+ "feed-footer-actions": t.feedFooterActions,
1990
+ "media-card": t.mediaCard,
1991
+ "has-next": t.state.next !== null,
1992
+ "infinite-scroll": t.state.infiniteScroll,
1993
+ "is-loading-more": t.state.isLoadingMore,
1994
+ items: t.state.items,
1995
+ "load-more-locked": t.state.loadMoreLocked,
1996
+ "media-indices": t.state.mediaIndices,
1997
+ "next-page-error": !!t.state.nextPageError,
1972
1998
  "preview-states": A.value,
1973
- suspended: r.state.reelOrigin === "masonry" || S.value,
1974
- state: N.value,
1975
- total: r.state.total,
1976
- onActivate: X,
1999
+ suspended: t.state.reelOrigin === "masonry" || S.value,
2000
+ state: M.value,
2001
+ total: t.state.total,
2002
+ onActivate: oe,
1977
2003
  onError: G,
1978
- onLoadMore: s[7] ||= (e) => d("loadMore"),
2004
+ onLoadMore: i[7] ||= (e) => d("loadMore"),
1979
2005
  onMediaChange: J,
1980
- onReady: te,
1981
- onRetryEnd: s[8] ||= (e) => d("retryEnd")
2006
+ onReady: K,
2007
+ onRetryEnd: i[8] ||= (e) => d("retryEnd")
1982
2008
  }, null, 8, [
1983
2009
  "can-retry-end",
1984
2010
  "entering-post-ids",
@@ -2001,11 +2027,11 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
2001
2027
  "suspended",
2002
2028
  "state",
2003
2029
  "total"
2004
- ]), l(t, {
2030
+ ]), u(n, {
2005
2031
  name: "vibe-reel-viewer",
2006
2032
  onAfterLeave: de
2007
2033
  }, {
2008
- default: O(() => [r.state.reelOrigin === "masonry" ? (y(), o("section", {
2034
+ default: k(() => [t.state.reelOrigin === "masonry" ? (b(), s("section", {
2009
2035
  key: 0,
2010
2036
  ref_key: "reelOverlay",
2011
2037
  ref: h,
@@ -2014,44 +2040,44 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
2014
2040
  "aria-label": "Media viewer",
2015
2041
  "aria-modal": "true",
2016
2042
  tabindex: "-1",
2017
- style: g(x.value)
2018
- }, [l(bt, {
2043
+ style: _(x.value)
2044
+ }, [u(St, {
2019
2045
  ref_key: "reelRenderer",
2020
- ref: m,
2021
- "can-retry-end": r.canRetryEnd,
2022
- "card-footer": r.cardFooter,
2023
- "card-header": r.cardHeader,
2024
- "feed-footer": r.feedFooter,
2025
- "feed-footer-actions": r.feedFooterActions,
2026
- "forward-index": r.state.reelForwardIndex,
2027
- "forward-item": r.state.reelForwardItem,
2028
- "media-card": r.mediaCard,
2029
- "has-next": r.state.next !== null,
2030
- "infinite-scroll": r.state.infiniteScroll,
2031
- "initial-post-id": r.state.activeReelPostId,
2032
- "info-sheet": r.reelInfoSheet,
2033
- "info-sheet-enabled": r.state.reelInfoSheet.enabled,
2034
- "info-sheet-overlay": r.state.reelInfoSheetOverlay,
2035
- "is-loading-more": r.state.isLoadingMore,
2036
- items: r.state.items,
2037
- "load-more-locked": r.state.loadMoreLocked,
2038
- "media-indices": r.state.mediaIndices,
2046
+ ref: p,
2047
+ "can-retry-end": t.canRetryEnd,
2048
+ "card-footer": t.cardFooter,
2049
+ "card-header": t.cardHeader,
2050
+ "feed-footer": t.feedFooter,
2051
+ "feed-footer-actions": t.feedFooterActions,
2052
+ "forward-index": t.state.reelForwardIndex,
2053
+ "forward-item": t.state.reelForwardItem,
2054
+ "media-card": t.mediaCard,
2055
+ "has-next": t.state.next !== null,
2056
+ "infinite-scroll": t.state.infiniteScroll,
2057
+ "initial-post-id": t.state.activeReelPostId,
2058
+ "info-sheet": t.reelInfoSheet,
2059
+ "info-sheet-enabled": t.state.reelInfoSheet.enabled,
2060
+ "info-sheet-overlay": t.state.reelInfoSheetOverlay,
2061
+ "is-loading-more": t.state.isLoadingMore,
2062
+ items: t.state.items,
2063
+ "load-more-locked": t.state.loadMoreLocked,
2064
+ "media-indices": t.state.mediaIndices,
2039
2065
  "media-source": "original",
2040
- "next-page-error": !!r.state.nextPageError,
2066
+ "next-page-error": !!t.state.nextPageError,
2041
2067
  origin: "masonry",
2042
2068
  "preview-states": j.value,
2043
- "reel-auto-advance": r.state.reelAutoAdvance,
2044
- "reel-forward": r.state.reelForward,
2045
- state: N.value,
2046
- total: r.state.total,
2047
- onActiveChange: s[9] ||= (e) => d("activeReelChange", e),
2048
- onCloseInfoSheet: s[10] ||= (e) => d("reelInfoSheetChange", !1),
2049
- onError: ne,
2050
- onLoadMore: s[11] ||= (e) => d("loadMore"),
2069
+ "reel-auto-advance": t.state.reelAutoAdvance,
2070
+ "reel-forward": t.state.reelForward,
2071
+ state: M.value,
2072
+ total: t.state.total,
2073
+ onActiveChange: i[9] ||= (e) => d("activeReelChange", e),
2074
+ onCloseInfoSheet: i[10] ||= (e) => d("reelInfoSheetChange", !1),
2075
+ onError: te,
2076
+ onLoadMore: i[11] ||= (e) => d("loadMore"),
2051
2077
  onMediaChange: J,
2052
- onReady: re,
2053
- onRetryEnd: s[12] ||= (e) => d("retryEnd"),
2054
- onRetryForward: s[13] ||= (e) => d("retryForward")
2078
+ onReady: ne,
2079
+ onRetryEnd: i[12] ||= (e) => d("retryEnd"),
2080
+ onRetryForward: i[13] ||= (e) => d("retryForward")
2055
2081
  }, null, 8, [
2056
2082
  "can-retry-end",
2057
2083
  "card-footer",
@@ -2077,14 +2103,14 @@ var lt = ["aria-label"], ut = /* @__PURE__ */ u({
2077
2103
  "reel-forward",
2078
2104
  "state",
2079
2105
  "total"
2080
- ])], 4)) : a("", !0)]),
2106
+ ])], 4)) : o("", !0)]),
2081
2107
  _: 1
2082
2108
  })], 64))], 512));
2083
2109
  }
2084
2110
  });
2085
2111
  //#endregion
2086
2112
  //#region src/core/page.ts
2087
- function wt(e) {
2113
+ function Et(e) {
2088
2114
  if (!e || typeof e != "object" || !Array.isArray(e.items)) throw TypeError("Vibe loadPage must resolve to a page with an items array.");
2089
2115
  if (e.next !== null && typeof e.next != "string" && typeof e.next != "number") throw TypeError("Vibe page next must be a string, number, or null.");
2090
2116
  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.");
@@ -2096,32 +2122,32 @@ function Q(e, t) {
2096
2122
  }
2097
2123
  //#endregion
2098
2124
  //#region src/core/requestDelay.ts
2099
- var Tt = 2e3, Et = 1e4, Dt = 250, Ot = {
2125
+ var Dt = 2e3, Ot = 1e4, kt = 250, At = {
2100
2126
  delayRemainingMs: null,
2101
2127
  nextRequestAt: null
2102
2128
  };
2103
- function kt(e, t) {
2129
+ function jt(e, t) {
2104
2130
  return e === void 0 ? t : Math.floor(e);
2105
2131
  }
2106
- function At(e, t) {
2132
+ function Mt(e, t) {
2107
2133
  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.`);
2108
2134
  }
2109
- function jt(e, t = {}) {
2110
- let n = kt(t.delayStepMs, Tt), r = kt(t.delayMaxMs, Et);
2135
+ function Nt(e, t = {}) {
2136
+ let n = jt(t.delayStepMs, Dt), r = jt(t.delayMaxMs, Ot);
2111
2137
  return Math.min(Math.max(0, e) * n, r);
2112
2138
  }
2113
2139
  function $(e) {
2114
- if (e == null || !Number.isFinite(e)) return { ...Ot };
2140
+ if (e == null || !Number.isFinite(e)) return { ...At };
2115
2141
  let t = Math.max(0, Math.floor(e - Date.now()));
2116
2142
  return t > 0 ? {
2117
2143
  delayRemainingMs: t,
2118
2144
  nextRequestAt: e
2119
- } : { ...Ot };
2145
+ } : { ...At };
2120
2146
  }
2121
- async function Mt({ delayMs: e, onChange: t, signal: n }) {
2147
+ async function Pt({ delayMs: e, onChange: t, signal: n }) {
2122
2148
  if (n.aborted) throw new DOMException("Aborted", "AbortError");
2123
2149
  if (e <= 0) {
2124
- t({ ...Ot });
2150
+ t({ ...At });
2125
2151
  return;
2126
2152
  }
2127
2153
  let r = Date.now() + e;
@@ -2129,9 +2155,9 @@ async function Mt({ delayMs: e, onChange: t, signal: n }) {
2129
2155
  delayRemainingMs: e,
2130
2156
  nextRequestAt: r
2131
2157
  }), await new Promise((i, a) => {
2132
- let o = !1, s = setInterval(f, Dt), c = setTimeout(() => u(), e);
2158
+ let o = !1, s = setInterval(f, kt), c = setTimeout(() => u(), e);
2133
2159
  function l() {
2134
- clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...Ot });
2160
+ clearInterval(s), clearTimeout(c), n.removeEventListener("abort", d), t({ ...At });
2135
2161
  }
2136
2162
  function u(e) {
2137
2163
  o || (o = !0, l(), e ? a(e) : i());
@@ -2146,13 +2172,13 @@ async function Mt({ delayMs: e, onChange: t, signal: n }) {
2146
2172
  n.addEventListener("abort", d, { once: !0 });
2147
2173
  });
2148
2174
  }
2149
- var Nt = class {
2175
+ var Ft = class {
2150
2176
  interval = null;
2151
2177
  constructor(e) {
2152
2178
  this.onChange = e;
2153
2179
  }
2154
2180
  clear() {
2155
- this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...Ot });
2181
+ this.interval !== null && clearInterval(this.interval), this.interval = null, this.onChange({ ...At });
2156
2182
  }
2157
2183
  sync(e) {
2158
2184
  this.clear();
@@ -2160,22 +2186,22 @@ var Nt = class {
2160
2186
  this.onChange(t), t.delayRemainingMs !== null && (this.interval = setInterval(() => {
2161
2187
  let t = $(e);
2162
2188
  this.onChange(t), t.delayRemainingMs === null && this.clear();
2163
- }, Dt));
2189
+ }, kt));
2164
2190
  }
2165
2191
  };
2166
- function Pt(e, t = !0) {
2192
+ function It(e, t = !0) {
2167
2193
  return e.maxAdditionalPages === "unlimited" ? Infinity : (e.maxAdditionalPages ?? 10) + (t ? 1 : 0);
2168
2194
  }
2169
- function Ft(e) {
2195
+ function Lt(e) {
2170
2196
  return `${typeof e}:${String(e)}`;
2171
2197
  }
2172
- function It(e, t) {
2198
+ function Rt(e, t) {
2173
2199
  if (!Number.isInteger(e) || e <= 0) throw TypeError(`Vibe ${t} must be a positive integer.`);
2174
2200
  }
2175
- function Lt(e) {
2201
+ function zt(e) {
2176
2202
  if (!e) return;
2177
- if (It(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2178
- At(e, "frontend autofill");
2203
+ if (Rt(e.pageSize, "autofill pageSize"), e.strategy === "frontend") {
2204
+ Mt(e, "frontend autofill");
2179
2205
  let t = e.maxAdditionalPages;
2180
2206
  if (t !== void 0 && t !== "unlimited" && (!Number.isInteger(t) || t < 0)) throw TypeError("Vibe autofill maxAdditionalPages must be a non-negative integer or \"unlimited\".");
2181
2207
  return;
@@ -2187,7 +2213,7 @@ function Lt(e) {
2187
2213
  if (t.pageSize !== e.pageSize) throw TypeError("Vibe backend autofill initialSession pageSize must match autofill pageSize.");
2188
2214
  }
2189
2215
  }
2190
- function Rt(e, t, n = !0) {
2216
+ function Bt(e, t, n = !0) {
2191
2217
  if (!e) return {
2192
2218
  cycleId: null,
2193
2219
  delayRemainingMs: null,
@@ -2221,7 +2247,7 @@ function Rt(e, t, n = !0) {
2221
2247
  strategy: e.strategy
2222
2248
  };
2223
2249
  }
2224
- function zt(e) {
2250
+ function Vt(e) {
2225
2251
  return [
2226
2252
  "cancelling",
2227
2253
  "filling",
@@ -2229,9 +2255,9 @@ function zt(e) {
2229
2255
  "waiting"
2230
2256
  ].includes(e.status);
2231
2257
  }
2232
- async function Bt(e, t, n) {
2258
+ async function Ht(e, t, n) {
2233
2259
  let r = t.autofill;
2234
- if (!zt(r) || !r.cycleId) return;
2260
+ if (!Vt(r) || !r.cycleId) return;
2235
2261
  let i = {
2236
2262
  cycleId: r.cycleId,
2237
2263
  feedKey: r.feedKey ?? "",
@@ -2244,83 +2270,134 @@ async function Bt(e, t, n) {
2244
2270
  throw r.error = e, r.status = "error", e;
2245
2271
  }
2246
2272
  }
2247
- function Vt(e, t, n) {
2273
+ function Ut(e, t, n) {
2248
2274
  return e?.strategy === "backend" && t.feedKey === e.feedKey && t.sessionId === n.sessionId;
2249
2275
  }
2250
- async function Ht({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onDelayChange: i, onProgress: a, options: o, receivedOffset: s = 0, requestOffset: c = 0, signal: l }) {
2251
- let u = [], d = [...e], f = /* @__PURE__ */ new Set(), p = r ?? Pt(o), m = t, h = t, g = 0, _;
2252
- for (; g < p;) {
2253
- let e = Ft(m);
2254
- if (f.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2255
- f.add(e), await Mt({
2256
- delayMs: jt(c + g, o),
2257
- onChange: i,
2258
- signal: l
2276
+ async function Wt({ existingItems: e, initialCursor: t, loadPage: n, maximumRequests: r, onCollection: i, onDelayChange: a, onProgress: o, options: s, receivedOffset: c = 0, requestOffset: l = 0, signal: u }) {
2277
+ let d = [], f = [...e], p = /* @__PURE__ */ new Set(), m = r ?? It(s), h = t, g = t, _ = 0, v;
2278
+ for (; _ < m;) {
2279
+ let e = Lt(h);
2280
+ if (p.has(e)) throw Error("Vibe autofill received a repeated cursor.");
2281
+ p.add(e), await Pt({
2282
+ delayMs: Nt(l + _, s),
2283
+ onChange: a,
2284
+ signal: u
2259
2285
  });
2260
- let t = wt(await n({
2261
- cursor: m,
2262
- signal: l
2286
+ let t = Et(await n({
2287
+ cursor: h,
2288
+ signal: u
2263
2289
  }));
2264
- g += 1;
2265
- let r = Q(d, t.items).slice(d.length);
2266
- d.push(...r), u.push(...r), h = t.next, t.total !== void 0 && (_ = t.total);
2267
- let p = {
2268
- missing: Math.max(0, o.pageSize - s - u.length),
2269
- next: h,
2270
- received: s + u.length,
2271
- requests: c + g
2290
+ _ += 1;
2291
+ let r = Q(f, t.items).slice(f.length);
2292
+ f.push(...r), d.push(...r), g = t.next, t.total !== void 0 && (v = t.total);
2293
+ let m = {
2294
+ missing: Math.max(0, s.pageSize - c - d.length),
2295
+ next: g,
2296
+ received: c + d.length,
2297
+ requests: l + _
2272
2298
  };
2273
- if (a(p), p.missing === 0) return {
2274
- ...p,
2275
- items: u,
2276
- lastCursor: m,
2277
- status: "complete",
2278
- total: _
2299
+ o(m);
2300
+ let y = {
2301
+ ...m,
2302
+ items: [...d],
2303
+ lastCursor: h,
2304
+ total: v
2305
+ };
2306
+ if (i(y), m.missing === 0) return {
2307
+ ...y,
2308
+ status: "complete"
2279
2309
  };
2280
- if (h === null) return {
2281
- ...p,
2282
- items: u,
2283
- lastCursor: m,
2284
- status: "exhausted",
2285
- total: _
2310
+ if (g === null) return {
2311
+ ...y,
2312
+ status: "exhausted"
2286
2313
  };
2287
- m = h;
2314
+ h = g;
2288
2315
  }
2289
2316
  return {
2290
- items: u,
2291
- lastCursor: m,
2292
- missing: Math.max(0, o.pageSize - s - u.length),
2293
- next: h,
2294
- received: s + u.length,
2295
- requests: c + g,
2317
+ items: d,
2318
+ lastCursor: h,
2319
+ missing: Math.max(0, s.pageSize - c - d.length),
2320
+ next: g,
2321
+ received: c + d.length,
2322
+ requests: l + _,
2296
2323
  status: "exhausted",
2297
- total: _
2324
+ total: v
2298
2325
  };
2299
2326
  }
2300
- var Ut = 100;
2301
- function Wt(e, t) {
2327
+ //#endregion
2328
+ //#region src/core/autofillController.ts
2329
+ var Gt = class {
2330
+ collection = null;
2331
+ cycle = 0;
2332
+ delayCountdown;
2333
+ constructor(e) {
2334
+ this.context = e, this.delayCountdown = new Ft((t) => Object.assign(e.state.autofill, t)), this.syncCountdown();
2335
+ }
2336
+ beginCycle() {
2337
+ let { options: e, state: t } = this.context;
2338
+ if (!e) return "";
2339
+ this.clear();
2340
+ let n = `vibe-autofill-${Date.now().toString(36)}-${++this.cycle}`;
2341
+ return t.autofill = {
2342
+ ...Bt(e, void 0, !1),
2343
+ cycleId: n,
2344
+ status: "filling"
2345
+ }, n;
2346
+ }
2347
+ async cancel() {
2348
+ let { cancelRequest: e, options: t, state: n } = this.context;
2349
+ await Ht(t, n, e), this.commitCollection();
2350
+ }
2351
+ captureCollection(e, t) {
2352
+ t && (this.collection = e);
2353
+ }
2354
+ clear() {
2355
+ this.delayCountdown.clear(), this.collection = null;
2356
+ }
2357
+ clearCountdown() {
2358
+ this.delayCountdown.clear();
2359
+ }
2360
+ clearCollection() {
2361
+ this.collection = null;
2362
+ }
2363
+ syncCountdown() {
2364
+ let { autofill: e } = this.context.state;
2365
+ this.delayCountdown.sync(e.strategy === "backend" && e.status === "waiting" ? e.nextRequestAt : null);
2366
+ }
2367
+ commitCollection() {
2368
+ let { onLastCursor: e, options: t, state: n } = this.context;
2369
+ if (t?.strategy !== "frontend") return;
2370
+ let r = this.collection;
2371
+ 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, {
2372
+ missing: r.missing,
2373
+ received: r.received,
2374
+ requests: r.requests
2375
+ }));
2376
+ }
2377
+ }, Kt = 100;
2378
+ function qt(e, t) {
2302
2379
  if (!Number.isFinite(t) || t <= 0) throw TypeError(`Vibe ${e} must be a positive number.`);
2303
2380
  }
2304
- function Gt(e, t, n) {
2381
+ function Jt(e, t, n) {
2305
2382
  return Math.min(n, Math.max(t, e));
2306
2383
  }
2307
- function Kt(e) {
2384
+ function Yt(e) {
2308
2385
  if (!e) return;
2309
2386
  let t = e.minSpeedPxPerSecond ?? 20, n = e.maxSpeedPxPerSecond ?? 240;
2310
- if (Wt("autoScroll.minSpeedPxPerSecond", t), Wt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2311
- e.speedPxPerSecond !== void 0 && Wt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2387
+ if (qt("autoScroll.minSpeedPxPerSecond", t), qt("autoScroll.maxSpeedPxPerSecond", n), t > n) throw TypeError("Vibe autoScroll.minSpeedPxPerSecond cannot exceed maxSpeedPxPerSecond.");
2388
+ e.speedPxPerSecond !== void 0 && qt("autoScroll.speedPxPerSecond", e.speedPxPerSecond);
2312
2389
  }
2313
- function qt(e) {
2390
+ function Xt(e) {
2314
2391
  let t = e?.minSpeedPxPerSecond ?? 20, n = e?.maxSpeedPxPerSecond ?? 240;
2315
2392
  return {
2316
2393
  enabled: e?.enabled ?? !1,
2317
2394
  maxSpeedPxPerSecond: n,
2318
2395
  minSpeedPxPerSecond: t,
2319
2396
  paused: !1,
2320
- speedPxPerSecond: Gt(e?.speedPxPerSecond ?? 80, t, n)
2397
+ speedPxPerSecond: Jt(e?.speedPxPerSecond ?? 80, t, n)
2321
2398
  };
2322
2399
  }
2323
- var Jt = class {
2400
+ var Zt = class {
2324
2401
  frame = null;
2325
2402
  lastTimestamp = null;
2326
2403
  mounted = !1;
@@ -2340,9 +2417,9 @@ var Jt = class {
2340
2417
  this.options.state.enabled && (this.options.state.paused = e, this.lastTimestamp = null, e ? this.cancelFrame() : this.schedule());
2341
2418
  }
2342
2419
  setSpeed(e) {
2343
- Wt("auto-scroll speed", e);
2420
+ qt("auto-scroll speed", e);
2344
2421
  let t = this.options.state;
2345
- t.speedPxPerSecond = Gt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2422
+ t.speedPxPerSecond = Jt(e, t.minSpeedPxPerSecond, t.maxSpeedPxPerSecond);
2346
2423
  }
2347
2424
  tick = (e) => {
2348
2425
  this.frame = null;
@@ -2354,7 +2431,7 @@ var Jt = class {
2354
2431
  return;
2355
2432
  }
2356
2433
  if (this.lastTimestamp !== null) {
2357
- let r = Math.min(Ut, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2434
+ let r = Math.min(Kt, Math.max(0, e - this.lastTimestamp)), i = Math.max(0, n.scrollHeight - n.clientHeight);
2358
2435
  n.scrollTop = Math.min(i, n.scrollTop + t.speedPxPerSecond * r / 1e3);
2359
2436
  }
2360
2437
  this.lastTimestamp = e, this.schedule();
@@ -2368,7 +2445,7 @@ var Jt = class {
2368
2445
  };
2369
2446
  //#endregion
2370
2447
  //#region src/core/backendAutofill.ts
2371
- async function Yt(e, t, n, r) {
2448
+ async function Qt(e, t, n, r) {
2372
2449
  let i = await e.onUnderfilled(n);
2373
2450
  if (!r()) return;
2374
2451
  if (!i.sessionId.trim()) throw TypeError("Vibe backend autofill requires a sessionId.");
@@ -2382,80 +2459,81 @@ async function Yt(e, t, n, r) {
2382
2459
  status: "waiting"
2383
2460
  });
2384
2461
  }
2385
- function Xt(e, t) {
2462
+ function $t(e, t) {
2386
2463
  ["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);
2387
2464
  }
2388
- function Zt(e, t, n) {
2465
+ function en(e, t, n) {
2389
2466
  let r = t.autofill;
2390
- return !Vt(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : (Xt(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);
2467
+ return !Ut(e, n, r) || n.sequence <= r.sequence || ["cancelled", "cancelling"].includes(r.status) || ["complete", "exhausted"].includes(n.status) && n.next === void 0 ? !1 : ($t(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);
2391
2468
  }
2392
- function Qt(e, t, n) {
2393
- return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Rt(e, n), Xt(t, n), !0);
2469
+ function tn(e, t, n) {
2470
+ return e?.strategy !== "backend" || n.feedKey !== e.feedKey || n.pageSize !== e.pageSize ? !1 : (t.autofill = Bt(e, n), $t(t, n), !0);
2394
2471
  }
2395
2472
  //#endregion
2396
2473
  //#region src/core/initialAutofill.ts
2397
- async function $t({ cycleId: e, isCurrent: t, onLastCursor: n, options: r, signal: i, state: a }) {
2398
- let o = r.autofill;
2399
- if (!o) return;
2400
- let s = a.items.length;
2401
- if (Object.assign(a.autofill, {
2402
- missing: Math.max(0, o.pageSize - s),
2403
- received: s,
2474
+ async function nn({ cycleId: e, isCurrent: t, onCollection: n, onLastCursor: r, options: i, signal: a, state: o }) {
2475
+ let s = i.autofill;
2476
+ if (!s) return;
2477
+ let c = o.items.length;
2478
+ if (Object.assign(o.autofill, {
2479
+ missing: Math.max(0, s.pageSize - c),
2480
+ received: c,
2404
2481
  requests: 1
2405
- }), s >= o.pageSize) {
2406
- a.autofill.status = "complete";
2482
+ }), c >= s.pageSize) {
2483
+ o.autofill.status = "complete";
2407
2484
  return;
2408
2485
  }
2409
- if (o.strategy === "backend") {
2410
- await Yt(o, a, {
2486
+ if (s.strategy === "backend") {
2487
+ await Qt(s, o, {
2411
2488
  cycleId: e,
2412
- feedKey: o.feedKey,
2413
- items: [...a.items],
2414
- missing: o.pageSize - s,
2415
- next: a.next,
2416
- pageSize: o.pageSize,
2417
- received: s,
2418
- signal: i,
2419
- total: a.total
2489
+ feedKey: s.feedKey,
2490
+ items: [...o.items],
2491
+ missing: s.pageSize - c,
2492
+ next: o.next,
2493
+ pageSize: s.pageSize,
2494
+ received: c,
2495
+ signal: a,
2496
+ total: o.total
2420
2497
  }, t);
2421
2498
  return;
2422
2499
  }
2423
- if (!r.loadPage || a.next === null) {
2424
- a.autofill.status = "exhausted";
2500
+ if (!i.loadPage || o.next === null) {
2501
+ o.autofill.status = "exhausted";
2425
2502
  return;
2426
2503
  }
2427
- let c = await Ht({
2428
- existingItems: a.items,
2429
- initialCursor: a.next,
2430
- loadPage: r.loadPage,
2431
- maximumRequests: Pt(o, !1),
2504
+ let l = await Wt({
2505
+ existingItems: o.items,
2506
+ initialCursor: o.next,
2507
+ loadPage: i.loadPage,
2508
+ maximumRequests: It(s, !1),
2509
+ onCollection: n,
2432
2510
  onDelayChange: (e) => {
2433
- t() && Object.assign(a.autofill, e);
2511
+ t() && Object.assign(o.autofill, e);
2434
2512
  },
2435
2513
  onProgress: (e) => {
2436
- t() && Object.assign(a.autofill, e, { status: "filling" });
2514
+ t() && Object.assign(o.autofill, e, { status: "filling" });
2437
2515
  },
2438
- options: o,
2439
- receivedOffset: s,
2516
+ options: s,
2517
+ receivedOffset: c,
2440
2518
  requestOffset: 1,
2441
- signal: i
2519
+ signal: a
2442
2520
  });
2443
- t() && (a.items = Q(a.items, c.items), a.next = c.next, c.total !== void 0 && (a.total = c.total), n(c.lastCursor), Object.assign(a.autofill, {
2444
- missing: c.missing,
2445
- received: c.received,
2446
- requests: c.requests,
2447
- status: c.status
2521
+ 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, {
2522
+ missing: l.missing,
2523
+ received: l.received,
2524
+ requests: l.requests,
2525
+ status: l.status
2448
2526
  }));
2449
2527
  }
2450
2528
  //#endregion
2451
2529
  //#region src/core/fill.ts
2452
- function en(e) {
2530
+ function rn(e) {
2453
2531
  return "pages" in e ? { pages: e.pages } : { until: "end" };
2454
2532
  }
2455
- function tn(e) {
2533
+ function an(e) {
2456
2534
  return `${typeof e}:${String(e)}`;
2457
2535
  }
2458
- function nn(e) {
2536
+ function on(e) {
2459
2537
  if (!e || typeof e != "object") throw TypeError("Vibe fill target must be an object.");
2460
2538
  if ("pages" in e) {
2461
2539
  if (!Number.isInteger(e.pages) || e.pages <= 0) throw TypeError("Vibe fill pages must be a positive integer.");
@@ -2464,20 +2542,20 @@ function nn(e) {
2464
2542
  if ("until" in e && e.until === "end") return { until: "end" };
2465
2543
  throw TypeError("Vibe fill target must be { pages } or { until: 'end' }.");
2466
2544
  }
2467
- function rn(e) {
2545
+ function sn(e) {
2468
2546
  if (!e) return;
2469
2547
  if (e.strategy === "frontend") {
2470
- At(e, "frontend fill");
2548
+ Mt(e, "frontend fill");
2471
2549
  return;
2472
2550
  }
2473
2551
  if (!e.feedKey.trim()) throw TypeError("Vibe backend fill requires a feedKey.");
2474
2552
  let t = e.initialSession;
2475
2553
  if (t) {
2476
2554
  if (t.feedKey !== e.feedKey) throw TypeError("Vibe backend fill initialSession feedKey must match fill feedKey.");
2477
- nn(t.target);
2555
+ on(t.target);
2478
2556
  }
2479
2557
  }
2480
- function an(e, t, n = !0) {
2558
+ function cn(e, t, n = !0) {
2481
2559
  let r = e?.strategy === "backend" && n ? e.initialSession : void 0, i = t ?? r, a = $(i?.nextRequestAt);
2482
2560
  return {
2483
2561
  completedPages: i?.completedPages ?? 0,
@@ -2491,10 +2569,10 @@ function an(e, t, n = !0) {
2491
2569
  sessionId: i?.sessionId ?? null,
2492
2570
  status: i?.status ?? "idle",
2493
2571
  strategy: e?.strategy ?? null,
2494
- target: i ? en(i.target) : null
2572
+ target: i ? rn(i.target) : null
2495
2573
  };
2496
2574
  }
2497
- function on(e) {
2575
+ function ln(e) {
2498
2576
  return [
2499
2577
  "cancelling",
2500
2578
  "filling",
@@ -2502,17 +2580,17 @@ function on(e) {
2502
2580
  "waiting"
2503
2581
  ].includes(e.status);
2504
2582
  }
2505
- async function sn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2583
+ async function un({ existingItems: e, initialCursor: t, loadPage: n, onDelayChange: r, onProgress: i, options: a, signal: o, target: s }) {
2506
2584
  let c = [], l = [...e], u = /* @__PURE__ */ new Set(), d = 0, f = t, p = t, m = 0, h;
2507
2585
  for (; p !== null;) {
2508
- let e = tn(f);
2586
+ let e = an(f);
2509
2587
  if (u.has(e)) throw Error("Vibe fill received a repeated cursor.");
2510
- u.add(e), await Mt({
2511
- delayMs: jt(d, a),
2588
+ u.add(e), await Pt({
2589
+ delayMs: Nt(d, a),
2512
2590
  onChange: r,
2513
2591
  signal: o
2514
2592
  });
2515
- let t = wt(await n({
2593
+ let t = Et(await n({
2516
2594
  cursor: f,
2517
2595
  signal: o
2518
2596
  }));
@@ -2554,7 +2632,7 @@ async function sn({ existingItems: e, initialCursor: t, loadPage: n, onDelayChan
2554
2632
  }
2555
2633
  //#endregion
2556
2634
  //#region src/core/backendFill.ts
2557
- async function cn(e, t, n, r) {
2635
+ async function dn(e, t, n, r) {
2558
2636
  let i = await e.onStart(n);
2559
2637
  if (r()) {
2560
2638
  if (!i.sessionId.trim()) throw TypeError("Vibe backend fill requires a sessionId.");
@@ -2568,22 +2646,22 @@ async function cn(e, t, n, r) {
2568
2646
  });
2569
2647
  }
2570
2648
  }
2571
- function ln(e, t, n) {
2649
+ function fn(e, t, n) {
2572
2650
  return e?.strategy === "backend" && n.feedKey === e.feedKey && n.sessionId === t.fill.sessionId;
2573
2651
  }
2574
- function un(e) {
2652
+ function pn(e) {
2575
2653
  return Number.isInteger(e.completedPages) && e.completedPages >= 0 && Number.isInteger(e.received) && e.received >= 0 && Number.isInteger(e.sequence) && e.sequence >= 0;
2576
2654
  }
2577
- function dn(e, t) {
2655
+ function mn(e, t) {
2578
2656
  if (!["complete", "exhausted"].includes(t.status)) return !0;
2579
2657
  let n = e.fill.target;
2580
2658
  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;
2581
2659
  }
2582
- function fn(e, t, n) {
2660
+ function hn(e, t, n) {
2583
2661
  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));
2584
2662
  }
2585
- function pn(e, t, n, r) {
2586
- return !ln(e, t, n) || !un(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !dn(t, n) ? !1 : (fn(t, n, r), Object.assign(t.fill, {
2663
+ function gn(e, t, n, r) {
2664
+ return !fn(e, t, n) || !pn(n) || n.sequence <= t.fill.sequence || ["cancelled", "cancelling"].includes(t.fill.status) || !mn(t, n) ? !1 : (hn(t, n, r), Object.assign(t.fill, {
2587
2665
  ...$(n.status === "waiting" ? n.nextRequestAt : null),
2588
2666
  completedPages: n.completedPages,
2589
2667
  error: n.error ?? null,
@@ -2592,41 +2670,41 @@ function pn(e, t, n, r) {
2592
2670
  status: n.status
2593
2671
  }), !0);
2594
2672
  }
2595
- function mn(e, t, n, r) {
2673
+ function _n(e, t, n, r) {
2596
2674
  if (e?.strategy !== "backend" || n.feedKey !== e.feedKey) return !1;
2597
2675
  let i = t.fill;
2598
- return t.fill = an(e, n), !un(n) || !dn(t, n) ? (t.fill = i, !1) : (fn(t, n, r), !0);
2676
+ return t.fill = cn(e, n), !pn(n) || !mn(t, n) ? (t.fill = i, !1) : (hn(t, n, r), !0);
2599
2677
  }
2600
2678
  //#endregion
2601
2679
  //#region src/core/fillController.ts
2602
- var hn = class {
2680
+ var vn = class {
2603
2681
  abortController = null;
2604
2682
  cycle = 0;
2605
2683
  delayCountdown;
2606
2684
  requestVersion = 0;
2607
2685
  constructor(e) {
2608
- this.options = e, this.delayCountdown = new Nt((e) => {
2686
+ this.options = e, this.delayCountdown = new Ft((e) => {
2609
2687
  Object.assign(this.options.state.fill, e);
2610
2688
  }), this.syncBackendCountdown();
2611
2689
  }
2612
2690
  isActive() {
2613
- return on(this.options.state.fill);
2691
+ return ln(this.options.state.fill);
2614
2692
  }
2615
2693
  applyUpdate(e) {
2616
- let t = pn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2694
+ let t = gn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2617
2695
  return t && this.syncBackendCountdown(), t;
2618
2696
  }
2619
2697
  restoreSession(e) {
2620
- let t = mn(this.options.fill, this.options.state, e, this.options.onLastCursor);
2698
+ let t = _n(this.options.fill, this.options.state, e, this.options.onLastCursor);
2621
2699
  return t && this.syncBackendCountdown(), t;
2622
2700
  }
2623
2701
  async start(e) {
2624
2702
  let t = this.options.fill;
2625
2703
  if (!t) throw Error("Vibe fill is not configured.");
2626
2704
  if (this.isActive()) throw Error("Vibe fill is already active.");
2627
- let n = nn(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2705
+ let n = on(e), r = `vibe-fill-${Date.now().toString(36)}-${++this.cycle}`;
2628
2706
  if (this.options.state.fill = {
2629
- ...an(t, void 0, !1),
2707
+ ...cn(t, void 0, !1),
2630
2708
  cycleId: r,
2631
2709
  status: "filling",
2632
2710
  target: n
@@ -2637,7 +2715,7 @@ var hn = class {
2637
2715
  let i = ++this.requestVersion, a = new AbortController();
2638
2716
  this.abortController = a;
2639
2717
  try {
2640
- t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await cn(t, this.options.state, {
2718
+ t.strategy === "frontend" ? await this.startFrontend(t, n, a, i) : (await dn(t, this.options.state, {
2641
2719
  cycleId: r,
2642
2720
  feedKey: t.feedKey,
2643
2721
  items: [...this.options.state.items],
@@ -2655,7 +2733,7 @@ var hn = class {
2655
2733
  }
2656
2734
  async cancel() {
2657
2735
  let { fill: e, state: t } = this.options;
2658
- if (!on(t.fill) || !t.fill.cycleId) return;
2736
+ if (!ln(t.fill) || !t.fill.cycleId) return;
2659
2737
  let n = {
2660
2738
  cycleId: t.fill.cycleId,
2661
2739
  feedKey: t.fill.feedKey ?? "",
@@ -2669,7 +2747,7 @@ var hn = class {
2669
2747
  }
2670
2748
  }
2671
2749
  reset() {
2672
- this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = an(this.options.fill, void 0, !1);
2750
+ this.abortLocalRequest(), this.delayCountdown.clear(), this.options.state.fill = cn(this.options.fill, void 0, !1);
2673
2751
  }
2674
2752
  destroy() {
2675
2753
  this.abortLocalRequest(), this.delayCountdown.clear();
@@ -2685,7 +2763,7 @@ var hn = class {
2685
2763
  if (!i) throw Error("Vibe frontend fill requires loadPage.");
2686
2764
  let a = this.options.state;
2687
2765
  a.isLoadingMore = !0;
2688
- let o = await sn({
2766
+ let o = await un({
2689
2767
  existingItems: a.items,
2690
2768
  initialCursor: a.next,
2691
2769
  loadPage: i,
@@ -2712,7 +2790,7 @@ var hn = class {
2712
2790
  };
2713
2791
  //#endregion
2714
2792
  //#region src/core/feedFooter.ts
2715
- function gn(e) {
2793
+ function yn(e) {
2716
2794
  return {
2717
2795
  cancelAutofill: () => e.cancelAutofill(),
2718
2796
  loadMore: () => e.loadNext(),
@@ -2720,45 +2798,45 @@ function gn(e) {
2720
2798
  retryEnd: () => e.retryEnd()
2721
2799
  };
2722
2800
  }
2723
- function _n(e) {
2801
+ function bn(e) {
2724
2802
  if (!Number.isFinite(e) || e <= 0) throw TypeError("Vibe reelAutoAdvance.intervalMs must be a positive number.");
2725
2803
  }
2726
- function vn(e) {
2727
- e?.intervalMs !== void 0 && _n(e.intervalMs);
2804
+ function xn(e) {
2805
+ e?.intervalMs !== void 0 && bn(e.intervalMs);
2728
2806
  }
2729
- function yn(e) {
2807
+ function Sn(e) {
2730
2808
  return {
2731
2809
  enabled: e?.enabled ?? !1,
2732
2810
  includePostItems: e?.includePostItems ?? !1,
2733
2811
  intervalMs: e?.intervalMs ?? 5e3
2734
2812
  };
2735
2813
  }
2736
- function bn(e, t) {
2814
+ function Cn(e, t) {
2737
2815
  if (typeof t == "boolean") {
2738
2816
  e.enabled = t;
2739
2817
  return;
2740
2818
  }
2741
- vn(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);
2819
+ xn(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);
2742
2820
  }
2743
2821
  //#endregion
2744
2822
  //#region src/core/reelInfoSheet.ts
2745
- function xn(e) {
2823
+ function wn(e) {
2746
2824
  return { enabled: e?.enabled ?? !1 };
2747
2825
  }
2748
- function Sn(e, t, n) {
2826
+ function Tn(e, t, n) {
2749
2827
  if (n && !t) throw Error("Vibe cannot enable reelInfoSheet without a configured component.");
2750
2828
  e.enabled = n;
2751
2829
  }
2752
2830
  //#endregion
2753
2831
  //#region src/core/initialRuntimeState.ts
2754
- function Cn(e, t) {
2832
+ function En(e, t) {
2755
2833
  let n = e.initialPage;
2756
2834
  return {
2757
2835
  activeReelPostId: null,
2758
- autoScroll: qt(e.autoScroll),
2759
- autofill: Rt(e.autofill),
2836
+ autoScroll: Xt(e.autoScroll),
2837
+ autofill: Bt(e.autofill),
2760
2838
  error: null,
2761
- fill: an(e.fill),
2839
+ fill: cn(e.fill),
2762
2840
  infiniteScroll: e.infiniteScroll ?? !0,
2763
2841
  isLoading: !n,
2764
2842
  isLoadingMore: !1,
@@ -2768,14 +2846,14 @@ function Cn(e, t) {
2768
2846
  mediaIndices: /* @__PURE__ */ new Map(),
2769
2847
  next: n?.next ?? null,
2770
2848
  nextPageError: null,
2771
- reelAutoAdvance: yn(e.reelAutoAdvance),
2849
+ reelAutoAdvance: Sn(e.reelAutoAdvance),
2772
2850
  reelForward: {
2773
2851
  error: null,
2774
2852
  status: "idle"
2775
2853
  },
2776
2854
  reelForwardIndex: null,
2777
2855
  reelForwardItem: null,
2778
- reelInfoSheet: xn(e.reelInfoSheet),
2856
+ reelInfoSheet: wn(e.reelInfoSheet),
2779
2857
  reelInfoSheetOverlay: !1,
2780
2858
  reelMediaSource: "original",
2781
2859
  reelOrigin: null,
@@ -2784,26 +2862,26 @@ function Cn(e, t) {
2784
2862
  }
2785
2863
  //#endregion
2786
2864
  //#region src/core/options.ts
2787
- function wn(e, t) {
2865
+ function Dn(e, t) {
2788
2866
  if (t) {
2789
2867
  if (!Number.isFinite(t.height) || t.height <= 0) throw TypeError(`Vibe ${e} height must be a positive number.`);
2790
2868
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe ${e} background must be "default" or "transparent".`);
2791
2869
  }
2792
2870
  }
2793
- function Tn(e, t) {
2871
+ function On(e, t) {
2794
2872
  if (t) {
2795
2873
  if (t.background !== void 0 && t.background !== "default" && t.background !== "transparent") throw TypeError(`Vibe mediaCard ${e} background must be "default" or "transparent".`);
2796
2874
  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.`);
2797
2875
  }
2798
2876
  }
2799
- function En(e) {
2800
- if (Kt(e.autoScroll), wn("cardHeader", e.cardHeader), wn("cardFooter", e.cardFooter), Tn("header", e.mediaCard?.header), Tn("footer", e.mediaCard?.footer), Lt(e.autofill), rn(e.fill), vn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2877
+ function kn(e) {
2878
+ if (Yt(e.autoScroll), Dn("cardHeader", e.cardHeader), Dn("cardFooter", e.cardFooter), On("header", e.mediaCard?.header), On("footer", e.mediaCard?.footer), zt(e.autofill), sn(e.fill), xn(e.reelAutoAdvance), e.removalHistoryLimit !== void 0 && (!Number.isInteger(e.removalHistoryLimit) || e.removalHistoryLimit < 0)) throw TypeError("Vibe removalHistoryLimit must be a non-negative integer.");
2801
2879
  if (!e.initialPage && !e.loadPage) throw TypeError("Vibe requires either initialPage or loadPage.");
2802
2880
  if (e.initialPage?.next !== null && !e.loadPage) throw TypeError("Vibe requires loadPage when initialPage has a next cursor.");
2803
2881
  if (e.fill?.strategy === "frontend" && !e.loadPage) throw TypeError("Vibe frontend fill requires loadPage.");
2804
2882
  if (e.fill?.strategy === "backend" && e.fill.initialSession && !e.initialPage) throw TypeError("Vibe backend fill restoration requires initialPage.");
2805
2883
  }
2806
- function Dn(e) {
2884
+ function An(e) {
2807
2885
  if (typeof e != "string") return e;
2808
2886
  if (typeof document > "u") throw Error("Vibe cannot resolve a selector without a document.");
2809
2887
  let t = document.querySelector(e);
@@ -2812,7 +2890,7 @@ function Dn(e) {
2812
2890
  }
2813
2891
  //#endregion
2814
2892
  //#region src/core/activeItemRemoval.ts
2815
- function On(e, t, n, r, i) {
2893
+ function jn(e, t, n, r, i) {
2816
2894
  let a = new Set(t.map(({ item: e }) => e.postId));
2817
2895
  if (e.activeReelPostId === null || !a.has(e.activeReelPostId)) return;
2818
2896
  let o = e.items[Math.max(n, 0)];
@@ -2825,7 +2903,7 @@ function On(e, t, n, r, i) {
2825
2903
  }
2826
2904
  //#endregion
2827
2905
  //#region src/core/exactMediaRemovalController.ts
2828
- function kn(e, t) {
2906
+ function Mn(e, t) {
2829
2907
  let [n, ...r] = t;
2830
2908
  if (!n) throw Error("Vibe items must contain at least one media asset.");
2831
2909
  return {
@@ -2834,10 +2912,10 @@ function kn(e, t) {
2834
2912
  items: r
2835
2913
  };
2836
2914
  }
2837
- function An(e) {
2915
+ function Nn(e) {
2838
2916
  if (!Number.isInteger(e.mediaIndex) || e.mediaIndex < 0) throw TypeError("Vibe mediaIndex must be a non-negative integer.");
2839
2917
  }
2840
- var jn = class {
2918
+ var Pn = class {
2841
2919
  generation = 0;
2842
2920
  metadata = /* @__PURE__ */ new WeakMap();
2843
2921
  state;
@@ -2845,10 +2923,10 @@ var jn = class {
2845
2923
  this.options = e, this.state = e.state;
2846
2924
  }
2847
2925
  remove(e) {
2848
- An(e);
2926
+ Nn(e);
2849
2927
  let t = this.state.items.findIndex(({ postId: t }) => t === e.postId), n = this.state.items[t];
2850
2928
  if (!n) return null;
2851
- let r = [...j(n)], i = r[e.mediaIndex];
2929
+ let r = [...M(n)], i = r[e.mediaIndex];
2852
2930
  if (!i) return null;
2853
2931
  let a = Object.freeze({
2854
2932
  media: i,
@@ -2862,7 +2940,7 @@ var jn = class {
2862
2940
  restored: !1
2863
2941
  });
2864
2942
  let o = this.state.mediaIndices.get(n.postId) ?? 0, s = this.isReelOpen() && this.state.activeReelPostId === n.postId, c = s && o === e.mediaIndex;
2865
- return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = kn(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);
2943
+ return r.splice(e.mediaIndex, 1), r.length > 0 ? (this.state.items[t] = Mn(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);
2866
2944
  }
2867
2945
  reset() {
2868
2946
  this.generation += 1;
@@ -2887,32 +2965,32 @@ var jn = class {
2887
2965
  return this.state.layout === "reel" || this.state.reelOrigin === "masonry";
2888
2966
  }
2889
2967
  restoreIntoPost(e, t) {
2890
- let n = this.state.items[e], r = [...j(n)], i = Math.min(t.mediaIndex, r.length);
2891
- if (r.splice(i, 0, t.media), this.state.items[e] = kn(n, r), this.state.activeReelPostId !== t.postId) return;
2968
+ let n = this.state.items[e], r = [...M(n)], i = Math.min(t.mediaIndex, r.length);
2969
+ if (r.splice(i, 0, t.media), this.state.items[e] = Mn(n, r), this.state.activeReelPostId !== t.postId) return;
2892
2970
  let a = this.state.mediaIndices.get(t.postId) ?? 0;
2893
2971
  a >= i && this.state.mediaIndices.set(t.postId, a + 1);
2894
2972
  }
2895
2973
  updateMediaIndexAfterRemoval(e, t, n) {
2896
2974
  let r = this.state.items.find((t) => t.postId === e);
2897
2975
  if (!r) return;
2898
- let i = j(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
2976
+ let i = M(r).length, a = this.state.mediaIndices.get(e) ?? 0, o = a;
2899
2977
  n ? o = t < i ? t : 0 : t < a && (o = a - 1), this.state.mediaIndices.set(e, Math.min(o, i - 1));
2900
2978
  }
2901
2979
  };
2902
2980
  //#endregion
2903
2981
  //#region src/core/itemPlacement.ts
2904
- function Mn(e, t) {
2982
+ function Fn(e, t) {
2905
2983
  let n = new Set(t);
2906
2984
  return e.flatMap((e, t) => n.has(e.postId) ? [{
2907
2985
  index: t,
2908
2986
  item: e
2909
2987
  }] : []);
2910
2988
  }
2911
- function Nn(e, t) {
2989
+ function In(e, t) {
2912
2990
  let n = new Set(t.map(({ item: e }) => e.postId));
2913
2991
  return e.filter((e) => !n.has(e.postId));
2914
2992
  }
2915
- function Pn(e, t) {
2993
+ function Ln(e, t) {
2916
2994
  t.forEach(({ index: e }) => {
2917
2995
  if (!Number.isInteger(e) || e < 0) throw Error("Vibe item restore indexes must be non-negative integers.");
2918
2996
  });
@@ -2923,7 +3001,7 @@ function Pn(e, t) {
2923
3001
  }
2924
3002
  //#endregion
2925
3003
  //#region src/core/itemRemovalController.ts
2926
- var Fn = 20, In = class {
3004
+ var Rn = 20, zn = class {
2927
3005
  generation = 0;
2928
3006
  historyLimit;
2929
3007
  metadata = /* @__PURE__ */ new WeakMap();
@@ -2932,7 +3010,7 @@ var Fn = 20, In = class {
2932
3010
  itemOrder;
2933
3011
  stopItemsWatcher;
2934
3012
  constructor(e) {
2935
- this.options = e, this.historyLimit = e.historyLimit ?? Fn, 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" });
3013
+ this.options = e, this.historyLimit = e.historyLimit ?? Rn, 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" });
2936
3014
  }
2937
3015
  destroy() {
2938
3016
  this.reset(), this.stopItemsWatcher();
@@ -2945,7 +3023,7 @@ var Fn = 20, In = class {
2945
3023
  let i = this.options.startRemoval(r);
2946
3024
  if (i > 0 && await new Promise((e) => setTimeout(e, i)), this.metadata.get(n)?.generation !== this.generation) return n;
2947
3025
  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);
2948
- return this.state.items = Nn(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
3026
+ return this.state.items = In(this.state.items, t), this.options.onItemsRemoved(n, t, c), this.record(n), n;
2949
3027
  }
2950
3028
  reset() {
2951
3029
  this.generation += 1, this.history = [], this.itemOrder = [];
@@ -2956,7 +3034,7 @@ var Fn = 20, In = class {
2956
3034
  this.restoreRemoval(t);
2957
3035
  return;
2958
3036
  }
2959
- let n = Pn(this.state.items, e);
3037
+ let n = Ln(this.state.items, e);
2960
3038
  this.registerExternalPlacements(e), this.state.items = n;
2961
3039
  }
2962
3040
  restoreRemoval(e) {
@@ -2982,7 +3060,7 @@ var Fn = 20, In = class {
2982
3060
  }
2983
3061
  collectOrderedPlacements(e) {
2984
3062
  let t = new Map(this.itemOrder.map((e, t) => [e, t]));
2985
- return Mn(this.state.items, e).map((e) => ({
3063
+ return Fn(this.state.items, e).map((e) => ({
2986
3064
  index: t.get(e.item.postId) ?? e.index,
2987
3065
  item: e.item
2988
3066
  }));
@@ -3013,7 +3091,7 @@ var Fn = 20, In = class {
3013
3091
  let r = new Map(this.itemOrder.map((e, t) => [e, t]));
3014
3092
  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;
3015
3093
  }
3016
- }, Ln = class {
3094
+ }, Bn = class {
3017
3095
  forward = null;
3018
3096
  forwardPromise = null;
3019
3097
  forwardVersion = 0;
@@ -3091,7 +3169,7 @@ var Fn = 20, In = class {
3091
3169
  }
3092
3170
  }
3093
3171
  }
3094
- }, Rn = class {
3172
+ }, Vn = class {
3095
3173
  generation = 0;
3096
3174
  pending = Promise.resolve();
3097
3175
  constructor(e) {
@@ -3108,7 +3186,7 @@ var Fn = 20, In = class {
3108
3186
  if (!n) return;
3109
3187
  let r = t.mediaIndices.get(e.postId) ?? 0;
3110
3188
  if (e.mediaIndex === r) {
3111
- if (j(n).length > 1) {
3189
+ if (M(n).length > 1) {
3112
3190
  await this.options.transitionMedia(1);
3113
3191
  return;
3114
3192
  }
@@ -3141,22 +3219,22 @@ var Fn = 20, In = class {
3141
3219
  };
3142
3220
  //#endregion
3143
3221
  //#region src/core/removalControllers.ts
3144
- function zn(e) {
3145
- let t = new Ln(e), n = new Rn({
3222
+ function Hn(e) {
3223
+ let t = new Bn(e), n = new Vn({
3146
3224
  state: e.state,
3147
3225
  transitionMedia: (t) => e.surface()?.transitionActiveReelMedia(t) ?? Promise.resolve(!1),
3148
3226
  transitionPost: (t) => e.surface()?.transitionActiveReelPost(t) ?? Promise.resolve(!1)
3149
3227
  });
3150
3228
  return {
3151
- exactMediaRemoval: new jn({
3229
+ exactMediaRemoval: new Pn({
3152
3230
  onActivate: e.onActivate,
3153
3231
  reelForward: t,
3154
3232
  state: e.state
3155
3233
  }),
3156
- itemRemoval: new In({
3234
+ itemRemoval: new zn({
3157
3235
  historyLimit: e.historyLimit,
3158
3236
  onItemsRemoved: (n, r, i) => {
3159
- On(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3237
+ jn(e.state, r, i, e.onActivate, (e, r) => t.start(n, e, r));
3160
3238
  },
3161
3239
  onRemovalRestored: (n) => {
3162
3240
  let r = t.cancel(n);
@@ -3170,17 +3248,17 @@ function zn(e) {
3170
3248
  reelRemoval: n
3171
3249
  };
3172
3250
  }
3173
- var Bn = 1.5;
3174
- function Vn(e) {
3251
+ var Un = 1.5;
3252
+ function Wn(e) {
3175
3253
  let t = Math.min(e.screenWidth, e.screenHeight);
3176
3254
  if (t > 0 && t < 600) return !0;
3177
- let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Bn;
3255
+ let n = Math.min(e.viewportWidth, e.viewportHeight), r = t >= n * Un;
3178
3256
  return !e.hasHover && n > 0 && n < 600 && r;
3179
3257
  }
3180
- function Hn(e) {
3181
- return Vn(e) ? "reel" : "masonry";
3258
+ function Gn(e) {
3259
+ return Wn(e) ? "reel" : "masonry";
3182
3260
  }
3183
- function Un(e) {
3261
+ function Kn(e) {
3184
3262
  let t = e.ownerDocument.defaultView, n = e.ownerDocument.documentElement;
3185
3263
  return {
3186
3264
  hasHover: typeof t?.matchMedia == "function" && t.matchMedia("(hover: hover)").matches,
@@ -3190,15 +3268,15 @@ function Un(e) {
3190
3268
  viewportWidth: n.clientWidth
3191
3269
  };
3192
3270
  }
3193
- function Wn(e) {
3194
- return Vn(Un(e));
3271
+ function qn(e) {
3272
+ return Wn(Kn(e));
3195
3273
  }
3196
- function Gn(e) {
3197
- return Hn(Un(e));
3274
+ function Jn(e) {
3275
+ return Gn(Kn(e));
3198
3276
  }
3199
3277
  //#endregion
3200
3278
  //#region src/core/responsiveLayoutController.ts
3201
- var Kn = class {
3279
+ var Yn = class {
3202
3280
  layoutMode;
3203
3281
  resizeObserver = null;
3204
3282
  target = null;
@@ -3223,10 +3301,10 @@ var Kn = class {
3223
3301
  }
3224
3302
  handleResponsiveLayout = () => {
3225
3303
  if (!this.target) return;
3226
- let e = Gn(this.target);
3227
- this.state.reelInfoSheetOverlay = Wn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3304
+ let e = Jn(this.target);
3305
+ this.state.reelInfoSheetOverlay = qn(this.target), this.state.reelMediaSource = e === "reel" ? "preview" : "original", this.layoutMode === "responsive" && this.applyLayout(e);
3228
3306
  };
3229
- }, qn = class {
3307
+ }, Xn = class {
3230
3308
  routedReelPostId = null;
3231
3309
  reelRouteIsActive = !1;
3232
3310
  constructor(e, t) {
@@ -3253,11 +3331,10 @@ var Kn = class {
3253
3331
  let i = this.reelRouteIsActive ? "replace" : "push";
3254
3332
  this.reelRouteIsActive = !0, this.routedReelPostId = e, this.options.router[i](r);
3255
3333
  }
3256
- }, Jn = class {
3334
+ }, Zn = class {
3257
3335
  app = null;
3258
3336
  autoScroll;
3259
- autofillDelayCountdown;
3260
- autofillCycle = 0;
3337
+ autofillController;
3261
3338
  abortController = null;
3262
3339
  pendingRequest = null;
3263
3340
  requestVersion = 0;
@@ -3273,20 +3350,27 @@ var Kn = class {
3273
3350
  lastLoadedCursor = null;
3274
3351
  state;
3275
3352
  constructor(e) {
3276
- this.options = e, En(e);
3353
+ this.options = e, kn(e);
3277
3354
  let t = e.layout ?? "masonry";
3278
- this.state = b(Cn(e, t)), this.autoScroll = new Jt({
3355
+ this.state = x(En(e, t)), this.autoScroll = new Zt({
3279
3356
  getScrollElement: () => this.surface?.getAutoScrollElement() ?? null,
3280
3357
  state: this.state.autoScroll
3281
- }), this.autofillDelayCountdown = new Nt((e) => Object.assign(this.state.autofill, e)), this.syncAutofillCountdown(), this.fillController = new hn({
3358
+ }), this.autofillController = new Gt({
3359
+ cancelRequest: () => this.cancelRequest(),
3360
+ onLastCursor: (e) => {
3361
+ this.lastLoadedCursor = e;
3362
+ },
3363
+ options: e.autofill,
3364
+ state: this.state
3365
+ }), this.fillController = new vn({
3282
3366
  fill: e.fill,
3283
3367
  loadPage: e.loadPage,
3284
3368
  onLastCursor: (e) => {
3285
3369
  this.lastLoadedCursor = e;
3286
3370
  },
3287
3371
  state: this.state
3288
- }), this.routing = new qn(e.routing, this.state);
3289
- let n = zn({
3372
+ }), this.routing = new Xn(e.routing, this.state);
3373
+ let n = Hn({
3290
3374
  historyLimit: e.removalHistoryLimit,
3291
3375
  loadNext: () => this.loadNext(),
3292
3376
  onActivate: (e) => this.setActiveReelPost(e),
@@ -3294,20 +3378,20 @@ var Kn = class {
3294
3378
  state: this.state,
3295
3379
  surface: () => this.surface
3296
3380
  });
3297
- this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Kn(t, this.state, () => {
3381
+ this.exactMediaRemoval = n.exactMediaRemoval, this.itemRemoval = n.itemRemoval, this.reelForward = n.reelForward, this.reelRemoval = n.reelRemoval, this.responsiveLayout = new Yn(t, this.state, () => {
3298
3382
  this.routing.syncFeed();
3299
3383
  }), this.startStateNotifications();
3300
3384
  }
3301
3385
  async mount() {
3302
3386
  if (this.app) throw Error("Vibe is already mounted.");
3303
3387
  this.startStateNotifications();
3304
- let e = Dn(this.options.target);
3305
- this.responsiveLayout.mount(e), this.app = r(Ct, {
3388
+ let e = An(this.options.target);
3389
+ this.responsiveLayout.mount(e), this.app = i(Tt, {
3306
3390
  canRetryEnd: !!this.options.loadPage,
3307
3391
  cardFooter: this.options.cardFooter,
3308
3392
  cardHeader: this.options.cardHeader,
3309
3393
  feedFooter: this.options.feedFooter,
3310
- feedFooterActions: gn(this),
3394
+ feedFooterActions: yn(this),
3311
3395
  mediaCard: this.options.mediaCard,
3312
3396
  reelInfoSheet: this.options.reelInfoSheet,
3313
3397
  state: this.state,
@@ -3332,7 +3416,7 @@ var Kn = class {
3332
3416
  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;
3333
3417
  }
3334
3418
  getState() {
3335
- return F(this.state);
3419
+ return I(this.state);
3336
3420
  }
3337
3421
  removeMedia(e) {
3338
3422
  return this.exactMediaRemoval.remove(e);
@@ -3383,11 +3467,11 @@ var Kn = class {
3383
3467
  this.autoScroll.setSpeed(e);
3384
3468
  }
3385
3469
  applyAutofillUpdate(e) {
3386
- let t = Zt(this.options.autofill, this.state, e);
3387
- return t && this.syncAutofillCountdown(), t;
3470
+ let t = en(this.options.autofill, this.state, e);
3471
+ return t && this.autofillController.syncCountdown(), t;
3388
3472
  }
3389
- async cancelAutofill() {
3390
- await Bt(this.options.autofill, this.state, () => this.cancelRequest());
3473
+ cancelAutofill() {
3474
+ return this.autofillController.cancel();
3391
3475
  }
3392
3476
  applyFillUpdate(e) {
3393
3477
  return this.fillController.applyUpdate(e);
@@ -3396,19 +3480,19 @@ var Kn = class {
3396
3480
  return this.fillController.cancel();
3397
3481
  }
3398
3482
  async fill(e) {
3399
- if (this.pendingRequest || zt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3483
+ if (this.pendingRequest || Vt(this.state.autofill)) throw Error("Vibe cannot fill while another page operation is active.");
3400
3484
  await this.fillController.start(e);
3401
3485
  }
3402
3486
  restoreAutofillSession(e) {
3403
- let t = Qt(this.options.autofill, this.state, e);
3404
- return t && this.syncAutofillCountdown(), t;
3487
+ let t = tn(this.options.autofill, this.state, e);
3488
+ return t && this.autofillController.syncCountdown(), t;
3405
3489
  }
3406
3490
  restoreFillSession(e) {
3407
3491
  return this.fillController.restoreSession(e);
3408
3492
  }
3409
3493
  async loadNext() {
3410
3494
  if (this.pendingRequest) return this.pendingRequest;
3411
- if (!this.state.loadMoreLocked && !(zt(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);
3495
+ if (!this.state.loadMoreLocked && !(Vt(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);
3412
3496
  }
3413
3497
  async refresh() {
3414
3498
  return this.replaceFeed(this.state.next ?? this.lastLoadedCursor, "refresh");
@@ -3418,23 +3502,23 @@ var Kn = class {
3418
3502
  }
3419
3503
  async replaceFeed(e, t) {
3420
3504
  if (!this.options.loadPage) throw Error(`Vibe cannot ${t} without loadPage.`);
3421
- return zt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Rt(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);
3505
+ return Vt(this.state.autofill) && await this.cancelAutofill(), this.fillController.isActive() && await this.cancelFill(), this.cancelRequest(), this.state.autofill = Bt(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);
3422
3506
  }
3423
3507
  async retryEnd() {
3424
3508
  if (this.pendingRequest) return this.pendingRequest;
3425
- if (!this.state.loadMoreLocked && !(zt(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);
3509
+ if (!this.state.loadMoreLocked && !(Vt(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);
3426
3510
  }
3427
3511
  setInfiniteScroll(e) {
3428
- this.state.infiniteScroll = e, e && p(() => this.surface?.loadIfNearBottom());
3512
+ this.state.infiniteScroll = e, e && m(() => this.surface?.loadIfNearBottom());
3429
3513
  }
3430
3514
  setLoadMoreLocked(e) {
3431
- this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && p(() => this.surface?.loadIfNearBottom()));
3515
+ this.state.loadMoreLocked !== e && (this.state.loadMoreLocked = e, !e && this.state.infiniteScroll && m(() => this.surface?.loadIfNearBottom()));
3432
3516
  }
3433
3517
  setReelAutoAdvance(e) {
3434
- bn(this.state.reelAutoAdvance, e);
3518
+ Cn(this.state.reelAutoAdvance, e);
3435
3519
  }
3436
3520
  setReelInfoSheet(e) {
3437
- Sn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3521
+ Tn(this.state.reelInfoSheet, this.options.reelInfoSheet, e);
3438
3522
  }
3439
3523
  setLayout(e) {
3440
3524
  this.responsiveLayout.setLayout(e);
@@ -3449,19 +3533,20 @@ var Kn = class {
3449
3533
  this.state.layout !== "reel" && this.state.reelOrigin !== "masonry" || (this.state.activeReelPostId = e, this.routing.syncReel(e));
3450
3534
  }
3451
3535
  cancelRequest() {
3452
- this.autofillDelayCountdown.clear(), this.requestVersion += 1, this.abortController?.abort(), this.abortController = null, this.pendingRequest = null, this.state.isLoading = !1, this.state.isLoadingMore = !1;
3536
+ this.autofillController.clearCountdown(), this.requestVersion += 1, this.abortController?.abort(), this.abortController = null, this.pendingRequest = null, this.state.isLoading = !1, this.state.isLoadingMore = !1;
3453
3537
  }
3454
3538
  async fetchPage(e, t) {
3455
3539
  let n = this.options.loadPage;
3456
3540
  if (!n) return;
3457
- let r = ++this.requestVersion, i = new AbortController(), a = this.options.autofill, o = a ? this.beginAutofillCycle() : null, s = !1;
3541
+ let r = ++this.requestVersion, i = new AbortController(), a = this.options.autofill, o = a ? this.autofillController.beginCycle() : null, s = !1;
3458
3542
  this.abortController = i;
3459
3543
  try {
3460
3544
  if (a?.strategy === "frontend") {
3461
- let o = await Ht({
3545
+ let o = await Wt({
3462
3546
  existingItems: t ? this.state.items : [],
3463
3547
  initialCursor: e,
3464
3548
  loadPage: n,
3549
+ onCollection: (e) => this.autofillController.captureCollection(e, r === this.requestVersion),
3465
3550
  onDelayChange: (e) => {
3466
3551
  r === this.requestVersion && Object.assign(this.state.autofill, e);
3467
3552
  },
@@ -3477,10 +3562,10 @@ var Kn = class {
3477
3562
  received: o.received,
3478
3563
  requests: o.requests,
3479
3564
  status: o.status
3480
- });
3565
+ }), this.autofillController.clearCollection();
3481
3566
  return;
3482
3567
  }
3483
- let c = wt(await n({
3568
+ let c = Et(await n({
3484
3569
  cursor: e,
3485
3570
  signal: i.signal
3486
3571
  }));
@@ -3495,7 +3580,7 @@ var Kn = class {
3495
3580
  this.state.autofill.status = "complete";
3496
3581
  return;
3497
3582
  }
3498
- await Yt(a, this.state, {
3583
+ await Qt(a, this.state, {
3499
3584
  cycleId: o,
3500
3585
  feedKey: a.feedKey,
3501
3586
  items: u.slice(l.length),
@@ -3505,30 +3590,15 @@ var Kn = class {
3505
3590
  received: d,
3506
3591
  signal: i.signal,
3507
3592
  total: this.state.total
3508
- }, () => r === this.requestVersion), this.syncAutofillCountdown();
3593
+ }, () => r === this.requestVersion), this.autofillController.syncCountdown();
3509
3594
  }
3510
3595
  } catch (e) {
3511
3596
  if (i.signal.aborted || r !== this.requestVersion) return;
3512
3597
  a && (this.state.autofill.error = e, this.state.autofill.status = "error"), s || (t ? this.state.nextPageError = e : this.state.error = e);
3513
3598
  } finally {
3514
- r === this.requestVersion && (this.abortController = null, this.state.isLoading = !1, this.state.isLoadingMore = !1);
3599
+ r === this.requestVersion && (this.autofillController.clearCollection(), this.abortController = null, this.state.isLoading = !1, this.state.isLoadingMore = !1);
3515
3600
  }
3516
3601
  }
3517
- beginAutofillCycle() {
3518
- let e = this.options.autofill;
3519
- if (!e) return "";
3520
- this.autofillDelayCountdown.clear();
3521
- let t = `vibe-autofill-${Date.now().toString(36)}-${++this.autofillCycle}`;
3522
- return this.state.autofill = {
3523
- ...Rt(e, void 0, !1),
3524
- cycleId: t,
3525
- status: "filling"
3526
- }, t;
3527
- }
3528
- syncAutofillCountdown() {
3529
- let e = this.state.autofill;
3530
- this.autofillDelayCountdown.sync(e.strategy === "backend" && e.status === "waiting" ? e.nextRequestAt : null);
3531
- }
3532
3602
  startRequest(e, t) {
3533
3603
  let n = this.fetchPage(e, t);
3534
3604
  return this.pendingRequest = n, n.finally(() => {
@@ -3536,11 +3606,12 @@ var Kn = class {
3536
3606
  });
3537
3607
  }
3538
3608
  startInitialAutofill() {
3539
- let e = ++this.requestVersion, t = new AbortController(), n = this.beginAutofillCycle();
3609
+ let e = ++this.requestVersion, t = new AbortController(), n = this.autofillController.beginCycle();
3540
3610
  this.abortController = t, this.state.isLoadingMore = !0;
3541
- let r = $t({
3611
+ let r = nn({
3542
3612
  cycleId: n,
3543
3613
  isCurrent: () => e === this.requestVersion,
3614
+ onCollection: (t) => this.autofillController.captureCollection(t, e === this.requestVersion),
3544
3615
  onLastCursor: (e) => {
3545
3616
  this.lastLoadedCursor = e;
3546
3617
  },
@@ -3550,20 +3621,20 @@ var Kn = class {
3550
3621
  }).catch((n) => {
3551
3622
  t.signal.aborted || e !== this.requestVersion || (this.state.autofill.error = n, this.state.autofill.status = "error", this.state.nextPageError = n);
3552
3623
  }).finally(() => {
3553
- e === this.requestVersion && (this.syncAutofillCountdown(), this.abortController = null, this.state.isLoadingMore = !1, this.pendingRequest === r && (this.pendingRequest = null));
3624
+ e === this.requestVersion && (this.autofillController.clearCollection(), this.autofillController.syncCountdown(), this.abortController = null, this.state.isLoadingMore = !1, this.pendingRequest === r && (this.pendingRequest = null));
3554
3625
  });
3555
3626
  return this.pendingRequest = r, r;
3556
3627
  }
3557
3628
  startStateNotifications() {
3558
3629
  let e = this.options.onStateChange;
3559
- !e || this.stopStateWatcher || (e(this.getState()), this.stopStateWatcher = D(this.state, () => e(this.getState()), {
3630
+ !e || this.stopStateWatcher || (e(this.getState()), this.stopStateWatcher = O(this.state, () => e(this.getState()), {
3560
3631
  deep: !0,
3561
3632
  flush: "post"
3562
3633
  }));
3563
3634
  }
3564
3635
  };
3565
- function Yn(e) {
3566
- return new Jn(e);
3636
+ function Qn(e) {
3637
+ return new Zn(e);
3567
3638
  }
3568
3639
  //#endregion
3569
- export { Yn as createVibe };
3640
+ export { Qn as createVibe };