namespace Lumi.Companion.Abstractions;

public enum CompanionPluginHealth
{
    Ready,
    Healthy,
    Warning,
    Error
}

public sealed record CompanionPluginDescriptor(
    string Id,
    string Name,
    Version Version,
    string Description,
    int Order = 100);

public sealed record CompanionPluginPage(
    string Key,
    string Label,
    int Order = 100);

public sealed record CompanionPluginStatus(
    CompanionPluginHealth Health,
    string Summary,
    string? Detail = null);

public sealed record CompanionPluginAction(
    string Id,
    Func<string> Label,
    Func<CancellationToken, Task> Execute,
    Func<bool>? CanExecute = null,
    int Order = 100);

/// <summary>
/// A UI-neutral contribution contract. The Avalonia shell owns rendering and
/// guarantees that each plugin receives one nested root in both the sidebar and
/// tray menu instead of leaking loose actions into the global navigation.
/// </summary>
public interface ICompanionPluginContribution
{
    CompanionPluginDescriptor Descriptor { get; }
    IReadOnlyList<CompanionPluginPage> Pages { get; }
    IReadOnlyList<CompanionPluginAction> Actions { get; }
    CompanionPluginStatus Status { get; }
    event Action? Changed;
}
