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