namespace SatelliteProvider.Services.RouteManagement.TileProvision;

public sealed record RouteTileDeliveryJob(
    Guid RouteId,
    IReadOnlyList<(double Lat, double Lon)> Waypoints,
    double RegionSizeMeters,
    int Zoom,
    IReadOnlyList<IReadOnlyList<(double Lat, double Lon)>> GeofenceVertices,
    bool IncludeGeofenceTiles,
    IReadOnlyList<ClientTileSnapshot> ClientTiles);

public sealed record PreparedTileDelivery(
    RouteTileCandidate Candidate,
    byte[] Jpeg,
    byte[] ContentSha256,
    double ResolutionMetersPerPx,
    DateTime CapturedAtUtc,
    string Source);

public interface IRouteTileDeliverySink
{
    ValueTask WriteManifestAsync(uint totalCandidates, uint skippedByClient, uint toDeliver, CancellationToken cancellationToken);
    ValueTask WriteBatchAsync(uint batchSeq, IReadOnlyList<PreparedTileDelivery> tiles, CancellationToken cancellationToken);
    ValueTask WriteProgressAsync(uint delivered, uint total, uint downloading, CancellationToken cancellationToken);
    ValueTask WriteCompleteAsync(uint delivered, uint skippedClient, uint skippedServerFilter, CancellationToken cancellationToken);
    ValueTask WriteErrorAsync(string code, string message, bool retryable, CancellationToken cancellationToken);
}
