using Microsoft.CommandPalette.Extensions;
using Microsoft.CommandPalette.Extensions.Toolkit;
using Olive.Helpers;
using Olive.Pages;

namespace Olive;

public sealed partial class OliveCommandsProvider : CommandProvider
{
  private readonly SettingsManager _settingsManager = new();

  public OliveCommandsProvider()
  {
    DisplayName = "Olive";
    Icon = IconHelpers.FromRelativePath("Assets\\StoreLogo.png");
    Settings = _settingsManager.Settings;
  }

  public override ICommandItem[] TopLevelCommands()
  {
    return
    [
      new CommandItem(new GifPickerPage(_settingsManager))
      {
        Title = "Olive GIF Picker",
        Subtitle = "Browse through lots of GIFs and find the one that suits you best!",
        MoreCommands =
        [
          new CommandContextItem(_settingsManager.Settings.SettingsPage)
          {
            Title = "Olive Settings",
            Subtitle = "Configure the Klipy API key and result count.",
            Icon = new IconInfo("\uE713")
          }
        ],
        Icon = Icon
      },
      new CommandItem(_settingsManager.Settings.SettingsPage)
      {
        Title = "Olive Settings",
        Subtitle = "Configure the Klipy API key and result count.",
        Icon = new IconInfo("\uE713")
      }
    ];
  }
}
