import { ce as L, cn as g, co as F, b$ as w, c2 as h, bw as P, bx as T } from "./address-BLzPWV-E.mjs";
function D(n, t, e, s) {
  g(n);
  const a = F({ dkLen: 32, asyncTick: 10 }, s), { c: u, dkLen: c, asyncTick: o } = a;
  if (w(u), w(c), w(o), u < 1)
    throw new Error("PBKDF2: iterations (c) should be >= 1");
  const d = h(t), i = h(e), f = new Uint8Array(c), l = P.create(n, d), r = l._cloneInto().update(i);
  return { c: u, dkLen: c, asyncTick: o, DK: f, PRF: l, PRFSalt: r };
}
function K(n, t, e, s, a) {
  return n.destroy(), t.destroy(), s && s.destroy(), a.fill(0), e;
}
function R(n, t, e, s) {
  const { c: a, dkLen: u, DK: c, PRF: o, PRFSalt: d } = D(n, t, e, s);
  let i;
  const f = new Uint8Array(4), l = L(f), r = new Uint8Array(o.outputLen);
  for (let k = 1, p = 0; p < u; k++, p += o.outputLen) {
    const m = c.subarray(p, p + o.outputLen);
    l.setInt32(0, k, !1), (i = d._cloneInto(i)).update(f).digestInto(r), m.set(r.subarray(0, m.length));
    for (let b = 1; b < a; b++) {
      o._cloneInto(i).update(r).digestInto(r);
      for (let y = 0; y < m.length; y++)
        m[y] ^= r[y];
    }
  }
  return K(o, d, c, i, r);
}
/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
function I(n) {
  if (typeof n != "string")
    throw new TypeError("invalid mnemonic type: " + typeof n);
  return n.normalize("NFKD");
}
function S(n) {
  const t = I(n), e = t.split(" ");
  if (![12, 15, 18, 21, 24].includes(e.length))
    throw new Error("Invalid mnemonic");
  return { nfkd: t, words: e };
}
const v = (n) => I("mnemonic" + n);
function E(n, t = "") {
  return R(T, S(n).nfkd, v(t), { c: 2048, dkLen: 64 });
}
export {
  E as m
};
