"use strict";

function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.CardTextFieldsSkeleton = exports.CardSecondaryTextSkeleton = exports.CardPrimaryTextSkeleton = exports.CardHeaderActionsSkeleton = exports.CardFooterActionsSkeleton = exports.CardButtonSkeleton = exports.CardAvatarSkeleton = void 0;
exports["default"] = CardSkeleton;

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

var _Avatar = _interopRequireDefault(require("../avatar/Avatar"));

var _Button = _interopRequireDefault(require("../button/Button"));

var _Text = _interopRequireDefault(require("../text/Text"));

var _Box = _interopRequireDefault(require("../layout/Box"));

var _CardModule = _interopRequireDefault(require("./Card.module.css"));

var _Card = _interopRequireDefault(require("./Card.constantProps"));

var _Box2 = _interopRequireDefault(require("../layout/Box.constantProps"));

var _Card2 = _interopRequireWildcard(require("./Card.propTypes"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

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 CardSkeleton(props) {
  var children = props.children,
      type = props.type;
  var Components = {};

  _react["default"].Children.forEach(children, function (child) {
    if (child && child.type && child.type.displayName) {
      Components[child.type.displayName] = function () {
        return child;
      };
    }
  });

  if (Object.keys(Components).length) {
    return /*#__PURE__*/_react["default"].createElement(_Box["default"], _extends({
      isContainer: true
    }, props, {
      customClassName: _CardModule["default"][type] + " " + _CardModule["default"].base
    }), /*#__PURE__*/_react["default"].createElement(_Box["default"], null, Components.Avatar ? /*#__PURE__*/_react["default"].createElement(Components.Avatar, null) : null), /*#__PURE__*/_react["default"].createElement(_Box["default"], {
      flexible: true,
      customClassName: _CardModule["default"].spacing
    }, /*#__PURE__*/_react["default"].createElement(_Box["default"], null, Components.HeaderActions ? /*#__PURE__*/_react["default"].createElement(_Box["default"], {
      customClassName: _CardModule["default"].absposition
    }, Components.HeaderActions ? /*#__PURE__*/_react["default"].createElement(Components.HeaderActions, null) : null) : null), Components.TextFields ? /*#__PURE__*/_react["default"].createElement(Components.TextFields, null) : null, /*#__PURE__*/_react["default"].createElement(_Box["default"], null, Components.FooterActions ? /*#__PURE__*/_react["default"].createElement(Components.FooterActions, null) : null)));
  }

  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, children);
}

CardSkeleton.propTypes = _Card2["default"];
CardSkeleton.defaultProps = _Card2.defaultProps;
CardSkeleton.propsDescription = _Card2.propsDescription;
CardSkeleton.constantProps = _Card["default"]; // sub comp

var CardAvatarSkeleton = function CardAvatarSkeleton(props) {
  if (props.children) {
    return props.children;
  }

  return /*#__PURE__*/_react["default"].createElement(_Avatar["default"], props);
};

exports.CardAvatarSkeleton = CardAvatarSkeleton;

var CardPrimaryTextSkeleton = function CardPrimaryTextSkeleton(props) {
  return /*#__PURE__*/_react["default"].createElement(_Text["default"], props);
};

exports.CardPrimaryTextSkeleton = CardPrimaryTextSkeleton;

var CardSecondaryTextSkeleton = function CardSecondaryTextSkeleton(props) {
  return /*#__PURE__*/_react["default"].createElement(_Text["default"], props);
};

exports.CardSecondaryTextSkeleton = CardSecondaryTextSkeleton;

var CardButtonSkeleton = function CardButtonSkeleton(props) {
  return /*#__PURE__*/_react["default"].createElement(_Button["default"], props);
};

exports.CardButtonSkeleton = CardButtonSkeleton;

var CardTextFieldsSkeleton = function CardTextFieldsSkeleton(props) {
  return /*#__PURE__*/_react["default"].createElement(_Box["default"], _extends({
    direction: _Box2["default"].direction.column
  }, props), props.children);
};

exports.CardTextFieldsSkeleton = CardTextFieldsSkeleton;

var CardFooterActionsSkeleton = function CardFooterActionsSkeleton(props) {
  var customeclass = props.customClassName ? "".concat(props.customClassName, " ").concat(props.isHover ? _CardModule["default"].footeractions : "", " ") : "".concat(props.isHover ? _CardModule["default"].footeractions : "");
  return /*#__PURE__*/_react["default"].createElement(_Box["default"], _extends({
    isContainer: true,
    direction: _Box2["default"].direction.row
  }, props, {
    customClassName: customeclass
  }), props.children);
};

exports.CardFooterActionsSkeleton = CardFooterActionsSkeleton;

var CardHeaderActionsSkeleton = function CardHeaderActionsSkeleton(props) {
  return /*#__PURE__*/_react["default"].createElement(_Box["default"], _extends({
    isContainer: true,
    direction: _Box2["default"].direction.row
  }, props, {
    customClassName: props.isHover ? _CardModule["default"].headeractions : ""
  }), props.children);
};

exports.CardHeaderActionsSkeleton = CardHeaderActionsSkeleton;