!function(){"use strict";var e={d:function(t,n){for(var o in n)e.o(n,o)&&!e.o(t,o)&&Object.defineProperty(t,o,{enumerable:!0,get:n[o]})},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={};e.r(n),e.d(n,{name:function(){return f},settings:function(){return v}});var o={};e.r(o),e.d(o,{name:function(){return k},settings:function(){return x}});var r=window.wp.blocks,l=window.wp.element,s=window.wp.primitives,a=(0,l.createElement)(s.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24"},(0,l.createElement)(s.Path,{fillRule:"evenodd",d:"M6.863 13.644L5 13.25h-.5a.5.5 0 01-.5-.5v-3a.5.5 0 01.5-.5H5L18 6.5h2V16h-2l-3.854-.815.026.008a3.75 3.75 0 01-7.31-1.549zm1.477.313a2.251 2.251 0 004.356.921l-4.356-.921zm-2.84-3.28L18.157 8h.343v6.5h-.343L5.5 11.823v-1.146z",clipRule:"evenodd"})),c=window.wp.i18n,i=window.React,u=window.wp.blockEditor,d=function({icon:e,size:t=24,...n}){return(0,l.cloneElement)(e,{width:t,height:t,...n})},m=window.wp.data,w=window.wp.htmlEntities,p=window.wp.components,y=window.nisje.components,E=window.nisje.format,g=window.nisje.fullSiteEditing;const _="dekode-news",C="dekode-news-category";const f="nisje/card-news",v={title:(0,c.__)("News post"),edit:function({attributes:e,setAttributes:t}){const{postId:n,categoryId:o}=e,{GridSizeToolbar:r,sizeClassNames:s}=(0,g.useGridSize)(),[f,v]=(0,g.useDarkClassname)(),[S,k]=(0,i.useState)(!1),[x,h]=(0,i.useState)(!1),I=(0,m.useSelect)((e=>{if(0!==n){const t=e("core").getEntityRecord("postType",_,n);return(null==t?void 0:t.title.rendered)||"..."}if(0!==o){const t=e("core").getEntityRecord("taxonomy",C,o);return(0,c.sprintf)((0,c.__)("Category: %s"),(null==t?void 0:t.name)||"...")}return(0,c.__)("Currently showing latest post")}),[n,o]),b=(0,u.useBlockProps)({style:v,className:(0,E.classnames)("editor-news-post",s,f)}),{BackgroundColor:B,InspectorControlsColorPanel:P}=(0,u.__experimentalUseColors)([{name:"backgroundColor"}]),j=0!==n,R=0!==o;return(0,l.createElement)(l.Fragment,null,r,(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(p.PanelBody,null,(0,l.createElement)(p.Flex,{justify:"flex-start"},!R&&(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.Button,{isPrimary:!0,onClick:()=>k(!0)},j?(0,c.__)("Change post"):(0,c.__)("Select post"))),!j&&(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.Button,{isPrimary:!0,onClick:()=>h(!0)},R?(0,c.__)("Change category"):(0,c.__)("Select category"))),(j||R)&&(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.Button,{isDestructive:!0,isLink:!0,onClick:()=>t({postId:0,categoryId:0})},(0,c.__)("Remove")))))),P,(0,l.createElement)(B,null,(0,l.createElement)(y.BaseCard,b,(0,l.createElement)("div",null,(0,l.createElement)(d,{icon:a,size:40}),(0,l.createElement)(y.TextDeprecated,{as:"h2",variant:"title-medium"},(0,c.__)("News post")),(0,l.createElement)(y.TextDeprecated,{as:"p"},(0,w.decodeEntities)(I))))),x&&(0,l.createElement)(g.CategorySelector,{taxonomy:C,onSelect:e=>t({categoryId:e}),onRequestClose:()=>h(!1)}),S&&(0,l.createElement)(g.PostSelector,{onRequestClose:()=>k(!1),onSelect:e=>t({postId:e}),postType:_}))}},S="dekode-news-category";const k="nisje/card-latest-news",x={title:(0,c.__)("Latest news"),edit:function({attributes:e,setAttributes:t}){const{categoryId:n}=e,[o,r]=(0,g.useDarkClassname)(),[s,_]=(0,i.useState)(!1),C=(0,m.useSelect)((e=>{if(0!==n){const t=e("core").getEntityRecord("taxonomy",S,n);return(0,c.sprintf)((0,c.__)("Category: %s"),(null==t?void 0:t.name)||"...")}return(0,c.__)("Currently showing all news")}),[n]),f=(0,u.useBlockProps)({style:r,className:(0,E.classnames)("editor-news-post",o)}),{BackgroundColor:v,InspectorControlsColorPanel:k}=(0,u.__experimentalUseColors)([{name:"backgroundColor"}]),x=0!==n;return(0,l.createElement)(l.Fragment,null,(0,l.createElement)(u.InspectorControls,null,(0,l.createElement)(p.PanelBody,null,(0,l.createElement)(p.Flex,{justify:"flex-start"},(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.Button,{isPrimary:!0,onClick:()=>_(!0)},x?(0,c.__)("Change category"):(0,c.__)("Select category"))),x&&(0,l.createElement)(p.FlexItem,null,(0,l.createElement)(p.Button,{isDestructive:!0,isLink:!0,onClick:()=>t({postId:0,categoryId:0})},(0,c.__)("Remove")))))),k,(0,l.createElement)(v,null,(0,l.createElement)(y.BaseCard,f,(0,l.createElement)("div",null,(0,l.createElement)(d,{icon:a,size:40}),(0,l.createElement)(y.TextDeprecated,{as:"h2",variant:"title-medium"},(0,c.__)("Latest news")),(0,l.createElement)(y.TextDeprecated,{as:"p"},(0,w.decodeEntities)(C))))),s&&(0,l.createElement)(g.CategorySelector,{taxonomy:S,onSelect:e=>t({categoryId:e}),onRequestClose:()=>_(!1)}))}};[n,o].forEach((e=>{const{settings:t,name:n}=e;(0,r.registerBlockType)(n,{icon:a,...t})})),(window.nisje=window.nisje||{}).pluginNewsAdmin=t}();