import { jsx } from "react/jsx-runtime";
import { forwardRef } from "react";
import clsx from "clsx";
import { FocusTrap } from "../FocusTrap/FocusTrap.mjs";
import { Paper } from "../Paper/Paper.mjs";
import { Transition } from "../Transition/Transition.mjs";
import { useModalBaseContext } from "./ModalBase.context.mjs";
import classes from "./ModalBase.module.css.mjs";
const ModalBaseContent = forwardRef(
  ({ transitionProps, className, innerProps, onKeyDown, style, ...others }, ref) => {
    const ctx = useModalBaseContext();
    return /* @__PURE__ */ jsx(
      Transition,
      {
        mounted: ctx.opened,
        transition: "pop",
        ...ctx.transitionProps,
        onExited: () => {
          var _a, _b, _c;
          (_a = ctx.onExitTransitionEnd) == null ? void 0 : _a.call(ctx);
          (_c = (_b = ctx.transitionProps) == null ? void 0 : _b.onExited) == null ? void 0 : _c.call(_b);
        },
        onEntered: () => {
          var _a, _b, _c;
          (_a = ctx.onEnterTransitionEnd) == null ? void 0 : _a.call(ctx);
          (_c = (_b = ctx.transitionProps) == null ? void 0 : _b.onEntered) == null ? void 0 : _c.call(_b);
        },
        ...transitionProps,
        children: (transitionStyles) => /* @__PURE__ */ jsx(
          "div",
          {
            ...innerProps,
            className: clsx({ [classes.inner]: !ctx.unstyled }, innerProps.className),
            children: /* @__PURE__ */ jsx(FocusTrap, { active: ctx.opened && ctx.trapFocus, innerRef: ref, children: /* @__PURE__ */ jsx(
              Paper,
              {
                ...others,
                component: "section",
                role: "dialog",
                tabIndex: -1,
                "aria-modal": true,
                "aria-describedby": ctx.bodyMounted ? ctx.getBodyId() : void 0,
                "aria-labelledby": ctx.titleMounted ? ctx.getTitleId() : void 0,
                style: [style, transitionStyles],
                className: clsx({ [classes.content]: !ctx.unstyled }, className),
                unstyled: ctx.unstyled,
                children: others.children
              }
            ) })
          }
        )
      }
    );
  }
);
ModalBaseContent.displayName = "@mantine/core/ModalBaseContent";
export {
  ModalBaseContent
};
