"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");

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

var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));

var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));

var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));

var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));

var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));

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

var _immutable = require("immutable");

var _reactImmutableProptypes = _interopRequireDefault(require("react-immutable-proptypes"));

var _lib = _interopRequireDefault(require("@instructure/ui-themeable/lib"));

var _theme = _interopRequireDefault(require("./theme"));

var _dec, _class, _class2, _temp;

var styles = {
  componentId: 'fvxaa',
  template: function template(theme) {
    return "\n\n.errors__styles__errors{align-items:flex-start;display:flex;flex-direction:column}\n\n.errors__styles__error{color:".concat(theme.errorColor || 'inherit', ";flex:1 1 auto;font-size:").concat(theme.errorFontSize || 'inherit', "}");
  },
  'errors': 'errors__styles__errors',
  'error': 'errors__styles__error'
};
var Errors = (_dec = (0, _lib.default)(_theme.default, styles), _dec(_class = (_temp = _class2 =
/*#__PURE__*/
function (_Component) {
  (0, _inherits2.default)(Errors, _Component);

  function Errors() {
    (0, _classCallCheck2.default)(this, Errors);
    return (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(Errors).apply(this, arguments));
  }

  (0, _createClass2.default)(Errors, [{
    key: "renderError",
    value: function renderError(errorText, i) {
      var key = "error_for_".concat(i);
      return _react.default.createElement("div", {
        className: styles.error,
        key: key
      }, errorText);
    }
  }, {
    key: "render",
    value: function render() {
      if (this.props.errorList.size === 0) {
        return null;
      }

      return _react.default.createElement("div", {
        className: styles.errors
      }, this.props.errorList.toArray().map(this.renderError));
    }
  }]);
  Errors.displayName = "Errors";
  return Errors;
}(_react.Component), _class2.propTypes = {
  errorList: _reactImmutableProptypes.default.list
}, _class2.defaultProps = {
  errorList: (0, _immutable.List)()
}, _temp)) || _class);
var _default = Errors;
exports.default = _default;