function k(e) {
  if (!Number.isSafeInteger(e) || e < 0)
    throw new Error(`Wrong positive integer: ${e}`);
}
function B(e, ...t) {
  if (!(e instanceof Uint8Array))
    throw new Error("Expected Uint8Array");
  if (t.length > 0 && !t.includes(e.length))
    throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
}
function C(e) {
  if (typeof e != "function" || typeof e.create != "function")
    throw new Error("Hash should be wrapped by utils.wrapConstructor");
  k(e.outputLen), k(e.blockLen);
}
function w(e, t = !0) {
  if (e.destroyed)
    throw new Error("Hash instance has been destroyed");
  if (t && e.finished)
    throw new Error("Hash#digest() has already been called");
}
function D(e, t) {
  B(e);
  const s = t.outputLen;
  if (e.length < s)
    throw new Error(`digestInto() expects output buffer of length at least ${s}`);
}
const H = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
const A = (e) => e instanceof Uint8Array, N = (e) => new Uint8Array(e.buffer, e.byteOffset, e.byteLength), F = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), y = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), u = (e, t) => e << 32 - t | e >>> t, I = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
if (!I)
  throw new Error("Non little-endian hardware is not supported");
const M = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
function V(e) {
  if (!A(e))
    throw new Error("Uint8Array expected");
  let t = "";
  for (let s = 0; s < e.length; s++)
    t += M[e[s]];
  return t;
}
function G(e) {
  if (typeof e != "string")
    throw new Error("hex string expected, got " + typeof e);
  const t = e.length;
  if (t % 2)
    throw new Error("padded hex string expected, got unpadded hex of length " + t);
  const s = new Uint8Array(t / 2);
  for (let n = 0; n < s.length; n++) {
    const o = n * 2, r = e.slice(o, o + 2), i = Number.parseInt(r, 16);
    if (Number.isNaN(i) || i < 0)
      throw new Error("Invalid byte sequence");
    s[n] = i;
  }
  return s;
}
const O = async () => {
};
async function W(e, t, s) {
  let n = Date.now();
  for (let o = 0; o < e; o++) {
    s(o);
    const r = Date.now() - n;
    r >= 0 && r < t || (await O(), n += r);
  }
}
function S(e) {
  if (typeof e != "string")
    throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
  return new Uint8Array(new TextEncoder().encode(e));
}
function p(e) {
  if (typeof e == "string" && (e = S(e)), !A(e))
    throw new Error(`expected Uint8Array, got ${typeof e}`);
  return e;
}
function $(...e) {
  const t = new Uint8Array(e.reduce((n, o) => n + o.length, 0));
  let s = 0;
  return e.forEach((n) => {
    if (!A(n))
      throw new Error("Uint8Array expected");
    t.set(n, s), s += n.length;
  }), t;
}
class E {
  // Safe version that clones internal state
  clone() {
    return this._cloneInto();
  }
}
const v = {}.toString;
function P(e, t) {
  if (t !== void 0 && v.call(t) !== "[object Object]")
    throw new Error("Options should be object or undefined");
  return Object.assign(e, t);
}
function m(e) {
  const t = (n) => e().update(p(n)).digest(), s = e();
  return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = () => e(), t;
}
function z(e) {
  const t = (n, o) => e(o).update(p(n)).digest(), s = e({});
  return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = (n) => e(n), t;
}
function R(e) {
  const t = (n, o) => e(o).update(p(n)).digest(), s = e({});
  return t.outputLen = s.outputLen, t.blockLen = s.blockLen, t.create = (n) => e(n), t;
}
function q(e = 32) {
  if (H && typeof H.getRandomValues == "function")
    return H.getRandomValues(new Uint8Array(e));
  throw new Error("crypto.getRandomValues must be defined");
}
const nt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  Hash: E,
  asyncLoop: W,
  bytesToHex: V,
  checkOpts: P,
  concatBytes: $,
  createView: y,
  hexToBytes: G,
  isLE: I,
  nextTick: O,
  randomBytes: q,
  rotr: u,
  toBytes: p,
  u32: F,
  u8: N,
  utf8ToBytes: S,
  wrapConstructor: m,
  wrapConstructorWithOpts: z,
  wrapXOFConstructorWithOpts: R
}, Symbol.toStringTag, { value: "Module" }));
class U extends E {
  constructor(t, s) {
    super(), this.finished = !1, this.destroyed = !1, C(t);
    const n = p(s);
    if (this.iHash = t.create(), typeof this.iHash.update != "function")
      throw new Error("Expected instance of class which extends utils.Hash");
    this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
    const o = this.blockLen, r = new Uint8Array(o);
    r.set(n.length > o ? t.create().update(n).digest() : n);
    for (let i = 0; i < r.length; i++)
      r[i] ^= 54;
    this.iHash.update(r), this.oHash = t.create();
    for (let i = 0; i < r.length; i++)
      r[i] ^= 106;
    this.oHash.update(r), r.fill(0);
  }
  update(t) {
    return w(this), this.iHash.update(t), this;
  }
  digestInto(t) {
    w(this), B(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
  }
  digest() {
    const t = new Uint8Array(this.oHash.outputLen);
    return this.digestInto(t), t;
  }
  _cloneInto(t) {
    t || (t = Object.create(Object.getPrototypeOf(this), {}));
    const { oHash: s, iHash: n, finished: o, destroyed: r, blockLen: i, outputLen: c } = this;
    return t = t, t.finished = o, t.destroyed = r, t.blockLen = i, t.outputLen = c, t.oHash = s._cloneInto(t.oHash), t.iHash = n._cloneInto(t.iHash), t;
  }
  destroy() {
    this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
  }
}
const j = (e, t, s) => new U(e, t).update(s).digest();
j.create = (e, t) => new U(e, t);
const st = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  HMAC: U,
  hmac: j
}, Symbol.toStringTag, { value: "Module" }));
function K(e, t, s, n) {
  if (typeof e.setBigUint64 == "function")
    return e.setBigUint64(t, s, n);
  const o = BigInt(32), r = BigInt(4294967295), i = Number(s >> o & r), c = Number(s & r), f = n ? 4 : 0, a = n ? 0 : 4;
  e.setUint32(t + f, i, n), e.setUint32(t + a, c, n);
}
class X extends E {
  constructor(t, s, n, o) {
    super(), this.blockLen = t, this.outputLen = s, this.padOffset = n, this.isLE = o, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = y(this.buffer);
  }
  update(t) {
    w(this);
    const { view: s, buffer: n, blockLen: o } = this;
    t = p(t);
    const r = t.length;
    for (let i = 0; i < r; ) {
      const c = Math.min(o - this.pos, r - i);
      if (c === o) {
        const f = y(t);
        for (; o <= r - i; i += o)
          this.process(f, i);
        continue;
      }
      n.set(t.subarray(i, i + c), this.pos), this.pos += c, i += c, this.pos === o && (this.process(s, 0), this.pos = 0);
    }
    return this.length += t.length, this.roundClean(), this;
  }
  digestInto(t) {
    w(this), D(t, this), this.finished = !0;
    const { buffer: s, view: n, blockLen: o, isLE: r } = this;
    let { pos: i } = this;
    s[i++] = 128, this.buffer.subarray(i).fill(0), this.padOffset > o - i && (this.process(n, 0), i = 0);
    for (let h = i; h < o; h++)
      s[h] = 0;
    K(n, o - 8, BigInt(this.length * 8), r), this.process(n, 0);
    const c = y(t), f = this.outputLen;
    if (f % 4)
      throw new Error("_sha2: outputLen should be aligned to 32bit");
    const a = f / 4, d = this.get();
    if (a > d.length)
      throw new Error("_sha2: outputLen bigger than state");
    for (let h = 0; h < a; h++)
      c.setUint32(4 * h, d[h], r);
  }
  digest() {
    const { buffer: t, outputLen: s } = this;
    this.digestInto(t);
    const n = t.slice(0, s);
    return this.destroy(), n;
  }
  _cloneInto(t) {
    t || (t = new this.constructor()), t.set(...this.get());
    const { blockLen: s, buffer: n, length: o, finished: r, destroyed: i, pos: c } = this;
    return t.length = o, t.pos = c, t.finished = r, t.destroyed = i, o % s && t.buffer.set(n), t;
  }
}
const J = (e, t, s) => e & t ^ ~e & s, Q = (e, t, s) => e & t ^ e & s ^ t & s, Y = /* @__PURE__ */ new Uint32Array([
  1116352408,
  1899447441,
  3049323471,
  3921009573,
  961987163,
  1508970993,
  2453635748,
  2870763221,
  3624381080,
  310598401,
  607225278,
  1426881987,
  1925078388,
  2162078206,
  2614888103,
  3248222580,
  3835390401,
  4022224774,
  264347078,
  604807628,
  770255983,
  1249150122,
  1555081692,
  1996064986,
  2554220882,
  2821834349,
  2952996808,
  3210313671,
  3336571891,
  3584528711,
  113926993,
  338241895,
  666307205,
  773529912,
  1294757372,
  1396182291,
  1695183700,
  1986661051,
  2177026350,
  2456956037,
  2730485921,
  2820302411,
  3259730800,
  3345764771,
  3516065817,
  3600352804,
  4094571909,
  275423344,
  430227734,
  506948616,
  659060556,
  883997877,
  958139571,
  1322822218,
  1537002063,
  1747873779,
  1955562222,
  2024104815,
  2227730452,
  2361852424,
  2428436474,
  2756734187,
  3204031479,
  3329325298
]), l = /* @__PURE__ */ new Uint32Array([
  1779033703,
  3144134277,
  1013904242,
  2773480762,
  1359893119,
  2600822924,
  528734635,
  1541459225
]), b = /* @__PURE__ */ new Uint32Array(64);
class T extends X {
  constructor() {
    super(64, 32, 8, !1), this.A = l[0] | 0, this.B = l[1] | 0, this.C = l[2] | 0, this.D = l[3] | 0, this.E = l[4] | 0, this.F = l[5] | 0, this.G = l[6] | 0, this.H = l[7] | 0;
  }
  get() {
    const { A: t, B: s, C: n, D: o, E: r, F: i, G: c, H: f } = this;
    return [t, s, n, o, r, i, c, f];
  }
  // prettier-ignore
  set(t, s, n, o, r, i, c, f) {
    this.A = t | 0, this.B = s | 0, this.C = n | 0, this.D = o | 0, this.E = r | 0, this.F = i | 0, this.G = c | 0, this.H = f | 0;
  }
  process(t, s) {
    for (let h = 0; h < 16; h++, s += 4)
      b[h] = t.getUint32(s, !1);
    for (let h = 16; h < 64; h++) {
      const g = b[h - 15], x = b[h - 2], _ = u(g, 7) ^ u(g, 18) ^ g >>> 3, L = u(x, 17) ^ u(x, 19) ^ x >>> 10;
      b[h] = L + b[h - 7] + _ + b[h - 16] | 0;
    }
    let { A: n, B: o, C: r, D: i, E: c, F: f, G: a, H: d } = this;
    for (let h = 0; h < 64; h++) {
      const g = u(c, 6) ^ u(c, 11) ^ u(c, 25), x = d + g + J(c, f, a) + Y[h] + b[h] | 0, L = (u(n, 2) ^ u(n, 13) ^ u(n, 22)) + Q(n, o, r) | 0;
      d = a, a = f, f = c, c = i + x | 0, i = r, r = o, o = n, n = x + L | 0;
    }
    n = n + this.A | 0, o = o + this.B | 0, r = r + this.C | 0, i = i + this.D | 0, c = c + this.E | 0, f = f + this.F | 0, a = a + this.G | 0, d = d + this.H | 0, this.set(n, o, r, i, c, f, a, d);
  }
  roundClean() {
    b.fill(0);
  }
  destroy() {
    this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
  }
}
class Z extends T {
  constructor() {
    super(), this.A = -1056596264, this.B = 914150663, this.C = 812702999, this.D = -150054599, this.E = -4191439, this.F = 1750603025, this.G = 1694076839, this.H = -1090891868, this.outputLen = 28;
  }
}
const tt = /* @__PURE__ */ m(() => new T()), et = /* @__PURE__ */ m(() => new Z()), ot = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
  __proto__: null,
  sha224: et,
  sha256: tt
}, Symbol.toStringTag, { value: "Module" }));
export {
  E as H,
  X as S,
  ot as a,
  B as b,
  $ as c,
  nt as d,
  w as e,
  st as f,
  j as h,
  k as n,
  D as o,
  q as r,
  tt as s,
  p as t,
  F as u,
  m as w
};
