import { fg } from '@atlaskit/platform-feature-flags';
import { buildAction } from './manifest-helpers';
export function buildMenuItem(manifest, extensionModule) {
  const title = extensionModule.title || manifest.title;
  const key = `${manifest.key}:${extensionModule.key}`;
  const node = buildAction(extensionModule.action, manifest);
  if (!node) {
    throw new Error(`Couldn't find any action for ${title} (${key})`);
  }
  return {
    key,
    title,
    extensionType: manifest.type,
    extensionKey: manifest.key,
    keywords: extensionModule.keywords || manifest.keywords || [],
    featured: extensionModule.featured || false,
    categories: extensionModule.categories || manifest.categories || [],
    description: extensionModule.description || manifest.description,
    summary: manifest.summary,
    documentationUrl: manifest.documentationUrl,
    ...((fg('cc_fd_wb_create_priority_in_slash_menu_enabled') || fg('rovo_chat_enable_skills_ui_m1')) && {
      priority: extensionModule.priority
    }),
    ...(extensionModule.lozenge != null && {
      lozenge: extensionModule.lozenge
    }),
    icon: extensionModule.icon || manifest.icons['48'],
    node
  };
}