(()=>{"use strict";var e={n:t=>{var r=t&&t.__esModule?()=>t.default:()=>t;return e.d(r,{a:r}),r},d:(t,r)=>{for(var i in r)e.o(r,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:r[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.data,r=window.wp.components,i=window.wp.blockEditor,n=window.wp.serverSideRender;var o=e.n(n);const l=window.wp.blocks,a=window.wp.element,c=window.ReactJSXRuntime;(0,l.registerBlockType)("um-block/um-member-directories",{edit:function(e){const n=(0,i.useBlockProps)(),{attributes:l,setAttributes:d}=e,{member_id:s}=l,u=(0,t.useSelect)(e=>e("core").getEntityRecords("postType","um_directory",{per_page:-1,_fields:["id","title"]}),[]),m=(0,a.useMemo)(()=>u?0===u.length?[{label:wp.i18n.__("No posts found.","ultimate-member"),value:""}]:[{label:wp.i18n.__("Select Directory","ultimate-member"),value:""}].concat(u.map(e=>({label:e.title.rendered,value:e.id}))):[{label:wp.i18n.__("Loading...","ultimate-member"),value:""}],[u]);return u?(0,c.jsxs)("div",{...n,children:[(0,c.jsx)(o(),{block:"um-block/um-member-directories",attributes:l}),(0,c.jsx)(i.InspectorControls,{children:(0,c.jsx)(r.PanelBody,{title:wp.i18n.__("Select Directories","ultimate-member"),children:(0,c.jsx)(r.SelectControl,{label:wp.i18n.__("Select Directories","ultimate-member"),className:"um_select_directory",value:s,options:m,onChange:e=>d({member_id:e})})})})]}):(0,c.jsxs)("p",{children:[(0,c.jsx)(r.Spinner,{}),wp.i18n.__("Loading...","ultimate-member")]})},save:()=>null}),jQuery(window).on("load",function(e){new MutationObserver(function(e){e.forEach(function(e){jQuery(e.addedNodes).find(".um.um-directory").each(function(){let e=document.querySelector(".um-directory"),t=jQuery(this);um_ajax_get_members(t),um_slider_filter_init(t),um_datepicker_filter_init(t),um_timepicker_filter_init(t),e&&e.addEventListener("click",t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())})}),jQuery(e.addedNodes).find(".um-member").each(function(){let e=document.querySelector(".um-member"),t=jQuery(this).parent();t.hasClass("um-members-grid")&&UM_Member_Grid(t),e&&e.addEventListener("click",t=>{t.target!==e&&(t.preventDefault(),t.stopPropagation())})})})}).observe(document,{attributes:!1,childList:!0,characterData:!1,subtree:!0})})})();