"use client";
import * as a from "react";
import { a as c } from "./useRenderElement-DNB2vtF1.js";
const n = a[`useInsertionEffect${Math.random().toFixed(1)}`.slice(0, -3)], r = (
  // React 17 doesn't have useInsertionEffect.
  n && // Preact replaces useInsertionEffect with useLayoutEffect and fires too late.
  n !== a.useLayoutEffect ? n : (e) => e()
);
function f(e) {
  const t = c(o).current;
  return t.next = e, r(t.effect), t.trampoline;
}
function o() {
  const e = {
    next: void 0,
    callback: s,
    trampoline: (...t) => e.callback?.(...t),
    effect: () => {
      e.callback = e.next;
    }
  };
  return e;
}
function s() {
  if (process.env.NODE_ENV !== "production")
    throw (
      /* minify-error-disabled */
      new Error("Base UI: Cannot call an event handler while rendering.")
    );
}
export {
  f as u
};
