'use strict';

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

var _extends = require('@babel/runtime/helpers/extends');
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
var React = require('react');
var reactTransitionGroup = require('react-transition-group');
var classNames = require('clsx');
var Portal = require('@prom-ui/core/Portal');
var BodyScrollLock = require('@prom-ui/core/BodyScrollLock');
var useForwardRef = require('@prom-ui/core/useForwardRef');

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

function _interopNamespaceCompat(e) {
  if (e && typeof e === 'object' && 'default' in e) return e;
  var n = Object.create(null);
  if (e) {
    Object.keys(e).forEach(function (k) {
      if (k !== 'default') {
        var d = Object.getOwnPropertyDescriptor(e, k);
        Object.defineProperty(n, k, d.get ? d : {
          enumerable: true,
          get: function () { return e[k]; }
        });
      }
    });
  }
  n.default = e;
  return Object.freeze(n);
}

var _extends__default = /*#__PURE__*/_interopDefaultCompat(_extends);
var _defineProperty__default = /*#__PURE__*/_interopDefaultCompat(_defineProperty);
var _objectWithoutProperties__default = /*#__PURE__*/_interopDefaultCompat(_objectWithoutProperties);
var React__namespace = /*#__PURE__*/_interopNamespaceCompat(React);
var classNames__default = /*#__PURE__*/_interopDefaultCompat(classNames);

var css = {"root":"Backdrop__root___ew14A","backdrop":"Backdrop__backdrop___RtyKW","enterActive":"Backdrop__enterActive___FuHNM","exitActive":"Backdrop__exitActive___qwiIx","enter":"Backdrop__enter___Ww68r","exit":"Backdrop__exit___MBjXR"};

var _excluded = ["isOpen", "isRenderPortal", "isAnimated", "isBodyScrollLock", "style", "zIndex", "children", "className", "onClick"];
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 Backdrop = /*#__PURE__*/React__namespace.forwardRef(function (_ref, ref) {
  var _ref$isOpen = _ref.isOpen,
    isOpen = _ref$isOpen === void 0 ? false : _ref$isOpen,
    _ref$isRenderPortal = _ref.isRenderPortal,
    isRenderPortal = _ref$isRenderPortal === void 0 ? true : _ref$isRenderPortal,
    _ref$isAnimated = _ref.isAnimated,
    isAnimated = _ref$isAnimated === void 0 ? true : _ref$isAnimated,
    _ref$isBodyScrollLock = _ref.isBodyScrollLock,
    isBodyScrollLock = _ref$isBodyScrollLock === void 0 ? false : _ref$isBodyScrollLock,
    _ref$style = _ref.style,
    style = _ref$style === void 0 ? {} : _ref$style,
    _ref$zIndex = _ref.zIndex,
    zIndex = _ref$zIndex === void 0 ? 1000 : _ref$zIndex,
    children = _ref.children,
    className = _ref.className,
    onClick = _ref.onClick,
    props = _objectWithoutProperties__default.default(_ref, _excluded);
  var nodeRef = useForwardRef.useForwardRef(ref, null);
  return /*#__PURE__*/React__namespace.createElement(reactTransitionGroup.CSSTransition, {
    nodeRef: nodeRef,
    "in": isOpen,
    timeout: isAnimated ? 225 : 0,
    classNames: css,
    unmountOnExit: true
  }, /*#__PURE__*/React__namespace.createElement(Portal.Portal, {
    isActive: isRenderPortal
  }, /*#__PURE__*/React__namespace.createElement(BodyScrollLock.BodyScrollLock, {
    isActive: isBodyScrollLock
  }), /*#__PURE__*/React__namespace.createElement("div", _extends__default.default({
    ref: nodeRef,
    className: classNames__default.default(css.root, className),
    style: _objectSpread({
      zIndex: zIndex
    }, style),
    "aria-hidden": true,
    "data-testid": "backdrop",
    "data-qaid": "backdrop"
  }, props), /*#__PURE__*/React__namespace.createElement("div", {
    className: css.backdrop,
    onClick: onClick
  }), children)));
});
Backdrop.displayName = 'Backdrop';

exports.Backdrop = Backdrop;

require('./style.development.css');
