"use client";
let react = require("react");
//#region src/utils/use-event.ts
/**
* Returns a memoized callback that will flushSync the callback if sync is true
*/
function useEvent(callback, opts = {}) {
	const { sync = false } = opts;
	const callbackRef = useLatestRef(callback);
	return (0, react.useCallback)((...args) => {
		if (sync) return queueMicrotask(() => callbackRef.current?.(...args));
		return callbackRef.current?.(...args);
	}, [sync, callbackRef]);
}
function useLatestRef(value) {
	const ref = (0, react.useRef)(value);
	ref.current = value;
	return ref;
}
//#endregion
exports.useEvent = useEvent;
