import{r as o,a3 as P,a4 as b}from"./index-Bf3Szspx.js";function y({onChange:a,errorCallback:r}){const[l,u]=o.useState(!1),[c,i]=o.useState(0),[g,f]=o.useState(()=>()=>null),p=P();function t(){u(!1),i(0)}async function s(h,m,e){const{errorSnackbar:S=!0}=e||{};u(!0);try{const n=await b.uploadFileWithProgress(h,m,w=>i(w),f);return a({customData:{name:"googleCloudStorageUriPrefix",value:n.googleCloudStorageUriPrefix}}),t(),n.filename}catch(n){if(S&&p.showError("common.errors.generic"),t(),r&&typeof r=="function")r(n);else throw n}}function d(){g(),t()}return{uploading:l,progress:c,abort:d,uploadFile:s}}function U({errorCallback:a,entity:r,entityId:l}={}){const[u,c]=o.useState(!1),[i,g]=o.useState(0),[f,p]=o.useState(()=>()=>null),t=P();function s(){c(!1),g(0)}async function d(m){c(!0);try{const e=await b.uploadImageWithProgress({file:m,onProgress:S=>g(S),setAbort:p,entity:r,entityId:l});return s(),e}catch(e){if(t.showError("common.errors.generic"),s(),typeof a=="function")a(e);else throw e}}function h(){f(),s()}return{uploading:u,progress:i,abort:h,uploadImage:d}}export{U as a,y as u};