/**
 * Navigation Structure for Admin Core
 *
 * 3 Categories: Communication, Infrastructure, Development
 */

export type CategoryId = 'infrastructure'

export interface NavModule {
  id: string
  name: string
  href: string
  description: string
  purpose: string
  audience: string[]
  subgroup?: string
}

export interface NavCategory {
  id: CategoryId
  name: string
  icon: string
  color: string
  colorClass: string
  description: string
  modules: NavModule[]
}

export const navigation: NavCategory[] = [
  // =========================================================================
  // Infrastruktur & DevOps (Orange)
  // =========================================================================
  {
    id: 'infrastructure',
    name: 'Infrastruktur',
    icon: 'server',
    color: '#f97316',
    colorClass: 'infrastructure',
    description: 'GPU, Security, CI/CD & Monitoring',
    modules: [
      {
        id: 'middleware',
        name: 'Middleware',
        href: '/infrastructure/middleware',
        description: 'Rate Limiting, IP Whitelist/Blacklist',
        purpose: 'Middleware-Stack und API Gateway ueberwachen und konfigurieren.',
        audience: ['DevOps'],
        subgroup: 'Netzwerk',
      },
      {
        id: 'security',
        name: 'Security Dashboard',
        href: '/infrastructure/security',
        description: 'DevSecOps & Vulnerability Scans',
        purpose: 'Security-Scans, Vulnerability-Reports und OWASP-Compliance.',
        audience: ['DevOps', 'Security'],
        subgroup: 'DevOps Pipeline',
      },
      {
        id: 'sbom',
        name: 'SBOM',
        href: '/infrastructure/sbom',
        description: 'Software Bill of Materials',
        purpose: 'Software-Abhaengigkeiten und deren Lizenzen verwalten.',
        audience: ['DevOps', 'Compliance'],
        subgroup: 'DevOps Pipeline',
      },
      {
        id: 'ci-cd',
        name: 'CI/CD Dashboard',
        href: '/infrastructure/ci-cd',
        description: 'Gitea Actions Pipelines',
        purpose: 'CI/CD Dashboard mit Pipelines, Deployment-Status und Container-Management.',
        audience: ['DevOps', 'Entwickler'],
        subgroup: 'DevOps Pipeline',
      },
      {
        id: 'tests',
        name: 'Test Dashboard',
        href: '/infrastructure/tests',
        description: '280+ Tests aus allen Services',
        purpose: 'Zentrales Dashboard fuer alle Tests. Unit, Integration, E2E und Quality Tests.',
        audience: ['Entwickler', 'QA', 'DevOps'],
        subgroup: 'DevOps Pipeline',
      },
    ],
  },
]

// Meta modules (always visible)
export const metaModules: NavModule[] = [
  {
    id: 'dashboard',
    name: 'Dashboard',
    href: '/dashboard',
    description: 'Uebersicht & Statistiken',
    purpose: 'Zentrale Uebersicht ueber alle Core-Systeme.',
    audience: ['Alle'],
  },
]

// Helper function to get category by ID
export function getCategoryById(id: CategoryId): NavCategory | undefined {
  return navigation.find(cat => cat.id === id)
}

// Helper function to get module by href
export function getModuleByHref(href: string): { category: NavCategory; module: NavModule } | undefined {
  for (const category of navigation) {
    const module = category.modules.find(m => m.href === href)
    if (module) {
      return { category, module }
    }
  }
  return undefined
}

// Helper function to get all modules flat
export function getAllModules(): NavModule[] {
  return [...navigation.flatMap(cat => cat.modules), ...metaModules]
}
