!function(){"use strict";function e(){document.addEventListener("change",(e=>{e.target.classList.contains("gb-menu-condition-select")&&function(e){const t=e.closest(".menu-item-settings").querySelector(".field-gb-menu-condition-invert");if(t)if(e.value)t.style.display="";else{t.style.display="none";const e=t.querySelector('input[type="checkbox"]');e&&(e.checked=!1)}}(e.target)})),document.addEventListener("click",(e=>{e.target.classList.contains("gb-load-more-conditions")&&(e.preventDefault(),function(e){const t=e.dataset.itemId,n=document.getElementById("gb-menu-condition-"+t);if(!n)return;const o=parseInt(n.dataset.page)||1;e.disabled=!0,e.textContent=gbMenuConditions.strings.loading;const i=new FormData;i.append("action","gb_load_more_conditions"),i.append("page",o+1),i.append("_ajax_nonce",gbMenuConditions.nonces.loadMore),fetch(gbMenuConditions.ajaxurl,{method:"POST",credentials:"same-origin",body:i}).then((e=>e.json())).then((t=>{t.success&&t.data.conditions&&(t.data.conditions.forEach((e=>{const t=document.createElement("option");t.value=e.id,t.textContent=e.title,n.appendChild(t)})),n.dataset.page=o+1,t.data.has_more?(e.disabled=!1,e.textContent=gbMenuConditions.strings.loadMore):e.remove())})).catch((()=>{e.disabled=!1,e.textContent=gbMenuConditions.strings.loadMore}))}(e.target))})),document.querySelectorAll(".gb-menu-condition-select").forEach((e=>{const t=e.closest(".menu-item-settings");if(t){const n=t.querySelector(".field-gb-menu-condition-invert");n&&!e.value&&(n.style.display="none")}}))}"undefined"!=typeof gbMenuConditions&&("loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e())}();