"use strict";

exports.__esModule = true;
exports.default = void 0;
var _keys2 = _interopRequireDefault(require("lodash/fp/keys"));
var _react = _interopRequireDefault(require("react"));
var _propTypes = _interopRequireDefault(require("prop-types"));
var _provider = _interopRequireDefault(require("../../atom/provider"));
var _progressBar = _interopRequireDefault(require("../../molecule/progress-bar"));
var _brandUploadBox = _interopRequireDefault(require("../../molecule/brand-upload-box"));
var _brandDownloadBox = _interopRequireDefault(require("../../molecule/brand-download-box"));
var _style = _interopRequireDefault(require("./style.css"));
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
const notificationStyle = {
  warning: _style.default.warning,
  error: _style.default.error,
  success: _style.default.success
};
const BrandUpload = props => {
  const {
    title = '',
    download,
    oneLoginTokens,
    upload,
    progress,
    notifications
  } = props;
  const notificationsItems = notifications.map((notif, index) => /*#__PURE__*/_react.default.createElement("div", {
    className: notificationStyle[notif.type],
    key: index
  }, /*#__PURE__*/_react.default.createElement("span", null, notif.message)));
  const oneLoginTokensView = oneLoginTokens ? /*#__PURE__*/_react.default.createElement("div", null, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.title
  }, /*#__PURE__*/_react.default.createElement("h3", null, oneLoginTokens.title, " ")), oneLoginTokens.download ? /*#__PURE__*/_react.default.createElement(_brandDownloadBox.default, oneLoginTokens.download) : null) : null;
  return /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.wrapper
  }, oneLoginTokensView, /*#__PURE__*/_react.default.createElement("div", {
    className: _style.default.title
  }, /*#__PURE__*/_react.default.createElement("h3", null, title)), download ? /*#__PURE__*/_react.default.createElement(_brandDownloadBox.default, download) : null, /*#__PURE__*/_react.default.createElement(_brandUploadBox.default, upload), progress ? /*#__PURE__*/_react.default.createElement(_progressBar.default, _extends({}, progress, {
    className: _style.default.progress
  })) : null, /*#__PURE__*/_react.default.createElement("ul", {
    className: _style.default.notifications
  }, notificationsItems));
};
BrandUpload.contextTypes = {
  skin: _provider.default.childContextTypes.skin
};
BrandUpload.propTypes = process.env.NODE_ENV !== "production" ? {
  title: _propTypes.default.string,
  download: _propTypes.default.shape(_brandDownloadBox.default.propTypes),
  oneLoginTokens: _propTypes.default.shape({
    title: _propTypes.default.string,
    download: _propTypes.default.shape(_brandDownloadBox.default.propTypes)
  }),
  progress: _propTypes.default.shape({
    value: _propTypes.default.number.isRequired,
    max: _propTypes.default.number.isRequired,
    desc: _propTypes.default.string
  }),
  upload: _propTypes.default.shape(_brandUploadBox.default.propTypes).isRequired,
  notifications: _propTypes.default.arrayOf(_propTypes.default.shape({
    type: _propTypes.default.oneOf((0, _keys2.default)(notificationStyle)).isRequired,
    message: _propTypes.default.string.isRequired
  }))
} : {};
var _default = exports.default = BrandUpload;
//# sourceMappingURL=index.js.map