import { useState as i, useRef as f, useEffect as l, useMemo as a } from "react";
import { getPropertyByString as C } from "@m4l/core";
import { deepEqual as h } from "fast-equals";
import { ColumnSetCheckFormatter as k } from "./formatter.js";
import { getColumnKey as S } from "../../helpers/shared/getColumnKey/getColumnKey.js";
const d = (t) => (e, o) => {
  const r = S(t.field);
  return C(e, r) === o;
}, g = (t) => (e, o) => {
  const { useHook: r, field: n, rowKeyGetter: u } = t, [s] = r(n), c = s.has(u(e)), m = s.has(u(o));
  return c && !m ? 1 : !c && m ? -1 : 0;
}, R = (t) => {
  const [e, o] = i(t), r = f({ ...t });
  return l(() => {
    h(r.current, t) || (r.current = t, o(t));
  }, [t]), a(() => ({
    formatter: k(e),
    customFilter: d(e),
    customSort: g(e)
  }), [e]);
};
export {
  R as useColumnSetCheck
};
