var e=async(e,t={})=>{Array.isArray(t)&&(t=t[0]);let n=document.createElement(`a`),r=e;`body`in e&&(r=await async function(e,t){let n=e.getReader(),r=new ReadableStream({start:e=>async function t(){return n.read().then(({done:n,value:r})=>{if(!n)return e.enqueue(r),t();e.close()})}()}),i=await new Response(r).blob();return n.releaseLock(),new Blob([i],{type:t})}(e.body,e.headers.get(`content-type`))),n.download=t.fileName||`Untitled`,n.href=URL.createObjectURL(await r);let i=()=>{typeof a==`function`&&a()},a=t.legacySetup&&t.legacySetup(i,()=>a(reject),n);return n.addEventListener(`click`,()=>{setTimeout(()=>URL.revokeObjectURL(n.href),3e4),i()}),n.click(),null};export{e as default};