"use strict";

function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Card = void 0;
var _isNil2 = _interopRequireDefault(require("ramda/src/isNil"));
var _react = _interopRequireDefault(require("react"));
var _styledComponents = _interopRequireWildcard(require("styled-components"));
var _utils = require("../../common/utils");
var _excluded = ["as", "barColor", "children", "className", "grow"];
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _extends() { _extends = Object.assign ? Object.assign.bind() : 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; }
var getColor = function getColor(props) {
  var barColor = props.barColor,
    theme = props.theme;
  if ((0, _utils.isFunction)(barColor)) {
    return barColor(theme);
  }
  return 'transparent';
};
var barStyles = (0, _styledComponents.css)(["position:relative;&::before{content:'';display:block;width:100%;height:", "px;background:", ";position:absolute;top:0;left:0;", "{border-top-left-radius:", ";border-top-right-radius:", ";}}"], function (p) {
  return p.theme.spacing.unit(2);
}, function (p) {
  return getColor(p);
}, function (p) {
  return p.theme.media.greaterThan(p.theme.breakpoints.sm);
}, function (p) {
  return p.theme.borderRadius8;
}, function (p) {
  return p.theme.borderRadius8;
});
var StyledCard = _styledComponents.default.div.withConfig({
  displayName: "Card__StyledCard",
  componentId: "sc-1e5czjc-0"
})(["background:", ";box-shadow:0 2px 2px 0 ", ";", ";&&{", ";}", "{border-radius:", ";}"], function (_ref) {
  var theme = _ref.theme;
  return theme.color.card;
}, function (_ref2) {
  var theme = _ref2.theme;
  return theme.color.shadowCard;
}, function (p) {
  return p.barColor ? barStyles : "";
}, function (p) {
  return !(0, _isNil2.default)(p.grow) && "flex-grow: ".concat(p.grow);
}, function (p) {
  return p.theme.media.greaterThan(p.theme.breakpoints.sm);
}, function (_ref3) {
  var theme = _ref3.theme;
  return theme.borderRadius8;
});
var Card = exports.Card = _react.default.forwardRef(function (_ref4, ref) {
  var as = _ref4.as,
    barColor = _ref4.barColor,
    children = _ref4.children,
    className = _ref4.className,
    grow = _ref4.grow,
    rest = _objectWithoutProperties(_ref4, _excluded);
  return _react.default.createElement(StyledCard, _extends({
    className: className,
    as: as,
    barColor: barColor,
    ref: ref,
    grow: grow
  }, rest), children);
});
Card.displayName = 'Card';