"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const React = require("react");
const getSize = require("../../core/utils/get-size/get-size.cjs");
const createVarsResolver = require("../../core/styles-api/create-vars-resolver/create-vars-resolver.cjs");
require("clsx");
const useProps = require("../../core/MantineProvider/use-props/use-props.cjs");
const useStyles = require("../../core/styles-api/use-styles/use-styles.cjs");
const polymorphicFactory = require("../../core/factory/polymorphic-factory.cjs");
const Paper = require("../Paper/Paper.cjs");
const Card_context = require("./Card.context.cjs");
const CardSection = require("./CardSection/CardSection.cjs");
const Card_module_css = require("./Card.module.css.cjs");
const defaultProps = {};
const varsResolver = createVarsResolver.createVarsResolver((_, { padding }) => ({
  root: {
    "--card-padding": getSize.getSpacing(padding)
  }
}));
const Card = polymorphicFactory.polymorphicFactory((_props, ref) => {
  const props = useProps.useProps("Card", defaultProps, _props);
  const { classNames, className, style, styles, unstyled, vars, children, padding, ...others } = props;
  const getStyles = useStyles.useStyles({
    name: "Card",
    props,
    classes: Card_module_css.default,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  const _children = React.Children.toArray(children);
  const content = _children.map((child, index) => {
    if (typeof child === "object" && child && "type" in child && child.type === CardSection.CardSection) {
      return React.cloneElement(child, {
        "data-first-section": index === 0 || void 0,
        "data-last-section": index === _children.length - 1 || void 0
      });
    }
    return child;
  });
  return /* @__PURE__ */ jsxRuntime.jsx(Card_context.CardProvider, { value: { getStyles }, children: /* @__PURE__ */ jsxRuntime.jsx(Paper.Paper, { ref, unstyled, ...getStyles("root"), ...others, children: content }) });
});
Card.classes = Card_module_css.default;
Card.displayName = "@mantine/core/Card";
Card.Section = CardSection.CardSection;
exports.Card = Card;
