import { isObject as c } from "@scalar/helpers/object/is-object";
import { getResolvedRef as l } from "@scalar/workspace-store/helpers/get-resolved-ref";
import { unpackProxyObject as p } from "@scalar/workspace-store/helpers/unpack-proxy";
const v = (f) => {
  const i = /* @__PURE__ */ new WeakSet(), r = /* @__PURE__ */ new WeakMap(), o = (e) => {
    if (!c(e) && !Array.isArray(e))
      return e;
    const t = p(e, { depth: 1 });
    if (r.has(t))
      return r.get(t);
    if (i.has(t))
      return "[circular]";
    if (i.add(t), "$ref" in e) {
      const s = l(e), a = o(s);
      return r.set(t, a), a;
    }
    if (Array.isArray(e)) {
      const s = e.map(o);
      return r.set(t, s), s;
    }
    const n = Object.fromEntries(Object.entries(e).map(([s, a]) => [s, o(a)]));
    return r.set(t, n), n;
  };
  return o(f);
};
export {
  v as getResolvedRefDeep
};
