Liferay.Loader.define("knowledge-base-web@5.0.75/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","./ActionsDropdown"],(function(e,t,a){window;{Object.defineProperty(t,"__esModule",{value:!0}),t.default=function NavigationPanel({items:t,moveKBObjectURL:a,portletNamespace:l,selectedItemId:u}){const handleClickItem=(e,t)=>{e.defaultPrevented||(e.stopPropagation(),e.preventDefault(),(0,i.navigate)(t.href))};return c.default.createElement(r.TreeView,{defaultItems:t,defaultSelectedKeys:new Set([u]),dragAndDrop:!0,nestedKey:"children",onItemMove:(e,t,r)=>{var n;return e.type===s.folder&&t.type===s.article?((0,i.openToast)({message:Liferay.Language.get("folders-cannot-be-moved-into-articles"),type:"danger"}),!1):((0,i.fetch)(a,{body:(0,i.objectToFormData)({["".concat(l,"dragAndDrop")]:!0,["".concat(l,"position")]:null!==(n=null==r?void 0:r.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)})).catch((({message:e=Liferay.Language.get("an-unexpected-error-occurred")})=>{(0,i.openToast)({message:e,type:"danger"})})),!0)},showExpanderOnHover:!1},(t=>c.default.createElement(r.TreeView.Item,{actions:(0,d.default)({actions:t.actions}),onClick:e=>{handleClickItem(e,t)}},c.default.createElement(r.TreeView.ItemStack,{className:(0,o.default)({"knowledge-base-navigation-item-active":t.id===u})},c.default.createElement(n.default,{symbol:e[t.type]}),t.name),c.default.createElement(r.TreeView.Group,{items:t.children},(t=>c.default.createElement(r.TreeView.Item,{actions:(0,d.default)({actions:t.actions}),onClick:e=>{handleClickItem(e,t)}},c.default.createElement(n.default,{symbol:e[t.type]}),t.name))))))};var r=a("@frontend-taglib-clay$clayui/core"),n=_interopRequireDefault(a("@frontend-taglib-clay$clayui/icon")),o=_interopRequireDefault(a("liferay!frontend-js-react-web$classnames")),i=a("frontend-js-web"),l=_interopRequireDefault(a("liferay!frontend-js-react-web$prop-types")),c=_interopRequireDefault(a("liferay!frontend-js-react-web$react")),d=_interopRequireDefault(a("./ActionsDropdown"));function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}const e={article:"document-text",folder:"folder"},s={article:"article",folder:"folder"};const u={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};u.children=l.default.arrayOf(l.default.shape(u))}}));
//# sourceMappingURL=NavigationPanel.js.map