"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _react = _interopRequireDefault(require("react"));

var _classnames = _interopRequireDefault(require("classnames"));

var _js = require("../../globals/js");

var _excluded = ["children", "className", "image", "isExternal", "isLink", "metadata", "more", "subTitle", "title", "kind", "url"];
var prefix = _js.settings.prefix;
/**
 * Hero 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 Hero = function Hero(_ref) {
  var _classNames;

  var children = _ref.children,
      className = _ref.className,
      image = _ref.image,
      isExternal = _ref.isExternal,
      isLink = _ref.isLink,
      metadata = _ref.metadata,
      more = _ref.more,
      subTitle = _ref.subTitle,
      title = _ref.title,
      kind = _ref.kind,
      url = _ref.url,
      other = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var style = kind !== 'related' ? {
    backgroundImage: "url(".concat(image, ")")
  } : {};
  var wrapperClasses = (0, _classnames.default)("".concat(prefix, "--photo-card"), (_classNames = {}, (0, _defineProperty2.default)(_classNames, "".concat(prefix, "--photo-card--").concat(kind), kind), (0, _defineProperty2.default)(_classNames, "".concat(prefix, "--photo-card--no-background"), !image), (0, _defineProperty2.default)(_classNames, "".concat(prefix, "--photo-card--link"), isLink), (0, _defineProperty2.default)(_classNames, "".concat(className), className), _classNames));

  var content = /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--photo-card__background"),
    style: style
  }), image && kind === 'related' && /*#__PURE__*/_react.default.createElement("img", {
    src: image,
    alt: title
  }), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--photo-card__info")
  }, /*#__PURE__*/_react.default.createElement("div", null, (kind === 'landscape' || kind === 'hero') && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--photo-card__info__background"),
    style: style
  }), metadata && /*#__PURE__*/_react.default.createElement("p", {
    className: "".concat(prefix, "--photo-card__info__metadata")
  }, metadata), title && (kind === 'hero' || kind === 'page-splash') && /*#__PURE__*/_react.default.createElement("h2", {
    className: "".concat(prefix, "--photo-card__info__title")
  }, title), title && kind !== 'hero' && kind !== 'page-splash' && /*#__PURE__*/_react.default.createElement("h3", {
    className: "".concat(prefix, "--photo-card__info__title")
  }, title), subTitle && /*#__PURE__*/_react.default.createElement("p", {
    className: "".concat(prefix, "--photo-card__info__subtitle")
  }, subTitle)), kind === 'hero' || kind === 'splash-image' || kind === 'splash-compact' && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--photo-card__info__more")
  }, more)), children);

  return isLink ? /*#__PURE__*/_react.default.createElement("a", (0, _extends2.default)({
    href: url,
    target: isExternal ? '_blank' : '',
    className: wrapperClasses
  }, other), content) : /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    className: wrapperClasses
  }, other), content);
};

Hero.propTypes = {
  /**
   Additional className which will be added
  */
  className: _propTypes.default.string,

  /**
   The links target
  */
  href: _propTypes.default.string,

  /**
   An optimized photograph
  */
  image: _propTypes.default.string,

  /**
  External link flag
  */
  isExternal: _propTypes.default.bool,

  /**
  Render the Hero as link
  */
  isLink: _propTypes.default.bool,

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

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

  /**
  Additional metadatas
  */
  metadata: _propTypes.default.string,

  /**
  Additional more content
  */
  more: _propTypes.default.node,

  /**
  Kind of Hero
  */
  kind: _propTypes.default.oneOf(['landscape', 'landscape-light', 'emergencies', 'split', 'hero', 'splash', 'splash-image', 'splash-compact', 'related']).isRequired,

  /**
  The URL where the content uploaded is located.
  */
  url: _propTypes.default.string
};
Hero.defaultProps = {
  isLink: true
};
var _default = Hero;
exports.default = _default;