<script lang="ts" setup>
	import { theme } from "ant-design-vue";

	const { getSession, signIn } = useAuth();

	await getSession({ force: true });

	const { data } = await useAuth();

	const dop = data?.value as any;
	let darkBool = dop?.user?.profile?.nightMode || false;
	console.log("l->", useNuxtApp().$loaded);
	// provide("user", ref(dop?.user || null));
	provide("dark", darkBool);
	useHead({
		bodyAttrs: {
			"data-theme": computed(() => {
				return darkBool ? "dark" : undefined;
			}).value,
		},
		titleTemplate: (title) =>
			title ? `Rockfic | ${title}` : "Rockfic | Band fiction that rocks",
	});
	// provide("loaded", useNuxtApp().$loaded);
	// let loaded = ref<boolean[]>([]);
	// provide("loaded", {
	// 	loaded,
	// 	pushState() {
	// 		loaded.value.push(false)
	// 	},
	// 	flipLast() {
	// 		loaded.value[ loaded.value.length ] = true
	// 	}
	// });
</script>
<template>
	<NuxtLayout>
		<NuxtPage />
		<!-- <NuxtWelcome /> -->
	</NuxtLayout>
	<nuxt-error-boundary>
		<template #error="{ error, clearError }">
			<error-bound :error="error" />
		</template>
	</nuxt-error-boundary>
</template>
<style>
	body[data-theme="dark"],
	body[data-theme="dark"] .alayhead {
		background-color: #141414;
		color: #fff;
	}

	html {
		background: #f5f5f5;
	}

	html,
	body {
		height: 100%;
	}

	html:has(body[data-theme="dark"]) {
		background-color: #141414 !important;
	}

	body {
		margin: 0px !important;
	}

	body:not([data-theme="dark"]) .alayhead {
		background-color: #f5f5f5 !important;
	}
</style>