"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports.getExportModalStepProps = getExportModalStepProps;
var _designSystem = require("@wix/design-system");
var _react = _interopRequireDefault(require("react"));
var _ExportStepConfig = require("./ExportStepConfig");
var _ExportStepProgress = require("./ExportStepProgress");
var _ExportStepError = require("./ExportStepError");
var _ExportStepCancel = require("./ExportStepCancel");
var _getExportModalErrorProps = require("./getExportModalErrorProps");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/ExportButton/getExportModalStepProps.tsx";
function getExportModalStepProps({
  state,
  renderError,
  exportModalFooter,
  exportModalTitle,
  exportToCSVMessage,
  onProgressModalTitle
}) {
  const {
    currentStep,
    translate: t
  } = state;
  if (currentStep === 'cancel') {
    return {
      title: t('cairo.export.cancelTheExport'),
      children: /*#__PURE__*/_react.default.createElement(_ExportStepCancel.ExportStepCancel, {
        state: state,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 42,
          columnNumber: 17
        }
      }),
      primaryButtonText: t('cairo.export.cancelTheExportConfirm'),
      secondaryButtonText: t('cairo.export.cancelTheExportGoBack'),
      secondaryButtonProps: {
        skin: 'destructive'
      },
      primaryButtonProps: {
        skin: 'destructive',
        disabled: false
      },
      primaryButtonOnClick: () => state.onCancelExportVerifyButtonClick(),
      secondaryButtonOnClick: state.onCancelExportGoBackButtonClick,
      closeButtonProps: {
        onClick: state.onCancelExportCloseButtonClick,
        autoFocus: true
      },
      onRequestClose: state.onCancelExportCloseButtonClick
    };
  }
  if (currentStep === 'config') {
    return {
      title: exportModalTitle || t('cairo.export.exportTypeQuestionTitle'),
      children: /*#__PURE__*/_react.default.createElement(_ExportStepConfig.ExportStepConfig, {
        state: state,
        exportToCSVMessage: exportToCSVMessage,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 58,
          columnNumber: 9
        }
      }),
      primaryButtonText: t('cairo.export.export'),
      primaryButtonOnClick: state.onExportToClick,
      secondaryButtonText: t('cairo.export.cancelButton'),
      secondaryButtonOnClick: state.onCancelClick,
      closeButtonProps: {
        onClick: state.onCloseClick,
        autoFocus: true
      },
      onRequestClose: state.onCloseClick,
      footnote: exportModalFooter ? /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        dataHook: "export-modal-footer-text",
        size: "small",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 70,
          columnNumber: 9
        }
      }, exportModalFooter == null ? void 0 : exportModalFooter.text) : null
    };
  }
  if (currentStep === 'error') {
    const modalProps = (0, _getExportModalErrorProps.getExportModalErrorProps)({
      state,
      renderError
    });
    return {
      title: t('cairo.export.exportFailed'),
      secondaryButtonText: t('cairo.export.cancelButton'),
      secondaryButtonOnClick: state.onFailedCancel,
      closeButtonProps: {
        onClick: state.onFailedClose,
        autoFocus: true
      },
      onRequestClose: state.onFailedClose,
      primaryButtonText: t('Got It'),
      primaryButtonOnClick: state.onFailedClose,
      ...modalProps,
      children: /*#__PURE__*/_react.default.createElement(_ExportStepError.ExportStepError, {
        state: state,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 89,
          columnNumber: 9
        }
      }, modalProps.children ?? /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
        direction: "vertical",
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 91,
          columnNumber: 13
        }
      }, /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
        widows: true,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 92,
          columnNumber: 15
        }
      }, t('cairo.export.serverErrorMessage')), /*#__PURE__*/_react.default.createElement(_designSystem.TextButton, {
        dataHook: "export-error-message-action",
        as: "a",
        onClick: state.onRetryExportToClick,
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 93,
          columnNumber: 15
        }
      }, t('cairo.export.tryAgain'))))
    };
  }

  // exporting
  return {
    title: onProgressModalTitle || t('cairo.export.exportingTitle'),
    children: /*#__PURE__*/_react.default.createElement(_ExportStepProgress.ExportStepProgress, {
      state: state,
      __self: this,
      __source: {
        fileName: _jsxFileName,
        lineNumber: 110,
        columnNumber: 15
      }
    }),
    primaryButtonText: t('cairo.export.exporting'),
    primaryButtonProps: {
      disabled: true
    },
    closeButtonProps: {
      onClick: state.onExportCloseAttemptClick,
      autoFocus: true
    },
    onRequestClose: state.onExportCloseAttemptClick,
    secondaryButtonText: t('cairo.export.cancelButton'),
    secondaryButtonOnClick: state.onExportSecondaryActionAttempt
  };
}
//# sourceMappingURL=getExportModalStepProps.js.map