"use client";
import { getSingleElementChild } from "../../core/utils/get-single-element-child/get-single-element-child.mjs";
import { VisuallyHidden } from "../VisuallyHidden/VisuallyHidden.mjs";
import { cloneElement } from "react";
import { useFocusTrap, useMergedRef } from "@mantine/hooks";
import { jsx } from "react/jsx-runtime";
//#region packages/@mantine/core/src/components/FocusTrap/FocusTrap.tsx
function FocusTrap({ children, active = true, refProp = "ref", innerRef }) {
	const ref = useMergedRef(useFocusTrap(active), innerRef);
	const child = getSingleElementChild(children);
	if (!child) return children;
	return cloneElement(child, { [refProp]: ref });
}
function FocusTrapInitialFocus(props) {
	return /* @__PURE__ */ jsx(VisuallyHidden, {
		tabIndex: -1,
		"data-autofocus": true,
		...props
	});
}
FocusTrap.displayName = "@mantine/core/FocusTrap";
FocusTrapInitialFocus.displayName = "@mantine/core/FocusTrapInitialFocus";
FocusTrap.InitialFocus = FocusTrapInitialFocus;
//#endregion
export { FocusTrap, FocusTrapInitialFocus };

//# sourceMappingURL=FocusTrap.mjs.map