@echo off
setlocal EnableExtensions
REM CCS PDF Editor — IT / incident investigation
REM Drag-drop a .ccspdf onto this bat, or:
REM   "Extract Project Audit.bat" "C:\path\file.ccspdf"
cd /d "%~dp0"
if "%~1"=="" (
  echo.
  echo  CCS PDF Editor — Extract Project Audit
  echo  --------------------------------------
  echo  Decodes CCS project state from catalog /CCSProject and/or legacy trailer.
  echo  Works on .ccspdf and Export PDF files that still embed project state.
  echo  Writes summary + CSV + JSON next to the file ^(folder *_extract^).
  echo.
  echo  Usage: drag a .ccspdf or .pdf onto this file, or:
  echo    "%~nx0" "path\to\file.ccspdf"
  echo.
  echo  NOTE: This is NOT password removal for final encrypted PDF exports.
  echo        Decode = gunzip + parse ^(catalog GZipHex or trailer^), not QPDF.
  echo.
  pause
  exit /b 1
)
powershell -NoProfile -ExecutionPolicy Bypass -File "%~dp0scripts\extract-ccspdf-audit.ps1" -Path "%~1" -FullSchema -ExtractPdf
set ERR=%ERRORLEVEL%
echo.
if %ERR% equ 2 (
  echo Integrity hash FAILED — content may be tampered. Artifacts were still written.
) else if %ERR% neq 0 (
  echo Extract failed with code %ERR%.
) else (
  echo Done. Open the *_extract folder next to the source file.
)
echo.
pause
exit /b %ERR%
