import{au as L,b1 as g,b2 as F,b3 as k,b4 as h,ay as P,aA as T}from"../main.js";function A(n,t,e,s){g(n);const i=F({dkLen:32,asyncTick:10},s),{c:u,dkLen:c,asyncTick:o}=i;if(k(u),k(c),k(o),u<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const d=h(t),a=h(e),f=new Uint8Array(c),l=P.create(n,d),r=l._cloneInto().update(a);return{c:u,dkLen:c,asyncTick:o,DK:f,PRF:l,PRFSalt:r}}function D(n,t,e,s,i){return n.destroy(),t.destroy(),s&&s.destroy(),i.fill(0),e}function K(n,t,e,s){const{c:i,dkLen:u,DK:c,PRF:o,PRFSalt:d}=A(n,t,e,s);let a;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=c.subarray(p,p+o.outputLen);l.setInt32(0,w,!1),(a=d._cloneInto(a)).update(f).digestInto(r),y.set(r.subarray(0,y.length));for(let b=1;b<i;b++){o._cloneInto(a).update(r).digestInto(r);for(let m=0;m<y.length;m++)y[m]^=r[m]}}return D(o,d,c,a,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 R(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 S=n=>I("mnemonic"+n);function E(n,t=""){return K(T,R(n).nfkd,S(t),{c:2048,dkLen:64})}export{E as m};
