/**
 * 意图关键词 -> 小程序页面路径映射表
 * 仅映射 app.config.ts 中已注册的页面路径
 */

export interface NavigationEntry {
  /** 意图类型 */
  intent: string;
  /** 目标页面路径 */
  path: string;
  /** 按钮文案 */
  label: string;
}

/** 意图 -> 页面映射（仅已注册路径） */
const NAVIGATION_MAP: NavigationEntry[] = [
  { intent: 'service_help',        path: '/pages/my-service-projects/index', label: '查看我的需求' },
  { intent: 'activity_registered', path: '/pages/my-registered-activities/index', label: '查看我报名的活动' },
  { intent: 'survey_history',      path: '/pages/my-surveys/index',          label: '查看我的答卷' },
  { intent: 'point_history',       path: '/pages/my-points/index',           label: '查看积分历史' },
  { intent: 'learning_records',    path: '/pages/my-learning/index',         label: '查看学习记录' },
  { intent: 'browsing_history',    path: '/pages/my-browsing-history/index', label: '查看浏览历史' },
  { intent: 'social_card',         path: '/pages/social-card/index',         label: '查看社交名片' },
  { intent: 'policy_inquiry',      path: '/pages/suggestions/index',          label: '查看建言献策' },
  { intent: 'point_query',         path: '/pages/my-points/index',            label: '查看我的积分' },
  { intent: 'performance_query',   path: '/pages/profile/index',              label: '查看个人中心' },
  { intent: 'review_inquiry',      path: '/pages/my-suggestions/index',       label: '查看我的建言' },
  { intent: 'portal_guide',        path: '/pages/join/index',                 label: '入会指南' },
  { intent: 'service_inquiry',     path: '/pages/services/index',             label: '查看服务项目' },
  { intent: 'survey_inquiry',      path: '/pages/my-surveys/index',           label: '查看我的问卷' },
  { intent: 'news_inquiry',        path: '/pages/news-list/index',            label: '查看新闻资讯' },
  { intent: 'learning_recommend',  path: '/pages/learning-list/index',        label: '查看学习园地' },
];

/** 快速查找：意图 -> NavigationEntry */
const intentLookup = new Map<string, NavigationEntry>();
NAVIGATION_MAP.forEach((entry) => intentLookup.set(entry.intent, entry));

/**
 * 根据意图类型查找导航目标
 */
export function getNavigationByIntent(intent: string): NavigationEntry | undefined {
  return intentLookup.get(intent);
}

/**
 * 获取完整映射表（不可变副本）
 */
export function getAllNavigationEntries(): readonly NavigationEntry[] {
  return NAVIGATION_MAP;
}
