using System.Text.Json;
using Tiku.Application.Storage;
using Tiku.Domain.Content;

namespace Tiku.Application.Assets;

public sealed record AssetAccessRequest(
    Guid TenantId,
    Guid AssetId,
    Guid? UserId,
    string? IpAddress,
    string? UserAgent,
    TimeSpan? RequestedExpiresIn = null);

public sealed record AssetAccessResultModel(
    ContentAssetAccessSummary Item,
    AssetAccessPrincipal Access,
    ObjectStorageSignedUrl Url,
    JsonElement Watermark);

public sealed record ContentAssetAccessSummary(
    Guid Id,
    ContentAssetType AssetType,
    string? Title,
    string? FileName,
    string? PreviewUrl,
    AssetUploadStatus UploadStatus,
    AssetSecurityScanStatus SecurityScanStatus,
    AssetPreviewStatus PreviewStatus,
    ContentVisibility Visibility);

public sealed record AssetAccessPrincipal(
    Guid? UserId,
    bool IsMember,
    bool HasSvip);

public sealed class AssetAccessException(string message, string code) : InvalidOperationException(message)
{
    public string Code { get; } = code;
}
