using AntDesign.ProLayout;
using Blazored.LocalStorage;
using Microsoft.AspNetCore.Components.Authorization;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Net.Http;
using System.Threading.Tasks;
using wispro.sp.web.Auth;
using wispro.sp.web.Services;

namespace wispro.sp.web
{
    public class Program
    {
        public static async Task Main(string[] args)
        {
            var builder = WebAssemblyHostBuilder.CreateDefault(args);
            builder.RootComponents.Add<wispro.sp.web.App>("#app");

            builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
            builder.Services.AddAntDesign();
            builder.Services.Configure<ProSettings>(builder.Configuration.GetSection("ProSettings"));

            builder.Services.AddScoped<IChartService, ChartService>();
            builder.Services.AddScoped<IProjectService, ProjectService>();
            builder.Services.AddScoped<IUserService, UserService>();
            
            builder.Services.AddScoped<IProfileService, ProfileService>();
            builder.Services.AddScoped<StaffGradeService, StaffGradeService>();
            builder.Services.AddScoped<PerformanceItemServices, PerformanceItemServices>();
            builder.Services.AddBlazoredLocalStorage();
            builder.Services.AddAuthorizationCore(option=>
                option.AddPolicy("admin",policy=>policy.RequireClaim("admin"))
            );
            builder.Services.AddScoped<AuthenticationStateProvider, JwtAuthenticationStateProvider>();
            builder.Services.AddScoped<IAuthService, AuthService>();
            builder.Services.AddScoped<TaskService, TaskService>();

            await builder.Build().RunAsync();
        }
    }
}