"use client";
import { createContext, useContext, useMemo } from "react";
import { createHoverModeContext, useHoverModeProvider } from "../hoverMode/useHoverModeProvider.js";
const context = createContext({
    ...createHoverModeContext(),
    root: false,
    menubar: false,
    menuitem: false
});
context.displayName = "MenuBar";
/**
 * @internal
 * @remarks \@since 6.0.0
 */ export const { Provider: MenuBarProvider } = context;
/**
 * @internal
 * @remarks \@since 5.0.0
 */ export function useMenuBarContext() {
    return useContext(context);
}
/**
 * @internal
 * @remarks \@since 6.0.0
 */ export function useMenuBarProvider(options) {
    const { hoverTimeout, root, menubar, defaultActiveId = "" } = options;
    const hoverMode = useHoverModeProvider({
        hoverTimeout,
        forceRerender: true,
        defaultActiveId
    });
    if (defaultActiveId) {
        // without this "fix", first-level nested dropdown menus will only disable
        // the animation the first time they are shown.
        hoverMode.animatedOnceRef.current = true;
    }
    return useMemo(()=>({
            // when not within a menubar, disable all the hover mode functionality by
            // creating an empty hover mode context. This makes it so nested dropdown
            // menus don't trigger the hover mode timeouts and behavior
            ...menubar ? hoverMode : createHoverModeContext(),
            root,
            menubar,
            menuitem: true
        }), [
        hoverMode,
        menubar,
        root
    ]);
}

//# sourceMappingURL=useMenuBarProvider.js.map