#!/usr/bin/env sh
set -eu
cd "$(dirname "$0")"

if [ ! -x ".venv/bin/python" ]; then
  echo "[1/3] Creating Python environment..."
  python3 -m venv .venv
fi

echo "[2/3] Installing requirements..."
.venv/bin/python -m pip install -r requirements.txt

echo "[3/3] Starting Arcopet Bot at http://127.0.0.1:1271"
if command -v xdg-open >/dev/null 2>&1; then
  (sleep 2; xdg-open "http://127.0.0.1:1271" >/dev/null 2>&1) &
fi
.venv/bin/python -m uvicorn main:app --host 127.0.0.1 --port 1271 --reload
