// A formula is drawn as it arrives; one that does not parse yet keeps its last drawing.
const bubble = document.querySelector('aparte-chat-bubble');
bubble.setSegments([{ id: 's1', type: 'text', content: '' }]);
const text = 'The area under $x^2$ from 0 to 1:\n\n$$\n\\int_0^1 x^2\\,dx = \\frac{1}{3}\n$$\n\nAnd a price stays a price: it costs $5 and $10.';
let i = 0;
const tick = setInterval(() => {
bubble.appendToSegment('s1', text.slice(i, i + 3));
i += 3;
if (i >= text.length) {
clearInterval(tick);
bubble.updateSegment('s1', { isStreaming: false });
bubble.removeAttribute('streaming');
}
}, 60);