import { stepsOrder as o } from "./order.es.js";
import { createRenderStep as T } from "./render-step.es.js";
import { MotionGlobalConfig as b } from "../../../../../../motion-utils@12.36.0/node_modules/motion-utils/dist/es/global-config.es.js";
const v = 40;
function N(c, i) {
  let r = !1, a = !0;
  const e = {
    delta: 0,
    timestamp: 0,
    isProcessing: !1
  }, l = () => r = !0, n = o.reduce((t, s) => (t[s] = T(l), t), {}), { setup: m, read: u, resolveKeyframes: f, preUpdate: d, update: g, preRender: h, render: M, postRender: R } = n, p = () => {
    const t = b.useManualTiming, s = t ? e.timestamp : performance.now();
    r = !1, t || (e.delta = a ? 1e3 / 60 : Math.max(Math.min(s - e.timestamp, v), 1)), e.timestamp = s, e.isProcessing = !0, m.process(e), u.process(e), f.process(e), d.process(e), g.process(e), h.process(e), M.process(e), R.process(e), e.isProcessing = !1, r && i && (a = !1, c(p));
  }, x = () => {
    r = !0, a = !0, e.isProcessing || c(p);
  };
  return { schedule: o.reduce((t, s) => {
    const P = n[s];
    return t[s] = (w, E = !1, F = !1) => (r || x(), P.schedule(w, E, F)), t;
  }, {}), cancel: (t) => {
    for (let s = 0; s < o.length; s++)
      n[o[s]].cancel(t);
  }, state: e, steps: n };
}
export {
  N as createRenderBatcher
};
//# sourceMappingURL=batcher.es.js.map
