import{r as e}from"./chunk-QTnfLwEv.js";import{n as t}from"./index-7yDgay5u.js";import{o as n}from"./jsx-runtime-DHSfUA5-.js";import{P as r,R as i,z as a}from"./test.id-DxQrYxPk.js";import{t as o}from"./diaryService-CNt2_Lb5.js";import{a as s,n as c}from"./fileAssetService-gA4Q8V3n.js";import{t as l}from"./useLoadingToast-BBb6RyKX.js";var u=e(n(),1);function d({notebookId:e,onSuccess:n}){let d=r(o),f=r(c),p=r(i),m=l(),[h,g]=(0,u.useState)(!1),_=(0,u.useRef)(!1);return{uploading:h,pick:(0,u.useCallback)(async()=>{if(!e||_.current)return;_.current=!0,g(!0);let r;try{let i=await p.pickImageBlob(a.Photos);if(!i)return;r=m({message:t(`common.uploading`,`Uploading...`)});let o=s(await f.uploadImage(i,{thumbnail:!0}),e);d.addAttachment(o),await n(o,e)}catch{}finally{r?.dispose(),_.current=!1,g(!1)}},[d,f,p,e,n,m])}}export{d as t};
//# sourceMappingURL=usePickNotebookImageFromAlbum-DN3QeK7W.js.map