"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.useFullScreenDrawer = useFullScreenDrawer;
var _react = require("react");
function useFullScreenDrawer({
  isShow = false,
  onDismissCallback = () => {},
  shouldShowCloseWarning
} = {
  isShow: false,
  onDismissCallback: () => {},
  shouldShowCloseWarning: false
}) {
  const [show, setShow] = (0, _react.useState)(isShow);
  const [showCloseWarning, setShowCloseWarning] = (0, _react.useState)(false);
  const onDismiss = (0, _react.useCallback)(() => {
    // if consumer's requirements to show warning is true and warning is not shown yet - then show warning instead of closing
    // if warning was already shown - then proceed closing
    if (shouldShowCloseWarning && !showCloseWarning) {
      setShowCloseWarning(true);
    } else {
      onDismissCallback();
      setShowCloseWarning(false);
      setShow(false);
    }
  }, [onDismissCallback, shouldShowCloseWarning, showCloseWarning]);
  return {
    show,
    setShow,
    onDismiss,
    showCloseWarning,
    setShowCloseWarning
  };
}