using OF_DL.Models.Downloads;
using ArchivedEntities = OF_DL.Models.Entities.Archived;
using MessageEntities = OF_DL.Models.Entities.Messages;
using PostEntities = OF_DL.Models.Entities.Posts;
using PurchasedEntities = OF_DL.Models.Entities.Purchased;
using StreamEntities = OF_DL.Models.Entities.Streams;

namespace OF_DL.Services;

public interface IDownloadService
{
    /// <summary>
    /// Calculates the total size of a set of URLs by fetching their metadata.
    /// </summary>
    Task<long> CalculateTotalFileSize(List<string> urls);

    /// <summary>
    /// Downloads media and updates metadata storage.
    /// </summary>
    Task<bool> ProcessMediaDownload(string folder, long mediaId, string apiType, string url, string path,
        string serverFileName, string resolvedFileName, string extension, IProgressReporter progressReporter);

    /// <summary>
    /// Retrieves decryption information for a DRM media item.
    /// </summary>
    Task<(string decryptionKey, DateTime lastModified, double? mpdDurationSeconds)?> GetDecryptionInfo(
        string mpdUrl, string policy, string signature, string kvp,
        string mediaId, string contentId, string drmType,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing);

    /// <summary>
    /// Downloads profile avatar and header images for a creator.
    /// </summary>
    Task DownloadAvatarHeader(string? avatarUrl, string? headerUrl, string folder, string username);

    /// <summary>
    /// Downloads highlight media for a creator.
    /// </summary>
    Task<DownloadResult> DownloadHighlights(string username, long userId, string path, HashSet<long> paidPostIds,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads story media for a creator.
    /// </summary>
    Task<DownloadResult> DownloadStories(string username, long userId, string path, HashSet<long> paidPostIds,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads archived posts for a creator.
    /// </summary>
    Task<DownloadResult> DownloadArchived(string username, long userId, string path, Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing, ArchivedEntities.ArchivedCollection archived,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads free messages for a creator.
    /// </summary>
    Task<DownloadResult> DownloadMessages(string username, long userId, string path, Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing, MessageEntities.MessageCollection messages,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads paid messages for a creator.
    /// </summary>
    Task<DownloadResult> DownloadPaidMessages(string username, string path, Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        PurchasedEntities.PaidMessageCollection paidMessageCollection,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads stream posts for a creator.
    /// </summary>
    Task<DownloadResult> DownloadStreams(string username, long userId, string path, Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing, StreamEntities.StreamsCollection streams,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads free posts for a creator.
    /// </summary>
    Task<DownloadResult> DownloadFreePosts(string username, long userId, string path, Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing, PostEntities.PostCollection posts,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads paid posts for a creator.
    /// </summary>
    Task<DownloadResult> DownloadPaidPosts(string username, long userId, string path, Dictionary<string, long> users,
        bool clientIdBlobMissing, bool devicePrivateKeyMissing, PurchasedEntities.PaidPostCollection purchasedPosts,
        IProgressReporter progressReporter);

    /// <summary>
    /// Downloads paid posts sourced from the Purchased tab.
    /// </summary>
    Task<DownloadResult> DownloadPaidPostsPurchasedTab(string username, string path,
        Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        PurchasedEntities.PaidPostCollection purchasedPosts, IProgressReporter progressReporter);

    /// <summary>
    /// Downloads paid messages sourced from the Purchased tab.
    /// </summary>
    Task<DownloadResult> DownloadPaidMessagesPurchasedTab(string username, string path,
        Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        PurchasedEntities.PaidMessageCollection paidMessageCollection, IProgressReporter progressReporter);

    /// <summary>
    /// Downloads a single post collection.
    /// </summary>
    Task<DownloadResult> DownloadSinglePost(string username, string path,
        Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        PostEntities.SinglePostCollection post, IProgressReporter progressReporter);

    /// <summary>
    /// Downloads a single paid message collection.
    /// </summary>
    Task<DownloadResult> DownloadSinglePaidMessage(string username, string path,
        Dictionary<string, long> users, bool clientIdBlobMissing, bool devicePrivateKeyMissing,
        PurchasedEntities.SinglePaidMessageCollection singlePaidMessageCollection,
        IProgressReporter progressReporter);
}
