<script>
    import DateTime from "$lib/components/DateTime.svelte";
    import { getPages } from "$lib/pages";
    import links from "../data/links.json";

    const pages = getPages();

    let ntfyLock = $state(false);
    async function sendNtfyMessage() {
        if (ntfyLock) return;
        ntfyLock = true;
        const message = document.getElementById("ntfy-message").value;
        if (message.length < 15)
            return alert(
                `Message must be 15 to 128 characters. Current length is ${message.length}`,
            );
        var resp = await fetch("https://ntfy.meow.company/pancakes", {
            method: "POST",
            body: message,
            headers: {
                Title: "pancakes.gay",
                Priority: "low",
                Tags: "black_cat",
            },
        });
        if (resp.ok) alert(`Sent: ${message}`);
        ntfyLock = false;
    }

    function updateNtfyCharCount(_) {
        const message = document.getElementById("ntfy-message").value;
        const el = document.getElementById("ntfy-char-count");

        if (message.length >= 15 && message.length <= 128)
            el.setAttribute("style", "color: var(--success);");
        else el.setAttribute("style", "color: var(--error);");

        el.innerText = 128 - message.length;
    }
</script>

<main id="main-content">
    <header>
        <h1 id="about-me">About Me</h1>
        <p>
            I'm a 22 year old enby (<em>they/it</em>) from Australia (it's
            <DateTime display="time" timeZone="Australia/Brisbane" />). I like
            cats, Linux, and programming in C# and Python (for now). You can
            find my links, projects, and other pages here.
        </p>
    </header>

    <h2 id="accounts">Accounts</h2>

    <p>Other places you can find me</p>

    {#each links as link}
        <div class="icon-link">
            <img
                class={link.iconInvert ? "invert" : ""}
                src={"/assets/icons/" + link.icon}
                alt={link.name}
            />
            {#if link.href}
                <a href={link.href} rel="me" target="_blank">
                    {link.name}: {link.username}
                </a>
            {:else}
                <span>
                    {link.name}: {link.username}
                </span>
            {/if}
        </div>
    {/each}

    <h2 id="pages">Pages</h2>

    <p>Things I've written</p>

    <div class="notice">
        <p>
            Content under the pages section uses the
            <a
                href="https://creativecommons.org/licenses/by-sa/4.0/"
                target="_blank"
            >
                Creative Commons Attribution-ShareAlike 4.0 International (CC
                BY-SA 4.0)
            </a>
            license unless specified in the page footer.
        </p>
    </div>

    <ol class="page-links">
        {#each pages as page}
            <li>
                <h3>
                    <a href={"/" + page.slug + "/"}>
                        {page.title}
                    </a>
                </h3>
                <p>{page.description}</p>
                {#if page.published}
                    <p>
                        <small>
                            Published:
                            <DateTime datetime={page.published} />
                            {#if page.edited}
                                &bull; Last edited:
                                <DateTime
                                    datetime={page.edited}
                                    display="dateTime"
                                />
                            {/if}
                        </small>
                    </p>
                {/if}
            </li>
        {/each}
    </ol>

    <h2 id="more">More</h2>

    <h3 id="buttons">Buttons</h3>

    <p>pancakes (me)</p>

    <ul class="buttons">
        <li>
            <a href="/" title="pancakes">
                <img src="/assets/88x31.png" alt="pancakes" />
            </a>
        </li>
        <li>
            <a href="https://meow.company" target="_blank" title="meow.company">
                <img
                        src="https://meow.company/88x31.png"
                        alt="meow dot company"
                />
            </a>
        </li>
    </ul>

    <p>Other people and entities</p>

    <ul class="buttons">
        <li>
            <a href="https://aagaming.me/" target="_blank" title="aagaming">
                <img
                    src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFgAAAAfCAYAAABjyArgAAAACXBIWXMAAAsTAAALEwEAmpwYAAADVUlEQVR4nO3XiU/TYBjH8f59xmjUaIxGjfeBCAIqarxiVETFA5HLKxqPP8ErSiQaTYz3EY+ojG3d0R2EwU73NW1f2nWHTNicW0fSvO3TbW/74dlvbyVJkqhvUjkN6sBSHViqyLdM/at3sFQHxuYxVAVf1chDiAxBZBgmnpj16AuIvoLoG4i+M+uxLxD/BvHvkBgx60kZkl5IKZAK6rVf45Ce0PfTCUs8ZEbE1H52PbOW79x/D8z4feuxAGbyubUefStwP1rriR9idFrrqYAAHhO4k2JM5qBOB56NXV3AkXtZwMMC+Jm1HntdAPi7GB3WelIR0GEBnb+LC8HVDvD4nQzsRxB5LICfmvXoSy0qdOD31vfHv+UAazGR9AnYkBgjAjhmL2BJg70LkQdif8isTzwzokJFNuqxDxD7BPHPEP9q1hMOSLgMZG1M6cDGa9JRAZUC0kVBVnUGS7P952QA/5P57Af8uQ4slRpVXbbF3uX84JWzawvEQ/EdjHsbyNsr3pFS9W1FAsuNYmwBua3SF03tAbu3Wo89Oyp94dQYcAO4G0FuykDeWfILInwTxm7bEXgLyA0ii5szkHeVBjZ0FULXBPItGwK7Noku3mrpYh25feawwQEIXrTWwjftCLxR72IVWW4Ed3MW8m7w7gXvfvAeAN9h8B0B37E/4Pbm1sLXIHzDjsDrRReryCpwRhbLf85i/B3g77TWAucLR0X4ul2BN4Jrs4gJPYuRW4ueDOUkKKdAOZP/fPAShK4YWWwz4LU6slvv4tlMitKVB3cwA/iqDYGda4wuLsXEKKezgPshNAihS5UGqQywjrwOXBuMLtaiwt2kPULjaf3rdTGBs2LsgWBf3hVFDWzToS4H50pwrioOzbMLvFMrin3gPTgN8jntB49Ar0AerE1gRubCyHxwLADHInAshtGlMLoMRlcI5NVmVKhd7Coui/EeMpdt/o48yN16F2vIA7UKPGdGH2A+QjeDpwU8baKL28G7R1sX57xHOQ7+E9qKQj82u/g/ACkPsHajP9UunlfySfCpDx4HtS7Oxe7SshilG4I9tQ1s3LQWFQvLMiFqVPiPgv94/vOBCxDoq21g42a1LF5Stsnxd+oPHv586+J+bUVB8HKlgWa1/QYdo4m5c/5ljgAAAABJRU5ErkJggg=="
                    alt="AA gaming"
                />
            </a>
        </li>
        <li>
            <a
                href="https://astrid.tech/"
                target="_blank"
                title="astrid dot tech"
            >
                <img
                    src="https://s3.us-west-000.backblazeb2.com/nyaabucket/a313cf12a8c46d0262c69cdf8a3accc3b6a2d159b8e1211b7abe30886a212884/astriddottech.png"
                    alt="astrid dot tech"
                />
            </a>
        </li>
<!--        <li>-->
<!--            <a-->
<!--                href="https://blueb.pages.gay"-->
<!--                target="_blank"-->
<!--                title="blueb's website"-->
<!--            >-->
<!--                <img-->
<!--                    src="https://blueb.pages.gay/_nuxt/kattgutte.D3vLs2tl.png"-->
<!--                    alt="kattgutte er ikke ekte"-->
<!--                />-->
<!--            </a>-->
<!--        </li>-->
        <li>
            <a href="https://elke.cafe/" target="_blank" title="elke.cafe">
                <img
                    src="https://elke.cafe/assets/images/buttons/elke.cafe.gif"
                    alt="elke dot cafe"
                />
            </a>
        </li>
        <li>
            <a
                href="https://eris.meows.gay/"
                target="_blank"
                title="eris meow :3"
            >
                <img
                    src="https://eris.meows.gay/images/badges/eris.png"
                    alt="eris"
                />
            </a>
        </li>
        <li>
            <a
                href="https://notfire.cc"
                target="_blank"
                title="home // notfire.cc"
            >
                <img
                    src="https://notfire.cc/design/images/buttons/notfire-cc-88x31-af.gif"
                    alt="not fire dot CC"
                />
            </a>
        </li>
        <li>
            <a
                href="https://lilysthings.org/"
                target="_blank"
                title="Lily's Things at The Cool Site"
            >
                <img
                    src="https://lilysthings.org/buttons/lilysthings.png"
                    alt="lily!!"
                />
            </a>
        </li>
        <li>
            <a
                href="https://micro.niko.lgbt"
                target="_blank"
                title="micro's site"
            >
                <img src="/assets/buttons/micro.png" alt="Micro" />
            </a>
        </li>
        <li>
            <a
                href="https://nelle.observer/"
                target="_blank"
                title="nelle.observer"
            >
                <img
                    src="https://nelle.observer/assets/images/badges/mine/nelleobserver-gray.gif"
                    alt="nelle observer"
                />
            </a>
        </li>
        <li>
            <a
                href="https://synth.download"
                target="_blank"
                title="synth download!"
            >
                <img
                    src="https://synth.download/assets/buttons/synth.download.svg"
                    alt="Synth.Download!"
                />
            </a>
        </li>
        <li>
            <a href="https://void.rehab" target="_blank" title="void.rehab">
                <img
                    src="https://void.rehab/88x31/void.rehab.png"
                    alt="void dot rehab"
                />
            </a>
        </li>
        <li>
            <a href="https://w.on-t.work/" target="_blank" title="Won't Work!">
                <img
                    src="https://w.on-t.work/assets/88x31.png"
                    alt="wont work"
                />
            </a>
        </li>
        <li>
            <a href="https://zvava.org/" target="_blank" title="zvava.org">
                <img
                    src="https://zvava.org/images/buttons/zvava.org.png"
                    alt="zvava dot org"
                />
            </a>
        </li>
    </ul>

    <p>Cool things</p>

    <ul class="buttons">
        <li>
            <img
                src="/assets/buttons/anythingbutchrome.gif"
                alt="Anything But Chrome"
                title="Anything But Chrome"
            />
        </li>
        <li>
            <a href="https://archlinux.org" target="_blank" title="arch linux">
                <img src="/assets/buttons/archlinux.gif" alt="arch linux" />
            </a>
        </li>
        <li>
            <img
                src="/assets/buttons/emulate.gif"
                alt="Emulate Now!"
                title="Emulate Now!"
            />
        </li>
        <li>
            <a
                href="https://www.mozilla.org/en-US/firefox/"
                target="_blank"
                title="Get Firefox"
            >
                <img src="/assets/buttons/getfirefox.gif" alt="Get Firefox" />
            </a>
        </li>
        <li>
            <img
                src="/assets/buttons/fediverse.gif"
                alt="Join the Fediverse"
                title="Join the Fediverse"
            />
        </li>
        <li>
            <img
                src="/assets/buttons/xenia.gif"
                alt="Linux Now!"
                title="Linux Now!"
            />
        </li>
        <li>
            <img
                src="/assets/buttons/paws.png"
                alt="made with My Own Two Paws"
                title="made with MY OWN TWO PAWS"
            />
        </li>
        <li>
            <img
                src="/assets/buttons/nonbinary.png"
                alt="Non-binary flag"
                title="Non-binary"
            />
        </li>
        <li>
            <a
                href="https://www.debian.org/"
                target="_blank"
                title="Powered by debian"
            >
                <img src="/assets/buttons/debian.png" alt="Powered by debian" />
            </a>
        </li>
        <li>
            <a href="https://scp-wiki.wikidot.com/" target="_blank" title="SCP">
                <img src="/assets/buttons/scp.png" alt="SCP" />
            </a>
        </li>
        <li>
            <a
                href="https://store.steampowered.com/app/440/Team_Fortress_2/"
                target="_blank"
                title="Team Fortress GET IT!"
            >
                <img
                    src="/assets/buttons/team_fortress_get_it.gif"
                    alt="Team Fortress Get It!"
                />
            </a>
        </li>
        <li>
            <a
                href="https://ublockorigin.com/"
                target="_blank"
                title="uBlock Origin Now!"
            >
                <img
                    src="/assets/buttons/ublock.png"
                    alt="uBlock Origin Now!"
                />
            </a>
        </li>
        <li>
            <img src="/assets/buttons/wii.png" alt="Wii" title="Wii" />
        </li>
    </ul>

    <h3 id="webrings">Webrings</h3>

    <p>Adjacent websites</p>

    <p>
        <a href="https://fediring.net/previous?host=pancakes.gay">←</a>
        <a href="https://fediring.net/">Fediring</a>
        <a href="https://fediring.net/next?host=pancakes.gay">→</a>
    </p>

    <h3 id="Notify">Notify</h3>

    <p>
        Send me a push notification. This will be a silent notification on my
        phone with no popup, vibration, or sound.
    </p>

    <input
        oninput={updateNtfyCharCount}
        type="text"
        id="ntfy-message"
        name="ntfy-message"
        placeholder="Message"
        minlength="15"
        maxlength="128"
    />
    <label for="ntfy-message" id="ntfy-char-count" style="color: var(--error);">
        128
    </label>
    <br />
    <button onclick={sendNtfyMessage} style="margin-top: 1rem;" disabled={ntfyLock}> Send </button>
</main>

<style>
    ol.page-links {
        padding-left: 0.5rem;
        list-style: none;
    }

    ol.page-links li {
        padding: 0.5rem;

        background-color: var(--background-2);
        border-left: 2px solid var(--accent);
    }

    ol.page-links li {
        margin-top: 1rem;
    }

    ol.page-links li > *:first-child {
        margin-top: 0;
    }

    ol.page-links li > *:last-child {
        margin-bottom: 0;
    }

    ul.buttons {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 0.25rem;
        justify-content: center;
        padding: 0;
        margin: 0;

        list-style: none;
    }

    ul.buttons img {
        image-rendering: pixelated;
        width: 88px;
        height: 31px;
    }
</style>
