'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var BodyProvider = require('@prom-ui/core/BodyProvider');

function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }

var _defineProperty__default = /*#__PURE__*/_interopDefaultCompat(_defineProperty);

function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty__default.default(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }

/**
 * Хук используется для кратких уведомлений о процессах
 */
var useSnackBar = function useSnackBar() {
  var snackBarAddToQueue = BodyProvider.useBodyStore(function (store) {
    return store.snackBarAddToQueue;
  });
  var snackBarClose = BodyProvider.useBodyStore(function (store) {
    return store.snackBarClose;
  });
  return {
    open: function open(children, props) {
      snackBarAddToQueue(_objectSpread(_objectSpread({}, props), {}, {
        isOpen: false,
        children: children,
        onClose: function onClose() {
          snackBarClose();
        }
      }));
    },
    close: function close() {
      snackBarClose();
    }
  };
};

exports.useSnackBar = useSnackBar;
