import{u as d,bZ as H}from"./app-BgLa5dit.js";import{U as f}from"./q-IBKcuF.chunk.js";function c(s,e){return Object.keys(s||{}).reduce((U,i)=>(e[i]||(U[i]=s[i]),U),{})}const I=()=>{var p;const[s,e]=d(H.BULK_USER_UPLOAD);function g(r){e({users:r,invalidUsers:null,existingUsersHash:null}),u(r)}function U(r){const t=s.users.map(a=>a.lookupId!==r.lookupId?a:r);e({users:t,invalidUsers:c(s==null?void 0:s.invalidUsers,{[r.lookupId]:!0}),existingUsersHash:s==null?void 0:s.existingUsersHash}),u(t)}function i(r){var x;const t=r.reduce((n,h)=>(n[h]=!0,n),{}),a=s.users.filter(n=>!t[n.lookupId]);e({users:a,invalidUsers:c(s==null?void 0:s.invalidUsers,t),existingUsersHash:c(s==null?void 0:s.existingUsersHash,t),existingUserToAdd:(x=s==null?void 0:s.existingUserToAdd)==null?void 0:x.filter(n=>!!(s!=null&&s.existingUsersHash[n.lookupId]))}),u(a)}function u(r){const t=f.getNewDuplicates(r);e("duplicateSets",t)}return{users:s==null?void 0:s.users,invalidUsers:s==null?void 0:s.invalidUsers,hasValidatedUsers:!!(s!=null&&s.invalidUsers),existingUsersHash:(s==null?void 0:s.existingUsersHash)||{},hasExistingUsers:!!Object.keys((s==null?void 0:s.existingUsersHash)||{}).length,existingUserToAdd:s==null?void 0:s.existingUserToAdd,duplicateSets:s==null?void 0:s.duplicateSets,newUsers:((p=s==null?void 0:s.users)==null?void 0:p.filter(r=>{var t;return!((t=s==null?void 0:s.existingUsersHash)!=null&&t[r.lookupId])}))||[],setUsers:g,setInvalidUsers:r=>e("invalidUsers",r),setExistingUsers:r=>e("existingUsersHash",r),updateUser:U,deleteUsers:i}};export{I as u};
//# sourceMappingURL=DL8ott7R.chunk.js.map
