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