'use client';

// src/components/Stepper/use-stepper.ts
import * as React2 from "react";

// src/components/Stepper/context.tsx
import * as React from "react";
import { jsx } from "react/jsx-runtime";
var StepperContext = React.createContext({
  steps: [],
  activeStep: 0,
  initialStep: 0,
  nextStep: () => {
  },
  prevStep: () => {
  },
  resetSteps: () => {
  },
  setStep: () => {
  }
});

// src/components/Stepper/use-stepper.ts
function usePrevious(value) {
  const ref = React2.useRef();
  React2.useEffect(() => {
    ref.current = value;
  }, [value]);
  return ref.current;
}
function useStepper() {
  const context = React2.useContext(StepperContext);
  if (context === void 0) {
    throw new Error("useStepper must be used within a StepperProvider");
  }
  const { children, className, ...rest } = context;
  const isLastStep = context.activeStep === context.steps.length - 1;
  const hasCompletedAllSteps = context.activeStep === context.steps.length;
  const previousActiveStep = usePrevious(context.activeStep);
  const currentStep = context.steps[context.activeStep];
  const isOptionalStep = !!currentStep?.optional;
  const isDisabledStep = context.activeStep === 0;
  return {
    ...rest,
    isLastStep,
    hasCompletedAllSteps,
    isOptionalStep,
    isDisabledStep,
    currentStep,
    previousActiveStep
  };
}
export {
  useStepper
};
