"use strict";

exports.__esModule = true;
exports.default = void 0;
var _react = _interopRequireDefault(require("react"));
var _progressBar = _interopRequireDefault(require("../progress-bar"));
var _statusItem = _interopRequireDefault(require("../../atom/status-item"));
var _colors = require("../../variables/colors");
var _style = _interopRequireDefault(require("./style.css"));
var _types = require("./types");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
const {
  negative: cm_negative_100,
  cm_primary_blue,
  cm_positive_500
} = _colors.COLORS;
const STATUS = {
  inProgress: 'inProgress',
  fail: 'fail'
};
const renderStatusIcon = (status, progress) => {
  if (status === STATUS.inProgress) return /*#__PURE__*/_react.default.createElement("div", {
    role: "status",
    className: _style.default.progressText
  }, `${progress} %`);
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.statusItemWrapper
  }, /*#__PURE__*/_react.default.createElement(_statusItem.default, {
    icon: status === STATUS.fail ? 'invalid' : 'valid'
  }));
};
const resolveProgressBarColor = status => {
  switch (status) {
    case STATUS.fail:
      return cm_negative_100;
    case STATUS.inProgress:
      return cm_primary_blue;
    default:
      return cm_positive_500;
  }
};
const BulkProgressBar = props => {
  const {
    'data-name': dataName,
    status,
    progress
  } = props;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.container,
    "data-name": dataName
  }, /*#__PURE__*/_react.default.createElement(_progressBar.default, {
    className: _style.default.progressBar,
    value: progress,
    max: 100,
    steps: 0,
    style: {
      backgroundColor: resolveProgressBarColor(status),
      borderRadius: '10px'
    },
    displayInfo: false
  }), renderStatusIcon(status, progress));
};
BulkProgressBar.propTypes = process.env.NODE_ENV !== "production" ? _types.propTypes : {};
var _default = exports.default = BulkProgressBar;
//# sourceMappingURL=index.js.map