import { navGroups } from "@/config/navGroups"

function normalizeTitle(title: string) {
    return title.trim().toLowerCase()
}

const titleToHref = new Map<string, string>()

for (const group of navGroups) {
    for (const item of group.items) {
        titleToHref.set(normalizeTitle(item.title), item.href)

        for (const subItem of item.items ?? []) {
            titleToHref.set(normalizeTitle(subItem.title), subItem.href)
        }
    }
}

export function getNavHrefByTitle(title: string) {
    return titleToHref.get(normalizeTitle(title))
}
