var c, l;
function O() {
  if (l)
    return c;
  l = 1;
  const u = (e) => {
    const r = e.charCodeAt(0).toString(16).toUpperCase();
    return "0x" + (r.length % 2 ? "0" : "") + r;
  }, E = (e, r, t) => {
    if (!r)
      return {
        message: e.message + " while parsing empty string",
        position: 0
      };
    const s = e.message.match(/^Unexpected token (.) .*position\s+(\d+)/i), n = s ? +s[2] : e.message.match(/^Unexpected end of JSON.*/i) ? r.length - 1 : null, o = s ? e.message.replace(/^Unexpected token ./, `Unexpected token ${JSON.stringify(s[1])} (${u(s[1])})`) : e.message;
    if (n != null) {
      const a = n <= t ? 0 : n - t, m = n + t >= r.length ? r.length : n + t, h = (a === 0 ? "" : "...") + r.slice(a, m) + (m === r.length ? "" : "...");
      return {
        message: o + ` while parsing ${r === h ? "" : "near "}${JSON.stringify(h)}`,
        position: n
      };
    } else
      return {
        message: o + ` while parsing '${r.slice(0, t * 2)}'`,
        position: 0
      };
  };
  class p extends SyntaxError {
    constructor(r, t, s, n) {
      s = s || 20;
      const o = E(r, t, s);
      super(o.message), Object.assign(this, o), this.code = "EJSONPARSE", this.systemError = r, Error.captureStackTrace(this, n || this.constructor);
    }
    get name() {
      return this.constructor.name;
    }
    set name(r) {
    }
    get [Symbol.toStringTag]() {
      return this.constructor.name;
    }
  }
  const y = Symbol.for("indent"), d = Symbol.for("newline"), f = /^\s*[{\[]((?:\r?\n)+)([\s\t]*)/, S = /^(?:\{\}|\[\])((?:\r?\n)+)?$/, i = (e, r, t) => {
    const s = g(e);
    t = t || 20;
    try {
      const [, n = `
`, o = "  "] = s.match(S) || s.match(f) || [, "", ""], a = JSON.parse(s, r);
      return a && typeof a == "object" && (a[d] = n, a[y] = o), a;
    } catch (n) {
      if (typeof e != "string" && !Buffer.isBuffer(e)) {
        const o = Array.isArray(e) && e.length === 0;
        throw Object.assign(new TypeError(
          `Cannot parse ${o ? "an empty array" : String(e)}`
        ), {
          code: "EJSONPARSE",
          systemError: n
        });
      }
      throw new p(n, s, t, i);
    }
  }, g = (e) => String(e).replace(/^\uFEFF/, "");
  return c = i, i.JSONParseError = p, i.noExceptions = (e, r) => {
    try {
      return JSON.parse(g(e), r);
    } catch {
    }
  }, c;
}
export {
  O as __require
};
//# sourceMappingURL=index.js.map
