param(
    $Action,
    [hashtable] $Arguments
)

. "$PSScriptRoot/../../../Common/Scripts/BrowserAutomation.ps1";
. "$PSScriptRoot/../../../Common/Scripts/Software.ps1";
. "$PSScriptRoot/../../../Common/Scripts/System.ps1";

Start-SoftwareInstaller @PSBoundParameters `
    -Installer {
        Write-Host "Downloading reWASD…";
        $dir = New-TemporaryDirectory;
        $file = Start-BrowserDownload -URL "https://rewasd.com/" -ButtonSelector 'a.btn-default[href="#"]' -OutDir $dir -Timeout 1;

        Write-Host "Installing reWASD…";
        Start-Process -Wait -FilePath $($file.FullName) -ArgumentList "/S";
        Remove-Item -Recurse $dir;
        Remove-DesktopIcon "*reWASD*";
    };

# ToDo: Add restoration