using PlotLine.Models;

namespace PlotLine.ViewModels;

public sealed class HelpDiagnosticsViewModel
{
    public IReadOnlyList<HelpArticle> Articles { get; set; } = [];
    public IReadOnlyList<HelpCoverageItem> Coverage { get; set; } = [];
    public int TotalArticles => Articles.Count;
    public int TotalValidArticles => Articles.Count(x => x.IsValid);
    public int TotalInvalidArticles => Articles.Count(x => !x.IsValid);
    public int CoveragePercentage => TotalArticles == 0 ? 0 : (int)Math.Round(TotalValidArticles * 100.0 / TotalArticles);
}

public sealed class HelpArticleDiagnosticViewModel
{
    public HelpArticle Article { get; set; } = new();
}

public sealed class HelpDrawerArticleViewModel
{
    public HelpArticle? Article { get; set; }
    public string RenderedHtml { get; set; } = string.Empty;
    public IReadOnlyList<HelpArticle> RelatedArticles { get; set; } = [];
    public string RequestedContextKey { get; set; } = string.Empty;
}

public sealed class HelpCentreIndexViewModel
{
    public string? Query { get; set; }
    public IReadOnlyList<HelpCategoryViewModel> Categories { get; set; } = [];
    public IReadOnlyList<HelpArticle> SearchResults { get; set; } = [];
    public IReadOnlyList<HelpArticle> RecentArticles { get; set; } = [];
    public int ArticleCount { get; set; }
    public bool HasSearch => !string.IsNullOrWhiteSpace(Query);
}

public sealed class HelpCategoryViewModel
{
    public string CategoryName { get; set; } = string.Empty;
    public string CategorySlug { get; set; } = string.Empty;
    public int ArticleCount { get; set; }
    public string Url => $"/help/{CategorySlug}";
}

public sealed class HelpCategoryArticlesViewModel
{
    public string CategoryName { get; set; } = string.Empty;
    public string CategorySlug { get; set; } = string.Empty;
    public IReadOnlyList<HelpArticle> Articles { get; set; } = [];
    public string Url => $"/help/{CategorySlug}";
}

public sealed class HelpCentreArticleViewModel
{
    public HelpArticle Article { get; set; } = new();
    public string RenderedHtml { get; set; } = string.Empty;
    public IReadOnlyList<HelpArticle> RelatedArticles { get; set; } = [];
}
