using Microsoft.AspNetCore.Components.Web;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using ASTRAIN.Client;
using ASTRAIN.Client.Services;

var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("#app");
builder.RootComponents.Add<HeadOutlet>("head::after");

var apiBaseAddress = builder.Configuration["ApiBaseAddress"];
var baseAddress = string.IsNullOrWhiteSpace(apiBaseAddress)
	? builder.HostEnvironment.BaseAddress
	: apiBaseAddress;

builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(baseAddress) });
builder.Services.AddScoped<ApiClient>();
builder.Services.AddScoped<UserContext>();

await builder.Build().RunAsync();
