export interface SearchFilters {
	query: string;
	tags: string[];
	type: 'task' | 'thought' | 'all';
	dateRange: {
		start: string | null;
		end: string | null;
	};
}

export const defaultFilters: SearchFilters = {
	query: '',
	tags: [],
	type: 'all',
	dateRange: { start: null, end: null }
};

export function hasActiveFilters(filters: SearchFilters): boolean {
	return (
		filters.query.length >= 2 ||
		filters.tags.length > 0 ||
		filters.type !== 'all' ||
		filters.dateRange.start !== null ||
		filters.dateRange.end !== null
	);
}

// Date preset helper for quick date range selection
export function getDatePreset(preset: 'today' | 'week' | 'month'): { start: string; end: string } {
	const now = new Date();
	const end = now.toISOString().split('T')[0];

	let start: Date;
	switch (preset) {
		case 'today':
			start = now;
			break;
		case 'week':
			start = new Date(now);
			start.setDate(start.getDate() - 7);
			break;
		case 'month':
			start = new Date(now);
			start.setMonth(start.getMonth() - 1);
			break;
	}

	return {
		start: start.toISOString().split('T')[0],
		end
	};
}
