Liferay.Loader.define("knowledge-base-web@5.0.98/admin/js/components/NavigationPanel",["module","exports","require","@frontend-taglib-clay$clayui/core","@frontend-taglib-clay$clayui/icon","liferay!frontend-js-react-web$classnames","frontend-js-web","liferay!frontend-js-react-web$prop-types","liferay!frontend-js-react-web$react","../utils/getSearchItems","../utils/normalizeItems","../utils/showSuccessMessage","./ActionsDropdown","./SearchField"],(function(e,t,r){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function NavigationPanel({items:t,moveKBObjectURL:r,portletNamespace:l,selectedItemId:y}){const g=(0,c.useMemo)((()=>(0,u.default)(t,l)),[t,l]),w=(0,c.useMemo)((()=>(0,s.default)(t)),[t]),[h,b]=(0,c.useState)(!1),handleClickItem=(e,t)=>{e.defaultPrevented||(e.stopPropagation(),e.preventDefault(),(0,o.navigate)(t.href))};return c.default.createElement(c.default.Fragment,null,c.default.createElement(p.default,{handleSearchChange:({isSearchActive:e})=>{b(e)},items:w}),!h&&c.default.createElement(a.TreeView,{defaultItems:g,defaultSelectedKeys:new Set([y]),dragAndDrop:!0,nestedKey:"children",onItemMove:(e,t,a)=>{var n;return e.type===m.folder&&t.type===m.article?((0,o.openToast)({message:Liferay.Language.get("folders-cannot-be-moved-into-articles"),type:"danger"}),!1):((0,o.fetch)(r,{body:(0,o.objectToFormData)({["".concat(l,"dragAndDrop")]:!0,["".concat(l,"position")]:null!==(n=null==a?void 0:a.next)&&void 0!==n?n:-1,["".concat(l,"resourceClassNameId")]:e.classNameId,["".concat(l,"resourcePrimKey")]:e.id,["".concat(l,"parentResourceClassNameId")]:t.classNameId,["".concat(l,"parentResourcePrimKey")]:t.id}),method:"POST"}).then((e=>{if(!e.ok)throw new Error;return e.json()})).then((e=>{if(!e.success)throw new Error(e.errorMessage);(0,d.default)(l)})).catch((({message:e=Liferay.Language.get("an-unexpected-error-occurred")})=>{(0,o.openToast)({message:e,type:"danger"})})),!0)},showExpanderOnHover:!1},(t=>c.default.createElement(a.TreeView.Item,{actions:(0,f.default)({actions:t.actions}),onClick:e=>{handleClickItem(e,t)}},c.default.createElement(a.TreeView.ItemStack,{className:(0,i.default)({"knowledge-base-navigation-item-active":t.id===y})},c.default.createElement(n.default,{symbol:e[t.type]}),t.name),c.default.createElement(a.TreeView.Group,{items:t.children},(t=>c.default.createElement(a.TreeView.Item,{actions:(0,f.default)({actions:t.actions}),onClick:e=>{handleClickItem(e,t)}},c.default.createElement(n.default,{symbol:e[t.type]}),t.name)))))))};var a=r("@frontend-taglib-clay$clayui/core"),n=_interopRequireDefault(r("@frontend-taglib-clay$clayui/icon")),i=_interopRequireDefault(r("liferay!frontend-js-react-web$classnames")),o=r("frontend-js-web"),l=_interopRequireDefault(r("liferay!frontend-js-react-web$prop-types")),c=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 r={},a=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){var i=a?Object.getOwnPropertyDescriptor(e,n):null;i&&(i.get||i.set)?Object.defineProperty(r,n,i):r[n]=e[n]}r.default=e,t&&t.set(e,r);return r}(r("liferay!frontend-js-react-web$react")),s=_interopRequireDefault(r("../utils/getSearchItems")),u=_interopRequireDefault(r("../utils/normalizeItems")),d=_interopRequireDefault(r("../utils/showSuccessMessage")),f=_interopRequireDefault(r("./ActionsDropdown")),p=_interopRequireDefault(r("./SearchField"));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={article:"document-text",folder:"folder"},m={article:"article",folder:"folder"};const y={classNameId:l.default.string.isRequired,href:l.default.string.isRequired,id:l.default.string.isRequired,name:l.default.string.isRequired,type:l.default.oneOf(Object.keys(e)).isRequired};y.children=l.default.arrayOf(l.default.shape(y))}}));
//# sourceMappingURL=NavigationPanel.js.map