import { formatDocAsSingleLine } from '../../base-application/support/index.js';
const escapeDoubleQuotes = (text) => {
    if (text.includes('"')) {
        return text.replace(/"/g, '\\"');
    }
    return text;
};
export const formatDocAsJavaDoc = (text, indentSize = 0) => {
    if (indentSize < 0) {
        indentSize = 0;
    }
    if (!text) {
        text = '';
    }
    text = escapeDoubleQuotes(text);
    const indent = ' '.repeat(indentSize);
    const rows = ['/**', ...text.split('\\n').map(row => ` * ${row}`), ' */'].map(row => `${indent}${row}`);
    return rows.join('\n');
};
export const formatDocAsApiDescription = (text) => {
    if (!text) {
        return text;
    }
    return escapeDoubleQuotes(formatDocAsSingleLine(text));
};
