import React from 'react';
import { componentWithFG } from '@atlaskit/platform-feature-flags-react';
import useInlineActionNudgeExperiment from '../../../state/hooks/use-inline-action-nudge-experiment';
import { HoverCard } from '../../HoverCard';
import { RovoActionsCta } from '../common/rovo-actions-cta';
import { Frame } from '../Frame';
import { IconAndTitleLayout } from '../IconAndTitleLayout';
import { renderLozenge } from './renderLozenge';
export function InlineCardResolvedViewBase(_ref) {
  var id = _ref.id,
    _ref$title = _ref.title,
    title = _ref$title === void 0 ? '' : _ref$title,
    isSelected = _ref.isSelected,
    isHovered = _ref.isHovered,
    onClick = _ref.onClick,
    onAuxClick = _ref.onAuxClick,
    onContextMenu = _ref.onContextMenu,
    icon = _ref.icon,
    link = _ref.link,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'inline-card-resolved-view' : _ref$testId,
    titleTextColor = _ref.titleTextColor,
    titlePrefix = _ref.titlePrefix,
    _ref$showHoverPreview = _ref.showHoverPreview,
    showHoverPreview = _ref$showHoverPreview === void 0 ? false : _ref$showHoverPreview,
    hoverPreviewOptions = _ref.hoverPreviewOptions,
    actionOptions = _ref.actionOptions,
    truncateInline = _ref.truncateInline,
    type = _ref.type,
    hideIconLoadingSkeleton = _ref.hideIconLoadingSkeleton,
    lozenge = _ref.lozenge;
  var frame = /*#__PURE__*/React.createElement(Frame, {
    testId: testId,
    link: link,
    isSelected: isSelected,
    isHovered: isHovered,
    onClick: onClick,
    onAuxClick: onAuxClick,
    onContextMenu: onContextMenu,
    truncateInline: truncateInline
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), renderLozenge(lozenge));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/React.createElement(HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
export function InlineCardResolvedViewFunctionalWithRovoActions(_ref2) {
  var id = _ref2.id,
    _ref2$title = _ref2.title,
    title = _ref2$title === void 0 ? '' : _ref2$title,
    isSelected = _ref2.isSelected,
    isHovered = _ref2.isHovered,
    onClick = _ref2.onClick,
    onAuxClick = _ref2.onAuxClick,
    onContextMenu = _ref2.onContextMenu,
    icon = _ref2.icon,
    link = _ref2.link,
    _ref2$testId = _ref2.testId,
    testId = _ref2$testId === void 0 ? 'inline-card-resolved-view' : _ref2$testId,
    titleTextColor = _ref2.titleTextColor,
    titlePrefix = _ref2.titlePrefix,
    _ref2$showHoverPrevie = _ref2.showHoverPreview,
    showHoverPreview = _ref2$showHoverPrevie === void 0 ? false : _ref2$showHoverPrevie,
    hoverPreviewOptions = _ref2.hoverPreviewOptions,
    actionOptions = _ref2.actionOptions,
    truncateInline = _ref2.truncateInline,
    type = _ref2.type,
    hideIconLoadingSkeleton = _ref2.hideIconLoadingSkeleton,
    lozenge = _ref2.lozenge;
  var _useInlineActionNudge = useInlineActionNudgeExperiment(link, showHoverPreview, actionOptions),
    isEnabled = _useInlineActionNudge.isEnabled;

  // TODO https://hello.jira.atlassian.cloud/browse/NAVX-4436: fire analytics with cohort
  var frame = /*#__PURE__*/React.createElement(Frame, {
    testId: testId,
    link: link,
    isSelected: isSelected,
    isHovered: isHovered,
    onClick: onClick,
    onAuxClick: onAuxClick,
    onContextMenu: onContextMenu,
    truncateInline: truncateInline
  }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
    emoji: titlePrefix,
    icon: icon,
    title: title,
    titleTextColor: titleTextColor,
    type: type,
    hideIconLoadingSkeleton: hideIconLoadingSkeleton
  }), renderLozenge(lozenge), isEnabled && /*#__PURE__*/React.createElement(RovoActionsCta, {
    testId: "".concat(testId, "-rovo-actions-cta")
  }));
  if (!showHoverPreview || !link) {
    return frame;
  }
  return /*#__PURE__*/React.createElement(HoverCard, {
    id: id,
    url: link,
    actionOptions: actionOptions,
    hoverPreviewOptions: hoverPreviewOptions
  }, frame);
}
export var InlineCardResolvedViewFunctional = componentWithFG('rovogrowth-640-inline-action-nudge-fg', InlineCardResolvedViewFunctionalWithRovoActions, InlineCardResolvedViewBase);