param(
    [string] $Temp,
    [string] $Shared,
    [string] $Max2017Path,
    [string] $Max2018Path,
    [string] $Max2019Path,
    [string] $Max2020Path,
    [string] $Max2021Path,
    [switch] $User,
    [switch] $Quiet
)

$defaultTempValue = "%LOCALAPPDATA%\Temp\Simplygon"
$defaultSharedValue = "%USERPROFILE%\Documents\Simplygon\9"

function Set-EnvVar() {
    param(
        [Parameter(Mandatory=$true)]
        [string] $VariableName,
        [Parameter(Mandatory=$true)]
        [string] $VariableValue,
        [switch] $User,
        [switch] $Quiet
    )
    $environmentTarget = "[EnvironmentVariableTarget]::Machine"
    if ($User) {
        $environmentTarget = "[EnvironmentVariableTarget]::User"
    }
    $command = "[System.Environment]::SetEnvironmentVariable('$VariableName', '$VariableValue', $environmentTarget)"
    if (!$User -and !([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
        if ($Quiet) {
            "!! Error: failed to set machine-wide environment variable, user is not Administrator"
            ""
            exit -100
        }
        Start-Process powershell.exe "-Command `"$command`"" -Verb RunAs -Wait
    } else {
        Invoke-Expression $command
    }
    Set-Item -Path Env:$VariableName -Value $VariableValue
}

function Find-BlenderInstalls() {
    $sitePackages = @()

    try {
        (Get-Item HKLM:\Software\Microsoft\Windows\CurrentVersion\Installer\Folders).GetValueNames() | ForEach-Object {
            if ($_.EndsWith("site-packages\") -and $_.Contains("Blender")) {
                $sitePackages += $_
            }
        }
        $toRemove = @();
        $sitePackages | ForEach-Object {
            $_ -match ".*\\(\d)\.(\d+)\\.*" | Out-Null
            if ($Matches.Length -eq 0) {
                $toRemove += $_
            } else {
                $major = 0
                $minor = 0
                [int]::TryParse($Matches[1], [ref] $major) | Out-Null
                [int]::TryParse($Matches[2], [ref] $minor) | Out-Null
                if ($major -lt 2) {
                    $toRemove += $_
                } elseif ($major -gt 2) {
                    $toRemove += $_
                } else {
                    if ($minor -lt 80) {
                        $toRemove += $_
                    }
                }
            }
        }
        $toRemove | ForEach-Object {
            $sitePackages.Remove($_)
        }
    } catch {}

    $sitePackages
}

function InstallPythonModule() {
    param(
        [Parameter(Mandatory=$true)]
        [string] $LoaderSourceDirectory,
        [Parameter(Mandatory=$true)]
        [string] $SitePackagePath,
        [Parameter(Mandatory=$true)]
        [string] $DirectoryName,
        [switch] $Quiet
    )

    "   - $SitePackagePath"
    $loaderFileSource = "$LoaderSourceDirectory\simplygon_loader.py"
    if ($DirectoryName -eq "Python27" -or $DirectoryName -eq "Python36") {
        $loaderFileSource = "$LoaderSourceDirectory\simplygon_loader_no_type_hints.py"
    }
    $apiFileSources = (Get-ChildItem -Path "$pythonSourceDir" "Simplygon.py" -Recurse)
    $apiFileSources | ForEach-Object {
        $majorMinor = $_.Directory.Name.Substring(0, 10).Replace("-", "").Replace(".", "")
        $builtWithVS2015 = $_.Directory.Name.Contains("vs2015")
        if ($majorMinor -eq $DirectoryName -and ($majorMinor -eq "Python27" -or !$builtWithVS2015)) {
            mkdir "$SitePackagePath" -Force | Out-Null
            Copy-Item -Path "$loaderFileSource" -Destination "$SitePackagePath\simplygon_loader.py" -Force
            New-Item -Path "$SitePackagePath\__init__.py" -Force | Out-Null
            Copy-Item -Path $_.FullName -Destination "$SitePackagePath" -Force
            return
        } elseif ($majorMinor -eq "Python37" -and $builtWithVS2015 -eq $true -and $DirectoryName -eq "blender") {
            $commands = @(
                "mkdir '$SitePackagePath' -Force | Out-Null",
                "Copy-Item -Path '$loaderFileSource' -Destination '$SitePackagePath\simplygon_loader.py' -Force",
                "New-Item -Path '$SitePackagePath\__init__.py' -Force | Out-Null",
                "Copy-Item -Path '$($_.FullName)' -Destination '$SitePackagePath' -Force",
                "`$acl = Get-Acl '$SitePackagePath'",
                "`$ar = New-Object System.Security.AccessControl.FileSystemAccessRule('Users', 'Write', 'ContainerInherit,ObjectInherit', 'None', 'Allow')",
                "`$acl.SetAccessRule(`$ar)",
                "Set-Acl '$SitePackagePath' `$acl"
            )
            if (!([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
                if ($Quiet) {
                    "!! Error: failed to install Simplygon Python module to Blender, user is not Administrator"
                    ""
                    exit -200
                }
                Start-Process powershell.exe "-Command `"$($commands -join "`n")`"" -Verb RunAs -Wait
            } else {
                Invoke-Expression ($commands -join "`n")
            }
            return
        }
    }
}

function Install-MaxPlugin {
    param(
        [Parameter(Mandatory=$true)]
        [string] $Version,
        [Parameter(Mandatory=$true)]
        [string] $Path
    )
    "* Installing Autodesk 3ds Max $Version Simplygon plugin"
    if (!(Test-Path "$Path")) {
        "!! Error: Max$VersionPath could not be found"
        exit -300
    }
    if (!(Test-Path "$Path\bin\assemblies")) {
        "!! Error: No bin\assemblies path found under Max$VersionPath"
        exit -301
    }
    if (!(Test-Path "$Path\Plugins")) {
        "!! Error: No Plugins path found under Max$VersionPath"
        exit -302
    }
    $maxPluginSrc = "$PSScriptRoot\Max\SimplygonMax$Version\SimplygonMax$($Version).dlu"
    $maxPluginUISrc = "$PSScriptRoot\Max\SimplygonMax$Version\SimplygonMax$($Version)UI.dll"
    $pluginTargetPath = (Resolve-Path "$Path\Plugins").Path
    $pluginUITargetPath = (Resolve-Path "$Path\bin\assemblies").Path
    if (!$User -and !([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
        if ($Quiet) {
            "!! Error: failed to copy 3ds Max $Version plugin files, user is not Administrator"
            ""
            exit -303
        }
        Start-Process powershell.exe "-Command `"Copy-Item '$maxPluginSrc' '$pluginTargetPath' -Force; Copy-Item '$maxPluginUISrc' '$pluginUITargetPath' -Force`"" -Verb RunAs -Wait
    }
}

""
$extraLines = $false
if ([string]::IsNullOrEmpty($Temp)) {
    $Temp = $defaultTempValue
} else {
    "* Using SIMPLYGON_9_TEMP override value: $Temp"
    $extraLines = $true
}
if ([string]::IsNullOrEmpty($Shared)) {
    $Shared = $defaultSharedValue
} else {
    "* Using SIMPLYGON_9_SHARED override value: $Shared"
    $extraLines = $true
}
if ($extraLines) {
    ""
}

# Description text
if (-not $Quiet) {
    "This script sets up Simplygon on your computer by setting SIMPLYGON_9_PATH,"
    "SIMPLYGON_9_TEMP and SIMPLYGON_9_SHARED environment variables and copies the"
    "'simplygon' Python package to the site-packages folder of each supported"
    "Python version."
    ""
    "Script parameters:"
    "  -Shared       Set SIMPLYGON_9_SHARED path to given path."
    "                Defaults to %USERPROFILE%\Documents\Simplygon\9."
    "  -Temp         Set SIMPLYGON_9_TEMP path to given path."
    "                Defaults to %LOCALAPPDATA%\Temp\Simplygon."
    "  -Max2017Path  Path to Autodesk 3ds Max install dir. Specify this value"
    "                to install the 3ds Max Simplygon plugin (with UI)."
    "  -Max2018Path"
    "  -Max2019Path"
    "  -Max2020Path"
    "  -Max2021Path"
    "  -Max2022Path"
    "  -User         Installs the environment variables in user space rather"
    "                than machine-wide space."
    "  -Quiet        Run script without showing this help text and without user"
    "                interaction."
    ""
    "Press ENTER to continue or CTRL+C to abort the script."
    $dummy = Read-Host
}

# Install SIMPLYGON_9_PATH
"* Setting SIMPLYGON_9_PATH to $PSScriptRoot..."
Set-EnvVar -VariableName "SIMPLYGON_9_PATH" -VariableValue "$PSScriptRoot" -User:$User -Quiet:$Quiet

# Install SIMPLYGON_9_TEMP
if ([string]::IsNullOrEmpty($env:SIMPLYGON_9_TEMP)) {
    "* Setting SIMPLYGON_9_TEMP to $Temp..."
    Set-EnvVar -VariableName "SIMPLYGON_9_TEMP" -VariableValue "$Temp" -User:$User -Quiet:$Quiet
    $tempPathExpanded = [System.Environment]::ExpandEnvironmentVariables($Temp)
    if ($false -eq (Test-Path "$tempPathExpanded")) {
        New-Item -Path "$tempPathExpanded" -ItemType Directory -Force | Out-Null
    }
} else {
    "* SIMPLYGON_9_TEMP is previously set to $($env:SIMPLYGON_9_TEMP)"
}

# Install SIMPLYGON_9_SHARED
if ([string]::IsNullOrEmpty($env:SIMPLYGON_9_SHARED)) {
    "* Setting SIMPLYGON_9_SHARED to $Shared..."
    Set-EnvVar -VariableName "SIMPLYGON_9_SHARED" -VariableValue "$Shared" -User:$User -Quiet:$Quiet
    $sharedPathExpanded = [System.Environment]::ExpandEnvironmentVariables($Shared)
    if ($false -eq (Test-Path "$sharedPathExpanded")) {
        New-Item -Path "$sharedPathExpanded" -ItemType Directory -Force | Out-Null
    }
} else {
    "* SIMPLYGON_9_SHARED is previously set to $($env:SIMPLYGON_9_SHARED)"
}

# Install simplygon_loader modules
$pythonSourceDir = "$PSScriptRoot\Python"
if (Test-Path "$pythonSourceDir") {
    "* Installing simplygon_loader Python modules"
    $dirNames = @(
        "Python27",
        "Python36",
        "Python37",
        "Python38"
    )
    $loaderSourceDir = "$pythonSourceDir\simplygon_loader"
    $pythonModulesBaseDir = "$($env:APPDATA)\Python"
    $dirNames | ForEach-Object {
        $dirName = $_
        $targetDir = "$pythonModulesBaseDir\$dirName\site-packages\simplygon"
        InstallPythonModule -LoaderSourceDirectory "$loaderSourceDir" -SitePackagePath "$targetDir" -DirectoryName $dirName -Quiet:$Quiet
    }

    # Find and install the python module into any Blender installs
    $blenderSitePackages = Find-BlenderInstalls
    $blenderSitePackages | ForEach-Object {
        if ($_[-1] -eq "\") {
            $_ = $_.Substring(0, $_.Length - 1)
        }
        $targetDir = "$_\simplygon"
        InstallPythonModule -LoaderSourceDirectory "$loaderSourceDir" -SitePackagePath "$targetDir" -DirectoryName "blender" -Quiet:$Quiet
    }
}

# Max plugins
$maxSourceDir = "$PSScriptRoot\Max"
if (Test-Path "$maxSourceDir") {
    if (-not [string]::IsNullOrEmpty($Max2017Path)) {
        Install-MaxPlugin -Version 2017 -Path "$Max2017Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2018Path)) {
        Install-MaxPlugin -Version 2018 -Path "$Max2018Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2019Path)) {
        Install-MaxPlugin -Version 2019 -Path "$Max2019Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2020Path)) {
        Install-MaxPlugin -Version 2020 -Path "$Max2020Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2021Path)) {
        Install-MaxPlugin -Version 2021 -Path "$Max2021Path"
    }
    if (-not [string]::IsNullOrEmpty($Max2022Path)) {
        Install-MaxPlugin -Version 2022 -Path "$Max2022Path"
    }
} elseif ($Max2017Path -or $Max2018Path -or $Max2019Path -or $Max2020Path -or $Max2021Path -or $Max2022Path) {
    "[WARNING] Max plugin not bundled with this zip!"
}

""
"All done!"
""
"Please note that VC++ Redist (x64) is required to run Simplygon."
"Install the latest version from here:"
"https://aka.ms/vs/16/release/VC_redist.x64.exe"
""
# SIG # Begin signature block
# MIIntwYJKoZIhvcNAQcCoIInqDCCJ6QCAQExDzANBglghkgBZQMEAgEFADB5Bgor
# BgEEAYI3AgEEoGswaTA0BgorBgEEAYI3AgEeMCYCAwEAAAQQH8w7YFlLCE63JNLG
# KX7zUQIBAAIBAAIBAAIBAAIBADAxMA0GCWCGSAFlAwQCAQUABCCLLQWc08TY8B2e
# HM8jKUANoc8fMo1d/jAsEbtCVkmm5KCCDYEwggX/MIID56ADAgECAhMzAAACUosz
# qviV8znbAAAAAAJSMA0GCSqGSIb3DQEBCwUAMH4xCzAJBgNVBAYTAlVTMRMwEQYD
# VQQIEwpXYXNoaW5ndG9uMRAwDgYDVQQHEwdSZWRtb25kMR4wHAYDVQQKExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb24xKDAmBgNVBAMTH01pY3Jvc29mdCBDb2RlIFNpZ25p
# bmcgUENBIDIwMTEwHhcNMjEwOTAyMTgzMjU5WhcNMjIwOTAxMTgzMjU5WjB0MQsw
# CQYDVQQGEwJVUzETMBEGA1UECBMKV2FzaGluZ3RvbjEQMA4GA1UEBxMHUmVkbW9u
# ZDEeMBwGA1UEChMVTWljcm9zb2Z0IENvcnBvcmF0aW9uMR4wHAYDVQQDExVNaWNy
# b3NvZnQgQ29ycG9yYXRpb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