const storedTagFilter = localStorage.getItem('tagFilter');
const storedSummaryFormat = localStorage.getItem('summaryFormat');
const storedBatch = localStorage.getItem('batch');
const storedSfw = localStorage.getItem('sfw');
const storedTheme = localStorage.getItem('theme');

const deviceTheme = window.matchMedia?.('(prefers-color-scheme: dark)').matches ? 'dark' : 'light';

const defaultSummaryFormat = [
	{
		delimiter: ' - ',
		segments: [
			{
				prop: 'channel',
			},
			{
				prop: 'title',
			},
		],
	},
	{
		delimiter: ', ',
		bracket: '()',
		segments: [
			{
				prop: 'actors',
				delimiter: ', ',
			},
			{
				prop: 'date',
				format: 'DD-MM-YYYY',
			},
		],
	},
];

export default {
	tagFilter: storedTagFilter ? storedTagFilter.split(',') : [],
	summaryFormat: storedSummaryFormat ? JSON.parse(storedSummaryFormat) : defaultSummaryFormat,
	defaultSummaryFormat,
	range: 'latest',
	batch: storedBatch || 'all',
	sfw: storedSfw === 'true' || false,
	theme: storedTheme || deviceTheme,
};