import "./chunk-BJTO5JO5.mjs";

// src/navigation/index.ts
function getPrimaryNavItems(navigation) {
  return transformNavItems(getPrimaryNavigation(navigation));
}
function getNavItemsBySlug(navigation, slug) {
  return transformNavItems(getNavigationBySlug(navigation, slug));
}
function getPrimaryNavigation(navigation) {
  if (!navigation || navigation.length === 0) return null;
  return navigation.find((menu) => menu.isPrimary) ?? navigation[0];
}
function getNavigationBySlug(navigation, slug) {
  if (!navigation || navigation.length === 0) return null;
  return navigation.find((menu) => menu.name === slug) ?? null;
}
function transformNavItems(menu) {
  if (!menu?.items || menu.items.length === 0) return [];
  const items = menu.items;
  return items.slice().sort((a, b) => (a.orderIndex ?? 0) - (b.orderIndex ?? 0)).map((item) => ({
    label: item.label,
    href: resolveItemHref(item),
    isExternal: isExternalLink(item)
  })).filter((item) => Boolean(item.href));
}
function resolveItemHref(item) {
  const link = item.url;
  if (!link || typeof link !== "object" || !("href" in link)) return "";
  return link.href;
}
function isExternalLink(item) {
  const link = item.url;
  if (!link || typeof link !== "object" || !("kind" in link)) return false;
  return link.kind === "external";
}
export {
  getNavItemsBySlug,
  getNavigationBySlug,
  getPrimaryNavItems,
  getPrimaryNavigation,
  transformNavItems
};
//# sourceMappingURL=navigation.mjs.map