"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
require("react");
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 useRandomClassname = require("../../core/Box/use-random-classname/use-random-classname.cjs");
const Box = require("../../core/Box/Box.cjs");
const factory = require("../../core/factory/factory.cjs");
const Grid_context = require("./Grid.context.cjs");
const GridCol = require("./GridCol/GridCol.cjs");
const GridVariables = require("./GridVariables.cjs");
const Grid_module_css = require("./Grid.module.css.cjs");
const defaultProps = {
  gutter: "md",
  grow: false,
  columns: 12
};
const varsResolver = createVarsResolver.createVarsResolver((_, { justify, align, overflow }) => ({
  root: {
    "--grid-justify": justify,
    "--grid-align": align,
    "--grid-overflow": overflow
  }
}));
const Grid = factory.factory((_props, ref) => {
  const props = useProps.useProps("Grid", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    grow,
    gutter,
    columns,
    align,
    justify,
    children,
    breakpoints,
    type,
    ...others
  } = props;
  const getStyles = useStyles.useStyles({
    name: "Grid",
    classes: Grid_module_css.default,
    props,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  const responsiveClassName = useRandomClassname.useRandomClassName();
  if (type === "container" && breakpoints) {
    return /* @__PURE__ */ jsxRuntime.jsxs(Grid_context.GridProvider, { value: { getStyles, grow, columns: columns || 12, breakpoints, type }, children: [
      /* @__PURE__ */ jsxRuntime.jsx(GridVariables.GridVariables, { selector: `.${responsiveClassName}`, ...props }),
      /* @__PURE__ */ jsxRuntime.jsx("div", { ...getStyles("container"), children: /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ref, ...getStyles("root", { className: responsiveClassName }), ...others, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ...getStyles("inner"), children }) }) })
    ] });
  }
  return /* @__PURE__ */ jsxRuntime.jsxs(Grid_context.GridProvider, { value: { getStyles, grow, columns: columns || 12, breakpoints, type }, children: [
    /* @__PURE__ */ jsxRuntime.jsx(GridVariables.GridVariables, { selector: `.${responsiveClassName}`, ...props }),
    /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ref, ...getStyles("root", { className: responsiveClassName }), ...others, children: /* @__PURE__ */ jsxRuntime.jsx("div", { ...getStyles("inner"), children }) })
  ] });
});
Grid.classes = Grid_module_css.default;
Grid.displayName = "@mantine/core/Grid";
Grid.Col = GridCol.GridCol;
exports.Grid = Grid;
