import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["testId"];
import React, { useMemo } from 'react';
import WarningIcon from '@atlaskit/icon/core/status-warning';
import { messages } from '../../../messages';
import Text from '../../FlexibleCard/components/elements/common/base-text-element';
import { RetryAction } from '../actions/RetryAction';
import UnresolvedView from './unresolved-view';
import { withFlexibleUIBlockCardStyle } from './utils/withFlexibleUIBlockCardStyle';

/**
 * This view represents a Block Card with an 'Errored' status.
 *
 * @see SmartLinkStatus
 * @see FlexibleCardProps
 */
var ErroredView = function ErroredView(_ref) {
  var _ref$testId = _ref.testId,
    testId = _ref$testId === void 0 ? 'smart-block-errored-view' : _ref$testId,
    props = _objectWithoutProperties(_ref, _excluded);
  var actions = useMemo(function () {
    return props.onAuthorize ? [RetryAction(props.onAuthorize)] : [];
  }, [props.onAuthorize]);
  return /*#__PURE__*/React.createElement(UnresolvedView, _extends({}, props, {
    actions: actions,
    testId: testId
  }), /*#__PURE__*/React.createElement(WarningIcon, {
    label: "errored-warning-icon",
    color: "var(--ds-icon-warning, #E06C00)",
    testId: "".concat(testId, "-warning-icon")
  }), /*#__PURE__*/React.createElement(Text, {
    maxLines: 3,
    message: {
      descriptor: messages.could_not_load_link
    }
  }));
};
var _default_1 = withFlexibleUIBlockCardStyle(ErroredView);
export default _default_1;