import type { NextConfig } from 'next'

const nextConfig: NextConfig = {
  output: 'standalone',
  typedRoutes: true,
  serverExternalPackages: ['@prisma/client', 'minio'],
  experimental: {
    optimizePackageImports: ['lucide-react'],
  },
  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/competitions',
        permanent: true,
      },
      {
        source: '/applicant/pipeline/:path*',
        destination: '/applicant/competitions',
        permanent: true,
      },
    ]
  },
}

export default nextConfig
