import {
	defineConfig,
	presetIcons,
	presetTypography,
	presetUno,
	presetWebFonts,
	transformerDirectives,
	transformerVariantGroup,
} from 'unocss';

export default defineConfig({
	cli: {
		entry: {
			outFile: './assets/css/uno.css',
			patterns: [
				'./{templates,handlers}/**/*.templ',
				'./assets/**/*.{js,css,html}',
				'!./assets/css/uno.css',
			],
		},
	},
	presets: [
		presetIcons(),
		presetTypography(),
		presetUno({
			dark: 'media',
		}),
		presetWebFonts({
			fonts: {
				japanese: {
					name: 'Kaisei Decol',
				},
				sans: {
					name: 'Quattrocento Sans',
				},
				serif: {
					name: 'Quattrocento',
				},
			},
			provider: 'none',
		}),
	],
	rules: [
		['w-screen', [['width', '100vw'], ['width', '100dvw']]],
		[/^w-(\d+)dvw$/, ([, d]) => {
			return [
				['width', `${d}vw`],
				['width', `${d}dvw`],
			];
		}],
		['min-w-screen', [['width', '100vw'], ['width', '100dvw']]],
		[/^w-(\d+)dvw$/, ([, d]) => {
			return [
				['min-width', `${d}vw`],
				['min-width', `${d}dvw`],
			];
		}],
		['h-screen', [['height', '100vh'], ['height', '100dvh']]],
		[/^h-(\d+)dvh$/, ([, d]) => {
			return [
				['height', `${d}vh`],
				['height', `${d}dvh`],
			];
		}],
		['min-h-screen', [['height', '100vh'], ['height', '100dvh']]],
		[/^h-(\d+)dvh$/, ([, d]) => {
			return [
				['min-height', `${d}vh`],
				['min-height', `${d}dvh`],
			];
		}],
		['vertical-lr', [['writing-mode', 'vertical-lr']]],
		['vertical-rl', [['writing-mode', 'vertical-rl']]],
		['horizontal-tb', [['writing-mode', 'horizontal-tb']]],
	],
	/* 	theme: {
		colors: {
			white: 'var(--white)',
			black: 'var(--black)',
			cyan: 'var(--cyan)',
			purple: 'var(--purple)',
			foreground: {
				'00': 'var(--foreground-00)',
			},
			background: {
				'00': 'var(--background-00)',
			},
			accent: {
				'00': 'var(--accent-00)',
			},
		},
	}, */
	transformers: [transformerDirectives(), transformerVariantGroup()],
});
