react-virtuoso
Version:
A virtual scroll React component for efficiently rendering large scrollable lists, grids, tables, and feeds
2,010 lines • 95.1 kB
JavaScript
import { jsx as G, jsxs as $t } from "react/jsx-runtime";
import E, { createElement as Dt } from "react";
import So from "react-dom";
const we = 0, Pt = 1, Xt = 2, Wn = 4;
function fn(t) {
return () => t;
}
function xo(t) {
t();
}
function re(t, e) {
return (n) => t(e(n));
}
function mn(t, e) {
return () => t(e);
}
function vo(t, e) {
return (n) => t(e, n);
}
function _e(t) {
return t !== void 0;
}
function To(...t) {
return () => {
t.map(xo);
};
}
function Jt() {
}
function ye(t, e) {
return e(t), t;
}
function Co(t, e) {
return e(t);
}
function rt(...t) {
return t;
}
function Y(t, e) {
return t(Pt, e);
}
function _(t, e) {
t(we, e);
}
function Ne(t) {
t(Xt);
}
function it(t) {
return t(Wn);
}
function k(t, e) {
return Y(t, vo(e, we));
}
function yt(t, e) {
const n = t(Pt, (o) => {
n(), e(o);
});
return n;
}
function pn(t) {
let e, n;
return (o) => (r) => {
e = r, n && clearTimeout(n), n = setTimeout(() => {
o(e);
}, t);
};
}
function Pn(t, e) {
return t === e;
}
function nt(t = Pn) {
let e;
return (n) => (o) => {
t(e, o) || (e = o, n(o));
};
}
function P(t) {
return (e) => (n) => {
t(n) && e(n);
};
}
function B(t) {
return (e) => re(e, t);
}
function Bt(t) {
return (e) => () => {
e(t);
};
}
function x(t, ...e) {
const n = wo(...e);
return ((o, r) => {
switch (o) {
case Xt:
Ne(t);
return;
case Pt:
return Y(t, n(r));
}
});
}
function Lt(t, e) {
return (n) => (o) => {
n(e = t(e, o));
};
}
function Ut(t) {
return (e) => (n) => {
t > 0 ? t-- : e(n);
};
}
function zt(t) {
let e = null, n;
return (o) => (r) => {
e = r, !n && (n = setTimeout(() => {
n = void 0, o(e);
}, t));
};
}
function $(...t) {
const e = new Array(t.length);
let n = 0, o = null;
const r = 2 ** t.length - 1;
return t.forEach((s, i) => {
const l = 2 ** i;
Y(s, (c) => {
const d = n;
n |= l, e[i] = c, d !== r && n === r && o && (o(), o = null);
});
}), (s) => (i) => {
const l = () => {
s([i].concat(e));
};
n === r ? l() : o = l;
};
}
function wo(...t) {
return (e) => t.reduceRight(Co, e);
}
function yo(t) {
let e, n;
const o = () => e?.();
return function(r, s) {
switch (r) {
case Pt:
return s ? n === s ? void 0 : (o(), n = s, e = Y(t, s), e) : (o(), Jt);
case Xt:
o(), n = null;
return;
}
};
}
function T(t) {
let e = t;
const n = U();
return ((o, r) => {
switch (o) {
case we:
e = r;
break;
case Pt: {
r(e);
break;
}
case Wn:
return e;
}
return n(o, r);
});
}
function ht(t, e) {
return ye(T(e), (n) => k(t, n));
}
function U() {
const t = [];
return ((e, n) => {
switch (e) {
case we:
t.slice().forEach((o) => {
o(n);
});
return;
case Xt:
t.splice(0, t.length);
return;
case Pt:
return t.push(n), () => {
const o = t.indexOf(n);
o > -1 && t.splice(o, 1);
};
}
});
}
function Tt(t) {
return ye(U(), (e) => k(t, e));
}
function j(t, e = [], { singleton: n } = { singleton: !0 }) {
return {
constructor: t,
dependencies: e,
id: bo(),
singleton: n
};
}
const bo = () => Symbol();
function Ro(t) {
const e = /* @__PURE__ */ new Map(), n = ({ constructor: o, dependencies: r, id: s, singleton: i }) => {
if (i && e.has(s))
return e.get(s);
const l = o(r.map((c) => n(c)));
return i && e.set(s, l), l;
};
return n(t);
}
function at(...t) {
const e = U(), n = new Array(t.length);
let o = 0;
const r = 2 ** t.length - 1;
return t.forEach((s, i) => {
const l = 2 ** i;
Y(s, (c) => {
n[i] = c, o |= l, o === r && _(e, n);
});
}), function(s, i) {
switch (s) {
case Xt: {
Ne(e);
return;
}
case Pt:
return o === r && i(n), Y(e, i);
}
};
}
function W(t, e = Pn) {
return x(t, nt(e));
}
function Fe(...t) {
return function(e, n) {
switch (e) {
case Xt:
return;
case Pt:
return To(...t.map((o) => Y(o, n)));
}
};
}
const ft = {
/** Detailed debugging information including item measurements */
DEBUG: 0,
/** General informational messages */
INFO: 1,
/** Warning messages for potential issues */
WARN: 2,
/** Error messages for failures (default level) */
ERROR: 3
}, Ho = {
[ft.DEBUG]: "debug",
[ft.ERROR]: "error",
[ft.INFO]: "log",
[ft.WARN]: "warn"
}, Eo = () => typeof globalThis > "u" ? window : globalThis, Gt = j(
() => {
const t = T(ft.ERROR);
return {
log: T((n, o, r = ft.INFO) => {
const s = Eo().VIRTUOSO_LOG_LEVEL ?? it(t);
r >= s && console[Ho[r]](
"%creact-virtuoso: %c%s %o",
"color: #0253b3; font-weight: bold",
"color: initial",
n,
o
);
}),
logLevel: t
};
},
[],
{ singleton: !0 }
), Ve = /* @__PURE__ */ new WeakMap();
function Gn(t) {
return "self" in t ? t.document.documentElement : t;
}
function Bo(t) {
const e = Gn(t), n = Ve.get(e);
if (n !== void 0)
return n;
const o = e.ownerDocument.defaultView.getComputedStyle(e).direction === "rtl";
return Ve.set(e, o), o;
}
function hn(t) {
Ve.delete(Gn(t));
}
function An(t, e) {
return Bo(t) ? -e : e;
}
const _t = An;
function gn(t, e) {
return An(t, e);
}
function Ot(t, e, n) {
return De(t, e, n).callbackRef;
}
function De(t, e, n) {
const o = E.useRef(null);
let r = (i) => {
};
const s = E.useMemo(() => typeof ResizeObserver < "u" ? new ResizeObserver((i) => {
const l = () => {
const c = i[0].target;
c.offsetParent !== null && t(c);
};
n ? l() : requestAnimationFrame(l);
}) : null, [t, n]);
return r = (i) => {
i && e ? (s?.observe(i), o.current = i) : (o.current && s?.unobserve(o.current), o.current = null);
}, { callbackRef: r, ref: o };
}
function Mn(t, e, n, o, r, s, i, l, c) {
const d = E.useCallback(
(m) => {
const v = Lo(m.children, e, l ? "offsetWidth" : "offsetHeight", r);
let p = m.parentElement;
for (; p.dataset.virtuosoScroller === void 0; )
p = p.parentElement;
const I = p.lastElementChild.dataset.viewportType === "window";
let w;
I && (w = p.ownerDocument.defaultView);
const R = i ? l ? i.scrollWidth : i.scrollHeight : I ? l ? w.document.documentElement.scrollWidth : w.document.documentElement.scrollHeight : l ? p.scrollWidth : p.scrollHeight, h = i ? l ? i.offsetWidth : i.offsetHeight : I ? l ? w.innerWidth : w.innerHeight : l ? p.offsetWidth : p.offsetHeight, f = i ? l ? _t(i, i.scrollLeft) : i.scrollTop : I ? l ? _t(w, w.scrollX || w.document.documentElement.scrollLeft) : w.scrollY || w.document.documentElement.scrollTop : l ? _t(p, p.scrollLeft) : p.scrollTop;
o({
scrollHeight: R,
scrollTop: Math.max(f, 0),
viewportHeight: h
}), s?.(
l ? In("column-gap", getComputedStyle(m).columnGap, r) : In("row-gap", getComputedStyle(m).rowGap, r)
), v !== null && t(v);
},
[t, e, r, s, i, o, l]
);
return De(d, n, c);
}
function Lo(t, e, n, o) {
const r = t.length;
if (r === 0)
return null;
const s = [];
for (let i = 0; i < r; i++) {
const l = t.item(i);
if (l.dataset.index === void 0)
continue;
const c = parseInt(l.dataset.index), d = parseFloat(l.dataset.knownSize), m = e(l, n);
if (m === 0 && o("Zero-sized element, this should not happen", { child: l }, ft.ERROR), m === d)
continue;
const v = s[s.length - 1];
s.length === 0 || v.size !== m || v.endIndex !== c - 1 ? s.push({ endIndex: c, size: m, startIndex: c }) : s[s.length - 1].endIndex++;
}
return s;
}
function In(t, e, n) {
return e !== "normal" && e?.endsWith("px") !== !0 && n(`${t} was not resolved to pixel value correctly`, e, ft.WARN), e === "normal" ? 0 : parseInt(e ?? "0", 10);
}
function $e(t, e, n) {
const o = E.useRef(null), r = E.useCallback(
(c) => {
if (!c?.offsetParent)
return;
const d = c.getBoundingClientRect(), m = d.width;
let v, p;
if (e) {
const I = e.getBoundingClientRect(), w = d.top - I.top;
p = I.height - Math.max(0, w), v = w + e.scrollTop;
} else {
const I = i.current.ownerDocument.defaultView;
p = I.innerHeight - Math.max(0, d.top), v = d.top + I.scrollY;
}
o.current = {
listHeight: d.height,
offsetTop: v,
visibleHeight: p,
visibleWidth: m
}, t(o.current);
},
// oxlint-disable-next-line exhaustive-deps
[t, e]
), { callbackRef: s, ref: i } = De(r, !0, n), l = E.useCallback(() => {
r(i.current);
}, [r, i]);
return E.useEffect(() => {
if (e) {
e.addEventListener("scroll", l);
const d = new ResizeObserver(() => {
requestAnimationFrame(l);
});
return d.observe(e), () => {
e.removeEventListener("scroll", l), d.unobserve(e);
};
}
const c = i.current?.ownerDocument.defaultView;
return c?.addEventListener("scroll", l), c?.addEventListener("resize", l), () => {
c?.removeEventListener("scroll", l), c?.removeEventListener("resize", l);
};
}, [l, e, i]), s;
}
const It = j(
() => {
const t = U(), e = U(), n = T(0), o = U(), r = T(0), s = U(), i = U(), l = T(0), c = T(0), d = T(0), m = T(0), v = U(), p = U(), I = T(!1), w = T(!1), R = T(!1);
return k(
x(
t,
B(({ scrollTop: h }) => h)
),
e
), k(
x(
t,
B(({ scrollHeight: h }) => h)
),
i
), k(e, r), {
deviation: n,
fixedFooterHeight: d,
fixedHeaderHeight: c,
footerHeight: m,
headerHeight: l,
horizontalDirection: w,
scrollBy: p,
// input
scrollContainerState: t,
scrollHeight: i,
scrollingInProgress: I,
// signals
scrollTo: v,
scrollTop: e,
skipAnimationFrameInResizeObserver: R,
smoothScrollTargetReached: o,
// state
statefulScrollTop: r,
viewportHeight: s
};
},
[],
{ singleton: !0 }
), se = { lvl: 0 };
function _n(t, e) {
const n = t.length;
if (n === 0)
return [];
let { index: o, value: r } = e(t[0]);
const s = [];
for (let i = 1; i < n; i++) {
const { index: l, value: c } = e(t[i]);
s.push({ end: l - 1, start: o, value: r }), o = l, r = c;
}
return s.push({ end: 1 / 0, start: o, value: r }), s;
}
function J(t) {
return t === se;
}
function ie(t, e) {
if (!J(t))
return e === t.k ? t.v : e < t.k ? ie(t.l, e) : ie(t.r, e);
}
function Rt(t, e, n = "k") {
if (J(t))
return [-1 / 0, void 0];
if (Number(t[n]) === e)
return [t.k, t.v];
if (Number(t[n]) < e) {
const o = Rt(t.r, e, n);
return o[0] === -1 / 0 ? [t.k, t.v] : o;
}
return Rt(t.l, e, n);
}
function vt(t, e, n) {
return J(t) ? $n(e, n, 1) : e === t.k ? dt(t, { k: e, v: n }) : e < t.k ? Sn(dt(t, { l: vt(t.l, e, n) })) : Sn(dt(t, { r: vt(t.r, e, n) }));
}
function Yt() {
return se;
}
function Zt(t, e, n) {
if (J(t))
return [];
const o = Rt(t, e)[0];
return Oo(Pe(t, o, n));
}
function We(t, e) {
if (J(t))
return se;
const { k: n, l: o, r } = t;
if (e === n) {
if (J(o))
return r;
if (J(r))
return o;
const [s, i] = Dn(o);
return xe(dt(t, { k: s, l: Nn(o), v: i }));
}
return e < n ? xe(dt(t, { l: We(o, e) })) : xe(dt(t, { r: We(r, e) }));
}
function Nt(t) {
return J(t) ? [] : [...Nt(t.l), { k: t.k, v: t.v }, ...Nt(t.r)];
}
function Pe(t, e, n) {
if (J(t))
return [];
const { k: o, l: r, r: s, v: i } = t;
let l = [];
return o > e && (l = l.concat(Pe(r, e, n))), o >= e && o <= n && l.push({ k: o, v: i }), o <= n && (l = l.concat(Pe(s, e, n))), l;
}
function xe(t) {
const { l: e, lvl: n, r: o } = t;
if (o.lvl >= n - 1 && e.lvl >= n - 1)
return t;
if (n > o.lvl + 1) {
if (Be(e))
return Un(dt(t, { lvl: n - 1 }));
if (!J(e) && !J(e.r))
return dt(e.r, {
l: dt(e, { r: e.r.l }),
lvl: n,
r: dt(t, {
l: e.r.r,
lvl: n - 1
})
});
throw new Error("Unexpected empty nodes");
}
if (Be(t))
return Ge(dt(t, { lvl: n - 1 }));
if (!J(o) && !J(o.l)) {
const r = o.l, s = Be(r) ? o.lvl - 1 : o.lvl;
return dt(r, {
l: dt(t, {
lvl: n - 1,
r: r.l
}),
lvl: r.lvl + 1,
r: Ge(dt(o, { l: r.r, lvl: s }))
});
}
throw new Error("Unexpected empty nodes");
}
function dt(t, e) {
return $n(
e.k !== void 0 ? e.k : t.k,
e.v !== void 0 ? e.v : t.v,
e.lvl !== void 0 ? e.lvl : t.lvl,
e.l !== void 0 ? e.l : t.l,
e.r !== void 0 ? e.r : t.r
);
}
function Nn(t) {
return J(t.r) ? t.l : xe(dt(t, { r: Nn(t.r) }));
}
function Be(t) {
return J(t) || t.lvl > t.r.lvl;
}
function Dn(t) {
return J(t.r) ? [t.k, t.v] : Dn(t.r);
}
function $n(t, e, n, o = se, r = se) {
return { k: t, l: o, lvl: n, r, v: e };
}
function Sn(t) {
return Ge(Un(t));
}
function Un(t) {
const { l: e } = t;
return !J(e) && e.lvl === t.lvl ? dt(e, { r: dt(t, { l: e.r }) }) : t;
}
function Ge(t) {
const { lvl: e, r: n } = t;
return !J(n) && !J(n.r) && n.lvl === e && n.r.lvl === e ? dt(n, { l: dt(t, { r: n.l }), lvl: e + 1 }) : t;
}
function Oo(t) {
return _n(t, ({ k: e, v: n }) => ({ index: e, value: n }));
}
function Kn(t, e) {
return !!(t && t.startIndex === e.startIndex && t.endIndex === e.endIndex);
}
function le(t, e) {
return !!(t && t[0] === e[0] && t[1] === e[1]);
}
const Ue = j(
() => ({ recalcInProgress: T(!1) }),
[],
{ singleton: !0 }
);
function jn(t, e, n) {
return t[Te(t, e, n)];
}
function Te(t, e, n, o = 0) {
let r = t.length - 1;
for (; o <= r; ) {
const s = Math.floor((o + r) / 2), i = t[s], l = n(i, e);
if (l === 0)
return s;
if (l === -1) {
if (r - o < 2)
return s - 1;
r = s - 1;
} else {
if (r === o)
return s;
o = s + 1;
}
}
throw new Error(`Failed binary finding record in array - ${t.join(",")}, searched for ${e}`);
}
function ko(t, e, n, o) {
const r = Te(t, e, o), s = Te(t, n, o, r);
return t.slice(r, s + 1);
}
function Ht(t, e) {
return Math.round(t.getBoundingClientRect()[e]);
}
function be(t) {
return !J(t.groupOffsetTree);
}
function Ke({ index: t }, e) {
return e === t ? 0 : e < t ? -1 : 1;
}
function zo() {
return {
groupIndices: [],
groupOffsetTree: Yt(),
lastIndex: 0,
lastOffset: 0,
lastSize: 0,
offsetTree: [],
sizeTree: Yt()
};
}
function Fo(t, e) {
let n = J(t) ? 0 : 1 / 0;
for (const o of e) {
const { endIndex: r, size: s, startIndex: i } = o;
if (n = Math.min(n, i), J(t)) {
t = vt(t, 0, s);
continue;
}
const l = Zt(t, i - 1, r + 1);
if (l.some(_o(o)))
continue;
let c = !1, d = !1;
for (const { end: m, start: v, value: p } of l)
c ? (r >= v || s === p) && (t = We(t, v)) : (d = p !== s, c = !0), m > r && r >= v && p !== s && (t = vt(t, r + 1, p));
d && (t = vt(t, i, s));
}
return [t, n];
}
function Vo(t) {
return typeof t.groupIndex < "u";
}
function Wo({ offset: t }, e) {
return e === t ? 0 : e < t ? -1 : 1;
}
function ce(t, e, n) {
if (e.length === 0)
return 0;
const { index: o, offset: r, size: s } = jn(e, t, Ke), i = t - o, l = s * i + (i - 1) * n + r;
return l > 0 ? l + n : l;
}
function qn(t, e) {
if (!be(e))
return t;
let n = 0;
for (; e.groupIndices[n] <= t + n; )
n++;
return t + n;
}
function Yn(t, e, n) {
if (Vo(t))
return e.groupIndices[t.groupIndex] + 1;
const o = t.index === "LAST" ? n : t.index;
let r = qn(o, e);
return r = Math.max(0, r, Math.min(n, r)), r;
}
function Po(t, e, n, o = 0) {
return o > 0 && (e = Math.max(e, jn(t, o, Ke).offset)), _n(ko(t, e, n, Wo), Mo);
}
function Go(t, [e, n, o, r]) {
e.length > 0 && o("received item sizes", e, ft.DEBUG);
const s = t.sizeTree;
let i = s, l = 0;
if (n.length > 0 && J(s) && e.length === 2) {
const p = e[0].size, I = e[1].size;
i = n.reduce((w, R) => vt(vt(w, R, p), R + 1, I), i);
} else
[i, l] = Fo(i, e);
if (i === s)
return t;
const { lastIndex: c, lastOffset: d, lastSize: m, offsetTree: v } = Ae(t.offsetTree, l, i, r);
return {
groupIndices: n,
groupOffsetTree: n.reduce((p, I) => vt(p, I, ce(I, v, r)), Yt()),
lastIndex: c,
lastOffset: d,
lastSize: m,
offsetTree: v,
sizeTree: i
};
}
function Ao(t) {
return Nt(t).map(({ k: e, v: n }, o, r) => {
const s = r[o + 1];
return { endIndex: s !== void 0 ? s.k - 1 : 1 / 0, size: n, startIndex: e };
});
}
function xn(t, e) {
let n = 0, o = 0;
for (; n < t; )
n += e[o + 1] - e[o] - 1, o++;
return o - (n === t ? 0 : 1);
}
function Ae(t, e, n, o) {
let r = t, s = 0, i = 0, l = 0, c = 0;
if (e !== 0) {
c = Te(r, e - 1, Ke), l = r[c].offset;
const m = Rt(n, e - 1);
s = m[0], i = m[1], r.length && r[c].size === Rt(n, e)[1] && (c -= 1), r = r.slice(0, c + 1);
} else
r = [];
for (const { start: d, value: m } of Zt(n, e, 1 / 0)) {
const v = d - s, p = v * i + l + v * o;
r.push({
index: d,
offset: p,
size: m
}), s = d, l = p, i = m;
}
return {
lastIndex: s,
lastOffset: l,
lastSize: i,
offsetTree: r
};
}
function Mo(t) {
return { index: t.index, value: t };
}
function _o(t) {
const { endIndex: e, size: n, startIndex: o } = t;
return (r) => r.start === o && (r.end === e || r.end === 1 / 0) && r.value === n;
}
const No = {
offsetHeight: "height",
offsetWidth: "width"
}, kt = j(
([{ log: t }, { recalcInProgress: e }]) => {
const n = U(), o = U(), r = ht(o, 0), s = U(), i = U(), l = T(0), c = T([]), d = T(void 0), m = T(void 0), v = T(void 0), p = T(void 0), I = T((u, g) => Ht(u, No[g])), w = T(void 0), R = T(0), h = zo(), f = ht(
x(n, $(c, t, R), Lt(Go, h), nt()),
h
), a = ht(
x(
c,
nt(),
Lt((u, g) => ({ current: g, prev: u.current }), {
current: [],
prev: []
}),
B(({ prev: u }) => u)
),
[]
);
k(
x(
c,
P((u) => u.length > 0),
$(f, R),
B(([u, g, C]) => {
const z = u.reduce((L, V, N) => vt(L, V, ce(V, g.offsetTree, C) || N), Yt());
return {
...g,
groupIndices: u,
groupOffsetTree: z
};
})
),
f
), k(
x(
o,
$(f),
P(([u, { lastIndex: g }]) => u < g),
B(([u, { lastIndex: g, lastSize: C }]) => [
{
endIndex: g,
size: C,
startIndex: u
}
])
),
n
), k(d, m);
const S = ht(
x(
d,
B((u) => u === void 0)
),
!0
);
k(
x(
m,
P((u) => u !== void 0 && J(it(f).sizeTree)),
B((u) => {
const g = it(v), C = it(c).length > 0;
return g !== void 0 && g !== 0 ? C ? [
{ endIndex: 0, size: g, startIndex: 0 },
{ endIndex: 1, size: u, startIndex: 1 }
] : [] : [{ endIndex: 0, size: u, startIndex: 0 }];
})
),
n
), k(
x(
p,
P((u) => u !== void 0 && u.length > 0 && J(it(f).sizeTree)),
B((u) => {
const g = [];
let C = u[0], z = 0;
for (let L = 1; L < u.length; L++) {
const V = u[L];
V !== C && (g.push({
endIndex: L - 1,
size: C,
startIndex: z
}), C = V, z = L);
}
return g.push({
endIndex: u.length - 1,
size: C,
startIndex: z
}), g;
})
),
n
), k(
x(
c,
$(v, m),
P(([, u, g]) => u !== void 0 && g !== void 0),
B(([u, g, C]) => {
const z = [];
for (let L = 0; L < u.length; L++) {
const V = u[L], N = u[L + 1];
z.push({
startIndex: V,
endIndex: V,
size: g
}), N !== void 0 && z.push({
startIndex: V + 1,
endIndex: N - 1,
size: C
});
}
return z;
})
),
n
);
const H = Tt(
x(
n,
$(f),
Lt(
({ sizes: u }, [g, C]) => ({
changed: C !== u,
sizes: C
}),
{ changed: !1, sizes: h }
),
B((u) => u.changed)
)
);
Y(
x(
l,
Lt(
(u, g) => ({ diff: u.prev - g, prev: g }),
{ diff: 0, prev: 0 }
),
B((u) => u.diff)
),
(u) => {
const { groupIndices: g } = it(f);
if (u > 0)
_(e, !0), _(s, u + xn(u, g));
else if (u < 0) {
const C = it(a);
C.length > 0 && (u -= xn(-u, C)), _(i, u);
}
}
), Y(x(l, $(t)), ([u, g]) => {
u < 0 && g(
"`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",
{ firstItemIndex: l },
ft.ERROR
);
});
const y = Tt(s);
k(
x(
s,
$(f),
B(([u, g]) => {
const C = g.groupIndices.length > 0, z = [], L = g.lastSize;
if (C) {
const V = ie(g.sizeTree, 0);
let N = 0, Z = 0;
for (; N < u; ) {
const q = g.groupIndices[Z], Q = g.groupIndices.length === Z + 1 ? 1 / 0 : g.groupIndices[Z + 1] - q - 1;
z.push({
endIndex: q,
size: V,
startIndex: q
}), z.push({
endIndex: q + 1 + Q - 1,
size: L,
startIndex: q + 1
}), Z++, N += Q + 1;
}
const F = Nt(g.sizeTree);
return N !== u && F.shift(), F.reduce(
(q, { k: Q, v: gt }) => {
let ut = q.ranges;
return q.prevSize !== 0 && (ut = [
...q.ranges,
{
endIndex: Q + u - 1,
size: q.prevSize,
startIndex: q.prevIndex
}
]), {
prevIndex: Q + u,
prevSize: gt,
ranges: ut
};
},
{
prevIndex: u,
prevSize: 0,
ranges: z
}
).ranges;
}
return Nt(g.sizeTree).reduce(
(V, { k: N, v: Z }) => ({
prevIndex: N + u,
prevSize: Z,
ranges: [...V.ranges, { endIndex: N + u - 1, size: V.prevSize, startIndex: V.prevIndex }]
}),
{
prevIndex: 0,
prevSize: L,
ranges: []
}
).ranges;
})
),
n
);
const O = Tt(
x(
i,
$(f, R),
B(([u, { offsetTree: g }, C]) => {
const z = -u;
return ce(z, g, C);
})
)
);
return k(
x(
i,
$(f, R),
B(([u, g, C]) => {
if (g.groupIndices.length > 0) {
if (J(g.sizeTree))
return g;
let V = Yt();
const N = it(a);
let Z = 0, F = 0, mt = 0;
for (; Z < -u; ) {
mt = N[F];
const Q = N[F + 1] - mt - 1;
F++, Z += Q + 1;
}
if (V = Nt(g.sizeTree).reduce((Q, { k: gt, v: ut }) => vt(Q, Math.max(0, gt + u), ut), V), Z !== -u) {
const Q = ie(g.sizeTree, mt);
V = vt(V, 0, Q);
const gt = Rt(g.sizeTree, -u + 1)[1];
V = vt(V, 1, gt);
}
return {
...g,
sizeTree: V,
...Ae(g.offsetTree, 0, V, C)
};
}
const L = Nt(g.sizeTree).reduce((V, { k: N, v: Z }) => vt(V, Math.max(0, N + u), Z), Yt());
return {
...g,
sizeTree: L,
...Ae(g.offsetTree, 0, L, C)
};
})
),
f
), {
beforeUnshiftWith: y,
// input
data: w,
defaultItemSize: m,
firstItemIndex: l,
fixedItemSize: d,
fixedGroupSize: v,
gap: R,
groupIndices: c,
heightEstimates: p,
itemSize: I,
listRefresh: H,
shiftWith: i,
shiftWithOffset: O,
sizeRanges: n,
// output
sizes: f,
statefulTotalCount: r,
totalCount: o,
trackItemSizes: S,
unshiftWith: s
};
},
rt(Gt, Ue),
{ singleton: !0 }
);
function Do(t) {
return t.reduce(
(e, n) => (e.groupIndices.push(e.totalCount), e.totalCount += n + 1, e),
{
groupIndices: [],
totalCount: 0
}
);
}
const Zn = j(
([{ groupIndices: t, sizes: e, totalCount: n }, { headerHeight: o, scrollTop: r }]) => {
const s = U(), i = U(), l = Tt(x(s, B(Do)));
return k(
x(
l,
B((c) => c.totalCount)
),
n
), k(
x(
l,
B((c) => c.groupIndices)
),
t
), k(
x(
at(r, e, o),
P(([c, d]) => be(d)),
B(([c, d, m]) => Rt(d.groupOffsetTree, Math.max(c - m, 0), "v")[0]),
nt(),
B((c) => [c])
),
i
), { groupCounts: s, topItemsIndexes: i };
},
rt(kt, It)
), At = j(
([{ log: t }]) => {
const e = T(!1), n = Tt(
x(
e,
P((o) => o),
nt()
)
);
return Y(e, (o) => {
o && it(t)("props updated", {}, ft.DEBUG);
}), { didMount: n, propsReady: e };
},
rt(Gt),
{ singleton: !0 }
), $o = typeof document < "u" && "scrollBehavior" in document.documentElement.style;
function Xn(t) {
const e = typeof t == "number" ? { index: t } : t;
return e.align || (e.align = "start"), (!e.behavior || !$o) && (e.behavior = "auto"), e.offset === void 0 && (e.offset = 0), e;
}
const fe = j(
([
{ gap: t, listRefresh: e, sizes: n, totalCount: o },
{
fixedFooterHeight: r,
fixedHeaderHeight: s,
footerHeight: i,
headerHeight: l,
scrollingInProgress: c,
scrollTo: d,
smoothScrollTargetReached: m,
viewportHeight: v
},
{ log: p }
]) => {
const I = U(), w = U(), R = T(0);
let h = null, f = null, a = null;
function S() {
h !== null && (h(), h = null), a !== null && (a(), a = null), f && (clearTimeout(f), f = null), _(c, !1);
}
return k(
x(
I,
$(n, v, o, R, l, i, p),
$(t, s, r),
B(
([
[H, y, O, u, g, C, z, L],
V,
N,
Z
]) => {
const F = Xn(H), { align: mt, behavior: q, offset: Q } = F, gt = u - 1, ut = Yn(F, y, gt);
let St = ce(ut, y.offsetTree, V) + C;
mt === "end" ? (St += N + Rt(y.sizeTree, ut)[1] - O + Z, ut === gt && (St += z)) : mt === "center" ? St += (N + Rt(y.sizeTree, ut)[1] - O + Z) / 2 : St -= g, Q !== void 0 && Q !== 0 && (St += Q);
const Ft = (pt) => {
S(), pt ? (L("retrying to scroll to", { location: H }, ft.DEBUG), _(I, H)) : (_(w, !0), L("list did not change, scroll successful", {}, ft.DEBUG));
};
if (S(), q === "smooth") {
let pt = !1;
a = Y(e, (jt) => {
pt = pt || jt;
}), h = yt(m, () => {
Ft(pt);
});
} else
h = yt(x(e, Uo(150)), Ft);
return f = setTimeout(() => {
S();
}, 1200), _(c, !0), L("scrolling from index to", { behavior: q, index: ut, top: St }, ft.DEBUG), { behavior: q, top: St };
}
)
),
d
), {
scrollTargetReached: w,
scrollToIndex: I,
topListHeight: R
};
},
rt(kt, It, Gt),
{ singleton: !0 }
);
function Uo(t) {
return (e) => {
const n = setTimeout(() => {
e(!1);
}, t);
return (o) => {
o && (e(!0), clearTimeout(n));
};
};
}
function je(t, e) {
t === 0 ? e() : requestAnimationFrame(() => {
je(t - 1, e);
});
}
function qe(t, e) {
const n = e - 1;
return typeof t == "number" ? t : t.index === "LAST" ? n : t.index;
}
const me = j(
([{ defaultItemSize: t, listRefresh: e, sizes: n }, { scrollTop: o }, { scrollTargetReached: r, scrollToIndex: s }, { didMount: i }]) => {
const l = T(!0), c = T(0), d = T(!0);
return k(
x(
i,
$(c),
P(([m, v]) => v !== 0),
Bt(!1)
),
l
), k(
x(
i,
$(c),
P(([m, v]) => v !== 0),
Bt(!1)
),
d
), Y(
x(
at(e, i),
$(l, n, t, d),
P(([[, m], v, { sizeTree: p }, I, w]) => m && (!J(p) || _e(I)) && !v && !w),
$(c)
),
([, m]) => {
yt(r, () => {
_(d, !0);
}), je(4, () => {
yt(o, () => {
_(l, !0);
}), _(s, m);
});
}
), {
initialItemFinalLocationReached: d,
initialTopMostItemIndex: c,
scrolledToInitialItem: l
};
},
rt(kt, It, fe, At),
{ singleton: !0 }
);
function Jn(t, e) {
return Math.abs(t - e) < 1.01;
}
const ue = "up", ne = "down", Ko = "none", jo = {
atBottom: !1,
notAtBottomBecause: "NOT_SHOWING_LAST_ITEM",
state: {
offsetBottom: 0,
scrollHeight: 0,
scrollTop: 0,
viewportHeight: 0
}
}, qo = 0, pe = j(([{ footerHeight: t, headerHeight: e, scrollBy: n, scrollContainerState: o, scrollTop: r, viewportHeight: s }]) => {
const i = T(!1), l = T(!0), c = U(), d = U(), m = T(4), v = T(qo), p = ht(
x(
Fe(x(W(r), Ut(1), Bt(!0)), x(W(r), Ut(1), Bt(!1), pn(100))),
nt()
),
!1
), I = ht(
x(Fe(x(n, Bt(!0)), x(n, Bt(!1), pn(200))), nt()),
!1
);
k(
x(
at(W(r), W(v)),
B(([a, S]) => a <= S),
nt()
),
l
), k(x(l, zt(50)), d);
const w = Tt(
x(
at(o, W(s), W(e), W(t), W(m)),
Lt((a, [{ scrollHeight: S, scrollTop: H }, y, O, u, g]) => {
const C = H + y - S > -g, z = {
scrollHeight: S,
scrollTop: H,
viewportHeight: y
};
if (C) {
let V, N;
return H > a.state.scrollTop ? (V = "SCROLLED_DOWN", N = a.state.scrollTop - H) : (V = "SIZE_DECREASED", N = a.state.scrollTop - H || a.scrollTopDelta), {
atBottom: !0,
atBottomBecause: V,
scrollTopDelta: N,
state: z
};
}
let L;
return z.scrollHeight > a.state.scrollHeight ? L = "SIZE_INCREASED" : y < a.state.viewportHeight ? L = "VIEWPORT_HEIGHT_DECREASING" : H < a.state.scrollTop ? L = "SCROLLING_UPWARDS" : L = "NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM", {
atBottom: !1,
notAtBottomBecause: L,
state: z
};
}, jo),
nt((a, S) => a !== void 0 && a.atBottom === S.atBottom)
)
), R = ht(
x(
o,
Lt(
(a, { scrollHeight: S, scrollTop: H, viewportHeight: y }) => {
if (!Jn(a.scrollHeight, S)) {
const O = S - (H + y) < 1;
return a.scrollTop !== H && O ? {
changed: !0,
jump: a.scrollTop - H,
scrollHeight: S,
scrollTop: H
} : {
changed: !0,
jump: 0,
scrollHeight: S,
scrollTop: H
};
}
return {
changed: !1,
jump: 0,
scrollHeight: S,
scrollTop: H
};
},
{ changed: !1, jump: 0, scrollHeight: 0, scrollTop: 0 }
),
P((a) => a.changed),
B((a) => a.jump)
),
0
);
k(
x(
w,
B((a) => a.atBottom)
),
i
), k(x(i, zt(50)), c);
const h = T(ne);
k(
x(
o,
B(({ scrollTop: a }) => a),
nt(),
Lt(
(a, S) => it(I) ? { direction: a.direction, prevScrollTop: S } : { direction: S < a.prevScrollTop ? ue : ne, prevScrollTop: S },
{ direction: ne, prevScrollTop: 0 }
),
B((a) => a.direction)
),
h
), k(x(o, zt(50), Bt(Ko)), h);
const f = T(0);
return k(
x(
p,
P((a) => !a),
Bt(0)
),
f
), k(
x(
r,
zt(100),
$(p),
P(([a, S]) => S),
Lt(([a, S], [H]) => [S, H], [0, 0]),
B(([a, S]) => S - a)
),
f
), {
atBottomState: w,
atBottomStateChange: c,
atBottomThreshold: m,
atTopStateChange: d,
atTopThreshold: v,
isAtBottom: i,
isAtTop: l,
isScrolling: p,
lastJumpDueToItemResize: R,
scrollDirection: h,
scrollVelocity: f
};
}, rt(It)), ae = "top", de = "bottom", vn = "none";
function Tn(t, e, n) {
return typeof t == "number" ? n === ue && e === ae || n === ne && e === de ? t : 0 : n === ue ? e === ae ? t.main : t.reverse : e === de ? t.main : t.reverse;
}
function Cn(t, e) {
return typeof t == "number" ? t : t[e] ?? 0;
}
const Ye = j(
([{ deviation: t, fixedHeaderHeight: e, headerHeight: n, scrollTop: o, viewportHeight: r }]) => {
const s = U(), i = T(0), l = T(0), c = T(0), d = ht(
x(
at(
W(o),
W(r),
W(n),
W(s, le),
W(c),
W(i),
W(e),
W(t),
W(l)
),
B(
([
m,
v,
p,
[I, w],
R,
h,
f,
a,
S
]) => {
const H = m - a, y = h + f, O = Math.max(p - H, 0);
let u = vn;
const g = Cn(S, ae), C = Cn(S, de);
return I -= a, I += p + f, w += p + f, w -= a, I > m + y - g && (u = ue), w < m - O + v + C && (u = ne), u !== vn ? [
Math.max(H - p - Tn(R, ae, u) - g, 0),
H - O - f + v + Tn(R, de, u) + C
] : null;
}
),
P((m) => m !== null),
nt(le)
),
[0, 0]
);
return {
increaseViewportBy: l,
// input
listBoundary: s,
overscan: c,
topListHeight: i,
// output
visibleRange: d
};
},
rt(It),
{ singleton: !0 }
);
function Yo(t, e, n) {
if (be(e)) {
const o = qn(t, e);
return [
{ index: Rt(e.groupOffsetTree, o)[0], offset: 0, size: 0 },
{ data: n?.[0], index: o, offset: 0, size: 0 }
];
}
return [{ data: n?.[0], index: t, offset: 0, size: 0 }];
}
const Le = {
bottom: 0,
firstItemIndex: 0,
items: [],
offsetBottom: 0,
offsetTop: 0,
top: 0,
topItems: [],
topListHeight: 0,
totalCount: 0
};
function ve(t, e, n, o, r, s) {
const { lastIndex: i, lastOffset: l, lastSize: c } = r;
let d = 0, m = 0;
if (t.length > 0) {
d = t[0].offset;
const R = t[t.length - 1];
m = R.offset + R.size;
}
const v = n - i, p = l + v * c + (v - 1) * o, I = d, w = p - m;
return {
bottom: m,
firstItemIndex: s,
items: wn(t, r, s),
offsetBottom: w,
offsetTop: d,
top: I,
topItems: wn(e, r, s),
topListHeight: e.reduce((R, h) => h.size + R, 0),
totalCount: n
};
}
function Qn(t, e, n, o, r, s) {
let i = 0;
if (n.groupIndices.length > 0)
for (const m of n.groupIndices) {
if (m - i >= t)
break;
i++;
}
const l = t + i, c = qe(e, l), d = Array.from({ length: l }).map((m, v) => ({
data: s[v + c],
index: v + c,
offset: 0,
size: 0
}));
return ve(d, [], l, r, n, o);
}
function wn(t, e, n) {
if (t.length === 0)
return [];
if (!be(e))
return t.map((d) => ({ ...d, index: d.index + n, originalIndex: d.index }));
const o = t[0].index, r = t[t.length - 1].index, s = [], i = Zt(e.groupOffsetTree, o, r);
let l, c = 0;
for (const d of t) {
(!l || l.end < d.index) && (l = i.shift(), c = e.groupIndices.indexOf(l.start));
let m;
d.index === l.start ? m = {
index: c,
type: "group"
} : m = {
groupIndex: c,
index: d.index - (c + 1) + n
}, s.push({
...m,
data: d.data,
offset: d.offset,
originalIndex: d.index,
size: d.size
});
}
return s;
}
function yn(t, e) {
return t === void 0 ? 0 : typeof t == "number" ? t : t[e] ?? 0;
}
const Kt = j(
([
{ data: t, firstItemIndex: e, gap: n, sizes: o, totalCount: r },
s,
{ listBoundary: i, topListHeight: l, visibleRange: c },
{ initialTopMostItemIndex: d, scrolledToInitialItem: m },
{ topListHeight: v },
p,
{ didMount: I },
{ recalcInProgress: w }
]) => {
const R = T([]), h = T(0), f = U(), a = T(0);
k(s.topItemsIndexes, R);
const S = ht(
x(
at(
I,
w,
W(c, le),
W(r),
W(o),
W(d),
m,
W(R),
W(e),
W(n),
W(a),
t
),
P(([u, g, , C, , , , , , , , z]) => {
const L = z !== void 0 && z.length !== C;
return u && !g && !L;
}),
B(
([
,
,
[u, g],
C,
z,
L,
V,
N,
Z,
F,
mt,
q
]) => {
const Q = z, { offsetTree: gt, sizeTree: ut } = Q, St = it(h);
if (C === 0)
return { ...Le, totalCount: C };
if (u === 0 && g === 0)
return St === 0 ? { ...Le, totalCount: C } : Qn(St, L, z, Z, F, q || []);
if (J(ut))
return St > 0 ? null : ve(
Yo(qe(L, C), Q, q),
[],
C,
F,
Q,
Z
);
const Ft = [];
if (N.length > 0) {
const D = N[0], K = N[N.length - 1];
let st = 0;
for (const tt of Zt(ut, D, K)) {
const X = tt.value, lt = Math.max(tt.start, D), xt = Math.min(tt.end, K);
for (let ct = lt; ct <= xt; ct++)
Ft.push({ data: q?.[ct], index: ct, offset: st, size: X }), st += X;
}
}
if (!V)
return ve([], Ft, C, F, Q, Z);
const pt = N.length > 0 ? N[N.length - 1] + 1 : 0, jt = Po(gt, u, g, pt);
if (jt.length === 0)
return null;
const Qt = C - 1, Et = ye([], (D) => {
for (const K of jt) {
const st = K.value;
let tt = st.offset, X = K.start;
const lt = st.size;
if (st.offset < u) {
X += Math.floor((u - st.offset + F) / (lt + F));
const ct = X - K.start;
tt += ct * lt + ct * F;
}
X < pt && (tt += (pt - X) * lt, X = pt);
const xt = Math.min(K.end, Qt);
for (let ct = X; ct <= xt && !(tt >= g); ct++)
D.push({ data: q?.[ct], index: ct, offset: tt, size: lt }), tt += lt + F;
}
}), te = yn(mt, ae), b = yn(mt, de);
if (Et.length > 0 && (te > 0 || b > 0)) {
const D = Et[0], K = Et[Et.length - 1];
if (te > 0 && D.index > pt) {
const st = Math.min(te, D.index - pt), tt = [];
let X = D.offset;
for (let lt = D.index - 1; lt >= D.index - st; lt--) {
const ct = Zt(ut, lt, lt)[0]?.value ?? D.size;
X -= ct + F, tt.unshift({ data: q?.[lt], index: lt, offset: X, size: ct });
}
Et.unshift(...tt);
}
if (b > 0 && K.index < Qt) {
const st = Math.min(b, Qt - K.index);
let tt = K.offset + K.size + F;
for (let X = K.index + 1; X <= K.index + st; X++) {
const xt = Zt(ut, X, X)[0]?.value ?? K.size;
Et.push({ data: q?.[X], index: X, offset: tt, size: xt }), tt += xt + F;
}
}
}
return ve(Et, Ft, C, F, Q, Z);
}
),
//@ts-expect-error filter needs to be fixed
P((u) => u !== null),
nt()
),
Le
);
k(
x(
t,
P(_e),
B((u) => u?.length)
),
r
), k(
x(
S,
B((u) => u.topListHeight)
),
v
), k(v, l), k(
x(
S,
B((u) => [u.top, u.bottom])
),
i
), k(
x(
S,
B((u) => u.items)
),
f
);
const H = Tt(
x(
S,
P(({ items: u }) => u.length > 0),
$(r, t),
P(([{ items: u }, g]) => u[u.length - 1].originalIndex === g - 1),
B(([, u, g]) => [u - 1, g]),
nt(le),
B(([u]) => u)
)
), y = Tt(
x(
S,
zt(200),
P(({ items: u, topItems: g }) => u.length > 0 && u[0].originalIndex === g.length),
B(({ items: u }) => u[0].index),
nt()
)
), O = Tt(
x(
S,
P(({ items: u }) => u.length > 0),
B(({ items: u }) => {
let g = 0, C = u.length - 1;
for (; u[g].type === "group" && g < C; )
g++;
for (; u[C].type === "group" && C > g; )
C--;
return {
endIndex: u[C].index,
startIndex: u[g].index
};
}),
nt(Kn)
)
);
return {
endReached: H,
initialItemCount: h,
itemsRendered: f,
listState: S,
minOverscanItemCount: a,
rangeChanged: O,
startReached: y,
topItemsIndexes: R,
...p
};
},
rt(
kt,
Zn,
Ye,
me,
fe,
pe,
At,
Ue
),
{ singleton: !0 }
), to = j(
([{ fixedFooterHeight: t, fixedHeaderHeight: e, footerHeight: n, headerHeight: o }, { listState: r }]) => {
const s = U(), i = ht(
x(
at(n, t, o, e, r),
B(([l, c, d, m, v]) => l + c + d + m + v.offsetBottom + v.bottom)
),
0
);
return k(W(i), s), { totalListHeight: i, totalListHeightChanged: s };
},
rt(It, Kt),
{ singleton: !0 }
), Zo = j(
([{ viewportHeight: t }, { totalListHeight: e }]) => {
const n = T(!1), o = ht(
x(
at(n, t, e),
P(([r]) => r),
B(([, r, s]) => Math.max(0, r - s)),
zt(0),
nt()
),
0
);
return { alignToBottom: n, paddingTopAddition: o };
},
rt(It, to),
{ singleton: !0 }
), eo = j(() => ({
context: T(null)
})), Xo = ({
itemBottom: t,
itemTop: e,
locationParams: { align: n, behavior: o, ...r },
viewportBottom: s,
viewportTop: i
}) => e < i ? { ...r, align: n ?? "start", ...o !== void 0 ? { behavior: o } : {} } : t > s ? { ...r, align: n ?? "end", ...o !== void 0 ? { behavior: o } : {} } : null, no = j(
([
{ gap: t, sizes: e, totalCount: n },
{ fixedFooterHeight: o, fixedHeaderHeight: r, headerHeight: s, scrollingInProgress: i, scrollTop: l, viewportHeight: c },
{ scrollToIndex: d }
]) => {
const m = U();
return k(
x(
m,
$(e, c, n, s, r, o, l),
$(t),
B(([[v, p, I, w, R, h, f, a], S]) => {
const { calculateViewLocation: H = Xo, done: y, ...O } = v, u = Yn(v, p, w - 1), g = ce(u, p.offsetTree, S) + R + h, C = g + Rt(p.sizeTree, u)[1], z = a + h, L = a + I - f, V = H({
itemBottom: C,
itemTop: g,
locationParams: O,
viewportBottom: L,
viewportTop: z
});
return V !== null ? y && yt(
x(
i,
P((N) => !N),
// skips the initial publish of false, and the cleanup call.
// but if scrollingInProgress is true, we skip the initial publish.
Ut(it(i) ? 1 : 2)
),
y
) : y?.(), V;
}),
P((v) => v !== null)
),
d
), {
scrollIntoView: m
};
},
rt(kt, It, fe, Kt, Gt),
{ singleton: !0 }
);
function bn(t) {
return t === !1 ? !1 : t === "smooth" ? "smooth" : "auto";
}
const Jo = (t, e) => typeof t == "function" ? bn(t(e)) : e && bn(t), Qo = j(
([
{ listRefresh: t, totalCount: e, fixedItemSize: n, data: o },
{ atBottomState: r, isAtBottom: s },
{ scrollToIndex: i },
{ scrolledToInitialItem: l },
{ didMount: c, propsReady: d },
{ log: m },
{ scrollingInProgress: v },
{ context: p },
{ scrollIntoView: I }
]) => {
const w = T(!1), R = U();
let h = null;
function f(y) {
_(i, {
align: "end",
behavior: y,
index: "LAST"
});
}
Y(
x(
at(x(W(e), Ut(1)), c),
$(W(w), s, l, v),
B(([[y, O], u, g, C, z]) => {
let L = O && C, V = "auto";
return L && (V = Jo(u, g || z), L = L && V !== !1), { followOutputBehavior: V, shouldFollow: L, totalCount: y };
}),
P(({ shouldFollow: y }) => y)
),
({ followOutputBehavior: y, totalCount: O }) => {
h !== null && (h(), h = null), it(n) !== void 0 ? requestAnimationFrame(() => {
it(m)("following output to ", { totalCount: O }, ft.DEBUG), f(y);
}) : h = yt(t, () => {
it(m)("following output to ", { totalCount: O }, ft.DEBUG), f(y), h = null;
});
}
);
function a(y) {
const O = yt(r, (u) => {
y && !u.atBottom && u.notAtBottomBecause === "SIZE_INCREASED" && h === null && (it(m)("scrolling to bottom due to increased size", {}, ft.DEBUG), f("auto"));
});
setTimeout(O, 100);
}
Y(
x(
at(W(w), e, d),
P(([y, , O]) => y !== !1 && O),
Lt(
({ value: y }, [, O]) => ({ refreshed: y === O, value: O }),
{ refreshed: !1, value: 0 }
),
P(({ refreshed: y }) => y),
$(w, e)
),
([, y]) => {
it(l) && a(y !== !1);
}
), Y(R, () => {
a(it(w) !== !1);
}), Y(at(W(w), r), ([y, O]) => {
y !== !1 && !O.atBottom && O.notAtBottomBecause === "VIEWPORT_HEIGHT_DECREASING" && f("auto");
});
const S = T(null), H = U();
return k(
Fe(
x(
W(o),
B((y) => y?.length ?? 0)
),
x(W(e))
),
H
), Y(
x(
at(x(H, Ut(1)), c),
$(W(S), l, v, p),
B(([[y, O], u, g, C, z]) => O && g && u?.({ context: z, totalCount: y, scrollingInProgress: C })),
P((y) => !!y),
zt(0)
),
(y) => {
h !== null && (h(), h = null), it(n) !== void 0 ? requestAnimationFrame(() => {
it(m)("scrolling into view", {}), _(I, y);
}) : h = yt(t, () => {
it(m)("scrolling into view", {}), _(I, y), h = null;
});
}
), { autoscrollToBottom: R, followOutput: w, scrollIntoViewOnChange: S };
},
rt(
kt,
pe,
fe,
me,
At,
Gt,
It,
eo,
no
)
), tr = j(
([{ data: t, firstItemIndex: e, gap: n, sizes: o }, { initialTopMostItemIndex: r }, { initialItemCount: s, listState: i }, { didMount: l }]) => (k(
x(
l,
$(s),
P(([, c]) => c !== 0),
$(r, o, e, n, t),
B(([[, c], d, m, v, p, I = []]) => Qn(c, d, m, v, p, I))
),
i
), {}),
rt(kt, me, Kt, At),
{ singleton: !0 }
), er = j(
([{ didMount: t }, { scrollTo: e }, { listState: n }]) => {
const o = T(0);
return Y(
x(
t,
$(o),
P(([, r]) => r !== 0),
B(([, r]) => ({ top: r }))
),
(r) => {
yt(
x(
n,
Ut(1),
P((s) => s.items.length > 1)
),
() => {
requestAnimationFrame(() => {
_(e, r);
});
}
);
}
), {
initialScrollTop: o
};
},
rt(At, It, Kt),
{ singleton: !0 }
), oo = j(
([{ scrollVelocity: t }]) => {
const e = T(!1), n = U(), o = T(!1);
return k(
x(
t,
$(o, e, n),
P(([r, s]) => s !== !1 && s !== void 0),
B(([r, s, i, l]) => {
const { enter: c, exit: d } = s;
if (i) {
if (d(r, l))
return !1;
} else if (c(r, l))
return !0;
return i;
}),
nt()
),
e
), Y(
x(at(e, t, n), $(o)),
([[r, s, i], l]) => {
r && l !== !1 && l !== void 0 && l.change && l.change(s, i);
}
), { isSeeking: e, scrollSeekConfiguration: o, scrollSeekRangeChanged: n, scrollVelocity: t };
},
rt(pe),
{ singleton: !0 }
), Ze = j(([{ scrollContainerState: t, scrollTo: e }]) => {
const n = U(), o = U(), r = U(), s = T(!1), i = T(void 0);
return k(
x(
at(n, o),
B(([{ scrollTop: l, viewportHeight: c }, { offsetTop: d, listHeight: m }]) => ({
scrollHeight: m,
scrollTop: Math.max(0, l - d),
viewportHeight: c
}))
),
t
), k(
x(
e,
$(o),
B(([l, { offsetTop: c }]) => ({
...l,
top: l.top + c
}))
),
r
), {
customScrollParent: i,
// config
useWindowScroll: s,
// input
windowScrollContainerState: n,
// signals
windowScrollTo: r,
windowViewportRect: o
};
}, rt(It)), nr = j(
([
{ sizeRanges: t, sizes: e },
{ headerHeight: n, scrollTop: o },
{ i