import { statsBuffer as d } from "../stats/buffer.js";
function C(m, u) {
  let t = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), r = !1, n = !1;
  const a = /* @__PURE__ */ new WeakSet();
  let l = {
    delta: 0,
    timestamp: 0,
    isProcessing: !1
  }, f = 0;
  function p(e) {
    a.has(e) && (o.schedule(e), m()), f++, e(l);
  }
  const o = {
    /**
     * Schedule a process to run on the next frame.
     */
    schedule: (e, h = !1, c = !1) => {
      const i = c && r ? t : s;
      return h && a.add(e), i.has(e) || i.add(e), e;
    },
    /**
     * Cancel the provided callback from running on the next frame.
     */
    cancel: (e) => {
      s.delete(e), a.delete(e);
    },
    /**
     * Execute all schedule callbacks.
     */
    process: (e) => {
      if (l = e, r) {
        n = !0;
        return;
      }
      r = !0, [t, s] = [s, t], t.forEach(p), u && d.value && d.value.frameloop[u].push(f), f = 0, t.clear(), r = !1, n && (n = !1, o.process(e));
    }
  };
  return o;
}
export {
  C as createRenderStep
};
//# sourceMappingURL=render-step.js.map
