"use client";
let react = require("react");
//#region packages/@mantine/hooks/src/use-event-listener/use-event-listener.ts
function useEventListener(type, listener, options) {
	const previousListener = (0, react.useRef)(null);
	const previousNode = (0, react.useRef)(null);
	const callbackRef = (0, react.useCallback)((node) => {
		if (!node) return;
		if (previousNode.current && previousListener.current) previousNode.current.removeEventListener(type, previousListener.current, options);
		node.addEventListener(type, listener, options);
		previousNode.current = node;
		previousListener.current = listener;
	}, [
		type,
		listener,
		options
	]);
	(0, react.useEffect)(() => () => {
		if (previousNode.current && previousListener.current) previousNode.current.removeEventListener(type, previousListener.current, options);
	}, [type, options]);
	return callbackRef;
}
//#endregion
exports.useEventListener = useEventListener;

//# sourceMappingURL=use-event-listener.cjs.map