using System;
using System.Threading;
using System.Threading.Tasks;
using Tornado3_2026Election.Domain;

namespace Tornado3_2026Election.Services;

public interface ITornado3Adapter
{
    string BackendName { get; }

    bool IsLiveCg { get; }

    bool IsConnected { get; }

    string ConnectionTarget { get; }

    TornadoConnectionState State { get; }

    event EventHandler<TornadoConnectionState>? StateChanged;

    event EventHandler? ConnectionChanged;

    Task EnsureConnectedAsync(CancellationToken cancellationToken);

    Task ApplyCutAsync(
        BroadcastChannel channel,
        FormatTemplateDefinition template,
        FormatCutDefinition cut,
        ElectionDataSnapshot snapshot,
        BroadcastStationProfile station,
        string imageRootPath,
        CancellationToken cancellationToken);

    Task<bool> TryCapturePendingCutPreviewAsync(
        BroadcastChannel channel,
        string fileName,
        int width,
        int height,
        int frame,
        CancellationToken cancellationToken);

    Task<bool> TryCaptureCutPreviewAsync(
        BroadcastChannel channel,
        FormatTemplateDefinition template,
        FormatCutDefinition cut,
        ElectionDataSnapshot snapshot,
        BroadcastStationProfile station,
        string imageRootPath,
        string fileName,
        int width,
        int height,
        int frame,
        CancellationToken cancellationToken);

    Task PrepareAsync(BroadcastChannel channel, CancellationToken cancellationToken);

    Task ShowPreparedFirstFrameAsync(BroadcastChannel channel, CancellationToken cancellationToken);

    Task TakeAsync(BroadcastChannel channel, CancellationToken cancellationToken);

    Task ClearOutputAsync(BroadcastChannel channel, CancellationToken cancellationToken);

    Task OutAsync(BroadcastChannel channel, CancellationToken cancellationToken);
}
