"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }require('./chunk-DGUM43GV.js');

// 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 _nullishCoalesce(navigation.find((menu) => menu.isPrimary), () => ( navigation[0]));
}
function getNavigationBySlug(navigation, slug) {
  if (!navigation || navigation.length === 0) return null;
  return _nullishCoalesce(navigation.find((menu) => menu.name === slug), () => ( null));
}
function transformNavItems(menu) {
  if (!_optionalChain([menu, 'optionalAccess', _ => _.items]) || menu.items.length === 0) return [];
  const items = menu.items;
  return items.slice().sort((a, b) => (_nullishCoalesce(a.orderIndex, () => ( 0))) - (_nullishCoalesce(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";
}






exports.getNavItemsBySlug = getNavItemsBySlug; exports.getNavigationBySlug = getNavigationBySlug; exports.getPrimaryNavItems = getPrimaryNavItems; exports.getPrimaryNavigation = getPrimaryNavigation; exports.transformNavItems = transformNavItems;
//# sourceMappingURL=navigation.js.map