@echo off
title MindShift CBT Therapy - Windows 11
color 0A
echo.
echo  ========================================
echo    MindShift CBT Therapy for Windows 11
echo  ========================================
echo.

REM Check if Node.js is installed
node --version >nul 2>&1
if %errorlevel% neq 0 (
    echo [ERROR] Node.js is not installed.
    echo.
    echo Please install Node.js from https://nodejs.org/ and try again.
    echo.
    pause
    exit /b 1
)

echo [SUCCESS] Node.js is installed
echo.

REM Check if dependencies are installed
if not exist "node_modules\electron" (
    echo [INFO] Installing dependencies for the first time...
    echo This may take a few minutes on first run...
    echo.
    call npm install
    if %errorlevel% neq 0 (
        echo.
        echo [ERROR] Failed to install dependencies.
        echo Please check your internet connection and try again.
        echo.
        pause
        exit /b 1
    )
    echo.
    echo [SUCCESS] Dependencies installed successfully!
    echo.
)

REM Start the app
echo [INFO] Launching MindShift CBT Therapy...
echo.
call npm start

if %errorlevel% neq 0 (
    echo.
    echo [ERROR] Failed to start the application.
    echo.
    pause
    exit /b 1
)

echo.
echo Thank you for using MindShift CBT Therapy!
echo.
pause