Liferay.Loader.define("product-navigation-control-menu-web@6.0.72/js/LayoutFinder",["module","exports","require","@frontend-taglib-clay$clayui/icon","@frontend-taglib-clay$clayui/loading-indicator","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","./useDebounceCallback"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var r=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/loading-indicator")),l=a("frontend-js-web"),o=(_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),function _interopRequireWildcard(e){if(e&&e.__esModule)return e;if(null===e||"object"!=typeof e&&"function"!=typeof e)return{default:e};var t=_getRequireWildcardCache();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"))),c=a("./useDebounceCallback");function _getRequireWildcardCache(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return _getRequireWildcardCache=function _getRequireWildcardCache(){return e},e}function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e=10;var u=function LayoutFinder({administrationPortletNamespace:t,administrationPortletURL:a,findLayoutsURL:u,keywords:i,namespace:d,productMenuPortletURL:s,setKeywords:f}){const[m,p]=(0,o.useState)([]),[g,y]=(0,o.useState)(!1),[b,h]=(0,o.useState)(0),L=(0,o.useCallback)((e=>{e.preventDefault(),e.stopPropagation()}),[]),[w,E]=(0,c.useDebounceCallback)((e=>{(0,l.fetch)(u,{body:(0,l.objectToFormData)({["".concat(d,"keywords")]:e}),method:"post"}).then((e=>e.ok?e.json():{layouts:[],totalCount:0})).then((e=>{y(!1),p(e.layouts),h(e.totalCount)}))}),1e3),k=(0,o.useCallback)((e=>{const t=e.target.value;f(t),t.length?(y(!0),w(t)):(y(!1),p([]),h(0),E())}),[E,f,w]),v=(0,o.useCallback)((()=>{Liferay.Portlet.destroy("#p_p_id".concat(d),!0),(0,l.setSessionValue)("com.liferay.product.navigation.product.menu.web_pagesTreeState","closed").then((()=>{(0,l.fetch)(s).then((e=>{if(!e.ok)throw new Error;return e.text()})).then((e=>{const t=document.querySelector(".lfr-product-menu-sidebar .sidebar-body");t.innerHTML="";const a=document.createRange();a.selectNode(t),t.appendChild(a.createContextualFragment(e))})).catch((()=>{(0,l.openToast)({message:Liferay.Language.get("an-unexpected-error-occurred"),title:Liferay.Language.get("error"),type:"danger"})}))}))}),[d,s]);return o.default.createElement("div",{className:"layout-finder"},o.default.createElement("button",{className:"back-to-menu btn btn-sm btn-unstyled mb-3 pr-3",onClick:v},o.default.createElement(r.default,{className:"icon-monospaced",symbol:"angle-left"}),"".concat(Liferay.Language.get("back-to-menu")," ")),o.default.createElement("form",{onSubmit:L,role:"search"},o.default.createElement("label",{className:"sr-only",htmlFor:"".concat(d,"-layout-finder-page-input")},"".concat(Liferay.Language.get("page-name"),": ")),o.default.createElement("input",{autoComplete:"off",className:"form-control form-control-sm",id:"".concat(d,"-layout-finder-page-input"),onChange:k,placeholder:Liferay.Language.get("start-typing-to-find-a-page"),type:"text",value:i})),b>0&&o.default.createElement(o.default.Fragment,null,o.default.createElement("nav",{className:"mt-2"},m.map(((t,a)=>a<e&&o.default.createElement(o.default.Fragment,null,o.default.createElement("ol",{className:"breadcrumb"},t.path&&!!t.path.length&&o.default.createElement(o.default.Fragment,null,t.path.map((e=>o.default.createElement("li",{className:"breadcrumb-item text-secondary",key:e},o.default.createElement("span",{className:"breadcrumb-text-truncate"},e))))),o.default.createElement("li",{className:"breadcrumb-item",key:t.name},o.default.createElement("a",{className:"d-block font-weight-bold mb-2 text-break",href:t.url,key:t.url,target:t.target},t.name))))))),b>e&&o.default.createElement("div",null,o.default.createElement("div",{className:"mb-3 mt-3 text-center"},(0,l.sub)(Liferay.Language.get("there-are-x-more-results-narrow-your-searc-to-get-more-precise-results"),b-e)),o.default.createElement("div",{className:"text-center"},o.default.createElement("a",{href:"".concat(a,"&").concat(t,"keywords=").concat(i)},Liferay.Language.get("view-in-page-administration"))))),g&&o.default.createElement(n.default,{className:"mb-0 mt-3",light:!0,small:!0}),0===b&&!g&&i.length>1&&o.default.createElement("div",{className:"mt-3 text-center"},Liferay.Language.get("page-not-found")))};t.default=u}}));
//# sourceMappingURL=LayoutFinder.js.map