"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/asyncToGenerator"),t=require("@babel/runtime/helpers/slicedToArray"),r=require("@babel/runtime/regenerator"),n=require("react/jsx-runtime"),a=require("react"),u=require("../FilesLoader/FilesLoader.js");function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var o=c(e),l=c(t),i=c(r);exports.Processor=function(e){var t=e.onStatusChange,r=e.file,c=e.processFile,s=e.onDelete,f=e.formatProgress,d=a.useState({total:0,current:0,indeterminate:!0,complete:!1}),p=l.default(d,2),m=p[0],b=p[1],v=a.useState(),x=l.default(v,2),k=x[0],C=x[1],g=a.useState(!1),h=l.default(g,2),q=h[0],y=h[1],S=a.useState(),j=l.default(S,2),F=j[0],P=j[1],w=a.useCallback((function(e,t){b({total:e,current:t,indeterminate:!1,complete:!1})}),[]),E=a.useMemo((function(){if(F)return function(){F(),y(!0),t({success:!1,cancelled:!0,file:r})}}),[F,r,t]),L=a.useCallback((function(){var e=!1;return function(){var r=o.default(i.default.mark((function r(n){var a,u,o,l;return i.default.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,a=function(){e||w.apply(void 0,arguments)},u=function(t){P((function(){return function(){e=!0,t()}}))},r.next=5,c(n,a,u);case 5:if(o=r.sent,!e){r.next=8;break}return r.abrupt("return");case 8:b((function(e){var t=e.total;return{total:t,current:t,indeterminate:e.indeterminate,complete:!0}})),t({success:!0,cancelled:!1,data:o,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:l=r.t0 instanceof Error?r.t0:new Error(String(r.t0)),C(l),t({success:!1,cancelled:!1,error:l,file:n});case 19:case"end":return r.stop()}}),r,null,[[0,12]])})));return function(e){return r.apply(this,arguments)}}()}),[c,t,w]),D=a.useCallback((function(){C(void 0),y(!1),t({file:r,success:!1,data:void 0,error:void 0,cancelled:!1}),L()(r)}),[r,L,t]),M=a.useCallback((function(){s(r)}),[s,r]);a.useEffect((function(){L()(r)}),[r,L]);var T=q?"Cancelled":null,_=k?null==k?void 0:k.message:T;return n.jsx(u.FilesLoader,{name:r.name,total:m.total,current:m.current,error:_,onCancel:E,onReload:D,onDelete:M,formatProgress:f,complete:m.complete,indeterminate:m.indeterminate})};
//# sourceMappingURL=Processor.js.map
