const ANSI = /\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1b\\)|_[\s\S]*?\x1b\\)/g; function isEditorBorder(line: string): boolean { const plain = line.replace(ANSI, ""); return /^─+$/.test(plain) || /^─── [↑↓] \d+ more ─*$/.test(plain); } export function addInputPrompt(lines: string[], prompt: string, promptWidth: number, border: string): string[] { if (!prompt) return lines; const continuation = " ".repeat(promptWidth); let renderedPrompt = false; return lines.map((line, index) => { if (index === 0 || isEditorBorder(line)) return line + border; if (!renderedPrompt) { renderedPrompt = true; return prompt + line; } return continuation + line; }); }