"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findFirstWordIndex = void 0;
const findFirstWordIndex = (lines, locale) => {
    const firstWordIndex = lines.findIndex((line, index) => {
        const nextLine = line[index + 1] || '';
        const isNextLineInOrder = line.localeCompare(nextLine, locale) > 0;
        const hasWhitespace = Boolean(line.match(/\s/));
        const isEmpty = line.trim().length === 0;
        return !isEmpty && !hasWhitespace && isNextLineInOrder;
    });
    if (typeof firstWordIndex === 'undefined') {
        throw new Error('Cannot find index of the first word in the file');
    }
    return firstWordIndex;
};
exports.findFirstWordIndex = findFirstWordIndex;
