/**
  Grava壮板=40
  Largo广板=46
  Lento慢板=52
  Adagio柔板=56
  Larghetto小广板=60
  Andante行板=66
  Anderato/Andantino小行板=69
  Moderato中板=88
  Allegretto小快板=108
  Allegro Moderato=108 // 考级需要
  Allegro快板=132
  Vivace快速有生气=152
  Vivo快速有生气=160
  Vivacissimo极其活泼的快板=168
  Presto急板=184
  Prestissimo最急板=208
 */

  import {TextAlignmentEnum} from "../../Common/Enums/TextAlignment";

export const SpeedTag: {[key in string]: number} = {
  "Grava": 40,
  "Largo": 46,
  "Lento": 52,
  "Adagio": 56,
  "Larghetto": 60,
  "Andante": 66,
  "Anderato": 69,
  "Andantino": 69,
  "Moderato": 88,
  "Allegretto": 108,
  "Allegro Moderato": 108,
  "Allegro": 132,
  "Vivace": 152,
  "Vivo": 160,
  "Vivacissimo": 168,
  "Presto": 184,
  "Prestissimo": 208
};

export const SpecialMarks: string[] = ["纯律", "纯律结束"];

export const HideWords: string[] = ["跳过下一个", "b", "#", "§", "º", "X"];

export const GradientWords: string[] = ["poco rit.", "rall.", "rit.", "accel.", "molto rit.", "molto rall", "lentando", "poco accel.", "calando"];

export const GRADIENT_SPEED_CLOSE_TAG: string = "结束范围速度";

export const GRADIENT_SPEED_RESET_TAG: string = "a tempo";

export const SpecialWords: string[] = [GRADIENT_SPEED_CLOSE_TAG];

export const SpeedKeyword: string = "速度 ";
export const SpeedHiddenKeyword: string = "仅文本速度 ";

/** 是否为速度关键词 */
export function isSpeedKeyword (str: string): boolean {
  return str.indexOf(SpeedKeyword) === 0;
};

/** 是否为速度关键词 */
export function isSpeedHiddenKeyword (str: string): boolean {
  return str.indexOf(SpeedHiddenKeyword) === 0;
};

/** 格式化速度关键词移除前缀 */
export function formatSpeedKeyword (str: string): string {
  return str.replace(SpeedHiddenKeyword, "").replace(SpeedKeyword, "");
};

/** 是否是渐变速度关键词 */
export function isGradientWords (str: string): boolean {
  return GradientWords.includes(str);
};

/**
 * 是否为特殊标记
 * 包含中文与英文，中文正则存在部分问题
 */
export function isSpecialMark (str: string): boolean {
  return [...Object.keys(SpeedTag), ...SpecialMarks, ...SpecialWords, ...HideWords]
  .map((s: string) => s.trim().toLocaleUpperCase()).includes(str.toLocaleUpperCase().trim());
}

export function isTopFont(textAlignment): boolean {
  return [TextAlignmentEnum.CenterTop, TextAlignmentEnum.RightTop].includes(textAlignment);
};
