namespace VideoStudy.Shared;

/// <summary>
/// Request model for video analysis
/// </summary>
public class AnalysisRequest
{
    public string VideoUrl { get; set; } = string.Empty;
    public string Language { get; set; } = "en"; // Input language (subtitles)
    public string? OutputLanguage { get; set; } // Output language (tutorial). null = same as Language
    public string Mode { get; set; } = "fast"; // fast or advanced
    public string? TranscriptText { get; set; } // Optional: if client already transcribed it
    public double DurationSeconds { get; set; }
}

/// <summary>
/// Response model containing analysis results
/// </summary>
public class AnalysisResponse
{
    public string VideoTitle { get; set; } = string.Empty;
    public string DocumentTitle { get; set; } = string.Empty; // New
    public string Category { get; set; } = "OTHER"; // New
    public string Transcript { get; set; } = string.Empty;
    public List<KeyMoment> KeyMoments { get; set; } = [];
    public string Analysis { get; set; } = string.Empty;
    public List<TutorialSection> TutorialSections { get; set; } = [];
    public List<string> DebugSteps { get; set; } = [];
    public string? RawLlmResponse { get; set; }
    public byte[]? PdfData { get; set; }
    public string Status { get; set; } = "success";
    public string? ErrorMessage { get; set; }
}

public class TutorialSection
{
    public string Title { get; set; } = string.Empty;
    public string Content { get; set; } = string.Empty;
    public string? ImageTimestamp { get; set; } // "HH:MM:SS"
    public int? ImageTimeSeconds { get; set; }
    public byte[]? ImageData { get; set; } // For internal use during PDF generation
}

/// <summary>
/// Represents a key moment in the video
/// </summary>
public class KeyMoment
{
    public string Timestamp { get; set; } = string.Empty;
    public string Description { get; set; } = string.Empty;
    public int StartSeconds { get; set; }
    public string Explanation { get; set; } = string.Empty;
}

/// <summary>
/// Progress update for long-running operations
/// </summary>
public class ProgressUpdate
{
    public double PercentComplete { get; set; }
    public string Message { get; set; } = string.Empty;
    public string Stage { get; set; } = string.Empty;
}

public class VideoInfo
{
    public string Title { get; set; } = string.Empty;
    public TimeSpan Duration { get; set; }
    public string Url { get; set; } = string.Empty;
    public string ThumbnailUrl { get; set; } = string.Empty;
    public string Author { get; set; } = string.Empty;
}

public class Transcription
{
    public string FullText { get; set; } = string.Empty;
    public List<TranscriptionSegment> Segments { get; set; } = [];
    public string Language { get; set; } = "en";
}

public class TranscriptionSegment
{
    public string Timestamp { get; set; } = string.Empty;
    public string Text { get; set; } = string.Empty;
    public double StartSeconds { get; set; }
    public double EndSeconds { get; set; }
}

public class ProcessingResult
{
    public Transcription Transcription { get; set; } = new();
    public List<KeyMoment> KeyMoments { get; set; } = [];
    public List<string> ScreenshotPaths { get; set; } = [];
}

public class DownloadProgress
{
    public double PercentComplete { get; set; }
    public string Status { get; set; } = string.Empty;
}

public interface IPdfSaver
{
    Task<string?> SavePdfAsync(byte[] pdfData, string suggestedFileName);
}