import _extends from "@babel/runtime/helpers/extends";
import _defineProperty from "@babel/runtime/helpers/defineProperty";
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
/**
 * @jsxRuntime classic
 * @jsx jsx
 */
import React, { useContext } from 'react';

// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
import { jsx } from '@emotion/react';
import { ArrowKeyNavigationType } from '../ArrowKeyNavigationProvider/types';
import DropdownComponent from '../Dropdown';
import { KeyDownHandlerContext } from '../ToolbarArrowKeyNavigationProvider';
export var DropdownContainer = /*#__PURE__*/React.memo(function DropdownContainer(props) {
  var keyDownHandlerContext = useContext(KeyDownHandlerContext);
  var newArrowKeyNavigationProviderOptions = props.arrowKeyNavigationProviderOptions;
  // if the dropdown is of type menu, use this keyDownHandlerContext
  if (props.arrowKeyNavigationProviderOptions.type === ArrowKeyNavigationType.MENU) {
    newArrowKeyNavigationProviderOptions = _objectSpread(_objectSpread({}, props.arrowKeyNavigationProviderOptions), {}, {
      keyDownHandlerContext: keyDownHandlerContext
    });
  }
  return (
    //This context is to handle the tab, Arrow Right/Left key events for dropdown.
    //Default context has the void callbacks for above key events
    jsx(DropdownComponent
    // eslint-disable-next-line react/jsx-props-no-spreading -- Spreading props to pass through dynamic component props
    , _extends({}, props, {
      arrowKeyNavigationProviderOptions: newArrowKeyNavigationProviderOptions
    }))
  );
});