document.addEventListener("DOMContentLoaded",(function(){"use strict";const e=document.querySelectorAll("#publish, .editor-post-publish-button, .editor-post-update-button");if(0<e.length){function n(e){if(e.disabled||null===e.offsetParent)return!1;const t=e.tagName.toLowerCase(),o=e.value;return"select"===t?!o||"none"===o:!("input"!==t&&"textarea"!==t||o&&0!==o&&""!==o&&"0"!==o)}function i(e){const t=document.querySelectorAll("[required]");let o=null,r=!1;return t&&(t.forEach((e=>{e.classList.remove("orbem-studio-error")})),t.forEach((e=>{const t=e;n(t)&&(t.classList.add("orbem-studio-error"),o||(o=t),r=!0)}))),!r||(e.preventDefault(),e.stopPropagation(),alert("There is one or more required fields that need attending to."),o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),o.focus()),!1)}for(let a=0;a<e.length;a++)e[a].addEventListener("click",i)}if(!window.wp||!wp.data||!wp.data.dispatch)return;const t="orbem-required-fields";let o=!1;const r=e=>{if(e.disabled||null===e.offsetParent)return!1;const t=e.tagName.toLowerCase(),o=e.value;return"select"===t?!o||"none"===o:!("input"!==t&&"textarea"!==t||o&&0!==o&&""!==o&&"0"!==o)},s=()=>{const e=document.querySelectorAll("[required]");let s=!1;e.forEach((e=>{e.classList.remove("orbem-studio-error"),r(e)&&(e.classList.add("orbem-studio-error"),s=!0)}));const n=wp.data.dispatch("core/editor");s&&!o?(n.lockPostSaving(t),o=!0):!s&&o&&(n.unlockPostSaving(t),o=!1)};s(),wp.data.subscribe((()=>{setTimeout(s,0)})),document.addEventListener("click",(e=>{if(!e.target.closest(".editor-post-publish-button, .editor-post-update-button"))return;const t=document.querySelectorAll("[required]");let o=null,s=!1;t.forEach((e=>{e.classList.remove("orbem-studio-error"),r(e)&&(e.classList.add("orbem-studio-error"),o||(o=e),s=!0)})),s&&(e.preventDefault(),e.stopPropagation(),alert("There is one or more required fields that need attending to."),o&&(o.scrollIntoView({behavior:"smooth",block:"center"}),o.focus()))}))}));