class PasswordMeter{constructor(e='input[type="password"]',t="strong-bar",s="password-bar",a="password-input",r){this.inputSelector=e,this.barClass=t,this.meterWrapperClass=s,this.passwordBoxId=a}init(){this.initProgressBar(),this.initPasswordBox()}initProgressBar(){var e=document.querySelectorAll(this.inputSelector);e&&0<e.length&&e.forEach(a=>{var s=a.nextElementSibling;if(s&&s.classList.contains(this.meterWrapperClass)){s.innerHTML="";for(let e=0;e<4;e++){var r=document.createElement("div");r.classList.add(this.barClass),s.appendChild(r)}let t=s.querySelectorAll("."+this.barClass);a.addEventListener("input",()=>{var e=a.value;let s=this.getPasswordScore(e);t.forEach(e=>e.className=this.barClass),t.forEach((e,t)=>{t<s&&e.classList.add("bar-active-"+s)})})}})}getPasswordScore(e){let t=0;return 8<=e.length&&t++,/[A-Z]/.test(e)&&t++,/\d/.test(e)&&t++,/[\W_]/.test(e)&&t++,t}initPasswordBox(){let t=document.getElementById(this.passwordBoxId);var s=document.querySelector(".password-box");let a={lower:document.getElementById("pass-lower"),upper:document.getElementById("pass-upper"),number:document.getElementById("pass-number"),length:document.getElementById("pass-length")};if(t&&s&&Object.values(a).every(Boolean)){let e=null;try{e=new bootstrap.Collapse(s,{toggle:!1})}catch(e){console.warn("Bootstrap Collapse not available:",e)}t.addEventListener("focus",()=>e?.show()),t.addEventListener("blur",()=>{t.value.length||e?.hide()}),t.addEventListener("keyup",()=>{var e=t.value;this.toggleValidity(a.lower,/[a-z]/.test(e)),this.toggleValidity(a.upper,/[A-Z]/.test(e)),this.toggleValidity(a.number,/[0-9]/.test(e)),this.toggleValidity(a.length,8<=e.length)})}}toggleValidity(e,t){e.classList.toggle("valid",t),e.classList.toggle("invalid",!t)}}document.addEventListener("DOMContentLoaded",()=>{(new PasswordMeter).init()});