"use strict";

exports.__esModule = true;
exports["default"] = void 0;
var _react = require("react");
var noop = function noop() {};
var emptyObj = {};
var _default = exports["default"] = function _default(defaultColumnSizing, onChange) {
  if (defaultColumnSizing === void 0) {
    defaultColumnSizing = emptyObj;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var _useState = (0, _react.useState)(function () {
      return defaultColumnSizing;
    }),
    columnSizing = _useState[0],
    setColumnSizing = _useState[1];
  var initialSetRef = (0, _react.useRef)(false);
  (0, _react.useEffect)(function () {
    if (columnSizing === defaultColumnSizing) return;
    initialSetRef.current = true;
    setColumnSizing(defaultColumnSizing);
  }, [defaultColumnSizing]);
  var onSizingChange = (0, _react.useCallback)(function (getValue) {
    onChange(getValue(columnSizing));
    setColumnSizing(getValue(columnSizing));
  }, [columnSizing]);
  return [columnSizing, onSizingChange];
};