import React, { useMemo } from 'react';
import { ResourcedMention } from '@atlaskit/mention';
import ProfileCardTrigger from '@atlaskit/profilecard/user';
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
export default function MentionWithProfileCard(_ref) {
  var autoFocus = _ref.autoFocus,
    id = _ref.id,
    text = _ref.text,
    accessLevel = _ref.accessLevel,
    mentionProvider = _ref.mentionProvider,
    profilecardProvider = _ref.profilecardProvider,
    onClick = _ref.onClick,
    onMouseEnter = _ref.onMouseEnter,
    onMouseLeave = _ref.onMouseLeave,
    localId = _ref.localId,
    ssrPlaceholderId = _ref.ssrPlaceholderId;
  var cloudId = profilecardProvider.cloudId,
    resourceClient = profilecardProvider.resourceClient;
  var actions = useMemo(function () {
    return profilecardProvider.getActions(id, text, accessLevel);
  }, [accessLevel, id, profilecardProvider, text]);
  return /*#__PURE__*/React.createElement(ProfileCardTrigger, {
    autoFocus: autoFocus,
    cloudId: cloudId,
    userId: id,
    resourceClient: resourceClient,
    actions: actions,
    trigger: "click",
    position: "bottom-end",
    testId: "mention-with-profilecard-trigger"
    // Ignored via go/ees005
    // eslint-disable-next-line require-unicode-regexp
    ,
    ariaLabel: text.replace(/^@/, ''),
    ssrPlaceholderId: ssrPlaceholderId,
    isRenderedInPortal: expValEquals('editor_a11y_7152_profile_card_tab_order', 'isEnabled', true)
  }, /*#__PURE__*/React.createElement(ResourcedMention, {
    id: id,
    text: text,
    accessLevel: accessLevel,
    localId: localId,
    mentionProvider: mentionProvider,
    onClick: onClick,
    onMouseEnter: onMouseEnter,
    onMouseLeave: onMouseLeave,
    ssrPlaceholderId: ssrPlaceholderId
  }));
}