import { g as getProductsFromDB, d as getBrandsFromDB, c as getModelsByBrand } from '../chunks/products_DQrRaeeW.mjs';
import { b as getBlogPosts } from '../chunks/blog_DtV0Ytrn.mjs';
export { renderers } from '../renderers.mjs';

const GET = async () => {
  const baseUrl = "https://sneakerpicks.nl";
  const staticPages = ["", "/sneakers", "/merken", "/deals", "/zoeken", "/blog"];
  const products = await getProductsFromDB({ limit: 5e4 });
  const brands = await getBrandsFromDB();
  const brandModels = [];
  for (const brand of brands) {
    try {
      const models = await getModelsByBrand(brand.slug);
      for (const model of models) {
        brandModels.push({ brandSlug: brand.slug, modelSlug: model.slug });
      }
    } catch {
    }
  }
  const today = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
  let xml = `<?xml version="1.0" encoding="UTF-8"?>
`;
  xml += `<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
`;
  for (const page of staticPages) {
    xml += `  <url>
    <loc>${baseUrl}${page}</loc>
    <lastmod>${today}</lastmod>
    <changefreq>daily</changefreq>
    <priority>${page === "" ? "1.0" : "0.8"}</priority>
  </url>
`;
  }
  for (const brand of brands) {
    xml += `  <url>
    <loc>${baseUrl}/merken/${brand.slug}</loc>
    <lastmod>${today}</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.7</priority>
  </url>
`;
  }
  for (const bm of brandModels) {
    xml += `  <url>
    <loc>${baseUrl}/merken/${bm.brandSlug}/${bm.modelSlug}</loc>
    <lastmod>${today}</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.65</priority>
  </url>
`;
  }
  for (const product of products) {
    xml += `  <url>
    <loc>${baseUrl}/sneakers/${product.slug}</loc>
    <lastmod>${today}</lastmod>
    <changefreq>daily</changefreq>
    <priority>0.6</priority>
  </url>
`;
  }
  try {
    const { posts: blogPosts } = await getBlogPosts({ limit: 1e4 });
    for (const post of blogPosts) {
      xml += `  <url>
    <loc>${baseUrl}/blog/${post.slug}</loc>
    <lastmod>${post.updated_at ? new Date(post.updated_at).toISOString().split("T")[0] : today}</lastmod>
    <changefreq>weekly</changefreq>
    <priority>0.7</priority>
  </url>
`;
    }
  } catch {
  }
  xml += `</urlset>`;
  return new Response(xml, {
    headers: {
      "Content-Type": "application/xml",
      "Cache-Control": "public, max-age=3600"
    }
  });
};

const _page = /*#__PURE__*/Object.freeze(/*#__PURE__*/Object.defineProperty({
  __proto__: null,
  GET
}, Symbol.toStringTag, { value: 'Module' }));

const page = () => _page;

export { page };
