Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/source-builder/utils",["module","exports","require","./constants"],(function(e,s,n){window;{Object.defineProperty(s,"__esModule",{value:!0}),s.parseActions=r,s.parseAssignments=function(e){const s={},n=[],i=[],r=[],t=[],a=Object.keys(e.assignments[0])[0];e.assignments.forEach((e=>{const a=Object.keys(e);a.includes("resource-action")?(s.assignmentType=["resourceActions"],s.resourceAction=e["resource-action"]):a.includes("role-id")?(s.assignmentType=["roleId"],s.roleId=parseInt(e["role-id"],10)):a.includes("role-type")?(s.assignmentType=["roleType"],n.push(e["auto-create"]),i.push(e.name),r.push(e["role-type"])):a.includes("script")?(s.assignmentType=["scriptedAssignment"],s.script=[e.script],s.scriptLanguage=e["script-language"]):a.includes("user")?s.assignmentType=["user"]:a.includes("email-address")?(s.assignmentType=["user"],t.push(e["email-address"])):a.includes("user-id")?(s.assignmentType=["user"],t.push(e["user-id"])):a.includes("screen-name")&&(s.assignmentType=["user"],t.push(e["screen-name"]))})),t.length&&("email-address"===a&&(s.emailAddress=t),"user-id"===a&&(s.userId=t),"screen-name"===a&&(s.screenName=t));"roleType"===s.assignmentType[0]&&(s.autoCreate=n[0],s.roleName=i[0],s.roleType=r[0]);return s},s.parseReassignments=t,s.parseNotifications=function(e){const s={notificationTypes:[],recipients:[]};return e.notifications.forEach(((e,n)=>{s.description=a(s,e,"description"),s.executionType=a(s,e,"execution-type"),s.name=a(s,e,"name"),s.receptionType=a(s,e,"receptionType");let r=a(s,e,"notification-type");if(Array.isArray(r[0])){const e=[];r[0].forEach((s=>{e.push({notificationType:s})})),r=e}else r=[{notificationType:r[0]}];if(s.notificationTypes[n]=r,s.template=a(s,e,"template"),s.templateLanguage=a(s,e,"template-language"),e.assignees)s.recipients[n]={assignmentType:["taskAssignees"]};else if(e.user){if(e.user.some((e=>e["email-address"]))){const i=[];e.user.forEach((e=>{i.push(e["email-address"])})),s.recipients[n]={assignmentType:["user"],emailAddress:i}}if(e.user.some((e=>e["user-id"]))){const i=[];e.user.forEach((e=>{i.push(e["user-id"])})),s.recipients[n]={assignmentType:["user"],userId:i}}if(e.user.some((e=>e["screen-name"]))){const i=[];e.user.forEach((e=>{i.push(e["screen-name"])})),s.recipients[n]={assignmentType:["user"],screenName:i}}}else if(e["role-type"])s.recipients[n]={assignmentType:["roleType"],autoCreate:e["auto-create"],roleName:e["role-name"],roleType:e["role-type"]};else if(e["role-id"])s.recipients[n]={assignmentType:["roleId"],roleId:e["role-id"][0]};else if(e["scripted-recipient"]){const r=e["scripted-recipient"][0],t=r.script,a=r["script-language"];s.recipients[n]={assignmentType:["scriptedRecipient"],script:[t],scriptLanguage:a||[i.DEFAULT_LANGUAGE]}}else s.recipients[n]={assignmentType:["user"]}})),s},s.parseTimers=function(e){const s={delay:[],reassignments:[],timerActions:[],timerNotifications:[]};return e.taskTimers.forEach(((n,i)=>{s.delay.push({duration:e.taskTimers[i].duration,scale:e.taskTimers[i].scale}),s.reassignments.push(e.taskTimers[i].reassignments?t({assignments:e.taskTimers[i].reassignments}):{}),s.timerActions.push(e.taskTimers[i]["timer-action"]?r({actions:e.taskTimers[i]["timer-action"]}):{}),s.timerNotifications.push({}),s.name=a(s,n,"name"),s.description=a(s,n,"description"),s.blocking=a(s,n,"blocking")})),s};var i=n("./constants");function r(e){const s={};return e.actions.forEach((e=>{s.name=a(s,e,"name"),s.description=a(s,e,"description"),s.executionType=a(s,e,"execution-type"),s.priority=a(s,e,"priority"),s.script=a(s,e,"script"),s.scriptLanguage=a(s,e,"script-language")})),s}function t(e){const s={},n=[],i=[],r=[],t=[],a=Object.keys(e.assignments[0])[0];return e.assignments.forEach((e=>{const a=Object.keys(e);a.includes("resource-action")?(s.assignmentType=["resourceActions"],s.resourceAction=e["resource-action"]):a.includes("role")?(s.assignmentType=["roleId"],s.roleId=parseInt(e.role,10)):a.includes("role-type")?(s.assignmentType=["roleType"],n.push(e["auto-create"]),i.push(e.name),r.push(e["role-type"])):a.includes("script")?(s.assignmentType=["scriptedAssignment"],s.script=[e.script],s.scriptLanguage=e["script-language"]):a.includes("user")?s.assignmentType=["user"]:a.includes("email-address")?(s.assignmentType=["user"],t.push(e["email-address"])):a.includes("user-id")?(s.assignmentType=["user"],t.push(e["user-id"])):a.includes("screen-name")&&(s.assignmentType=["user"],t.push(e["screen-name"]))})),t.length&&("email-address"===a&&(s.emailAddress=t),"user-id"===a&&(s.userId=t),"screen-name"===a&&(s.screenName=t)),"roleType"===s.assignmentType[0]&&(s.autoCreate=n[0],s.roleName=i[0],s.roleType=r[0]),s}function a(e,s,n){let i=n;return"execution-type"===n?i="executionType":"template-language"===n&&(i="templateLanguage"),Array.isArray(e[i])?(e[i].push(s[n]),e[i]):new Array(s[n])}}}));
//# sourceMappingURL=utils.js.map