react-virtuoso
Version:
A virtual scroll React component for efficiently rendering large scrollable lists, grids, tables, and feeds
2,021 lines (2,020 loc) • 90.1 kB
JavaScript
import { jsx as z, jsxs as Nt, Fragment as lo } from "react/jsx-runtime";
import H, { createElement as _t } from "react";
import co from "react-dom";
const we = 0, zt = 1, qt = 2, kn = 4;
function cn(t) {
return () => t;
}
function uo(t) {
t();
}
function ne(t, e) {
return (n) => t(e(n));
}
function un(t, e) {
return () => t(e);
}
function ao(t, e) {
return (n) => t(e, n);
}
function Me(t) {
return t !== void 0;
}
function fo(...t) {
return () => {
t.map(uo);
};
}
function Yt() {
}
function ve(t, e) {
return e(t), t;
}
function mo(t, e) {
return e(t);
}
function X(...t) {
return t;
}
function K(t, e) {
return t(zt, e);
}
function G(t, e) {
t(we, e);
}
function We(t) {
t(qt);
}
function st(t) {
return t(kn);
}
function O(t, e) {
return K(t, ao(e, we));
}
function bt(t, e) {
const n = t(zt, (o) => {
n(), e(o);
});
return n;
}
function an(t) {
let e, n;
return (o) => (r) => {
e = r, n && clearTimeout(n), n = setTimeout(() => {
o(e);
}, t);
};
}
function Fn(t, e) {
return t === e;
}
function Z(t = Fn) {
let e;
return (n) => (o) => {
t(e, o) || (e = o, n(o));
};
}
function P(t) {
return (e) => (n) => {
t(n) && e(n);
};
}
function E(t) {
return (e) => ne(e, t);
}
function yt(t) {
return (e) => () => {
e(t);
};
}
function x(t, ...e) {
const n = po(...e);
return (o, r) => {
switch (o) {
case qt:
We(t);
return;
case zt:
return K(t, n(r));
}
};
}
function Rt(t, e) {
return (n) => (o) => {
n(e = t(e, o));
};
}
function jt(t) {
return (e) => (n) => {
t > 0 ? t-- : e(n);
};
}
function Lt(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 = Math.pow(2, t.length) - 1;
return t.forEach((s, i) => {
const l = Math.pow(2, i);
K(s, (c) => {
const a = n;
n = n | l, e[i] = c, a !== r && n === r && o && (o(), o = null);
});
}), (s) => (i) => {
const l = () => {
s([i].concat(e));
};
n === r ? l() : o = l;
};
}
function po(...t) {
return (e) => t.reduceRight(mo, e);
}
function ho(t) {
let e, n;
const o = () => e == null ? void 0 : e();
return function(r, s) {
switch (r) {
case zt:
return s ? n === s ? void 0 : (o(), n = s, e = K(t, s), e) : (o(), Yt);
case qt:
o(), n = null;
return;
}
};
}
function C(t) {
let e = t;
const n = $();
return (o, r) => {
switch (o) {
case we:
e = r;
break;
case zt: {
r(e);
break;
}
case kn:
return e;
}
return n(o, r);
};
}
function ct(t, e) {
return ve(C(e), (n) => O(t, n));
}
function $() {
const t = [];
return (e, n) => {
switch (e) {
case we:
t.slice().forEach((o) => {
o(n);
});
return;
case qt:
t.splice(0, t.length);
return;
case zt:
return t.push(n), () => {
const o = t.indexOf(n);
o > -1 && t.splice(o, 1);
};
}
};
}
function ht(t) {
return ve($(), (e) => O(t, e));
}
function U(t, e = [], { singleton: n } = { singleton: !0 }) {
return {
constructor: t,
dependencies: e,
id: go(),
singleton: n
};
}
const go = () => Symbol();
function Io(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 rt(...t) {
const e = $(), n = new Array(t.length);
let o = 0;
const r = Math.pow(2, t.length) - 1;
return t.forEach((s, i) => {
const l = Math.pow(2, i);
K(s, (c) => {
n[i] = c, o = o | l, o === r && G(e, n);
});
}), function(s, i) {
switch (s) {
case qt: {
We(e);
return;
}
case zt:
return o === r && i(n), K(e, i);
}
};
}
function A(t, e = Fn) {
return x(t, Z(e));
}
function dn(...t) {
return function(e, n) {
switch (e) {
case qt:
return;
case zt:
return fo(...t.map((o) => K(o, n)));
}
};
}
var mt = /* @__PURE__ */ ((t) => (t[t.DEBUG = 0] = "DEBUG", t[t.INFO = 1] = "INFO", t[t.WARN = 2] = "WARN", t[t.ERROR = 3] = "ERROR", t))(mt || {});
const So = {
0: "debug",
3: "error",
1: "log",
2: "warn"
}, xo = () => typeof globalThis > "u" ? window : globalThis, Vt = U(
() => {
const t = C(
3
/* ERROR */
);
return {
log: C((n, o, r = 1) => {
var i;
const s = (i = xo().VIRTUOSO_LOG_LEVEL) != null ? i : st(t);
r >= s && console[So[r]](
"%creact-virtuoso: %c%s %o",
"color: #0253b3; font-weight: bold",
"color: initial",
n,
o
);
}),
logLevel: t
};
},
[],
{ singleton: !0 }
);
function Ht(t, e, n) {
return Ge(t, e, n).callbackRef;
}
function Ge(t, e, n) {
const o = H.useRef(null);
let r = (i) => {
};
const s = H.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 == null || s.observe(i), o.current = i) : (o.current && (s == null || s.unobserve(o.current)), o.current = null);
}, { callbackRef: r, ref: o };
}
function On(t, e, n, o, r, s, i, l, c) {
const a = H.useCallback(
(p) => {
const S = To(p.children, e, l ? "offsetWidth" : "offsetHeight", r);
let g = p.parentElement;
for (; !g.dataset.virtuosoScroller; )
g = g.parentElement;
const h = g.lastElementChild.dataset.viewportType === "window";
let w;
h && (w = g.ownerDocument.defaultView);
const v = i ? l ? i.scrollLeft : i.scrollTop : h ? l ? w.scrollX || w.document.documentElement.scrollLeft : w.scrollY || w.document.documentElement.scrollTop : l ? g.scrollLeft : g.scrollTop, m = i ? l ? i.scrollWidth : i.scrollHeight : h ? l ? w.document.documentElement.scrollWidth : w.document.documentElement.scrollHeight : l ? g.scrollWidth : g.scrollHeight, d = i ? l ? i.offsetWidth : i.offsetHeight : h ? l ? w.innerWidth : w.innerHeight : l ? g.offsetWidth : g.offsetHeight;
o({
scrollHeight: m,
scrollTop: Math.max(v, 0),
viewportHeight: d
}), s == null || s(
l ? fn("column-gap", getComputedStyle(p).columnGap, r) : fn("row-gap", getComputedStyle(p).rowGap, r)
), S !== null && t(S);
},
[t, e, r, s, i, o, l]
);
return Ge(a, n, c);
}
function To(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), a = parseFloat(l.dataset.knownSize), p = e(l, n);
if (p === 0 && o("Zero-sized element, this should not happen", { child: l }, mt.ERROR), p === a)
continue;
const S = s[s.length - 1];
s.length === 0 || S.size !== p || S.endIndex !== c - 1 ? s.push({ endIndex: c, size: p, startIndex: c }) : s[s.length - 1].endIndex++;
}
return s;
}
function fn(t, e, n) {
return e !== "normal" && !(e != null && e.endsWith("px")) && n(`${t} was not resolved to pixel value correctly`, e, mt.WARN), e === "normal" ? 0 : parseInt(e != null ? e : "0", 10);
}
function _e(t, e, n) {
const o = H.useRef(null), r = H.useCallback(
(c) => {
if (!(c != null && c.offsetParent))
return;
const a = c.getBoundingClientRect(), p = a.width;
let S, g;
if (e) {
const h = e.getBoundingClientRect(), w = a.top - h.top;
g = h.height - Math.max(0, w), S = w + e.scrollTop;
} else {
const h = i.current.ownerDocument.defaultView;
g = h.innerHeight - Math.max(0, a.top), S = a.top + h.scrollY;
}
o.current = {
offsetTop: S,
visibleHeight: g,
visibleWidth: p
}, t(o.current);
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[t, e]
), { callbackRef: s, ref: i } = Ge(r, !0, n), l = H.useCallback(() => {
r(i.current);
}, [r, i]);
return H.useEffect(() => {
var c;
if (e) {
e.addEventListener("scroll", l);
const a = new ResizeObserver(() => {
requestAnimationFrame(l);
});
return a.observe(e), () => {
e.removeEventListener("scroll", l), a.unobserve(e);
};
} else {
const a = (c = i.current) == null ? void 0 : c.ownerDocument.defaultView;
return a == null || a.addEventListener("scroll", l), a == null || a.addEventListener("resize", l), () => {
a == null || a.removeEventListener("scroll", l), a == null || a.removeEventListener("resize", l);
};
}
}, [l, e, i]), s;
}
const at = U(
() => {
const t = $(), e = $(), n = C(0), o = $(), r = C(0), s = $(), i = $(), l = C(0), c = C(0), a = C(0), p = C(0), S = $(), g = $(), h = C(!1), w = C(!1), v = C(!1);
return O(
x(
t,
E(({ scrollTop: m }) => m)
),
e
), O(
x(
t,
E(({ scrollHeight: m }) => m)
),
i
), O(e, r), {
deviation: n,
fixedFooterHeight: a,
fixedHeaderHeight: c,
footerHeight: p,
headerHeight: l,
horizontalDirection: w,
scrollBy: g,
// input
scrollContainerState: t,
scrollHeight: i,
scrollingInProgress: h,
// signals
scrollTo: S,
scrollTop: e,
skipAnimationFrameInResizeObserver: v,
smoothScrollTargetReached: o,
// state
statefulScrollTop: r,
viewportHeight: s
};
},
[],
{ singleton: !0 }
), oe = { lvl: 0 };
function Ln(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 === oe;
}
function re(t, e) {
if (!j(t))
return e === t.k ? t.v : e < t.k ? re(t.l, e) : re(t.r, e);
}
function Ct(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 = Ct(t.r, e, n);
return o[0] === -1 / 0 ? [t.k, t.v] : o;
}
return Ct(t.l, e, n);
}
function pt(t, e, n) {
return j(t) ? Pn(e, n, 1) : e === t.k ? ot(t, { k: e, v: n }) : e < t.k ? mn(ot(t, { l: pt(t.l, e, n) })) : mn(ot(t, { r: pt(t.r, e, n) }));
}
function Kt() {
return oe;
}
function ye(t, e, n) {
if (j(t))
return [];
const o = Ct(t, e)[0];
return Co(ze(t, o, n));
}
function Le(t, e) {
if (j(t)) return oe;
const { k: n, l: o, r } = t;
if (e === n) {
if (j(o))
return r;
if (j(r))
return o;
{
const [s, i] = Vn(o);
return ge(ot(t, { k: s, l: zn(o), v: i }));
}
} else return e < n ? ge(ot(t, { l: Le(o, e) })) : ge(ot(t, { r: Le(r, e) }));
}
function Gt(t) {
return j(t) ? [] : [...Gt(t.l), { k: t.k, v: t.v }, ...Gt(t.r)];
}
function ze(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(ze(r, e, n))), o >= e && o <= n && l.push({ k: o, v: i }), o <= n && (l = l.concat(ze(s, e, n))), l;
}
function ge(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 (Ee(e))
return An(ot(t, { lvl: n - 1 }));
if (!j(e) && !j(e.r))
return ot(e.r, {
l: ot(e, { r: e.r.l }),
lvl: n,
r: ot(t, {
l: e.r.r,
lvl: n - 1
})
});
throw new Error("Unexpected empty nodes");
} else {
if (Ee(t))
return Ve(ot(t, { lvl: n - 1 }));
if (!j(o) && !j(o.l)) {
const r = o.l, s = Ee(r) ? o.lvl - 1 : o.lvl;
return ot(r, {
l: ot(t, {
lvl: n - 1,
r: r.l
}),
lvl: r.lvl + 1,
r: Ve(ot(o, { l: r.r, lvl: s }))
});
} else
throw new Error("Unexpected empty nodes");
}
}
function ot(t, e) {
return Pn(
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 zn(t) {
return j(t.r) ? t.l : ge(ot(t, { r: zn(t.r) }));
}
function Ee(t) {
return j(t) || t.lvl > t.r.lvl;
}
function Vn(t) {
return j(t.r) ? [t.k, t.v] : Vn(t.r);
}
function Pn(t, e, n, o = oe, r = oe) {
return { k: t, l: o, lvl: n, r, v: e };
}
function mn(t) {
return Ve(An(t));
}
function An(t) {
const { l: e } = t;
return !j(e) && e.lvl === t.lvl ? ot(e, { r: ot(t, { l: e.r }) }) : t;
}
function Ve(t) {
const { lvl: e, r: n } = t;
return !j(n) && !j(n.r) && n.lvl === e && n.r.lvl === e ? ot(n, { l: ot(t, { r: n.l }), lvl: e + 1 }) : t;
}
function Co(t) {
return Ln(t, ({ k: e, v: n }) => ({ index: e, value: n }));
}
function Mn(t, e) {
return !!(t && t.startIndex === e.startIndex && t.endIndex === e.endIndex);
}
function se(t, e) {
return !!(t && t[0] === e[0] && t[1] === e[1]);
}
const Ne = U(
() => ({ recalcInProgress: C(!1) }),
[],
{ singleton: !0 }
);
function Wn(t, e, n) {
return t[Se(t, e, n)];
}
function Se(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 wo(t, e, n, o) {
const r = Se(t, e, o), s = Se(t, n, o, r);
return t.slice(r, s + 1);
}
function wt(t, e) {
return Math.round(t.getBoundingClientRect()[e]);
}
function Re(t) {
return !j(t.groupOffsetTree);
}
function De({ index: t }, e) {
return e === t ? 0 : e < t ? -1 : 1;
}
function vo() {
return {
groupIndices: [],
groupOffsetTree: Kt(),
lastIndex: 0,
lastOffset: 0,
lastSize: 0,
offsetTree: [],
sizeTree: Kt()
};
}
function yo(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 = pt(t, 0, s);
continue;
}
const l = ye(t, i - 1, r + 1);
if (l.some(Fo(o)))
continue;
let c = !1, a = !1;
for (const { end: p, start: S, value: g } of l)
c ? (r >= S || s === g) && (t = Le(t, S)) : (a = g !== s, c = !0), p > r && r >= S && g !== s && (t = pt(t, r + 1, g));
a && (t = pt(t, i, s));
}
return [t, n];
}
function Ro(t) {
return typeof t.groupIndex < "u";
}
function bo({ offset: t }, e) {
return e === t ? 0 : e < t ? -1 : 1;
}
function ie(t, e, n) {
if (e.length === 0)
return 0;
const { index: o, offset: r, size: s } = Wn(e, t, De), i = t - o, l = s * i + (i - 1) * n + r;
return l > 0 ? l + n : l;
}
function Gn(t, e) {
if (!Re(e))
return t;
let n = 0;
for (; e.groupIndices[n] <= t + n; )
n++;
return t + n;
}
function _n(t, e, n) {
if (Ro(t))
return e.groupIndices[t.groupIndex] + 1;
{
const o = t.index === "LAST" ? n : t.index;
let r = Gn(o, e);
return r = Math.max(0, r, Math.min(n, r)), r;
}
}
function Ho(t, e, n, o = 0) {
return o > 0 && (e = Math.max(e, Wn(t, o, De).offset)), Ln(wo(t, e, n, bo), ko);
}
function Eo(t, [e, n, o, r]) {
e.length > 0 && o("received item sizes", e, mt.DEBUG);
const s = t.sizeTree;
let i = s, l = 0;
if (n.length > 0 && j(s) && e.length === 2) {
const g = e[0].size, h = e[1].size;
i = n.reduce((w, v) => pt(pt(w, v, g), v + 1, h), i);
} else
[i, l] = yo(i, e);
if (i === s)
return t;
const { lastIndex: c, lastOffset: a, lastSize: p, offsetTree: S } = Pe(t.offsetTree, l, i, r);
return {
groupIndices: n,
groupOffsetTree: n.reduce((g, h) => pt(g, h, ie(h, S, r)), Kt()),
lastIndex: c,
lastOffset: a,
lastSize: p,
offsetTree: S,
sizeTree: i
};
}
function Bo(t) {
return Gt(t).map(({ k: e, v: n }, o, r) => {
const s = r[o + 1];
return { endIndex: s ? s.k - 1 : 1 / 0, size: n, startIndex: e };
});
}
function pn(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 Pe(t, e, n, o) {
let r = t, s = 0, i = 0, l = 0, c = 0;
if (e !== 0) {
c = Se(r, e - 1, De), l = r[c].offset;
const p = Ct(n, e - 1);
s = p[0], i = p[1], r.length && r[c].size === Ct(n, e)[1] && (c -= 1), r = r.slice(0, c + 1);
} else
r = [];
for (const { start: a, value: p } of ye(n, e, 1 / 0)) {
const S = a - s, g = S * i + l + S * o;
r.push({
index: a,
offset: g,
size: p
}), s = a, l = g, i = p;
}
return {
lastIndex: s,
lastOffset: l,
lastSize: i,
offsetTree: r
};
}
function ko(t) {
return { index: t.index, value: t };
}
function Fo(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 Oo = {
offsetHeight: "height",
offsetWidth: "width"
}, Et = U(
([{ log: t }, { recalcInProgress: e }]) => {
const n = $(), o = $(), r = ct(o, 0), s = $(), i = $(), l = C(0), c = C([]), a = C(void 0), p = C(void 0), S = C((I, f) => wt(I, Oo[f])), g = C(void 0), h = C(0), w = vo(), v = ct(
x(n, _(c, t, h), Rt(Eo, w), Z()),
w
), m = ct(
x(
c,
Z(),
Rt((I, f) => ({ current: f, prev: I.current }), {
current: [],
prev: []
}),
E(({ prev: I }) => I)
),
[]
);
O(
x(
c,
P((I) => I.length > 0),
_(v, h),
E(([I, f, b]) => {
const k = I.reduce((F, L, V) => pt(F, L, ie(L, f.offsetTree, b) || V), Kt());
return {
...f,
groupIndices: I,
groupOffsetTree: k
};
})
),
v
), O(
x(
o,
_(v),
P(([I, { lastIndex: f }]) => I < f),
E(([I, { lastIndex: f, lastSize: b }]) => [
{
endIndex: f,
size: b,
startIndex: I
}
])
),
n
), O(a, p);
const d = ct(
x(
a,
E((I) => I === void 0)
),
!0
);
O(
x(
p,
P((I) => I !== void 0 && j(st(v).sizeTree)),
E((I) => [{ endIndex: 0, size: I, startIndex: 0 }])
),
n
);
const u = ht(
x(
n,
_(v),
Rt(
({ sizes: I }, [f, b]) => ({
changed: b !== I,
sizes: b
}),
{ changed: !1, sizes: w }
),
E((I) => I.changed)
)
);
K(
x(
l,
Rt(
(I, f) => ({ diff: I.prev - f, prev: f }),
{ diff: 0, prev: 0 }
),
E((I) => I.diff)
),
(I) => {
const { groupIndices: f } = st(v);
if (I > 0)
G(e, !0), G(s, I + pn(I, f));
else if (I < 0) {
const b = st(m);
b.length > 0 && (I -= pn(-I, b)), G(i, I);
}
}
), K(x(l, _(t)), ([I, f]) => {
I < 0 && f(
"`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 },
mt.ERROR
);
});
const T = ht(s);
O(
x(
s,
_(v),
E(([I, f]) => {
const b = f.groupIndices.length > 0, k = [], F = f.lastSize;
if (b) {
const L = re(f.sizeTree, 0);
let V = 0, D = 0;
for (; V < I; ) {
const B = f.groupIndices[D], Y = f.groupIndices.length === D + 1 ? 1 / 0 : f.groupIndices[D + 1] - B - 1;
k.push({
endIndex: B,
size: L,
startIndex: B
}), k.push({
endIndex: B + 1 + Y - 1,
size: F,
startIndex: B + 1
}), D++, V += Y + 1;
}
const J = Gt(f.sizeTree);
return V !== I && J.shift(), J.reduce(
(B, { k: Y, v: it }) => {
let dt = B.ranges;
return B.prevSize !== 0 && (dt = [
...B.ranges,
{
endIndex: Y + I - 1,
size: B.prevSize,
startIndex: B.prevIndex
}
]), {
prevIndex: Y + I,
prevSize: it,
ranges: dt
};
},
{
prevIndex: I,
prevSize: 0,
ranges: k
}
).ranges;
}
return Gt(f.sizeTree).reduce(
(L, { k: V, v: D }) => ({
prevIndex: V + I,
prevSize: D,
ranges: [...L.ranges, { endIndex: V + I - 1, size: L.prevSize, startIndex: L.prevIndex }]
}),
{
prevIndex: 0,
prevSize: F,
ranges: []
}
).ranges;
})
),
n
);
const R = ht(
x(
i,
_(v, h),
E(([I, { offsetTree: f }, b]) => {
const k = -I;
return ie(k, f, b);
})
)
);
return O(
x(
i,
_(v, h),
E(([I, f, b]) => {
if (f.groupIndices.length > 0) {
if (j(f.sizeTree))
return f;
let F = Kt();
const L = st(m);
let V = 0, D = 0, J = 0;
for (; V < -I; ) {
J = L[D];
const B = L[D + 1] - J - 1;
D++, V += B + 1;
}
if (F = Gt(f.sizeTree).reduce((B, { k: Y, v: it }) => pt(B, Math.max(0, Y + I), it), F), V !== -I) {
const B = re(f.sizeTree, J);
F = pt(F, 0, B);
const Y = Ct(f.sizeTree, -I + 1)[1];
F = pt(F, 1, Y);
}
return {
...f,
sizeTree: F,
...Pe(f.offsetTree, 0, F, b)
};
} else {
const F = Gt(f.sizeTree).reduce((L, { k: V, v: D }) => pt(L, Math.max(0, V + I), D), Kt());
return {
...f,
sizeTree: F,
...Pe(f.offsetTree, 0, F, b)
};
}
})
),
v
), {
beforeUnshiftWith: T,
// input
data: g,
defaultItemSize: p,
firstItemIndex: l,
fixedItemSize: a,
gap: h,
groupIndices: c,
itemSize: S,
listRefresh: u,
shiftWith: i,
shiftWithOffset: R,
sizeRanges: n,
// output
sizes: v,
statefulTotalCount: r,
totalCount: o,
trackItemSizes: d,
unshiftWith: s
};
},
X(Vt, Ne),
{ singleton: !0 }
);
function Lo(t) {
return t.reduce(
(e, n) => (e.groupIndices.push(e.totalCount), e.totalCount += n + 1, e),
{
groupIndices: [],
totalCount: 0
}
);
}
const Nn = U(
([{ groupIndices: t, sizes: e, totalCount: n }, { headerHeight: o, scrollTop: r }]) => {
const s = $(), i = $(), l = ht(x(s, E(Lo)));
return O(
x(
l,
E((c) => c.totalCount)
),
n
), O(
x(
l,
E((c) => c.groupIndices)
),
t
), O(
x(
rt(r, e, o),
P(([c, a]) => Re(a)),
E(([c, a, p]) => Ct(a.groupOffsetTree, Math.max(c - p, 0), "v")[0]),
Z(),
E((c) => [c])
),
i
), { groupCounts: s, topItemsIndexes: i };
},
X(Et, at)
), Pt = U(
([{ log: t }]) => {
const e = C(!1), n = ht(
x(
e,
P((o) => o),
Z()
)
);
return K(e, (o) => {
o && st(t)("props updated", {}, mt.DEBUG);
}), { didMount: n, propsReady: e };
},
X(Vt),
{ singleton: !0 }
), zo = typeof document < "u" && "scrollBehavior" in document.documentElement.style;
function Dn(t) {
const e = typeof t == "number" ? { index: t } : t;
return e.align || (e.align = "start"), (!e.behavior || !zo) && (e.behavior = "auto"), e.offset || (e.offset = 0), e;
}
const ce = U(
([
{ gap: t, listRefresh: e, sizes: n, totalCount: o },
{
fixedFooterHeight: r,
fixedHeaderHeight: s,
footerHeight: i,
headerHeight: l,
scrollingInProgress: c,
scrollTo: a,
smoothScrollTargetReached: p,
viewportHeight: S
},
{ log: g }
]) => {
const h = $(), w = $(), v = C(0);
let m = null, d = null, u = null;
function T() {
m && (m(), m = null), u && (u(), u = null), d && (clearTimeout(d), d = null), G(c, !1);
}
return O(
x(
h,
_(n, S, o, v, l, i, g),
_(t, s, r),
E(
([
[R, I, f, b, k, F, L, V],
D,
J,
nt
]) => {
const B = Dn(R), { align: Y, behavior: it, offset: dt } = B, St = b - 1, ft = _n(B, I, St);
let ut = ie(ft, I.offsetTree, D) + F;
Y === "end" ? (ut += J + Ct(I.sizeTree, ft)[1] - f + nt, ft === St && (ut += L)) : Y === "center" ? ut += (J + Ct(I.sizeTree, ft)[1] - f + nt) / 2 : ut -= k, dt && (ut += dt);
const At = (xt) => {
T(), xt ? (V("retrying to scroll to", { location: R }, mt.DEBUG), G(h, R)) : (G(w, !0), V("list did not change, scroll successful", {}, mt.DEBUG));
};
if (T(), it === "smooth") {
let xt = !1;
u = K(e, (Xt) => {
xt = xt || Xt;
}), m = bt(p, () => {
At(xt);
});
} else
m = bt(x(e, Vo(150)), At);
return d = setTimeout(() => {
T();
}, 1200), G(c, !0), V("scrolling from index to", { behavior: it, index: ft, top: ut }, mt.DEBUG), { behavior: it, top: ut };
}
)
),
a
), {
scrollTargetReached: w,
scrollToIndex: h,
topListHeight: v
};
},
X(Et, at, Vt),
{ singleton: !0 }
);
function Vo(t) {
return (e) => {
const n = setTimeout(() => {
e(!1);
}, t);
return (o) => {
o && (e(!0), clearTimeout(n));
};
};
}
function $e(t, e) {
t == 0 ? e() : requestAnimationFrame(() => {
$e(t - 1, e);
});
}
function Ue(t, e) {
const n = e - 1;
return typeof t == "number" ? t : t.index === "LAST" ? n : t.index;
}
const ue = U(
([{ defaultItemSize: t, listRefresh: e, sizes: n }, { scrollTop: o }, { scrollTargetReached: r, scrollToIndex: s }, { didMount: i }]) => {
const l = C(!0), c = C(0), a = C(!0);
return O(
x(
i,
_(c),
P(([p, S]) => !!S),
yt(!1)
),
l
), O(
x(
i,
_(c),
P(([p, S]) => !!S),
yt(!1)
),
a
), K(
x(
rt(e, i),
_(l, n, t, a),
P(([[, p], S, { sizeTree: g }, h, w]) => p && (!j(g) || Me(h)) && !S && !w),
_(c)
),
([, p]) => {
bt(r, () => {
G(a, !0);
}), $e(4, () => {
bt(o, () => {
G(l, !0);
}), G(s, p);
});
}
), {
initialItemFinalLocationReached: a,
initialTopMostItemIndex: c,
scrolledToInitialItem: l
};
},
X(Et, at, ce, Pt),
{ singleton: !0 }
);
function $n(t, e) {
return Math.abs(t - e) < 1.01;
}
const le = "up", te = "down", Po = "none", Ao = {
atBottom: !1,
notAtBottomBecause: "NOT_SHOWING_LAST_ITEM",
state: {
offsetBottom: 0,
scrollHeight: 0,
scrollTop: 0,
viewportHeight: 0
}
}, Mo = 0, ae = U(([{ footerHeight: t, headerHeight: e, scrollBy: n, scrollContainerState: o, scrollTop: r, viewportHeight: s }]) => {
const i = C(!1), l = C(!0), c = $(), a = $(), p = C(4), S = C(Mo), g = ct(
x(
dn(x(A(r), jt(1), yt(!0)), x(A(r), jt(1), yt(!1), an(100))),
Z()
),
!1
), h = ct(
x(dn(x(n, yt(!0)), x(n, yt(!1), an(200))), Z()),
!1
);
O(
x(
rt(A(r), A(S)),
E(([u, T]) => u <= T),
Z()
),
l
), O(x(l, Lt(50)), a);
const w = ht(
x(
rt(o, A(s), A(e), A(t), A(p)),
Rt((u, [{ scrollHeight: T, scrollTop: R }, I, f, b, k]) => {
const F = R + I - T > -k, L = {
scrollHeight: T,
scrollTop: R,
viewportHeight: I
};
if (F) {
let D, J;
return R > u.state.scrollTop ? (D = "SCROLLED_DOWN", J = u.state.scrollTop - R) : (D = "SIZE_DECREASED", J = u.state.scrollTop - R || u.scrollTopDelta), {
atBottom: !0,
atBottomBecause: D,
scrollTopDelta: J,
state: L
};
}
let V;
return L.scrollHeight > u.state.scrollHeight ? V = "SIZE_INCREASED" : I < u.state.viewportHeight ? V = "VIEWPORT_HEIGHT_DECREASING" : R < u.state.scrollTop ? V = "SCROLLING_UPWARDS" : V = "NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM", {
atBottom: !1,
notAtBottomBecause: V,
state: L
};
}, Ao),
Z((u, T) => u && u.atBottom === T.atBottom)
)
), v = ct(
x(
o,
Rt(
(u, { scrollHeight: T, scrollTop: R, viewportHeight: I }) => {
if ($n(u.scrollHeight, T))
return {
changed: !1,
jump: 0,
scrollHeight: T,
scrollTop: R
};
{
const f = T - (R + I) < 1;
return u.scrollTop !== R && f ? {
changed: !0,
jump: u.scrollTop - R,
scrollHeight: T,
scrollTop: R
} : {
changed: !0,
jump: 0,
scrollHeight: T,
scrollTop: R
};
}
},
{ changed: !1, jump: 0, scrollHeight: 0, scrollTop: 0 }
),
P((u) => u.changed),
E((u) => u.jump)
),
0
);
O(
x(
w,
E((u) => u.atBottom)
),
i
), O(x(i, Lt(50)), c);
const m = C(te);
O(
x(
o,
E(({ scrollTop: u }) => u),
Z(),
Rt(
(u, T) => st(h) ? { direction: u.direction, prevScrollTop: T } : { direction: T < u.prevScrollTop ? le : te, prevScrollTop: T },
{ direction: te, prevScrollTop: 0 }
),
E((u) => u.direction)
),
m
), O(x(o, Lt(50), yt(Po)), m);
const d = C(0);
return O(
x(
g,
P((u) => !u),
yt(0)
),
d
), O(
x(
r,
Lt(100),
_(g),
P(([u, T]) => !!T),
Rt(([u, T], [R]) => [T, R], [0, 0]),
E(([u, T]) => T - u)
),
d
), {
atBottomState: w,
atBottomStateChange: c,
atBottomThreshold: p,
atTopStateChange: a,
atTopThreshold: S,
isAtBottom: i,
isAtTop: l,
isScrolling: g,
lastJumpDueToItemResize: v,
scrollDirection: m,
scrollVelocity: d
};
}, X(at)), xe = "top", Te = "bottom", hn = "none";
function gn(t, e, n) {
return typeof t == "number" ? n === le && e === xe || n === te && e === Te ? t : 0 : n === le ? e === xe ? t.main : t.reverse : e === Te ? t.main : t.reverse;
}
function In(t, e) {
var n;
return typeof t == "number" ? t : (n = t[e]) != null ? n : 0;
}
const Ke = U(
([{ deviation: t, fixedHeaderHeight: e, headerHeight: n, scrollTop: o, viewportHeight: r }]) => {
const s = $(), i = C(0), l = C(0), c = C(0), a = ct(
x(
rt(
A(o),
A(r),
A(n),
A(s, se),
A(c),
A(i),
A(e),
A(t),
A(l)
),
E(
([
p,
S,
g,
[h, w],
v,
m,
d,
u,
T
]) => {
const R = p - u, I = m + d, f = Math.max(g - R, 0);
let b = hn;
const k = In(T, xe), F = In(T, Te);
return h -= u, h += g + d, w += g + d, w -= u, h > p + I - k && (b = le), w < p - f + S + F && (b = te), b !== hn ? [
Math.max(R - g - gn(v, xe, b) - k, 0),
R - f - d + S + gn(v, Te, b) + F
] : null;
}
),
P((p) => p != null),
Z(se)
),
[0, 0]
);
return {
increaseViewportBy: l,
// input
listBoundary: s,
overscan: c,
topListHeight: i,
// output
visibleRange: a
};
},
X(at),
{ singleton: !0 }
);
function Wo(t, e, n) {
if (Re(e)) {
const o = Gn(t, e);
return [
{ index: Ct(e.groupOffsetTree, o)[0], offset: 0, size: 0 },
{ data: n == null ? void 0 : n[0], index: o, offset: 0, size: 0 }
];
}
return [{ data: n == null ? void 0 : n[0], index: t, offset: 0, size: 0 }];
}
const Be = {
bottom: 0,
firstItemIndex: 0,
items: [],
offsetBottom: 0,
offsetTop: 0,
top: 0,
topItems: [],
topListHeight: 0,
totalCount: 0
};
function Ie(t, e, n, o, r, s) {
const { lastIndex: i, lastOffset: l, lastSize: c } = r;
let a = 0, p = 0;
if (t.length > 0) {
a = t[0].offset;
const v = t[t.length - 1];
p = v.offset + v.size;
}
const S = n - i, g = l + S * c + (S - 1) * o, h = a, w = g - p;
return {
bottom: p,
firstItemIndex: s,
items: Sn(t, r, s),
offsetBottom: w,
offsetTop: a,
top: h,
topItems: Sn(e, r, s),
topListHeight: e.reduce((v, m) => m.size + v, 0),
totalCount: n
};
}
function Un(t, e, n, o, r, s) {
let i = 0;
if (n.groupIndices.length > 0)
for (const p of n.groupIndices) {
if (p - i >= t)
break;
i++;
}
const l = t + i, c = Ue(e, l), a = Array.from({ length: l }).map((p, S) => ({
data: s[S + c],
index: S + c,
offset: 0,
size: 0
}));
return Ie(a, [], l, r, n, o);
}
function Sn(t, e, n) {
if (t.length === 0)
return [];
if (!Re(e))
return t.map((a) => ({ ...a, index: a.index + n, originalIndex: a.index }));
const o = t[0].index, r = t[t.length - 1].index, s = [], i = ye(e.groupOffsetTree, o, r);
let l, c = 0;
for (const a of t) {
(!l || l.end < a.index) && (l = i.shift(), c = e.groupIndices.indexOf(l.start));
let p;
a.index === l.start ? p = {
index: c,
type: "group"
} : p = {
groupIndex: c,
index: a.index - (c + 1) + n
}, s.push({
...p,
data: a.data,
offset: a.offset,
originalIndex: a.index,
size: a.size
});
}
return s;
}
const Dt = U(
([
{ data: t, firstItemIndex: e, gap: n, sizes: o, totalCount: r },
s,
{ listBoundary: i, topListHeight: l, visibleRange: c },
{ initialTopMostItemIndex: a, scrolledToInitialItem: p },
{ topListHeight: S },
g,
{ didMount: h },
{ recalcInProgress: w }
]) => {
const v = C([]), m = C(0), d = $();
O(s.topItemsIndexes, v);
const u = ct(
x(
rt(
h,
w,
A(c, se),
A(r),
A(o),
A(a),
p,
A(v),
A(e),
A(n),
t
),
P(([f, b, , k, , , , , , , F]) => {
const L = F && F.length !== k;
return f && !b && !L;
}),
E(
([
,
,
[f, b],
k,
F,
L,
V,
D,
J,
nt,
B
]) => {
const Y = F, { offsetTree: it, sizeTree: dt } = Y, St = st(m);
if (k === 0)
return { ...Be, totalCount: k };
if (f === 0 && b === 0)
return St === 0 ? { ...Be, totalCount: k } : Un(St, L, F, J, nt, B || []);
if (j(dt))
return St > 0 ? null : Ie(
Wo(Ue(L, k), Y, B),
[],
k,
nt,
Y,
J
);
const ft = [];
if (D.length > 0) {
const Mt = D[0], vt = D[D.length - 1];
let Bt = 0;
for (const y of ye(dt, Mt, vt)) {
const N = y.value, Q = Math.max(y.start, Mt), lt = Math.min(y.end, vt);
for (let tt = Q; tt <= lt; tt++)
ft.push({ data: B == null ? void 0 : B[tt], index: tt, offset: Bt, size: N }), Bt += N;
}
}
if (!V)
return Ie([], ft, k, nt, Y, J);
const ut = D.length > 0 ? D[D.length - 1] + 1 : 0, At = Ho(it, f, b, ut);
if (At.length === 0)
return null;
const xt = k - 1, Xt = ve([], (Mt) => {
for (const vt of At) {
const Bt = vt.value;
let y = Bt.offset, N = vt.start;
const Q = Bt.size;
if (Bt.offset < f) {
N += Math.floor((f - Bt.offset + nt) / (Q + nt));
const tt = N - vt.start;
y += tt * Q + tt * nt;
}
N < ut && (y += (ut - N) * Q, N = ut);
const lt = Math.min(vt.end, xt);
for (let tt = N; tt <= lt && !(y >= b); tt++)
Mt.push({ data: B == null ? void 0 : B[tt], index: tt, offset: y, size: Q }), y += Q + nt;
}
});
return Ie(Xt, ft, k, nt, Y, J);
}
),
//@ts-expect-error filter needs to be fixed
P((f) => f !== null),
Z()
),
Be
);
O(
x(
t,
P(Me),
E((f) => f == null ? void 0 : f.length)
),
r
), O(
x(
u,
E((f) => f.topListHeight)
),
S
), O(S, l), O(
x(
u,
E((f) => [f.top, f.bottom])
),
i
), O(
x(
u,
E((f) => f.items)
),
d
);
const T = ht(
x(
u,
P(({ items: f }) => f.length > 0),
_(r, t),
P(([{ items: f }, b]) => f[f.length - 1].originalIndex === b - 1),
E(([, f, b]) => [f - 1, b]),
Z(se),
E(([f]) => f)
)
), R = ht(
x(
u,
Lt(200),
P(({ items: f, topItems: b }) => f.length > 0 && f[0].originalIndex === b.length),
E(({ items: f }) => f[0].index),
Z()
)
), I = ht(
x(
u,
P(({ items: f }) => f.length > 0),
E(({ items: f }) => {
let b = 0, k = f.length - 1;
for (; f[b].type === "group" && b < k; )
b++;
for (; f[k].type === "group" && k > b; )
k--;
return {
endIndex: f[k].index,
startIndex: f[b].index
};
}),
Z(Mn)
)
);
return { endReached: T, initialItemCount: m, itemsRendered: d, listState: u, rangeChanged: I, startReached: R, topItemsIndexes: v, ...g };
},
X(
Et,
Nn,
Ke,
ue,
ce,
ae,
Pt,
Ne
),
{ singleton: !0 }
), Kn = U(
([{ fixedFooterHeight: t, fixedHeaderHeight: e, footerHeight: n, headerHeight: o }, { listState: r }]) => {
const s = $(), i = ct(
x(
rt(n, t, o, e, r),
E(([l, c, a, p, S]) => l + c + a + p + S.offsetBottom + S.bottom)
),
0
);
return O(A(i), s), { totalListHeight: i, totalListHeightChanged: s };
},
X(at, Dt),
{ singleton: !0 }
), Go = U(
([{ viewportHeight: t }, { totalListHeight: e }]) => {
const n = C(!1), o = ct(
x(
rt(n, t, e),
P(([r]) => r),
E(([, r, s]) => Math.max(0, r - s)),
Lt(0),
Z()
),
0
);
return { alignToBottom: n, paddingTopAddition: o };
},
X(at, Kn),
{ singleton: !0 }
);
function xn(t) {
return t ? t === "smooth" ? "smooth" : "auto" : !1;
}
const _o = (t, e) => typeof t == "function" ? xn(t(e)) : e && xn(t), No = U(
([
{ listRefresh: t, totalCount: e, fixedItemSize: n },
{ atBottomState: o, isAtBottom: r },
{ scrollToIndex: s },
{ scrolledToInitialItem: i },
{ didMount: l, propsReady: c },
{ log: a },
{ scrollingInProgress: p }
]) => {
const S = C(!1), g = $();
let h = null;
function w(m) {
G(s, {
align: "end",
behavior: m,
index: "LAST"
});
}
K(
x(
rt(x(A(e), jt(1)), l),
_(A(S), r, i, p),
E(([[m, d], u, T, R, I]) => {
let f = d && R, b = "auto";
return f && (b = _o(u, T || I), f = f && !!b), { followOutputBehavior: b, shouldFollow: f, totalCount: m };
}),
P(({ shouldFollow: m }) => m)
),
({ followOutputBehavior: m, totalCount: d }) => {
h && (h(), h = null), st(n) ? requestAnimationFrame(() => {
st(a)("following output to ", { totalCount: d }, mt.DEBUG), w(m);
}) : h = bt(t, () => {
st(a)("following output to ", { totalCount: d }, mt.DEBUG), w(m), h = null;
});
}
);
function v(m) {
const d = bt(o, (u) => {
m && !u.atBottom && u.notAtBottomBecause === "SIZE_INCREASED" && !h && (st(a)("scrolling to bottom due to increased size", {}, mt.DEBUG), w("auto"));
});
setTimeout(d, 100);
}
return K(
x(
rt(A(S), e, c),
P(([m, , d]) => m && d),
Rt(
({ value: m }, [, d]) => ({ refreshed: m === d, value: d }),
{ refreshed: !1, value: 0 }
),
P(({ refreshed: m }) => m),
_(S, e)
),
([, m]) => {
st(i) && v(m !== !1);
}
), K(g, () => {
v(st(S) !== !1);
}), K(rt(A(S), o), ([m, d]) => {
m && !d.atBottom && d.notAtBottomBecause === "VIEWPORT_HEIGHT_DECREASING" && w("auto");
}), { autoscrollToBottom: g, followOutput: S };
},
X(Et, ae, ce, ue, Pt, Vt, at)
), Do = U(
([{ data: t, firstItemIndex: e, gap: n, sizes: o }, { initialTopMostItemIndex: r }, { initialItemCount: s, listState: i }, { didMount: l }]) => (O(
x(
l,
_(s),
P(([, c]) => c !== 0),
_(r, o, e, n, t),
E(([[, c], a, p, S, g, h = []]) => Un(c, a, p, S, g, h))
),
i
), {}),
X(Et, ue, Dt, Pt),
{ singleton: !0 }
), $o = U(
([{ didMount: t }, { scrollTo: e }, { listState: n }]) => {
const o = C(0);
return K(
x(
t,
_(o),
P(([, r]) => r !== 0),
E(([, r]) => ({ top: r }))
),
(r) => {
bt(
x(
n,
jt(1),
P((s) => s.items.length > 1)
),
() => {
requestAnimationFrame(() => {
G(e, r);
});
}
);
}
), {
initialScrollTop: o
};
},
X(Pt, at, Dt),
{ singleton: !0 }
), Uo = ({
itemBottom: t,
itemTop: e,
locationParams: { align: n, behavior: o, ...r },
viewportBottom: s,
viewportTop: i
}) => e < i ? { ...r, align: n != null ? n : "start", behavior: o } : t > s ? { ...r, align: n != null ? n : "end", behavior: o } : null, Ko = U(
([
{ gap: t, sizes: e, totalCount: n },
{ fixedFooterHeight: o, fixedHeaderHeight: r, headerHeight: s, scrollingInProgress: i, scrollTop: l, viewportHeight: c },
{ scrollToIndex: a }
]) => {
const p = $();
return O(
x(
p,
_(e, c, n, s, r, o, l),
_(t),
E(([[S, g, h, w, v, m, d, u], T]) => {
const { align: R, behavior: I, calculateViewLocation: f = Uo, done: b, ...k } = S, F = _n(S, g, w - 1), L = ie(F, g.offsetTree, T) + v + m, V = L + Ct(g.sizeTree, F)[1], D = u + m, J = u + h - d, nt = f({
itemBottom: V,
itemTop: L,
locationParams: { align: R, behavior: I, ...k },
viewportBottom: J,
viewportTop: D
});
return nt ? b && bt(
x(
i,
P((B) => !B),
// skips the initial publish of false, and the cleanup call.
// but if scrollingInProgress is true, we skip the initial publish.
jt(st(i) ? 1 : 2)
),
b
) : b && b(), nt;
}),
P((S) => S !== null)
),
a
), {
scrollIntoView: p
};
},
X(Et, at, ce, Dt, Vt),
{ singleton: !0 }
), jn = U(
([{ scrollVelocity: t }]) => {
const e = C(!1), n = $(), o = C(!1);
return O(
x(
t,
_(o, e, n),
P(([r, s]) => !!s),
E(([r, s, i, l]) => {
const { enter: c, exit: a } = s;
if (i) {
if (a(r, l))
return !1;
} else if (c(r, l))
return !0;
return i;
}),
Z()
),
e
), K(
x(rt(e, t, n), _(o)),
([[r, s, i], l]) => {
r && l && l.change && l.change(s, i);
}
), { isSeeking: e, scrollSeekConfiguration: o, scrollSeekRangeChanged: n, scrollVelocity: t };
},
X(ae),
{ singleton: !0 }
), je = U(([{ scrollContainerState: t, scrollTo: e }]) => {
const n = $(), o = $(), r = $(), s = C(!1), i = C(void 0);
return O(
x(
rt(n, o),
E(([{ scrollHeight: l, scrollTop: c, viewportHeight: a }, { offsetTop: p }]) => ({
scrollHeight: l,
scrollTop: Math.max(0, c - p),
viewportHeight: a
}))
),
t
), O(
x(
e,
_(o),
E(([l, { offsetTop: c }]) => ({
...l,
top: l.top + c
}))
),
r
), {
customScrollParent: i,
// config
useWindowScroll: s,
// input
windowScrollContainerState: n,
// signals
windowScrollTo: r,
windowViewportRect: o
};
}, X(at)), jo = U(
([
{ sizeRanges: t, sizes: e },
{ headerHeight: n, scrollTop: o },
{ initialTopMostItemIndex: r },
{ didMount: s },
{ useWindowScroll: i, windowScrollContainerState: l, windowViewportRect: c }
]) => {
const a = $(), p = C(void 0), S = C(null), g = C(null);
return O(l, S), O(c, g), K(
x(
a,
_(e, o, i, S, g, n)
),
([h, w, v, m, d, u, T]) => {
const R = Bo(w.sizeTree);
m && d !== null && u !== null && (v = d.scrollTop - u.offsetTop), v -= T, h({ ranges: R, scrollTop: v });
}
), O(x(p, P(Me), E(qo)), r), O(
x(
s,
_(p),
P(([, h]) => h !== void 0),
Z(),
E(([, h]) => h.ranges)
),
t
), {
getState: a,
restoreStateFrom: p
};
},
X(Et, at, ue, Pt, je)
);
function qo(t) {
return { align: "start", index: 0, offset: t.scrollTop };
}
const Yo = U(([{ topItemsIndexes: t }]) => {
const e = C(0);
return O(
x(
e,
P((n) => n >= 0),
E((n) => Array.from({ length: n }).map((o, r) => r))
),
t
), { topItemCount: e };
}, X(Dt));
function qn(t) {
let e = !1, n;
return () => (e || (e = !0, n = t()), n);
}
const Zo = qn(() => /iP(ad|od|hone)/i.test(navigator.userAgent) && /WebKit/i.test(navigator.userAgent)), Xo = U(
([
{ deviation: t, scrollBy: e, scrollingInProgress: n, scrollTop: o },
{ isAtBottom: r, isScrolling: s, lastJumpDueToItemResize: i, scrollDirection: l },
{ listState: c },
{ beforeUnshiftWith: a, gap: p, shiftWithOffset: S, sizes: g },
{ log: h },
{ recalcInProgress: w }
]) => {
const v = ht(
x(
c,
_(i),
Rt(
([, d, u, T], [{ bottom: R, items: I, offsetBottom: f, totalCount: b }, k]) => {
const F = R + f;
let L = 0;
return u === b && d.length > 0 && I.length > 0 && (I[0].originalIndex === 0 && d[0].originalIndex === 0 || (L = F - T, L !== 0 && (L += k))), [L, I, b, F];
},
[0, [], 0, 0]
),
P(([d]) => d !== 0),
_(o, l, n, r, h, w),
P(([, d, u, T, , , R]) => !R && !T && d !== 0 && u === le),
E(([[d], , , , , u]) => (u("Upward scrolling compensation", { amount: d }, mt.DEBUG), d))
)
);
function m(d) {
d > 0 ? (G(e, { behavior: "auto", top: -d }), G(t, 0)) : (G(t, 0), G(e, { behavior: "auto", top: -d }));
}
return K(x(v, _(t, s)), ([d, u, T]) => {
T && Zo() ? G(t, u - d) : m(-d);
}), K(
x(
rt(ct(s, !1), t, w),
P(([d, u, T]) => !d && !T && u !== 0),
E(([d, u]) => u),
Lt(1)
),
m
), O(
x(
S,
E((d) => ({ top: -d }))
),
e
), K(
x(
a,
_(g, p),
E(([d, { groupIndices: u, lastSize: T, sizeTree: R }, I]) => {
function f(b) {
return b * (T + I);
}
if (u.length === 0)
return f(d);
{
let b = 0;
const k = re(R, 0);
let F = 0, L = 0;
for (; F < d; ) {
F++, b += k;
let V = u.length === L + 1 ? 1 / 0 : u[L + 1] - u[L] - 1;
F + V > d && (b -= k, V = d - F + 1), F += V, b += f(V), L++;
}
return b;
}
})
),
(d) => {
G(t, d), requestAnimationFrame(() => {
G(e, { top: d }), requestAnimationFrame(() => {
G(t, 0), G(w, !1);
});
});
}
), { deviation: t };
},
X(at, ae, Dt, Et, Vt, Ne)
), Jo = U(
([
t,
e,
n,
o,
r,
s,
i,
l,
c,
a
]) => ({
...t,
...e,
...n,
...o,
...r,
...s,
...i,
...l,
...c,
...a
}),
X(
Ke,
Do,
Pt,
jn,
Kn,