/** @license MIT | @cube-dev/ui-kit v0.0.0-canary-e634e55 | Cube Dev Team */
import { useEvent } from "./use-event.js";
import { warn } from "../../utils/warnings.js";
import { useRef } from "react";

//#region src/_internal/hooks/use-warn.ts
const GLOBAL_WARNED = /* @__PURE__ */ new Set();
function useWarn(condition, params) {
	const { once = true, key, args } = params;
	const hasWarnedRef = useRef(false);
	const execute = useEvent((condition, args) => {
		if (condition) {
			warn(...args);
			return true;
		}
		return false;
	});
	if (once) {
		const keyString = JSON.stringify(key);
		if (GLOBAL_WARNED.has(keyString)) return;
		if (execute(condition, args)) {
			GLOBAL_WARNED.add(keyString);
			return;
		}
	}
	if (hasWarnedRef.current) return;
	if (execute(condition, args)) {
		hasWarnedRef.current = true;
		return;
	}
}

//#endregion
export { useWarn };
//# sourceMappingURL=use-warn.js.map