'use client';

import * as React from 'react';
import { useMenuItem } from '../item/useMenuItem.js';
import { useForkRef } from '../../utils/useForkRef.js';
export function useMenuSubmenuTrigger(parameters) {
  const {
    id,
    highlighted,
    disabled,
    ref: externalRef,
    menuEvents,
    setTriggerElement,
    allowMouseUpTriggerRef,
    typingRef
  } = parameters;
  const {
    getItemProps,
    rootRef: menuItemRef
  } = useMenuItem({
    closeOnClick: false,
    disabled,
    highlighted,
    id,
    menuEvents,
    ref: externalRef,
    allowMouseUpTriggerRef,
    typingRef
  });
  const menuTriggerRef = useForkRef(menuItemRef, setTriggerElement);
  const getTriggerProps = React.useCallback(externalProps => {
    return {
      ...getItemProps(externalProps),
      'aria-haspopup': 'menu',
      ref: menuTriggerRef
    };
  }, [getItemProps, menuTriggerRef]);
  return React.useMemo(() => ({
    getTriggerProps,
    rootRef: menuTriggerRef
  }), [getTriggerProps, menuTriggerRef]);
}