const preserveNewlines = (markdown)=>{
    const codeBlocks = [];
    let result = markdown.replace(/```[\s\S]*?```/g, (m)=>{
        codeBlocks.push(m);
        return `\n%%CODE_BLOCK_${codeBlocks.length - 1}%%\n`;
    });
    result = result.replace(/\n{3,}/g, (match)=>{
        const extraBreaks = match.length - 2;
        return `\n\n${'&nbsp;\n\n'.repeat(extraBreaks)}`;
    });
    result = result.replace(/%%CODE_BLOCK_(\d+)%%/g, (_, i)=>codeBlocks[Number(i)] ?? '');
    return result;
};
const isMac = ()=>"u" > typeof navigator && navigator.platform.includes('Mac');
const getModifierKey = ()=>isMac() ? '⌘' : 'Ctrl';
export { getModifierKey, isMac, preserveNewlines };
