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