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

/**
 * Обёртка над Modal.Header
 *
 * @visibleName MiniModal.Header
 */
export var MiniModalHeader = forwardRefAndName('MiniModalHeader', function (_ref, ref) {
  var _cx;
  var _ref$icon = _ref.icon,
    icon = _ref$icon === void 0 ? /*#__PURE__*/React.createElement(InfoCircleIcon64Regular, null) : _ref$icon,
    children = _ref.children,
    rest = _objectWithoutPropertiesLoose(_ref, _excluded);
  var theme = useContext(ThemeContext);
  return /*#__PURE__*/(
    React.createElement(Modal.Header, rest, /*#__PURE__*/
    React.createElement("div", {
      ref: ref
    }, icon && /*#__PURE__*/
    React.createElement("div", {
      "data-tid": MiniModalDataTids.icon,
      className: styles.icon()
    }, icon), children && /*#__PURE__*/
    React.createElement("div", {
      "data-tid": MiniModalDataTids.title,
      className: cx(styles.title(), (_cx = {}, _cx[styles.titleWithIcon(theme)] = !!icon, _cx))
    }, children)))
  );
});