import type { DebugPublishMeta } from '../../utils/debugPublish'; import { inferGradeFromAge } from '../../utils/debugPublish'; import { PINYIN_DICTATION_WORKSHEET_DEFINITIONS } from '../../config/worksheets/pinyin'; export { PINYIN_DICTATION_WORKSHEET_DEFINITIONS }; export type PinyinDictationMode = | 'pinyin-tracing' | 'pinyin-dictation' | 'pinyin-tracing-v2' | 'pinyin-dictation-v2' | 'pinyin-daily'; type PinyinDictationWorksheetRow = (typeof PINYIN_DICTATION_WORKSHEET_DEFINITIONS)[number]; const PINYIN_DICTATION_WORKSHEET_BY_ID = Object.fromEntries( PINYIN_DICTATION_WORKSHEET_DEFINITIONS.map((m) => [m.id, m]), ) as Record; export const PINYIN_DICTATION_MODE_OPTIONS = PINYIN_DICTATION_WORKSHEET_DEFINITIONS; export function getModeInfo(id: string) { const m = PINYIN_DICTATION_WORKSHEET_BY_ID[id]; return m ? { title: m.title, desc: m.subtitle } : undefined; } export function isValidMode(id: string): boolean { return id in PINYIN_DICTATION_WORKSHEET_BY_ID; } export function getPublishMetaByMode(id: string): DebugPublishMeta | null { const m = PINYIN_DICTATION_WORKSHEET_BY_ID[id]; if (!m) return null; return { id: m.id, title: m.title, subtitle: m.subtitle, category: 'pinyin', subcategory: 'pinyin-dictation', path: `/pinyinPages/pinyinDictation/pinyinDictation?id=${m.id}`, ageMin: m.ageMin, ageMax: m.ageMax, grade: inferGradeFromAge(m.ageMin, m.ageMax), difficulty: m.difficulty, previewImg: '', tags: [...m.tags], isNew: false, isHot: false, sortOrder: m.sortOrder, status: 'draft', }; }