const require_runtime = require("../../../../_virtual/_rolldown/runtime.js");
const require_objectSpread2 = require("../../../../_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
const require_index = require("../PcModal/index.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/pisellModal/components/MobileModal/index.tsx
let modalCount = 0;
const MobileModal = (props) => {
	const { wrapClassName, mobileModalHeight } = props;
	const ref = react.default.useRef(null);
	const prevOpenRef = (0, react.useRef)(props.open);
	const isFirstRender = (0, react.useRef)(true);
	(0, react.useEffect)(() => {
		if (isFirstRender.current && props.open) {
			modalCount++;
			document.body.style.overflow = "hidden";
		}
		isFirstRender.current = false;
	}, []);
	(0, react.useEffect)(() => {
		if (!isFirstRender.current && props.open !== prevOpenRef.current) {
			if (props.open) {
				modalCount++;
				document.body.style.overflow = "hidden";
			} else {
				modalCount--;
				if (modalCount <= 0) {
					modalCount = 0;
					document.body.style.overflow = "";
				}
			}
			prevOpenRef.current = props.open;
		}
	}, [props.open]);
	(0, react.useEffect)(() => {
		return () => {
			if (prevOpenRef.current) {
				modalCount--;
				if (modalCount <= 0) {
					modalCount = 0;
					document.body.style.overflow = "";
				}
			}
		};
	}, []);
	return /* @__PURE__ */ react.default.createElement(require_index.default, require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({}, props), {}, {
		transitionName: "pisell-move-down",
		width: "100%",
		wrapClassName: (0, classnames.default)("pisell-mobile-modal", { [wrapClassName]: wrapClassName }),
		modalRender: (node) => {
			return /* @__PURE__ */ react.default.createElement("div", {
				className: (0, classnames.default)({ ["pisell-mobile-modal-render"]: mobileModalHeight }),
				style: { height: mobileModalHeight || "100%" },
				ref
			}, node);
		}
	}));
};
//#endregion
exports.default = MobileModal;
