import { jsx as y } from "react/jsx-runtime";
import { Children as l, useId as I, isValidElement as N, cloneElement as b } from "react";
import { c as w } from "../../index-BtlgVD4m.js";
import { StepperMode as m } from "./types/StepperMode.js";
import V from "../box/Box.js";
import h from "./utils/isValidStepperStep.js";
import z from "./utils/getStepperStepStatus.js";
import "./components/stepper-step/StepperStep.js";
import "./types/StepperStepStatus.js";
const C = ({
  type: o = "horizontal",
  size: c = "sm",
  children: s,
  activeSteps: r,
  completedSteps: u,
  errorSteps: d,
  warningSteps: f,
  onClick: n,
  mode: i = "display"
}) => {
  const S = l.toArray(s).length, g = w(
    "w-full",
    o === "horizontal" && "flex items-center",
    o === "vertical" && "grid grid-cols-1 items-start gap-[var(--spacing-2)]",
    o === "large" && "grid grid-cols-1 w-full "
  ), v = I();
  if (i === m.NAVIGATION) {
    if (r == null)
      return console.error("Error: activeSteps must be provided in navigation mode of Stepper component."), null;
    if (Array.isArray(r))
      return console.error("Error: activeSteps should be a single number in navigation mode of Stepper component."), null;
    n || console.warn("Warning: onClick handler should be provided in navigation mode of Stepper component to enable step navigation.");
  }
  return /* @__PURE__ */ y(V, { className: g, children: l.map(s, (t, e) => {
    if (!N(t))
      return console.error("Error: Invalid child in Stepper. Expected a React element."), null;
    if (!h(t)) {
      const p = t == null ? void 0 : t.type;
      return console.error(
        `Error: Invalid child component in Stepper: Expected StepperStep, but received ${(p == null ? void 0 : p.displayName) || "unknown component"}`
      ), null;
    }
    const a = t, A = z(e, r, u, d, f), E = Array.isArray(r) && r.includes(e) || e === r;
    return b(a, {
      ...a.props,
      count: e + 1,
      key: `${v}-stepper-step-${e}`,
      isLastStep: e === S - 1,
      stepperType: o,
      stepperSize: c,
      status: A,
      isContentActive: E,
      // Pass onClick from parent if provided
      onClick: n ? () => n(e) : void 0,
      isNavigable: i === m.NAVIGATION
    });
  }) });
};
C.displayName = "Stepper";
export {
  C as default
};
//# sourceMappingURL=Stepper.js.map
