import type { RuleGroup } from './rule-engine.js';

export interface BuiltInCollection {
  slug: string;
  name_en: string;
  name_nl: string;
  description: string;
  rules: RuleGroup;
  sort_by: string;
  max_products: number | null;
  cache_ttl_sec: number;
  homepage_sort: number;
}

export const BUILT_IN_COLLECTIONS: BuiltInCollection[] = [
  {
    slug: 'sale',
    name_en: 'Sale',
    name_nl: 'Sale',
    description: 'Products with 15%+ discount',
    rules: {
      operator: 'AND',
      rules: [
        { type: 'field', field: 'discount_pct', op: 'gte', value: 15 },
        { type: 'field', field: 'price', op: 'gt', value: 0 },
      ],
    },
    sort_by: 'discount_desc',
    max_products: null,
    cache_ttl_sec: 300,
    homepage_sort: 6,
  },
  {
    slug: 'bestsellers',
    name_en: 'Bestsellers',
    name_nl: 'Bestsellers',
    description: 'Top performing products',
    rules: {
      operator: 'AND',
      rules: [
        { type: 'field', field: 'conversions_30d', op: 'gte', value: 1 },
      ],
    },
    sort_by: 'conversions_desc',
    max_products: 50,
    cache_ttl_sec: 3600,
    homepage_sort: 2,
  },
  {
    slug: 'trending',
    name_en: 'Trending',
    name_nl: 'Trending',
    description: 'Most clicked in last 48h',
    rules: {
      operator: 'AND',
      rules: [
        { type: 'field', field: 'clicks_48h', op: 'gte', value: 5 },
      ],
    },
    sort_by: 'clicks_48h_desc',
    max_products: 40,
    cache_ttl_sec: 300,
    homepage_sort: 1,
  },
  {
    slug: 'price-drops',
    name_en: 'Price Drops',
    name_nl: 'Prijsdalingen',
    description: 'Price decreased vs 7 days ago',
    rules: {
      operator: 'AND',
      rules: [
        { type: 'price_history', op: 'dropped', period_days: 7, min_drop_pct: 10 },
      ],
    },
    sort_by: 'drop_pct_desc',
    max_products: null,
    cache_ttl_sec: 600,
    homepage_sort: 7,
  },
  {
    slug: 'new-arrivals',
    name_en: 'New Arrivals',
    name_nl: 'Nieuw Binnen',
    description: 'Added in last 7 days',
    rules: {
      operator: 'AND',
      rules: [
        { type: 'time', field: 'first_seen_at', op: 'within_days', value: 7 },
      ],
    },
    sort_by: 'newest',
    max_products: null,
    cache_ttl_sec: 600,
    homepage_sort: 3,
  },
  {
    slug: 'under-100',
    name_en: 'Under €100',
    name_nl: 'Onder €100',
    description: 'Affordable sneakers under €100',
    rules: {
      operator: 'AND',
      rules: [
        { type: 'field', field: 'price', op: 'lt', value: 100 },
        { type: 'field', field: 'price', op: 'gt', value: 0 },
      ],
    },
    sort_by: 'price_asc',
    max_products: null,
    cache_ttl_sec: 600,
    homepage_sort: 9,
  },
];
