"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;
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _react = _interopRequireWildcard(require("react"));
var _reactIntlNext = require("react-intl-next");
var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
var _compiled = require("@atlaskit/primitives/compiled");
var _useAnalyticsEvents2 = require("../../common/analytics/generated/use-analytics-events");
var _constants = require("../../constants");
var _messages = require("../../messages");
var _experiments = require("../../utils/experiments");
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); }
/**
 * This component is used in unauthorized views of a smart link.
 * It represents the main text that provides a user with information on how to connect their account
 */
var UnauthorisedViewContent = function UnauthorisedViewContent(_ref) {
  var providerName = _ref.providerName,
    isProductIntegrationSupported = _ref.isProductIntegrationSupported,
    _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'unauthorised-view-content' : _ref$testId;
  var _useAnalyticsEvents = (0, _useAnalyticsEvents2.useAnalyticsEvents)(),
    fireEvent = _useAnalyticsEvents.fireEvent;
  var handleLearnMoreClick = (0, _react.useCallback)(function () {
    fireEvent('ui.button.clicked.learnMore', {});
  }, [fireEvent]);
  var learnMoreMessage = isProductIntegrationSupported ? (0, _platformFeatureFlags.fg)('product-terminology-refresh') ? _messages.messages.learn_more_about_connecting_account_appify : _messages.messages.learn_more_about_connecting_account : _messages.messages.learn_more_about_smart_links;
  var unauthorizedAccountDescriptionMessage = (0, _experiments.isNewBlockcardUnauthorizedRefreshExperimentEnabled)() ? _messages.messages.learn_more_about_connecting_account_experiment_shorter : (0, _platformFeatureFlags.fg)('product-terminology-refresh') ? _messages.messages.connect_unauthorised_account_description_appify : _messages.messages.connect_unauthorised_account_description;
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, providerName ? /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, unauthorizedAccountDescriptionMessage, {
    values: {
      context: providerName
    }
  })) : /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, (0, _platformFeatureFlags.fg)('product-terminology-refresh') ? _messages.messages.connect_unauthorised_account_description_no_provider_appify : _messages.messages.connect_unauthorised_account_description_no_provider), (0, _experiments.isNewBlockcardUnauthorizedRefreshExperimentEnabled)() ? /*#__PURE__*/_react.default.createElement("br", null) : ' ', /*#__PURE__*/_react.default.createElement(_compiled.Anchor, {
    href: isProductIntegrationSupported ? _constants.CONTENT_URL_3P_ACCOUNT_AUTH : _constants.CONTENT_URL_SECURITY_AND_PERMISSIONS,
    target: "_blank",
    testId: "".concat(testId, "-learn-more"),
    onClick: handleLearnMoreClick
  }, /*#__PURE__*/_react.default.createElement(_reactIntlNext.FormattedMessage, learnMoreMessage)));
};
var _default = exports.default = UnauthorisedViewContent;