/**
 * 解析ABC曲谱, 获取最小的音符单位
 * @param abcNotation abc曲谱
 * @returns 最小的音符单位
 */
export const getMinNoteUnit = (abcNotation: string) => {
	const lines = abcNotation.split("\n");
	let minNoteUnit = null;

	for (const line of lines) {
		const regex = /L:(\s*)(\d+\/\d+)/;
		const match = line.match(regex);
		console.log("🚀 ~ line:", line, match);
		// Extract the unit note length from the L: directive.
		const unitNoteLengthMatch = line.match(regex);
		if (unitNoteLengthMatch) {
			minNoteUnit = unitNoteLengthMatch[unitNoteLengthMatch.length - 1];
			break;
		}
	}

	return minNoteUnit;
};
