document.addEventListener("DOMContentLoaded",function(){const s=document.getElementById("trainingDatasetCreateForm");if(!s)return;const{translations:a}=window;s.addEventListener("submit",function(i){var t;if(!c())return i.preventDefault(),!1;const e=s.querySelector('button[type="submit"]')||document.querySelector(`button[type="submit"][form="${s.id}"]`);return e&&(e.disabled=!0,e.innerHTML='<i class="fas fa-spinner fa-spin me-2"></i>'+(((t=a.buttons)==null?void 0:t.saving)||"Saving...")),!0});function c(){var l,u;let i=!0;const e=document.getElementById("name");e&&!e.value.trim()?(e.classList.add("is-invalid"),r(e,((l=a.validation)==null?void 0:l.name_required)||"Dataset name is required."),i=!1):e&&(e.classList.remove("is-invalid"),n(e));const t=document.getElementById("type");return t&&!t.value?(t.classList.add("is-invalid"),r(t,((u=a.validation)==null?void 0:u.type_required)||"Dataset type is required."),i=!1):t&&(t.classList.remove("is-invalid"),n(t)),i}function r(i,e){n(i);const t=document.createElement("div");t.className="invalid-feedback",t.textContent=e,i.parentNode.appendChild(t)}function n(i){const e=i.parentNode.querySelector(".invalid-feedback");e&&e.remove()}const d=document.getElementById("name");d&&(d.addEventListener("blur",function(){var i;this.value.trim()?(this.classList.remove("is-invalid"),n(this)):(this.classList.add("is-invalid"),r(this,((i=a.validation)==null?void 0:i.name_required)||"Dataset name is required."))}),d.addEventListener("input",function(){this.value.trim()&&(this.classList.remove("is-invalid"),n(this))}));const o=document.getElementById("type");o&&o.addEventListener("change",function(){this.value&&(this.classList.remove("is-invalid"),n(this))})});
