import { jsx as r } from "react/jsx-runtime";
import { useMemo as u } from "react";
import p from "../../../Icons.js";
import { C as _ } from "../../../../index-20bzTFSx.js";
import { useTableContext as d } from "../../context/index.js";
const D = ({ targetId: k, ...i }) => {
  var n;
  const [h = {}, o] = d((e) => e.checkedData), [c] = d((e) => e.data), m = u(() => c.reduce((e, s) => (e[s.id] = s, e), {}), [c]), t = (((n = Object.keys(h)) == null ? void 0 : n.length) ?? 0) > 0, a = () => {
    o(t ? (e) => {
      e.checkedData = {};
    } : (e) => {
      e.checkedData = m;
    });
  };
  return t ? /* @__PURE__ */ r(
    "div",
    {
      onClick: a,
      className: "_cursor-pointer _bg-primary/80 _border-2 _border-primary  _w-5 _h-5 _rounded _flex _justify-center _items-center",
      children: /* @__PURE__ */ r(p.MinusIcon, { className: "_text-white _rounded " })
    }
  ) : /* @__PURE__ */ r(
    _,
    {
      inputProps: {
        checked: t,
        onChange: a,
        ...i
      }
    }
  );
};
export {
  D as default
};
