Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/source-builder/xmlUtil",["module","exports","require","../util/utils","./constants"],(function(e,_,R){window;Object.defineProperty(_,"__esModule",{value:!0}),_.default=void 0;var t=R("../util/utils"),T=R("./constants");var r={REGEX_TOKEN_1:/.+<\/\w[^>]*>$/,REGEX_TOKEN_2:/^<\/\w/,REGEX_TOKEN_3:/^<\w[^>]*[^/]>.*$/,create(e,_,R){const t=this.createObj(e,R);return t.open+(_||T.STR_BLANK)+t.close},createObj(e,_){let R=[T.STR_SPACE];const r=(0,t.uncamelize)(e,T.STR_DASH);void 0!==_&&_.xmlns&&(R=[T.STR_CHAR_CRLF]),_&&Object.entries(_).map((([e,t])=>{e&&(T.BUFFER_ATTR[0]=e,T.BUFFER_ATTR[2]=t,_.xmlns&&R.push(T.STR_CHAR_TAB),R.push(T.BUFFER_ATTR.join(T.STR_BLANK).trim()),_.xmlns&&R.push(T.STR_CHAR_CRLF))}));const E=R.join(T.STR_BLANK).trimRight();return T.BUFFER_CLOSE_NODE[1]=r,T.BUFFER_OPEN_NODE[1]=r,T.BUFFER_OPEN_NODE[2]=E,void 0!==_&&_.xmlns?T.BUFFER_OPEN_NODE[3]=T.STR_CHAR_CRLF+">":T.BUFFER_OPEN_NODE[3]=">",{close:T.BUFFER_CLOSE_NODE.join(T.STR_BLANK),open:T.BUFFER_OPEN_NODE.join(T.STR_BLANK)}},format(e){const _=this;let R=T.STR_BLANK,r=!1,E=0;return e.forEach((e=>{let n=0;if(r||(e.match(_.REGEX_TOKEN_1)?n=0:e.match(_.REGEX_TOKEN_2)?0!==E&&(E-=1):e.match(_.REGEX_TOKEN_3)&&(n=1),R+=(0,t.repeatSymbol)(T.STR_CHAR_TAB,E)),e.indexOf(T.STR_METADATA)>-1){const _=e.split(T.STR_CHAR_CR_LF_CRLF);e="";for(let R=0;R<_.length;R++)0!==R&&2!==R||(E+=1),R!==_.length-2&&R!==_.length-1||(E-=1),e+=(0,t.repeatSymbol)(T.STR_CHAR_TAB,E)+_[R]+T.STR_CHAR_CRLF}else if(e.indexOf(T.STR_CDATA_OPEN)>-1){let _=e.split(T.STR_CDATA_OPEN);e=(0,t.repeatSymbol)(T.STR_CHAR_TAB,E)+_[0],_=_[1].split(T.STR_CDATA_CLOSE),e+=(0,t.repeatSymbol)(T.STR_CHAR_TAB,E+1)+T.STR_CDATA_OPEN+_[0]+T.STR_CDATA_CLOSE+T.STR_CHAR_CRLF+(0,t.repeatSymbol)(T.STR_CHAR_TAB,E)+_[1].trim()}R+=e.trim()+T.STR_CHAR_CRLF,e.indexOf(T.STR_CDATA_CLOSE)>-1?r=!1:e.indexOf(T.STR_CDATA_OPEN)>-1&&(r=!0),E+=n})),R.trim()},validateDefinition(e){const _=(new DOMParser).parseFromString(e,"text/xml");let R=!0;return(null===_||null===_.documentElement||_.querySelector("parsererror"))&&(R=!1),R}};_.default=r}));
//# sourceMappingURL=xmlUtil.js.map