import { writeFileSync } from "fs";
import { extractStyle } from "ant-design-vue/lib/_util/static-style-extract";
import { ConfigProvider, theme } from "ant-design-vue";

const css = extractStyle((node) => (
	<>
		<ConfigProvider
			theme={{
				token: {
					colorPrimary: "#f14668",
					colorSuccess: "#2be396",
					colorWarning: "#face14",
					colorInfo: "#15c6e3",
					colorTextBase: "#101010",
				},
				algorithm: theme.defaultAlgorithm,
			}}
		>
			{node}
		</ConfigProvider>
		<ConfigProvider
			theme={{
				token: {
					colorPrimary: "#f14668",
					colorSuccess: "#2be396",
					colorWarning: "#face14",
					colorInfo: "#15c6e3",
					colorTextBase: "#fff",
				},
				algorithm: theme.darkAlgorithm,
			}}
		>
			{node}
		</ConfigProvider>
	</>
));

export default defineNitroPlugin((nitro) => {
	nitro.hooks.hook("render:html", (html) => {
		html.head.push(`<style>${css}</style>`);
	});
});
