import { jsxs as n, jsx as i } from "react/jsx-runtime";
import { useStepper as $ } from "./index-use-stepper.js";
import { mt6 as k, mb2 as q, dFlex as M, alignItemsCenter as A, justifyContentBetween as G } from "./index-general.module.js";
import { classNames as P } from "./index-classNames.js";
import { parseCssVariable as H } from "./index-css-variables-parser.js";
import { useScrollToTop as J } from "./index-scroll-to-top.js";
import { capitalizeFirstLetter as K } from "./index-string-helpers.js";
import { ModalBody as N } from "./index-ModalBody.js";
import { ModalFooter as F } from "./index-ModalFooter.js";
import { Render as f } from "./index-Render.js";
import { Text as Q } from "./index-Text.js";
import { useRef as U, useEffect as R } from "react";
import { useDispatch as W } from "react-redux";
import m from "./index-ModalStepper.module.scss.js";
import { ModalStepperSteps as X } from "./index-ModalStepperSteps.js";
const to = (s) => {
  var p, v, x, b, T, c, C, y;
  const {
    steps: j,
    activeStep: w,
    onStepChange: B,
    onStepChangeName: I,
    hidePagination: D = !1,
    padding: t,
    variant: V = "default",
    stepperStepsPosition: z = "left",
    scrollToTop: r,
    modalBodyMode: l,
    slice: a
  } = s;
  let {
    bgColor: d
  } = s;
  const {
    activeStepInStepper: h,
    currentStepOpts: o,
    innerVisibleSteps: g
  } = $(j, w, B, I);
  d = H(d);
  const E = J(), e = U(null), L = W();
  return R(() => {
    e.current && r && setTimeout(() => {
      E(e);
    }, 100);
  }, [e.current, r]), R(() => {
    a && a.setStep && o && L(a.setStep(o.name));
  }, [o]), V === "bottom" ? n("div", {
    children: [i(N, {
      innerRef: e,
      padding: t,
      mode: l,
      children: o == null ? void 0 : o.component
    }), n("div", {
      ref: e,
      className: P(M, G, A),
      children: [i("div", {
        style: {
          padding: "16px 32px 32px 32px"
        },
        className: m.bottomStepperSteps,
        children: n(Q, {
          color: "--n400",
          translate: !1,
          children: [h, "/", g.length]
        })
      }), i(f, {
        if: !!(o != null && o.footerOptions),
        children: i(F, {
          buttonsPosition: "end",
          ...o == null ? void 0 : o.footerOptions,
          positive: (p = o == null ? void 0 : o.footerOptions) == null ? void 0 : p.positive,
          negative: (v = o == null ? void 0 : o.footerOptions) == null ? void 0 : v.negative,
          padding: "16px 32px 32px 32px",
          buttonsShape: "round"
        })
      })]
    })]
  }) : n("div", {
    style: l === "fill" ? {
      display: "flex",
      flexDirection: "column",
      width: "100%",
      height: "100%",
      flex: 1
    } : {},
    children: [n(N, {
      innerRef: e,
      padding: t,
      bgColor: d,
      mode: l,
      children: [i(f, {
        if: !(o != null && o.hidePagination) && !D,
        children: i("div", {
          className: P(M, q, o != null && o.noMarginTop ? void 0 : k, o != null && o.padded ? m.padded : void 0, m[`stepperPosition${K(z ?? "")}`]),
          children: i(X, {
            activeIndex: h,
            stepsCount: g.length
          })
        })
      }), o == null ? void 0 : o.component]
    }), i(f, {
      if: ((x = o == null ? void 0 : o.footerOptions) == null ? void 0 : x.positive) !== null || ((b = o == null ? void 0 : o.footerOptions) == null ? void 0 : b.negative) !== null || ((T = o == null ? void 0 : o.footerOptions) == null ? void 0 : T.neutral) !== null,
      children: i(F, {
        buttonsPosition: "between",
        ...o == null ? void 0 : o.footerOptions,
        positive: (c = o == null ? void 0 : o.footerOptions) == null ? void 0 : c.positive,
        negative: (C = o == null ? void 0 : o.footerOptions) == null ? void 0 : C.negative,
        neutral: (y = o == null ? void 0 : o.footerOptions) == null ? void 0 : y.neutral
      })
    })]
  });
};
export {
  to as ModalStepper
};
