function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

/*
Copyright (c) 2018 Uber Technologies, Inc.

This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
*/
import React from 'react';
import { getOverride, getOverrideProps } from '../helpers/overrides.js';
import { Action as StyledAction, Body as StyledBody, Contents as StyledContents, HeaderImage as StyledHeaderImage, Root as StyledRoot, Thumbnail as StyledThumbnail, Title as StyledTitle } from './styled-components.js';
export function hasThumbnail(props) {
  return Boolean(props.thumbnail);
}

function Card(props) {
  var action = props.action,
      children = props.children,
      hasThumbnail = props.hasThumbnail,
      headerImage = props.headerImage,
      thumbnailSrc = props.thumbnail,
      title = props.title,
      overrides = props.overrides,
      otherProps = _objectWithoutProperties(props, ["action", "children", "hasThumbnail", "headerImage", "thumbnail", "title", "overrides"]);

  var ActionOverride = overrides.Action,
      BodyOverride = overrides.Body,
      ContentsOverride = overrides.Contents,
      HeaderImageOverride = overrides.HeaderImage,
      RootOverride = overrides.Root,
      ThumbnailOverride = overrides.Thumbnail,
      TitleOverride = overrides.Title;
  var Action = getOverride(ActionOverride) || StyledAction;
  var Body = getOverride(BodyOverride) || StyledBody;
  var Contents = getOverride(ContentsOverride) || StyledContents;
  var HeaderImage = getOverride(HeaderImageOverride) || StyledHeaderImage;
  var Root = getOverride(RootOverride) || StyledRoot;
  var Thumbnail = getOverride(ThumbnailOverride) || StyledThumbnail;
  var Title = getOverride(TitleOverride) || StyledTitle;
  var $hasThumbnail = hasThumbnail(props);
  return React.createElement(Root, _extends({
    "data-baseweb": "card"
  }, otherProps, getOverrideProps(RootOverride)), headerImage && React.createElement(HeaderImage, _extends({
    src: headerImage
  }, getOverrideProps(HeaderImageOverride))), React.createElement(Contents, getOverrideProps(ContentsOverride), thumbnailSrc && React.createElement(Thumbnail, _extends({
    src: thumbnailSrc
  }, getOverrideProps(ThumbnailOverride))), title && React.createElement(Title, _extends({
    $hasThumbnail: $hasThumbnail
  }, getOverrideProps(TitleOverride)), title), React.createElement(Body, getOverrideProps(BodyOverride), children), action && React.createElement(Action, getOverrideProps(ActionOverride), action)));
}

Card.defaultProps = {
  action: null,
  children: null,
  hasThumbnail: hasThumbnail,
  overrides: {}
};
export default Card;