"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.getExportModalErrorProps = getExportModalErrorProps;
var _designSystem = require("@wix/design-system");
var _bexCore = require("@wix/bex-core");
var _react = _interopRequireDefault(require("react"));
var _util = require("@wix/bex-core/util");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/ExportButton/getExportModalErrorProps.tsx";
function getExportModalErrorProps({
  renderError,
  state
}) {
  var _details$applicationE, _details$applicationE2, _resolvedError$action, _resolvedError$action2;
  const {
    exportStatus: {
      error: _error
    },
    translate: t,
    errorHandler
  } = state;
  const error = (0, _bexCore.isWixPatternsError)(_error) ? _error.originalException : _error;
  const details = (0, _util.isErrorDetailsHttpError)(error) ? error.response.data : null;
  const applicationErrorCode = details == null || (_details$applicationE = details.applicationError) == null ? void 0 : _details$applicationE.code;
  const applicationErrorData = details == null || (_details$applicationE2 = details.applicationError) == null ? void 0 : _details$applicationE2.data;
  if (!(0, _util.isHttpError)(error)) {
    return {};
  }
  if (applicationErrorCode === 'method_endpoint_permission_denied') {
    return {
      children: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        direction: "vertical",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 49,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        widows: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 50,
          columnNumber: 11
        }
      }, t('cairo.export.noPermissionsMessage')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
        dataHook: "export-error-message-action",
        as: "a",
        href: "https://support.wix.com/en/article/roles-permissions-overview",
        target: "_blank",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 51,
          columnNumber: 11
        }
      }, t('cairo.export.noPermissionsCTA')))
    };
  }
  if (applicationErrorCode === 'media_generate_signed_url' || applicationErrorCode === 'media_appender_completion' || applicationErrorCode === 'async_job_infra') {
    return {
      children: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        direction: "vertical",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 71,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        widows: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 72,
          columnNumber: 11
        }
      }, t('cairo.export.databaseIssueMessage')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
        dataHook: "export-error-message-action",
        as: "a",
        href: "https://www.wix.com/contact",
        target: "_blank",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 73,
          columnNumber: 11
        }
      }, t('cairo.error.contactSupport.cta')))
    };
  }
  if (applicationErrorCode === 'max_polling_stale_job') {
    return {
      children: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        direction: "vertical",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 89,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        widows: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 90,
          columnNumber: 11
        }
      }, t('cairo.export.overloadErrorMessage')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
        dataHook: "export-error-message-action",
        as: "a",
        onClick: state.onRetryExportToClick,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 91,
          columnNumber: 11
        }
      }, t('cairo.export.tryAgain')))
    };
  }
  if (applicationErrorCode === 'offline') {
    return {
      title: t('cairo.connection.error.title'),
      children: /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        widows: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 106,
          columnNumber: 17
        }
      }, t('cairo.export.offlineMessage'))
    };
  }
  if (applicationErrorCode === 'grpc_query_target_internal') {
    return {
      children: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        direction: "vertical",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 113,
          columnNumber: 9
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        widows: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 114,
          columnNumber: 11
        }
      }, t('cairo.export.serverErrorMessage')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
        dataHook: "export-error-message-action",
        as: "a",
        href: "https://www.wix.com/contact",
        target: "_blank",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 115,
          columnNumber: 11
        }
      }, t('cairo.error.contactSupport.cta'))),
      ...(renderError == null ? void 0 : renderError(applicationErrorData))
    };
  }
  const resolvedError = errorHandler.getResolvedError == null ? void 0 : errorHandler.getResolvedError(error);
  return {
    children: /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
      direction: "vertical",
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 133,
        columnNumber: 7
      }
    }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
      widows: true,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 134,
        columnNumber: 9
      }
    }, resolvedError == null ? void 0 : resolvedError.message), (resolvedError == null ? void 0 : resolvedError.action) && /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
      dataHook: "export-error-message-action",
      as: "a",
      onClick: resolvedError == null || (_resolvedError$action = resolvedError.action) == null ? void 0 : _resolvedError$action.onClick,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 136,
        columnNumber: 11
      }
    }, resolvedError == null || (_resolvedError$action2 = resolvedError.action) == null ? void 0 : _resolvedError$action2.text))
  };
}
//# sourceMappingURL=getExportModalErrorProps.js.map