import{__assign as e,__spreadArray as n}from'./../../ext-esm/tslib/tslib.es6.js';import{jsxs as r,jsx as t}from"react/jsx-runtime";import{useState as o,useEffect as i,useCallback as s}from"react";import{FilesDropzone as u}from"../FilesDropzone/FilesDropzone.js";import"../../utils/index.js";import{FilesLoaderV2 as c}from"../FilesLoaderV2/FilesLoaderV2.js";import{useStyles as l}from"./styles.js";import a from"classnames";import{Processor as f}from"./Processor.js";var m=function(m){var p=m.multiple,d=m.accept,v=m.className,g=m.processFile,h=m.value,F=void 0===h?[]:h,j=m.onDone,x=m.onDelete,D=m.maxFiles,z=m.maxSize,N=m.formatProgress,P=l(),S=o([]),b=S[0],y=S[1];i((function(){b.length>0&&b.every((function(e){return"success"in e}))&&b.some((function(e){return e.success}))&&(y((function(e){return e.filter((function(e){return!e.success}))})),j(b.filter((function(e){return e.success})).map((function(e){return e.data}))))}),[b]);var L=s((function(e){y((function(n){return n.filter((function(n){return n.file!==e}))}))}),[]),V=s((function(n){y((function(r){return r.map((function(r){return r.file===n.file?e(e({},r),{data:n.data,success:n.success}):r}))}))}),[]),C=s((function(e){var r=e.map((function(e){return{file:e}}));y((function(e){return n(n([],e,!0),r,!0)}))}),[]);return r("div",e({className:a(P.root,v)},{children:[(p||0===b.length&&0===(null==F?void 0:F.length))&&t(u,{multiple:p,onDrop:C,accept:d,maxFiles:D,maxSize:z}),(b.length>0||(null==F?void 0:F.length)>0)&&r("div",e({className:P.files},{children:[b.map((function(e){return t(f,{processFile:g,onStatusChange:V,file:e.file,onDelete:L,formatProgress:N},"".concat(e.file.size,"|").concat(e.file.name))})),null==F?void 0:F.map((function(e){return t(c,{name:e.name,onDelete:x?function(){return x(e)}:void 0,total:0,current:0})}))]}))]}))};export{m as FilesProcessor};
