import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  output: 'standalone',
  serverExternalPackages: ['@prisma/client', 'minio'],
  typescript: {
    ignoreBuildErrors: false,
  },
  experimental: {
    optimizePackageImports: [
      'lucide-react',
      'sonner',
      'date-fns',
      'recharts',
      'motion/react',
      'zod',
      '@radix-ui/react-icons',
    ],
  },
  images: {
    remotePatterns: [
      {
        protocol: 'https',
        hostname: '*.minio.local',
      },
    ],
  },
  async redirects() {
    return [
      // Legacy Pipeline/Stage routes → Competition/Round routes
      {
        source: '/admin/rounds/pipelines',
        destination: '/admin/competitions',
        permanent: true,
      },
      {
        source: '/admin/rounds/pipeline/:path*',
        destination: '/admin/competitions',
        permanent: true,
      },
      {
        source: '/jury/stages',
        destination: '/jury/competitions',
        permanent: true,
      },
      {
        source: '/jury/stages/:path*',
        destination: '/jury/competitions',
        permanent: true,
      },
      {
        source: '/applicant/pipeline',
        destination: '/applicant/competition',
        permanent: true,
      },
      {
        source: '/applicant/pipeline/:path*',
        destination: '/applicant/competition',
        permanent: true,
      },
    ]
  },
}

export default nextConfig
