"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.DefaultLinkComponent = void 0;
var _react = _interopRequireDefault(require("react"));
var _types = require("./types");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const DefaultLinkComponent = exports.DefaultLinkComponent = /*#__PURE__*/_react.default.forwardRef(({
  onMouseEnter,
  onMouseLeave,
  onKeyDown,
  onClick,
  option,
  children,
  disabled,
  ...rest
}, ref) => {
  const {
    className,
    isExternal,
    link,
    testId
  } = option;
  const handleClick = e => {
    if (disabled) {
      e.preventDefault();
      e.stopPropagation();
    }
    onClick?.(e);
  };
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
    className: className,
    ref: ref,
    rel: "noopener noreferrer",
    "test-id": testId,
    onClick: handleClick,
    onMouseEnter: onMouseEnter,
    onMouseLeave: onMouseLeave,
    onKeyDown: onKeyDown,
    target: isExternal ? '_blank' : undefined,
    href: disabled ? undefined : link,
    role: _types.MENU_ROLE.MENUITEM,
    ...rest,
    children: children
  });
});
DefaultLinkComponent.displayName = 'LinkComponent';