document.addEventListener("DOMContentLoaded",function(){const i=document.getElementById("escalationRuleForm");i&&i.addEventListener("submit",function(e){if(!d())return e.preventDefault(),!1;const t=i.querySelector('button[type="submit"]')||document.querySelector(`button[type="submit"][form="${i.id}"]`);return t&&(t.disabled=!0,t.innerHTML='<i class="fas fa-spinner fa-spin me-2"></i>Saving...'),!0});function d(){const e=document.getElementById("create_name");let t=!0;return e.value.trim()?(e.classList.remove("is-invalid"),n(e)):(e.classList.add("is-invalid"),a(e,"Rule name is required."),t=!1),t}function a(e,t){n(e);const r=document.createElement("div");r.className="invalid-feedback",r.textContent=t,e.parentNode.appendChild(r)}function n(e){const t=e.parentNode.querySelector(".invalid-feedback");t&&t.remove()}const s=document.getElementById("create_name");s&&(s.addEventListener("blur",function(){this.value.trim()?(this.classList.remove("is-invalid"),n(this)):(this.classList.add("is-invalid"),a(this,"Rule name is required."))}),s.addEventListener("input",function(){this.value.trim()&&(this.classList.remove("is-invalid"),n(this))}))});
