hello-csv
Version:
A modern CSV importer written in Preact
1,367 lines • 385 kB
JavaScript
var ns = Object.defineProperty;
var rs = (e, t, n) => t in e ? ns(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var Oe = (e, t, n) => rs(e, typeof t != "symbol" ? t + "" : t, n);
import * as E from "react";
import D, { forwardRef as En, useId as Ne, useRef as G, useCallback as ue, useEffect as le, useState as te, useMemo as re, useLayoutEffect as Pr, useContext as ce, createContext as me, Fragment as Me, isValidElement as os, cloneElement as is, createElement as ls, useReducer as Rn, useSyncExternalStore as ss, createRef as Xo, render as as, h as us } from "react";
import { jsx as h, jsxs as L, Fragment as Zo } from "react/jsx-runtime";
import * as hn from "react-dom";
import { createPortal as Ar, flushSync as dt } from "react-dom";
function Qo(e) {
var t, n, r = "";
if (typeof e == "string" || typeof e == "number") r += e;
else if (typeof e == "object") if (Array.isArray(e)) {
var o = e.length;
for (t = 0; t < o; t++) e[t] && (n = Qo(e[t])) && (r && (r += " "), r += n);
} else for (n in e) e[n] && (r && (r += " "), r += n);
return r;
}
function cs() {
for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = Qo(e)) && (r && (r += " "), r += t);
return r;
}
const io = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, lo = cs, wt = (e, t) => (n) => {
var r;
if ((t == null ? void 0 : t.variants) == null) return lo(e, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
const { variants: o, defaultVariants: i } = t, l = Object.keys(o).map((u) => {
const c = n == null ? void 0 : n[u], f = i == null ? void 0 : i[u];
if (c === null) return null;
const m = io(c) || io(f);
return o[u][m];
}), s = n && Object.entries(n).reduce((u, c) => {
let [f, m] = c;
return m === void 0 || (u[f] = m), u;
}, {}), a = t == null || (r = t.compoundVariants) === null || r === void 0 ? void 0 : r.reduce((u, c) => {
let { class: f, className: m, ...d } = c;
return Object.entries(d).every((p) => {
let [g, w] = p;
return Array.isArray(w) ? w.includes({
...i,
...s
}[g]) : {
...i,
...s
}[g] === w;
}) ? [
...u,
f,
m
] : u;
}, []);
return lo(e, l, a, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
}, ds = wt(
"text-center inline-block font-semibold px-3 py-2 rounded-md text-sm",
{
variants: {
variant: {
primary: "shadow-xs bg-hello-csv-primary text-white",
secondary: "bg-white text-hello-csv-primary ring-1 shadow-xs ring-bg-hello-csv-primary ring-inset",
tertiary: "bg-white text-gray-900 ring-1 shadow-xs ring-hello-csv-tertiary ring-inset",
success: "shadow-xs bg-hello-csv-success text-white",
danger: "shadow-xs bg-hello-csv-danger text-white"
},
withFullWidth: {
true: "w-full",
false: ""
},
disabled: {
true: "opacity-50 cursor-not-allowed pointer-events-none",
false: "cursor-pointer"
}
},
compoundVariants: [
{
variant: "primary",
disabled: !1,
className: "hover:bg-hello-csv-primary-light focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-primary"
},
{
variant: "secondary",
disabled: !1,
className: "hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-secondary"
},
{
variant: "tertiary",
disabled: !1,
className: "hover:bg-hello-csv-tertiary-light"
},
{
variant: "success",
disabled: !1,
className: "hover:opacity-80 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-success"
},
{
variant: "danger",
disabled: !1,
className: "hover:bg-hello-csv-danger-light focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-hello-csv-danger"
}
],
defaultVariants: {
withFullWidth: !1,
variant: "primary",
disabled: !1
}
}
);
function ke({
children: e,
variant: t,
disabled: n,
onClick: r,
withFullWidth: o
}) {
const i = ds({ variant: t, disabled: n, withFullWidth: o });
return /* @__PURE__ */ h(
"div",
{
role: "button",
tabIndex: 0,
className: i,
onClick: r,
"aria-disabled": n,
children: e
}
);
}
const fs = wt("overflow-hidden rounded-md border border-gray-200", {
variants: {
variant: {
default: "bg-white",
muted: "bg-hello-csv-muted"
},
withPadding: {
true: "px-4 py-5 sm:p-6",
false: ""
}
},
defaultVariants: {
variant: "default",
withPadding: !0
}
}), Jo = En(
({ children: e, className: t, variant: n, withPadding: r = !0 }, o) => {
const i = fs({ variant: n, withPadding: r });
return /* @__PURE__ */ h("div", { ref: o, className: `${i} ${t}`, children: e });
}
);
function ei({ checked: e, setChecked: t, label: n }) {
const r = Ne();
return /* @__PURE__ */ L("div", { className: "flex gap-3", children: [
/* @__PURE__ */ h("div", { className: "flex h-6 shrink-0 items-center", children: /* @__PURE__ */ L("div", { className: "group grid size-4 grid-cols-1", children: [
/* @__PURE__ */ h(
"input",
{
checked: e,
onChange: (o) => t(o.target.checked),
id: r,
type: "checkbox",
className: "checked:border-hello-csv-primary checked:bg-hello-csv-primary indeterminate:border-hello-csv-primary indeterminate:bg-hello-csv-primary focus-visible:outline-hello-csv-hello-csv-primary col-start-1 row-start-1 appearance-none rounded-sm border border-gray-300 bg-white focus-visible:outline-2 focus-visible:outline-offset-2 disabled:border-gray-300 disabled:bg-gray-100 disabled:checked:bg-gray-100 forced-colors:appearance-auto"
}
),
/* @__PURE__ */ L(
"svg",
{
fill: "none",
viewBox: "0 0 14 14",
className: "pointer-events-none col-start-1 row-start-1 size-3.5 self-center justify-self-center stroke-white group-has-disabled:stroke-gray-950/25",
children: [
/* @__PURE__ */ h(
"path",
{
d: "M3 8L6 11L11 3.5",
strokeWidth: 2,
strokeLinecap: "round",
strokeLinejoin: "round",
className: "opacity-0 group-has-checked:opacity-100"
}
),
/* @__PURE__ */ h(
"path",
{
d: "M3 7H11",
strokeWidth: 2,
strokeLinecap: "round",
strokeLinejoin: "round",
className: "opacity-0 group-has-indeterminate:opacity-100"
}
)
]
}
)
] }) }),
n && /* @__PURE__ */ h("div", { className: "text-sm/6", children: /* @__PURE__ */ h("label", { htmlFor: r, className: "font-medium text-gray-900", children: n }) })
] });
}
let ps = !1;
function Nr() {
return ps;
}
const ti = typeof document < "u" ? D.useLayoutEffect : () => {
};
function ms(e) {
const t = G(null);
return ti(() => {
t.current = e;
}, [
e
]), ue((...n) => {
const r = t.current;
return r == null ? void 0 : r(...n);
}, []);
}
const st = (e) => {
var t;
return (t = e == null ? void 0 : e.ownerDocument) !== null && t !== void 0 ? t : document;
}, ft = (e) => e && "window" in e && e.window === e ? e : st(e).defaultView || window;
function gs(e) {
return e !== null && typeof e == "object" && "nodeType" in e && typeof e.nodeType == "number";
}
function hs(e) {
return gs(e) && e.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in e;
}
function ni(e, t) {
if (!Nr()) return t && e ? e.contains(t) : !1;
if (!e || !t) return !1;
let n = t;
for (; n !== null; ) {
if (n === e) return !0;
n.tagName === "SLOT" && n.assignedSlot ? n = n.assignedSlot.parentNode : hs(n) ? n = n.host : n = n.parentNode;
}
return !1;
}
const sr = (e = document) => {
var t;
if (!Nr()) return e.activeElement;
let n = e.activeElement;
for (; n && "shadowRoot" in n && (!((t = n.shadowRoot) === null || t === void 0) && t.activeElement); ) n = n.shadowRoot.activeElement;
return n;
};
function ri(e) {
return Nr() && e.target.shadowRoot && e.composedPath ? e.composedPath()[0] : e.target;
}
function vs(e) {
var t;
return typeof window > "u" || window.navigator == null ? !1 : ((t = window.navigator.userAgentData) === null || t === void 0 ? void 0 : t.brands.some((n) => e.test(n.brand))) || e.test(window.navigator.userAgent);
}
function ws(e) {
var t;
return typeof window < "u" && window.navigator != null ? e.test(((t = window.navigator.userAgentData) === null || t === void 0 ? void 0 : t.platform) || window.navigator.platform) : !1;
}
function oi(e) {
let t = null;
return () => (t == null && (t = e()), t);
}
const bs = oi(function() {
return ws(/^Mac/i);
}), ys = oi(function() {
return vs(/Android/i);
});
function ii() {
let e = G(/* @__PURE__ */ new Map()), t = ue((o, i, l, s) => {
let a = s != null && s.once ? (...u) => {
e.current.delete(l), l(...u);
} : l;
e.current.set(l, {
type: i,
eventTarget: o,
fn: a,
options: s
}), o.addEventListener(i, a, s);
}, []), n = ue((o, i, l, s) => {
var a;
let u = ((a = e.current.get(l)) === null || a === void 0 ? void 0 : a.fn) || l;
o.removeEventListener(i, u, s), e.current.delete(l);
}, []), r = ue(() => {
e.current.forEach((o, i) => {
n(o.eventTarget, o.type, i, o.options);
});
}, [
n
]);
return le(() => r, [
r
]), {
addGlobalListener: t,
removeGlobalListener: n,
removeAllGlobalListeners: r
};
}
function xs(e) {
return e.mozInputSource === 0 && e.isTrusted ? !0 : ys() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function li(e) {
let t = e;
return t.nativeEvent = e, t.isDefaultPrevented = () => t.defaultPrevented, t.isPropagationStopped = () => t.cancelBubble, t.persist = () => {
}, t;
}
function Ss(e, t) {
Object.defineProperty(e, "target", {
value: t
}), Object.defineProperty(e, "currentTarget", {
value: t
});
}
function si(e) {
let t = G({
isFocused: !1,
observer: null
});
ti(() => {
const r = t.current;
return () => {
r.observer && (r.observer.disconnect(), r.observer = null);
};
}, []);
let n = ms((r) => {
e == null || e(r);
});
return ue((r) => {
if (r.target instanceof HTMLButtonElement || r.target instanceof HTMLInputElement || r.target instanceof HTMLTextAreaElement || r.target instanceof HTMLSelectElement) {
t.current.isFocused = !0;
let o = r.target, i = (l) => {
if (t.current.isFocused = !1, o.disabled) {
let s = li(l);
n(s);
}
t.current.observer && (t.current.observer.disconnect(), t.current.observer = null);
};
o.addEventListener("focusout", i, {
once: !0
}), t.current.observer = new MutationObserver(() => {
if (t.current.isFocused && o.disabled) {
var l;
(l = t.current.observer) === null || l === void 0 || l.disconnect();
let s = o === document.activeElement ? null : document.activeElement;
o.dispatchEvent(new FocusEvent("blur", {
relatedTarget: s
})), o.dispatchEvent(new FocusEvent("focusout", {
bubbles: !0,
relatedTarget: s
}));
}
}), t.current.observer.observe(o, {
attributes: !0,
attributeFilter: [
"disabled"
]
});
}
}, [
n
]);
}
let Cs = !1, Qt = null, ar = /* @__PURE__ */ new Set(), Bt = /* @__PURE__ */ new Map(), gt = !1, ur = !1;
const Es = {
Tab: !0,
Escape: !0
};
function kr(e, t) {
for (let n of ar) n(e, t);
}
function Rs(e) {
return !(e.metaKey || !bs() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
}
function vn(e) {
gt = !0, Rs(e) && (Qt = "keyboard", kr("keyboard", e));
}
function $t(e) {
Qt = "pointer", (e.type === "mousedown" || e.type === "pointerdown") && (gt = !0, kr("pointer", e));
}
function ai(e) {
xs(e) && (gt = !0, Qt = "virtual");
}
function ui(e) {
e.target === window || e.target === document || Cs || !e.isTrusted || (!gt && !ur && (Qt = "virtual", kr("virtual", e)), gt = !1, ur = !1);
}
function ci() {
gt = !1, ur = !0;
}
function cr(e) {
if (typeof window > "u" || Bt.get(ft(e))) return;
const t = ft(e), n = st(e);
let r = t.HTMLElement.prototype.focus;
t.HTMLElement.prototype.focus = function() {
gt = !0, r.apply(this, arguments);
}, n.addEventListener("keydown", vn, !0), n.addEventListener("keyup", vn, !0), n.addEventListener("click", ai, !0), t.addEventListener("focus", ui, !0), t.addEventListener("blur", ci, !1), typeof PointerEvent < "u" && (n.addEventListener("pointerdown", $t, !0), n.addEventListener("pointermove", $t, !0), n.addEventListener("pointerup", $t, !0)), t.addEventListener("beforeunload", () => {
di(e);
}, {
once: !0
}), Bt.set(t, {
focus: r
});
}
const di = (e, t) => {
const n = ft(e), r = st(e);
t && r.removeEventListener("DOMContentLoaded", t), Bt.has(n) && (n.HTMLElement.prototype.focus = Bt.get(n).focus, r.removeEventListener("keydown", vn, !0), r.removeEventListener("keyup", vn, !0), r.removeEventListener("click", ai, !0), n.removeEventListener("focus", ui, !0), n.removeEventListener("blur", ci, !1), typeof PointerEvent < "u" && (r.removeEventListener("pointerdown", $t, !0), r.removeEventListener("pointermove", $t, !0), r.removeEventListener("pointerup", $t, !0)), Bt.delete(n));
};
function $s(e) {
const t = st(e);
let n;
return t.readyState !== "loading" ? cr(e) : (n = () => {
cr(e);
}, t.addEventListener("DOMContentLoaded", n)), () => di(e, n);
}
typeof document < "u" && $s();
function fi() {
return Qt !== "pointer";
}
const _s = /* @__PURE__ */ new Set([
"checkbox",
"radio",
"range",
"color",
"file",
"image",
"button",
"submit",
"reset"
]);
function Ts(e, t, n) {
let r = st(n == null ? void 0 : n.target);
const o = typeof window < "u" ? ft(n == null ? void 0 : n.target).HTMLInputElement : HTMLInputElement, i = typeof window < "u" ? ft(n == null ? void 0 : n.target).HTMLTextAreaElement : HTMLTextAreaElement, l = typeof window < "u" ? ft(n == null ? void 0 : n.target).HTMLElement : HTMLElement, s = typeof window < "u" ? ft(n == null ? void 0 : n.target).KeyboardEvent : KeyboardEvent;
return e = e || r.activeElement instanceof o && !_s.has(r.activeElement.type) || r.activeElement instanceof i || r.activeElement instanceof l && r.activeElement.isContentEditable, !(e && t === "keyboard" && n instanceof s && !Es[n.key]);
}
function Is(e, t, n) {
cr(), le(() => {
let r = (o, i) => {
Ts(!!(n != null && n.isTextInput), o, i) && e(fi());
};
return ar.add(r), () => {
ar.delete(r);
};
}, t);
}
function Ms(e) {
let { isDisabled: t, onFocus: n, onBlur: r, onFocusChange: o } = e;
const i = ue((a) => {
if (a.target === a.currentTarget)
return r && r(a), o && o(!1), !0;
}, [
r,
o
]), l = si(i), s = ue((a) => {
const u = st(a.target), c = u ? sr(u) : sr();
a.target === a.currentTarget && c === ri(a.nativeEvent) && (n && n(a), o && o(!0), l(a));
}, [
o,
n,
l
]);
return {
focusProps: {
onFocus: !t && (n || o || r) ? s : void 0,
onBlur: !t && (r || o) ? i : void 0
}
};
}
function Fs(e) {
let { isDisabled: t, onBlurWithin: n, onFocusWithin: r, onFocusWithinChange: o } = e, i = G({
isFocusWithin: !1
}), { addGlobalListener: l, removeAllGlobalListeners: s } = ii(), a = ue((f) => {
f.currentTarget.contains(f.target) && i.current.isFocusWithin && !f.currentTarget.contains(f.relatedTarget) && (i.current.isFocusWithin = !1, s(), n && n(f), o && o(!1));
}, [
n,
o,
i,
s
]), u = si(a), c = ue((f) => {
if (!f.currentTarget.contains(f.target)) return;
const m = st(f.target), d = sr(m);
if (!i.current.isFocusWithin && d === ri(f.nativeEvent)) {
r && r(f), o && o(!0), i.current.isFocusWithin = !0, u(f);
let p = f.currentTarget;
l(m, "focus", (g) => {
if (i.current.isFocusWithin && !ni(p, g.target)) {
let w = new m.defaultView.FocusEvent("blur", {
relatedTarget: g.target
});
Ss(w, p);
let y = li(w);
a(y);
}
}, {
capture: !0
});
}
}, [
r,
o,
u,
l,
a
]);
return t ? {
focusWithinProps: {
// These cannot be null, that would conflict in mergeProps
onFocus: void 0,
onBlur: void 0
}
} : {
focusWithinProps: {
onFocus: c,
onBlur: a
}
};
}
let dr = !1, Gn = 0;
function Os() {
dr = !0, setTimeout(() => {
dr = !1;
}, 50);
}
function so(e) {
e.pointerType === "touch" && Os();
}
function Ps() {
if (!(typeof document > "u"))
return typeof PointerEvent < "u" && document.addEventListener("pointerup", so), Gn++, () => {
Gn--, !(Gn > 0) && typeof PointerEvent < "u" && document.removeEventListener("pointerup", so);
};
}
function pi(e) {
let { onHoverStart: t, onHoverChange: n, onHoverEnd: r, isDisabled: o } = e, [i, l] = te(!1), s = G({
isHovered: !1,
ignoreEmulatedMouseEvents: !1,
pointerType: "",
target: null
}).current;
le(Ps, []);
let { addGlobalListener: a, removeAllGlobalListeners: u } = ii(), { hoverProps: c, triggerHoverEnd: f } = re(() => {
let m = (g, w) => {
if (s.pointerType = w, o || w === "touch" || s.isHovered || !g.currentTarget.contains(g.target)) return;
s.isHovered = !0;
let y = g.currentTarget;
s.target = y, a(st(g.target), "pointerover", (S) => {
s.isHovered && s.target && !ni(s.target, S.target) && d(S, S.pointerType);
}, {
capture: !0
}), t && t({
type: "hoverstart",
target: y,
pointerType: w
}), n && n(!0), l(!0);
}, d = (g, w) => {
let y = s.target;
s.pointerType = "", s.target = null, !(w === "touch" || !s.isHovered || !y) && (s.isHovered = !1, u(), r && r({
type: "hoverend",
target: y,
pointerType: w
}), n && n(!1), l(!1));
}, p = {};
return typeof PointerEvent < "u" && (p.onPointerEnter = (g) => {
dr && g.pointerType === "mouse" || m(g, g.pointerType);
}, p.onPointerLeave = (g) => {
!o && g.currentTarget.contains(g.target) && d(g, g.pointerType);
}), {
hoverProps: p,
triggerHoverEnd: d
};
}, [
t,
n,
r,
o,
s,
a,
u
]);
return le(() => {
o && f({
currentTarget: s.target
}, s.pointerType);
}, [
o
]), {
hoverProps: c,
isHovered: i
};
}
function mi(e = {}) {
let { autoFocus: t = !1, isTextInput: n, within: r } = e, o = G({
isFocused: !1,
isFocusVisible: t || fi()
}), [i, l] = te(!1), [s, a] = te(() => o.current.isFocused && o.current.isFocusVisible), u = ue(() => a(o.current.isFocused && o.current.isFocusVisible), []), c = ue((d) => {
o.current.isFocused = d, l(d), u();
}, [
u
]);
Is((d) => {
o.current.isFocusVisible = d, u();
}, [], {
isTextInput: n
});
let { focusProps: f } = Ms({
isDisabled: r,
onFocusChange: c
}), { focusWithinProps: m } = Fs({
isDisabled: !r,
onFocusWithinChange: c
});
return {
isFocused: i,
isFocusVisible: s,
focusProps: r ? m : f
};
}
var As = Object.defineProperty, Ns = (e, t, n) => t in e ? As(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Wn = (e, t, n) => (Ns(e, typeof t != "symbol" ? t + "" : t, n), n);
let ks = class {
constructor() {
Wn(this, "current", this.detect()), Wn(this, "handoffState", "pending"), Wn(this, "currentId", 0);
}
set(t) {
this.current !== t && (this.handoffState = "pending", this.currentId = 0, this.current = t);
}
reset() {
this.set(this.detect());
}
nextId() {
return ++this.currentId;
}
get isServer() {
return this.current === "server";
}
get isClient() {
return this.current === "client";
}
detect() {
return typeof window > "u" || typeof document > "u" ? "server" : "client";
}
handoff() {
this.handoffState === "pending" && (this.handoffState = "complete");
}
get isHandoffComplete() {
return this.handoffState === "complete";
}
}, mt = new ks();
function Ft(e) {
return mt.isServer ? null : e instanceof Node ? e.ownerDocument : e != null && e.hasOwnProperty("current") && e.current instanceof Node ? e.current.ownerDocument : document;
}
function $n(e) {
typeof queueMicrotask == "function" ? queueMicrotask(e) : Promise.resolve().then(e).catch((t) => setTimeout(() => {
throw t;
}));
}
function Ge() {
let e = [], t = { addEventListener(n, r, o, i) {
return n.addEventListener(r, o, i), t.add(() => n.removeEventListener(r, o, i));
}, requestAnimationFrame(...n) {
let r = requestAnimationFrame(...n);
return t.add(() => cancelAnimationFrame(r));
}, nextFrame(...n) {
return t.requestAnimationFrame(() => t.requestAnimationFrame(...n));
}, setTimeout(...n) {
let r = setTimeout(...n);
return t.add(() => clearTimeout(r));
}, microTask(...n) {
let r = { current: !0 };
return $n(() => {
r.current && n[0]();
}), t.add(() => {
r.current = !1;
});
}, style(n, r, o) {
let i = n.style.getPropertyValue(r);
return Object.assign(n.style, { [r]: o }), this.add(() => {
Object.assign(n.style, { [r]: i });
});
}, group(n) {
let r = Ge();
return n(r), this.add(() => r.dispose());
}, add(n) {
return e.includes(n) || e.push(n), () => {
let r = e.indexOf(n);
if (r >= 0) for (let o of e.splice(r, 1)) o();
};
}, dispose() {
for (let n of e.splice(0)) n();
} };
return t;
}
function bt() {
let [e] = te(Ge);
return le(() => () => e.dispose(), [e]), e;
}
let ae = (e, t) => {
mt.isServer ? le(e, t) : Pr(e, t);
};
function at(e) {
let t = G(e);
return ae(() => {
t.current = e;
}, [e]), t;
}
let j = function(e) {
let t = at(e);
return D.useCallback((...n) => t.current(...n), [t]);
};
function Ds(e) {
let t = e.width / 2, n = e.height / 2;
return { top: e.clientY - n, right: e.clientX + t, bottom: e.clientY + n, left: e.clientX - t };
}
function Ls(e, t) {
return !(!e || !t || e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
}
function Vs({ disabled: e = !1 } = {}) {
let t = G(null), [n, r] = te(!1), o = bt(), i = j(() => {
t.current = null, r(!1), o.dispose();
}), l = j((s) => {
if (o.dispose(), t.current === null) {
t.current = s.currentTarget, r(!0);
{
let a = Ft(s.currentTarget);
o.addEventListener(a, "pointerup", i, !1), o.addEventListener(a, "pointermove", (u) => {
if (t.current) {
let c = Ds(u);
r(Ls(c, t.current.getBoundingClientRect()));
}
}, !1), o.addEventListener(a, "pointercancel", i, !1);
}
}
});
return { pressed: n, pressProps: e ? {} : { onPointerDown: l, onPointerUp: i, onClick: i } };
}
let Hs = me(void 0);
function Dr() {
return ce(Hs);
}
function fr(...e) {
return Array.from(new Set(e.flatMap((t) => typeof t == "string" ? t.split(" ") : []))).filter(Boolean).join(" ");
}
function Fe(e, t, ...n) {
if (e in t) {
let o = t[e];
return typeof o == "function" ? o(...n) : o;
}
let r = new Error(`Tried to handle "${e}" but there is no handler defined. Only defined handlers are: ${Object.keys(t).map((o) => `"${o}"`).join(", ")}.`);
throw Error.captureStackTrace && Error.captureStackTrace(r, Fe), r;
}
var Tt = ((e) => (e[e.None = 0] = "None", e[e.RenderStrategy = 1] = "RenderStrategy", e[e.Static = 2] = "Static", e))(Tt || {}), tt = ((e) => (e[e.Unmount = 0] = "Unmount", e[e.Hidden = 1] = "Hidden", e))(tt || {});
function ye() {
let e = Bs();
return ue((t) => zs({ mergeRefs: e, ...t }), [e]);
}
function zs({ ourProps: e, theirProps: t, slot: n, defaultTag: r, features: o, visible: i = !0, name: l, mergeRefs: s }) {
s = s ?? js;
let a = gi(t, e);
if (i) return an(a, n, r, l, s);
let u = o ?? 0;
if (u & 2) {
let { static: c = !1, ...f } = a;
if (c) return an(f, n, r, l, s);
}
if (u & 1) {
let { unmount: c = !0, ...f } = a;
return Fe(c ? 0 : 1, { 0() {
return null;
}, 1() {
return an({ ...f, hidden: !0, style: { display: "none" } }, n, r, l, s);
} });
}
return an(a, n, r, l, s);
}
function an(e, t = {}, n, r, o) {
let { as: i = n, children: l, refName: s = "ref", ...a } = qn(e, ["unmount", "static"]), u = e.ref !== void 0 ? { [s]: e.ref } : {}, c = typeof l == "function" ? l(t) : l;
"className" in a && a.className && typeof a.className == "function" && (a.className = a.className(t)), a["aria-labelledby"] && a["aria-labelledby"] === a.id && (a["aria-labelledby"] = void 0);
let f = {};
if (t) {
let m = !1, d = [];
for (let [p, g] of Object.entries(t)) typeof g == "boolean" && (m = !0), g === !0 && d.push(p.replace(/([A-Z])/g, (w) => `-${w.toLowerCase()}`));
if (m) {
f["data-headlessui-state"] = d.join(" ");
for (let p of d) f[`data-${p}`] = "";
}
}
if (i === Me && (Object.keys(et(a)).length > 0 || Object.keys(et(f)).length > 0)) if (!os(c) || Array.isArray(c) && c.length > 1) {
if (Object.keys(et(a)).length > 0) throw new Error(['Passing props on "Fragment"!', "", `The current component <${r} /> is rendering a "Fragment".`, "However we need to passthrough the following props:", Object.keys(et(a)).concat(Object.keys(et(f))).map((m) => ` - ${m}`).join(`
`), "", "You can apply a few solutions:", ['Add an `as="..."` prop, to ensure that we render an actual element instead of a "Fragment".', "Render a single element as the child so that we can forward the props onto that element."].map((m) => ` - ${m}`).join(`
`)].join(`
`));
} else {
let m = c.props, d = m == null ? void 0 : m.className, p = typeof d == "function" ? (...y) => fr(d(...y), a.className) : fr(d, a.className), g = p ? { className: p } : {}, w = gi(c.props, et(qn(a, ["ref"])));
for (let y in f) y in w && delete f[y];
return is(c, Object.assign({}, w, f, u, { ref: o(Gs(c), u.ref) }, g));
}
return ls(i, Object.assign({}, qn(a, ["ref"]), i !== Me && u, i !== Me && f), c);
}
function Bs() {
let e = G([]), t = ue((n) => {
for (let r of e.current) r != null && (typeof r == "function" ? r(n) : r.current = n);
}, []);
return (...n) => {
if (!n.every((r) => r == null)) return e.current = n, t;
};
}
function js(...e) {
return e.every((t) => t == null) ? void 0 : (t) => {
for (let n of e) n != null && (typeof n == "function" ? n(t) : n.current = t);
};
}
function gi(...e) {
if (e.length === 0) return {};
if (e.length === 1) return e[0];
let t = {}, n = {};
for (let r of e) for (let o in r) o.startsWith("on") && typeof r[o] == "function" ? (n[o] != null || (n[o] = []), n[o].push(r[o])) : t[o] = r[o];
if (t.disabled || t["aria-disabled"]) for (let r in n) /^(on(?:Click|Pointer|Mouse|Key)(?:Down|Up|Press)?)$/.test(r) && (n[r] = [(o) => {
var i;
return (i = o == null ? void 0 : o.preventDefault) == null ? void 0 : i.call(o);
}]);
for (let r in n) Object.assign(t, { [r](o, ...i) {
let l = n[r];
for (let s of l) {
if ((o instanceof Event || (o == null ? void 0 : o.nativeEvent) instanceof Event) && o.defaultPrevented) return;
s(o, ...i);
}
} });
return t;
}
function Lr(...e) {
if (e.length === 0) return {};
if (e.length === 1) return e[0];
let t = {}, n = {};
for (let r of e) for (let o in r) o.startsWith("on") && typeof r[o] == "function" ? (n[o] != null || (n[o] = []), n[o].push(r[o])) : t[o] = r[o];
for (let r in n) Object.assign(t, { [r](...o) {
let i = n[r];
for (let l of i) l == null || l(...o);
} });
return t;
}
function we(e) {
var t;
return Object.assign(En(e), { displayName: (t = e.displayName) != null ? t : e.name });
}
function et(e) {
let t = Object.assign({}, e);
for (let n in t) t[n] === void 0 && delete t[n];
return t;
}
function qn(e, t = []) {
let n = Object.assign({}, e);
for (let r of t) r in n && delete n[r];
return n;
}
function Gs(e) {
return D.version.split(".")[0] >= "19" ? e.props.ref : e.ref;
}
function Ws(e, t, n) {
let [r, o] = te(n), i = e !== void 0, l = G(i), s = G(!1), a = G(!1);
return i && !l.current && !s.current ? (s.current = !0, l.current = i, console.error("A component is changing from uncontrolled to controlled. This may be caused by the value changing from undefined to a defined value, which should not happen.")) : !i && l.current && !a.current && (a.current = !0, l.current = i, console.error("A component is changing from controlled to uncontrolled. This may be caused by the value changing from a defined value to undefined, which should not happen.")), [i ? e : r, j((u) => (i || o(u), t == null ? void 0 : t(u)))];
}
function qs(e) {
let [t] = te(e);
return t;
}
function hi(e = {}, t = null, n = []) {
for (let [r, o] of Object.entries(e)) wi(n, vi(t, r), o);
return n;
}
function vi(e, t) {
return e ? e + "[" + t + "]" : t;
}
function wi(e, t, n) {
if (Array.isArray(n)) for (let [r, o] of n.entries()) wi(e, vi(t, r.toString()), o);
else n instanceof Date ? e.push([t, n.toISOString()]) : typeof n == "boolean" ? e.push([t, n ? "1" : "0"]) : typeof n == "string" ? e.push([t, n]) : typeof n == "number" ? e.push([t, `${n}`]) : n == null ? e.push([t, ""]) : hi(n, t, e);
}
let Us = "span";
var It = ((e) => (e[e.None = 1] = "None", e[e.Focusable = 2] = "Focusable", e[e.Hidden = 4] = "Hidden", e))(It || {});
function Ks(e, t) {
var n;
let { features: r = 1, ...o } = e, i = { ref: t, "aria-hidden": (r & 2) === 2 ? !0 : (n = o["aria-hidden"]) != null ? n : void 0, hidden: (r & 4) === 4 ? !0 : void 0, style: { position: "fixed", top: 1, left: 1, width: 1, height: 0, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0, 0, 0, 0)", whiteSpace: "nowrap", borderWidth: "0", ...(r & 4) === 4 && (r & 2) !== 2 && { display: "none" } } };
return ye()({ ourProps: i, theirProps: o, slot: {}, defaultTag: Us, name: "Hidden" });
}
let qt = we(Ks), Ys = me(null);
function Xs({ children: e }) {
let t = ce(Ys);
if (!t) return D.createElement(D.Fragment, null, e);
let { target: n } = t;
return n ? Ar(D.createElement(D.Fragment, null, e), n) : null;
}
function Zs({ data: e, form: t, disabled: n, onReset: r, overrides: o }) {
let [i, l] = te(null), s = bt();
return le(() => {
if (r && i) return s.addEventListener(i, "reset", r);
}, [i, t, r]), D.createElement(Xs, null, D.createElement(Qs, { setForm: l, formId: t }), hi(e).map(([a, u]) => D.createElement(qt, { features: It.Hidden, ...et({ key: a, as: "input", type: "hidden", hidden: !0, readOnly: !0, form: t, disabled: n, name: a, value: u, ...o }) })));
}
function Qs({ setForm: e, formId: t }) {
return le(() => {
if (t) {
let n = document.getElementById(t);
n && e(n);
}
}, [e, t]), t ? null : D.createElement(qt, { features: It.Hidden, as: "input", type: "hidden", hidden: !0, readOnly: !0, ref: (n) => {
if (!n) return;
let r = n.closest("form");
r && e(r);
} });
}
let Js = me(void 0);
function bi() {
return ce(Js);
}
function ea(e) {
let t = e.parentElement, n = null;
for (; t && !(t instanceof HTMLFieldSetElement); ) t instanceof HTMLLegendElement && (n = t), t = t.parentElement;
let r = (t == null ? void 0 : t.getAttribute("disabled")) === "";
return r && ta(n) ? !1 : r;
}
function ta(e) {
if (!e) return !1;
let t = e.previousElementSibling;
for (; t !== null; ) {
if (t instanceof HTMLLegendElement) return !1;
t = t.previousElementSibling;
}
return !0;
}
let yi = Symbol();
function na(e, t = !0) {
return Object.assign(e, { [yi]: t });
}
function Te(...e) {
let t = G(e);
le(() => {
t.current = e;
}, [e]);
let n = j((r) => {
for (let o of t.current) o != null && (typeof o == "function" ? o(r) : o.current = r);
});
return e.every((r) => r == null || (r == null ? void 0 : r[yi])) ? void 0 : n;
}
let _n = me(null);
_n.displayName = "DescriptionContext";
function xi() {
let e = ce(_n);
if (e === null) {
let t = new Error("You used a <Description /> component, but it is not inside a relevant parent.");
throw Error.captureStackTrace && Error.captureStackTrace(t, xi), t;
}
return e;
}
function ra() {
var e, t;
return (t = (e = ce(_n)) == null ? void 0 : e.value) != null ? t : void 0;
}
function oa() {
let [e, t] = te([]);
return [e.length > 0 ? e.join(" ") : void 0, re(() => function(n) {
let r = j((i) => (t((l) => [...l, i]), () => t((l) => {
let s = l.slice(), a = s.indexOf(i);
return a !== -1 && s.splice(a, 1), s;
}))), o = re(() => ({ register: r, slot: n.slot, name: n.name, props: n.props, value: n.value }), [r, n.slot, n.name, n.props, n.value]);
return D.createElement(_n.Provider, { value: o }, n.children);
}, [t])];
}
let ia = "p";
function la(e, t) {
let n = Ne(), r = Dr(), { id: o = `headlessui-description-${n}`, ...i } = e, l = xi(), s = Te(t);
ae(() => l.register(o), [o, l.register]);
let a = r || !1, u = re(() => ({ ...l.slot, disabled: a }), [l.slot, a]), c = { ref: s, ...l.props, id: o };
return ye()({ ourProps: c, theirProps: i, slot: u, defaultTag: ia, name: l.name || "Description" });
}
let sa = we(la), aa = Object.assign(sa, {});
var Ee = ((e) => (e.Space = " ", e.Enter = "Enter", e.Escape = "Escape", e.Backspace = "Backspace", e.Delete = "Delete", e.ArrowLeft = "ArrowLeft", e.ArrowUp = "ArrowUp", e.ArrowRight = "ArrowRight", e.ArrowDown = "ArrowDown", e.Home = "Home", e.End = "End", e.PageUp = "PageUp", e.PageDown = "PageDown", e.Tab = "Tab", e))(Ee || {});
let Tn = me(null);
Tn.displayName = "LabelContext";
function Si() {
let e = ce(Tn);
if (e === null) {
let t = new Error("You used a <Label /> component, but it is not inside a relevant parent.");
throw Error.captureStackTrace && Error.captureStackTrace(t, Si), t;
}
return e;
}
function In(e) {
var t, n, r;
let o = (n = (t = ce(Tn)) == null ? void 0 : t.value) != null ? n : void 0;
return ((r = e == null ? void 0 : e.length) != null ? r : 0) > 0 ? [o, ...e].filter(Boolean).join(" ") : o;
}
function ua({ inherit: e = !1 } = {}) {
let t = In(), [n, r] = te([]), o = e ? [t, ...n].filter(Boolean) : n;
return [o.length > 0 ? o.join(" ") : void 0, re(() => function(i) {
let l = j((a) => (r((u) => [...u, a]), () => r((u) => {
let c = u.slice(), f = c.indexOf(a);
return f !== -1 && c.splice(f, 1), c;
}))), s = re(() => ({ register: l, slot: i.slot, name: i.name, props: i.props, value: i.value }), [l, i.slot, i.name, i.props, i.value]);
return D.createElement(Tn.Provider, { value: s }, i.children);
}, [r])];
}
let ca = "label";
function da(e, t) {
var n;
let r = Ne(), o = Si(), i = bi(), l = Dr(), { id: s = `headlessui-label-${r}`, htmlFor: a = i ?? ((n = o.props) == null ? void 0 : n.htmlFor), passive: u = !1, ...c } = e, f = Te(t);
ae(() => o.register(s), [s, o.register]);
let m = j((w) => {
let y = w.currentTarget;
if (y instanceof HTMLLabelElement && w.preventDefault(), o.props && "onClick" in o.props && typeof o.props.onClick == "function" && o.props.onClick(w), y instanceof HTMLLabelElement) {
let S = document.getElementById(y.htmlFor);
if (S) {
let C = S.getAttribute("disabled");
if (C === "true" || C === "") return;
let $ = S.getAttribute("aria-disabled");
if ($ === "true" || $ === "") return;
(S instanceof HTMLInputElement && (S.type === "radio" || S.type === "checkbox") || S.role === "radio" || S.role === "checkbox" || S.role === "switch") && S.click(), S.focus({ preventScroll: !0 });
}
}
}), d = l || !1, p = re(() => ({ ...o.slot, disabled: d }), [o.slot, d]), g = { ref: f, ...o.props, id: s, htmlFor: a, onClick: m };
return u && ("onClick" in g && (delete g.htmlFor, delete g.onClick), "onClick" in c && delete c.onClick), ye()({ ourProps: g, theirProps: c, slot: p, defaultTag: a ? ca : "div", name: o.name || "Label" });
}
let fa = we(da), pa = Object.assign(fa, {}), ma = me(() => {
});
function ga({ value: e, children: t }) {
return D.createElement(ma.Provider, { value: e }, t);
}
function Et(e, t, n) {
let r = n.initialDeps ?? [], o;
function i() {
var l, s, a, u;
let c;
n.key && ((l = n.debug) != null && l.call(n)) && (c = Date.now());
const f = e();
if (!(f.length !== r.length || f.some((p, g) => r[g] !== p)))
return o;
r = f;
let d;
if (n.key && ((s = n.debug) != null && s.call(n)) && (d = Date.now()), o = t(...f), n.key && ((a = n.debug) != null && a.call(n))) {
const p = Math.round((Date.now() - c) * 100) / 100, g = Math.round((Date.now() - d) * 100) / 100, w = g / 16, y = (S, C) => {
for (S = String(S); S.length < C; )
S = " " + S;
return S;
};
console.info(
`%c⏱ ${y(g, 5)} /${y(p, 5)} ms`,
`
font-size: .6rem;
font-weight: bold;
color: hsl(${Math.max(
0,
Math.min(120 - 120 * w, 120)
)}deg 100% 31%);`,
n == null ? void 0 : n.key
);
}
return (u = n == null ? void 0 : n.onChange) == null || u.call(n, o), o;
}
return i.updateDeps = (l) => {
r = l;
}, i;
}
function ao(e, t) {
if (e === void 0)
throw new Error("Unexpected undefined");
return e;
}
const ha = (e, t) => Math.abs(e - t) <= 1, va = (e, t, n) => {
let r;
return function(...o) {
e.clearTimeout(r), r = e.setTimeout(() => t.apply(this, o), n);
};
};
var Lt = { NODE_ENV: "production" };
const uo = (e) => {
const { offsetWidth: t, offsetHeight: n } = e;
return { width: t, height: n };
}, wa = (e) => e, ba = (e) => {
const t = Math.max(e.startIndex - e.overscan, 0), n = Math.min(e.endIndex + e.overscan, e.count - 1), r = [];
for (let o = t; o <= n; o++)
r.push(o);
return r;
}, ya = (e, t) => {
const n = e.scrollElement;
if (!n)
return;
const r = e.targetWindow;
if (!r)
return;
const o = (l) => {
const { width: s, height: a } = l;
t({ width: Math.round(s), height: Math.round(a) });
};
if (o(uo(n)), !r.ResizeObserver)
return () => {
};
const i = new r.ResizeObserver((l) => {
const s = () => {
const a = l[0];
if (a != null && a.borderBoxSize) {
const u = a.borderBoxSize[0];
if (u) {
o({ width: u.inlineSize, height: u.blockSize });
return;
}
}
o(uo(n));
};
e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(s) : s();
});
return i.observe(n, { box: "border-box" }), () => {
i.unobserve(n);
};
}, co = {
passive: !0
}, fo = typeof window > "u" ? !0 : "onscrollend" in window, xa = (e, t) => {
const n = e.scrollElement;
if (!n)
return;
const r = e.targetWindow;
if (!r)
return;
let o = 0;
const i = e.options.useScrollendEvent && fo ? () => {
} : va(
r,
() => {
t(o, !1);
},
e.options.isScrollingResetDelay
), l = (c) => () => {
const { horizontal: f, isRtl: m } = e.options;
o = f ? n.scrollLeft * (m && -1 || 1) : n.scrollTop, i(), t(o, c);
}, s = l(!0), a = l(!1);
a(), n.addEventListener("scroll", s, co);
const u = e.options.useScrollendEvent && fo;
return u && n.addEventListener("scrollend", a, co), () => {
n.removeEventListener("scroll", s), u && n.removeEventListener("scrollend", a);
};
}, Sa = (e, t, n) => {
if (t != null && t.borderBoxSize) {
const r = t.borderBoxSize[0];
if (r)
return Math.round(
r[n.options.horizontal ? "inlineSize" : "blockSize"]
);
}
return e[n.options.horizontal ? "offsetWidth" : "offsetHeight"];
}, Ca = (e, {
adjustments: t = 0,
behavior: n
}, r) => {
var o, i;
const l = e + t;
(i = (o = r.scrollElement) == null ? void 0 : o.scrollTo) == null || i.call(o, {
[r.options.horizontal ? "left" : "top"]: l,
behavior: n
});
};
class Ea {
constructor(t) {
this.unsubs = [], this.scrollElement = null, this.targetWindow = null, this.isScrolling = !1, this.scrollToIndexTimeoutId = null, this.measurementsCache = [], this.itemSizeCache = /* @__PURE__ */ new Map(), this.pendingMeasuredCacheIndexes = [], this.scrollRect = null, this.scrollOffset = null, this.scrollDirection = null, this.scrollAdjustments = 0, this.elementsCache = /* @__PURE__ */ new Map(), this.observer = /* @__PURE__ */ (() => {
let n = null;
const r = () => n || (!this.targetWindow || !this.targetWindow.ResizeObserver ? null : n = new this.targetWindow.ResizeObserver((o) => {
o.forEach((i) => {
const l = () => {
this._measureElement(i.target, i);
};
this.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(l) : l();
});
}));
return {
disconnect: () => {
var o;
(o = r()) == null || o.disconnect(), n = null;
},
observe: (o) => {
var i;
return (i = r()) == null ? void 0 : i.observe(o, { box: "border-box" });
},
unobserve: (o) => {
var i;
return (i = r()) == null ? void 0 : i.unobserve(o);
}
};
})(), this.range = null, this.setOptions = (n) => {
Object.entries(n).forEach(([r, o]) => {
typeof o > "u" && delete n[r];
}), this.options = {
debug: !1,
initialOffset: 0,
overscan: 1,
paddingStart: 0,
paddingEnd: 0,
scrollPaddingStart: 0,
scrollPaddingEnd: 0,
horizontal: !1,
getItemKey: wa,
rangeExtractor: ba,
onChange: () => {
},
measureElement: Sa,
initialRect: { width: 0, height: 0 },
scrollMargin: 0,
gap: 0,
indexAttribute: "data-index",
initialMeasurementsCache: [],
lanes: 1,
isScrollingResetDelay: 150,
enabled: !0,
isRtl: !1,
useScrollendEvent: !1,
useAnimationFrameWithResizeObserver: !1,
...n
};
}, this.notify = (n) => {
var r, o;
(o = (r = this.options).onChange) == null || o.call(r, this, n);
}, this.maybeNotify = Et(
() => (this.calculateRange(), [
this.isScrolling,
this.range ? this.range.startIndex : null,
this.range ? this.range.endIndex : null
]),
(n) => {
this.notify(n);
},
{
key: Lt.NODE_ENV !== "production",
debug: () => this.options.debug,
initialDeps: [
this.isScrolling,
this.range ? this.range.startIndex : null,
this.range ? this.range.endIndex : null
]
}
), this.cleanup = () => {
this.unsubs.filter(Boolean).forEach((n) => n()), this.unsubs = [], this.observer.disconnect(), this.scrollElement = null, this.targetWindow = null;
}, this._didMount = () => () => {
this.cleanup();
}, this._willUpdate = () => {
var n;
const r = this.options.enabled ? this.options.getScrollElement() : null;
if (this.scrollElement !== r) {
if (this.cleanup(), !r) {
this.maybeNotify();
return;
}
this.scrollElement = r, this.scrollElement && "ownerDocument" in this.scrollElement ? this.targetWindow = this.scrollElement.ownerDocument.defaultView : this.targetWindow = ((n = this.scrollElement) == null ? void 0 : n.window) ?? null, this.elementsCache.forEach((o) => {
this.observer.observe(o);
}), this._scrollToOffset(this.getScrollOffset(), {
adjustments: void 0,
behavior: void 0
}), this.unsubs.push(
this.options.observeElementRect(this, (o) => {
this.scrollRect = o, this.maybeNotify();
})
), this.unsubs.push(
this.options.observeElementOffset(this, (o, i) => {
this.scrollAdjustments = 0, this.scrollDirection = i ? this.getScrollOffset() < o ? "forward" : "backward" : null, this.scrollOffset = o, this.isScrolling = i, this.maybeNotify();
})
);
}
}, this.getSize = () => this.options.enabled ? (this.scrollRect = this.scrollRect ?? this.options.initialRect, this.scrollRect[this.options.horizontal ? "width" : "height"]) : (this.scrollRect = null, 0), this.getScrollOffset = () => this.options.enabled ? (this.scrollOffset = this.scrollOffset ?? (typeof this.options.initialOffset == "function" ? this.options.initialOffset() : this.options.initialOffset), this.scrollOffset) : (this.scrollOffset = null, 0), this.getFurthestMeasurement = (n, r) => {
const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
for (let l = r - 1; l >= 0; l--) {
const s = n[l];
if (o.has(s.lane))
continue;
const a = i.get(
s.lane
);
if (a == null || s.end > a.end ? i.set(s.lane, s) : s.end < a.end && o.set(s.lane, !0), o.size === this.options.lanes)
break;
}
return i.size === this.options.lanes ? Array.from(i.values()).sort((l, s) => l.end === s.end ? l.index - s.index : l.end - s.end)[0] : void 0;
}, this.getMeasurementOptions = Et(
() => [
this.options.count,
this.options.paddingStart,
this.options.scrollMargin,
this.options.getItemKey,
this.options.enabled
],
(n, r, o, i, l) => (this.pendingMeasuredCacheIndexes = [], {
count: n,
paddingStart: r,
scrollMargin: o,
getItemKey: i,
enabled: l
}),
{
key: !1
}
), this.getMeasurements = Et(
() => [this.getMeasurementOptions(), this.itemSizeCache],
({ count: n, paddingStart: r, scrollMargin: o, getItemKey: i, enabled: l }, s) => {
if (!l)
return this.measurementsCache = [], this.itemSizeCache.clear(), [];
this.measurementsCache.length === 0 && (this.measurementsCache = this.options.initialMeasurementsCache, this.measurementsCache.forEach((c) => {
this.itemSizeCache.set(c.key, c.size);
}));
const a = this.pendingMeasuredCacheIndexes.length > 0 ? Math.min(...this.pendingMeasuredCacheIndexes) : 0;
this.pendingMeasuredCacheIndexes = [];
const u = this.measurementsCache.slice(0, a);
for (let c = a; c < n; c++) {
const f = i(c), m = this.options.lanes === 1 ? u[c - 1] : this.getFurthestMeasurement(u, c), d = m ? m.end + this.options.gap : r + o, p = s.get(f), g = typeof p == "number" ? p : this.options.estimateSize(c), w = d + g, y = m ? m.lane : c % this.options.lanes;
u[c] = {
index: c,
start: d,
size: g,
end: w,
key: f,
lane: y
};
}
return this.measurementsCache = u, u;
},
{
key: Lt.NODE_ENV !== "production",
debug: () => this.options.debug
}
), this.calculateRange = Et(
() => [
this.getMeasurements(),
this.getSize(),
this.getScrollOffset(),
this.options.lanes
],
(n, r, o, i) => this.range = n.length > 0 && r > 0 ? Ra({
measurements: n,
outerSize: r,
scrollOffset: o,
lanes: i
}) : null,
{
key: Lt.NODE_ENV !== "production",
debug: () => this.options.debug
}
), this.getVirtualIndexes = Et(
() => {
let n = null, r = null;
const o = this.calculateRange();
return o && (n = o.startIndex, r = o.endIndex), this.maybeNotify.updateDeps([this.isScrolling, n, r]), [
this.options.rangeExtractor,
this.options.overscan,
this.options.count,
n,
r
];
},
(n, r, o, i, l) => i === null || l === null ? [] : n({
startIndex: i,
endIndex: l,
overscan: r,
count: o
}),
{
key: Lt.NODE_ENV !== "production",
debug: () => this.options.debug
}
), this.indexFromElement = (n) => {
const r = this.options.indexAttribute, o = n.getAttribute(r);
return o ? parseInt(o, 10) : (console.warn(
`Missing attribute name '${r}={index}' on measured element.`
), -1);
}, this._measureElement = (n, r) => {
const o = this.indexFromElement(n), i = this.measurementsCache[o];
if (!i)
return;
const l = i.key, s = this.elementsCache.get(l);
s !== n && (s && this.observer.unobserve(s), this.observer.observe(n), this.elementsCache.set(l, n)), n.isConnected && this.resizeItem(o, this.options.measureElement(n, r, this));
}, this.resizeItem = (n, r) => {
const o = this.measurementsCache[n];
if (!o)
return;
const i = this.itemSizeCache.get(o.key) ?? o.size, l = r - i;
l !== 0 && ((this.shouldAdjustScrollPositionOnItemSizeChange !== void 0 ? this.shouldAdjustScrollPositionOnItemSizeChange(o, l, this) : o.start < this.getScrollOffset() + this.scrollAdjustments) && this._scrollToOffset(this.getScrollOffset(), {
adjustments: this.scrollAdjustments += l,
behavior: void 0
}), this.pendingMeasuredCacheIndexes.push(o.index), this.itemSizeCache = new Map(this.itemSizeCache.set(o.key, r)), this.notify(!1));
}, this.measureElement = (n) => {
if (!n) {
this.elementsCache.forEach((r