import r from"@babel/runtime/helpers/asyncToGenerator";import e from"@babel/runtime/helpers/slicedToArray";import t from"@babel/runtime/regenerator";import{jsx as n}from"react/jsx-runtime";import{useState as o,useCallback as a,useMemo as c,useEffect as u}from"react";import{FilesLoaderV2 as i}from"../FilesLoaderV2/FilesLoaderV2.js";var l=function(l){var s=l.onStatusChange,f=l.file,m=l.processFile,p=l.onDelete,d=l.formatProgress,v=o({total:0,current:0}),b=e(v,2),x=b[0],g=b[1],h=o(),k=e(h,2),y=k[0],w=k[1],C=o(!1),F=e(C,2),T=F[0],j=F[1],D=o(),E=e(D,2),L=E[0],P=E[1],S=a((function(r,e){g({total:r,current:e})}),[]),V=c((function(){if(L)return function(){L(),j(!0),s({success:!1,cancelled:!0,file:f})}}),[L]),A=a((function(){var e=!1;return function(){var n=r(t.mark((function r(n){var o,a,c,u;return t.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,o=function(){e||S.apply(void 0,arguments)},a=function(r){P((function(){return function(){e=!0,r()}}))},r.next=5,m(n,o,a);case 5:if(c=r.sent,!e){r.next=8;break}return r.abrupt("return");case 8:g((function(r){var e=r.total;return{total:e,current:e}})),s({success:!0,cancelled:!1,data:c,file:n}),r.next=19;break;case 12:if(r.prev=12,r.t0=r.catch(0),!e){r.next=16;break}return r.abrupt("return");case 16:u=r.t0 instanceof Error?r.t0:new Error(String(r.t0)),w(u),s({success:!1,cancelled:!1,error:u,file:n});case 19:case"end":return r.stop()}}),r,null,[[0,12]])})));return function(r){return n.apply(this,arguments)}}()}),[m,s]),G=a((function(){w(void 0),j(!1),s({file:f,success:!1,data:void 0,error:void 0,cancelled:!1}),A()(f)}),[f,A,s]),R=a((function(){p(f)}),[p,f]);u((function(){A()(f)}),[f,A]);var q=y?null==y?void 0:y.message:T?"Cancelled":null;return n(i,{name:f.name,total:x.total,current:x.current,errorText:null!=q?q:void 0,onCancel:V,onReload:G,onDelete:R,formatProgress:d})};export{l as Processor};
//# sourceMappingURL=Processor.js.map
