// EN: Repository interface for BaristaQueueItem aggregate.
// VI: Interface repository cho aggregate BaristaQueueItem.

using FnbEngine.Domain.SeedWork;

namespace FnbEngine.Domain.AggregatesModel.BaristaAggregate;

/// <summary>
/// EN: Repository interface for BaristaQueueItem aggregate root.
/// VI: Interface repository cho aggregate root BaristaQueueItem.
/// </summary>
public interface IBaristaQueueRepository : IRepository<BaristaQueueItem>
{
    /// <summary>
    /// EN: Add a new queue item.
    /// VI: Them item moi vao hang doi.
    /// </summary>
    Task<BaristaQueueItem> AddAsync(BaristaQueueItem item, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Update an existing queue item.
    /// VI: Cap nhat item hang doi hien tai.
    /// </summary>
    void Update(BaristaQueueItem item);

    /// <summary>
    /// EN: Get queue item by ID.
    /// VI: Lay item hang doi theo ID.
    /// </summary>
    Task<BaristaQueueItem?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get active queue items for a shop sorted by priority then created time.
    /// VI: Lay cac item hang doi dang hoat dong cho shop sap xep theo uu tien roi thoi gian tao.
    /// </summary>
    Task<IEnumerable<BaristaQueueItem>> GetActiveByShopAsync(Guid shopId, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get all queue items for a shop (including completed).
    /// VI: Lay tat ca item hang doi cho shop (bao gom da hoan thanh).
    /// </summary>
    Task<IEnumerable<BaristaQueueItem>> GetByShopAsync(Guid shopId, CancellationToken cancellationToken = default);

    /// <summary>
    /// EN: Get queue stats for a shop (counts by status, avg prep time).
    /// VI: Lay thong ke hang doi cho shop (so luong theo trang thai, thoi gian pha che trung binh).
    /// </summary>
    Task<BaristaQueueStats> GetStatsAsync(Guid shopId, CancellationToken cancellationToken = default);
}

/// <summary>
/// EN: Queue statistics for a shop.
/// VI: Thong ke hang doi cho shop.
/// </summary>
public record BaristaQueueStats(
    int TotalQueued,
    int TotalPreparing,
    int TotalReady,
    int TotalDelivered,
    int TotalCancelled,
    double AveragePrepTimeMinutes
);
