export interface NavItem {
  title: string;
  path: string;
}

export interface NavSection {
  title: string;
  items: NavItem[];
}

export const NAV_SECTIONS: NavSection[] = [
  {
    title: "Getting Started",
    items: [
      { title: "What is Veylant IA?", path: "/docs/getting-started/what-is-veylant" },
      { title: "Quick Start", path: "/docs/getting-started/quick-start" },
      { title: "Key Concepts", path: "/docs/getting-started/concepts" },
    ],
  },
  {
    title: "Installation",
    items: [
      { title: "Docker Compose", path: "/docs/installation/docker" },
      { title: "Configuration", path: "/docs/installation/configuration" },
      { title: "Provider Setup", path: "/docs/installation/providers" },
    ],
  },
  {
    title: "API Reference",
    items: [
      { title: "Authentication", path: "/docs/api/authentication" },
      { title: "Chat Completions", path: "/docs/api/chat-completions" },
      { title: "PII Analysis", path: "/docs/api/pii" },
      { title: "Admin — Policies", path: "/docs/api/admin/policies" },
      { title: "Admin — Users", path: "/docs/api/admin/users" },
      { title: "Admin — Audit Logs", path: "/docs/api/admin/logs" },
      { title: "Admin — Compliance", path: "/docs/api/admin/compliance" },
      { title: "Admin — Feature Flags", path: "/docs/api/admin/flags" },
    ],
  },
  {
    title: "Guides",
    items: [
      { title: "PII Detection & Anonymization", path: "/docs/guides/pii" },
      { title: "Routing Rules Engine", path: "/docs/guides/routing" },
      { title: "RBAC & Permissions", path: "/docs/guides/rbac" },
      { title: "GDPR & AI Act Compliance", path: "/docs/guides/compliance" },
      { title: "Monitoring & Alerting", path: "/docs/guides/monitoring" },
      { title: "Circuit Breaker & Failover", path: "/docs/guides/circuit-breaker" },
    ],
  },
  {
    title: "Deployment",
    items: [
      { title: "Docker Compose", path: "/docs/deployment/docker" },
      { title: "Kubernetes (Helm)", path: "/docs/deployment/kubernetes" },
      { title: "Blue/Green Deployment", path: "/docs/deployment/blue-green" },
    ],
  },
  {
    title: "Security",
    items: [
      { title: "Security Model", path: "/docs/security/model" },
      { title: "API Key Management", path: "/docs/security/api-keys" },
    ],
  },
  {
    title: "Changelog",
    items: [{ title: "v1.0.0 (Latest)", path: "/docs/changelog" }],
  },
];

/** Flatten all nav items into a list, preserving section context */
export const ALL_NAV_ITEMS: (NavItem & { section: string })[] = NAV_SECTIONS.flatMap((s) =>
  s.items.map((item) => ({ ...item, section: s.title }))
);

/** Get previous and next pages for pagination */
export function getPrevNext(currentPath: string): {
  prev: NavItem | null;
  next: NavItem | null;
} {
  const idx = ALL_NAV_ITEMS.findIndex((i) => i.path === currentPath);
  return {
    prev: idx > 0 ? ALL_NAV_ITEMS[idx - 1] : null,
    next: idx < ALL_NAV_ITEMS.length - 1 ? ALL_NAV_ITEMS[idx + 1] : null,
  };
}
