@echo off
title K8E Widget Installer
color 0A
cls
echo.
echo  ================================================
echo   K8E WIDGET  //  JUSTICE IS COMING
echo   www.k8e-ai.com
echo  ================================================
echo.

REM Check Python
python --version >nul 2>&1
if errorlevel 1 (
    echo  ERROR: Python is not installed!
    echo.
    echo  Please install Python first:
    echo  1. Go to https://python.org/downloads
    echo  2. Download and run the installer
    echo  3. IMPORTANT: Check the box that says
    echo     "Add Python to PATH"
    echo  4. Then run this installer again
    echo.
    pause
    exit /b 1
)
echo  [OK] Python found

REM Install Pillow silently
echo  [..] Installing image library...
pip install pillow --quiet --disable-pip-version-check
echo  [OK] Image library ready

REM Create install folder
set INSTALL_DIR=%USERPROFILE%\K8E_Widget
if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
echo  [OK] Install folder: %INSTALL_DIR%

REM Copy all files
copy /Y "k8e_widget.py" "%INSTALL_DIR%\k8e_widget.py" >nul
copy /Y "k8e_config.ini" "%INSTALL_DIR%\k8e_config.ini" >nul
copy /Y "k8e_logo.png" "%INSTALL_DIR%\k8e_logo.png" >nul
copy /Y "k8e_logo_transparent.png" "%INSTALL_DIR%\k8e_logo_transparent.png" >nul
copy /Y "katie1.jpg" "%INSTALL_DIR%\katie1.jpg" >nul
echo  [OK] Files copied

REM Process Katie faded background
echo  [..] Processing images...
python -c "from PIL import Image,ImageEnhance; img=Image.open(r'%INSTALL_DIR%\katie1.jpg').convert('RGBA').resize((276,175)); r,g,b,a=img.split(); a=ImageEnhance.Brightness(a).enhance(0.22); Image.merge('RGBA',(r,g,b,a)).save(r'%INSTALL_DIR%\katie_faded.png')" >nul 2>&1
echo  [OK] Images ready

REM Auto-start with Windows
set STARTUP=%APPDATA%\Microsoft\Windows\Start Menu\Programs\Startup\K8EWidget.bat
echo @echo off > "%STARTUP%"
echo start /min pythonw "%INSTALL_DIR%\k8e_widget.py" >> "%STARTUP%"
echo  [OK] Widget will auto-start with Windows

REM Desktop shortcut
set DESK=%USERPROFILE%\Desktop\K8E Widget.bat
echo @echo off > "%DESK%"
echo start /min pythonw "%INSTALL_DIR%\k8e_widget.py" >> "%DESK%"
echo  [OK] Desktop shortcut created

echo.
echo  ================================================
echo   Installation complete!
echo.
echo   FIRST LAUNCH: You will be asked for your city.
echo   Just type your city name - that is all!
echo   Example: London  or  Tokyo  or  Sydney
echo.
echo   The widget will auto-start every time
echo   Windows boots. You can move and resize it
echo   anywhere on your desktop.
echo.
echo   Visit k8e-ai.com for more info.
echo  ================================================
echo.

REM Delete old config so setup screen shows
if exist "%INSTALL_DIR%\k8e_config.ini" del "%INSTALL_DIR%\k8e_config.ini"

REM Launch widget now
start /min pythonw "%INSTALL_DIR%\k8e_widget.py"
echo  Widget launching... check your desktop!
echo.
pause
