"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.InlineCardResolvedView = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
var _HoverCard = require("../../HoverCard");
var _inlineLozenge = _interopRequireDefault(require("../common/inline-lozenge"));
var _Frame = require("../Frame");
var _IconAndTitleLayout = require("../IconAndTitleLayout");
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2.default)(o), (0, _possibleConstructorReturn2.default)(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2.default)(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
var InlineCardResolvedView = exports.InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
  function InlineCardResolvedView() {
    (0, _classCallCheck2.default)(this, InlineCardResolvedView);
    return _callSuper(this, InlineCardResolvedView, arguments);
  }
  (0, _inherits2.default)(InlineCardResolvedView, _React$Component);
  return (0, _createClass2.default)(InlineCardResolvedView, [{
    key: "renderLozenge",
    value: function renderLozenge() {
      var _lozenge$style, _lozenge$style2;
      var lozenge = this.props.lozenge;
      if (!lozenge) {
        return null;
      }
      var appearance = lozenge.appearance || 'default';
      return /*#__PURE__*/_react.default.createElement(_inlineLozenge.default, {
        testId: "inline-card-resolved-view-lozenge",
        appearance: appearance,
        style: {
          backgroundColor: lozenge === null || lozenge === void 0 || (_lozenge$style = lozenge.style) === null || _lozenge$style === void 0 ? void 0 : _lozenge$style.backgroundColor,
          color: lozenge === null || lozenge === void 0 || (_lozenge$style2 = lozenge.style) === null || _lozenge$style2 === void 0 ? void 0 : _lozenge$style2.color
        },
        isBold: (0, _platformFeatureFlags.fg)('platform-component-visual-refresh') ? lozenge.isBold !== false : lozenge.isBold
      }, lozenge.text);
    }
  }, {
    key: "render",
    value: function render() {
      var _this$props = this.props,
        id = _this$props.id,
        _this$props$title = _this$props.title,
        title = _this$props$title === void 0 ? '' : _this$props$title,
        isSelected = _this$props.isSelected,
        isHovered = _this$props.isHovered,
        onClick = _this$props.onClick,
        icon = _this$props.icon,
        link = _this$props.link,
        _this$props$testId = _this$props.testId,
        testId = _this$props$testId === void 0 ? 'inline-card-resolved-view' : _this$props$testId,
        titleTextColor = _this$props.titleTextColor,
        titlePrefix = _this$props.titlePrefix,
        _this$props$showHover = _this$props.showHoverPreview,
        showHoverPreview = _this$props$showHover === void 0 ? false : _this$props$showHover,
        hoverPreviewOptions = _this$props.hoverPreviewOptions,
        actionOptions = _this$props.actionOptions,
        truncateInline = _this$props.truncateInline,
        type = _this$props.type,
        hideIconLoadingSkeleton = _this$props.hideIconLoadingSkeleton;
      var inlineCardResolvedView = /*#__PURE__*/_react.default.createElement(_Frame.Frame, {
        testId: testId,
        link: link,
        isSelected: isSelected,
        isHovered: isHovered,
        onClick: onClick,
        truncateInline: truncateInline
      }, /*#__PURE__*/_react.default.createElement(_IconAndTitleLayout.IconAndTitleLayout, {
        emoji: titlePrefix,
        icon: icon,
        title: title,
        titleTextColor: titleTextColor,
        type: type,
        hideIconLoadingSkeleton: (0, _expValEquals.expValEquals)('platform_editor_smart_card_otp', 'isEnabled', true) && hideIconLoadingSkeleton
      }), this.renderLozenge());
      if (showHoverPreview && link) {
        return /*#__PURE__*/_react.default.createElement(_HoverCard.HoverCard, {
          id: id,
          url: link,
          actionOptions: actionOptions,
          hoverPreviewOptions: hoverPreviewOptions
        }, inlineCardResolvedView);
      }
      return inlineCardResolvedView;
    }
  }]);
}(_react.default.Component);