"use client";
import { jsx as _jsx } from "react/jsx-runtime";
import { createContext, useContext, useMemo } from "react";
/**
 * @internal
 * @since 5.0.0
 */ const context = /*#__PURE__*/ createContext({
    visible: false,
    setVisible () {
        throw new Error('"MenuVisibilityProvider" must be a parent component');
    },
    defaultFocusIndex: {
        current: 0
    }
});
context.displayName = "MenuVisibility";
/**
 * @internal
 * @since 5.0.0
 */ const { Provider } = context;
/**
 * This hook allows you control the visibility of a parent menu. The main
 * use-case for this hook is adding a custom sheet header/footer.
 *
 * @example Simple Example
 * ```tsx
 * function SheetFooter(): ReactElement {
 *   const { setVisible } = useMenuVisibility();
 *
 *   return (
 *     <DialogFooter>
 *       <Button onClick={() => setVisible(false)}>Cancel</Button>
 *     </DialogFooter>
 *   );
 * }
 * ```
 *
 * @returns the {@link MenuVisibilityContext}
 * @since 5.0.0
 */ export function useMenuVisibility() {
    return useContext(context);
}
/**
 * **Client Component**
 *
 * @internal
 * @since 5.0.0
 */ export function MenuVisibilityProvider({ visible, setVisible, defaultFocusIndex, children }) {
    const value = useMemo(()=>({
            visible,
            setVisible,
            defaultFocusIndex
        }), [
        visible,
        setVisible,
        defaultFocusIndex
    ]);
    return /*#__PURE__*/ _jsx(Provider, {
        value: value,
        children: children
    });
}

//# sourceMappingURL=MenuVisibilityProvider.js.map