"use strict";

exports.__esModule = true;
exports.ImportStepProgress = void 0;
var _designSystem = require("@wix/design-system");
var _react = _interopRequireWildcard(require("react"));
var _mobxReactLite = require("mobx-react-lite");
var _jsxFileName = "/home/builduser/work/843658b9f44192f0/packages/cairo/dist/cjs/components/ImportButton/ImportStepProgress.tsx";
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (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 (const 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); }
function _ImportStepProgress({
  state
}) {
  const {
    processedCount,
    totalCount,
    isBackingUp,
    result,
    translate: t,
    importStatus,
    errorHandler
  } = state;
  const progress = totalCount > 0 ? Math.min(100, Math.round(processedCount / totalCount * 100)) : 0;
  const hasFailures = result != null && result.failed > 0;
  const errorMessage = (0, _react.useMemo)(() => {
    var _errorHandler$getReso;
    return importStatus.error ? errorHandler.getResolvedError == null || (_errorHandler$getReso = errorHandler.getResolvedError(importStatus.error)) == null ? void 0 : _errorHandler$getReso.message : null;
  }, [importStatus.error, errorHandler]);
  return /*#__PURE__*/_react.default.createElement(_designSystem.Box, {
    direction: "vertical",
    gap: "SP2",
    width: "100%",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 36,
      columnNumber: 5
    }
  }, /*#__PURE__*/_react.default.createElement(_designSystem.LinearProgressBar, {
    value: progress,
    showProgressIndication: true,
    dataHook: "import-progress-bar",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 37,
      columnNumber: 7
    }
  }), /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    size: "small",
    dataHook: "import-progress-label",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 42,
      columnNumber: 7
    }
  }, isBackingUp && !errorMessage ? t('cairo.import.backupDescription') : t('cairo.import.progressLabel', {
    processed: processedCount,
    total: totalCount
  })), hasFailures && /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    size: "small",
    skin: "error",
    dataHook: "import-partial-error",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 51,
      columnNumber: 9
    }
  }, t('cairo.import.partialSuccess', {
    succeeded: result.succeeded,
    failed: result.failed
  })), errorMessage && /*#__PURE__*/_react.default.createElement(_designSystem.Text, {
    size: "small",
    skin: "error",
    dataHook: "import-error-message",
    __self: this,
    __source: {
      fileName: _jsxFileName,
      lineNumber: 59,
      columnNumber: 9
    }
  }, errorMessage));
}
const ImportStepProgress = exports.ImportStepProgress = (0, _mobxReactLite.observer)(_ImportStepProgress);
//# sourceMappingURL=ImportStepProgress.js.map