import _extends from "@babel/runtime/helpers/esm/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/esm/objectWithoutPropertiesLoose";
import _inheritsLoose from "@babel/runtime/helpers/esm/inheritsLoose";
var _excluded = ["align"];
var _class, _Center;
import React from 'react';
import { CommonWrapper } from "../../../internal/CommonWrapper";
import { cx } from "../../../lib/theming/Emotion";
import { rootNode } from "../../../lib/rootNode";
import { createPropsGetter } from "../../../lib/createPropsGetter";
import { styles } from "../Center.styles";
export var CenterDataTids = {
  root: 'Center__root'
};

/**
 * `Center` — контейнер, который центрирует элементы внутри себя.
 *
 * Выравнивание задается пропом `align`.
 */
export var Center = rootNode(_class = (_Center = /*#__PURE__*/function (_React$Component) {
  function Center() {
    var _this;
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    _this = _React$Component.call.apply(_React$Component, [this].concat(args)) || this;
    _this.getProps = createPropsGetter(Center.defaultProps);
    _this.renderMain = function (props) {
      var _cx;
      var align = props.align,
        rest = _objectWithoutPropertiesLoose(props, _excluded);
      return /*#__PURE__*/(
        React.createElement("div", _extends({
          "data-tid": CenterDataTids.root
        }, rest, {
          className: cx((_cx = {}, _cx[styles.root()] = true, _cx[styles.rootAlignLeft()] = align === 'left', _cx[styles.rootAlignRight()] = align === 'right', _cx))
        }), /*#__PURE__*/

        React.createElement("span", {
          className: styles.spring()
        }), /*#__PURE__*/
        React.createElement("span", {
          className: styles.container()
        }, _this.props.children))
      );
    };
    return _this;
  }
  _inheritsLoose(Center, _React$Component);
  var _proto = Center.prototype;
  _proto.render = function render() {
    return /*#__PURE__*/React.createElement(CommonWrapper, _extends({
      rootNodeRef: this.setRootNode
    }, this.getProps()), this.renderMain);
  };
  return Center;
}(React.Component), _Center.__KONTUR_REACT_UI__ = 'Center', _Center.displayName = 'Center', _Center.defaultProps = {
  align: 'center'
}, _Center)) || _class;