import{c as e}from"./index-DLFWvoW-.js";var t=(t,n,r,i)=>new Promise(async a=>{let{data:{session:o}}=await e.auth.getSession(),s=o?.access_token,c=new XMLHttpRequest,l=Date.now();c.upload.addEventListener(`progress`,e=>{if(e.lengthComputable){let t=(Date.now()-l)/1e3,n=t>0?e.loaded/t:0,r=n>0?(e.total-e.loaded)/n:0;i({loaded:e.loaded,total:e.total,percentage:Math.round(e.loaded/e.total*100),speed:n,timeRemaining:r})}}),c.addEventListener(`load`,()=>{c.status>=200&&c.status<300?a({error:null}):a({error:Error(`Upload failed: ${c.statusText}`)})}),c.addEventListener(`error`,()=>{a({error:Error(`Upload failed`)})});let u=`https://woadjgjehpajwwbqodpt.supabase.co/storage/v1/object/${t}/${n}`;c.open(`POST`,u),c.setRequestHeader(`Authorization`,`Bearer ${s}`),c.setRequestHeader(`apikey`,`eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6IndvYWRqZ2plaHBhand3YnFvZHB0Iiwicm9sZSI6ImFub24iLCJpYXQiOjE3NzMyNjAyNjUsImV4cCI6MjA4ODgzNjI2NX0.G8rutnyMvjzZ5zJU8vxenEemAFea7NKLUWsOMO9VDR8`),c.setRequestHeader(`x-upsert`,`false`);let d=new FormData;d.append(`cacheControl`,`3600`),d.append(``,r),c.send(d)}),n=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`,r=e=>e<1?`< 1s`:e<60?`${Math.ceil(e)}s`:`${Math.floor(e/60)}m ${Math.ceil(e%60)}s`,i=e=>e<1024?`${Math.round(e)} B/s`:e<1048576?`${(e/1024).toFixed(1)} KB/s`:`${(e/1048576).toFixed(1)} MB/s`;export{t as i,i as n,r,n as t};