"use strict";
"use client";
Object.defineProperty(exports, "__esModule", { value: true });
exports.debounce = debounce;
const useTimeout_1 = require("../../utils/hooks/useTimeout");
// https://github.com/mui/material-ui/blob/master/packages/mui-utils/src/debounce.js
function debounce(func, wait = 166, leading = false) {
    const timeout = new useTimeout_1.Timeout();
    function debounced(...args) {
        const later = () => {
            func.apply(this, args);
        };
        if (!timeout.isStarted() && leading) {
            later();
        }
        timeout.start(wait, later);
    }
    debounced.clear = timeout.clear;
    return debounced;
}
//# sourceMappingURL=debounce.js.map