(() => {
  const card = document.querySelector("[data-card]");
  const form = document.querySelector("[data-waitlist]");
  const submit = document.querySelector("[data-submit]");
  if (!card || !form || !submit) return;

  form.addEventListener("submit", (e) => {
    e.preventDefault();
    if (card.classList.contains("is-done") || submit.classList.contains("is-loading")) {
      return;
    }

    submit.classList.add("is-loading");
    submit.setAttribute("aria-busy", "true");

    window.setTimeout(() => {
      card.classList.add("is-done");
      submit.classList.remove("is-loading");
      submit.removeAttribute("aria-busy");
    }, 900);
  });
})();
