import type { MetadataRoute } from "next";

import { getAbsoluteUrl } from "@/lib/site-config";
import { initialTools } from "@/lib/tools-registry";

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

  const staticEntries: MetadataRoute.Sitemap = [
    {
      url: getAbsoluteUrl("/"),
      lastModified: now,
      changeFrequency: "daily",
      priority: 1
    },
    {
      url: getAbsoluteUrl("/cookies"),
      lastModified: now,
      changeFrequency: "monthly",
      priority: 0.4
    },
    {
      url: getAbsoluteUrl("/share/twitter"),
      lastModified: now,
      changeFrequency: "monthly",
      priority: 0.6
    }
  ];

  const toolEntries: MetadataRoute.Sitemap = initialTools.map((tool) => ({
    url: getAbsoluteUrl(tool.route),
    lastModified: now,
    changeFrequency: "weekly",
    priority: 0.8
  }));

  return [...staticEntries, ...toolEntries];
}
