export type ExerciseCategory =
  | '核心与腹部'
  | '脊柱与后链'
  | '侧链与髋'
  | '平衡与支撑'
  | '进阶控制'
  | '柔韧与拉伸';

export type ExerciseLibraryItem = {
  key: string;
  name: string;
  description: string;
  category: ExerciseCategory;
};

export const EXERCISE_LIBRARY: ExerciseLibraryItem[] = [
  // 核心与腹部
  { key: 'hundred', name: '百次拍击 (The Hundred)', description: '仰卧桌面位，小幅摆臂协同吸呼，核心激活。', category: '核心与腹部' },
  { key: 'single_leg_stretch', name: '单腿伸展 (Single Leg Stretch)', description: '交替伸直一条腿，另一腿屈膝抱向胸口，稳定骨盆。', category: '核心与腹部' },
  { key: 'double_leg_stretch', name: '双腿伸展 (Double Leg Stretch)', description: '双臂双腿同时伸直/收回，呼吸控制，核心稳定。', category: '核心与腹部' },
  { key: 'criss_cross', name: '扭转卷腹 (Criss Cross)', description: '肘碰对侧膝，腹斜肌发力与呼吸配合。', category: '核心与腹部' },
  { key: 'single_straight_leg', name: '单腿直剪 (Scissors)', description: '交替拉长上抬直腿，控制下放，避免耸肩。', category: '核心与腹部' },
  { key: 'double_straight_leg', name: '双腿抬降 (Double Straight Leg Lower Lift)', description: '双腿并拢抬降，腹直肌抗伸展。', category: '核心与腹部' },
  { key: 'spine_stretch_forward', name: '脊柱前伸 (Spine Stretch Forward)', description: '坐姿脊柱分节前伸，强调轴向延展与呼吸。', category: '核心与腹部' },
  { key: 'roll_up', name: '卷起 (Roll Up)', description: '仰卧分节卷起到坐，前屈后还原，控制节律。', category: '核心与腹部' },
  { key: 'rolling_like_a_ball', name: '小球滚动 (Rolling Like a Ball)', description: '抱膝蜷成球，控制滚动回正，核心稳定。', category: '核心与腹部' },
  { key: 'teaser', name: '船式 (Teaser)', description: 'V字平衡，腿躯干对抗重力与摆动。', category: '核心与腹部' },

  // 脊柱与后链
  { key: 'swan', name: '天鹅式 (Swan)', description: '俯卧伸展胸椎，后链发力，延展不挤压。', category: '脊柱与后链' },
  { key: 'swan_dive', name: '天鹅下潜 (Swan Dive)', description: '在Swan基础上前后摆动，弹性控制。', category: '脊柱与后链' },
  { key: 'swimming', name: '游泳式 (Swimming)', description: '俯卧交替抬对侧上肢与下肢，脊柱中立。', category: '脊柱与后链' },
  { key: 'shoulder_bridge', name: '肩桥 (Shoulder Bridge)', description: '仰卧卷尾抬盆，臀腿后侧力量与脊柱分节。', category: '脊柱与后链' },
  { key: 'spine_twist', name: '脊柱扭转 (Spine Twist)', description: '坐姿轴向延展上的控制旋转。', category: '脊柱与后链' },
  { key: 'saw', name: '锯式 (Saw)', description: '坐姿分腿，旋转前屈触对侧脚尖。', category: '脊柱与后链' },

  // 侧链与髋
  { key: 'side_kick_front_back', name: '侧踢腿 前后摆 (Side Kick Front/Back)', description: '侧卧，髋稳定，腿前后摆动。', category: '侧链与髋' },
  { key: 'side_kick_up_down', name: '侧踢腿 上下 (Side Kick Up/Down)', description: '侧卧，上侧腿上抬下放，控制不耸肩。', category: '侧链与髋' },
  { key: 'side_leg_lift', name: '侧抬腿 (Side Leg Lift)', description: '侧卧抬腿，髋稳定，中臀肌激活。', category: '侧链与髋' },
  { key: 'clam', name: '蛤蜊式 (Clam)', description: '侧卧屈髋屈膝，抬起上侧膝，臀中刺激。', category: '侧链与髋' },
  { key: 'mermaid', name: '美人鱼 (Mermaid)', description: '坐姿侧屈拉伸，改善侧链柔韧。', category: '侧链与髋' },

  // 平衡与支撑
  { key: 'plank', name: '平板支撑 (Plank)', description: '掌/前臂支撑，身体成一直线，核心稳定。', category: '平衡与支撑' },
  { key: 'side_plank', name: '侧板支撑 (Side Plank)', description: '单侧支撑，侧链与肩带稳定。', category: '平衡与支撑' },
  { key: 'push_up', name: '俯卧撑 (Push Up)', description: '胸肩臂与核心协同的推举支撑。', category: '平衡与支撑' },
  { key: 'leg_pull_front', name: '前拉腿 (Leg Pull Front)', description: '俯撑抬腿，后链与肩带控制。', category: '平衡与支撑' },
  { key: 'leg_pull_back', name: '后拉腿 (Leg Pull Back)', description: '仰撑抬腿，后链与肩带控制。', category: '平衡与支撑' },

  // 进阶控制
  { key: 'jackknife', name: '折刀 (Jackknife)', description: '仰卧抬腿过头后折刀上推，核心与控制。', category: '进阶控制' },
  { key: 'open_leg_rocker', name: '开腿摇滚 (Open Leg Rocker)', description: '开腿V坐平衡，来回滚动。', category: '进阶控制' },
  { key: 'corkscrew', name: '开瓶器 (Corkscrew)', description: '躯干稳定下的双腿画圈，控制髋与核心。', category: '进阶控制' },
  { key: 'boomerang', name: '回旋镖 (Boomerang)', description: '融合Roll Over/Teaser的串联流畅控制。', category: '进阶控制' },
  { key: 'control_balance', name: '控制平衡 (Control Balance)', description: '过头位下的单腿抬降与控制。', category: '进阶控制' },
  { key: 'neck_pull', name: '抱颈卷起 (Neck Pull)', description: '更具挑战的卷起，背侧链参与更高。', category: '进阶控制' },
  { key: 'roll_over', name: '翻滚过头 (Roll Over)', description: '仰卧双腿过头落地，脊柱分节控制。', category: '进阶控制' },

  // 柔韧与拉伸
  { key: 'cat_cow', name: '猫牛 (Cat-Cow)', description: '四点支撑的屈伸热身/整理放松。', category: '柔韧与拉伸' },
  { key: 'hamstring_stretch', name: '腘绳肌拉伸', description: '仰卧或坐姿，拉伸大腿后侧。', category: '柔韧与拉伸' },
  { key: 'hip_flexor_stretch', name: '髋屈肌拉伸', description: '弓步位，前髋前侧拉伸。', category: '柔韧与拉伸' },
  { key: 'thoracic_extension', name: '胸椎伸展', description: '泡沫轴/垫上胸椎延展放松。', category: '柔韧与拉伸' },
];

export function getCategories(): ExerciseCategory[] {
  const set = new Set<ExerciseCategory>();
  EXERCISE_LIBRARY.forEach((e) => set.add(e.category));
  return Array.from(set);
}

export function searchExercises(keyword: string): ExerciseLibraryItem[] {
  const kw = keyword.trim().toLowerCase();
  if (!kw) return EXERCISE_LIBRARY;
  return EXERCISE_LIBRARY.filter((e) =>
    e.name.toLowerCase().includes(kw) ||
    e.description.toLowerCase().includes(kw)
  );
}


