# Receipt tool vendor files

All processing runs locally. These pinned dependencies are bundled from the versions in `package-lock.json`; there are no CDN requests.

- `pdf-lib.js`: pdf-lib, MIT. Bundled with esbuild from `pdf-lib/es/index.js`.
- `fflate.js`: fflate, MIT. Bundled with esbuild from `fflate/esm/browser.js`.
- `pdf.min.mjs`, `pdf.worker.min.mjs`: PDF.js, Apache-2.0. Copied from `pdfjs-dist/build/`.
- `heic2any.js`: locally named compatibility adapter built from `scripts/receipt-heic-adapter.mjs` and libheif-js's pure JavaScript implementation (LGPL-3.0 and included third-party licenses). It uses no WASM, runtime JavaScript compilation, or blob worker, so it works under this site's self-only CSP. The adapter decodes the first image and returns a canvas-encoded Blob. Sources: libheif-js 1.23.5 at https://github.com/catdad-experiments/libheif-js/tree/v1.23.5 and https://www.npmjs.com/package/libheif-js/v/1.23.5; libheif at https://github.com/strukturag/libheif. The upstream build instructions identify the included libheif revision. The adapter is distributed separately and can be rebuilt or relinked against a modified library using the command below.

Rebuild after `npm ci`:

```
npx esbuild node_modules/pdf-lib/es/index.js --bundle --format=esm --platform=browser --minify --outfile=dist/vendor/receipt/pdf-lib.js
npx esbuild node_modules/fflate/esm/browser.js --bundle --format=esm --platform=browser --minify --outfile=dist/vendor/receipt/fflate.js
npx esbuild scripts/receipt-heic-adapter.mjs --bundle --format=esm --platform=browser --external:fs --external:path --minify --outfile=dist/vendor/receipt/heic2any.js
cp node_modules/pdfjs-dist/build/pdf.min.mjs node_modules/pdfjs-dist/build/pdf.worker.min.mjs dist/vendor/receipt/
```
