const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_useEngineContext = require("../../../../hooks/useEngineContext.js");
const require_index = require("../../../../businessModel/SalesModel/Sales/index.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/eventBooking/components/progressBar/index.tsx
const ProgressBar = ({ title, description, showClose = true, isConfirmClose = true, showStep = true, showBack = true, style, onBack, onClose }) => {
	var _context$appHelper;
	const [open, setOpen] = (0, react.useState)(false);
	const { removeSessionStorage } = require_index.useSales();
	const { interaction } = ((_context$appHelper = require_useEngineContext.default().appHelper) === null || _context$appHelper === void 0 ? void 0 : _context$appHelper.utils) || {};
	/**
	* @title: 点击关闭
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-01-14 22:41
	*/
	const handleClose = () => {
		if (isConfirmClose) setOpen(true);
		else onClose === null || onClose === void 0 || onClose();
	};
	/**
	* @title: 点击退出
	* @description:
	* @return {*}
	* @Author: WangHan
	* @Date: 2025-02-10 17:46
	*/
	const handleOk = () => {
		var _interaction$utils, _interaction$utils$is;
		if (interaction === null || interaction === void 0 || (_interaction$utils = interaction.utils) === null || _interaction$utils === void 0 || (_interaction$utils$is = _interaction$utils.isAppEnv) === null || _interaction$utils$is === void 0 ? void 0 : _interaction$utils$is.call(_interaction$utils)) {
			const url = window.location.href;
			console.log(url, url.includes("isByTabbar"), "___url");
			if (url.includes("isByTabbar")) {
				removeSessionStorage === null || removeSessionStorage === void 0 || removeSessionStorage();
				const urlParams = new URLSearchParams(window.location.search);
				urlParams.delete("cacheId");
				setOpen(false);
				interaction.utils.postMessageToApp({
					module: "global",
					key: "openNative",
					data: { link: { page: "home" } }
				});
				window.location.href = window.location.pathname + "?" + urlParams.toString();
				return;
			}
			interaction.utils.postMessageToApp({
				module: "global",
				key: "paymentResultAction",
				data: { actionType: "backHome" }
			});
			return;
		}
		onClose === null || onClose === void 0 || onClose();
		setOpen(false);
		removeSessionStorage === null || removeSessionStorage === void 0 || removeSessionStorage();
	};
	return /* @__PURE__ */ react.default.createElement(react.default.Fragment, null, /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellHeaderProgressBar, {
		className: "event-progress-bar",
		style,
		stepText: showStep ? title : "",
		title: description,
		showClose,
		onBack,
		onClose: handleClose,
		enableBorder: true,
		borderColor: "#EAECF0",
		showBack
	}), /* @__PURE__ */ react.default.createElement(_pisell_materials.PisellModal.Information, {
		open,
		title: _pisell_utils.locales.getText("pisell2.event.close.title"),
		describe: _pisell_utils.locales.getText("pisell2.event.close.tip"),
		okText: _pisell_utils.locales.getText("pisell2.event.close.exit"),
		cancelText: _pisell_utils.locales.getText("pisell2.event.close.continue"),
		closable: true,
		okButtonProps: { style: { backgroundColor: "#D92D20" } },
		onCancel: () => {
			setOpen(false);
		},
		onOk: () => handleOk()
	}));
};
//#endregion
exports.default = ProgressBar;
