import { systemSetTimeoutZero as a } from "./timeoutManager.js";
var c = a;
function f() {
  let r = [], n = 0, o = (t) => {
    t();
  }, i = (t) => {
    t();
  }, u = c;
  const l = (t) => {
    n ? r.push(t) : u(() => {
      o(t);
    });
  }, s = () => {
    const t = r;
    r = [], t.length && u(() => {
      i(() => {
        t.forEach((e) => {
          o(e);
        });
      });
    });
  };
  return {
    batch: (t) => {
      let e;
      n++;
      try {
        e = t();
      } finally {
        n--, n || s();
      }
      return e;
    },
    /**
     * All calls to the wrapped function will be batched.
     */
    batchCalls: (t) => (...e) => {
      l(() => {
        t(...e);
      });
    },
    schedule: l,
    /**
     * Use this method to set a custom notify function.
     * This can be used to for example wrap notifications with `React.act` while running tests.
     */
    setNotifyFunction: (t) => {
      o = t;
    },
    /**
     * Use this method to set a custom function to batch notifications together into a single tick.
     * By default React Query will use the batch function provided by ReactDOM or React Native.
     */
    setBatchNotifyFunction: (t) => {
      i = t;
    },
    setScheduler: (t) => {
      u = t;
    }
  };
}
var y = f();
export {
  f as createNotifyManager,
  c as defaultScheduler,
  y as notifyManager
};
