// Fallback distributor for the isolated watermark module. The normal Vite // build also emits this public entry; no host-application imports are bundled. import { readFile, writeFile } from 'node:fs/promises'; const parts = await Promise.all([ 'src/watermark/codec.js', 'src/watermark/v3.js', 'src/watermark/v31.js', 'src/watermark/short8.js', 'src/watermark/v6.js', 'src/watermark/identity.js', 'src/watermark/render.js', 'src/watermark/ForensicWatermark.jsx', 'src/watermark/resolve-token.js', 'src/watermark/index.jsx', ].map(path => readFile(path, 'utf8'))); function localize(s) { return s.replace(/^import[\s\S]*?from\s+["'][^"']+["'];\s*/gm, '') .replace(/^export\s+(?=(?:const|function|class)\b)/gm, '') .replace(/^export\s*\{[^\n]*\}\s*from\s*[\"'][^\"']+[\"'];?\s*/gm, ''); } const output = `"use client";\nimport React, { useCallback, useRef, useState, useEffect } from "react";\nimport { d as defineFeature } from "./chunks/_shared-DHh79jO9.js";\nimport { u as useKeycloakOptional } from "./chunks/_runtime-B6XIrDzf.js";\n` + parts.map((part, index) => { const source = localize(part); // The SDK keeps independent `parity` helpers in v3.js and v6.js. This // fallback concatenate-only distributor must disambiguate the v6-local // helper without changing the vendored SDK source or the encoded bits. return index === 4 ? source.replace(/\bparity\b/g, 'v6Parity') : source; }).join('\n') + '\nexport { Watermark, ForensicWatermark };\n'; await writeFile('dist/watermark.js', output);