const passwordField = document.getElementsByClassName("no-copy");
Array.from(passwordField).forEach((element) => {
  element.addEventListener("copy", (e) => {
    e.preventDefault();
  });
});

const error_popup_div = document.querySelector(".error-popup");
const close_popup_btn = document.querySelector("#close-popup");

const messagePopup = () => {
  error_popup_div.classList.remove("hidden");
  error_popup_div.classList.add("fade-in");
  error_popup_div.addEventListener(
    "animationend",
    () => {
      error_popup_div.classList.remove("fade-in");
    },
    { once: true }
  );
};

close_popup_btn.addEventListener("click", () => {
  error_popup_div.classList.add("hidden");
});

let new_user_popup_btn = document.querySelector("#new-user-popup");
let new_user_popup = document.querySelector("#new_user_popup");

new_user_popup_btn.addEventListener("click", () => {
  popup_onof(new_user_popup);
});
let close_opup2 = document.querySelector("#close-popup2");
close_opup2.addEventListener("click", () => {
  popup_onof(new_user_popup);
});
const popup_onof = (element) => {
  let overlay = document.querySelector(".overlay");

  if (!overlay) {
    overlay = document.createElement("div");
    overlay.classList.add("overlay", "hidden");
    document.body.appendChild(overlay);
  }

  if (element.classList.contains("hidden")) {
    element.classList.remove("hidden");
    overlay.classList.remove("hidden");
  } else {
    element.classList.add("hidden");
    overlay.classList.add("hidden");
  }
};
