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