/* index.tsx generated by @compiled/babel-plugin v0.38.1 */
"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;
require("./index.compiled.css");
var _react = _interopRequireWildcard(require("react"));
var React = _react;
var _runtime = require("@compiled/react/runtime");
var _reactIntlNext = require("react-intl-next");
var _dropdownMenu = require("@atlaskit/dropdown-menu");
var _statusError = _interopRequireDefault(require("@atlaskit/icon/core/status-error"));
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _compiled = require("@atlaskit/primitives/compiled");
var _colors = require("@atlaskit/theme/colors");
var _useAnalyticsEvents2 = require("../../../../../../../../common/analytics/generated/use-analytics-events");
var _messages = require("../../../../../../../../messages");
var _useInvokeClientAction = _interopRequireDefault(require("../../../../../../../../state/hooks/use-invoke-client-action"));
var _utils = require("../../../../../utils");
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 MAX_LINE_NUMBER = 8;
var styles = {
  contentStyles: "_zulpu2gc _11c81d4k _1reo15vq _18m915vq _1e0c1txw _1ul9idpf _2lx2vrvc _19pkv77o _4cvr1y6m _pqmefhey _102efhey _ngc01fxt _1t4p1fxt",
  linkStyles: "_zulpu2gc _1reo15vq _18m915vq _11c8fhey _1e0c1txw _1ul9idpf _2lx2vrvc _4cvr1h6o _80omtlke _19pku2gc _18u0xy5q _otyrv77o",
  textStylesBase: "_11c81d4k _1reo15vq _18m915vq _o5724jg8 _1e0ccj1k _1bto1l2s _1nmz1hna _sudp1e54",
  dropdownItemGroupStyles: "_14hp1wdt _6pup1kw7 _1eo073ad",
  openIssueInJiraStyles: "_11c8fhey _bfhk1j28 _1bah1e5h _1e0c1kw7 _syaz13af _ca0qze3t _u5f3ze3t _n3tdze3t _19bvze3t _9oik1r31 _1bnx8stv _jf4cnqa1 _30l312zz"
};
var LozengeActionError = function LozengeActionError(_ref) {
  var errorMessage = _ref.errorMessage,
    testId = _ref.testId,
    _ref$maxLineNumber = _ref.maxLineNumber,
    maxLineNumber = _ref$maxLineNumber === void 0 ? MAX_LINE_NUMBER : _ref$maxLineNumber,
    invokePreviewAction = _ref.invokePreviewAction;
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
    fireEvent = _useAnalyticsEvents.fireEvent;
  var invoke = (0, _useInvokeClientAction.default)({});
  var isPreviewAvailable = invokePreviewAction !== undefined;
  var handlePreviewOpen = (0, _react.useCallback)(function () {
    if (isPreviewAvailable) {
      fireEvent('ui.button.clicked.smartLinkStatusOpenPreview', {});
      if (invokePreviewAction) {
        invoke(invokePreviewAction);
      }
    }
  }, [isPreviewAvailable, invoke, invokePreviewAction, fireEvent]);
  var dynamicCss = null;
  var content = (0, _react.useMemo)(function () {
    return /*#__PURE__*/React.createElement(_react.Fragment, null, /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([styles.contentStyles])
    }, /*#__PURE__*/React.createElement(_statusError.default, {
      testId: "".concat(testId, "-icon"),
      color: "var(--ds-icon-danger, ".concat(_colors.R500, ")"),
      label: 'error',
      spacing: "spacious"
    }), /*#__PURE__*/React.createElement("span", {
      "data-testid": "".concat(testId, "-error-message"),
      className: (0, _runtime.ax)([styles.textStylesBase, "_1yyj1n6p _102k1hw0"]),
      style: {
        "--_t4prqe": (0, _runtime.ix)(maxLineNumber),
        "--_hm3wc5": (0, _runtime.ix)("calc(".concat(maxLineNumber, " * 1rem)"))
      }
    }, typeof errorMessage === 'string' ? errorMessage : (0, _utils.getFormattedMessage)(errorMessage))), isPreviewAvailable ? /*#__PURE__*/React.createElement("div", {
      className: (0, _runtime.ax)([styles.linkStyles])
    }, /*#__PURE__*/React.createElement(_compiled.Pressable, {
      testId: "".concat(testId, "-open-embed"),
      onClick: handlePreviewOpen,
      xcss: styles.openIssueInJiraStyles
    }, (0, _platformFeatureFlags.fg)('confluence-issue-terminology-refresh') ? /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, _messages.messages.open_issue_in_jiraIssueTermRefresh) : /*#__PURE__*/React.createElement(_reactIntlNext.FormattedMessage, _messages.messages.open_issue_in_jira))) : null);
  }, [errorMessage, handlePreviewOpen, isPreviewAvailable, testId, dynamicCss]);
  return /*#__PURE__*/React.createElement("span", {
    "data-testid": "".concat(testId, "-error-item-group"),
    className: (0, _runtime.ax)([styles.dropdownItemGroupStyles])
  }, /*#__PURE__*/React.createElement(_dropdownMenu.DropdownItemGroup, null, /*#__PURE__*/React.createElement(_dropdownMenu.DropdownItem, {
    testId: "".concat(testId, "-error")
  }, content)));
};
var _default = exports.default = LozengeActionError;