using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;

namespace NexusReader.Application.Abstractions.Persistence;

/// <summary>
/// Represents a chunk of text retrieved from the semantic vector database.
/// </summary>
public record VectorChunk(string Content, string EbookId, double Score, string MetadataJson = "", string BookTitle = "", string ChapterTitle = "");

/// <summary>
/// Abstraction for performing semantic vector searches, isolating Qdrant gRPC dependencies from the Application layer.
/// </summary>
public interface IVectorSearchStore
{
    /// <summary>
    /// Searches the entire global catalog (filtered by tenant) for the best semantic matches.
    /// </summary>
    Task<List<VectorChunk>> SearchGlobalAsync(string queryText, string tenantId, int limit, CancellationToken cancellationToken = default);

    /// <summary>
    /// Searches within a whitelist of owned book IDs for the best semantic matches.
    /// </summary>
    Task<List<VectorChunk>> SearchLocalAsync(string queryText, string tenantId, List<Guid> whitelistedBookIds, int limit, CancellationToken cancellationToken = default);

    /// <summary>
    /// Searches the entire global catalog (filtered by tenant) for the best semantic matches, excluding a specific book ID.
    /// </summary>
    Task<List<VectorChunk>> SearchGlobalExcludeAsync(string queryText, string tenantId, Guid excludeBookId, int limit, CancellationToken cancellationToken = default);
}
