import _extends from "@babel/runtime/helpers/extends";
import "core-js/modules/es.symbol.js";
import "core-js/modules/es.symbol.description.js";
import "core-js/modules/es.array.includes.js";
import "core-js/modules/es.string.includes.js";
import "core-js/modules/es.string.link.js";
import * as React from 'react';
import { Header, Paragraph } from '@megafon/ui-core';
import { cnCreate, convert, filterDataAttrs } from '@megafon/ui-helpers';
import { setRelAttribute } from "../../../helpers/setRelAttribute";
import "./BenefitCard.css";
var typographyConfig = {
  b: {
    component: function component(_ref) {
      var children = _ref.children;
      return /*#__PURE__*/React.createElement("b", null, children);
    }
  }
};
var cn = cnCreate('mfui-9-benefit-card');
var BenefitCard = function BenefitCard(_ref2) {
  var title = _ref2.title,
    description = _ref2.description,
    imageSrc = _ref2.imageSrc,
    link = _ref2.link,
    _ref2$background = _ref2.background,
    background = _ref2$background === void 0 ? 'gray' : _ref2$background,
    dataAttrs = _ref2.dataAttrs,
    className = _ref2.className;
  var isLink = !!link;
  var Element = isLink ? 'a' : 'div';
  var isGradientBackground = !!background && background.includes('gradient');
  return /*#__PURE__*/React.createElement(Element, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
    href: link === null || link === void 0 ? void 0 : link.href,
    target: link === null || link === void 0 ? void 0 : link.target,
    rel: isLink ? setRelAttribute(link.rel, link.target) : undefined,
    className: cn({
      background: background,
      interactive: isLink,
      gradient: isGradientBackground
    }, [className]),
    tabIndex: isLink ? 0 : -1
  }), /*#__PURE__*/React.createElement("div", {
    className: cn('content')
  }, /*#__PURE__*/React.createElement(Header, {
    as: "h3",
    color: "inherit"
  }, convert(title, {})), /*#__PURE__*/React.createElement(Paragraph, {
    hasMargin: false,
    color: "inherit"
  }, convert(description, typographyConfig), !!(link === null || link === void 0 ? void 0 : link.pseudoLinkText) && /*#__PURE__*/React.createElement(React.Fragment, null, ' ', /*#__PURE__*/React.createElement("span", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.pseudoLink), {
    className: cn('pseudo-link')
  }), link.pseudoLinkText)))), /*#__PURE__*/React.createElement("img", {
    src: imageSrc,
    alt: title,
    className: cn('image')
  }));
};
export default BenefitCard;