import { __require as requireStrip } from './strip.mjs';
import { __require as requireSrc } from '../../../../../sisteransi@1.0.5/node_modules/sisteransi/src/index.mjs';

var clear;
var hasRequiredClear;
function requireClear() {
  if (hasRequiredClear) return clear;
  hasRequiredClear = 1;
  const strip = requireStrip();
  const {
    erase,
    cursor
  } = requireSrc();
  const width = str => [...strip(str)].length;

  /**
   * @param {string} prompt
   * @param {number} perLine
   */
  clear = function (prompt, perLine) {
    if (!perLine) return erase.line + cursor.to(0);
    let rows = 0;
    const lines = prompt.split(/\r?\n/);
    for (let line of lines) {
      rows += 1 + Math.floor(Math.max(width(line) - 1, 0) / perLine);
    }
    return erase.lines(rows);
  };
  return clear;
}

export { requireClear as __require };
