"use strict";
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
const jsxRuntime = require("react/jsx-runtime");
const rem = require("../../core/utils/units-converters/rem.cjs");
require("react");
const getDefaultZIndex = require("../../core/utils/get-default-z-index/get-default-z-index.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 Box = require("../../core/Box/Box.cjs");
const factory = require("../../core/factory/factory.cjs");
const OptionalPortal = require("../Portal/OptionalPortal.cjs");
const Affix_module_css = require("./Affix.module.css.cjs");
const defaultProps = {
  position: { bottom: 0, right: 0 },
  zIndex: getDefaultZIndex.getDefaultZIndex("modal"),
  withinPortal: true
};
const varsResolver = createVarsResolver.createVarsResolver((_, { zIndex, position }) => ({
  root: {
    "--affix-z-index": zIndex == null ? void 0 : zIndex.toString(),
    "--affix-top": rem.rem(position == null ? void 0 : position.top),
    "--affix-left": rem.rem(position == null ? void 0 : position.left),
    "--affix-bottom": rem.rem(position == null ? void 0 : position.bottom),
    "--affix-right": rem.rem(position == null ? void 0 : position.right)
  }
}));
const Affix = factory.factory((_props, ref) => {
  const props = useProps.useProps("Affix", defaultProps, _props);
  const {
    classNames,
    className,
    style,
    styles,
    unstyled,
    vars,
    portalProps,
    zIndex,
    withinPortal,
    position,
    ...others
  } = props;
  const getStyles = useStyles.useStyles({
    name: "Affix",
    classes: Affix_module_css.default,
    props,
    className,
    style,
    classNames,
    styles,
    unstyled,
    vars,
    varsResolver
  });
  return /* @__PURE__ */ jsxRuntime.jsx(OptionalPortal.OptionalPortal, { ...portalProps, withinPortal, children: /* @__PURE__ */ jsxRuntime.jsx(Box.Box, { ref, ...getStyles("root"), ...others }) });
});
Affix.classes = Affix_module_css.default;
Affix.displayName = "@mantine/core/Affix";
exports.Affix = Affix;
