using IOModuleTestBlazor;
using IOModuleTestBlazor.Components;
using IOModuleTestBlazor.Services;

var builder = WebApplication.CreateBuilder(args);

// ── CAN bus ───────────────────────────────────────────────────────────────────
builder.Services.AddSingleton<ICanService, CanService>();
builder.Services.AddHostedService<CanWorker>();

// ── Serial port ───────────────────────────────────────────────────────────────
builder.Services.AddSingleton<ISerialPortService, SerialPortService>();

// ── Blazor ────────────────────────────────────────────────────────────────────
builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents();

var app = builder.Build();

if (!app.Environment.IsDevelopment())
{
    app.UseExceptionHandler("/Error", createScopeForErrors: true);
    app.UseHsts();
}
app.UseStatusCodePagesWithReExecute("/not-found", createScopeForStatusCodePages: true);
app.UseHttpsRedirection();

app.UseAntiforgery();

app.MapStaticAssets();
app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode();

app.Run();
