!function(){"use strict";var e={n:function(t){var n=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(n,{a:n}),n},d:function(t,n){for(var r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[r]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r:function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t);var n=window.wp.element,r=window.wp.hooks,o=window.wp.i18n,i=window.nisje.app.plugins,s=window.nisje.app.routes,a=window.nisje.app.router,l=window.wp.data,c=window.nisje.components,p=window.nisje.app.api,u=window.nisje.app.components,d=window.nisje.app.utils;(0,p.registerCard)("nisje-blogs-group",(function(e){let{id:t}=e;const r=(0,l.useSelect)((e=>e("nisje/core").post(t)));if(!r)return null;const{group_id:o,title:i}=r,s=`/groups/${o}/blog/${t}/`;return(0,n.createElement)(c.BaseCard,{url:s},(0,n.createElement)(c.TextDeprecated,{as:"h2",variant:"title-medium"},(0,n.createElement)(u.Link,{to:s},(0,d.decodeEntities)(i.rendered))))}));var g=window.lodash,m=window.nisje.app.url,w=window.nisje.app.constants,E=window.nisje.interface,j=window.nisje.icons,_=window.nisje.data;const h=(0,w.canUserCreate)("groupBlog");var b=function(e){let{match:t}=e;const{receiveRecords:r}=(0,l.useDispatch)("nisje/core"),{id:i}=t.params,s=parseInt(t.params.page||"1",10),a={per_page:24,page:s,group_id:i},p=(0,m.addQueryArgs)("/wp/v2/nisje-blogs-group",a),[u,d]=(0,_.useApiFetch)(p,{fetchHeaders:!0,callback:e=>r(e)});return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(E.Header,{title:(0,o.__)("Blogs","nisje")},h&&(0,n.createElement)(E.HeaderButton,{icon:j.plusCircle,href:{pathname:(0,m.getAdminUrl)(`post-new.php?post_type=nisje-blogs-group&group_id=${i}`)}},(0,o.__)("New post","nisje"))),!u&&(0,n.createElement)(c.FeedGrid,null,(0,n.createElement)(c.BaseCardLoaders,null)),u&&!(0,g.isEmpty)(u)&&(0,n.createElement)(c.FeedGrid,null,(0,n.createElement)(c.Cards,{items:u})),u&&(0,g.isEmpty)(u)&&(0,n.createElement)(E.Message,{icon:j.postList},(0,o.__)("No posts yet...","nisje")),d&&(0,n.createElement)(c.Pagination,{totalPages:d.totalPages,currentPage:s,path:"/blog/"}))},f=window.nisje.views,y=window.nisje.app.comments,v=window.nisje.app.reactions,C=e.n(v),P=function(e){let{match:t}=e;const{blogId:r,id:i}=t.params,[s,a]=(0,_.useApiFetch)(`/wp/v2/nisje-blogs-group/${r}?group_id=${i}`,{callback:e=>{(0,l.dispatch)("nisje/reactions").setReactors(e.id,e.reactions)}});if(a)return(0,n.createElement)(f.Message,{icon:j.warning},a.data.status,": ",a.message);if(!s)return(0,n.createElement)(c.PostLoader,null);const p=[{title:(0,o.__)("Blogs","nisje"),href:`/groups/${i}/blog/`}],d="open"===s.comment_status;return(0,n.createElement)(n.Fragment,null,(0,n.createElement)(c.EntryContainer,{autoHeight:d},(0,n.createElement)(c.EntryControls,{showOptions:(0,w.canUserEdit)("groupBlog")||w.currentUserId===s.author,controls:[(0,n.createElement)(c.ExperimentalButton,{isMenuItem:!0,href:(0,m.getAdminUrl)(`post.php?post=${r}&action=edit`)},(0,o.__)("Edit","nisje")),(0,n.createElement)(E.DeleteDialog,{closeOnClick:!1,restPath:`/wp/v2/nisje-blogs-group/${r}?force=true&group_id=${i}`,redirect:`/groups/${i}/blog/`,title:(0,o.__)("Delete article?","nisje"),message:(0,o.__)("This will delete the article permanently","nisje"),successMessage:(0,o.__)("Successfully deleted the article","nisje")})],breadcrumbs:p}),(0,n.createElement)(c.EntryHeader,{title:s.title.rendered},(0,n.createElement)(u.Byline,{authorId:s.author,authorName:s.author_name,date:s.date_gmt})),(0,n.createElement)(c.EntryContent,null,s.content.rendered),(0,n.createElement)(c.EntryActions,null,(0,n.createElement)(C(),{id:r}))),d&&(0,n.createElement)(y.Comments,{group:i,id:r,isEntryComments:!0}))};(0,i.registerPlugin)("group-blogs",{render(){return(0,n.createElement)(s.PluginGroupRoutes,null,(0,n.createElement)(a.Route,{path:"/groups/:id/blog",component:b,exact:!0}),(0,n.createElement)(a.Route,{path:"/groups/:id/blog/:blogId",component:P}))}}),(0,r.addFilter)("groups.menu.controls","nisje/plugin-blogs",((e,t)=>(t.enable_blogs&&e.push({icon:"postList",id:"blogs",title:(0,o.__)("Blog","nisje"),to:`/groups/${t.id}/blog/`}),e)),30),(window.nisje=window.nisje||{}).pluginBlogs=t}();