Option Strict On
Option Explicit On

Imports System.Collections.Generic
Imports System.Linq

Namespace Nexamas.UI.ThemeStudio

    ''' <summary>
    ''' Readiness report for Phase 5 Theme Studio / Surface Designer foundation.
    ''' </summary>
    ''' <remarks>
    ''' The report is public because gates, diagnostics, and future Showcase pages need a
    ''' safe readiness summary. It only exposes counts and findings, not internal registries.
    ''' </remarks>
    Friend NotInheritable Class MASThemeStudioReadinessReport

        Friend Sub New(themeCount As Integer,
                       materialCount As Integer,
                       materialProfileCount As Integer,
                       slotCount As Integer,
                       roleCount As Integer,
                       visualStyleCount As Integer,
                       contrastCheckCount As Integer,
                       findings As IEnumerable(Of MASThemeStudioReadinessFinding))
            Me.ThemeCount = Math.Max(0, themeCount)
            Me.MaterialCount = Math.Max(0, materialCount)
            Me.MaterialProfileCount = Math.Max(0, materialProfileCount)
            Me.SlotCount = Math.Max(0, slotCount)
            Me.RoleCount = Math.Max(0, roleCount)
            Me.VisualStyleCount = Math.Max(0, visualStyleCount)
            Me.ContrastCheckCount = Math.Max(0, contrastCheckCount)

            Dim list As New List(Of MASThemeStudioReadinessFinding)()
            If findings IsNot Nothing Then list.AddRange(findings)
            Me.Findings = list.AsReadOnly()
        End Sub

        Friend ReadOnly Property ThemeCount As Integer
        Friend ReadOnly Property MaterialCount As Integer
        Friend ReadOnly Property MaterialProfileCount As Integer
        Friend ReadOnly Property SlotCount As Integer
        Friend ReadOnly Property RoleCount As Integer
        Friend ReadOnly Property VisualStyleCount As Integer
        Friend ReadOnly Property ContrastCheckCount As Integer
        Friend ReadOnly Property Findings As IReadOnlyList(Of MASThemeStudioReadinessFinding)

        Friend ReadOnly Property ErrorCount As Integer
            Get
                Return Global.System.Linq.Enumerable.Count(Findings, Function(finding) finding IsNot Nothing AndAlso finding.Severity = MASThemeStudioReadinessSeverity.Error)
            End Get
        End Property

        Friend ReadOnly Property WarningCount As Integer
            Get
                Return Global.System.Linq.Enumerable.Count(Findings, Function(finding) finding IsNot Nothing AndAlso finding.Severity = MASThemeStudioReadinessSeverity.Warning)
            End Get
        End Property

        Friend ReadOnly Property ReadyForPhase5Foundation As Boolean
            Get
                Return ErrorCount = 0 AndAlso
                       ThemeCount >= 3 AndAlso
                       MaterialCount >= 8 AndAlso
                       MaterialProfileCount >= 5 AndAlso
                       SlotCount >= 10 AndAlso
                       RoleCount >= 8 AndAlso
                       VisualStyleCount >= 1 AndAlso
                       ContrastCheckCount >= ThemeCount * 3
            End Get
        End Property

    End Class

End Namespace
