using IntegryApiClient.MAUI;
using Microsoft.Extensions.Logging;
using Template.Maui.Services;
using Template.Shared;
using Template.Shared.Interfaces;

namespace Template.Maui
{
    public static class MauiProgram
    {
#if DEBUG
        private const string BaseRestServicesEndpoint = "https://devservices.studioml.it/ems-api/";
        //private const string BaseRestServicesEndpoint = "http://192.168.2.23:8080/ems-api/";
#else
    private const string BaseRestServicesEndpoint = "https://services.studioml.it/ems-api/";
#endif

        public static MauiApp CreateMauiApp()
        {
            InteractiveRenderSettings.ConfigureBlazorHybridRenderModes();

            var builder = MauiApp.CreateBuilder();
            builder
                .UseMauiApp<App>()
                .UseIntegry(BaseRestServicesEndpoint)
                .ConfigureFonts(fonts =>
                {
                    fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
                });

            builder.Services.AddMauiBlazorWebView();
            builder.Services.AddBlazorBootstrap();

#if DEBUG
            builder.Services.AddBlazorWebViewDeveloperTools();
    		builder.Logging.AddDebug();
#endif

            builder.Services.AddSingleton<IFormFactor, FormFactor>();

            return builder.Build();
        }
    }
}
