import { y as h } from "./app-Bpb4394e.js";
var a = { exports: {} };
function x(r, s = 100, u = {}) {
  if (typeof r != "function")
    throw new TypeError(`Expected the first parameter to be a function, got \`${typeof r}\`.`);
  if (s < 0)
    throw new RangeError("`wait` must not be negative.");
  const { immediate: f } = typeof u == "boolean" ? { immediate: u } : u;
  let t, n, e, m, l;
  function p() {
    const o = Date.now() - m;
    if (o < s && o >= 0)
      e = setTimeout(p, s - o);
    else if (e = void 0, !f) {
      const d = t, i = n;
      t = void 0, n = void 0, l = r.apply(d, i);
    }
  }
  const c = function(...o) {
    if (t && this !== t)
      throw new Error("Debounced method called with different contexts.");
    t = this, n = o, m = Date.now();
    const d = f && !e;
    if (e || (e = setTimeout(p, s)), d) {
      const i = t, b = n;
      t = void 0, n = void 0, l = r.apply(i, b);
    }
    return l;
  };
  return c.clear = () => {
    e && (clearTimeout(e), e = void 0);
  }, c.flush = () => {
    if (!e)
      return;
    const o = t, d = n;
    t = void 0, n = void 0, l = r.apply(o, d), clearTimeout(e), e = void 0;
  }, c;
}
a.exports.debounce = x;
a.exports = x;
var g = a.exports;
const y = /* @__PURE__ */ h(g);
export {
  y as d
};
