import { getFormatBoolean as m } from "../../../formatters/BooleanFormatter/BooleanFormatter.js";
import { ColumnBooleanFormatter as d } from "./formatter.js";
import { ColumnBooleanGroupFormatter as B } from "./ColumnBooleanGroupFormatter.js";
import { useModuleDictionary as g, getPropertyByString as s } from "@m4l/core";
import { useState as p, useRef as v, useEffect as S, useMemo as C } from "react";
import { deepEqual as b } from "fast-equals";
import { getColumnKey as y } from "../../helpers/shared/getColumnKey/getColumnKey.js";
const F = (e, o) => (t, u) => {
  const r = y(e.fieldValue), l = s(t, r);
  let n;
  return typeof l == "boolean" ? n = l : n = void 0, m(
    e.presentationType,
    n,
    o
  ).includes(u);
}, M = (e, o) => (t, u) => {
  const r = y(e.fieldValue), l = s(t, r), n = s(u, r);
  let i, a;
  typeof l == "boolean" ? i = l : i = void 0, typeof n == "boolean" ? a = n : a = void 0;
  const f = m(
    e.presentationType,
    i,
    o
  ), c = m(
    e.presentationType,
    a,
    o
  );
  return f > c ? 1 : f < c ? -1 : 0;
}, k = (e) => {
  const { getLabel: o } = g(), [t, u] = p(e), r = v({ ...e });
  return S(() => {
    b(r.current, e) || (r.current = e, u(e));
  }, [e]), C(
    () => ({
      formatter: d(t),
      renderGroupCell: B(t),
      customFilter: F(t, o),
      customSort: M(t, o)
    }),
    [t, o]
  );
};
export {
  k as useColumnBoolean
};
