import useEngineContext from "../../hooks/useEngineContext.js";
import useWindowSize from "../../hooks/useWindowSize.js";
import Header from "./components/Header/index.js";
import Footer from "./components/Footer/index.js";
import Content from "./components/Content/index.js";
import locales_default from "./locales.js";
import React, { useMemo } from "react";
import { locales } from "@pisell/utils";
import { usePisellConfig } from "@pisell/materials";
import classNames from "classnames";
import "./index.less";
//#region src/components/stepController/index.tsx
const StepController = ({ steps, currentStep, children, onBack, confirmCloseProps, showFooter, footerContent, onClose }) => {
	var _context$engine;
	const context = useEngineContext();
	locales.init(locales_default, (context === null || context === void 0 || (_context$engine = context.engine) === null || _context$engine === void 0 || (_context$engine = _context$engine.props) === null || _context$engine === void 0 ? void 0 : _context$engine.locale) || "en");
	useWindowSize({ debounceMs: 200 });
	/**
	* @title: 是否是移动端
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-06-12 15:56
	*/
	const isMobile = useMemo(() => {
		const config = usePisellConfig();
		return ((config === null || config === void 0 ? void 0 : config.platform) || "h5") === "h5";
	}, []);
	const currentStepIndex = useMemo(() => {
		return (steps === null || steps === void 0 ? void 0 : steps.findIndex((step) => step.key === currentStep)) || 0;
	}, [steps, currentStep]);
	return /* @__PURE__ */ React.createElement("div", { className: classNames("pisell-step-controller", { "pisell-step-controller-mobile": isMobile }) }, /* @__PURE__ */ React.createElement(Header, {
		steps,
		currentStepIndex,
		confirmCloseProps,
		onBack,
		onClose
	}), /* @__PURE__ */ React.createElement(Content, { children }), showFooter && footerContent ? /* @__PURE__ */ React.createElement(Footer, {
		children: footerContent,
		isMobile
	}) : null);
};
//#endregion
export { StepController as default };
