"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.lineWrap = void 0;
function lineWrap(text, MAX = 15) {
    const lines = [];
    const segments = text.split(' ');
    const l = segments.length;
    let line_segments = [];
    let line_segments_char_count = 0;
    for (let i = 0; i < l; i++) {
        const segment = segments[i];
        const segment_l = segment.length;
        if (line_segments_char_count + line_segments.length - 1 + segment_l > MAX) {
            lines.push(line_segments.join(' '));
            line_segments = [];
            line_segments_char_count = 0;
        }
        line_segments.push(segment);
        line_segments_char_count += segment_l;
    }
    if (line_segments.length > 0) {
        lines.push(line_segments.join(' '));
    }
    return lines;
}
exports.lineWrap = lineWrap;
//# sourceMappingURL=lineWrap.js.map