"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.TOP_LINE_COLOR = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _tooltip = require("../tooltip");
var _hooks = require("../hooks");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const TOP_LINE_COLOR = exports.TOP_LINE_COLOR = {
  BLUE: 'blue',
  ORANGE: 'orange',
  GREEN: 'green',
  RED: 'red'
};

/**
 * Customizable generic card
 * @uxr-only-supported
 * @midnight-gray-supported
 * @alpine-light-supported
 * */
function CustomCard({
  children,
  className,
  testId,
  onClick,
  ariaLabel,
  isDisabled,
  tooltipContent,
  isSelected,
  topLineColor,
  interactiveFooter,
  tooltipProps = {}
}) {
  const attrs = (0, _hooks.useNonNativeButtonAttrs)({
    isDisabled: !onClick || isDisabled,
    onClick,
    // eslint-disable-next-line @typescript-eslint/ban-ts-comment
    // @ts-ignore
    onKeyDown: onClick
  });
  const containerClassName = (0, _classnames.default)('custom-card-container', {
    'with-top-line': !!topLineColor,
    'with-interactive-footer': !!interactiveFooter,
    selected: isSelected,
    disabled: isDisabled,
    clickable: !interactiveFooter && onClick && !isDisabled
  }, topLineColor, className);
  const clickableContentClassName = (0, _classnames.default)('clickable-content-area', {
    clickable: !isDisabled
  });
  const cardContent = /*#__PURE__*/(0, _jsxRuntime.jsx)(_tooltip.Tooltip, {
    placement: _tooltip.TOOLTIP_PLACEMENT_TYPES.TOP,
    content: tooltipContent,
    ...tooltipProps,
    children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
      ...(!interactiveFooter ? {
        'test-id': testId
      } : {}),
      role: attrs.role,
      onClick: attrs.onClick,
      onKeyDown: attrs.onKeyDown,
      tabIndex: attrs.tabIndex,
      "aria-disabled": attrs['aria-disabled'],
      "aria-label": ariaLabel,
      className: interactiveFooter ? clickableContentClassName : containerClassName,
      children: interactiveFooter ? /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "card-content-wrapper",
        children: children
      }) : children
    })
  });

  // Clickable card with interactive footer
  if (interactiveFooter && onClick) {
    return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
      ...(interactiveFooter ? {
        'test-id': testId
      } : {}),
      className: containerClassName,
      children: [cardContent, /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
        className: "card-footer-wrapper",
        children: interactiveFooter
      })]
    });
  }
  return cardContent;
}
var _default = exports.default = CustomCard;