"use strict";

exports.__esModule = true;
exports.default = void 0;
var _isEmpty2 = _interopRequireDefault(require("lodash/fp/isEmpty"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _icon = _interopRequireDefault(require("../icon"));
var _tag = _interopRequireDefault(require("../tag"));
var _buttonLink = _interopRequireDefault(require("../button-link"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const getTitleStyle = (type, size) => {
  switch (type) {
    case 'page':
      return _style.default.titlePage;
    case 'form-group':
      switch (size) {
        case 'standard':
          return _style.default.titleFormGroup;
        case 'standard-light-weight':
          return _style.default.titleFormGroupLightWeight;
        case 'xl-strong':
          return _style.default.xlStrongTitle;
        case 'medium':
          return _style.default.mediumTitleFormGroup;
        case 'medium-light-color':
          return _style.default.mediumAndLightColorTitleFormGroup;
        case 'small':
          return _style.default.smallTitleFormGroup;
        case 'small-and-light':
          return _style.default.smallAndLightTitleFormGroup;
      }
  }
};
const getSubtitleStyle = (type, size) => {
  switch (type) {
    case 'page':
      return _style.default.subtitlePage;
    case 'form-group':
      switch (size) {
        case 'standard':
          return _style.default.subtitleFormGroup;
        case 'standard-without-margin':
          return _style.default.subtitleFormGroupWithoutMargin;
        case 'medium':
          return _style.default.mediumSubtitleFormGroup;
        case 'small':
          return _style.default.smallSubtitleFormGroup;
        case 'small-without-margin':
          return _style.default.smallSubtitleFormGroupWithoutMargin;
        case 'extra-small':
          return _style.default.extraSmallSubtitleFormGroup;
      }
  }
};
const Title = props => {
  const {
    title,
    subtitle,
    type,
    'data-name': dataName,
    titleSize = 'standard',
    subtitleSize = 'standard',
    icon,
    tag,
    button,
    required
  } = props;
  const titleStyle = getTitleStyle(type, titleSize);
  const subtitleStyle = getSubtitleStyle(type, subtitleSize);
  const subtitleSection = subtitle ? /*#__PURE__*/_react.default.createElement("div", {
    className: subtitleStyle
  }, subtitle) : null;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.container
  }, icon ? /*#__PURE__*/_react.default.createElement(_icon.default, _extends({}, icon, {
    className: _style.default.icon
  })) : null, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.titleContainer
  }, /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
    className: titleStyle,
    "data-name": dataName
  }, title, required ? /*#__PURE__*/_react.default.createElement("span", {
    className: _style.default.required
  }, "*") : null, tag ? /*#__PURE__*/_react.default.createElement(_tag.default, tag) : null), subtitleSection), !(0, _isEmpty2.default)(button) ? /*#__PURE__*/_react.default.createElement(_buttonLink.default, button) : null));
};
Title.propTypes = process.env.NODE_ENV !== "production" ? {
  title: _propTypes.default.string,
  subtitle: _propTypes.default.string,
  type: _propTypes.default.oneOf(['page', 'form-group']),
  'data-name': _propTypes.default.string,
  titleSize: _propTypes.default.oneOf(['xl-strong', 'standard', 'standard-light-weight', 'medium', 'medium-light-color', 'small', 'small-and-light']),
  subtitleSize: _propTypes.default.oneOf(['standard', 'standard-without-margin', 'medium', 'small', 'small-without-margin', 'extra-small']),
  icon: _propTypes.default.shape(_icon.default.propTypes),
  tag: _propTypes.default.shape(_tag.default.propTypes),
  button: _propTypes.default.shape(_buttonLink.default.propTypes),
  required: _propTypes.default.bool
} : {};
var _default = exports.default = Title;
//# sourceMappingURL=index.js.map