export const LATE_CHUNK_MIN_TOKEN_ESTIMATE = 2_000;
export function isLateChunkingEnabled() {
    return process.env.TUBEROSA_LATE_CHUNKING_ENABLED === 'true';
}
export function isLateChunkingSupported(provider) {
    if (!isLateChunkingEnabled()) {
        return false;
    }
    return typeof provider.supportsLongContextEmbed === 'function' && provider.supportsLongContextEmbed();
}
export async function lateChunkDocument(provider, document) {
    if (!isLateChunkingSupported(provider)) {
        return undefined;
    }
    const tokens = Math.ceil(document.content.length / 4);
    if (tokens < LATE_CHUNK_MIN_TOKEN_ESTIMATE) {
        return undefined;
    }
    // Phase 4 carry-over: when a real long-context embedder lands, replace this stub
    // with: (1) embed the whole document once via provider.embed; (2) for each atom,
    // pool the embedder's token vectors across [lineStart..lineEnd]; (3) emit per-atom
    // vectors via the returned Map. Until then, return undefined and let the existing
    // chunk-and-embed path run unchanged.
    return undefined;
}
