#pragma once

#include <filesystem>
#include <string>
#include <vector>

enum class ExternalApplicationId
{
    visual_studio_code,
    visual_studio_code_insiders,
    vscodium,
    cursor,
    windsurf,
    trae,
    zed,
    antigravity,

    visual_studio,

    github_desktop,
    file_explorer,
    terminal,
    git_bash,
    wsl,

    android_studio,

    intellij_idea,
    clion,
    rider,
    pycharm,
    webstorm,
    phpstorm,
    rubymine,
    goland,
    datagrip,
    jetbrains_fleet,

    sublime_text,
    notepad_plus_plus,
    atom,
    pulsar,
    brackets,
    lapce,
    lite_xl,
    geany,
    kate,

    qt_creator,
    codeblocks,
    dev_cpp,
    eclipse,
    netbeans,

    vim,
    neovim,
    emacs,
    helix,
};

struct ExternalApplication
{
    ExternalApplicationId id;
    std::string name;
    bool available = false;
    std::filesystem::path executable;
};

class ApplicationManager
{
public:
    ApplicationManager();

    const std::vector<ExternalApplication> &applications() const { return applications_; }
    const ExternalApplication *application(ExternalApplicationId id) const;
    ExternalApplicationId defaultApplication() const;
    bool launch(ExternalApplicationId application, const std::filesystem::path &repository,
                std::string &error) const;

private:
    struct LaunchTarget
    {
        ExternalApplication info;
        std::vector<std::string> arguments;
    };

    std::vector<LaunchTarget> targets_;
    std::vector<ExternalApplication> applications_;
};