"use strict";const n=require("./index-uRFn7LyP.js");function L(i,p,f,l){n.hash(i);const y=n.checkOpts({dkLen:32,asyncTick:10},l),{c:b,dkLen:d,asyncTick:t}=y;if(n.number(b),n.number(d),n.number(t),b<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const e=n.toBytes(p),r=n.toBytes(f),s=new Uint8Array(d),k=n.hmac.create(i,e),o=k._cloneInto().update(r);return{c:b,dkLen:d,asyncTick:t,DK:s,PRF:k,PRFSalt:o}}function g(i,p,f,l,y){return i.destroy(),p.destroy(),l&&l.destroy(),y.fill(0),f}function _(i,p,f,l){const{c:y,dkLen:b,DK:d,PRF:t,PRFSalt:e}=L(i,p,f,l);let r;const s=new Uint8Array(4),k=n.createView(s),o=new Uint8Array(t.outputLen);for(let c=1,w=0;w<b;c++,w+=t.outputLen){const u=d.subarray(w,w+t.outputLen);k.setInt32(0,c,!1),(r=e._cloneInto(r)).update(s).digestInto(o),u.set(o.subarray(0,u.length));for(let I=1;I<y;I++){t._cloneInto(r).update(o).digestInto(o);for(let a=0;a<u.length;a++)u[a]^=o[a]}}return g(t,e,d,r,o)}async function h(i,p,f,l){const{c:y,dkLen:b,asyncTick:d,DK:t,PRF:e,PRFSalt:r}=L(i,p,f,l);let s;const k=new Uint8Array(4),o=n.createView(k),c=new Uint8Array(e.outputLen);for(let w=1,u=0;u<b;w++,u+=e.outputLen){const I=t.subarray(u,u+e.outputLen);o.setInt32(0,w,!1),(s=r._cloneInto(s)).update(k).digestInto(c),I.set(c.subarray(0,I.length)),await n.asyncLoop(y-1,d,()=>{e._cloneInto(s).update(c).digestInto(c);for(let a=0;a<I.length;a++)I[a]^=c[a]})}return g(e,r,t,s,c)}const P=Object.freeze(Object.defineProperty({__proto__:null,pbkdf2:_,pbkdf2Async:h},Symbol.toStringTag,{value:"Module"}));exports.pbkdf2=_;exports.pbkdf2$1=P;
