document.addEventListener("DOMContentLoaded", () => {
    const flashButtons = document.querySelectorAll(".notification .delete");

    flashButtons.forEach((button) => {
        const flash = button.parentNode;

        if (flash === null) {
            console.error(
                "Unreachable because our `querySelector` includes a parent; something went very wrong"
            );
            return;
        }

        flash.addEventListener("click", () => {
            if (flash.parentNode === null) {
                console.error(
                    "Notification not placed in DOM; something went very wrong"
                );
                return;
            }

            flash.parentNode.removeChild(flash);
        });

        // In development, there won't be a web server hooked up to
        // this to render the flash message, so we remove it entirely
        if (process.env.NODE_ENV === "development") {
            if (
                flash.parentNode === null ||
                flash.parentNode.parentNode === null
            ) {
                return;
            }

            console.warn("Disabling flash message");

            // Get the containing <span> element
            const block = flash.parentNode;
            // flash.parentNode.parentNode.removeChild(block);
        }
    });
});

export {};
