/** 背景 id 0–22，对应 `appearance-styles.css` 中 `:root[data-bg]`。 */
export const BACKGROUNDS: { id: string; name: string }[] = [
  { id: '0', name: '云雾灰' },
  { id: '1', name: '羊皮纸' },
  { id: '2', name: '深海蓝' },
  { id: '3', name: '森绿' },
  { id: '4', name: '极光渐变' },
  { id: '5', name: '极简粉' },
  { id: '6', name: '暗夜橙' },
  { id: '7', name: '薰衣草' },
  { id: '8', name: '暖石褐' },
  { id: '9', name: '星夜紫' },
  { id: '10', name: '霜青' },
  { id: '11', name: '玫瑰灰' },
  { id: '12', name: '石墨黑' },
  { id: '13', name: '薄荷冰' },
  { id: '14', name: '焦糖拿铁' },
  { id: '15', name: '青瓷' },
  { id: '16', name: '暮光紫灰' },
  { id: '17', name: '沙岸米' },
  { id: '18', name: '松烟墨' },
  { id: '19', name: '樱粉雾' },
  { id: '20', name: '钢蓝灰' },
  { id: '21', name: '苔痕绿' },
  { id: '22', name: 'Kindle 纸感' }
]

/** 字体 id 0–31，对应 `:root[data-font]`。 */
export const FONTS: { id: string; name: string }[] = [
  { id: '0', name: '系统默认' },
  { id: '1', name: '衬线阅读' },
  { id: '2', name: '等宽代码' },
  { id: '3', name: '人文宋黑' },
  { id: '4', name: 'IBM Plex' },
  { id: '5', name: 'Helvetica 系' },
  { id: '6', name: 'Georgia 系' },
  { id: '7', name: 'Verdana 系' },
  { id: '8', name: 'Courier 打字机' },
  { id: '9', name: 'Segoe UI 系' },
  { id: '10', name: '思源黑体优先' },
  { id: '11', name: '圆体休闲' },
  { id: '12', name: '苹方优先' },
  { id: '13', name: '冬青黑体' },
  { id: '14', name: '霞鹜文楷' },
  { id: '15', name: 'HarmonyOS Sans' },
  { id: '16', name: 'OPPO Sans' },
  { id: '17', name: '小米兰亭' },
  { id: '18', name: '阿里巴巴普惠' },
  { id: '19', name: '得意黑' },
  { id: '20', name: 'Maple Mono' },
  { id: '21', name: 'Fira Sans + Mono' },
  { id: '22', name: 'Roboto 系' },
  { id: '23', name: 'Open Sans 系' },
  { id: '24', name: 'Lato 系' },
  { id: '25', name: 'Montserrat 系' },
  { id: '26', name: 'Merriweather 阅读' },
  { id: '27', name: 'Crimson Text' },
  { id: '28', name: 'Literata 阅读' },
  { id: '29', name: 'Inconsolata 等宽' },
  { id: '30', name: 'Anonymous Pro' },
  { id: '31', name: 'Fantasque Sans Mono' }
]

export type ViewMode = 'edit' | 'read' | 'hybrid'

export function validBackgroundId(s: string | null): string | null {
  if (s === null) return null
  return /^([0-9]|1[0-9]|2[0-2])$/.test(s) ? s : null
}

export function validFontId(s: string | null): string | null {
  if (s === null) return null
  return /^([0-9]|[12][0-9]|3[01])$/.test(s) ? s : null
}
