/**
 * @license MIT
 * author: Cube Dev Team
 * @cube-dev/ui-kit v0.0.0-canary-2305ece
 * Released under the MIT license.
 */

import { useRef } from 'react';
import { warn } from '../../utils/warnings.js';
import { useEvent } from './use-event.js';
const GLOBAL_WARNED = new Set();
export 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;
    }
}

        