/** @type {import("next").NextConfig} */
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withBundleAnalyzer = require("@next/bundle-analyzer")({
  enabled: process.env.ANALYZE === "true",
});

const nextConfig = {
  typescript: {
    // تایپ‌چک جدا با yarn check-types؛ بیلد سریع‌تر می‌شود
    ignoreBuildErrors: true,
  },
  // موازی‌سازی کمتر روی ویندوز تا OOM/گیر نکند
  experimental: {
    cpus: 2,
  },
  images: {
    // بهینه‌ساز Next با آپاچی/لوکال‌هاست اغلب 400 می‌دهد
    unoptimized: true,
    remotePatterns: [
      {
        protocol: "http",
        hostname: "localhost",
        pathname: "/**",
      },
      {
        protocol: "http",
        hostname: "127.0.0.1",
        pathname: "/**",
      },
      {
        protocol: "https",
        hostname: "**.ventoo.ir",
        pathname: "/**",
      },
      {
        protocol: "https",
        hostname: "ventoo.ir",
        pathname: "/**",
      },
      {
        protocol: "https",
        hostname: "lh3.googleusercontent.com",
      },
      {
        protocol: "https",
        hostname: "i.ibb.co",
      },
      {
        protocol: "https",
        hostname: "flagcdn.com",
      },
      {
        protocol: "https",
        hostname: "graph.facebook.com",
      },
    ],
  },
};

module.exports = withBundleAnalyzer(nextConfig);
