. "$PSScriptRoot/../../lib/SoftwareManagement.ps1";
. "$PSScriptRoot/../../../lib/Software.ps1";
. "$PSScriptRoot/../../../lib/System.ps1";

Start-SoftwareInstaller @args `
    -UserConfigurator {
        Write-Information "Downgrading AutoHotkey…";
        $id = "AutoHotkey.AutoHotkey";
        $uninstall = { winget uninstall --accept-source-agreements -e --id "$id" };
        & $uninstall;
        Install-WingetPackage $id -ArgumentList "--version", "1.1.37.00";
        Install-ChocoPackage temurin11jre;

        Write-Host "Installing UniFi Controller…";
        Install-ChocoPackage ubiquiti-unifi-controller -ArgumentList "--ignore-dependencies";

        Write-Information "Upgrading AutoHotkey…";
        & $uninstall;
        Install-WingetPackage $id;
        Remove-DesktopIcon "UniFi*";
    };