'use strict';

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

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

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

var _styledComponents2 = _interopRequireDefault(_styledComponents);

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

var Container = _styledComponents2.default.div.withConfig({
  displayName: 'PasswordGauge__Container'
})(['display:flex;justify-content:flex-start;align-items:center;position:absolute;width:100%;height:3px;bottom:0;left:0;']);
var Bar = _styledComponents2.default.div.withConfig({
  displayName: 'PasswordGauge__Bar'
})(['display:inline-flex;width:20%;height:100%;box-sizing:border-box;background-color:', ';'], function (props) {
  return props.theme[props.color];
});

var selectColor = function selectColor(score) {
  switch (score) {
    case 1:
      return 'error';
    case 2:
      return 'red';
    case 3:
      return 'brand-yellow-lighter';
    case 4:
      return 'brand-yellow';
    case 5:
      return 'success';
    default:
      return 'transparent';
  }
};

var PasswordGauge = function PasswordGauge(props) {
  var score = props.score;

  var color = selectColor(score);

  return _react2.default.createElement(
    Container,
    null,
    score > 0 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'transparent' }),
    score > 1 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'transparent' }),
    score > 2 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'transparent' }),
    score > 3 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'transparent' }),
    score > 4 ? _react2.default.createElement(Bar, { color: color }) : _react2.default.createElement(Bar, { color: 'transparent' })
  );
};

PasswordGauge.propTypes = {
  score: _propTypes2.default.oneOf([1, 2, 3, 4, 5]).isRequired
};

PasswordGauge.defaultProps = {
  score: 0
};

exports.default = PasswordGauge;