import { useEffect as p, useLayoutEffect as w, useRef as s, useMemo as y, useState as E, useCallback as k } from "react";
import "../../../../@dnd-kit_state@0.1.21/node_modules/@dnd-kit/state/dist/index.js";
import { flushSync as O } from "react-dom";
import { currentValue as m } from "./utilities.js";
import { effect as S, untracked as V } from "../../../../@preact_signals-core@1.12.0/node_modules/@preact/signals-core/dist/signals-core.module.js";
var L = typeof window < "u" && typeof window.document < "u" && typeof window.document.createElement < "u", a = L ? w : p;
function M() {
  const e = E(0)[1];
  return k(() => {
    e((t) => t + 1);
  }, [e]);
}
function D(e, t) {
  const n = s(/* @__PURE__ */ new Map()), r = M();
  return a(() => {
    if (!e) {
      n.current.clear();
      return;
    }
    return S(() => {
      var u;
      let c = !1, o = !1;
      for (const d of n.current) {
        const [f] = d, l = V(() => d[1]), i = e[f];
        l !== i && (c = !0, n.current.set(f, i), o = (u = t?.(f, l, i)) != null ? u : !1);
      }
      c && (o ? O(r) : r());
    });
  }, [e]), y(
    () => e && new Proxy(e, {
      get(u, c) {
        const o = u[c];
        return n.current.set(c, o), o;
      }
    }),
    [e]
  );
}
function I(e, t) {
  e();
}
function R(e) {
  const t = s(e);
  return a(() => {
    t.current = e;
  }, [e]), t;
}
function _(e, t, n = p, r = Object.is) {
  const u = s(e);
  n(() => {
    const c = u.current;
    r(e, c) || (u.current = e, t(e, c));
  }, [t, e]);
}
function j(e, t) {
  const n = s(m(e));
  a(() => {
    const r = m(e);
    r !== n.current && (n.current = r, t(r));
  });
}
export {
  D as useDeepSignal,
  I as useImmediateEffect,
  a as useIsomorphicLayoutEffect,
  R as useLatest,
  j as useOnElementChange,
  _ as useOnValueChange
};
//# sourceMappingURL=hooks.js.map
