"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("@babel/runtime/helpers/toConsumableArray"),r=require("@babel/runtime/helpers/defineProperty"),t=require("@babel/runtime/helpers/slicedToArray"),n=require("react/jsx-runtime"),s=require("react"),o=require("../FilesDropzone/FilesDropzone.js"),u=require("../FilesLoaderV2/FilesLoaderV2.js"),i=require("./styles.js"),c=require("classnames"),l=require("./Processor.js");function a(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var f=a(e),p=a(r),d=a(t),m=a(c);function b(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),t.push.apply(t,n)}return t}function j(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?b(Object(t),!0).forEach((function(r){p.default(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):b(Object(t)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}exports.FilesProcessor=function(e){var r=e.multiple,t=e.accept,c=e.className,a=e.processFile,p=e.value,b=void 0===p?[]:p,v=e.onDone,y=e.onDelete,O=e.maxFiles,g=e.maxSize,P=e.formatProgress,h=e.onProcessingFailure,x=e.onStartProcessing,D=i.useStyles(),F=s.useState([]),q=d.default(F,2),S=q[0],w=q[1];s.useEffect((function(){S.length>0&&S.every((function(e){return"success"in e}))&&S.some((function(e){return e.success}))&&(w((function(e){return e.filter((function(e){return!e.success}))})),v(S.filter((function(e){return e.success})).map((function(e){return e.data}))))}),[S]);var z=s.useCallback((function(e){w((function(r){return r.filter((function(r){return r.file!==e}))}))}),[]),C=s.useCallback((function(e){e.success||null==h||h(e.file,e.cancelled,e.error),w((function(r){return r.map((function(r){return r.file===e.file?j(j({},r),{},{data:e.data,success:e.success}):r}))}))}),[]),k=s.useCallback((function(e){null==x||x(e);var r=e.map((function(e){return{file:e}}));w((function(e){return[].concat(f.default(e),f.default(r))}))}),[]);return n.jsxs("div",{className:m.default(D.root,c),children:[(r||0===S.length&&0===(null==b?void 0:b.length))&&n.jsx(o.FilesDropzone,{multiple:r,onDrop:k,accept:t,maxFiles:O,maxSize:g}),(S.length>0||(null==b?void 0:b.length)>0)&&n.jsxs("div",{className:D.files,children:[S.map((function(e){return n.jsx(l.Processor,{processFile:a,onStatusChange:C,file:e.file,onDelete:z,formatProgress:P},"".concat(e.file.size,"|").concat(e.file.name))})),null==b?void 0:b.map((function(e){return n.jsx(u.FilesLoaderV2,{name:e.name,onDelete:y?function(){return y(e)}:void 0,total:0,current:0})}))]})]})};
//# sourceMappingURL=FilesProcessor.js.map
