"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(defaultExpanded, onChange) {
  if (defaultExpanded === void 0) {
    defaultExpanded = emptyObj;
  }
  if (onChange === void 0) {
    onChange = noop;
  }
  var initialSetRef = (0, _react.useRef)(false);
  var _useState = (0, _react.useState)(function () {
      return defaultExpanded;
    }),
    expanded = _useState[0],
    setExpanded = _useState[1];
  (0, _react.useEffect)(function () {
    if (!defaultExpanded || expanded === defaultExpanded) return;
    initialSetRef.current = true;
    setExpanded(defaultExpanded);
  }, [defaultExpanded]);
  var onExpand = (0, _react.useCallback)(function (value) {
    onChange(value);
    setExpanded(value);
  }, []);
  return [expanded, onExpand];
};