Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/diagram-builder/util/populateAssignmentsData",["module","exports","require","portal-workflow-kaleo-designer-web$react-flow-renderer","../../util/fetchUtil","../components/sidebar/sections/assignments/utils"],(function(e,t,s){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var a=s("portal-workflow-kaleo-designer-web$react-flow-renderer"),r=s("../../util/fetchUtil"),n=s("../components/sidebar/sections/assignments/utils");function i(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),s.push.apply(s,a)}return s}function o(e){for(var t=1;t<arguments.length;t++){var s=null!=arguments[t]?arguments[t]:{};t%2?i(Object(s),!0).forEach((function(t){l(e,t,s[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):i(Object(s)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(s,t))}))}return e}function l(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}var d=(e,t,s)=>{for(let i=0;i<e.length;i++){const l=e[i];if((0,a.isNode)(l)&&"task"===l.type&&l.data.assignments){const a=(0,n.getAssignmentType)(l.data.assignments);if("user"===a){const a=[];let n=Object.keys(l.data.assignments)[1];const i=Object.values(l.data.assignments)[1],d=()=>{a.length?(l.data.assignments.sectionsData=a,t([...e])):(delete l.data.assignments.sectionsData,l.data.assignments.emailAddress?(delete l.data.assignments.emailAddress,s((e=>o(o({},e),{},{errorMessage:Liferay.Language.get("please-enter-a-valid-email-address"),errorType:"assignment"})))):l.data.assignments.screenName?(delete l.data.assignments.screenName,s((e=>o(o({},e),{},{errorMessage:Liferay.Language.get("please-enter-a-valid-screen-name"),errorType:"assignment"})))):l.data.assignments.userId&&(delete l.data.assignments.userId,s((e=>o(o({},e),{},{errorMessage:Liferay.Language.get("please-enter-a-valid-user-id"),errorType:"assignment"})))))};"screenName"===n?n="alternateName":"userId"===n&&(n=n.toLocaleLowerCase().replace("user","")),(0,r.retrieveUsersBy)(n,i).then((e=>e.json())).then((({items:e})=>{e.forEach(((e,t)=>{a.push({emailAddress:e.emailAddress,identifier:"".concat(Date.now(),"-").concat(t),name:e.name,screenName:e.alternateName,userId:e.id})}))})).then((()=>d()))}else"roleId"===a&&(0,r.retrieveRolesBy)("roleId",l.data.assignments.roleId).then((e=>e.json())).then((s=>{e[i].data.assignments.sectionsData={id:s.id,name:s.name,roleType:s.roleType},t([...e])}))}}};t.default=d}}));
//# sourceMappingURL=populateAssignmentsData.js.map