@echo off
REM Goal Power Dialer — one-click updater
REM Downloads the latest extension zip from app.goalpowerdialer.com and
REM extracts it on top of this folder. Then click the Reload icon on the
REM extension card in chrome://extensions and you're current.

setlocal
set ZIP_URL=https://app.goalpowerdialer.com/static/extension.zip
set TMP_ZIP=%TEMP%\gpd-update.zip
set HERE=%~dp0
echo Downloading latest from %ZIP_URL% ...
powershell -Command "Invoke-WebRequest -UseBasicParsing -Uri '%ZIP_URL%' -OutFile '%TMP_ZIP%'" || goto :err
echo Extracting on top of %HERE% ...
powershell -Command "Expand-Archive -Force -Path '%TMP_ZIP%' -DestinationPath '%TEMP%\gpd-extract'" || goto :err
xcopy /E /Y /I "%TEMP%\gpd-extract\power-dialer\*" "%HERE%" >nul || goto :err
del "%TMP_ZIP%" >nul 2>&1
rmdir /S /Q "%TEMP%\gpd-extract" >nul 2>&1
echo.
echo ===========================================================
echo  Updated. Now open chrome://extensions and click the
echo  Reload icon on the Goal Power Dialer card.
echo  Then hard-refresh your Impact tab (Ctrl+Shift+R).
echo ===========================================================
echo.
pause
exit /b 0
:err
echo.
echo Update failed. Try downloading manually from:
echo   https://app.goalpowerdialer.com/static/extension.zip
echo.
pause
exit /b 1
