"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Steps = void 0;
var _react = _interopRequireWildcard(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _Styles = require("./Styles");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
var Steps = exports.Steps = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
  var numberOfSteps = _ref.numberOfSteps,
    activeStep = _ref.activeStep,
    _ref$progressive = _ref.progressive,
    progressive = _ref$progressive === void 0 ? false : _ref$progressive,
    wrapperClassName = _ref.wrapperClassName;
  var steps = (0, _react.useMemo)(function () {
    // fastest way to generate an array of N numbers
    var a = [];
    var b = numberOfSteps;
    while (b--) {
      a[b] = b + 1;
    }
    return a;
  }, [numberOfSteps]);
  var activeSteps = (0, _react.useMemo)(function () {
    if (!progressive) {
      return [activeStep];
    }
    return steps.filter(function (step) {
      return step <= activeStep;
    });
  }, [activeStep, progressive, steps]);
  return /*#__PURE__*/_react.default.createElement(_Styles.StyledSteps, {
    className: (0, _classnames.default)("c-steps-wrapper", wrapperClassName),
    ref: ref
  }, steps.map(function (step) {
    return /*#__PURE__*/_react.default.createElement(_Styles.StyledStep, {
      key: "step-".concat(step),
      $isActiveStep: activeSteps.indexOf(step) > -1
    });
  }));
});
Steps.displayName = "Steps";
//# sourceMappingURL=Steps.js.map