"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.EmbeddedSteps = void 0;
var _react = _interopRequireDefault(require("react"));
var _classnames = _interopRequireDefault(require("classnames"));
var _embeddedStep = require("./embedded-step");
var _jsxRuntime = require("react/jsx-runtime");
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
/** Conveys progress through numbers of steps
 * [CAPITALIZATION] Use sentence case for each step
 * @deprecated The component is deprecated, use Stepper instead
 */
const EmbeddedSteps = ({
  steps,
  currentStepKey,
  onClick = () => {},
  isDisabled,
  className
}) => {
  const currentStepIndex = steps.findIndex(step => step.stepKey === currentStepKey);
  const currentStep = steps.find(step => step.stepKey === currentStepKey);
  function isCompleted(step, index) {
    if (!currentStep) {
      return true;
    }
    return currentStep.markCompleted ? currentStep.markCompleted.includes(step.stepKey) : index < currentStepIndex;
  }
  return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
    className: (0, _classnames.default)('embedded-steps', {
      disabled: isDisabled
    }, className),
    "test-id": "embedded-steps",
    children: steps.map((step, index) => {
      return /*#__PURE__*/(0, _jsxRuntime.jsx)(_embeddedStep.EmbeddedStep, {
        name: step.stepName,
        stepKey: step.stepKey,
        active: index === currentStepIndex,
        completed: isCompleted(step, index),
        styling: step.stepStyle,
        onClick: () => !isDisabled && onClick(step.stepKey),
        isDisabled: isDisabled
      }, step.stepName);
    })
  });
};
exports.EmbeddedSteps = EmbeddedSteps;