import dd from 'ts-dedent';
import { DataTransferType, isVSCode, tryParseVSCodeData } from "../../../utils/clipboard.js";
import { LATEX_MODES } from "./const.js";
export function isLatexMode(mode) {
    if (!mode)
        return false;
    return LATEX_MODES.has(mode.toLowerCase());
}
export function parseLatexFormulas(content) {
    const blocks = content.split(/\n\s*\n/);
    const formulas = [];
    for (const block of blocks) {
        const lines = block
            .split('\n')
            .map((line) => line.trim())
            .filter((line) => line.length > 0);
        if (lines.length > 0) {
            formulas.push(lines.join('\n'));
        }
    }
    return formulas;
}
export function getLatexData(data) {
    if (!data.getData(DataTransferType.Text))
        return null;
    if (isVSCode(data)) {
        const vsCodeData = tryParseVSCodeData(data);
        const mode = vsCodeData?.mode;
        if (mode && isLatexMode(mode)) {
            return {
                editor: 'vscode',
                mode,
                value: dd(data.getData(DataTransferType.Text)),
            };
        }
    }
    return null;
}
//# sourceMappingURL=utils.js.map
