Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/source-builder/deserializeUtil",["module","exports","require","../constants","../util/utils","./constants","./utils","./xmlDefinition"],(function(e,t,i){var a;window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=d;var n=i("../constants"),s=i("../util/utils"),o=i("./constants"),l=i("./utils"),r=(a=i("./xmlDefinition"))&&a.__esModule?a:{default:a};function d(e){this.definition=new r.default({value:e})}d.prototype={getElements(){const e=[],t=[],i=[];return this.definition.forEachField(((e,t)=>{t.results.forEach((e=>{i.push(e.name)}))})),this.definition.forEachField(((a,r)=>{r.results.forEach((r=>{var d,u,c,f;(null===(d=r.actions)||void 0===d?void 0:d.length)&&(r.notifications=r.actions.filter((e=>{if(e.template)return e})),r.actions=r.actions.filter((e=>{if(e.script)return e})));const p={};let m=a;r.initial&&(m="start");const g=r.metadata&&JSON.parse(r.metadata);((null==g?void 0:g.terminal)||"state"===m&&!r.transitions&&!g)&&(m="end"),p.x=(null==g?void 0:g.xy[0])||Math.floor(800*Math.random()),p.y=(null==g?void 0:g.xy[1])||Math.floor(500*Math.random());let v={};var h;Array.isArray(r.labels)?null===(h=r.labels)||void 0===h||h.map((e=>{Object.entries(e).map((([e,t])=>{v[e]=(0,s.replaceTabSpaces)((0,s.removeNewLine)(t))}))})):v={[n.defaultLanguageId]:r.name};const y={description:r.description,label:v,script:r.script};var b;("condition"===m&&(y.scriptLanguage=r.scriptLanguage||o.DEFAULT_LANGUAGE),"task"===m)&&(null===(b=r.assignments)||void 0===b||b.forEach((e=>{const t=e["role-type"];null==t||t.forEach(((e,i)=>{"depot"===e&&(t[i]="asset library")}))})),r.assignments&&(y.assignments=(0,l.parseAssignments)(r)),r.taskTimers&&(y.taskTimers=(0,l.parseTimers)(r)),y.scriptLanguage=r.scriptLanguage||o.DEFAULT_LANGUAGE);let E;if(y.actions=(null===(u=r.actions)||void 0===u?void 0:u.length)&&(0,l.parseActions)(r),y.notifications=(null===(c=r.notifications)||void 0===c?void 0:c.length)&&(0,l.parseNotifications)(r),null===(f=r.notifications)||void 0===f||f.forEach((e=>{const t=e["role-type"];null==t||t.forEach(((e,i)=>{"depot"===e&&(t[i]="asset library")}))})),r.id)E=r.id;else{if(!r.name)return;E=r.name}e.push({data:y,id:E,position:p,type:m});const L=r.transitions;if(L){let a=null==L?void 0:L.find((e=>"true"===(null==e?void 0:e.default)));L.forEach((o=>{let l={};var r;Array.isArray(o.labels)?null===(r=o.labels)||void 0===r||r.map((e=>{Object.entries(e).map((([e,t])=>{l[e]=(0,s.replaceTabSpaces)((0,s.removeNewLine)(t))}))})):l={[n.defaultLanguageId]:o.name};let d;if(o.id)d=o.id;else{if(!o.name)return;d=o.name}t.includes(d)||i.includes(d)?d="".concat(E,"_").concat(d,"_").concat(o.target):t.push(d);const u="true"===(null==o?void 0:o.default)||!a;e.push({arrowHeadType:"arrowclosed",data:{defaultEdge:u,label:l},id:d,source:E,target:o.target,type:"transition"}),u&&!a&&(a=!0)}))}}))})),e},getMetadata(){return this.definition.getDefinitionMetadata()},updateXMLDefinition(e){this.definition=new r.default({value:e})}}}}));
//# sourceMappingURL=deserializeUtil.js.map