import{a as e,g as t,s as n,t as r}from"./api-Duu96wkE.js";import{G as i}from"./index-DyQEyT-0.js";var a={types:[`document-types`],checklist:e=>[`applicants`,e,`documents`],queue:e=>[`documents`,`queue`,e],history:(e,t)=>[`applicants`,e,`documents`,t,`history`]};function o(){return e({queryKey:a.types,queryFn:async()=>(await r.get(`/document-types`)).data.data,staleTime:18e5})}function s(t){return e({queryKey:a.checklist(t??``),queryFn:async()=>{let e=await r.get(`/applicants/${t}/documents`),n=e.data.meta;return{items:e.data.data,...n}},enabled:!!t})}function c(e){let t=n();return i({mutationFn:async t=>r.post(`/applicants/${e}/documents`,t,{headers:{"Content-Type":`multipart/form-data`}}),onSuccess:()=>{t.invalidateQueries({queryKey:a.checklist(e)}),t.invalidateQueries({queryKey:[`applicants`,e,`stage`]})}})}function l(){let e=n();return i({mutationFn:async e=>r.post(`/documents/${e.documentId}/review`,{decision:e.decision,reason:e.reason,notes:e.notes}),onSuccess:()=>{e.invalidateQueries({queryKey:[`documents`]}),e.invalidateQueries({queryKey:[`applicants`]})}})}function u(n){return e({queryKey:a.queue(n),queryFn:async()=>{let e=await r.get(`/documents/queue`,{params:n});return{documents:e.data.data,meta:e.data.meta}},placeholderData:t})}async function d(e,t=!0){let n=await r.get(`/documents/${e}/download`,{params:{preview:+!!t},responseType:`blob`});if(String(n.headers[`content-type`]??``).includes(`application/json`)){let e=await n.data.text(),t=JSON.parse(e);window.open(t.data.url,`_blank`,`noopener`);return}let i=URL.createObjectURL(n.data);window.open(i,`_blank`,`noopener`),setTimeout(()=>URL.revokeObjectURL(i),6e4)}export{l as a,o as i,s as n,c as o,u as r,d as t};