@echo off
title Spatial Separation Calculator - Trial Installer
color 0B

echo ========================================
echo   Spatial Separation Calculator
echo   Trial Installation
echo ========================================
echo.

REM Check for admin rights
net session >nul 2>&1
if %errorLevel% NEQ 0 (
    echo This installer needs administrator privileges.
    echo Please right-click this file and select "Run as Administrator"
    echo.
    pause
    exit /b 1
)

echo Installing certificate and application...
echo.

REM Get the directory where this batch file is located
set "SCRIPT_DIR=%~dp0"

REM Install certificate
echo [1/2] Installing security certificate...
certutil -addstore -f "TrustedPeople" "%SCRIPT_DIR%GerwulfCodeSigning.cer" >nul 2>&1
if %errorLevel% NEQ 0 (
    echo ERROR: Failed to install certificate
    echo Please contact support: info@gerwulf.co
    pause
    exit /b 1
)
echo Certificate installed successfully
echo.

REM Install MSIX
echo [2/2] Installing Spatial Separation Calculator...
powershell -Command "Add-AppxPackage -Path '%SCRIPT_DIR%GerwulfCalculator-v1.0.2.msix'"
if %errorLevel% NEQ 0 (
    echo ERROR: Failed to install application
    echo Please contact support: info@gerwulf.co
    pause
    exit /b 1
)

echo.
echo ========================================
echo   Installation Complete!
echo ========================================
echo.
echo Next steps:
echo 1. Find "Spatial Separation Calculator" in your Start Menu
echo 2. Enter your trial license key: TRIAL-PREVIEW-MAY2026
echo.
echo Visit https://gerwulf.co for support
echo.
pause
