Liferay.Loader.define("portal-workflow-kaleo-designer-web@5.0.85/designer/js/definition-builder/source-builder/xmlSchemaUtil",["module","exports","require","../util/utils"],(function(e,t,n){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var o=n("../util/utils");function r(e){const t=[];return Object.entries(e).map((e=>{const n=e[1].attributes;n&&Object.entries(n).map((e=>{t.push({[e[1].value]:e[1].ownerElement.textContent})}))})),t}function l(e,t){let n=e.locator||e.key||e;"taskTimers"===n&&(n="task-timers");const o=t.ownerDocument||t;let l,a;const s={};if(void 0!==o.evaluate)for(l=o.evaluate(n,t,o.createNSResolver(t.ownerDocument?t.ownerDocument.documentElement:t.documentElement),0,null);a=l.iterateNext();){const e=r(a.childNodes);if(e.length)s.content=e;else if(a.children.length){const e=[];for(const t of a.children){const n={};if(t.children.length)for(const e of t.children)if(e.children.length){let t,o=[],l=[];for(const a of e.children){o=r(a.childNodes);for(const e of a.childNodes)if(e.children)for(const t of e.children){const o="name"===t.tagName?"".concat(e.tagName,"-name"):t.tagName;n[o]||(n[o]=[]),n[o].push(t.textContent)}const s=r(e.childNodes);let c;if(o.length)c=o;else{if(s.length){c=s,s.length&&(n[e.tagName]||(n[e.tagName]=[]),n[e.tagName]=c);break}if(a.children.length){t?t!==a.tagName&&(l=[]):t=a.tagName,t=a.tagName;const e={};for(const t of a.children)if(t.children.length)for(const e of t.children){const t={};t[e.tagName]=e.textContent,l.push(t)}else e[t.tagName]=t.textContent;l.push(e)}else c=a.textContent,n[a.tagName]||(n[a.tagName]=[]),n[a.tagName].push(c)}n[t]=l}const a=e.attributes;if(a&&a.length)for(let e=0;e<a.length;e++)n[a[e].name]=a[e].value}else{const t=r(e.childNodes);let o;o=t.length?t:e.textContent,n[e.tagName]?n[e.tagName]=[n[e.tagName],o]:n[e.tagName]=o}else{const e=r(t.childNodes);let o;o=e.length?e:t.textContent,n[t.tagName]=o}e.push(n)}s.content=e}else s.content=a.textContent}return function(e,t){return t.parser&&t.parser instanceof Function&&(e.content=t.parser.call(this,e.content)),e}(s,e)}var a={applySchema(e,t){const n=t;let r={meta:{},results:[]};return n&&n.nodeType&&(9===n.nodeType||1===n.nodeType||11===n.nodeType)&&e?(r=function(e,t,n){if(e.resultListLocator&&Array.isArray(e.resultFields)){const o=t.getElementsByTagName(e.resultListLocator),r=e.resultFields,a=[];let s,c,i,u,d;if(o.length){for(u=o.length-1;u>=0;u--){for(i={},s=o[u],d=r.length-1;d>=0;d--){c=r[d];const e=l(c,s);i[c.key||c]=e.content,e.attributes&&(i.metaAttributes=e.attributes)}a[u]=i}n.results=a}else n.error=new Error("XML schema result nodes retrieval failure")}return n}(e,n,r),r=function(e,t,n){if((0,o.isObject)(e)){const o=t.ownerDocument||t;for(var r in e)Object.keys(e).includes(r)&&(n.meta[r]=l(e[r],o).content)}return n}(e.metaFields,n,r)):r.error=new Error("XML schema parse failure"),r}};t.default=a}}));
//# sourceMappingURL=xmlSchemaUtil.js.map