const R=3,g=1e3;function w(a,t){switch(a){case"fixed":return async()=>{await new Promise(e=>setTimeout(e,t))};case"exponential":return async e=>{const s=t*Math.pow(2,e-1);await new Promise(n=>setTimeout(n,s))};default:return async()=>{}}}const m=async(a,t={})=>{const{maxRetries:e=3,retryStrategy:s="exponential",delay:n=1e3,logger:r,messages:o={retry:"Operation failed. Retrying...",maxRetriesReached:"Max retries reached"}}=t,y=w(s,n);let i=0;for(;;)try{return await a()}catch(c){if(i++,r&&r.warn(`${o.retry}: ${c.message}`),i>e)throw r&&r.error(`${o.maxRetriesReached}: ${c.message}`),c;await y(i)}};export{m as retryAsyncOperation};
