import _extends from "@babel/runtime/helpers/extends";
import React from 'react';
import cx from 'classnames';
import theme from './theme.css';
import Box from '../box';
import ProgressStep from './ProgressStep';

var ProgressTracker = function ProgressTracker(_ref) {
  var _ref$color = _ref.color,
      color = _ref$color === void 0 ? 'mint' : _ref$color,
      children = _ref.children,
      _ref$currentStep = _ref.currentStep,
      currentStep = _ref$currentStep === void 0 ? 0 : _ref$currentStep,
      done = _ref.done,
      _ref$labelPosition = _ref.labelPosition,
      labelPosition = _ref$labelPosition === void 0 ? 'top' : _ref$labelPosition;
  var classNames = cx(theme['tracker'], theme[color], theme["tracker-".concat(labelPosition)]);
  return /*#__PURE__*/React.createElement(Box, {
    className: classNames
  }, React.Children.map(children, function (child, index) {
    var activeStep = Math.max(0, currentStep);
    var childProps = /*#__PURE__*/React.isValidElement(child) && child.props;
    return /*#__PURE__*/React.createElement(ProgressStep, _extends({
      active: done ? false : index === activeStep,
      completed: done || index < activeStep
    }, childProps));
  }));
};

ProgressTracker.ProgressStep = ProgressStep;
export default ProgressTracker;