"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tokensEqual = tokensEqual;
exports.formatAnchor = formatAnchor;
exports.findAllSequences = findAllSequences;
function tokensEqual(a, b) {
    if (a.type === 'bpe' || b.type === 'bpe') {
        return (a.text.replace(/\r?\n/g, '').trim() ===
            b.text.replace(/\r?\n/g, '').trim());
    }
    return a.text === b.text;
}
function formatAnchor(anchor) {
    return anchor.map((t) => t.text).join(' ');
}
function findAllSequences(haystack, needle) {
    if (needle.length === 0)
        return [];
    const indices = [];
    outer: for (let i = 0; i <= haystack.length - needle.length; i++) {
        for (let j = 0; j < needle.length; j++) {
            if (!tokensEqual(haystack[i + j], needle[j])) {
                continue outer;
            }
        }
        indices.push(i);
    }
    return indices;
}
//# sourceMappingURL=tokens.js.map