@echo off
setlocal
cd /d "%~dp0"
set "BROWSERPILOT_INSTALL_URL=https://browserpilot.seedsource.dev/install"
if exist "bin\browserpilot-installer.exe" (
  "bin\browserpilot-installer.exe" --register-native-host --ensure-launcher --install-url "%BROWSERPILOT_INSTALL_URL%"
  exit /b %errorlevel%
)
if exist "bin\browserpilot-core.exe" (
  "bin\browserpilot-core.exe" install-native-host
  if errorlevel 1 exit /b %errorlevel%
  echo BrowserPilot native host registered through the compiled local core.
  echo Continue the signed install or update flow at %BROWSERPILOT_INSTALL_URL%
  exit /b 0
)
if not exist "bin\browserpilot-core.exe" (
  echo BrowserPilot installer scaffold requires a compiled local core binary at bin\browserpilot-core.exe.
  exit /b 1
)
