'use strict';

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

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _styledComponents = require('styled-components');

var _styledComponents2 = _interopRequireDefault(_styledComponents);

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

function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }

var BaseTextAreaInput = _styledComponents2.default.textarea.withConfig({
  displayName: 'TextAreaInput__BaseTextAreaInput'
})(['display:block;width:100%;padding:6px 12px;box-sizing:border-box;font-size:14px;color:', ';background-color:', ';background-image:none;outline-width:0;user-select:text;font-family:\'Montserrat\',Helvetica,sans-serif;border:1px solid ', ';&::-webkit-input-placeholder{color:', ';}'], function (props) {
  return props.theme['gray-5'];
}, function (props) {
  return props.theme['white'];
}, function (props) {
  return props.theme['gray-2'];
}, function (props) {
  return props.theme['gray-2'];
});

var selectBorderColor = function selectBorderColor(state) {
  switch (state) {
    case 'initial':
      return 'gray-2';
    case 'invalid':
      return 'error';
    case 'valid':
      return 'success';
    default:
      return 'gray-2';
  }
};

var TextAreaInput = function TextAreaInput(props) {
  var errorState = props.errorState,
      rest = _objectWithoutProperties(props, ['errorState']);

  var borderColor = selectBorderColor(errorState);
  return _react2.default.createElement(BaseTextAreaInput, _extends({ borderColor: borderColor }, rest));
};

exports.default = TextAreaInput;