"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EntityCard = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Styles = require("./Styles");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
var EntityCard = exports.EntityCard = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var _ref$renderAs = _ref.renderAs,
    renderAs = _ref$renderAs === void 0 ? "list-item" : _ref$renderAs,
    properties = _ref.properties,
    className = _ref.className;
  var renderAsListItem = (0, _react.useCallback)(function (properties) {
    return properties.filter(function (p) {
      return p.showInList;
    }).map(function (p) {
      return /*#__PURE__*/_react.default.createElement("div", {
        key: p.name,
        className: "entity-property-".concat(p.name)
      }, p.render());
    });
  }, []);
  var renderAsGridItem = (0, _react.useCallback)(function (properties) {
    var headerSection = properties.filter(function (p) {
      return p.cardSection === "header";
    });
    var bodySection = properties.filter(function (p) {
      return p.cardSection === "body";
    });
    var footerSection = properties.filter(function (p) {
      return p.cardSection === "footer";
    });
    var renderProperty = function renderProperty(p) {
      return /*#__PURE__*/_react.default.createElement("div", {
        key: p.name,
        className: "entity-property-".concat(p.name)
      }, p.render());
    };
    return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("div", {
      className: "card-header"
    }, headerSection.map(function (p) {
      return renderProperty(p);
    })), /*#__PURE__*/_react.default.createElement("div", {
      className: "card-body"
    }, bodySection.map(function (p) {
      return renderProperty(p);
    })), /*#__PURE__*/_react.default.createElement("div", {
      className: "card-footer"
    }, footerSection.map(function (p) {
      return renderProperty(p);
    })));
  }, []);
  return /*#__PURE__*/_react.default.createElement(_Styles.StyledEntityCard, {
    ref: ref,
    hoverable: true,
    className: (0, _classnames.default)("entity-card-wrapper", {
      "grid-item": renderAs === "grid-item",
      "list-item": renderAs === "list-item"
    }, className),
    variant: renderAs === "grid-item" ? "paper-1" : "paper-2",
    $renderAs: renderAs
  }, renderAs === "list-item" ? renderAsListItem(properties) : null, renderAs === "grid-item" ? renderAsGridItem(properties) : null);
});
EntityCard.displayName = "EntityCard";
//# sourceMappingURL=EntityCard.js.map