import { useCallback as c, useMemo as f } from "react";
const y = ({
  value: i,
  normalizedItems: n,
  groups: u,
  isGrouped: o
}) => {
  const l = c(
    (e) => o && u ? u.find((r) => r.id === e.id)?.items || [] : [],
    [o, u]
  ), t = c(
    (e) => i.includes(e),
    [i]
  ), d = c(
    (e) => {
      const r = l(e);
      return r.length === 0 ? !1 : r.every((s) => t(s.id));
    },
    [l, t]
  ), g = c(
    (e) => {
      const r = l(e);
      if (r.length === 0)
        return !1;
      const s = r.filter(
        (a) => t(a.id)
      ).length;
      return s > 0 && s < r.length;
    },
    [l, t]
  ), h = f(() => n.length === 0 ? !1 : n.every((e) => t(e.id)), [n, t]), S = f(() => n.length === 0 ? !1 : n.some((e) => t(e.id)), [n, t]);
  return {
    getGroupItems: l,
    isItemSelected: t,
    isGroupFullySelected: d,
    isGroupPartiallySelected: g,
    areAllItemsSelected: h,
    areSomeItemsSelected: S
  };
};
export {
  y as useCheckableListSelection
};
