export const requestNavigationRefresh = (focusKey = null) => {
  window.dispatchEvent(
    new CustomEvent("nebula-navigation-refresh", {
      detail: { focusKey },
    }),
  );
};

export const cycleOption = (options, current, direction) => {
  const index = options.findIndex((option) => option === current);
  const safeIndex = index >= 0 ? index : 0;
  const nextIndex = (safeIndex + direction + options.length) % options.length;
  return options[nextIndex];
};
