(()=>{"use strict";var e,t={767(e,t,o){const n=window.wp.blocks,r=window.wp.i18n,s=window.wp.blockEditor,l=window.wp.components,i=window.wp.serverSideRender;var a=o.n(i);const c=window.wp.primitives,u=window.ReactJSXRuntime;var d=(0,u.jsx)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,u.jsx)(c.Path,{d:"M4 4v1.5h16V4H4zm8 8.5h8V11h-8v1.5zM4 20h16v-1.5H4V20zm4-8c0-1.1-.9-2-2-2s-2 .9-2 2 .9 2 2 2 2-.9 2-2z"})}),v=(0,u.jsx)(c.SVG,{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",children:(0,u.jsx)(c.Path,{fillRule:"evenodd",clipRule:"evenodd",d:"m3 5c0-1.10457.89543-2 2-2h13.5c1.1046 0 2 .89543 2 2v13.5c0 1.1046-.8954 2-2 2h-13.5c-1.10457 0-2-.8954-2-2zm2-.5h6v6.5h-6.5v-6c0-.27614.22386-.5.5-.5zm-.5 8v6c0 .2761.22386.5.5.5h6v-6.5zm8 0v6.5h6c.2761 0 .5-.2239.5-.5v-6zm0-8v6.5h6.5v-6c0-.27614-.2239-.5-.5-.5z"})});const p=window.wp.element,w=window.wp.coreData,h=[],g=JSON.parse('{"UU":"sunflower/next-events","uK":{"title":{"type":"string","default":""},"tag":{"type":"array"},"count":{"type":"number","default":3},"blockLayout":{"type":"string","default":"grid"},"excerptLength":{"type":"number","default":55}}}'),{uK:f}=g,m=[{attributes:{...f,count:{type:"string"}},migrate:e=>({...e,count:parseInt(e.count,10)}),isEligible:({count:e})=>e&&"string"==typeof e,save:()=>null}];(0,n.registerBlockType)(g.UU,{edit:function({attributes:e,setAttributes:t}){const o=(0,s.useBlockProps)({className:"row"}),{title:n,tag:i,count:c,blockLayout:g}=e,f=[{icon:d,title:(0,r.__)("List view"),onClick:()=>t({blockLayout:"list"}),isActive:"list"===g},{icon:v,title:(0,r.__)("Grid view"),onClick:()=>t({blockLayout:"grid"}),isActive:"grid"===g}],[m,b]=(0,p.useState)(h),[x,_]=(0,p.useState)(h),{records:y,hasResolved:k}=(0,w.useEntityRecords)("taxonomy","sunflower_event_tag",{per_page:-1,context:"view"});return(0,p.useEffect)(()=>{k&&(b(y.map(e=>e.name)),_(y.filter(t=>e.tag?.includes(t.id)||e.tag?.includes(t.slug)).map(e=>e.name)))},[y,k,i,e.tag]),(0,u.jsxs)("div",{...o,children:[(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(s.BlockControls,{children:(0,u.jsx)(l.ToolbarGroup,{controls:f})}),(0,u.jsx)(l.Disabled,{children:(0,u.jsx)(a(),{block:"sunflower/next-events",attributes:{title:n,blockLayout:g,tag:i,count:c,tagFormValue:x}})})]}),(0,u.jsx)(s.InspectorControls,{children:(0,u.jsxs)(l.PanelBody,{title:(0,r.__)("Filter"),initialOpen:!0,children:[(0,u.jsx)(l.TextControl,{label:(0,r.__)("Title"),help:(0,r.__)("Title of the block section","sunflower-latest-posts"),value:n,placeholder:(0,r.__)("Next events","sunflower-next-events"),onChange:e=>{t({title:void 0===e?"":e})}}),(0,u.jsx)(l.FormTokenField,{hasResolved:k,label:(0,r.__)("Tags"),value:x,onChange:e=>{t({tag:e.map(e=>y.filter(t=>t.name===e).map(e=>e.slug)[0])})},suggestions:m}),(0,u.jsx)(l.RangeControl,{label:(0,r.__)("Number of items"),help:(0,r.__)("Number of posts to be shown","sunflower-latest-posts"),value:c,onChange:e=>{t({count:e})},min:1,max:20})]})})]})},deprecated:m})}},o={};function n(e){var r=o[e];if(void 0!==r)return r.exports;var s=o[e]={exports:{}};return t[e](s,s.exports,n),s.exports}n.m=t,e=[],n.O=(t,o,r,s)=>{if(!o){var l=1/0;for(u=0;u<e.length;u++){for(var[o,r,s]=e[u],i=!0,a=0;a<o.length;a++)(!1&s||l>=s)&&Object.keys(n.O).every(e=>n.O[e](o[a]))?o.splice(a--,1):(i=!1,s<l&&(l=s));if(i){e.splice(u--,1);var c=r();void 0!==c&&(t=c)}}return t}s=s||0;for(var u=e.length;u>0&&e[u-1][2]>s;u--)e[u]=e[u-1];e[u]=[o,r,s]},n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={439:0,671:0};n.O.j=t=>0===e[t];var t=(t,o)=>{var r,s,[l,i,a]=o,c=0;if(l.some(t=>0!==e[t])){for(r in i)n.o(i,r)&&(n.m[r]=i[r]);if(a)var u=a(n)}for(t&&t(o);c<l.length;c++)s=l[c],n.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return n.O(u)},o=globalThis.webpackChunksunflower=globalThis.webpackChunksunflower||[];o.forEach(t.bind(null,0)),o.push=t.bind(null,o.push.bind(o))})();var r=n.O(void 0,[671],()=>n(767));r=n.O(r)})();