#!/bin/pwsh
. "$PSScriptRoot/../Scripts/Context.ps1";
. "$PSScriptRoot/../Scripts/SoftwarePackage.ps1";
. "$PSScriptRoot/../Software/Firefox/Install.ps1";
. "$PSScriptRoot/../Software/git/Manage.ps1";
. "$PSScriptRoot/../Software/LGHub/Manage.ps1";
. "$PSScriptRoot/../Software/ManiaPlanet/Manage.ps1";
. "$PSScriptRoot/../Software/osu!/Manage.ps1";
. "$PSScriptRoot/../Software/osu!lazer/Manage.ps1";
. "$PSScriptRoot/../Software/PuTTY/Manage.ps1";
. "$PSScriptRoot/../Software/RetroArch/Manage.ps1";
. "$PSScriptRoot/../Software/reWASD/Manage.ps1";
. "$PSScriptRoot/../Software/TrackMania Nations Forever/Manage.ps1";
. "$PSScriptRoot/../Software/TrackMania United Forever/Manage.ps1";
. "$PSScriptRoot/../Software/VisualStudio/Manage.ps1";

function Backup-GenericApps([Context] $context) {
    Backup-Git $context;
    Backup-PuTTY $context;
}

function Restore-GenericApps([Context] $context) {
    # Device specific
    if ((Get-Command Install-PersonalDrivers -ErrorAction SilentlyContinue)) {
        Write-Information "Driver installation function was found. Starting installation";
        Install-PersonalDrivers $context;
    }

    # Backed up applications
    Restore-Git $context;
    Restore-PuTTY $context;

    # Essentials
    choco install -y zoxide;
    winget install --accept-source-agreements --accept-package-agreements -e --id junegunn.fzf;
    . "$PSScriptRoot/../../Common/Config/zoxide/install.ps1";

    # Design
    choco install -y `
        nerd-fonts-CascadiaCode;

    # Browsing
    Install-Firefox $context;
    . "$PSScriptRoot/../Software/MSEdgeRedirect/Install.ps1";

    winget install --accept-source-agreements --accept-package-agreements -e --id Brave.Brave;
    winget install --accept-source-agreements --accept-package-agreements -e --id kamranahmedse.pennywise;

    $context.RemoveTaskbarItem("*Firefox*");
    $context.RemoveDesktopIcon("*Brave*");
    $context.RemoveTaskbarItem("*Brave*");
    $context.RemoveDesktopIcon("Pennywise*");

    choco install -y `
        7zip `
        chocolateygui `
        DefaultProgramsEditor `
        bitwarden `
        keepass `
        procexp `
        procmon `
        ;

    winget install --accept-source-agreements --accept-package-agreements -e --id KDE.KDEConnect;
    winget install --accept-source-agreements --accept-package-agreements -e --id SomePythonThings.WingetUIStore

    # Media
    choco install -y `
        k-litecodecpackmega `
        jellyfin-media-player `
        vlc `
        ;

    winget install --accept-source-agreements --accept-package-agreements -e --id Ytmdesktop.Ytmdesktop;
    $context.RemoveDesktopIcon("YouTube Music*");
    $context.RemoveDesktopIcon("VLC*");

    # Coding
    choco install -y --params "/NoDesktopIcon" vscode;
    choco install -y --params "/NoDesktopIcon /AssociateWithFiles" vscodium;
    # winget install --scope machine --accept-source-agreements --accept-package-agreements -e --id VSCodium.VSCodium.Insiders --override '/VerySilent /MergeTasks="!runCode,quicklaunchicon,addcontextmenufiles,addcontextmenufolders,associatewithfiles,addtopath"';

    refreshenv;
    . "$PSScriptRoot/../Config/vscode/Install.ps1";

    choco install -y `
        gh `
        github-desktop `
        ;

    $context.RemoveDesktopIcon("GitHub*");

    choco install -y `
        python `
        visualstudio2019-workload-vctools `
        ;

    . "$PSScriptRoot/../Software/NVS/Install.ps1";
    $context.RemoveDesktopIcon("*Microsoft Edge*");
}