import { MetadataRoute } from 'next'

const BASE_URL = process.env.NEXT_PUBLIC_SITE_URL ?? 'https://sitechangemonitor.com'

export default function sitemap(): MetadataRoute.Sitemap {
  const now = new Date()

  const staticPages = [
    { url: `${BASE_URL}/`, changeFrequency: 'weekly' as const, priority: 1.0 },
    { url: `${BASE_URL}/blog`, changeFrequency: 'weekly' as const, priority: 0.7 },
    { url: `${BASE_URL}/privacy`, changeFrequency: 'yearly' as const, priority: 0.3 },
    { url: `${BASE_URL}/features`, changeFrequency: 'monthly' as const, priority: 0.9 },
    { url: `${BASE_URL}/use-cases`, changeFrequency: 'monthly' as const, priority: 0.9 },
  ]

  const featureSlugs = ['noise-filtering', 'visual-diff', 'keyword-monitoring', 'seo-ranking', 'multi-channel-alerts']
  const featurePages = featureSlugs.map((slug) => ({
    url: `${BASE_URL}/features/${slug}`,
    changeFrequency: 'monthly' as const,
    priority: 0.8,
  }))

  const useCaseSlugs = ['ecommerce-price-monitoring', 'seo-serp-tracking', 'compliance-policy-monitoring', 'competitor-intelligence']
  const useCasePages = useCaseSlugs.map((slug) => ({
    url: `${BASE_URL}/use-cases/${slug}`,
    changeFrequency: 'monthly' as const,
    priority: 0.8,
  }))

  return [...staticPages, ...featurePages, ...useCasePages].map((page) => ({
    ...page,
    lastModified: now,
  }))
}
