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

var _Icons = require('../../Icons');

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

var Wrapper = _styledComponents2.default.div.withConfig({
  displayName: 'template__Wrapper'
})(['display:flex;flex-direction:column;justify-content:flex-start;align-items:center;width:100%;']);
var Content = _styledComponents2.default.div.withConfig({
  displayName: 'template__Content'
})(['position:relative;width:100%;min-height:', 'px;overflow-x:hidden;'], function (props) {
  return props.height;
});
var Slider = _styledComponents2.default.div.withConfig({
  displayName: 'template__Slider'
})(['position:absolute;display:flex;flex-direction:row;justify-content:center;align-items:center;top:0;left:', '%;width:', '%;min-height:auto;transition:all 0.4s ease-in-out;& > *{position:relative;width:100%;height:100%;}'], function (props) {
  return props.index * -100;
}, function (props) {
  return (props.total + 1) * 100;
});
var Controls = _styledComponents2.default.div.withConfig({
  displayName: 'template__Controls'
})(['position:relative;display:flex;flex-direction:row;justify-content:center;align-items:center;width:100%;height:40px;']);
var Control = _styledComponents2.default.div.withConfig({
  displayName: 'template__Control'
})(['display:flex;width:10px;height:10px;margin:0 10px;border-radius:5px;background-color:', ';cursor:pointer;z-index:'], function (props) {
  return props.active ? props.theme['brand-secondary'] : props.theme['gray-4'];
});
var Arrow = (0, _styledComponents2.default)(_Icons.Icon).attrs({
  name: 'down-arrow',
  size: '24px',
  weight: 700,
  color: 'gray-6'
}).withConfig({
  displayName: 'template__Arrow'
})(['position:absolute;top:50%;margin-top:-18px;left:', ';right:', ';transform:', ';cursor:pointer;z-index:1;&:hover{color:', '!important;}'], function (props) {
  return props.left ? '10px' : 'initial';
}, function (props) {
  return !props.left ? '10px' : 'initial';
}, function (props) {
  return props.left ? 'rotate(90deg)' : 'rotate(-90deg)';
}, (0, _Colors.Color)('brand-secondary'));

var Carousel = function Carousel(props) {
  var index = props.index,
      total = props.total,
      height = props.height,
      arrows = props.arrows,
      chips = props.chips,
      children = props.children,
      handleClick = props.handleClick,
      handlePrevious = props.handlePrevious,
      handleNext = props.handleNext;


  return _react2.default.createElement(
    Wrapper,
    null,
    _react2.default.createElement(
      Content,
      { height: height, total: total },
      arrows && _react2.default.createElement(Arrow, { left: true, onClick: handlePrevious }),
      _react2.default.createElement(
        Slider,
        { height: height, index: index, total: total },
        children
      ),
      arrows && _react2.default.createElement(Arrow, { onClick: handleNext })
    ),
    chips && _react2.default.createElement(
      Controls,
      null,
      (0, _ramda.range)(0, total + 1).map(function (value, arrayIndex) {
        return _react2.default.createElement(Control, { key: arrayIndex, onClick: function onClick() {
            return handleClick(value);
          }, active: index === value });
      })
    )
  );
};

Carousel.propTypes = {
  index: _propTypes2.default.number.isRequired,
  total: _propTypes2.default.number.isRequired,
  height: _propTypes2.default.number.isRequired,
  handleClick: _propTypes2.default.func.isRequired,
  arrows: _propTypes2.default.bool.isRequired,
  chips: _propTypes2.default.bool.isRequired
};

exports.default = Carousel;