"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = void 0;

var _react = _interopRequireDefault(require("react"));

var _propTypes = _interopRequireDefault(require("prop-types"));

var _reactIntl = require("react-intl");

var _deprecated = _interopRequireDefault(require("../../../images/deprecated.svg"));

var _locked = _interopRequireDefault(require("../../../images/locked.svg"));

var _replicated = _interopRequireDefault(require("../../../images/replicated.svg"));

var _WorkflowStateIcon = _interopRequireDefault(require("../../../styles/cspace-ui/WorkflowStateIcon.css"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

const messages = (0, _reactIntl.defineMessages)({
  deprecated: {
    "id": "workflowStateIcon.deprecated",
    "defaultMessage": "Deprecated"
  },
  locked: {
    "id": "workflowStateIcon.locked",
    "defaultMessage": "Locked"
  },
  replicated: {
    "id": "workflowStateIcon.replicated",
    "defaultMessage": "Replicated"
  }
});
const images = {
  replicated: _replicated.default,
  deprecated: _deprecated.default,
  locked: _locked.default
};
const propTypes = {
  intl: _reactIntl.intlShape,
  value: _propTypes.default.string
};

function WorkflowStateIcon(props) {
  const {
    intl,
    value
  } = props;

  if (!value) {
    return null;
  }

  const icons = [];
  Object.keys(images).forEach(state => {
    if (value.includes(state)) {
      const src = images[state];
      const message = messages[state];
      const desc = message ? intl.formatMessage(message) : state;
      icons.push( /*#__PURE__*/_react.default.createElement("img", {
        key: state,
        alt: desc,
        src: src,
        title: desc
      }));
    }
  });

  if (icons.length === 0) {
    return null;
  }

  return /*#__PURE__*/_react.default.createElement("div", {
    className: _WorkflowStateIcon.default.common
  }, icons);
}

WorkflowStateIcon.propTypes = propTypes;

var _default = (0, _reactIntl.injectIntl)(WorkflowStateIcon);

exports.default = _default;