'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);

var _ramda = require('ramda');

var _Colors = require('../Colors');

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 stretchAnimation = (0, _styledComponents.keyframes)(['0%,40%,100%{opacity:1;}20%{opacity:0;}']);
var Container = _styledComponents2.default.div.withConfig({
  displayName: 'FlatLoader__Container'
})(['display:flex;justify-content:space-around;width:', ';height:', ';text-align:center;font-size:10px;'], function (props) {
  return props.width;
}, function (props) {
  return props.height;
});
var Rectangle = _styledComponents2.default.div.withConfig({
  displayName: 'FlatLoader__Rectangle'
})(['display:inline-block;width:15%;height:100%;background-color:', ';animation:', ' 1.2s infinite ease-in-out;'], function (props) {
  return props.theme[props.color];
}, stretchAnimation);
var Rectangle1 = (0, _styledComponents2.default)(Rectangle).withConfig({
  displayName: 'FlatLoader__Rectangle1'
})(['animation-delay:-1.1s;']);
var Rectangle2 = (0, _styledComponents2.default)(Rectangle).withConfig({
  displayName: 'FlatLoader__Rectangle2'
})(['animation-delay:-1.0s;']);
var Rectangle3 = (0, _styledComponents2.default)(Rectangle).withConfig({
  displayName: 'FlatLoader__Rectangle3'
})(['animation-delay:-0.9s;']);
var Rectangle4 = (0, _styledComponents2.default)(Rectangle).withConfig({
  displayName: 'FlatLoader__Rectangle4'
})(['animation-delay:-0.8s;']);
var Rectangle5 = (0, _styledComponents2.default)(Rectangle).withConfig({
  displayName: 'FlatLoader__Rectangle5'
})(['animation-delay:-0.7s;']);

var FlatLoader = function FlatLoader(props) {
  var color = props.color,
      rest = _objectWithoutProperties(props, ['color']);

  return _react2.default.createElement(
    Container,
    rest,
    _react2.default.createElement(Rectangle1, { color: color }),
    _react2.default.createElement(Rectangle2, { color: color }),
    _react2.default.createElement(Rectangle3, { color: color }),
    _react2.default.createElement(Rectangle4, { color: color }),
    _react2.default.createElement(Rectangle5, { color: color })
  );
};

FlatLoader.propTypes = {
  width: _propTypes2.default.string.isRequired,
  height: _propTypes2.default.string.isRequired,
  color: _propTypes2.default.oneOf((0, _ramda.keysIn)((0, _Colors.Palette)()))
};

FlatLoader.defaultProps = {
  width: '50px',
  height: '30px',
  color: 'brand-secondary'
};

exports.default = FlatLoader;