import { useState as l, useRef as i, useCallback as a } from "react";
import { saveColumnsWidth as h } from "../../helpers/persistence/saveColumnsWidth/saveColumnsWidth.js";
const f = ({
  id: s,
  onChangeConfig: u,
  initialWidths: o
}) => {
  const [t, r] = l(() => o ?? /* @__PURE__ */ new Map()), e = i(null), n = a(
    (m, c) => {
      t.set(m, Math.round(c)), e.current && clearTimeout(e.current), e.current = setTimeout(() => {
        h(s, t, u);
      }, 500);
    },
    [s, t, u]
  );
  return {
    columnsWidths: t,
    setColumnsWidths: r,
    onChangeColumnWidth: n
  };
};
export {
  f as useColumnsWidth
};
