import _extends from "@babel/runtime/helpers/extends";
import "core-js/modules/es.array.concat.js";
import * as React from 'react';
import { cnCreate, convert, filterDataAttrs, textConvertConfig, titleConvertConfig } from '@megafon/ui-helpers';
import { setRelAttribute } from "../../../../helpers/setRelAttribute";
import "./ServiceCard.css";
var ArrowRight = function ArrowRight(props) {
  return /*#__PURE__*/React.createElement("svg", _extends({
    viewBox: "0 0 32 32"
  }, props), /*#__PURE__*/React.createElement("path", {
    d: "M12.5 20.8l4.8-4.8-4.8-4.8 1.6-1.7 6.4 6.5-6.4 6.5z"
  }));
};
var cn = cnCreate('mfui-service-card');
var ServiceCard = function ServiceCard(_ref) {
  var title = _ref.title,
    subtitle = _ref.subtitle,
    value = _ref.value,
    _ref$background = _ref.background,
    background = _ref$background === void 0 ? 'shadow' : _ref$background,
    _ref$size = _ref.size,
    size = _ref$size === void 0 ? 'big' : _ref$size,
    imageSrc = _ref.imageSrc,
    imageSrc2x = _ref.imageSrc2x,
    _ref$imageAlt = _ref.imageAlt,
    imageAlt = _ref$imageAlt === void 0 ? 'image' : _ref$imageAlt,
    href = _ref.href,
    _ref$target = _ref.target,
    target = _ref$target === void 0 ? '_self' : _ref$target,
    rel = _ref.rel,
    classes = _ref.classes,
    dataAttrs = _ref.dataAttrs,
    onClick = _ref.onClick;
  var isSizeSmall = size === 'small';
  var currentRel = setRelAttribute(rel, target);
  var imageSrcSet = imageSrc2x ? "".concat(imageSrc, ", ").concat(imageSrc2x, " 2x") : undefined;
  var footerElement = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
    className: cn('image-wrapper')
  }, /*#__PURE__*/React.createElement("img", {
    className: cn('image'),
    src: imageSrc,
    srcSet: imageSrcSet,
    alt: imageAlt
  })), /*#__PURE__*/React.createElement("div", {
    className: cn('price')
  }, /*#__PURE__*/React.createElement("div", {
    className: cn('circle')
  }, /*#__PURE__*/React.createElement(ArrowRight, {
    className: cn('arrow')
  })), /*#__PURE__*/React.createElement("div", {
    className: cn('value')
  }, value)));
  var renderFooter = function renderFooter() {
    if (isSizeSmall) {
      return /*#__PURE__*/React.createElement("div", _extends({
        className: cn('footer')
      }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.footer)), footerElement);
    }
    return footerElement;
  };
  return /*#__PURE__*/React.createElement("a", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
    className: cn({
      background: background,
      size: size
    }, [classes === null || classes === void 0 ? void 0 : classes.root]),
    href: href,
    target: target,
    rel: currentRel,
    onClick: onClick
  }), /*#__PURE__*/React.createElement("div", {
    className: cn('header')
  }, /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.title), {
    className: cn('title', [classes === null || classes === void 0 ? void 0 : classes.title])
  }), typeof title === 'string' ? convert(title, titleConvertConfig) : title), subtitle && /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.subtitle), {
    className: cn('subtitle'),
    style: {
      WebkitBoxOrient: 'vertical'
    }
  }), typeof subtitle === 'string' ? convert(subtitle, textConvertConfig) : subtitle)), renderFooter());
};
export default ServiceCard;