export interface ParsedQuestion {
    id: string;
    questionText: string;
}

const parseText = (text: string): ParsedQuestion[] => {
    const lines = text.split('\\n').filter(line => line.trim());
    return lines.map(line => {
        const match = line.match(/(.*?)\{\{(\d+)\}\}/);
        if (match) {
            return {
                questionText: match[1],
                id: match[2]
            };
        }
        return { questionText: line, id: '' };
    }).filter(q => q.id);
};

const reconstructText = (questions: ParsedQuestion[]): string => {
    return questions.map(q => `${q.questionText}{{${q.id}}}`).join('\\n') + '\\n';
};

export {
    parseText,
    reconstructText
}
