import*as e from"@wordpress/interactivity";var t={d:(e,s)=>{for(var r in s)t.o(s,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:s[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const s=(r={getContext:()=>e.getContext,getElement:()=>e.getElement,store:()=>e.store},n={},t.d(n,r),n);var r,n;const{state:o}=(0,s.store)("gatherpress",{callbacks:{renderBlocks(){const e=(0,s.getContext)(),t=(0,s.getElement)(),r=t.ref.closest(".wp-block-gatherpress-rsvp-response");fetch(function(){if("object"==typeof GatherPress)return"urls.eventApiUrl".split(".").reduce((e,t)=>e?.[t],GatherPress)}()+"/rsvp-status-html",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({status:o.posts[e.postId]?.rsvpSelection||"attending",post_id:e.postId,block_data:t.ref.textContent,limit_enabled:"1"===r.dataset.limitEnabled,limit:parseInt(r.dataset.limit,10)})}).then(e=>e.json()).then(s=>{if(s.success){const r=t.ref.parentElement;Array.from(r.children).forEach(e=>{e!==t.ref&&"id"in e.dataset&&e.remove()});const n=r.parentElement.querySelector(".gatherpress-rsvp-response--no-responses");n&&(["attending","no_status"].includes(o.posts[e.postId]?.rsvpSelection)&&0===s.responses.attending.count?(n.classList.add("gatherpress--is-visible"),n.classList.remove("gatherpress--is-hidden")):(n.classList.add("gatherpress--is-hidden"),n.classList.remove("gatherpress--is-visible"))),t.ref.insertAdjacentHTML("beforebegin",function(e){const{body:t}=document.implementation.createHTMLDocument("");t.innerHTML=e;const s=t.getElementsByTagName("*");let r=s.length;for(;r--;){const e=s[r];if("SCRIPT"===e.tagName)e.remove();else{let t=e.attributes.length;for(;t--;){const{name:s}=e.attributes[t];s.startsWith("on")&&e.removeAttribute(s)}}}return t.innerHTML}(s.content))}}).catch(()=>{})}}});