import a, { useContext as $, useState as l, useRef as f } from "react";
const c = {
  prefix: /* @__PURE__ */ String(/* @__PURE__ */ Math.round(/* @__PURE__ */ Math.random() * 1e10)),
  current: 0
}, s = /* @__PURE__ */ a.createContext(c), p = /* @__PURE__ */ a.createContext(!1);
let v = !!(typeof window < "u" && window.document && window.document.createElement), d = /* @__PURE__ */ new WeakMap();
function b(t = !1) {
  let e = $(s), r = f(null);
  if (r.current === null && !t) {
    var n, u;
    let o = (u = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED) === null || u === void 0 || (n = u.ReactCurrentOwner) === null || n === void 0 ? void 0 : n.current;
    if (o) {
      let i = d.get(o);
      i == null ? d.set(o, {
        id: e.current,
        state: o.memoizedState
      }) : o.memoizedState !== i.state && (e.current = i.id, d.delete(o));
    }
    r.current = ++e.current;
  }
  return r.current;
}
function x(t) {
  let e = $(s);
  e === c && !v && process.env.NODE_ENV !== "production" && console.warn("When server rendering, you must wrap your application in an <SSRProvider> to ensure consistent ids are generated between the client and server.");
  let r = b(!!t), n = e === c && process.env.NODE_ENV === "test" ? "react-aria" : `react-aria${e.prefix}`;
  return t || `${n}-${r}`;
}
function S(t) {
  let e = a.useId(), [r] = l(y()), n = r || process.env.NODE_ENV === "test" ? "react-aria" : `react-aria${c.prefix}`;
  return t || `${n}-${e}`;
}
const C = typeof a.useId == "function" ? S : x;
function m() {
  return !1;
}
function w() {
  return !0;
}
function g(t) {
  return () => {
  };
}
function y() {
  return typeof a.useSyncExternalStore == "function" ? a.useSyncExternalStore(g, m, w) : $(p);
}
export {
  y as $,
  C as a
};
//# sourceMappingURL=SSRProvider-CQ9PmFV6.es.js.map
