'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});

var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');

var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);

var _createClass2 = require('babel-runtime/helpers/createClass');

var _createClass3 = _interopRequireDefault(_createClass2);

var _possibleConstructorReturn2 = require('babel-runtime/helpers/possibleConstructorReturn');

var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2);

var _inherits2 = require('babel-runtime/helpers/inherits');

var _inherits3 = _interopRequireDefault(_inherits2);

var _dec, _class, _class2, _temp;

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _immutable = require('immutable');

var _reactImmutableProptypes = require('react-immutable-proptypes');

var _reactImmutableProptypes2 = _interopRequireDefault(_reactImmutableProptypes);

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

var _lib2 = _interopRequireDefault(_lib);

var _theme = require('./theme');

var _theme2 = _interopRequireDefault(_theme);

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

var styles = {
  template: function template(theme) {
    return '/*  imported from styles.css  */\n\n.errors__styles__errors {\n  display: flex;\n  align-items: flex-start;\n  flex-direction: column;\n}\n\n.errors__styles__error {\n  font-size: ' + theme.errorFontSize + ';\n  color: ' + theme.errorColor + ';\n  flex: 1 1 auto;\n}\n';
  },
  'errors': 'errors__styles__errors',
  'error': 'errors__styles__error'
};
var Errors = (_dec = (0, _lib2.default)(_theme2.default, styles), _dec(_class = (_temp = _class2 = function (_Component) {
  (0, _inherits3.default)(Errors, _Component);

  function Errors() {
    (0, _classCallCheck3.default)(this, Errors);
    return (0, _possibleConstructorReturn3.default)(this, (Errors.__proto__ || Object.getPrototypeOf(Errors)).apply(this, arguments));
  }

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

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