":
      case " ":
      case "\uFEFF":
      case `
`:
      case "\r":
      case "\u2028":
      case "\u2029":
        return void u();
      case "/":
        return u(), void (C = "comment");
      case void 0:
        return u(), a("eof");
    }
    if (!((D) => typeof D == "string" && R.Space_Separator.test(D))(A)) return J[p]();
    u();
  }, comment() {
    switch (A) {
      case "*":
        return u(), void (C = "multiLineComment");
      case "/":
        return u(), void (C = "singleLineComment");
    }
    throw t(u());
  }, multiLineComment() {
    switch (A) {
      case "*":
        return u(), void (C = "multiLineCommentAsterisk");
      case void 0:
        throw t(u());
    }
    u();
  }, multiLineCommentAsterisk() {
    switch (A) {
      case "*":
        return void u();
      case "/":
        return u(), void (C = "default");
      case void 0:
        throw t(u());
    }
    u(), C = "multiLineComment";
  }, singleLineComment() {
    switch (A) {
      case `
`:
      case "\r":
      case "\u2028":
      case "\u2029":
        return u(), void (C = "default");
      case void 0:
        return u(), a("eof");
    }
    u();
  }, value() {
    switch (A) {
      case "{":
      case "[":
        return a("punctuator", u());
      case "n":
        return u(), N("ull"), a("null", null);
      case "t":
        return u(), N("rue"), a("boolean", !0);
      case "f":
        return u(), N("alse"), a("boolean", !1);
      case "-":
      case "+":
        return u() === "-" && (f = -1), void (C = "sign");
      case ".":
        return e = u(), void (C = "decimalPointLeading");
      case "0":
        return e = u(), void (C = "zero");
      case "1":
      case "2":
      case "3":
      case "4":
      case "5":
      case "6":
      case "7":
      case "8":
      case "9":
        return e = u(), void (C = "decimalInteger");
      case "I":
        return u(), N("nfinity"), a("numeric", 1 / 0);
      case "N":
        return u(), N("aN"), a("numeric", NaN);
      case '"':
      case "'":
        return x = u() === '"', e = "", void (C = "string");
    }
    throw t(u());
  }, identifierNameStartEscape() {
    if (A !== "u") throw t(u());
    u();
    const D = n();
    switch (D) {
      case "$":
      case "_":
        break;
      default:
        if (!q(D)) throw l();
    }
    e += D, C = "identifierName";
  }, identifierName() {
    switch (A) {
      case "$":
      case "_":
      case "‌":
      case "‍":
        return void (e += u());
      case "\\":
        return u(), void (C = "identifierNameEscape");
    }
    if (!T(A)) return a("identifier", e);
    e += u();
  }, identifierNameEscape() {
    if (A !== "u") throw t(u());
    u();
    const D = n();
    switch (D) {
      case "$":
      case "_":
      case "‌":
      case "‍":
        break;
      default:
        if (!T(D)) throw l();
    }
    e += D, C = "identifierName";
  }, sign() {
    switch (A) {
      case ".":
        return e = u(), void (C = "decimalPointLeading");
      case "0":
        return e = u(), void (C = "zero");
      case "1":
      case "2":
      case "3":
      case "4":
      case "5":
      case "6":
      case "7":
      case "8":
      case "9":
        return e = u(), void (C = "decimalInteger");
      case "I":
        return u(), N("nfinity"), a("numeric", f * (1 / 0));
      case "N":
        return u(), N("aN"), a("numeric", NaN);
    }
    throw t(u());
  }, zero() {
    switch (A) {
      case ".":
        return e += u(), void (C = "decimalPoint");
      case "e":
      case "E":
        return e += u(), void (C = "decimalExponent");
      case "x":
      case "X":
        return e += u(), void (C = "hexadecimal");
      case "n":
        return void (C = "bigInt");
    }
    return a("numeric", 0 * f);
  }, decimalInteger() {
    switch (A) {
      case ".":
        return e += u(), void (C = "decimalPoint");
      case "e":
      case "E":
        return e += u(), void (C = "decimalExponent");
      case "n":
        return void (C = "bigInt");
    }
    if (!I(A)) return b(f, e);
    e += u();
  }, decimalPointLeading() {
    if (I(A)) return e += u(), void (C = "decimalFraction");
    throw t(u());
  }, decimalPoint() {
    switch (A) {
      case "e":
      case "E":
        return e += u(), void (C = "decimalExponent");
    }
    return I(A) ? (e += u(), void (C = "decimalFraction")) : b(f, e);
  }, decimalFraction() {
    switch (A) {
      case "e":
      case "E":
        return e += u(), void (C = "decimalExponent");
    }
    if (!I(A)) return b(f, e);
    e += u();
  }, decimalExponent() {
    switch (A) {
      case "+":
      case "-":
        return e += u(), void (C = "decimalExponentSign");
    }
    if (I(A)) return e += u(), void (C = "decimalExponentInteger");
    throw t(u());
  }, decimalExponentSign() {
    if (I(A)) return e += u(), void (C = "decimalExponentInteger");
    throw t(u());
  }, decimalExponentInteger() {
    if (!I(A)) return b(f, e);
    e += u();
  }, bigInt() {
    if (e != null && e.length && (typeof (D = e) == "string" && !/[^0-9]/.test(D) || ((E) => typeof E == "string" && /0x[0-9a-f]+$/i.test(E))(e))) return u(), a("bigint", BigInt(f) * BigInt(e));
    var D;
    throw t(u());
  }, hexadecimal() {
    if (M(A)) return e += u(), void (C = "hexadecimalInteger");
    throw t(u());
  }, hexadecimalInteger() {
    if (M(A)) e += u();
    else {
      if (A !== "n") return b(f, e);
      C = "bigInt";
    }
  }, string() {
    switch (A) {
      case "\\":
        return u(), void (e += function() {
          switch (g()) {
            case "b":
              return u(), "\b";
            case "f":
              return u(), "\f";
            case "n":
              return u(), `
`;
            case "r":
              return u(), "\r";
            case "t":
              return u(), "	";
            case "v":
              return u(), "\v";
            case "0":
              if (u(), I(g())) throw t(u());
              return "\0";
            case "x":
              return u(), function() {
                let E = "", c = g();
                if (!M(c) || (E += u(), c = g(), !M(c))) throw t(u());
                return E += u(), String.fromCodePoint(parseInt(E, 16));
              }();
            case "u":
              return u(), n();
            case `
`:
            case "\u2028":
            case "\u2029":
              return u(), "";
            case "\r":
              return u(), g() === `
` && u(), "";
            case "1":
            case "2":
            case "3":
            case "4":
            case "5":
            case "6":
            case "7":
            case "8":
            case "9":
            case void 0:
              throw t(u());
          }
          return u();
        }());
      case '"':
        return x ? (u(), a("string", e)) : void (e += u());
      case "'":
        return x ? void (e += u()) : (u(), a("string", e));
      case `
`:
      case "\r":
        throw t(u());
      case "\u2028":
      case "\u2029":
        D = A, console.warn(`JSON11: '${P(D)}' in strings is not valid ECMAScript; consider escaping`);
        break;
      case void 0:
        throw t(u());
    }
    var D;
    e += u();
  }, start() {
    switch (A) {
      case "{":
      case "[":
        return a("punctuator", u());
      case void 0:
        return a("eof");
    }
    C = "value";
  }, beforePropertyName() {
    switch (A) {
      case "$":
      case "_":
        return e = u(), void (C = "identifierName");
      case "\\":
        return u(), void (C = "identifierNameStartEscape");
      case "}":
        return a("punctuator", u());
      case '"':
      case "'":
        return x = u() === '"', void (C = "string");
    }
    if (q(A)) return e += u(), void (C = "identifierName");
    throw t(u());
  }, afterPropertyName() {
    if (A === ":") return a("punctuator", u());
    throw t(u());
  }, beforePropertyValue() {
    C = "value";
  }, afterPropertyValue() {
    switch (A) {
      case ",":
      case "}":
        return a("punctuator", u());
    }
    throw t(u());
  }, beforeArrayValue() {
    if (A === "]") return a("punctuator", u());
    C = "value";
  }, afterArrayValue() {
    switch (A) {
      case ",":
      case "]":
        return a("punctuator", u());
    }
    throw t(u());
  }, end() {
    throw t(u());
  } }, L = { start() {
    if (r.type === "eof") throw o();
    i();
  }, beforePropertyName() {
    switch (r.type) {
      case "identifier":
      case "string":
        return S = r.value, void (p = "afterPropertyName");
      case "punctuator":
        return void F();
      case "eof":
        throw o();
    }
  }, afterPropertyName() {
    if (r.type === "eof") throw o();
    p = "beforePropertyValue";
  }, beforePropertyValue() {
    if (r.type === "eof") throw o();
    i();
  }, beforeArrayValue() {
    if (r.type === "eof") throw o();
    r.type !== "punctuator" || r.value !== "]" ? i() : F();
  }, afterPropertyValue() {
    if (r.type === "eof") throw o();
    switch (r.value) {
      case ",":
        return void (p = "beforePropertyName");
      case "}":
        F();
    }
  }, afterArrayValue() {
    if (r.type === "eof") throw o();
    switch (r.value) {
      case ",":
        return void (p = "beforeArrayValue");
      case "]":
        F();
    }
  }, end() {
  } };
  do
    r = _(), L[p]();
  while (r.type !== "eof");
  return typeof s == "function" ? function D(E, c, k) {
    const y = E[c];
    if (y != null && typeof y == "object") if (Array.isArray(y)) for (let j = 0; j < y.length; j++) {
      const z = String(j), G = D(y, z, k);
      Object.defineProperty(y, z, { value: G, writable: !0, enumerable: !0, configurable: !0 });
    }
    else for (const j in y) {
      const z = D(y, j, k);
      z === void 0 ? delete y[j] : Object.defineProperty(y, j, { value: z, writable: !0, enumerable: !0, configurable: !0 });
    }
    return k.call(E, c, y);
  }({ "": O }, "", s) : O;
  function _() {
    for (C = "default", e = "", x = !1, f = 1; ; ) {
      A = g();
      const D = J[C]();
      if (D) return D;
    }
  }
  function g() {
    if (w[$]) return String.fromCodePoint(w.codePointAt($));
  }
  function u() {
    const D = g();
    return D === `
` ? (v++, h = 0) : D ? h += D.length : h++, D && ($ += D.length), D;
  }
  function a(D, E) {
    return { type: D, value: E, line: v, column: h };
  }
  function b(D, E) {
    const c = D * Number(E);
    if (V != null && V.withLongNumerals && (c > Number.MAX_SAFE_INTEGER || c < Number.MIN_SAFE_INTEGER)) try {
      return a("bigint", BigInt(D) * BigInt(E));
    } catch (k) {
      console.warn(k);
    }
    return a("numeric", c);
  }
  function N(D) {
    for (const E of D) {
      if (g() !== E) throw t(u());
      u();
    }
  }
  function n() {
    let D = "", E = 4;
    for (; E-- > 0; ) {
      const c = g();
      if (!M(c)) throw t(u());
      D += u();
    }
    return String.fromCodePoint(parseInt(D, 16));
  }
  function i() {
    let D;
    switch (r.type) {
      case "punctuator":
        switch (r.value) {
          case "{":
            D = {};
            break;
          case "[":
            D = [];
        }
        break;
      case "null":
      case "boolean":
      case "numeric":
      case "string":
      case "bigint":
        D = r.value;
    }
    if (O === void 0) O = D;
    else {
      const E = m[m.length - 1];
      Array.isArray(E) ? E.push(D) : Object.defineProperty(E, S, { value: D, writable: !0, enumerable: !0, configurable: !0 });
    }
    if (D !== null && typeof D == "object") m.push(D), p = Array.isArray(D) ? "beforeArrayValue" : "beforePropertyName";
    else {
      const E = m[m.length - 1];
      p = E == null ? "end" : Array.isArray(E) ? "afterArrayValue" : "afterPropertyValue";
    }
  }
  function F() {
    m.pop();
    const D = m[m.length - 1];
    p = D == null ? "end" : Array.isArray(D) ? "afterArrayValue" : "afterPropertyValue";
  }
  function t(D) {
    return d(D === void 0 ? `JSON11: invalid end of input at ${v}:${h}` : `JSON11: invalid character '${P(D)}' at ${v}:${h}`);
  }
  function o() {
    return d(`JSON11: invalid end of input at ${v}:${h}`);
  }
  function l() {
    return h -= 5, d(`JSON11: invalid identifier character at ${v}:${h}`);
  }
  function P(D) {
    const E = { "'": "\\'", '"': '\\"', "\\": "\\\\", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", "	": "\\t", "\v": "\\v", "\0": "\\0", "\u2028": "\\u2028", "\u2029": "\\u2029" };
    if (E[D]) return E[D];
    if (D < " ") {
      const c = D.charCodeAt(0).toString(16);
      return "\\x" + ("00" + c).substring(c.length);
    }
    return D;
  }
  function d(D) {
    const E = new SyntaxError(D);
    return Object.defineProperty(E, "lineNumber", { value: v, writable: !0, enumerable: !0, configurable: !0 }), Object.defineProperty(E, "columnNumber", { value: h, writable: !0, enumerable: !0, configurable: !0 }), E;
  }
}
function Z(B, s, V, r) {
  var g, u, a, b, N;
  const S = [];
  let O, C, e, x, f, A = "", w = "", p = function(n) {
    if (n.length === 0) return _(n);
    const i = String.fromCodePoint(n.codePointAt(0));
    if (!q(i)) return _(n);
    for (let F = i.length; F < n.length; F++) if (!T(String.fromCodePoint(n.codePointAt(F)))) return _(n);
    return n;
  }, m = "";
  const $ = { "'": 0.1, '"': 0.2 };
  if (s == null || typeof s != "object" || Array.isArray(s)) {
    if (typeof s == "function") C = s;
    else if (Array.isArray(s)) {
      O = [];
      const n = /* @__PURE__ */ new Set();
      for (const i of s) {
        const F = (g = i == null ? void 0 : i.toString) == null ? void 0 : g.call(i);
        F !== void 0 && n.add(F);
      }
      O = [...n];
    }
    w = J(V), e = (a = (u = r == null ? void 0 : r.quote) == null ? void 0 : u.trim) == null ? void 0 : a.call(u), (r == null ? void 0 : r.quoteNames) === !0 && (p = _), x = r == null ? void 0 : r.withBigInt, f = (r == null ? void 0 : r.withLegacyEscapes) === !0, r != null && r.trailingComma && (m = ",");
  } else w = J(s.space), s.trailingComma && (m = ","), e = (N = (b = s.quote) == null ? void 0 : b.trim) == null ? void 0 : N.call(b), s.quoteNames === !0 && (p = _), typeof s.replacer == "function" && (C = s.replacer), x = s.withBigInt, f = s.withLegacyEscapes === !0;
  const v = { "'": "\\'", '"': '\\"', "\\": "\\\\", "\b": "\\b", "\f": "\\f", "\n": "\\n", "\r": "\\r", "	": "\\t", "\v": f ? "\\v" : "\\u000b", "\0": f ? "\\0" : "\\u0000", "\u2028": "\\u2028", "\u2029": "\\u2029" }, h = f ? "\\x00" : "\\u0000";
  return L("", { "": B });
  function J(n) {
    if (typeof n == "number" || n instanceof Number) {
      const i = Number(n);
      if (isFinite(i) && i > 0) return " ".repeat(Math.min(10, Math.floor(i)));
    } else if (typeof n == "string" || n instanceof String) return n.substring(0, 10);
    return "";
  }
  function L(n, i) {
    let F = i[n];
    switch (F != null && (typeof F.toJSON11 == "function" ? F = F.toJSON11(n) : typeof F.toJSON5 == "function" ? F = F.toJSON5(n) : typeof F.toJSON == "function" && (F = F.toJSON(n))), C && (F = C.call(i, n, F)), F instanceof Number ? F = Number(F) : F instanceof String ? F = String(F) : F instanceof Boolean && (F = F.valueOf()), F) {
      case null:
        return "null";
      case !0:
        return "true";
      case !1:
        return "false";
    }
    return typeof F == "string" ? _(F) : typeof F == "number" ? String(F) : typeof F == "bigint" ? F.toString() + (x === !1 ? "" : "n") : typeof F == "object" ? Array.isArray(F) ? function(t) {
      if (S.includes(t)) throw TypeError("Converting circular structure to JSON11");
      S.push(t);
      let o = A;
      A += w;
      let l, P = [];
      for (let d = 0; d < t.length; d++) {
        const D = L(String(d), t);
        P.push(D !== void 0 ? D : "null");
      }
      if (P.length === 0) l = "[]";
      else if (w === "")
        l = "[" + P.join(",") + "]";
      else {
        let d = P.join(`,
` + A);
        l = `[
` + A + d + m + `
` + o + "]";
      }
      return S.pop(), A = o, l;
    }(F) : function(t) {
      if (S.includes(t)) throw TypeError("Converting circular structure to JSON11");
      S.push(t);
      let o = A;
      A += w;
      let l, P = O || Object.keys(t), d = [];
      for (const D of P) {
        const E = L(D, t);
        if (E !== void 0) {
          let c = p(D) + ":";
          w !== "" && (c += " "), c += E, d.push(c);
        }
      }
      if (d.length === 0) l = "{}";
      else {
        let D;
        w === "" ? (D = d.join(","), l = "{" + D + "}") : (D = d.join(`,
` + A), l = `{
` + A + D + m + `
` + o + "}");
      }
      return S.pop(), A = o, l;
    }(F) : void 0;
  }
  function _(n) {
    let i = "";
    for (let t = 0; t < n.length; t++) {
      const o = n[t];
      switch (o) {
        case "'":
        case '"':
          $[o]++, i += o;
          continue;
        case "\0":
          if (I(n[t + 1])) {
            i += h;
            continue;
          }
      }
      if (v[o]) i += v[o];
      else if (o < " ") {
        let l = o.charCodeAt(0).toString(16);
        i += f ? "\\x" + ("00" + l).substring(l.length) : "\\u" + l.padStart(4, "0");
      } else i += o;
    }
    const F = e || Object.keys($).reduce((t, o) => $[t] < $[o] ? t : o);
    return i = i.replace(new RegExp(F, "g"), v[F]), F + i + F;
  }
}
export {
  X as parse,
  Z as stringify
};
//# sourceMappingURL=index.min.mjs.map
