import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["children", "className", "image", "isExternal", "isLink", "metadata", "subTitle", "title", "kind", "url", "cardWidth", "cardHeight"];
import PropTypes from 'prop-types';
import React from 'react';
import classNames from 'classnames';
import { settings } from '../../globals/js';
var prefix = settings.prefix;
/**
 * Cards are a convenient means of displaying content composed of different types of objects. It is a multi usage component which creates boxes that are usually teasing some kind of content. */

var Card = function Card(_ref) {
  var _classNames;

  var children = _ref.children,
      className = _ref.className,
      image = _ref.image,
      isExternal = _ref.isExternal,
      isLink = _ref.isLink,
      metadata = _ref.metadata,
      subTitle = _ref.subTitle,
      title = _ref.title,
      kind = _ref.kind,
      url = _ref.url,
      cardWidth = _ref.cardWidth,
      cardHeight = _ref.cardHeight,
      other = _objectWithoutProperties(_ref, _excluded);

  var style = kind == 'overlay' ? {
    backgroundImage: "url(".concat(image, ")")
  } : {};
  var pagewidth = cardWidth ? cardWidth : '300px';
  var pageheight = cardHeight ? cardHeight : '260px';
  var wrapperClasses = classNames(["".concat(prefix, "--card-box")], (_classNames = {}, _defineProperty(_classNames, "".concat(prefix, "--photo-cardnew--").concat(kind), kind), _defineProperty(_classNames, "".concat(prefix, "--photo-cardnew--link"), isLink), _defineProperty(_classNames, "".concat(className), className), _classNames));
  var content = /*#__PURE__*/React.createElement(React.Fragment, null, kind === 'overlay' ? /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-cardnew__background"),
    style: style
  }) : null, image && kind === 'simple-card' ? /*#__PURE__*/React.createElement("img", {
    src: image,
    alt: title,
    className: "".concat(prefix, "--header-photo")
  }) : null, /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-cardnew__info")
  }, /*#__PURE__*/React.createElement("div", null, kind === 'overlay' && /*#__PURE__*/React.createElement("div", {
    className: "".concat(prefix, "--photo-cardnew__info__background"),
    style: style
  }), metadata && /*#__PURE__*/React.createElement("p", {
    className: "".concat(prefix, "--photo-cardnew__info__metadata")
  }, metadata), title && /*#__PURE__*/React.createElement("h3", {
    className: "".concat(prefix, "--photo-cardnew__info__title")
  }, title), subTitle && /*#__PURE__*/React.createElement("p", {
    className: "".concat(prefix, "--photo-cardnew__info__subtitle")
  }, subTitle))), children);
  return isLink ? /*#__PURE__*/React.createElement("div", {
    className: wrapperClasses,
    style: {
      width: pagewidth,
      minHeight: pageheight
    }
  }, /*#__PURE__*/React.createElement("a", _extends({
    href: url,
    target: isExternal ? '_blank' : '',
    style: {
      width: pagewidth,
      minHeight: pageheight
    }
  }, other), content)) : /*#__PURE__*/React.createElement("div", _extends({
    className: wrapperClasses
  }, other, {
    style: {
      width: pagewidth,
      minHeight: pageheight
    }
  }), content);
};

Card.propTypes = {
  /**
   Additional className which will be added
  */
  className: PropTypes.string,

  /**
   An optimized photograph
  */
  image: PropTypes.string,

  /**
  isExternal if true, opens link in a different window
  */
  isExternal: PropTypes.bool,

  /**
  Render the Card as link
  */
  isLink: PropTypes.bool,

  /**
  A short sentence to explain the content of the node (max 180 characters) 
  */
  subTitle: PropTypes.node,

  /**
   A search-friendly title (ideally 50 characters, max 100) 
  */
  title: PropTypes.node,

  /**
  Additional metadatas
  */
  metadata: PropTypes.string,

  /**
  Kind of Card
  */
  kind: PropTypes.oneOf(['simple-card', 'overlay']).isRequired,

  /**
  The URL where the content uploaded is located.
  */
  url: PropTypes.string,

  /**
   * override default card width with preferred width
   */
  cardWidth: PropTypes.string,

  /**
   * override default card width with preferred width
   */
  cardHeight: PropTypes.string
};
Card.defaultProps = {
  isLink: true
};
export default Card;