"use strict";

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _constants = require("../../constants");

var _Icon = _interopRequireWildcard(require("../Icon"));

// Copyright 1999-2020. Plesk International GmbH. All rights reserved.

/**
 * `Heading` is used as a text title (or a subtitle) to define the hierarchy and the structure of the content.
 * @since 2.3.0
 */
const Heading = ({
  baseClassName = "".concat(_constants.CLS_PREFIX, "heading"),
  className,
  icon,
  children,
  component: Tag,
  level = 1,
  ...props
}) => {
  if (!Tag) {
    Tag = "h".concat(level);
  }

  let iconSize = _Icon.ICON_SIZE_16;

  if (level === 1) {
    iconSize = _Icon.ICON_SIZE_32;
  }

  if (level === 2 || level === 3) {
    iconSize = _Icon.ICON_SIZE_24;
  }

  if (level === 6) {
    iconSize = _Icon.ICON_SIZE_12;
  }

  return /*#__PURE__*/_react.default.createElement(Tag, (0, _extends2.default)({
    className: (0, _classnames.default)(baseClassName, {
      ["".concat(baseClassName, "--h").concat(level)]: level,
      ["".concat(baseClassName, "--icon")]: icon
    }, className)
  }, props), _Icon.default.create(icon, {
    className: "".concat(baseClassName, "__icon"),
    size: iconSize
  }), icon ? /*#__PURE__*/_react.default.createElement("span", {
    className: "".concat(baseClassName, "__text")
  }, children) : children);
};

var _default = Heading;
exports.default = _default;