Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.115/designer/js/definition-builder/diagram-builder/components/sidebar/sections/timers/select-action/ActionTypeReassignment",["module","exports","require","liferay!frontend-js-react-web$react","../../../../../../util/fetchUtil","../select-reassignment/AssetCreator","../select-reassignment/ResourceActions","../select-reassignment/Role","../select-reassignment/RoleType","../select-reassignment/ScriptedReassignment","../select-reassignment/SelectReassignment","../select-reassignment/User"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();if(t&&t.has(e))return t.get(e);var n={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var s in e)if(Object.prototype.hasOwnProperty.call(e,s)){var i=r?Object.getOwnPropertyDescriptor(e,s):null;i&&(i.get||i.set)?Object.defineProperty(n,s,i):n[s]=e[s]}n.default=e,t&&t.set(e,n);return n}(n("liferay!frontend-js-react-web$react")),s=n("../../../../../../util/fetchUtil"),i=_interopRequireDefault(n("../select-reassignment/AssetCreator")),a=_interopRequireDefault(n("../select-reassignment/ResourceActions")),o=_interopRequireDefault(n("../select-reassignment/Role")),c=_interopRequireDefault(n("../select-reassignment/RoleType")),l=_interopRequireDefault(n("../select-reassignment/ScriptedReassignment")),u=n("../select-reassignment/SelectReassignment"),d=_interopRequireDefault(n("../select-reassignment/User"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _objectWithoutProperties(e,t){if(null==e)return{};var n,r,s=function _objectWithoutPropertiesLoose(e,t){if(null==e)return{};var n,r,s={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(s[n]=e[n]);return s}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(s[n]=e[n])}return s}const e={assetCreator:i.default,resourceActions:a.default,roleId:o.default,roleType:c.default,scriptedReassignment:l.default,user:d.default};var _default=({actionData:t,actionSectionsIndex:n,identifier:i,sectionsLength:a,setActionSections:o,setContentName:c,setErrors:l})=>{var d;const f=t.assignmentType,[m,p]=(0,r.useState)((null==t||null===(d=t.users)||void 0===d?void 0:d.length)&&t.users.some((({emailAddress:e})=>e))?t.users:[{identifier:"".concat(Date.now(),"-0")}]);(0,r.useEffect)((()=>{"user"===f&&o((e=>{const t=[...e];return t[n].assignmentType="user",t[n].users=m,t}))}),[m]),(0,r.useEffect)((()=>{var e;if((null==t||null===(e=t.users)||void 0===e?void 0:e.length)&&t.users.some((({emailAddress:e})=>e))){const e=[];(0,s.retrieveUsersBy)("emailAddress",t.users.map((({emailAddress:e})=>e))).then((e=>e.json())).then((({items:t})=>{t.forEach(((t,n)=>{e.push({emailAddress:t.emailAddress,identifier:"".concat(Date.now(),"-").concat(n),name:t.name,screenName:t.alternateName,userId:t.id})}))})).then((()=>{p(e)}))}}),[]);const g=e[f];return r.default.createElement(r.default.Fragment,null,r.default.createElement(u.SelectReassignment,{currentAssignmentType:f,setSection:e=>{o((t=>{const r=[...t];return r[n].assignmentType=e,r}))},setSubSections:p}),m.map(((e,s)=>{let{identifier:u}=e,d=_objectWithoutProperties(e,["identifier"]);return g&&r.default.createElement(g,{actionData:t,actionSectionsIndex:n,currentAssignmentType:f,identifier:i,index:s,key:"section-".concat(u),reassignmentType:f,restProps:d,sectionsLength:a,setActionSections:o,setContentName:c,setErrors:l,setSections:p,subSectionIdentifier:u,subSectionsLength:m.length})})))};t.default=_default}}));
//# sourceMappingURL=ActionTypeReassignment.js.map