hello-csv
Version:
A modern CSV importer written in Preact
1,368 lines (1,367 loc) • 388 kB
JavaScript
var as = Object.defineProperty;
var us = (e, t, n) => t in e ? as(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var xe = (e, t, n) => us(e, typeof t != "symbol" ? t + "" : t, n);
import { createRoot as cs } from "react-dom/client";
import * as E from "react";
import D, { forwardRef as Rn, 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 Oe, isValidElement as ds, cloneElement as fs, createElement as Qo, useReducer as $n, useSyncExternalStore as ps, createRef as ei } from "react";
import { jsx as h, jsxs as k, Fragment as Ar } from "react/jsx-runtime";
import * as vn from "react-dom";
import { createPortal as Nr, flushSync as dt } from "react-dom";
function ti(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 = ti(e[t])) && (r && (r += " "), r += n);
} else for (n in e) e[n] && (r && (r += " "), r += n);
return r;
}
function ms() {
for (var e, t, n = 0, r = "", o = arguments.length; n < o; n++) (e = arguments[n]) && (t = ti(e)) && (r && (r += " "), r += t);
return r;
}
const ao = (e) => typeof e == "boolean" ? `${e}` : e === 0 ? "0" : e, uo = ms, wt = (e, t) => (n) => {
var r;
if ((t == null ? void 0 : t.variants) == null) return uo(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 = ao(c) || ao(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 uo(e, l, a, n == null ? void 0 : n.class, n == null ? void 0 : n.className);
}, gs = 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 = gs({ variant: t, disabled: n, withFullWidth: o });
return /* @__PURE__ */ h(
"div",
{
role: "button",
tabIndex: 0,
className: i,
onClick: r,
"aria-disabled": n,
children: e
}
);
}
const hs = 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
}
}), ni = Rn(
({ children: e, className: t, variant: n, withPadding: r = !0 }, o) => {
const i = hs({ variant: n, withPadding: r });
return /* @__PURE__ */ h("div", { ref: o, className: `${i} ${t}`, children: e });
}
);
function ri({ checked: e, setChecked: t, label: n }) {
const r = Ne();
return /* @__PURE__ */ k("div", { className: "flex gap-3", children: [
/* @__PURE__ */ h("div", { className: "flex h-6 shrink-0 items-center", children: /* @__PURE__ */ k("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__ */ k(
"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 vs = !1;
function kr() {
return vs;
}
const oi = typeof document < "u" ? D.useLayoutEffect : () => {
};
function ws(e) {
const t = G(null);
return oi(() => {
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 bs(e) {
return e !== null && typeof e == "object" && "nodeType" in e && typeof e.nodeType == "number";
}
function ys(e) {
return bs(e) && e.nodeType === Node.DOCUMENT_FRAGMENT_NODE && "host" in e;
}
function ii(e, t) {
if (!kr()) 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 : ys(n) ? n = n.host : n = n.parentNode;
}
return !1;
}
const sr = (e = document) => {
var t;
if (!kr()) 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 li(e) {
return kr() && e.target.shadowRoot && e.composedPath ? e.composedPath()[0] : e.target;
}
function xs(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 Ss(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 si(e) {
let t = null;
return () => (t == null && (t = e()), t);
}
const Cs = si(function() {
return Ss(/^Mac/i);
}), Es = si(function() {
return xs(/Android/i);
});
function ai() {
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 Rs(e) {
return e.mozInputSource === 0 && e.isTrusted ? !0 : Es() && e.pointerType ? e.type === "click" && e.buttons === 1 : e.detail === 0 && !e.pointerType;
}
function ui(e) {
let t = e;
return t.nativeEvent = e, t.isDefaultPrevented = () => t.defaultPrevented, t.isPropagationStopped = () => t.cancelBubble, t.persist = () => {
}, t;
}
function $s(e, t) {
Object.defineProperty(e, "target", {
value: t
}), Object.defineProperty(e, "currentTarget", {
value: t
});
}
function ci(e) {
let t = G({
isFocused: !1,
observer: null
});
oi(() => {
const r = t.current;
return () => {
r.observer && (r.observer.disconnect(), r.observer = null);
};
}, []);
let n = ws((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 = ui(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 _s = !1, Jt = null, ar = /* @__PURE__ */ new Set(), jt = /* @__PURE__ */ new Map(), gt = !1, ur = !1;
const Ts = {
Tab: !0,
Escape: !0
};
function Dr(e, t) {
for (let n of ar) n(e, t);
}
function Is(e) {
return !(e.metaKey || !Cs() && e.altKey || e.ctrlKey || e.key === "Control" || e.key === "Shift" || e.key === "Meta");
}
function wn(e) {
gt = !0, Is(e) && (Jt = "keyboard", Dr("keyboard", e));
}
function $t(e) {
Jt = "pointer", (e.type === "mousedown" || e.type === "pointerdown") && (gt = !0, Dr("pointer", e));
}
function di(e) {
Rs(e) && (gt = !0, Jt = "virtual");
}
function fi(e) {
e.target === window || e.target === document || _s || !e.isTrusted || (!gt && !ur && (Jt = "virtual", Dr("virtual", e)), gt = !1, ur = !1);
}
function pi() {
gt = !1, ur = !0;
}
function cr(e) {
if (typeof window > "u" || jt.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", wn, !0), n.addEventListener("keyup", wn, !0), n.addEventListener("click", di, !0), t.addEventListener("focus", fi, !0), t.addEventListener("blur", pi, !1), typeof PointerEvent < "u" && (n.addEventListener("pointerdown", $t, !0), n.addEventListener("pointermove", $t, !0), n.addEventListener("pointerup", $t, !0)), t.addEventListener("beforeunload", () => {
mi(e);
}, {
once: !0
}), jt.set(t, {
focus: r
});
}
const mi = (e, t) => {
const n = ft(e), r = st(e);
t && r.removeEventListener("DOMContentLoaded", t), jt.has(n) && (n.HTMLElement.prototype.focus = jt.get(n).focus, r.removeEventListener("keydown", wn, !0), r.removeEventListener("keyup", wn, !0), r.removeEventListener("click", di, !0), n.removeEventListener("focus", fi, !0), n.removeEventListener("blur", pi, !1), typeof PointerEvent < "u" && (r.removeEventListener("pointerdown", $t, !0), r.removeEventListener("pointermove", $t, !0), r.removeEventListener("pointerup", $t, !0)), jt.delete(n));
};
function Ms(e) {
const t = st(e);
let n;
return t.readyState !== "loading" ? cr(e) : (n = () => {
cr(e);
}, t.addEventListener("DOMContentLoaded", n)), () => mi(e, n);
}
typeof document < "u" && Ms();
function gi() {
return Jt !== "pointer";
}
const Os = /* @__PURE__ */ new Set([
"checkbox",
"radio",
"range",
"color",
"file",
"image",
"button",
"submit",
"reset"
]);
function Fs(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 && !Os.has(r.activeElement.type) || r.activeElement instanceof i || r.activeElement instanceof l && r.activeElement.isContentEditable, !(e && t === "keyboard" && n instanceof s && !Ts[n.key]);
}
function Ps(e, t, n) {
cr(), le(() => {
let r = (o, i) => {
Fs(!!(n != null && n.isTextInput), o, i) && e(gi());
};
return ar.add(r), () => {
ar.delete(r);
};
}, t);
}
function As(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 = ci(i), s = ue((a) => {
const u = st(a.target), c = u ? sr(u) : sr();
a.target === a.currentTarget && c === li(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 Ns(e) {
let { isDisabled: t, onBlurWithin: n, onFocusWithin: r, onFocusWithinChange: o } = e, i = G({
isFocusWithin: !1
}), { addGlobalListener: l, removeAllGlobalListeners: s } = ai(), 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 = ci(a), c = ue((f) => {
if (!f.currentTarget.contains(f.target)) return;
const m = st(f.target), d = sr(m);
if (!i.current.isFocusWithin && d === li(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 && !ii(p, g.target)) {
let w = new m.defaultView.FocusEvent("blur", {
relatedTarget: g.target
});
$s(w, p);
let S = ui(w);
a(S);
}
}, {
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 ks() {
dr = !0, setTimeout(() => {
dr = !1;
}, 50);
}
function co(e) {
e.pointerType === "touch" && ks();
}
function Ds() {
if (!(typeof document > "u"))
return typeof PointerEvent < "u" && document.addEventListener("pointerup", co), Gn++, () => {
Gn--, !(Gn > 0) && typeof PointerEvent < "u" && document.removeEventListener("pointerup", co);
};
}
function hi(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(Ds, []);
let { addGlobalListener: a, removeAllGlobalListeners: u } = ai(), { 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 S = g.currentTarget;
s.target = S, a(st(g.target), "pointerover", (C) => {
s.isHovered && s.target && !ii(s.target, C.target) && d(C, C.pointerType);
}, {
capture: !0
}), t && t({
type: "hoverstart",
target: S,
pointerType: w
}), n && n(!0), l(!0);
}, d = (g, w) => {
let S = s.target;
s.pointerType = "", s.target = null, !(w === "touch" || !s.isHovered || !S) && (s.isHovered = !1, u(), r && r({
type: "hoverend",
target: S,
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 vi(e = {}) {
let { autoFocus: t = !1, isTextInput: n, within: r } = e, o = G({
isFocused: !1,
isFocusVisible: t || gi()
}), [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
]);
Ps((d) => {
o.current.isFocusVisible = d, u();
}, [], {
isTextInput: n
});
let { focusProps: f } = As({
isDisabled: r,
onFocusChange: c
}), { focusWithinProps: m } = Ns({
isDisabled: !r,
onFocusWithinChange: c
});
return {
isFocused: i,
isFocusVisible: s,
focusProps: r ? m : f
};
}
var Ls = Object.defineProperty, Vs = (e, t, n) => t in e ? Ls(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n, Wn = (e, t, n) => (Vs(e, typeof t != "symbol" ? t + "" : t, n), n);
let Hs = 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 Hs();
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 We() {
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 = We();
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(We);
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 zs(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 Bs(e, t) {
return !(!e || !t || e.right < t.left || e.left > t.right || e.bottom < t.top || e.top > t.bottom);
}
function js({ 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 = zs(u);
r(Bs(c, t.current.getBoundingClientRect()));
}
}, !1), o.addEventListener(a, "pointercancel", i, !1);
}
}
});
return { pressed: n, pressProps: e ? {} : { onPointerDown: l, onPointerUp: i, onClick: i } };
}
let Gs = me(void 0);
function Lr() {
return ce(Gs);
}
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 It = ((e) => (e[e.None = 0] = "None", e[e.RenderStrategy = 1] = "RenderStrategy", e[e.Static = 2] = "Static", e))(It || {}), tt = ((e) => (e[e.Unmount = 0] = "Unmount", e[e.Hidden = 1] = "Hidden", e))(tt || {});
function ye() {
let e = Us();
return ue((t) => Ws({ mergeRefs: e, ...t }), [e]);
}
function Ws({ ourProps: e, theirProps: t, slot: n, defaultTag: r, features: o, visible: i = !0, name: l, mergeRefs: s }) {
s = s ?? qs;
let a = wi(t, e);
if (i) return un(a, n, r, l, s);
let u = o ?? 0;
if (u & 2) {
let { static: c = !1, ...f } = a;
if (c) return un(f, n, r, l, s);
}
if (u & 1) {
let { unmount: c = !0, ...f } = a;
return Fe(c ? 0 : 1, { 0() {
return null;
}, 1() {
return un({ ...f, hidden: !0, style: { display: "none" } }, n, r, l, s);
} });
}
return un(a, n, r, l, s);
}
function un(e, t = {}, n, r, o) {
let { as: i = n, children: l, refName: s = "ref", ...a } = Un(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 === Oe && (Object.keys(et(a)).length > 0 || Object.keys(et(f)).length > 0)) if (!ds(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" ? (...S) => fr(d(...S), a.className) : fr(d, a.className), g = p ? { className: p } : {}, w = wi(c.props, et(Un(a, ["ref"])));
for (let S in f) S in w && delete f[S];
return fs(c, Object.assign({}, w, f, u, { ref: o(Ks(c), u.ref) }, g));
}
return Qo(i, Object.assign({}, Un(a, ["ref"]), i !== Oe && u, i !== Oe && f), c);
}
function Us() {
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 qs(...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 wi(...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 Vr(...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(Rn(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 Un(e, t = []) {
let n = Object.assign({}, e);
for (let r of t) r in n && delete n[r];
return n;
}
function Ks(e) {
return D.version.split(".")[0] >= "19" ? e.props.ref : e.ref;
}
function Ys(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 Xs(e) {
let [t] = te(e);
return t;
}
function bi(e = {}, t = null, n = []) {
for (let [r, o] of Object.entries(e)) xi(n, yi(t, r), o);
return n;
}
function yi(e, t) {
return e ? e + "[" + t + "]" : t;
}
function xi(e, t, n) {
if (Array.isArray(n)) for (let [r, o] of n.entries()) xi(e, yi(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, ""]) : bi(n, t, e);
}
let Zs = "span";
var Mt = ((e) => (e[e.None = 1] = "None", e[e.Focusable = 2] = "Focusable", e[e.Hidden = 4] = "Hidden", e))(Mt || {});
function Js(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: Zs, name: "Hidden" });
}
let qt = we(Js), Qs = me(null);
function ea({ children: e }) {
let t = ce(Qs);
if (!t) return D.createElement(D.Fragment, null, e);
let { target: n } = t;
return n ? Nr(D.createElement(D.Fragment, null, e), n) : null;
}
function ta({ 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(ea, null, D.createElement(na, { setForm: l, formId: t }), bi(e).map(([a, u]) => D.createElement(qt, { features: Mt.Hidden, ...et({ key: a, as: "input", type: "hidden", hidden: !0, readOnly: !0, form: t, disabled: n, name: a, value: u, ...o }) })));
}
function na({ setForm: e, formId: t }) {
return le(() => {
if (t) {
let n = document.getElementById(t);
n && e(n);
}
}, [e, t]), t ? null : D.createElement(qt, { features: Mt.Hidden, as: "input", type: "hidden", hidden: !0, readOnly: !0, ref: (n) => {
if (!n) return;
let r = n.closest("form");
r && e(r);
} });
}
let ra = me(void 0);
function Si() {
return ce(ra);
}
function oa(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 && ia(n) ? !1 : r;
}
function ia(e) {
if (!e) return !1;
let t = e.previousElementSibling;
for (; t !== null; ) {
if (t instanceof HTMLLegendElement) return !1;
t = t.previousElementSibling;
}
return !0;
}
let Ci = Symbol();
function la(e, t = !0) {
return Object.assign(e, { [Ci]: t });
}
function Ie(...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[Ci])) ? void 0 : n;
}
let Tn = me(null);
Tn.displayName = "DescriptionContext";
function Ei() {
let e = ce(Tn);
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, Ei), t;
}
return e;
}
function sa() {
var e, t;
return (t = (e = ce(Tn)) == null ? void 0 : e.value) != null ? t : void 0;
}
function aa() {
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(Tn.Provider, { value: o }, n.children);
}, [t])];
}
let ua = "p";
function ca(e, t) {
let n = Ne(), r = Lr(), { id: o = `headlessui-description-${n}`, ...i } = e, l = Ei(), s = Ie(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: ua, name: l.name || "Description" });
}
let da = we(ca), fa = Object.assign(da, {});
var Re = ((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))(Re || {});
let In = me(null);
In.displayName = "LabelContext";
function Ri() {
let e = ce(In);
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, Ri), t;
}
return e;
}
function Mn(e) {
var t, n, r;
let o = (n = (t = ce(In)) == 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 pa({ inherit: e = !1 } = {}) {
let t = Mn(), [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(In.Provider, { value: s }, i.children);
}, [r])];
}
let ma = "label";
function ga(e, t) {
var n;
let r = Ne(), o = Ri(), i = Si(), l = Lr(), { id: s = `headlessui-label-${r}`, htmlFor: a = i ?? ((n = o.props) == null ? void 0 : n.htmlFor), passive: u = !1, ...c } = e, f = Ie(t);
ae(() => o.register(s), [s, o.register]);
let m = j((w) => {
let S = w.currentTarget;
if (S instanceof HTMLLabelElement && w.preventDefault(), o.props && "onClick" in o.props && typeof o.props.onClick == "function" && o.props.onClick(w), S instanceof HTMLLabelElement) {
let C = document.getElementById(S.htmlFor);
if (C) {
let x = C.getAttribute("disabled");
if (x === "true" || x === "") return;
let R = C.getAttribute("aria-disabled");
if (R === "true" || R === "") return;
(C instanceof HTMLInputElement && (C.type === "radio" || C.type === "checkbox") || C.role === "radio" || C.role === "checkbox" || C.role === "switch") && C.click(), C.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 ? ma : "div", name: o.name || "Label" });
}
let ha = we(ga), va = Object.assign(ha, {}), wa = me(() => {
});
function ba({ value: e, children: t }) {
return D.createElement(wa.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, S = (C, x) => {
for (C = String(C); C.length < x; )
C = " " + C;
return C;
};
console.info(
`%c⏱ ${S(g, 5)} /${S(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 fo(e, t) {
if (e === void 0)
throw new Error("Unexpected undefined");
return e;
}
const ya = (e, t) => Math.abs(e - t) <= 1, xa = (e, t, n) => {
let r;
return function(...o) {
e.clearTimeout(r), r = e.setTimeout(() => t.apply(this, o), n);
};
};
var Vt = { NODE_ENV: "production" };
const po = (e) => {
const { offsetWidth: t, offsetHeight: n } = e;
return { width: t, height: n };
}, Sa = (e) => e, Ca = (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;
}, Ea = (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(po(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(po(n));
};
e.options.useAnimationFrameWithResizeObserver ? requestAnimationFrame(s) : s();
});
return i.observe(n, { box: "border-box" }), () => {
i.unobserve(n);
};
}, mo = {
passive: !0
}, go = typeof window > "u" ? !0 : "onscrollend" in window, Ra = (e, t) => {
const n = e.scrollElement;
if (!n)
return;
const r = e.targetWindow;
if (!r)
return;
let o = 0;
const i = e.options.useScrollendEvent && go ? () => {
} : xa(
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, mo);
const u = e.options.useScrollendEvent && go;
return u && n.addEventListener("scrollend", a, mo), () => {
n.removeEventListener("scroll", s), u && n.removeEventListener("scrollend", a);
};
}, $a = (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"];
}, _a = (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 Ta {
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: Sa,
rangeExtractor: Ca,
onChange: () => {
},
measureElement: $a,
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: Vt.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, S = m ? m.lane : c % this.options.lanes;
u[c] = {
index: c,
start: d,
size: g,
end: w,
key: f,
lane: S
};
}
return this.measurementsCache = u, u;
},
{
key: Vt.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 ? Ia({
measurements: n,
outerSize: r,
scrollOffset: o,
lanes: i
}) : null,
{
key: Vt.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: Vt.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) {