@echo off
chcp 65001 >nul
cd /d "%~dp0"
title AI Maketing Facebook - Cai dat
echo ============================================
echo  AI Maketing Facebook — Cai dat Windows
echo ============================================
echo.
where python >nul 2>&1
if errorlevel 1 (
  echo [LOI] Chua co Python. Tai Python 3.12:
  echo   https://www.python.org/downloads/windows/
  echo   Tick "Add python.exe to PATH" khi cai.
  pause
  exit /b 1
)
python -c "import sys; print(sys.version)"
echo.
echo [1/3] Tao moi truong ao .venv ...
if not exist ".venv\Scripts\python.exe" (
  python -m venv .venv
)
call .venv\Scripts\activate.bat
python -m pip install -U pip wheel
echo.
echo [2/3] Cai thu vien (uu tien wheels offline)...
if exist "wheels\*.whl" (
  python -m pip install --no-index --find-links=wheels -r requirements.txt
  if errorlevel 1 python -m pip install -r requirements.txt
) else (
  python -m pip install -r requirements.txt
)
echo.
echo [3/3] Cai Chromium cho Playwright...
python -m playwright install chromium
echo.
echo ============================================
echo  XONG. Chay CHAY_APP.cmd de mo app.
echo  Dang nhap online: aurexislab.com/license-api
echo ============================================
pause
