import{al as L,r as s,am as e,an as a,W as b}from"./index-CipWZKo_.js";const S=L("documents",()=>{const i=s(null),u=s(null),l=s(null);async function f(){let t="error";return await e.post(a.motionDocuments).then(n=>{i.value=n?.data}).catch(()=>{t="error"}),t}async function h(){await e.post(a.contractsEnclosures).then(t=>{u.value=t.data})}async function D(t){const n=Object.fromEntries(Object.entries(t).filter(([o,d])=>d!=null)),c=new URLSearchParams(n).toString(),r=b+a.invoiceDocumentGuest+(c?`?${c}`:"");await e.post(r).then(o=>{l.value=o.data})}async function p(t){await e.post(a.motionDocumentDownload,{...t}).then(n=>{n?.data?.Status==="Ok"&&m({url:n?.data?.Location,original_name:"Contract"})})}async function w(t){await e.post(a.contractEnclosureDownload,{...t}).then(n=>{n?.data?.Status==="Ok"&&m({url:n?.data?.Location,original_name:"Contract"})})}function m({url:t,original_name:n}){e.get(t,{responseType:"blob"}).then(c=>{const r=new Blob([c.data],{type:"application/pdf"}),o=document.createElement("a");o.href=URL.createObjectURL(r),o.download=n,o.click(),URL.revokeObjectURL(o.href)}).catch(console.error)}return{motionDocumentsList:i,contractDocumentsList:u,motionDocumentDownload:p,contractEnclosureDownload:w,fetchMotionDocuments:f,fetchContractDocuments:h,fetchInvoiceDocumentGuest:D,invoiceDocumentGuest:l}});export{S as u};
