var B = Object.defineProperty;
var o = (n, s) => B(n, "name", { value: s, configurable: !0 });
import { assert as I } from "./private/assert.js";
import { uInt64ToString as y, int64ToString as S, int64FromString as p } from "./google/varint.js";
function d() {
  const n = new DataView(new ArrayBuffer(8));
  if (typeof BigInt == "function" && typeof n.getBigInt64 == "function" && typeof n.getBigUint64 == "function" && typeof n.setBigInt64 == "function" && typeof n.setBigUint64 == "function" && (typeof process != "object" || typeof process.env != "object" || process.env.BUF_BIGINT_DISABLE !== "1")) {
    const t = BigInt("-9223372036854775808"), e = BigInt("9223372036854775807"), c = BigInt("0"), u = BigInt("18446744073709551615");
    return {
      zero: BigInt(0),
      supported: !0,
      parse(r) {
        const i = typeof r == "bigint" ? r : BigInt(r);
        if (i > e || i < t)
          throw new Error(`int64 invalid: ${r}`);
        return i;
      },
      uParse(r) {
        const i = typeof r == "bigint" ? r : BigInt(r);
        if (i > u || i < c)
          throw new Error(`uint64 invalid: ${r}`);
        return i;
      },
      enc(r) {
        return n.setBigInt64(0, this.parse(r), !0), {
          lo: n.getInt32(0, !0),
          hi: n.getInt32(4, !0)
        };
      },
      uEnc(r) {
        return n.setBigInt64(0, this.uParse(r), !0), {
          lo: n.getInt32(0, !0),
          hi: n.getInt32(4, !0)
        };
      },
      dec(r, i) {
        return n.setInt32(0, r, !0), n.setInt32(4, i, !0), n.getBigInt64(0, !0);
      },
      uDec(r, i) {
        return n.setInt32(0, r, !0), n.setInt32(4, i, !0), n.getBigUint64(0, !0);
      }
    };
  }
  const g = /* @__PURE__ */ o((t) => I(/^-?[0-9]+$/.test(t), `int64 invalid: ${t}`), "assertInt64String"), f = /* @__PURE__ */ o((t) => I(/^[0-9]+$/.test(t), `uint64 invalid: ${t}`), "assertUInt64String");
  return {
    zero: "0",
    supported: !1,
    parse(t) {
      return typeof t != "string" && (t = t.toString()), g(t), t;
    },
    uParse(t) {
      return typeof t != "string" && (t = t.toString()), f(t), t;
    },
    enc(t) {
      return typeof t != "string" && (t = t.toString()), g(t), p(t);
    },
    uEnc(t) {
      return typeof t != "string" && (t = t.toString()), f(t), p(t);
    },
    dec(t, e) {
      return S(t, e);
    },
    uDec(t, e) {
      return y(t, e);
    }
  };
}
o(d, "makeInt64Support");
const h = d();
export {
  h as protoInt64
};
