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