(()=>{"use strict";var e,t={471(e,t,n){const s=window.wp.blocks,l=window.wp.i18n,o=window.wp.blockEditor,r=window.wp.components,i=window.wp.serverSideRender;var a=n.n(i);const u=window.wp.element,d=window.wp.coreData,v=window.ReactJSXRuntime,c=[],p=JSON.parse('{"UU":"sunflower/next-events","uK":{"title":{"type":"string","default":""},"tag":{"type":"array"},"count":{"type":"number","default":6},"excerptLength":{"type":"number","default":55},"eventTitleFilter":{"type":"string","default":""}}}'),{uK:w}=p,f=[{attributes:{...w,blockLayout:{type:"string",default:"grid"}},migrate:e=>{const{blockLayout:t,...n}=e;return n},isEligible:({blockLayout:e})=>void 0!==e,save:()=>null},{attributes:{...w,count:{type:"string"}},migrate:e=>({...e,count:parseInt(e.count,10)}),isEligible:({count:e})=>e&&"string"==typeof e,save:()=>null}];(0,s.registerBlockType)(p.UU,{edit:function({attributes:e,setAttributes:t}){const n=(0,o.useBlockProps)({className:"row"}),{title:s,tag:i,count:p,eventTitleFilter:w}=e,[f,g]=(0,u.useState)(c),[b,x]=(0,u.useState)(c),{records:h,hasResolved:m}=(0,d.useEntityRecords)("taxonomy","sunflower_event_tag",{per_page:-1,context:"view"});return(0,u.useEffect)(()=>{m&&(g(h.map(e=>e.name)),x(h.filter(t=>e.tag?.includes(t.id)||e.tag?.includes(t.slug)).map(e=>e.name)))},[h,m,i,e.tag]),(0,v.jsxs)("div",{...n,children:[(0,v.jsx)(r.Disabled,{children:(0,v.jsx)(a(),{block:"sunflower/next-events",attributes:{title:s,tag:i,count:p,eventTitleFilter:w}})}),(0,v.jsxs)(o.InspectorControls,{children:[(0,v.jsxs)(r.PanelBody,{title:(0,l.__)("Settings","sunflower-next-events"),initialOpen:!0,children:[(0,v.jsx)(r.TextControl,{label:(0,l.__)("Block title","sunflower-next-events"),help:(0,l.__)("Heading displayed above the events list","sunflower-next-events"),value:s,placeholder:(0,l.__)("Next events","sunflower-next-events"),onChange:e=>{t({title:void 0===e?"":e})}}),(0,v.jsx)(r.RangeControl,{label:(0,l.__)("Number of items","sunflower-next-events"),help:(0,l.__)("Number of events to show","sunflower-next-events"),value:p,onChange:e=>t({count:e}),min:6,max:18,step:6})]}),(0,v.jsxs)(r.PanelBody,{title:(0,l.__)("Filter","sunflower-next-events"),initialOpen:!1,children:[(0,v.jsx)(r.TextControl,{label:(0,l.__)("Filter by title","sunflower-next-events"),help:(0,l.__)("Only show events whose title contains this text (case-insensitive)","sunflower-next-events"),value:w,onChange:e=>t({eventTitleFilter:e})}),(0,v.jsx)(r.FormTokenField,{hasResolved:m,label:(0,l.__)("Tags","sunflower-next-events"),value:b,onChange:e=>{t({tag:e.map(e=>h.find(t=>t.name===e)?.slug)})},suggestions:f})]})]})]})},deprecated:f})}},n={};function s(e){var l=n[e];if(void 0!==l)return l.exports;var o=n[e]={exports:{}};return t[e](o,o.exports,s),o.exports}s.m=t,e=[],s.O=(t,n,l,o)=>{if(!n){var r=1/0;for(d=0;d<e.length;d++){for(var[n,l,o]=e[d],i=!0,a=0;a<n.length;a++)(!1&o||r>=o)&&Object.keys(s.O).every(e=>s.O[e](n[a]))?n.splice(a--,1):(i=!1,o<r&&(r=o));if(i){e.splice(d--,1);var u=l();void 0!==u&&(t=u)}}return t}o=o||0;for(var d=e.length;d>0&&e[d-1][2]>o;d--)e[d]=e[d-1];e[d]=[n,l,o]},s.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return s.d(t,{a:t}),t},s.d=(e,t)=>{for(var n in t)s.o(t,n)&&!s.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},s.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{var e={439:0,671:0};s.O.j=t=>0===e[t];var t=(t,n)=>{var l,o,[r,i,a]=n,u=0;if(r.some(t=>0!==e[t])){for(l in i)s.o(i,l)&&(s.m[l]=i[l]);if(a)var d=a(s)}for(t&&t(n);u<r.length;u++)o=r[u],s.o(e,o)&&e[o]&&e[o][0](),e[o]=0;return s.O(d)},n=globalThis.webpackChunksunflower=globalThis.webpackChunksunflower||[];n.forEach(t.bind(null,0)),n.push=t.bind(null,n.push.bind(n))})();var l=s.O(void 0,[671],()=>s(471));l=s.O(l)})();