const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_objectWithoutProperties = require("../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectWithoutProperties.js");
const require_index = require("../pisellLayout/index.js");
const require_classNames = require("./utils/classNames.js");
const require_footerPosition = require("./utils/footerPosition.js");
const require_ProcedureHeader = require("./components/ProcedureHeader.js");
const require_useStepManager = require("./hooks/useStepManager.js");
const require_ProcedureFooter = require("./components/ProcedureFooter.js");
const require_ProcedureBody = require("./components/ProcedureBody.js");
const require_useMobile = require("../../hooks/useMobile.js");
let react = require("react");
react = require_runtime.__toESM(react);
require("./PisellProcedure.less");
//#region src/components/PisellProcedure/PisellProcedure.tsx
const _excluded = [
	"className",
	"style",
	"mode",
	"showHeader",
	"showSidebar",
	"showFooter",
	"defaultCurrent",
	"onStepsChange",
	"headerProps",
	"bodyProps",
	"footerProps",
	"onClose",
	"onPrev",
	"onNext",
	"onFirstStepBack",
	"onBackConfirm",
	"onCloseConfirm",
	"__designMode",
	"__id"
];
/**
* PisellProcedure 流程容器组件
*
* @description 用于管理多步骤流程的复合容器组件，基于 PisellLayout 实现三段式布局
* @author Pisell Team
* @version 1.0.0
*
* @example
* // 使用 ref 调用组件方法
* const procedureRef = useRef<PisellProcedureRef>(null);
*
* // 跳转到下一步
* procedureRef.current?.goNext();
*
* // 获取当前步骤
* const currentStep = procedureRef.current?.getCurrentStep();
*/
const PisellProcedure = (0, react.forwardRef)((props, ref) => {
	const { className, style, mode = "page", showHeader = true, showSidebar = true, showFooter = true, defaultCurrent = 0, onStepsChange, headerProps, bodyProps, footerProps, onClose, onPrev, onNext, onFirstStepBack, onBackConfirm, onCloseConfirm, __designMode, __id } = props, other = require_objectWithoutProperties._objectWithoutProperties(props, _excluded);
	const isMobileDetected = require_useMobile.useMobile(744);
	const isMobile = mode === "modal" ? false : isMobileDetected;
	const { currentStep, goPrev, goNext, goToStep } = require_useStepManager.useStepManager({
		stepsProps: headerProps === null || headerProps === void 0 ? void 0 : headerProps.stepsProps,
		defaultCurrent,
		onPrev,
		onNext,
		onStepsChange
	});
	const [summaryModalOpen, setSummaryModalOpen] = (0, react.useState)(false);
	const openSummaryModal = (0, react.useCallback)(() => setSummaryModalOpen(true), []);
	const closeSummaryModal = (0, react.useCallback)(() => setSummaryModalOpen(false), []);
	(0, react.useImperativeHandle)(ref, () => ({
		goPrev: () => goPrev(),
		goNext: () => goNext(),
		goToStep: (step) => goToStep(step),
		getCurrentStep: () => currentStep,
		openSummaryModal,
		closeSummaryModal
	}), [
		goPrev,
		goNext,
		goToStep,
		currentStep,
		openSummaryModal,
		closeSummaryModal
	]);
	const footerPosition = (0, react.useMemo)(() => {
		if (isMobile && mode !== "modal") return "float-all";
		return (footerProps === null || footerProps === void 0 ? void 0 : footerProps.position) || "float-sidebar";
	}, [
		mode,
		isMobile,
		footerProps === null || footerProps === void 0 ? void 0 : footerProps.position
	]);
	const containerCls = (0, react.useMemo)(() => {
		return require_classNames.mergeClassNames("pisell-procedure", className, mode === "modal" && "pisell-procedure--modal", require_classNames.modifierClassName("pisell-procedure", `footer-${footerPosition}`));
	}, [
		className,
		mode,
		footerPosition
	]);
	const footerIsGlobal = require_footerPosition.isFooterGlobal(footerPosition);
	return /* @__PURE__ */ react.default.createElement("div", require_objectSpread2._objectSpread2({
		className: containerCls,
		style,
		"data-component": "pisell-procedure",
		"data-id": __id
	}, other), /* @__PURE__ */ react.default.createElement(require_index.default, null, showHeader && /* @__PURE__ */ react.default.createElement(require_ProcedureHeader.default, {
		headerProps,
		currentStep,
		goPrev,
		onClose,
		onFirstStepBack,
		onBackConfirm,
		onCloseConfirm,
		goToStep
	}), /* @__PURE__ */ react.default.createElement(require_ProcedureBody.default, {
		bodyProps,
		footerProps,
		footerPosition,
		showFooter: showFooter && !footerIsGlobal,
		showSidebar,
		summaryModalOpen,
		onOpenSummaryModal: openSummaryModal,
		onCloseSummaryModal: closeSummaryModal,
		goPrev,
		goNext,
		mode
	}), showFooter && footerIsGlobal && /* @__PURE__ */ react.default.createElement(require_ProcedureFooter.default, {
		footerProps,
		position: footerPosition,
		isGlobal: true,
		sidebarContent: bodyProps === null || bodyProps === void 0 ? void 0 : bodyProps.sidebarSlot,
		summaryModalOpen,
		onOpenSummaryModal: openSummaryModal,
		onCloseSummaryModal: closeSummaryModal,
		goPrev,
		goNext,
		mode
	})));
});
PisellProcedure.displayName = "PisellProcedure";
//#endregion
exports.default = PisellProcedure;
