namespace NexusReader.Maui;

public partial class App : Microsoft.Maui.Controls.Application
{
	public App()
	{
		InitializeComponent();

		MainPage = new MainPage();
	}

	protected override Window CreateWindow(IActivationState? activationState)
	{
		var window = base.CreateWindow(activationState);

		// Hook into native MAUI lifecycle events to cleanly flush and close Serilog buffers
		window.Stopped += (s, e) => 
		{
			Serilog.Log.CloseAndFlush();
		};

		window.Destroying += (s, e) => 
		{
			Serilog.Log.CloseAndFlush();
		};

		return window;
	}
}
