import{t as e}from"./axios-m7YkukvY.js";import{I as t}from"./index-uCtpzrM3.js";import{t as n}from"./image-BBguLbTF.js";async function r(r,i,a,o=`receipt`){let s=Array.isArray(a)?a:a?[a]:[];for(let a of s){let s=new FormData;s.append(`type`,r),s.append(`id`,i),s.append(`kind`,o),a.__billNo&&s.append(`bill_no`,a.__billNo),s.append(`file`,await n(a));try{await e.post(`/attachments`,s,{headers:{"Content-Type":`multipart/form-data`}})}catch(e){let n=e?.response?.data?.errors?.bill_no?.[0]||e?.response?.data?.message||`${a.name||`File`} — upload failed`;throw t.create({type:`negative`,timeout:8e3,multiLine:!0,message:n}),e}}return s.length}export{r as t};