/**
 * @desc 使用async await 进项进行延时操作
 * @param {*} time
 */
export function sleep(time = 500) {
  return new Promise((resolve) => {
    setTimeout(() => resolve(true), time)
  })
}

export const themes = [
  {
    "name": "melbet",
    "label": "橙色",
    "description": "黑橙",
    "color": {
      "primary": "#f8b932",
      "primaryDark": "#c69428",
      "primaryDisabled": "#f5dba3",
      "primaryLight": "#fef2da",
      "bgColor": "#f3f4f6",
      "bgWhite": "#ffffff",
      "bgGrayLight": "#f1f1f1",
      "bgGrayDark": "#2f343c",
      "bgBlack": "#212121",
      "info": "#909399",
      "infoDark": "#82848a",
      "infoDisabled": "#c8c9cc",
      "infoLight": "#f4f4f5",
      "warning": "#ff9900",
      "warningDark": "#f29100",
      "warningDisabled": "#fcbd71",
      "warningLight": "#fdf6ec",
      "error": "#fa3534",
      "errorDark": "#dd6161",
      "errorDisabled": "#fab6b6",
      "errorLight": "#fef0f0",
      "success": "#19be6b",
      "successDark": "#18b566",
      "successDisabled": "#71d5a1",
      "successLight": "#dbf1e1",
      "mainColor": "#303133",
      "contentColor": "#606266",
      "tipsColor": "#909399",
      "lightColor": "#c0c4cc",
      "borderColor": "#dcdfe6",
      "whiteColor": "#ffffff",
      "blackColor": "#000000",
      "dividerColor": "#ebeef5",
      "maskColor": "rgba(0, 0, 0, 0.4)",
      "shadowColor": "rgba(0, 0, 0, 0.1)"
    },
    "darkColor": {}
  }
]

export function formatRange(input) {
  // 确保输入是字符串，方便正则处理
  const str = String(input);

  // 正则解析：
  // (\d+) 捕捉整数部分
  // (\.25|\.75) 捕捉特定的后缀
  return str.replace(/(\d+)(\.25|\.75)/g, (match, integer, decimal) => {
    const num = parseInt(integer);

    if (decimal === '.25') {
      // 4.25 -> 4/4.5
      return `${num}/${num + 0.5}`;
    } else if (decimal === '.75') {
      // 4.75 -> 4.5/5
      return `${num + 0.5}/${num + 1}`;
    }

    return match; // 如果没匹配上则返回原样
  });
}
