Liferay.Loader.define("layout-taglib@11.0.7/select_layout/js/SelectLayoutTree.es",["module","exports","require","@frontend-taglib-clay$clayui/core","@frontend-taglib-clay$clayui/empty-state","@frontend-taglib-clay$clayui/form","@frontend-taglib-clay$clayui/icon","frontend-js-web","liferay!frontend-js-react-web$react"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.SelectLayoutTree=function({filter:t,followURLOnTitleClick:a,itemSelectorSaveEvent:c,items:d=[],multiSelection:f,selectedLayoutIds:s}){const[y,m]=(0,u.useState)(d),[p,g]=(0,u.useState)(new Set(s)),b=(0,u.useMemo)((()=>t?e(y,t):y),[y,t]),v=(0,u.useRef)(new Map),w=(e,t)=>{if(t.toggle(e.id),t.has(e.id)?v.current.delete(e.id):v.current.set(e.id,{groupId:e.groupId,id:e.id,layoutId:e.layoutId,name:e.value,privateLayout:e.privateLayout,returnType:e.returnType,title:e.name,value:e.payload}),v.current.size)if(a)(0,o.getOpener)().document.location.href=e.url;else{const e=Array.from(v.current.values());Liferay.fire(c,{data:e}),(0,o.getOpener)().Liferay.fire(c,{data:e})}},h=(e,t)=>{const a={groupId:e.groupId,id:e.id,layoutId:e.layoutId,name:e.value,privateLayout:e.privateLayout,returnType:e.returnType,title:e.name,value:e.payload};Liferay.fire(c,{data:a}),(0,o.getOpener)().Liferay.fire(c,{data:a}),requestAnimationFrame((()=>{t.toggle(e.id)}))},L=(e,t,r,n)=>{e.preventDefault(),a?(0,o.getOpener)().document.location.href=t.url:t.disabled?n.toggle(t.id):f?w(t,r):h(t,r)},E=(e,t,a)=>{" "!==e.key&&"Enter"!==e.key||(e.stopPropagation(),f?w(t,a):h(t,a))};return b.length?u.default.createElement(r.TreeView,{items:b,onItemsChange:e=>m(e),onSelectionChange:e=>g(e),selectedKeys:p,selectionMode:f?"multiple":"single",showExpanderOnHover:!1},((e,t,a)=>u.default.createElement(r.TreeView.Item,{active:!1},u.default.createElement(r.TreeView.ItemStack,{active:!1,onClick:r=>L(r,e,t,a),onKeyDown:a=>E(a,e,t)},f&&!e.disabled&&u.default.createElement(l.ClayCheckbox,{onChange:()=>w(e,t),tabIndex:"-1"}),u.default.createElement(i.default,{symbol:e.icon}),u.default.createElement("div",{className:"d-flex"},u.default.createElement("span",{className:"flex-grow-0",title:e.url},e.name))),u.default.createElement(r.TreeView.Group,{items:e.children},(e=>u.default.createElement(r.TreeView.Item,{disabled:e.disabled,expanderDisabled:!1,onClick:a=>L(a,e,t),onKeyDown:a=>E(a,e,t)},f&&!e.disabled&&u.default.createElement(l.ClayCheckbox,{onChange:()=>w(e,t),tabIndex:"-1"}),u.default.createElement(i.default,{symbol:e.icon}),u.default.createElement("div",{className:"d-flex"},u.default.createElement("span",{className:"flex-grow-0",title:e.url},e.name)))))))):u.default.createElement(n.default,{description:Liferay.Language.get("try-again-with-a-different-search"),imgSrc:"".concat(themeDisplay.getPathThemeImages(),"/states/search_state.gif"),small:!0,title:Liferay.Language.get("no-results-found")})};var r=a("@frontend-taglib-clay$clayui/core"),n=d(a("@frontend-taglib-clay$clayui/empty-state")),l=a("@frontend-taglib-clay$clayui/form"),i=d(a("@frontend-taglib-clay$clayui/icon")),o=a("frontend-js-web"),u=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var a={},r=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var l=r?Object.getOwnPropertyDescriptor(e,n):null;l&&(l.get||l.set)?Object.defineProperty(a,n,l):a[n]=e[n]}a.default=e,t&&t.set(e,a);return a}(a("liferay!frontend-js-react-web$react"));function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function d(e){return e&&e.__esModule?e:{default:e}}const e=(e,t)=>e.reduce((function e(a,r){var n;return(null===(n=r.name)||void 0===n?void 0:n.toLowerCase().includes(t.toLowerCase()))?a.push(r):r.children&&a.concat(r.children.reduce(e,a)),a}),[])}}));
//# sourceMappingURL=SelectLayoutTree.es.js.map