import{C as r}from"./p-DaIKrQry.js";import{g as o,a as e}from"./p-Cb8cfh-k.js";const n=({authToken:n,businessId:i,service:t})=>async({onSuccess:s,onError:a,final:c=()=>{}})=>{var l;try{const c=await t.fetchBusiness(i,n);if(c.error){return a({error:e(c.error),code:o(null===(l=c.error)||void 0===l?void 0:l.code),severity:r.ERROR})}s(c)}catch(e){const n=o(null==e?void 0:e.code);return a({error:e.message||e,code:n,severity:r.ERROR})}finally{c()}},i=({authToken:n,businessId:i,service:t})=>async({payload:s,onSuccess:a,onError:c,final:l=()=>{}})=>{var v;try{const l=await t.patchBusiness(n,i,s);if(l.error){return c({error:e(l.error),code:o(null===(v=l.error)||void 0===v?void 0:v.code),severity:r.ERROR,rawError:l.error})}a(l)}catch(e){const n=o(null==e?void 0:e.code);return c({error:e.message||e,code:n,severity:r.ERROR,rawError:e})}finally{l()}},t=({authToken:n,businessId:i,product:t,service:s})=>async({onSuccess:a,onError:c})=>{var l,v,d,u;try{const y=await s.postProvisioning(n,i,t);if(!(null==y?void 0:y.data)||y.error){const n=null!==(d=null!==(l=null==y?void 0:y.error)&&void 0!==l?l:null===(v=null==y?void 0:y.errors)||void 0===v?void 0:v[0])&&void 0!==d?d:"Provisioning request failed";return c({error:e(n),code:o(null===(u=null==y?void 0:y.error)||void 0===u?void 0:u.code),severity:r.ERROR})}a(y)}catch(e){const n=o(null==e?void 0:e.code);return c({error:e.message||e,code:n,severity:r.ERROR})}},s=({authToken:n,identityId:i,service:t})=>async({onSuccess:s,onError:a,final:c=()=>{}})=>{var l;try{const c=await t.fetchIdentity(i,n);if(c.error){return a({error:e(c.error),code:o(null===(l=c.error)||void 0===l?void 0:l.code),severity:r.ERROR})}s(c)}catch(e){const n=o(null==e?void 0:e.code);return a({error:e.message||e,code:n,severity:r.ERROR})}finally{c()}},a=({authToken:n,identityId:i,service:t})=>async({payload:s,onSuccess:a,onError:c,final:l=()=>{}})=>{var v;try{const l=await t.patchIdentity(n,i,s);if(l.error){return c({error:e(l.error),code:o(null===(v=l.error)||void 0===v?void 0:v.code),severity:r.ERROR})}a(l)}catch(e){const n=o(null==e?void 0:e.code);return c({error:e.message||e,code:n,severity:r.ERROR})}finally{l()}},c=({authToken:n,service:i})=>async({payload:t,onSuccess:s,onError:a,final:c=()=>{}})=>{var l;try{const c=await i.postIdentity(n,t);if(c.error){return a({error:e(c.error),code:o(null===(l=c.error)||void 0===l?void 0:l.code),severity:r.ERROR})}s(c)}catch(e){const n=o(null==e?void 0:e.code);return a({error:e.message||e,code:n,severity:r.ERROR})}finally{c()}},l=({authToken:n,service:i})=>async({payload:t,onSuccess:s,onError:a,final:c=()=>{}})=>{var l;try{const c=await i.postBankAccount(n,t);if(c.error){return a({error:e(c.error),code:o(null===(l=c.error)||void 0===l?void 0:l.code),severity:r.ERROR})}s(c)}catch(e){const n=o(null==e?void 0:e.code);return a({error:e.message||e,code:n,severity:r.ERROR})}finally{c()}},v=({authToken:n,service:i})=>async({payload:t,onSuccess:s,onError:a,final:c=()=>{}})=>{var l;try{const c=await i.postDocumentRecord(n,t);if(c.error){return a({error:e(c.error),code:o(null===(l=c.error)||void 0===l?void 0:l.code),severity:r.ERROR})}s(c)}catch(e){const n=o(null==e?void 0:e.code);return a({error:e.message||e,code:n,severity:r.ERROR})}finally{c()}};export{i as a,t as b,l as c,v as d,s as e,a as f,c as g,n as m}