"use strict";
var import_Card = require("../Card.css");
const jsxRuntime = require("react/jsx-runtime");
const kit_Collection = require("./Collection.cjs");
const kit_Icon = require("./Icon.cjs");
const kit_internal_functions = require("./internal/functions.cjs");
const kit_Theme_UI = require("./Theme/UI.cjs");
require("./Theme/themeUtils.cjs");
const kit_Theme_themes = require("./Theme/themes.cjs");
const kit_Button = require("./Button.cjs");
const kit_Dropdown = require("./Dropdown.cjs");
const kit_Surface = require("./Surface.cjs");
const cardBase = "Card_cardBase_4ec5b";
const action = "Card_action_4ec5b";
const content = "Card_content_4ec5b";
const clickable = "Card_clickable_4ec5b";
const smallCard = "Card_smallCard_4ec5b";
const mediumCard = "Card_mediumCard_4ec5b";
const groupBase = "Card_groupBase_4ec5b";
const css = {
  cardBase,
  action,
  content,
  clickable,
  smallCard,
  mediumCard,
  groupBase
};
const CardSizes = {
  medium: { minHeight: "110px", minWidth: "302px" },
  small: { minHeight: "64px", minWidth: "143px" }
};
const stopPropagation = (e) => e.stopPropagation();
const Card = ({
  actionMenu,
  children,
  disabled = false,
  onClick,
  onDropdown,
  size = "small",
  testId
}) => {
  const {
    themeSettings: { className: themeClass }
  } = kit_Theme_UI.useTheme();
  const classnames = [css.cardBase, themeClass];
  if (onClick)
    classnames.push(css.clickable);
  const sizeStyle = CardSizes[size];
  switch (size) {
    case "small":
      classnames.push(css.smallCard);
      break;
    case "medium":
      classnames.push(css.mediumCard);
      break;
  }
  const actionsAvailable = (actionMenu == null ? void 0 : actionMenu.length) !== void 0 && actionMenu.length > 0;
  return /* @__PURE__ */ jsxRuntime.jsx(
    "div",
    {
      className: classnames.join(" "),
      "data-testid": testId,
      style: sizeStyle,
      tabIndex: onClick ? 0 : -1,
      onClick,
      children: /* @__PURE__ */ jsxRuntime.jsxs(kit_Surface, { hover: !!onClick, children: [
        /* @__PURE__ */ jsxRuntime.jsx("section", { className: css.content, children }),
        actionsAvailable && /* @__PURE__ */ jsxRuntime.jsx("div", { className: css.action, onClick: stopPropagation, children: /* @__PURE__ */ jsxRuntime.jsx(
          kit_Dropdown,
          {
            disabled,
            menu: actionMenu,
            placement: "bottomRight",
            onClick: onDropdown,
            children: /* @__PURE__ */ jsxRuntime.jsx(
              kit_Button,
              {
                icon: /* @__PURE__ */ jsxRuntime.jsx(kit_Icon.default, { name: "overflow-horizontal", size: "tiny", title: "Action menu" }),
                type: "text",
                onClick: stopPropagation
              }
            )
          }
        ) })
      ] })
    }
  );
};
const CardGroup = ({
  children,
  wrap = true,
  size = "small"
}) => {
  const cardSize = CardSizes[size].minWidth;
  const minCardWidth = kit_internal_functions.isNumber(cardSize) ? cardSize : parseInt(cardSize);
  const {
    themeSettings: { className: themeClass }
  } = kit_Theme_UI.useTheme();
  const classes = [css.groupBase, themeClass];
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: classes.join(" "), children: /* @__PURE__ */ jsxRuntime.jsx(
    kit_Collection.default,
    {
      gap: kit_Theme_themes.ShirtSize.Large,
      minItemWidth: minCardWidth,
      mode: wrap ? kit_Collection.LayoutMode.AutoFill : kit_Collection.LayoutMode.ScrollableRow,
      children
    }
  ) });
};
Card.Group = CardGroup;
module.exports = Card;
