(function () {
	document.querySelectorAll("[data-password-toggle]").forEach(function (button) {
		var id = button.getAttribute("data-password-toggle");
		var input = id ? document.getElementById(id) : null;
		if (!input) return;
		var showIcon = button.querySelector(".icon-toggle-show");
		var hideIcon = button.querySelector(".icon-toggle-hide");
		button.addEventListener("click", function () {
			var visible = input.type === "text";
			input.type = visible ? "password" : "text";
			var label = visible ? "Show password" : "Hide password";
			button.setAttribute("aria-pressed", visible ? "false" : "true");
			button.setAttribute("aria-label", label);
			button.setAttribute("title", label);
			if (showIcon) showIcon.classList.toggle("d-none", !visible);
			if (hideIcon) hideIcon.classList.toggle("d-none", visible);
		});
	});
})();