/**
 * robots.txt — Next.js serves this at /robots.txt.
 *
 * Mirrors the default Shopware storefront: crawl the catalog, but keep private
 * / transactional areas (account, checkout, admin, API, wishlist) out of the
 * index, and advertise the sitemap.
 */
import type { MetadataRoute } from 'next';
import { getStorefrontUrl } from '@/lib/shopware-api';

export default function robots(): MetadataRoute.Robots {
  const base = (getStorefrontUrl() || '').replace(/\/+$/, '');
  return {
    rules: {
      userAgent: '*',
      allow: '/',
      disallow: ['/account', '/checkout', '/admin', '/api/', '/wishlist'],
    },
    ...(base ? { sitemap: `${base}/sitemap.xml` } : {}),
  };
}
