using System;
using Nexamas.UI.Application;
using Nexamas.UI.Components;
using Nexamas.UI.Controls;

internal static class Program
{
    private static int Main()
    {
        MASApplication.ConfigureRuntime(
            enableDiagnosticsDiskLogging: true,
            throwOnSwallowedException: false,
            throwOnLifecycleBreakingException: true,
            traceRepeatedBoundaryExceptions: true);

        MASButton button = MASButton.Create("Packed consumer button");
        MASToggleSwitch toggle = MASToggleSwitch.Create("Packed consumer toggle");
        MASDataView view = new MASDataView();
        view.AddColumn("id", "ID");
        view.AddColumn("name", "Name");
        view.AddRow(1, "Package row");
        view.SortByColumn("id", MASDataGridSortDirection.Ascending);

        var diagnosticsSnapshot = MASApplication.Diagnostics.GetSnapshot();
        if (diagnosticsSnapshot == null || diagnosticsSnapshot.RecentFaults == null || !diagnosticsSnapshot.IsReadOnlySnapshot)
        {
            Console.Error.WriteLine("Nexamas UI packed consumer probe failed to read the public diagnostics snapshot gateway.");
            return 3;
        }

        if (button == null || toggle == null || view.VisibleRowCount != 1)
        {
            Console.Error.WriteLine("Nexamas UI packed consumer probe failed to exercise public package APIs.");
            return 2;
        }

        Console.WriteLine("Nexamas UI packed consumer probe PASS: " + typeof(MASButton).Assembly.FullName);
        return 0;
    }
}
