"use client";
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
import { createPortal } from "react-dom";
import { usePortalContainer } from "./PortalContainerProvider.js";
/**
 * **Client Component**
 *
 * Portals are a great way to render temporary elements like dialogs, tooltips,
 * and menus at a different port of the DOM. This implementation will render
 * the `children` in the current {@link PortalContainer} element.
 *
 * @example Simple Example
 * ```tsx
 * import { Portal } from "@react-md/portal";
 *
 * function Example() {
 *   return <Portal><div>Some Content</div></Portal>;
 * }
 * ```
 *
 * @see {@link https://react-md.dev/components/portal | Portal Demos}
 * @see {@link PortalContainerProvider}
 * @see {@link usePortalContainer}
 */ export function Portal(props) {
    const { children, disabled = false } = props;
    const container = usePortalContainer();
    if (!container || disabled) {
        return /*#__PURE__*/ _jsx(_Fragment, {
            children: disabled && children
        });
    }
    return /*#__PURE__*/ createPortal(children, container);
}

//# sourceMappingURL=Portal.js.map