#!/usr/bin/env bash
set -euo pipefail
cd "$(dirname "$0")"

if ! command -v docker >/dev/null 2>&1; then
  echo "Docker not found."
  exit 1
fi

echo "Calculator: http://localhost:8888"
(
  sleep 2
  command -v xdg-open >/dev/null 2>&1 && xdg-open "http://localhost:8888" 2>/dev/null || true
  command -v open >/dev/null 2>&1 && open "http://localhost:8888" 2>/dev/null || true
) &

if docker compose version >/dev/null 2>&1; then
  exec docker compose up
fi
if command -v docker-compose >/dev/null 2>&1; then
  exec docker-compose up
fi

echo "Docker Compose not found."
exit 1
