using Microsoft.AspNetCore.Components; using Microsoft.AspNetCore.Components.Authorization; using Microsoft.AspNetCore.Components.WebAssembly.Hosting; using MudBlazor; using MudBlazor.Services; using RobotNet10.CustomConfigurationEditor.Services.API; using RobotNet10.CustomConfigurationEditor.Services.State; using RobotNet10.FleetManager.Client; using RobotNet10.FleetManager.Client.Services; using RobotNet10.MapEditor.Services.API; using RobotNet10.MapEditor.Services.State; using RobotNet10.ScriptEditor; using System.Globalization; CultureInfo.DefaultThreadCurrentCulture = new CultureInfo("en-US"); var builder = WebAssemblyHostBuilder.CreateDefault(args); builder.Logging.AddFilter("System.Net.Http.HttpClient", LogLevel.Warning); builder.Services.AddAuthorizationCore(); builder.Services.AddCascadingAuthenticationState(); builder.Services.AddAuthenticationStateDeserialization(); builder.Services.AddNavigationMenu(); builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress), }); builder.Services.AddMudServices(config => { config.SnackbarConfiguration.VisibleStateDuration = 2000; config.SnackbarConfiguration.HideTransitionDuration = 500; config.SnackbarConfiguration.ShowTransitionDuration = 500; config.SnackbarConfiguration.PositionClass = Defaults.Classes.Position.BottomLeft; }); // MapEditor Services builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); // Robot Management Services builder.Services.AddScoped(); builder.Services.AddScoped(); // SignalR Hub Client - Use factory to create per-scope instances builder.Services.AddScoped(sp => { var navigationManager = sp.GetRequiredService(); var logger = sp.GetService>(); return new RobotStateHubClient(navigationManager, logger); }); // Robot Monitor State builder.Services.AddScoped(sp => { var mapApiService = sp.GetRequiredService(); var robotApiService = sp.GetRequiredService(); var robotModelApiService = sp.GetRequiredService(); var hubClient = sp.GetRequiredService(); return new RobotMonitorState(mapApiService, robotApiService, robotModelApiService, hubClient); }); // Config Manager Services builder.Services.AddScoped(); builder.Services.AddScoped(sp => { var configApi = sp.GetRequiredService(); var authStateProvider = sp.GetService(); return new ConfigManagerState(configApi, authStateProvider, "Distributor"); }); // Script Engine Services builder.Services.AddScriptEditor(); await builder.Build().RunAsync();