---
import Login from "@components/Login.svelte";
import NavbarLayout from "@layouts/NavbarLayout.astro";
import {t} from "astro-i18n";
import {Image} from "astro:assets";
import localBau from "@images/2023-10-08_20.43.43.png";
---

<NavbarLayout title={t("login.page")}>
    <script>
        import {l} from "../util/util";
        import {navigate} from "astro:transitions/client";

        document.addEventListener("astro:page-load", () => {
            if (window.location.href.endsWith("/login") || window.location.href.endsWith("/login/")) {
                if ((localStorage.getItem("sw-session") ?? "") !== "") {
                    navigate(l("/dashboard"), {history: "replace"});
                }
            }
        });
    </script>
    <Image src={localBau} alt="Bau" width="1920" height="1080"
        class="w-screen h-screen dark:brightness-75 fixed -z-10 object-cover" draggable="false"/>
    <div class="h-screen mx-auto  p-8 rounded-b-md pt-40 sm:pt-28 md:pt-14 flex flex-col justify-center items-center
            dark:text-white " style="width: min(100vw, 75em);">
        <Login client:load/>
    </div>
</NavbarLayout>