﻿Option Strict On
Option Explicit On

Imports System
Imports System.Collections.Generic

Friend NotInheritable Class ShowcaseProductJourney

    Friend ReadOnly Property Id As String
    Friend ReadOnly Property Title As String
    Friend ReadOnly Property Audience As String
    Friend ReadOnly Property Summary As String
    Friend ReadOnly Property EntryIds As IReadOnlyList(Of String)

    Friend Sub New(id As String,
                   title As String,
                   audience As String,
                   summary As String,
                   entryIds As IEnumerable(Of String))
        Me.Id = If(id, String.Empty).Trim()
        Me.Title = If(title, String.Empty).Trim()
        Me.Audience = If(audience, String.Empty).Trim()
        Me.Summary = If(summary, String.Empty).Trim()

        Dim ids As New List(Of String)()
        If entryIds IsNot Nothing Then
            For Each entryId As String In entryIds
                Dim normalizedEntryId As String = If(entryId, String.Empty).Trim()
                If normalizedEntryId.Length > 0 Then ids.Add(normalizedEntryId)
            Next
        End If
        Me.EntryIds = ids.AsReadOnly()
    End Sub
End Class

Partial Friend NotInheritable Class ShowcaseNavigationCatalog

    Private Shared ReadOnly _productJourneys As IReadOnlyList(Of ShowcaseProductJourney) = CreateProductJourneys()

    Private Shared Function CreateProductJourneys() As IReadOnlyList(Of ShowcaseProductJourney)
        Dim journeys As New List(Of ShowcaseProductJourney) From {
            New ShowcaseProductJourney(
                "executive",
                "Executive buyer tour",
                "Buyer / decision maker",
                "A short path that shows product value first: commands, inputs, data, theme/RTL, output, and proof.",
                New String() {"buttons", "inputs", "datagrid", "theme.studio", "localization.rtl.product", "output.product", "certification.center"}),
            New ShowcaseProductJourney(
                "developer",
                "Developer architecture tour",
                "Developer / integrator",
                "A technical path through PageHost ownership, services, workflow, productivity navigation, and SDK consumption boundaries.",
                New String() {"application.architecture", "services", "workflow.foundations", "productivity.navigation", "output.product", "element.coverage"}),
            New ShowcaseProductJourney(
                "data-proof",
                "Data and scale proof",
                "Data-heavy product review",
                "A focused route for table-heavy information, analytics, charts, inspector surfaces, and virtualization evidence.",
                New String() {"datagrid", "data.analytics", "charts.dashboard", "property.inspector", "virtualization", "diagnostics.dashboard"}),
            New ShowcaseProductJourney(
                "theme-rtl",
                "Theme, material, and RTL tour",
                "Product designer / RTL buyer",
                "A visual path for theme switching, surface materials, localization, RTL layout, and motion consumers.",
                New String() {"theme.studio", "surface.materials", "localization.rtl.product", "motion", "inputs", "datagrid"}),
            New ShowcaseProductJourney(
                "quality",
                "Quality and certification proof",
                "Technical evaluator",
                "A proof-first path that keeps gates, coverage, diagnostics, render verification, and commercial readiness available without dominating the first screen.",
                New String() {"certification.center", "element.coverage", "render.verification", "diagnostics.dashboard", "commercial.foundations"})
        }

        Return journeys.AsReadOnly()
    End Function

    Friend Shared Function GetProductJourneys() As IReadOnlyList(Of ShowcaseProductJourney)
        Return _productJourneys
    End Function

    Friend Shared Function FindProductJourneyById(id As String) As ShowcaseProductJourney
        Dim normalizedId As String = If(id, String.Empty).Trim()
        If normalizedId.Length = 0 Then Return Nothing

        For Each journey As ShowcaseProductJourney In _productJourneys
            If journey IsNot Nothing AndAlso String.Equals(journey.Id, normalizedId, StringComparison.OrdinalIgnoreCase) Then
                Return journey
            End If
        Next

        Return Nothing
    End Function

    Friend Shared Function GetJourneyEntries(journey As ShowcaseProductJourney) As IReadOnlyList(Of ShowcaseNavigationEntry)
        Dim result As New List(Of ShowcaseNavigationEntry)()
        If journey Is Nothing Then Return result.AsReadOnly()

        For Each entryId As String In journey.EntryIds
            Dim entry As ShowcaseNavigationEntry = FindById(entryId)
            If entry IsNot Nothing Then result.Add(entry)
        Next

        Return result.AsReadOnly()
    End Function

    Friend Shared Function GetFirstJourneyEntry(journey As ShowcaseProductJourney) As ShowcaseNavigationEntry
        Dim entries As IReadOnlyList(Of ShowcaseNavigationEntry) = GetJourneyEntries(journey)
        If entries.Count = 0 Then Return Nothing
        Return entries(0)
    End Function

    Friend Shared Function ResolveJourneyPathText(journey As ShowcaseProductJourney) As String
        If journey Is Nothing Then Return String.Empty

        Dim titles As New List(Of String)()
        For Each entry As ShowcaseNavigationEntry In GetJourneyEntries(journey)
            titles.Add(entry.Title)
        Next

        Return String.Join(" → ", titles.ToArray())
    End Function
End Class
