import { cf as L, co as g, cp as F, c0 as k, c3 as b, bx as P, by as T } from "./address-CBux52Na.mjs";
function D(n, t, e, c) {
  g(n);
  const a = F({ dkLen: 32, asyncTick: 10 }, c), { c: u, dkLen: s, asyncTick: o } = a;
  if (k(u), k(s), k(o), u < 1)
    throw new Error("PBKDF2: iterations (c) should be >= 1");
  const d = b(t), i = b(e), f = new Uint8Array(s), l = P.create(n, d), r = l._cloneInto().update(i);
  return { c: u, dkLen: s, asyncTick: o, DK: f, PRF: l, PRFSalt: r };
}
function K(n, t, e, c, a) {
  return n.destroy(), t.destroy(), c && c.destroy(), a.fill(0), e;
}
function R(n, t, e, c) {
  const { c: a, dkLen: u, DK: s, PRF: o, PRFSalt: d } = D(n, t, e, c);
  let i;
  const f = new Uint8Array(4), l = L(f), r = new Uint8Array(o.outputLen);
  for (let w = 1, p = 0; p < u; w++, p += o.outputLen) {
    const y = s.subarray(p, p + o.outputLen);
    l.setInt32(0, w, !1), (i = d._cloneInto(i)).update(f).digestInto(r), y.set(r.subarray(0, y.length));
    for (let h = 1; h < a; h++) {
      o._cloneInto(i).update(r).digestInto(r);
      for (let m = 0; m < y.length; m++)
        y[m] ^= r[m];
    }
  }
  return K(o, d, s, 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
};
