const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let _pisell_materials = require("@pisell/materials");
require("./index.less");
//#region src/components/stepController/components/Header/index.tsx
const Header = ({ steps, currentStepIndex, style, onBack, onClose, confirmCloseProps }) => {
	var _steps$currentStepInd;
	const [open, setOpen] = (0, react.useState)(false);
	/**
	* @title: 点击关闭
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-14 22:41
	*/
	const handleClose = () => {
		if (confirmCloseProps === null || confirmCloseProps === void 0 ? void 0 : confirmCloseProps.isConfirmClose) setOpen(true);
		else onClose === null || onClose === void 0 || onClose();
	};
	/**
	* @title: 点击退出
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-02-10 17:46
	*/
	const handleOk = () => {
		setOpen(false);
		onClose === null || onClose === void 0 || onClose();
	};
	/**
	* @title: 返回上一步
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-06-12 16:44
	*/
	const handleBack = () => {
		if (!steps) return;
		if (currentStepIndex > 0) {
			const prevKey = steps[currentStepIndex - 1].key;
			onBack === null || onBack === void 0 || onBack(prevKey);
		}
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellHeaderProgressBar, {
		className: "pisell-step-controller-header",
		style,
		stepText: _pisell_utils.locales.getText("pisell2.step.controller.step")(currentStepIndex + 1),
		title: steps === null || steps === void 0 || (_steps$currentStepInd = steps[currentStepIndex]) === null || _steps$currentStepInd === void 0 ? void 0 : _steps$currentStepInd.description,
		showClose: true,
		onBack: handleBack,
		onClose: handleClose,
		enableBorder: true,
		borderColor: "#EAECF0",
		showBack: currentStepIndex > 0 || false
	}), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal.Information, {
		open,
		title: (confirmCloseProps === null || confirmCloseProps === void 0 ? void 0 : confirmCloseProps.title) || "",
		describe: (confirmCloseProps === null || confirmCloseProps === void 0 ? void 0 : confirmCloseProps.content) || "",
		okText: (confirmCloseProps === null || confirmCloseProps === void 0 ? void 0 : confirmCloseProps.okText) || "",
		cancelText: (confirmCloseProps === null || confirmCloseProps === void 0 ? void 0 : confirmCloseProps.cancelText) || "",
		closable: true,
		okButtonProps: { style: { backgroundColor: "#D92D20" } },
		onCancel: () => {
			setOpen(false);
		},
		onOk: () => handleOk()
	}));
};
//#endregion
exports.default = Header;
