import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
var _excluded = ["direction", "children"];
import React, { useContext } from 'react';
import { Modal } from "../../Modal";
import { forwardRefAndName } from "../../../lib/forwardRefAndName";
import { ThemeContext } from "../../../lib/theming/ThemeContext";
import { cx } from "../../../lib/theming/Emotion";
import { styles } from "../MiniModal.styles";
import { MiniModalDataTids } from "../MiniModal";

/**
 * Обёртка над Modal.Footer
 *
 * @visibleName MiniModal.Footer
 */
export var MiniModalFooter = forwardRefAndName('MiniModalFooter', function (_ref, ref) {
  var _ref$direction = _ref.direction,
    direction = _ref$direction === void 0 ? 'row' : _ref$direction,
    children = _ref.children,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var theme = useContext(ThemeContext);
  var childrenCount = React.Children.count(children);
  var _direction = childrenCount > 2 || childrenCount === 1 ? 'column' : direction;
  return /*#__PURE__*/(
    React.createElement(Modal.Footer, rest, /*#__PURE__*/
    React.createElement("div", {
      ref: ref,
      "data-tid": MiniModalDataTids.actions,
      className: cx(styles.actions(), _direction === 'row' && styles.actionsRow(theme), _direction === 'column' && styles.actionsColumn(theme))
    }, children))
  );
});