@echo off
setlocal
cd /d "%~dp0"

call "%~dp0tools\resolve_h3_runtime.cmd"
if errorlevel 1 (pause & exit /b 1)
set "H3_ENGINE_PYTHON=%H3_RUNTIME_PYTHON%"

if not exist "studio\h3_studio.py" (
  echo [ERROR] H3 Studio not found: studio\h3_studio.py
  pause
  exit /b 1
)

echo Starting H3 Studio...
echo Browser: http://127.0.0.1:8191
echo Close this window or use the power button in the UI to stop.
echo.

"%H3_RUNTIME_PYTHON%" "studio\h3_studio.py" %*
set "H3_STUDIO_EXIT=%ERRORLEVEL%"

echo.
echo H3 Studio stopped.
pause
exit /b %H3_STUDIO_EXIT%
