"use client";
import { BIGINT as p, ERROR as l, SET as I, MAP as g, REGEXP as i, DATE as E, OBJECT as R, ARRAY as y, VOID as A, PRIMITIVE as b } from "./types.js";
const f = typeof self == "object" ? self : globalThis, B = (c, w) => {
  const s = (e, o) => (c.set(o, e), e), a = (e) => {
    if (c.has(e))
      return c.get(e);
    const [o, t] = w[e];
    switch (o) {
      case b:
      case A:
        return s(t, e);
      case y: {
        const r = s([], e);
        for (const n of t)
          r.push(a(n));
        return r;
      }
      case R: {
        const r = s({}, e);
        for (const [n, u] of t)
          r[a(n)] = a(u);
        return r;
      }
      case E:
        return s(new Date(t), e);
      case i: {
        const { source: r, flags: n } = t;
        return s(new RegExp(r, n), e);
      }
      case g: {
        const r = s(/* @__PURE__ */ new Map(), e);
        for (const [n, u] of t)
          r.set(a(n), a(u));
        return r;
      }
      case I: {
        const r = s(/* @__PURE__ */ new Set(), e);
        for (const n of t)
          r.add(a(n));
        return r;
      }
      case l: {
        const { name: r, message: n } = t;
        return s(new f[r](n), e);
      }
      case p:
        return s(BigInt(t), e);
      case "BigInt":
        return s(Object(BigInt(t)), e);
      case "ArrayBuffer":
        return s(new Uint8Array(t).buffer, t);
      case "DataView": {
        const { buffer: r } = new Uint8Array(t);
        return s(new DataView(r), t);
      }
    }
    return s(new f[o](t), e);
  };
  return a;
}, m = (c) => B(/* @__PURE__ */ new Map(), c)(0);
export {
  m as deserialize
};
