Option Strict On
Option Explicit On

Namespace Nexamas.UI.Theming

    ''' <summary>
    ''' Internal access gateway from the public theme identity contract into Nexamas UI-owned
    ''' deep theme composition contracts.
    ''' </summary>
    ''' <remarks>
    ''' Public consumers receive <see cref="IMASAppTheme"/> as a stable theme identity and
    ''' selection contract. Controls, renderers, Theme Studio, and commercial gates use this
    ''' Friend gateway to consume foundation and family recipes without exposing the full
    ''' recipe graph as SDK public API.
    ''' </remarks>
    Friend NotInheritable Class MASAppThemeContracts

        Private Sub New()
        End Sub

        Friend Shared Function Foundation(theme As IMASAppTheme) As IMASThemeFoundation
            Dim foundationContract As IMASThemeFoundation = TryCast(theme, IMASThemeFoundation)
            If foundationContract Is Nothing Then
                Throw New Global.System.InvalidOperationException("The selected MAS app theme does not provide the internal foundation contract required by Nexamas UI rendering. Use a Nexamas UI-provided theme or a theme derived inside Nexamas UI from MASAppThemeBase.")
            End If

            Return foundationContract
        End Function

        Friend Shared Function Families(theme As IMASAppTheme) As IMASThemeFamilies
            Dim familiesContract As IMASThemeFamilies = TryCast(theme, IMASThemeFamilies)
            If familiesContract Is Nothing Then
                Throw New Global.System.InvalidOperationException("The selected MAS app theme does not provide the internal family contract required by Nexamas UI controls. Use a Nexamas UI-provided theme or a theme derived inside Nexamas UI from MASAppThemeBase.")
            End If

            Return familiesContract
        End Function

    End Class

End Namespace
