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