"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof = require("@babel/runtime/helpers/typeof");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _dropdownMenu = require("@atlaskit/dropdown-menu");
var _lozenge = _interopRequireDefault(require("@atlaskit/lozenge"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
var LozengeActionItem = function LozengeActionItem(_ref) {
  var appearance = _ref.appearance,
    id = _ref.id,
    onClick = _ref.onClick,
    testId = _ref.testId,
    text = _ref.text;
  var handleClick = (0, _react.useCallback)(function (e) {
    // Prevent dropdown to close on select item.
    // We want to show loading screen.
    e.stopPropagation();
    if (onClick) {
      onClick(id, text, appearance);
    }
  }, [appearance, id, onClick, text]);
  var handleMouseEnter = (0, _react.useCallback)(function (e) {
    var _e$currentTarget;
    (_e$currentTarget = e.currentTarget) === null || _e$currentTarget === void 0 || (_e$currentTarget = _e$currentTarget.firstElementChild) === null || _e$currentTarget === void 0 || _e$currentTarget.focus();
  }, []);
  return (
    /*#__PURE__*/
    // eslint-disable-next-line @atlassian/a11y/mouse-events-have-key-events
    _react.default.createElement("span", {
      onMouseEnter: handleMouseEnter,
      role: "presentation"
    }, /*#__PURE__*/_react.default.createElement(_dropdownMenu.DropdownItem, {
      onClick: handleClick,
      testId: testId
    }, /*#__PURE__*/_react.default.createElement(_lozenge.default, (0, _extends2.default)({
      appearance: appearance
    }, (0, _platformFeatureFlags.fg)('platform-component-visual-refresh') ? {
      isBold: true
    } : undefined), text)))
  );
};
var _default = exports.default = LozengeActionItem;