Liferay.Loader.define("@liferay/content-dashboard-web@2.0.83/js/components/TreeFilter/treeUtils",["module","exports","require"],(function(e,r,n){window;{function ownKeys(e,r){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable}))),n.push.apply(n,t)}return n}function _objectSpread(e){for(var r=1;r<arguments.length;r++){var n=null!=arguments[r]?arguments[r]:{};r%2?ownKeys(Object(n),!0).forEach((function(r){_defineProperty(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ownKeys(Object(n)).forEach((function(r){Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function _defineProperty(e,r,n){return r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}function nodeTreeArrayMapper({childrenPropertyKey:e,namePropertyKey:r,nodeArray:n}){return n.map(((n,t)=>{var o;const i=!!(null===(o=n[e])||void 0===o?void 0:o.length);return _objectSpread(_objectSpread({},n),{},{children:i?nodeTreeArrayMapper({childrenPropertyKey:e,namePropertyKey:r,nodeArray:n[e]}):null,id:(({index:e,node:n})=>i?"_".concat(e):"".concat(n[r]))({index:t,node:n}),name:n[r]||n.label})}))}Object.defineProperty(r,"__esModule",{value:!0}),r.visit=function visit(e,r){e.forEach((e=>{r(e),e.children&&visit(e.children,r)}))},r.nodeTreeArrayMapper=nodeTreeArrayMapper,r.handleNodeName=function handleNodeName({childrenPropertyKey:e,node:r}){let n=(r.children||r[e]).length;n||(n=r[e].length);const t=n>1?Liferay.Language.get("items"):Liferay.Language.get("item");return"".concat(r.label," (").concat(n," ").concat(t,")")},r.filterNodes=function filterNodes({childrenPropertyKey:e,namePropertyKey:r,nodes:n,query:t}){const o=handleNodeFiltering({childrenPropertyKey:e,namePropertyKey:r,nodes:n,query:t});if(!o.length)return[];return o},r.getSelectedNodeObject=function getSelectedNodeObject({mandatoryFieldsForFiltering:e,node:r}){const n={};return e.forEach((e=>{n[e]=r[e]})),n},r.selectedDataOutputTransfomer=function selectedDataOutputTransfomer({data:e,mandatoryFieldsForFiltering:r}){if(!e.length||r.length>1)return e;return e.map((e=>e[r[0]]))};const handleNodeFiltering=({childrenPropertyKey:e,namePropertyKey:r,nodes:n,query:t})=>{const nodeHasChildren=e=>Array.isArray(e)&&!!e.length;return n.filter((n=>{var o;nodeHasChildren(n.children)&&(n.children=[...handleNodeFiltering({childrenPropertyKey:e,nodes:n.children,query:t})]);const i=n.name.toLowerCase().replace(/\(\d+ [a-z]+\)$/i,"").trim().includes(t);return i&&!nodeHasChildren(n.children)&&(null===(o=n[e])||void 0===o?void 0:o.length)&&(n.children=[...nodeTreeArrayMapper({childrenPropertyKey:e,namePropertyKey:r,nodeArray:n[e]})]),i||!i&&nodeHasChildren(n.children)}))}}}));
//# sourceMappingURL=treeUtils.js.map