require("../../../../../_virtual/_rolldown/runtime.js");
let react = require("react");
//#region src/components/PisellCards/components/MultilevelCard/hooks/useMultilevelCardHover.ts
/**
* Hover 交互处理 Hook
* @param options - 配置选项
* @returns 鼠标事件处理函数
*/
const useMultilevelCardHover = (options) => {
	var _delay$enter, _delay$leave;
	const { enabled, delay, onExpandChange } = options;
	const enterTimerRef = (0, react.useRef)(null);
	const leaveTimerRef = (0, react.useRef)(null);
	const enterDelay = (_delay$enter = delay === null || delay === void 0 ? void 0 : delay.enter) !== null && _delay$enter !== void 0 ? _delay$enter : 100;
	const leaveDelay = (_delay$leave = delay === null || delay === void 0 ? void 0 : delay.leave) !== null && _delay$leave !== void 0 ? _delay$leave : 200;
	/**
	* 清除所有定时器
	*/
	const clearTimers = (0, react.useCallback)(() => {
		if (enterTimerRef.current) {
			clearTimeout(enterTimerRef.current);
			enterTimerRef.current = null;
		}
		if (leaveTimerRef.current) {
			clearTimeout(leaveTimerRef.current);
			leaveTimerRef.current = null;
		}
	}, []);
	return {
		onMouseEnter: (0, react.useCallback)(() => {
			if (!enabled) return;
			if (leaveTimerRef.current) {
				clearTimeout(leaveTimerRef.current);
				leaveTimerRef.current = null;
			}
			enterTimerRef.current = setTimeout(() => {
				onExpandChange(true);
			}, enterDelay);
		}, [
			enabled,
			enterDelay,
			onExpandChange
		]),
		onMouseLeave: (0, react.useCallback)(() => {
			if (!enabled) return;
			if (enterTimerRef.current) {
				clearTimeout(enterTimerRef.current);
				enterTimerRef.current = null;
			}
			leaveTimerRef.current = setTimeout(() => {
				onExpandChange(false);
			}, leaveDelay);
		}, [
			enabled,
			leaveDelay,
			onExpandChange
		]),
		clearTimers
	};
};
//#endregion
exports.useMultilevelCardHover = useMultilevelCardHover;
