document.addEventListener("DOMContentLoaded",function(){var e=document.getElementById("signupForm");if(e){var s={firstname:{required:!0,message:"Please enter your firstname"},lastname:{required:!0,message:"Please enter your lastname"},username:{required:!0,minLength:2,message:"Please enter a username",minLengthMessage:"Your username must consist of at least 2 characters"},password:{required:!0,minLength:5,message:"Please provide a password",minLengthMessage:"Your password must be at least 5 characters long"},confirm_password:{required:!0,minLength:5,equalTo:"password",message:"Please provide a password",minLengthMessage:"Your password must be at least 5 characters long",equalToMessage:"Please enter the same password as above"},email:{required:!0,email:!0,message:"Please enter a valid email address"},agree:{required:!0,message:"Please accept our policy"}};e.querySelectorAll("input").forEach(function(e){e.addEventListener("blur",function(){t(e)}),"email"!==e.type&&"confirm_password"!==e.name||e.addEventListener("input",function(){e.value.trim()&&t(e)})}),e.addEventListener("submit",function(s){s.preventDefault(),s.stopPropagation();var a=!0;if(e.querySelectorAll("input").forEach(function(e){t(e)||(a=!1)}),a){var r=e.querySelector('button[type="submit"]'),i=r.textContent;r.textContent="Success!",r.classList.add("btn-success"),r.classList.remove("btn-primary"),setTimeout(function(){r.textContent=i,r.classList.add("btn-primary"),r.classList.remove("btn-success")},2e3)}else{var n=e.querySelector(".is-invalid");n&&n.focus()}})}function a(e){var s=document.createElement("div");return s.className="invalid-feedback",s.textContent=e,s}function t(e){var t=e.name,r=e.value.trim(),i=s[t];if(!i)return!0;var n=e.parentNode.querySelector(".invalid-feedback");if(n&&n.remove(),i.required&&!r){e.classList.add("is-invalid"),e.classList.remove("is-valid");var d=a(i.message);return e.type,e.parentNode.appendChild(d),!1}if(i.minLength&&r&&r.length<i.minLength){e.classList.add("is-invalid"),e.classList.remove("is-valid");var l=a(i.minLengthMessage||i.message);return e.parentNode.appendChild(l),!1}if(i.email&&r&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)){e.classList.add("is-invalid"),e.classList.remove("is-valid");var o=a(i.message);return e.parentNode.appendChild(o),!1}if(i.equalTo&&r){var u=document.getElementById(i.equalTo);if(u&&r!==u.value){e.classList.add("is-invalid"),e.classList.remove("is-valid");var m=a(i.equalToMessage||i.message);return e.parentNode.appendChild(m),!1}}if("checkbox"===e.type&&i.required&&!e.checked){e.classList.add("is-invalid"),e.classList.remove("is-valid");var c=a(i.message);return e.parentNode.appendChild(c),!1}return(r||"checkbox"===e.type)&&(e.classList.add("is-valid"),e.classList.remove("is-invalid")),!0}});