import _extends from "@babel/runtime/helpers/extends";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import * as React from 'react';
import { Header, Paragraph, Grid, GridColumn } from '@megafon/ui-core';
import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
import "./TitleDescriptionBox.css";
var testIdPrefix = 'TitleDescriptionBox';
var cn = cnCreate('mfui-title-description-box');
var TitleDescriptionBox = function TitleDescriptionBox(_ref) {
  var dataAttrs = _ref.dataAttrs,
    title = _ref.title,
    description = _ref.description,
    textColor = _ref.textColor,
    align = _ref.align,
    rootRef = _ref.rootRef,
    className = _ref.className;
  var renderDescription = React.useCallback(function () {
    if (typeof description === 'string') {
      return /*#__PURE__*/React.createElement(Paragraph, {
        className: cn('item'),
        hasMargin: false,
        color: "inherit",
        dataAttrs: {
          root: {
            'data-testid': "".concat(testIdPrefix, "-description-text")
          }
        }
      }, description);
    }
    return /*#__PURE__*/React.createElement("div", {
      className: cn('description'),
      "data-testid": "".concat(testIdPrefix, "-description-node")
    }, description);
  }, [description]);
  return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
    className: cn({
      'h-align': align,
      'text-color': textColor
    }, className),
    ref: rootRef
  }), /*#__PURE__*/React.createElement(Grid, {
    hAlign: align,
    dataAttrs: {
      container: {
        'data-testid': "".concat(testIdPrefix, "-grid")
      }
    }
  }, /*#__PURE__*/React.createElement(GridColumn, {
    wide: "8",
    desktop: "10"
  }, title && /*#__PURE__*/React.createElement(Header, {
    className: cn('item', {
      header: true
    }),
    as: "h2",
    color: "inherit"
  }, title), description && renderDescription())));
};
export default TitleDescriptionBox;