@formancy/report-render-pdf 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/NOTICE +8 -0
- package/README.md +447 -14
- package/dist/bill-fonts-CFSgj0iW.mjs +18 -0
- package/dist/bill-fonts-CFSgj0iW.mjs.map +1 -0
- package/dist/browser.d.mts.map +1 -1
- package/dist/browser.mjs +54 -13
- package/dist/browser.mjs.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +30 -15
- package/dist/index.mjs.map +1 -1
- package/dist/render-DkPoADDg.mjs +3228 -0
- package/dist/render-DkPoADDg.mjs.map +1 -0
- package/fonts/AUTHORS-LiberationSans.txt +16 -0
- package/fonts/LICENSE-LiberationSans.txt +102 -0
- package/fonts/LiberationSans-Bold.ttf +0 -0
- package/fonts/LiberationSans-Regular.ttf +0 -0
- package/package.json +9 -7
- package/dist/render-Bs7DXIYJ.mjs +0 -1943
- package/dist/render-Bs7DXIYJ.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-DkPoADDg.mjs","names":["mm","pageOf","pageOf","line"],"sources":["../src/glyphs.ts","../src/engine.ts","../src/qr.ts","../src/bill.ts","../src/bytes.ts","../src/build.ts","../src/style.ts","../src/epc.ts","../src/svg-content.ts","../src/breaks.ts","../src/table-rules.ts","../src/widths.ts","../src/table.ts","../src/words.ts","../src/content.ts","../src/bound.ts","../src/assets.ts","../src/e-invoice.ts","../src/svg-pdfa.ts","../src/check.ts","../src/pdfa.ts","../src/slip.ts","../src/definition.ts","../src/measure.ts","../src/render.ts"],"sourcesContent":["/**\n * Which characters the renderer can draw: those the faces it embeds map to\n * a glyph, read from each face's own character map.\n *\n * pdfmake, through fontkit, draws a character its font has no glyph for as\n * glyph 0 -- an empty box, or nothing -- and writes U+0000 to the text\n * layer, so the text is lost on the page and in a search alike, and the\n * render still succeeds: 'Customer: 山田太郎 様' printed as 'Customer: '\n * and a run of empty boxes. So every character a document prints is held to\n * the face it prints in before anything is laid out, and one the face has\n * no glyph for is refused as `unsupported`, naming the block and the\n * character. Fallback fonts, which would draw it, are plan section 19's,\n * and not built.\n *\n * The maps are read from the very bytes pdfmake embeds -- the font files in\n * Node, the virtual files in a browser -- so they cannot drift from the\n * fonts. Roboto 3.014 maps the Basic Multilingual Plane only, in a format 4\n * subtable; a character past it, an emoji among them, has no glyph here.\n */\n\n/** pdfmake's names for a family's four faces. */\nexport type Face = 'normal' | 'bold' | 'italics' | 'bolditalics'\n\n/** The characters each face has a glyph for, by code point. */\nexport type Glyphs = Readonly<Record<Face, ReadonlySet<number>>>\n\n/** The two faces of Liberation Sans a QR-bill's slip prints in (`style.ts`): its values, and its titles and headings. */\nexport type BillFace = 'normal' | 'bold'\n\n/** The characters each of them has a glyph for. */\nexport type BillGlyphs = Readonly<Record<BillFace, ReadonlySet<number>>>\n\n/** The face text in this weight and slant prints in. */\nexport function faceOf(bold: boolean, italic: boolean): Face {\n return bold ? (italic ? 'bolditalics' : 'bold') : italic ? 'italics' : 'normal'\n}\n\n/** A line break: pdfmake breaks the line there and draws nothing for it. */\nconst LINE_BREAKS: ReadonlySet<number> = new Set([0x0a, 0x0d])\n\n/** The first character of `text` that `face` has no glyph for, as its code point; undefined when it has a glyph for every one. */\nexport function missingGlyph(text: string, face: ReadonlySet<number>): number | undefined {\n for (const character of text) {\n const point = character.codePointAt(0) as number\n if (!face.has(point) && !LINE_BREAKS.has(point)) return point\n }\n return undefined\n}\n\n/** A code point as Unicode writes it: U+5C71. */\nexport function codePoint(point: number): string {\n return `U+${point.toString(16).toUpperCase().padStart(4, '0')}`\n}\n\n/**\n * The code points a TrueType font maps to a glyph other than glyph 0, from\n * its Unicode BMP character map: the Windows (3, 1) or Unicode (0, 3)\n * subtable, in format 4. A font without one is not one this renderer\n * embeds, and is an error, not a document's refusal.\n */\nexport function characterMap(font: Uint8Array): ReadonlySet<number> {\n const view = new DataView(font.buffer, font.byteOffset, font.byteLength)\n const tables = view.getUint16(4)\n let cmap: number | undefined\n for (let index = 0; index < tables; index++) {\n const record = 12 + 16 * index\n if (String.fromCharCode(...font.subarray(record, record + 4)) === 'cmap') cmap = view.getUint32(record + 8)\n }\n if (cmap === undefined) throw new Error('the font has no character map')\n const encodings = view.getUint16(cmap + 2)\n for (let index = 0; index < encodings; index++) {\n const record = cmap + 4 + 8 * index\n const [platform, encoding] = [view.getUint16(record), view.getUint16(record + 2)]\n const subtable = cmap + view.getUint32(record + 4)\n const unicode = (platform === 3 && encoding === 1) || (platform === 0 && encoding === 3)\n if (unicode && view.getUint16(subtable) === 4) return format4(view, subtable)\n }\n throw new Error('the font has no Unicode character map in format 4')\n}\n\n/** A format 4 subtable's segments, each mapping a range of code points by a delta or through the glyph array; glyph 0 is no glyph. */\nfunction format4(view: DataView, table: number): ReadonlySet<number> {\n const segments = view.getUint16(table + 6) / 2\n const ends = table + 14\n const starts = ends + 2 * segments + 2\n const deltas = starts + 2 * segments\n const offsets = deltas + 2 * segments\n const mapped = new Set<number>()\n for (let segment = 0; segment < segments; segment++) {\n const end = view.getUint16(ends + 2 * segment)\n const start = view.getUint16(starts + 2 * segment)\n const delta = view.getUint16(deltas + 2 * segment)\n const offsetAt = offsets + 2 * segment\n const offset = view.getUint16(offsetAt)\n for (let point = start; point <= end; point++) {\n const indexed = offset === 0 ? point : view.getUint16(offsetAt + offset + 2 * (point - start))\n const glyph = offset !== 0 && indexed === 0 ? 0 : (indexed + delta) & 0xffff\n if (glyph !== 0) mapped.add(point)\n }\n }\n return mapped\n}\n","import type { TDocumentDefinitions } from 'pdfmake/interfaces.js'\nimport { characterMap, type BillFace, type BillGlyphs, type Face, type Glyphs } from './glyphs.js'\nimport type { Finish, PdfKitDocument } from './pdfa.js'\n\n/**\n * pdfmake with the renderer's fonts and access policies, as Node's entry\n * (`node.ts`) or the browser's (`browser.ts`) configures it: what runs a\n * definition and returns the PDF's bytes, and the characters the faces it\n * embeds have glyphs for. Everything else a render does is the same in both\n * (`render.ts`).\n */\nexport interface Engine {\n /**\n * The PDF of `definition`. `finish`, where given, acts on PDFKit's\n * document once pdfmake has laid it out and before it is ended, which is\n * where an e-invoice's file and XMP are added (`pdfa.ts`): only the final\n * pass gives one, since a measuring pass throws before its end.\n */\n readonly run: (definition: TDocumentDefinitions, finish?: Finish) => Promise<Uint8Array>\n /** Roboto's four faces, which a report's own text prints in. */\n readonly glyphs: () => Promise<Glyphs>\n /**\n * Liberation Sans's two faces, which a QR-bill's slip and an EPC QR\n * code's caption print in: read the first time a document has a payment\n * part or a captioned code, and in a browser loaded then, so that a host\n * that never prints either never loads them. Once they are read, `run`\n * has them for a document that prints them.\n */\n readonly billGlyphs: () => Promise<BillGlyphs>\n}\n\n/** Roboto's faces, as pdfmake names them. */\nexport const FACES: readonly Face[] = ['normal', 'bold', 'italics', 'bolditalics']\n\n/** Liberation Sans's, as pdfmake names them. */\nexport const BILL_FACES: readonly BillFace[] = ['normal', 'bold']\n\n/**\n * What `load` loads, loaded by the first call and kept for every call after\n * it: the fonts do not change while the process or the page runs. Calls made\n * while it loads share the one load. A load that fails is not kept: the\n * calls that shared it fail, and the next call loads again, so that a file\n * the process could not open just then, or a chunk the browser could not\n * fetch, fails the documents that asked for it and no document after.\n */\nexport function loadOnce<T>(load: () => Promise<T>): () => Promise<T> {\n let loading: Promise<T> | undefined\n return () =>\n (loading ??= load().catch((error: unknown) => {\n loading = undefined\n throw error\n }))\n}\n\n/** The glyphs of `faces`, from the bytes `read` reads for each. */\nexport async function glyphsOf<F extends string>(faces: readonly F[], read: (face: F) => Promise<Uint8Array>): Promise<Readonly<Record<F, ReadonlySet<number>>>> {\n const maps = await Promise.all(faces.map(async (face) => [face, characterMap(await read(face))] as const))\n return Object.fromEntries(maps) as Record<F, ReadonlySet<number>>\n}\n\n/** The glyphs of `faces`, read by `read` the first time they are asked for and kept once every face has been read (`loadOnce`). */\nexport function glyphsOnce<F extends string>(faces: readonly F[], read: (face: F) => Promise<Uint8Array>): () => Promise<Readonly<Record<F, ReadonlySet<number>>>> {\n return loadOnce(() => glyphsOf(faces, read))\n}\n\n/** PDFKit's document, as both of pdfmake's builds hand it out: a readable stream, ended to be written. */\nexport interface PdfStream {\n on(event: 'data', listener: (chunk: Uint8Array) => void): unknown\n on(event: 'end', listener: () => void): unknown\n on(event: 'error', listener: (error: unknown) => void): unknown\n end(): unknown\n}\n\n/**\n * The PDF of the document `getStream` hands over, `finish` acting on it\n * first: what each entry's `run` does once it has configured its pdfmake.\n */\nexport async function written(document: Promise<unknown>, finish: Finish | undefined): Promise<Uint8Array> {\n const pdf = (await document) as PdfStream & PdfKitDocument\n finish?.(pdf)\n return collect(pdf)\n}\n\n/**\n * The PDF's bytes, read from PDFKit's stream. pdfmake's own `getBuffer`\n * listens for the end of the stream and never for an error, so a stream that\n * fails leaves its promise pending forever; this one rejects.\n */\nexport function collect(stream: PdfStream): Promise<Uint8Array> {\n return new Promise((resolve, reject) => {\n const chunks: Uint8Array[] = []\n stream.on('data', (chunk) => chunks.push(chunk))\n stream.on('error', reject)\n stream.on('end', () => {\n const bytes = new Uint8Array(chunks.reduce((total, chunk) => total + chunk.length, 0))\n let offset = 0\n for (const chunk of chunks) {\n bytes.set(chunk, offset)\n offset += chunk.length\n }\n resolve(bytes)\n })\n stream.end()\n })\n}\n","import type { ContentSvg } from 'pdfmake/interfaces.js'\nimport { encode } from 'uqr'\nimport { RenderRefusal, type QrCode } from '@formancy/report-runtime'\nimport { codePoint } from './glyphs.js'\n\n/**\n * A QR code (ISO/IEC 18004), encoded by uqr and drawn as vectors.\n *\n * The text is encoded once, when the document is checked (`check.ts`), and\n * the symbol that check returns is the one every pass draws, so what is\n * refused and what is drawn are one decision. uqr encodes the text as UTF-8\n * in byte mode -- or as digits or upper-case alphanumerics, when that is\n * all it holds -- in the smallest version that holds it at the level\n * asked, and never raises the level to fill a version.\n *\n * The square is the code's `size`, its quiet zone inside it: four modules\n * on every side, white, the symbol between them, so a module is the size\n * over the symbol's modules and eight. The white is drawn whole under the\n * code, so it scans on a tinted section, and the dark modules over it are\n * one path, filled once (`qrContent`).\n */\n\n/** ISO/IEC 18004's quiet zone: four modules of white on every side of the symbol. */\nexport const QUIET_ZONE = 4\n\n/**\n * The smallest module drawn: 0.4 mm, 1.13 pt. ISO/IEC 18004 leaves the\n * module's size to the application; SIX's Swiss Implementation Guidelines\n * for the QR-bill, version 2.3, section 6.3, require at least 0.4 mm when\n * printing, and that is taken here as what a printer prints and a phone's\n * camera reads reliably. A square too small for its text at that module is\n * refused, naming the size it needs, never drawn finer. It is a borrowed\n * minimum: the same guidelines draw their largest code finer (0020).\n */\nexport const MIN_MODULE = (0.4 * 72) / 25.4\n\n/**\n * The most characters any QR code holds: 7089 digits, version 40 at level\n * L (ISO/IEC 18004, table 7). A character is a code point, as a reader\n * counts one: an emoji is one, though JavaScript holds it in two code\n * units. Longer text fits no version in any mode, and is refused before it\n * is encoded, which takes time and memory with the length of the text;\n * within it, the encoder decides by the bytes the text takes.\n */\nexport const MAX_CHARACTERS = 7089\n\nconst LEVELS: ReadonlySet<unknown> = new Set(['L', 'M', 'Q', 'H'])\n\n/** A code's symbol, without its quiet zone: rows of modules, `true` for dark, as many rows as modules in each. */\nexport interface QrSymbol {\n readonly modules: readonly (readonly boolean[])[]\n}\n\n/** How many code points `text` holds, counted without building them into an array. */\nfunction codePoints(text: string): number {\n let count = 0\n for (const _ of text) count++\n return count\n}\n\n/**\n * `code`'s symbol, or the refusal that says why it is not drawn: a level or\n * text no encoder can draw, as `unsupported`; text no version holds, or a\n * square too small for the version that holds it, as `content-too-large`.\n * Each names the code by its id. Its size is checked already.\n */\nexport function qrSymbol(code: QrCode): QrSymbol {\n const { id, text, size, errorCorrection } = code\n if (!LEVELS.has(errorCorrection)) throw new RenderRefusal('unsupported', `the QR code ${id} asks for the error correction level '${String(errorCorrection)}'; the levels are L, M, Q and H`, id)\n if (typeof text !== 'string') throw new RenderRefusal('unsupported', `the QR code ${id} encodes something that is not text`, id)\n // With the u flag, a surrogate pair is one character and only a lone half is a surrogate.\n const lone = /\\p{Cs}/u.exec(text)?.[0]\n if (lone !== undefined) throw new RenderRefusal('unsupported', `the QR code ${id} holds ${codePoint(lone.charCodeAt(0))}, half of a surrogate pair without the other, which has no UTF-8`, id)\n // No text has more code points than code units, so they are counted only past the cap.\n const characters = text.length > MAX_CHARACTERS ? codePoints(text) : text.length\n if (characters > MAX_CHARACTERS) throw new RenderRefusal('content-too-large', `the QR code ${id} holds ${characters} characters; no QR code holds more than ${MAX_CHARACTERS}`, id)\n const modules = encoded(text, errorCorrection, id)\n refuseFineModules({ modules }, size, `the QR code ${id}`, 'its text', id)\n return { modules }\n}\n\n/**\n * Refuses `symbol` drawn in a square of `size` with its quiet zone when its\n * modules would be finer than 0.4 mm, naming the square `holds` needs:\n * the floor every code drawn with a quiet zone is held to (0020).\n */\nexport function refuseFineModules(symbol: QrSymbol, size: number, what: string, holds: string, id: string): void {\n const count = symbol.modules.length + 2 * QUIET_ZONE\n const smallest = count * MIN_MODULE\n if (size < smallest) {\n throw new RenderRefusal(\n 'content-too-large',\n `${what} is ${size} pt a side, which makes the ${count} modules across its symbol and quiet zone ${(size / count).toFixed(2)} pt each; the smallest module is 0.4 mm (${MIN_MODULE.toFixed(2)} pt), so ${holds} needs a square of at least ${(Math.ceil(smallest * 100) / 100).toFixed(2)} pt`,\n id,\n )\n }\n}\n\n/** The symbol uqr encodes, without its quiet zone; refused when no version holds the text, which uqr 0.1.3 says with this error and no other. */\nfunction encoded(text: string, level: QrCode['errorCorrection'], id: string): boolean[][] {\n try {\n return encode(text, { ecc: level, border: 0, boostEcc: false }).data\n } catch (error) {\n if (!(error instanceof RangeError && error.message === 'Data too long')) throw error\n throw new RenderRefusal('content-too-large', `the QR code ${id} holds ${new TextEncoder().encode(text).length} bytes of text, more than a QR code at level ${level} holds`, id)\n }\n}\n\n/**\n * The code's square, exactly `size` points a side: white, and over it its\n * dark modules in black, one path filled once, each run of them in a row a\n * rectangle of it. Drawn in modules, the square's own units, and scaled to\n * `size`.\n *\n * Filled once, because a run filled on its own is blended into the page on\n * its own: where two rows meet inside a pixel, each covers part of it, and\n * a viewer draws a light line between them. The path is drawn as an SVG,\n * because pdfmake 0.3.11 cannot place one in a canvas: its `offsetVector`\n * (`helpers/tools.js`) moves a canvas's rectangles, lines and polylines to\n * where the canvas stands, never a `path`, which stays at the page's\n * corner; and a polyline's points, moved in place, are not put back when a\n * page break makes it lay the document out again. An SVG it places as it\n * places an image.\n */\nexport function qrContent(symbol: QrSymbol, size: number): ContentSvg {\n const across = symbol.modules.length + 2 * QUIET_ZONE\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${size}\" height=\"${size}\" viewBox=\"0 0 ${across} ${across}\"><rect width=\"${across}\" height=\"${across}\" fill=\"#ffffff\"/><path d=\"${darkRuns(symbol, QUIET_ZONE)}\" fill=\"#000000\"/></svg>`\n return { svg, width: size, height: size }\n}\n\n/** The symbol's dark modules as one path's subpaths, a rectangle for each run of them in a row, `offset` modules in from the square's corner. */\nexport function darkRuns(symbol: QrSymbol, offset: number): string {\n const runs: string[] = []\n symbol.modules.forEach((row, y) => {\n for (let x = 0; x < row.length; x++) {\n if (!row[x]) continue\n const start = x\n while (row[x + 1] === true) x++\n const length = x + 1 - start\n runs.push(`M${offset + start} ${offset + y}h${length}v1h-${length}z`)\n }\n })\n return runs.join('')\n}\n\n/** Millimetres in points. */\nconst mm = (value: number): number => (value * 72) / 25.4\n\n/**\n * The most characters a Swiss QR Code holds, its line feeds included: 997\n * (IG 6.2), which is what version 25 holds at level M in byte mode. A\n * payload of more is refused before it is encoded.\n */\nexport const SWISS_MAX_CHARACTERS = 997\n\n/** The largest version SIX allows (IG 6.2): 117 modules a side. */\nconst SWISS_MAX_VERSION = 25\n\n/** A Swiss QR Code's side, without a quiet zone, whatever its version (IG 6.4): its modules are this over theirs. */\nexport const SWISS_CODE_SIZE = mm(46)\n\n/**\n * A QR-bill's Swiss QR Code (IG 6), or the refusal that says why it is not\n * drawn: its payload as UTF-8 at level M (6.1), in the smallest version that\n * holds it (6.4), and never past version 25 (6.2). A payload of more than\n * 997 characters is refused unencoded; one whose UTF-8 is more than version\n * 25 holds, once the encoder finds none does. Every refusal names the\n * payment part, and none quotes the payload: it holds names and accounts.\n *\n * SIX prints the code at 46 mm whatever its version, so a module is 46 mm\n * over the symbol's modules, 0.393 mm at version 25: finer than the 0.4 mm\n * a `qrCode` is held to, which is SIX's own figure for print (6.3). SIX's\n * size is drawn, not the floor (0020's generic minimum does not apply).\n */\nexport function swissSymbol(payload: unknown): QrSymbol {\n const refuse = (code: 'unsupported' | 'content-too-large', what: string): RenderRefusal => new RenderRefusal(code, `the payment part's Swiss QR Code ${what}`, 'paymentPart')\n if (typeof payload !== 'string') throw refuse('unsupported', 'holds something that is not text')\n const lone = /\\p{Cs}/u.exec(payload)?.[0]\n if (lone !== undefined) throw refuse('unsupported', `holds ${codePoint(lone.charCodeAt(0))}, half of a surrogate pair without the other, which has no UTF-8`)\n const characters = payload.length > SWISS_MAX_CHARACTERS ? codePoints(payload) : payload.length\n if (characters > SWISS_MAX_CHARACTERS) throw refuse('content-too-large', `holds ${characters} characters; SIX allows ${SWISS_MAX_CHARACTERS}`)\n try {\n return { modules: encode(payload, { ecc: 'M', border: 0, boostEcc: false, maxVersion: SWISS_MAX_VERSION }).data }\n } catch (error) {\n if (!(error instanceof RangeError && error.message === 'Data too long')) throw error\n throw refuse('content-too-large', `holds ${new TextEncoder().encode(payload).length} bytes, more than version ${SWISS_MAX_VERSION} holds at level M, the largest code SIX allows`)\n }\n}\n\n/**\n * The Swiss cross over the code's centre (IG 6.4.2), in millimetres: SIX's\n * logo, as schoero's generator draws it, is a white square of 7 mm, a black\n * square of 6 mm on it, and a white cross on that, its arms 7/6 mm wide and\n * 35/9 mm from end to end. manuelbl's draws the same black square and cross\n * on modules it clears, rather than on a white square.\n */\nconst CROSS = { white: 7, black: 6, arm: 7 / 6, span: 35 / 9 } as const\n\n/**\n * The Swiss QR Code's square, 46 mm a side, without a quiet zone of its own:\n * the slip leaves 5 mm unprinted around it (IG 3.5.2, 6.4.1). White, its\n * dark modules in black as one path filled once, as a `qrCode`'s are, and\n * over them the Swiss cross: its white square, its black square, and its\n * white cross, one path. Drawn in modules and scaled to the side.\n */\nexport function swissCodeContent(symbol: QrSymbol): ContentSvg {\n const across = symbol.modules.length\n const unit = across / 46\n const centre = across / 2\n const square = (side: number, fill: string): string => `<rect x=\"${centre - (side * unit) / 2}\" y=\"${centre - (side * unit) / 2}\" width=\"${side * unit}\" height=\"${side * unit}\" fill=\"${fill}\"/>`\n const [arm, span] = [(CROSS.arm * unit) / 2, (CROSS.span * unit) / 2]\n const corners: readonly (readonly [number, number])[] = [\n [-arm, -span],\n [arm, -span],\n [arm, -arm],\n [span, -arm],\n [span, arm],\n [arm, arm],\n [arm, span],\n [-arm, span],\n [-arm, arm],\n [-span, arm],\n [-span, -arm],\n [-arm, -arm],\n ]\n const cross = `M${corners.map(([x, y]) => `${centre + x} ${centre + y}`).join('L')}z`\n const size = SWISS_CODE_SIZE\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${size}\" height=\"${size}\" viewBox=\"0 0 ${across} ${across}\"><rect width=\"${across}\" height=\"${across}\" fill=\"#ffffff\"/><path d=\"${darkRuns(symbol, 0)}\" fill=\"#000000\"/>${square(CROSS.white, '#ffffff')}${square(CROSS.black, '#000000')}<path d=\"${cross}\" fill=\"#ffffff\"/></svg>`\n return { svg, width: size, height: size }\n}\n","import {\n checkQrBillAmount,\n MAX_QR_BILL_ADDITIONAL_INFORMATION,\n QR_BILL_CURRENCIES,\n qrBillPageBreak,\n RenderRefusal,\n type PageSetup,\n type QrBill,\n type QrBillHeadings,\n} from '@formancy/report-runtime'\nimport { codePoint, missingGlyph, type BillFace, type BillGlyphs } from './glyphs.js'\nimport { swissSymbol, type QrSymbol } from './qr.js'\n\n/**\n * What the renderer refuses about a QR-bill's payment part before anything\n * is laid out, and its Swiss QR Code, encoded once.\n *\n * The runtime hands the renderer a bill SIX's rules have accepted, every\n * text as the slip prints it (report-runtime's `QrBill`); the renderer\n * formats nothing, and decides none of SIX's rules again. What it refuses\n * is what it cannot draw whole, or would draw as some other slip: a kind of\n * payment part it does not know, a page the slip has no room on, text that\n * is not text or that its font has no glyph for, an amount or currency SIX\n * does not print, more lines than a slip prints, a value longer than any\n * SIX allows, and a code larger than SIX allows (`qr.ts`). Where one of\n * those is SIX's rule -- the page, the currencies, the amounts, the longest\n * value -- it is report-spec's, which the runtime hands on, so that what\n * the editor accepts and what the renderer draws cannot part. Every\n * refusal names the payment part and the field, and none quotes a value: a\n * bill holds names, addresses and accounts.\n */\n\n/** A bill the renderer draws, and its code's symbol. */\nexport interface CheckedBill {\n readonly bill: QrBill\n readonly symbol: QrSymbol\n}\n\n/** The longest value a slip prints: a line of the additional information, which the message and the billing information share (IG Table 8). An address line is shorter. */\nconst MAX_VALUE = MAX_QR_BILL_ADDITIONAL_INFORMATION\n\n/** An amount as the slip prints it: a space between thousands, a point and two decimals (IG 3.5.3). Which amounts a bill pays is report-spec's `checkQrBillAmount`. */\nconst AMOUNT = /^\\d{1,3}(?: \\d{3})*\\.\\d{2}$/\n\n/** The lines an address prints: its name, its street and building number, its postal code and town (IG 3.5.4). */\nconst ADDRESS_LINES = 3\n\n/** The message and the billing information, each on its line. */\nconst ADDITIONAL_LINES = 2\n\nfunction refuse(what: string): RenderRefusal {\n return new RenderRefusal('unsupported', `the payment part's ${what}`, 'paymentPart')\n}\n\n/**\n * Refuses `page` for a slip by report-spec's rule, the one the editor\n * refuses it by (`qrBillPageBreak`): a page that is not A4 in portrait,\n * which has no foot the slip spans, and one whose top margin, with `above`\n * printed under it, reaches into the slip, which no layout can undo.\n */\nexport function refusePage(page: PageSetup, above = 0): void {\n const broken = qrBillPageBreak(page, above)\n if (broken !== undefined) throw new RenderRefusal(broken.field === 'page' ? 'unsupported' : 'content-too-large', broken.rule, 'paymentPart')\n}\n\n/** Refuses what the renderer cannot draw of `bill` on `page`, the top margin alone before the header is measured, and encodes its code. */\nexport function checkBill(bill: QrBill, page: PageSetup, glyphs: BillGlyphs): CheckedBill {\n const { kind } = bill as { readonly kind?: unknown }\n if (kind !== 'swissQrBill') throw new RenderRefusal('unsupported', `the payment part is a '${String(kind)}', which the renderer does not know`, 'paymentPart')\n refusePage(page)\n const text = (value: unknown, what: string, face: BillFace): void => {\n if (typeof value !== 'string') throw refuse(`${what} holds something that is not text`)\n if (value.length > MAX_VALUE) throw refuse(`${what} holds a value longer than any SIX allows, ${MAX_VALUE} characters`)\n const missing = missingGlyph(value, glyphs[face])\n if (missing !== undefined) throw refuse(`${what} prints ${codePoint(missing)}, which Liberation Sans has no glyph for: it would print as an empty box`)\n }\n const lines = (value: unknown, what: string, most: number, least: number): void => {\n if (!Array.isArray(value)) throw refuse(`${what} is not lines of text`)\n if (value.length > most || value.length < least) throw refuse(`${what} has the wrong number of lines: a slip prints ${least} to ${most}`)\n for (const line of value) text(line, what, 'normal')\n }\n const headings = (bill.headings ?? {}) as Partial<Record<keyof QrBillHeadings, unknown>>\n for (const [key, face] of Object.entries(HEADING_FACES) as [keyof QrBillHeadings, BillFace][]) text(headings[key], `heading '${key}'`, face)\n text(bill.account, 'account', 'normal')\n lines(bill.creditor, \"creditor's address\", ADDRESS_LINES, 2)\n if (bill.reference !== null) text(bill.reference, 'reference', 'normal')\n lines(bill.additionalInformation, 'additional information', ADDITIONAL_LINES, 0)\n if (bill.debtor !== null) lines(bill.debtor, \"debtor's address\", ADDRESS_LINES, 2)\n if (!(QR_BILL_CURRENCIES as readonly unknown[]).includes(bill.currency)) throw refuse(`currency is not one SIX allows: ${QR_BILL_CURRENCIES.join(' or ')}`)\n text(bill.currency, 'currency', 'normal')\n if (bill.amount !== null) {\n if (typeof bill.amount !== 'string' || !AMOUNT.test(bill.amount)) throw refuse('amount is not written as the slip prints one: its thousands apart and two decimals')\n const paid = checkQrBillAmount(bill.amount.replaceAll(' ', ''))\n if (!paid.ok) throw refuse(`amount ${paid.rule}`)\n text(bill.amount, 'amount', 'normal')\n }\n return { bill, symbol: swissSymbol(bill.payload) }\n}\n\n/**\n * The face each heading a slip prints in, which its glyphs are held to:\n * `separate` regular, the rest bold (`slip.ts`). A table over every\n * heading, so that one added to the document's `QrBillHeadings` without\n * its face does not compile, rather than going unchecked.\n */\nconst HEADING_FACES: { readonly [K in keyof QrBillHeadings]-?: BillFace } = {\n paymentPart: 'bold',\n receipt: 'bold',\n account: 'bold',\n reference: 'bold',\n additionalInformation: 'bold',\n payableBy: 'bold',\n currency: 'bold',\n amount: 'bold',\n acceptancePoint: 'bold',\n separate: 'normal',\n}\n","/**\n * Byte arithmetic the renderer needs in Node and in a browser alike, written\n * on the standard library alone: neither `Buffer` nor `node:zlib` exists in a\n * browser, and the browser entry shares every line of this package but its\n * font loading (`browser.ts`).\n */\n\nconst BASE64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'\n\n/** Standard base64 with padding, as a `data:` URL carries bytes. */\nexport function base64(bytes: Uint8Array): string {\n const parts: string[] = []\n for (let offset = 0; offset < bytes.length; offset += 3) {\n const [a = 0, b = 0, c = 0] = [bytes[offset], bytes[offset + 1], bytes[offset + 2]]\n const left = bytes.length - offset\n parts.push(\n BASE64[a >> 2]! +\n BASE64[((a & 3) << 4) | (b >> 4)]! +\n (left > 1 ? BASE64[((b & 15) << 2) | (c >> 6)]! : '=') +\n (left > 2 ? BASE64[c & 63]! : '='),\n )\n }\n return parts.join('')\n}\n\n/** The bytes standard base64 with padding spells, as pdfmake's virtual files hold fonts; whitespace ignored, anything else not base64 refused. */\nexport function fromBase64(text: string): Uint8Array {\n const digits = text.replace(/\\s+/g, '').replace(/=+$/, '')\n const bytes = new Uint8Array(Math.floor((digits.length * 3) / 4))\n let bits = 0\n let held = 0\n let at = 0\n for (const digit of digits) {\n const value = BASE64.indexOf(digit)\n if (value === -1) throw new Error('not base64')\n bits = (bits << 6) | value\n held += 6\n if (held >= 8) {\n held -= 8\n bytes[at++] = (bits >> held) & 0xff\n }\n }\n return bytes\n}\n\n/** What inflating gave: every chunk in order, or why it stopped. */\nexport type Inflated = { readonly kind: 'done'; readonly length: number } | { readonly kind: 'too-long' } | { readonly kind: 'invalid' }\n\n/**\n * Inflates zlib-wrapped `data` -- a PNG's image data -- with the platform's\n * own `DecompressionStream`, handing each chunk to `each` as it arrives and\n * stopping, without reading further, once more than `limit` bytes have come\n * out: the limit is what the image's header promises, so a PNG whose data\n * inflates to gigabytes costs no more than one that keeps its promise.\n *\n * Data that is not a whole zlib stream is `invalid`, and so is data with\n * bytes after the stream's end, which Node's `inflateSync` would ignore and\n * the Compression Streams standard refuses: refusing them costs a PNG some\n * decoder would have drawn, and keeps Node and a browser in agreement.\n */\nexport async function inflate(data: Uint8Array<ArrayBuffer>, limit: number, each: (chunk: Uint8Array, offset: number) => void): Promise<Inflated> {\n const reader = new Blob([data]).stream().pipeThrough(new DecompressionStream('deflate')).getReader()\n let length = 0\n try {\n for (;;) {\n const { done, value } = await reader.read()\n if (done) return { kind: 'done', length }\n if (length + value.length > limit) {\n await reader.cancel()\n return { kind: 'too-long' }\n }\n each(value, length)\n length += value.length\n }\n } catch {\n return { kind: 'invalid' }\n }\n}\n","import type { Node, NodeQueries } from 'pdfmake/interfaces.js'\nimport type { Block, EpcQrCode, ImageAsset, QrCode, Table, TableRow } from '@formancy/report-runtime'\nimport type { CheckedImage } from './assets.js'\nimport type { KeepBlock } from './breaks.js'\nimport type { QrSymbol } from './qr.js'\nimport type { WordRoom } from './words.js'\n\n/**\n * What building one pdfmake document from a resolved one accumulates, in one\n * of two modes. `render` is what the PDF is made of. `measure` is the same\n * content made fully breakable, with a mark on each table row, for the passes\n * that measure heights before the PDF is laid out (`measure.ts`).\n *\n * pdfmake knows nothing of keep-with-next or group headers. Both are rules\n * run by its `pageBreakBefore` hook, which it calls for each node once it\n * has laid the document out, and lays it out again whenever a rule asks for\n * a break. The node a rule runs for is found by its `headlineLevel`, which\n * pdfmake passes to the hook and otherwise ignores: here it is not a level\n * but a number that names the node.\n *\n * The node a rule looks for -- the row a group header heads, the block a\n * heading is kept with -- carries an `id` as well, and the rule reads the\n * page it starts on. pdfmake records the position of a node inside an\n * unbreakable block (a row it keeps whole, a keep-together block) before it\n * moves the block to the next page, and corrects the page afterwards only\n * for a node with an id; without one, a row moved to the next page still\n * says it is on the last. The cost: every id is also a named destination in\n * the PDF.\n */\n\n/** A rule run when pdfmake asks whether to break before a marked node: true to break. */\nexport type BreakRule = (node: Node, queries: NodeQueries) => boolean\n\n/** How a table in the body is broken across pages, decided from its measured rows (`tablePlan`). */\nexport interface TablePlan {\n /** Every row fits on a page under what repeats or moves with it, so none is split. */\n readonly dontBreakRows: boolean\n /** Rows after the header that move to the next page with it, so the header never ends a page. */\n readonly keepWithHeaderRows: number\n /** Each row's height and the rule under it, as measured, the header first. */\n readonly pitches: readonly number[]\n /** The rows the table's rules keep on one page (`breaks.ts`). */\n readonly blocks: readonly KeepBlock[]\n}\n\n/** The plan of a table nothing measured: a table in a keep-together block or a page region, which no rule breaks. */\nexport const UNPLANNED: TablePlan = { dontBreakRows: false, keepWithHeaderRows: 0, pitches: [], blocks: [] }\n\n/** What a row of a table is, as pdfmake lays it out: the column header, the empty text, or one of the document's rows. */\nexport type RowKind = TableRow['kind'] | 'header' | 'empty'\n\n/** The values of the page fields, known only in a page region and only to pdfmake's header and footer functions. */\nexport interface Fields {\n readonly pageNumber: number\n readonly pageCount: number\n}\n\nexport interface Build {\n readonly mode: 'measure' | 'render'\n /** Where the body starts on every page, from the top of the paper. */\n readonly bodyTop: number\n /** Where it ends. */\n readonly bodyBottom: number\n readonly plans: ReadonlyMap<Table, TablePlan>\n /** Each image asset as the asset checks read it. */\n readonly assets: ReadonlyMap<ImageAsset, CheckedImage>\n /** Each QR code's and EPC QR code's symbol, as the checks encoded it. */\n readonly codes: ReadonlyMap<QrCode | EpcQrCode, QrSymbol>\n /** Filled in: each asset's key in pdfmake's image dictionary, and the dictionary. */\n readonly imageKeys: Map<ImageAsset, string>\n readonly images: Record<string, string>\n /** Filled in: the rules for marked nodes, by mark. */\n readonly rules: Map<number, BreakRule>\n /** Filled in, in measure mode: each table's rows as pdfmake lays them out, with the mark on each one's first cell. */\n readonly measuredRows: Map<Table, readonly { readonly kind: RowKind; readonly mark: number }[]>\n /** Where each paragraph stands in the document, `body[2]`, for a refusal to name. */\n readonly paths: ReadonlyMap<Block, string>\n /** Filled in: every text node whose widest word is held to its room once pdfmake has measured it (`words.ts`). */\n readonly words: WordRoom[]\n /** The next unused mark. */\n next: number\n}\n\nexport function newBuild(\n mode: Build['mode'],\n checked: { readonly assets: ReadonlyMap<ImageAsset, CheckedImage>; readonly codes: ReadonlyMap<QrCode | EpcQrCode, QrSymbol>; readonly paths: ReadonlyMap<Block, string> },\n body: { readonly top: number; readonly bottom: number } = { top: 0, bottom: 0 },\n plans: ReadonlyMap<Table, TablePlan> = new Map(),\n): Build {\n const { assets, codes, paths } = checked\n return { mode, bodyTop: body.top, bodyBottom: body.bottom, plans, assets, codes, paths, imageKeys: new Map(), images: {}, rules: new Map(), measuredRows: new Map(), words: [], next: 1 }\n}\n\n/** Marks `node`, keeping a mark it already has, and returns the mark. */\nexport function mark(node: { headlineLevel?: number }, build: Build): number {\n return (node.headlineLevel ??= build.next++)\n}\n\n/** Whether a node with one of `ids`, among those pdfmake has on this page and the next, starts on `page`. */\nexport function startsOnPage(queries: NodeQueries, ids: ReadonlySet<string>, page: number): boolean {\n return [...queries.getFollowingNodesOnPage(), ...queries.getNodesOnNextPage()].some((other) => other.id !== undefined && ids.has(other.id) && other.startPosition.pageNumber === page)\n}\n\n/**\n * The page a node handed to pdfmake starts on in its last layout, read from\n * the node itself: pdfmake records each node's positions on it, and reports\n * the first as the node's `startPosition`. `startsOnPage` asks pdfmake's\n * queries, each of which walks every node to the end of the document, so a\n * rule per row of a long table made the rules' work grow with the square of\n * the table; this is one read. Undefined for a node pdfmake laid out\n * nowhere. `pdfmake.test.ts` holds that 0.3.11 still records positions here.\n */\nexport function pageOf(node: object): number | undefined {\n return (node as { readonly positions?: readonly { readonly pageNumber: number }[] }).positions?.[0]?.pageNumber\n}\n","import type { TextStyle } from '@formancy/report-runtime'\n\n/**\n * A document's text styles as pdfmake's: the one place a font token becomes\n * a font, and a style becomes pdfmake's properties.\n *\n * **Fonts.** pdfmake ships one family, Roboto 3.014, under the SIL Open Font\n * License 1.1, which allows embedding in documents\n * ([0006](../../../docs/decisions/0006-dependencies-and-fonts-allow-public-source-and-licensed-production.md)).\n * `sans` is Roboto. `serif` and `mono` have no font here, and a report that\n * asks for one is refused as `unsupported` before anything is laid out\n * (`check.ts`): printing it in Roboto would be a substitution nobody sees\n * until the PDF is read, which plan section 20 rules out. Bold is Roboto\n * Medium, the heaviest face pdfmake ships, and italic its italic.\n */\n\n/** pdfmake's name for the family a report's own text prints in. */\nexport const ROBOTO = 'Roboto'\n\n/**\n * pdfmake's name for Liberation Sans 2.1.5, under the SIL Open Font License\n * 1.1, which the package ships in its `fonts` directory: the family a\n * QR-bill's slip prints in, and nothing else. SIX allows Arial, Frutiger,\n * Helvetica and Liberation Sans on a slip (IG 3.4), and Roboto is none of\n * them. Regular and bold; SIX allows no italics.\n */\nexport const LIBERATION_SANS = 'LiberationSans'\n\n/**\n * Liberation Sans's ascender and its line, ascender less descender, as\n * multiples of the font size: 1854 and 2288 of its 2048 units per em, from\n * its `hhea` table, Arial's metrics. pdfmake sets a line's baseline its\n * ascender below the line's top, and lays the line out its line tall times\n * the node's `lineHeight`.\n */\nexport const LIBERATION_ASCENDER = 1854 / 2048\nexport const LIBERATION_LINE = 2288 / 2048\n\n/** The font each token prints in; a token without one is refused. */\nexport const FONTS: Readonly<Partial<Record<NonNullable<TextStyle['font']>, string>>> = { sans: ROBOTO }\n\n/**\n * Roboto's line, as a multiple of the font size: its ascender less its\n * descender, 2400 of its 2048 units per em. pdfmake lays out a line exactly\n * this tall.\n */\nexport const LINE_FACTOR = 2400 / 2048\n\n/** Text when a paragraph names no size. */\nexport const DEFAULT_SIZE = 10\n\n/** A colour as the document writes one, and as pdfmake reads one: `#` and six lower-case hex digits. */\nexport const COLOR = /^#[0-9a-f]{6}$/\n\n/** pdfmake's text properties for a style, the renderer's own defaults under it. Only what is set is written. */\nexport function textProperties(style: TextStyle, defaults: { readonly size: number; readonly bold?: boolean; readonly italic?: boolean }): Record<string, unknown> {\n const bold = style.bold ?? defaults.bold\n const italic = style.italic ?? defaults.italic\n return {\n fontSize: style.size ?? defaults.size,\n ...(style.font === undefined ? {} : { font: FONTS[style.font] }),\n ...(bold === undefined ? {} : { bold }),\n ...(italic === undefined ? {} : { italics: italic }),\n ...(style.color === undefined ? {} : { color: style.color }),\n }\n}\n","import type { ContentSvg } from 'pdfmake/interfaces.js'\nimport { encode } from 'uqr'\nimport { EPC_CAPTION, EPC_FRAME, EPC_MAX_BYTES, EPC_MAX_VERSION, epcCaptionBreak, epcLeastVersion, epcModule, RenderRefusal, type EpcQrCode } from '@formancy/report-runtime'\nimport { codePoint } from './glyphs.js'\nimport { darkRuns, qrContent, refuseFineModules, type QrSymbol } from './qr.js'\nimport { LIBERATION_SANS } from './style.js'\nimport type { ConvertedSvg } from './svg-content.js'\n\n/**\n * An EPC QR code (EPC069-12 v3.1), encoded by uqr and drawn as a QR code\n * is (0020): its payload as UTF-8 at level M, in a symbol of version 13 at\n * most, encoded once when the document is checked, its dark modules one\n * path filled once over a white square exactly its size.\n *\n * Without a caption it is a QR code's square, its quiet zone of four\n * modules inside it, held to the 0.4 mm floor. With Austria's caption it\n * is the PSA's (PSA v3.0 5), laid out by report-spec's `epc-print.ts`, the\n * one place its rules are decided: modules of 15 to 20 mil, a frame of\n * half a module with corners of two, four modules from the symbol, and\n * \"Zahlen mit Code\" at 7 pt in Liberation Sans, reading from bottom to top\n * on the right. In a square the author sized, the version that just holds\n * a payload may have modules over 20 mil: the code is drawn at the least\n * version that prints (`epcLeastVersion`), a larger symbol of the same\n * payload at the same level.\n *\n * Every refusal names the code by its id, and none quotes the payload: it\n * holds a name and an account.\n */\n\n/** The version `symbol` is, from its modules a side (ISO/IEC 18004: 4 a version and 17). */\nconst versionOf = (symbol: QrSymbol): number => (symbol.modules.length - 17) / 4\n\n/**\n * `code`'s symbol, or the refusal that says why it is not drawn: a caption\n * the renderer does not know, or a payload that is not text, as\n * `unsupported`; a payload past 331 bytes, refused unencoded when it is\n * longer than that in characters, or modules the square cannot print, as\n * `content-too-large`. Its size is checked already.\n */\nexport function epcSymbol(code: EpcQrCode): QrSymbol {\n const { id, payload, size, caption } = code\n const what = `the EPC QR code ${id}`\n if (caption !== undefined && caption !== 'zahlenMitCode') throw new RenderRefusal('unsupported', `${what} asks for the caption '${String(caption)}', which the renderer does not know`, id)\n if (typeof payload !== 'string') throw new RenderRefusal('unsupported', `${what} holds something that is not text`, id)\n const lone = /\\p{Cs}/u.exec(payload)?.[0]\n if (lone !== undefined) throw new RenderRefusal('unsupported', `${what} holds ${codePoint(lone.charCodeAt(0))}, half of a surrogate pair without the other, which has no UTF-8`, id)\n // No character is fewer bytes than code units, so a payload longer than the limit in code units is longer in bytes, and is refused without being encoded.\n if (payload.length > EPC_MAX_BYTES) throw new RenderRefusal('content-too-large', `${what} holds more than the ${EPC_MAX_BYTES} bytes the EPC allows`, id)\n const square = caption === undefined ? undefined : epcCaptionBreak(size)\n if (square !== undefined) throw new RenderRefusal('content-too-large', `${what} cannot be printed as the PSA prints it: ${square}`, id)\n // A size the caption's rules take has a least version (report-spec's epc-print.test.ts holds every one).\n const least = epcLeastVersion(size, caption) as number\n let symbol: QrSymbol\n try {\n symbol = { modules: encode(payload, { ecc: 'M', border: 0, boostEcc: false, minVersion: least, maxVersion: EPC_MAX_VERSION }).data }\n } catch (error) {\n if (!(error instanceof RangeError && error.message === 'Data too long')) throw error\n throw new RenderRefusal('content-too-large', `${what} holds ${new TextEncoder().encode(payload).length} bytes, more than version ${EPC_MAX_VERSION} holds at level M, the largest code the EPC allows`, id)\n }\n if (caption === undefined) {\n refuseFineModules(symbol, size, what, 'its payload', id)\n return symbol\n }\n const version = epcCaptionBreak(size, versionOf(symbol))\n if (version !== undefined) throw new RenderRefusal('content-too-large', `${what} cannot be printed as the PSA prints it: ${version}`, id)\n return symbol\n}\n\n/**\n * Between each end of the caption and the frame's right line, which is\n * broken where the caption stands: one module. The PSA's figure leaves\n * about that, and gives no number.\n */\nconst CAPTION_GAP = 1\n\n/**\n * Fails the render on anything the SVG converter would otherwise only\n * warn about and draw past: above all a face it could not open, which it\n * would replace by whatever face it last drew in, without a word.\n */\nfunction refuseWarning(warning: string): never {\n throw new Error(`pdfmake's SVG converter could not draw an EPC QR code's caption as written: ${warning}`)\n}\n\n/** The code's square: a QR code's without a caption, the PSA's with one. */\nexport function epcContent(symbol: QrSymbol, code: EpcQrCode): ContentSvg | ConvertedSvg {\n return code.caption === undefined ? qrContent(symbol, code.size) : captionedContent(symbol, code.size)\n}\n\n/**\n * A captioned code's square, `size` points a side, drawn in points: white,\n * the frame, the symbol's dark modules as one path, and the caption.\n *\n * Across, from the left, it is what `epcModule` counts: the frame's line,\n * half a module; four modules; the symbol; four modules; and the caption's\n * band, 7 pt, which holds the caption and the frame's right line along\n * its baseline, the line's outer edge the square's right edge. So the\n * frame spans the square's width. Down, the frame is the symbol and four\n * and a half modules above and below it, less than the square by the\n * band and half a module, and stands in the middle of the square's\n * height. The caption reads from bottom to top, its letters' tops towards\n * the symbol, centred on the symbol and no longer than it (report-spec\n * refuses a version whose symbol is shorter), and the frame's right line\n * is broken a module beyond each end of it.\n *\n * The caption is text, drawn by pdfmake's SVG converter in Liberation\n * Sans: it is in the PDF's text, and a reader finds it.\n *\n * What that takes of a 30 mm square (85.04 pt), measured on the PDF on 17\n * October 2026 (`epc-qr-code.test.ts`): the EPC's first example drawn in\n * version 8, modules of 0.479 mm; across, 8.5 modules and the band, 18.54\n * pt, so that the symbol is 78.2 % of the side; down, 9 modules, with\n * 3.16 pt of the square white above the frame and below it. At its\n * corners the frame, rounded by two modules as the PSA's figure is, comes\n * within 3.49 modules of both of the symbol's edges -- 4.93 from its\n * corner, straight -- and so half a module into the square of four\n * modules ISO/IEC 18004 keeps quiet; along the sides, four.\n */\nfunction captionedContent(symbol: QrSymbol, size: number): ConvertedSvg {\n const modules = symbol.modules.length\n const module = epcModule(size, versionOf(symbol), 'zahlenMitCode')\n const line = EPC_FRAME.line * module\n const inset = line + EPC_FRAME.distance * module\n const side = modules * module\n const frame = side + 2 * inset\n const top = (size - frame) / 2\n // The frame's line along its middle: its outer edge on the square's sides, and on the frame's top and foot.\n const [left, right, upper, lower] = [line / 2, size - line / 2, top + line / 2, top + frame - line / 2]\n const radius = EPC_FRAME.radius * module\n const centre = top + inset + side / 2\n const broken = (EPC_CAPTION.advance * EPC_CAPTION.size) / 2 + CAPTION_GAP * module\n const corner = (x: number, y: number): string => `A${radius} ${radius} 0 0 1 ${x} ${y}`\n const path = `M${right} ${centre + broken}V${lower - radius}${corner(right - radius, lower)}H${left + radius}${corner(left, lower - radius)}V${upper + radius}${corner(left + radius, upper)}H${right - radius}${corner(right, upper + radius)}V${centre - broken}`\n const svg = [\n `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${size}\" height=\"${size}\" viewBox=\"0 0 ${size} ${size}\">`,\n `<rect width=\"${size}\" height=\"${size}\" fill=\"#ffffff\"/>`,\n `<path d=\"${path}\" fill=\"none\" stroke=\"#000000\" stroke-width=\"${line}\"/>`,\n `<path transform=\"translate(${inset} ${top + inset}) scale(${module})\" d=\"${darkRuns(symbol, 0)}\" fill=\"#000000\"/>`,\n `<text transform=\"translate(${right} ${centre}) rotate(-90)\" text-anchor=\"middle\" font-family=\"${LIBERATION_SANS}\" font-size=\"${EPC_CAPTION.size}\" fill=\"#000000\">${EPC_CAPTION.words}</text>`,\n '</svg>',\n ].join('')\n return { svg, width: size, height: size, options: { warningCallback: refuseWarning } }\n}\n","import type { ContentSvg } from 'pdfmake/interfaces.js'\nimport { RenderRefusal, type Image } from '@formancy/report-runtime'\nimport type { Vector } from './assets.js'\n\n/**\n * An SVG asset as pdfmake draws it (0030): the drawing `checkSvg` accepted,\n * handed to the SVG converter pdfmake 0.3.11 vendors, svg-to-pdfkit, as the\n * very text that was approved, in the image's box. The converter fits the\n * drawing's viewBox into the box itself, centred: `contain` is its\n * `xMidYMid meet`, all of the drawing as large as the box allows, and\n * `cover` its `xMidYMid slice`, the box filled and what falls outside it\n * clipped by the outer svg's viewport, which the converter clips to\n * (`pdfmake.test.ts` holds both). Nothing is drawn outside the box.\n *\n * What decides is the check: bytes that are not exactly what `cleanSvg`\n * writes never get this far (`assets.ts`). Two guards stand behind it, so\n * that a bug in the cleaner does not reach the converter as it would a\n * customer's file:\n *\n * - **The renderer's own list of elements.** Before it is handed on, the\n * text is held to the elements a cleaned drawing may hold, written here\n * and not taken from report-spec's tables, so that the two would have to\n * be wrong together: printable ASCII, no entity, and every tag one of\n * `DRAWN`. A link, an image, text, `use`, a style sheet, a comment or a\n * DOCTYPE is refused.\n * - **Callbacks that throw.** The converter would open an `<image>`'s file\n * past pdfmake's local access policy, or a virtual file in a browser, and\n * draws on past what it cannot read, saying so only to the console. Its\n * `imageCallback` and `warningCallback` throw instead, and its\n * `documentCallback` is left unset, so that it follows no reference out of\n * the drawing. They do not stop a link: the converter writes a link\n * annotation for an `<a>` whatever its callbacks say (`pdfmake.test.ts`),\n * which is why the list above refuses one.\n */\n\n/** The elements of a drawing in the form `cleanSvg` writes (0030), the renderer's own copy: it may refuse more than report-spec's tables, never less, and `svg-threats.test.ts` holds it to them. */\nexport const DRAWN: ReadonlySet<string> = new Set(['svg', 'g', 'defs', 'path', 'rect', 'circle', 'ellipse', 'line', 'polyline', 'polygon', 'linearGradient', 'radialGradient', 'stop', 'clipPath'])\n\n/** A tag's name as a refusal may repeat it: short, and nothing but a name's characters. */\nconst NAME = /^[A-Za-z][A-Za-z0-9:._-]{0,63}$/\n\n/**\n * What in `svg` the renderer never hands the converter, or nothing: a\n * character that is not printable ASCII, an entity, or a tag -- an end tag,\n * a comment, a DOCTYPE or a processing instruction among them -- that is\n * not one of `DRAWN`.\n */\nexport function foreignMarkup(svg: string): string | undefined {\n if (/[^\\x20-\\x7e]/.test(svg)) return 'a character that is not printable ASCII'\n if (svg.includes('&')) return 'an entity'\n for (const [, name = ''] of svg.matchAll(/<\\/?([^\\s/>]*)/g)) {\n if (!DRAWN.has(name)) return NAME.test(name) ? `the element ${name}` : 'markup that is not an element'\n }\n return undefined\n}\n\n/** What pdfmake's SVG converter is handed beside the drawing, which pdfmake 0.3.11 passes on (`Renderer.renderSVG`) and its types do not declare. */\nexport interface ConverterOptions {\n readonly preserveAspectRatio?: string\n readonly imageCallback?: (href: string) => never\n readonly warningCallback: (warning: string) => never\n}\n\n/** An SVG node with options for pdfmake's SVG converter. */\nexport type ConvertedSvg = ContentSvg & { readonly options: ConverterOptions }\n\n/**\n * The converter's options for the asset `id` drawn as `fit` says: the\n * viewBox fitted into the box, and both callbacks refusing the asset.\n * Neither repeats what the converter was handed: a callback is what holds\n * only where the check has failed, and then the drawing may hold anything\n * -- a file's path, an id, a word -- which the converter's warnings quote.\n */\nexport function converterOptions(id: string, fit: Image['fit']): ConverterOptions {\n return {\n preserveAspectRatio: fit === 'cover' ? 'xMidYMid slice' : 'xMidYMid meet',\n imageCallback: () => {\n throw new RenderRefusal('invalid-asset', `the image asset ${id} asks pdfmake's SVG converter to open an image, which the renderer never lets it do`, id)\n },\n warningCallback: () => {\n throw new RenderRefusal('invalid-asset', `pdfmake's SVG converter could not draw the image asset ${id} as it was approved: it warned, and the renderer draws an SVG whole or not at all`, id)\n },\n }\n}\n\n/** The drawings that have passed the list: one in a page region is built anew for every page, and read once. */\nconst PASSED = new WeakSet<Vector>()\n\n/** `image`, an SVG whose drawing the checks read as `vector`, as pdfmake's node: the drawing in the image's box, guarded and under the converter's options. */\nexport function svgContent(image: Image, vector: Vector): ConvertedSvg {\n const { id } = image.asset\n if (!PASSED.has(vector)) {\n const foreign = foreignMarkup(vector.svg)\n if (foreign !== undefined) throw new RenderRefusal('invalid-asset', `the image asset ${id} holds ${foreign}, which the renderer never hands pdfmake's SVG converter`, id)\n PASSED.add(vector)\n }\n return { svg: vector.svg, width: image.width, height: image.height, options: converterOptions(id, image.fit) }\n}\n","import type { RowKind } from './build.js'\n\n/**\n * Which rows of a table must share a page, and where a table's page breaks\n * fall once they do: pure arithmetic on the row heights the body pass\n * measured (`measure.ts`), which `table.ts` turns into pdfmake's rules.\n *\n * **What is kept together.** A group header with the row it heads, so a\n * group never starts at the foot of a page with nothing under its heading.\n * And a table's closing rows -- a group's footers, the totals under the\n * last row -- with the row before them, and with its group header when that\n * row is the group's first: a quotation's subtotal, VAT and total on one\n * page with the last line item, a subtotal on the page of the rows it adds\n * up, never alone under a repeated column header. Each is a `KeepBlock`.\n *\n * **Why plan the breaks.** pdfmake asks the renderer's rule for each marked\n * node once its layout is done, and lays the whole document out again for\n * the first rule that asks for a break. A rule fires about once a page, so\n * a long grouped table was laid out once per page: 1,600 groups over 134\n * pages took 60 seconds (measured on 2026-10-15, on an Intel i9-10900K under\n * Node 24.21). So when the first row of a table is laid out, the breaks its\n * rules will ask for are worked out here, from the measured heights, where\n * the first row stands and where a row starts under the repeated header,\n * and are all made in the next layout. The rules stay, and hold the next\n * layout to them: a break the plan missed is still made, one layout later.\n */\n\n/** Rows from `first` to `last`, indices into the table's rows as pdfmake lays them out (the column header at 0), that stand on one page. */\nexport interface KeepBlock {\n readonly first: number\n readonly last: number\n}\n\n/** Rows that close what is above them: a group's footer, a total. */\nconst CLOSING: ReadonlySet<RowKind> = new Set(['groupFooter', 'total'])\n\n/**\n * The blocks of rows of these kinds that stand on one page, overlapping\n * ones merged, in order. Closing rows are kept with the row before them only\n * when `closing`: a table whose rows may split across pages has no row\n * height to keep them by.\n */\nexport function keepBlocks(kinds: readonly RowKind[], closing: boolean): KeepBlock[] {\n const blocks: KeepBlock[] = []\n kinds.forEach((kind, index) => {\n if (kind === 'groupHeader' && index + 1 < kinds.length) blocks.push({ first: index, last: index + 1 })\n const before = kinds[index - 1]\n if (!closing || !CLOSING.has(kind) || before === undefined || CLOSING.has(before) || (before !== 'detail' && before !== 'empty')) return\n let last = index\n while (kinds[last + 1] !== undefined && CLOSING.has(kinds[last + 1]!)) last++\n const anchor = index - 1\n blocks.push({ first: kinds[anchor - 1] === 'groupHeader' ? anchor - 1 : anchor, last })\n })\n const merged: KeepBlock[] = []\n for (const block of blocks.sort((a, b) => a.first - b.first)) {\n const previous = merged.at(-1)\n if (previous !== undefined && block.first <= previous.last) merged[merged.length - 1] = { first: previous.first, last: Math.max(previous.last, block.last) }\n else merged.push(block)\n }\n return merged\n}\n\n/** The rows' height from `first` to `last`, each row's pitch being its height and the rule under it. */\nexport function blockHeight(pitches: readonly number[], block: KeepBlock): number {\n return pitches.slice(block.first, block.last + 1).reduce((sum, pitch) => sum + pitch, 0)\n}\n\n/** The blocks a table's rules can keep: each fits under the repeated header, and starts after the rows that move with it. */\nexport function keptBlocks(blocks: readonly KeepBlock[], pitches: readonly number[], keepWithHeaderRows: number, room: number): KeepBlock[] {\n return blocks.filter((block) => block.first > keepWithHeaderRows && blockHeight(pitches, block) <= room)\n}\n\n/** Where a table stands on the pages its body pass did not see: what the first layout showed. */\nexport interface Geometry {\n /** The top of the row `first`, on its page. */\n readonly top: number\n /** Where a row starts on a page the table continues on: under the repeated column header. */\n readonly continued: number\n /** The foot of every page's body. */\n readonly bottom: number\n}\n\n/** A height closer than this to what is left of a page could fall either way in pdfmake's arithmetic: the plan stops there and leaves the rest to the rules. */\nconst UNSURE = 0.01\n\n/**\n * The rows, from `first` on, that the `blocks`' rules will break before,\n * laid out row after row as pdfmake lays out rows it keeps whole: a row\n * that does not fit in what is left of a page starts the next one. `sure`\n * is false when a height came too close to the foot of a page to say, and\n * the breaks are then those before it.\n */\nexport function plannedBreaks(pitches: readonly number[], blocks: readonly KeepBlock[], first: number, geometry: Geometry): { readonly breaks: readonly number[]; readonly sure: boolean } {\n const { continued, bottom } = geometry\n const starts = new Map(blocks.map((block) => [block.first, block]))\n const breaks: number[] = []\n let y = geometry.top\n /** Whether `height` fits below `y`, or undefined when that is too close to say. */\n const fits = (height: number): boolean | undefined => {\n const left = bottom - y - height\n return Math.abs(left) < UNSURE ? undefined : left > 0\n }\n for (let row = first; row < pitches.length; row++) {\n // A row that does not fit starts the next page by itself, and its block with it.\n const fitting = fits(pitches[row]!)\n if (fitting === undefined) return { breaks, sure: false }\n if (!fitting) y = continued\n const block = starts.get(row)\n if (block !== undefined && y > continued + UNSURE) {\n const whole = fits(blockHeight(pitches, block))\n if (whole === undefined) return { breaks, sure: false }\n if (!whole) {\n breaks.push(row)\n y = continued\n }\n }\n y += pitches[row]!\n }\n return { breaks, sure: true }\n}\n\n/** Where a row stands when nothing breaks the table but pdfmake: the page, counting the first row's as 0; its top; whether it is first on that page. */\nexport interface Placed {\n readonly page: number\n readonly top: number\n readonly first: boolean\n}\n\n/** Where each row from `first` on stands when no rule breaks the table: how pdfmake lays out rows it keeps whole. */\nexport function naturalLayout(pitches: readonly number[], first: number, geometry: Geometry): Placed[] {\n const placed: Placed[] = []\n let [y, page] = [geometry.top, 0]\n for (let row = first; row < pitches.length; row++) {\n const moves = y + pitches[row]! > geometry.bottom\n if (moves) [y, page] = [geometry.continued, page + 1]\n placed.push({ page, top: y, first: moves || row === first })\n y += pitches[row]!\n }\n return placed\n}\n","import type { Node, NodeQueries } from 'pdfmake/interfaces.js'\nimport { naturalLayout, plannedBreaks, type Geometry, type KeepBlock } from './breaks.js'\nimport { mark, pageOf, type BreakRule, type Build, type TablePlan } from './build.js'\nimport type { Cell, Row } from './table.js'\n\n/**\n * The rules that keep a table's blocks of rows on one page (`breaks.ts`),\n * as pdfmake runs them: each cell of a block's first row that prints is\n * marked with a rule, each cell of its first and last rows that prints gets\n * an id, and when none of the last row's starts on the first row's page,\n * the first row breaks to the next page, under the repeated column header.\n * pdfmake breaks before a cell, not a row, so every cell of the row that\n * prints carries the rule, and the first to break sets the break on the\n * others: one at a time, each left a piece of the row's rule at the foot of\n * the page, and took a layout of its own. The ids are what make a row's\n * page right: pdfmake corrects the page of a node it moved whole to the\n * next page only when it has one, and without it a row that did not fit\n * reported the page before, and its rule broke before a row already first\n * on its page, for another layout. Every id is a named destination in the\n * PDF, two to a block.\n *\n * A block first on its page always fits: the table's plan keeps only\n * blocks that fit under the repeated header, and none that start among the\n * rows that move with the header (`keepWithHeaderRows`), where a break\n * inside pdfmake's unbreakable block would lose the rows after it. A block\n * whose first or last row has no text cannot be kept: there is nothing on\n * the page for the rule to find.\n *\n * In the body, outside any frame, a table whose rows are kept whole also\n * has its breaks planned. The first body row after those that move with\n * the header carries one more rule, which pdfmake asks before any block's\n * once its first layout is done. It reads where that row stands, works out\n * every break the blocks' rules would ask for (`plannedBreaks`), and makes\n * them all in the next layout -- the first through its own rule's answer,\n * the rest by setting the break on their cells -- so that a table of any\n * length is laid out about twice, not once a page.\n *\n * pdfmake reports where a row of a table it keeps whole starts: its row's\n * top, on its page. Not for a row that did not fit, which reports where it\n * would have stood, at the foot of the page before, nor for the rows that\n * move with the header, which report where they stand in the block they\n * move in. So the plan starts from the first row after those, and before it\n * plans anything it lays the table out by its own arithmetic and compares\n * every row pdfmake reports on that page and the next, other than the first\n * of a page: if one differs, nothing is planned, and the rules alone break\n * the table, one layout each.\n */\n\n/** Where a page's first row starts on the pages a table continues on; `undefined` where its breaks are not planned. */\nexport type Continued = number | undefined\n\nexport function tableRules(rows: readonly Row[], plan: TablePlan, build: Build, continued: Continued): void {\n const forced = new Set<Cell>()\n const ruled = plan.blocks.flatMap((block) => {\n const starts = printing(rows[block.first]!)\n const end = rows.slice(block.first + 1, block.last + 1).findLast((row) => printing(row).length > 0)\n if (starts.length === 0 || end === undefined) return []\n const ends = printing(end)\n for (const cell of [...starts, ...ends]) cell.id ??= `row-${build.next++}`\n for (const cell of starts) {\n add(\n cell,\n (node) => {\n const breaks = forced.has(cell) || !ends.some((other) => pageOf(other) === node.startPosition.pageNumber)\n if (breaks) for (const other of starts) if (other !== cell) other.pageBreak = 'before'\n return breaks\n },\n build,\n )\n }\n return [block]\n })\n if (continued === undefined || !plan.dontBreakRows || ruled.length === 0) return\n // Every row's first printing cell is marked, so that a row is found among the nodes pdfmake reports by its mark.\n const rowOf = new Map<number, number>()\n rows.forEach((row, index) => {\n const [first] = printing(row)\n if (first !== undefined && index > 0) rowOf.set(mark(first, build), index)\n })\n const hookRow = rows.findIndex((row, index) => index > plan.keepWithHeaderRows && printing(row).length > 0)\n if (hookRow === -1 || hookRow > ruled[0]!.first) return\n const hook = printing(rows[hookRow]!)[0]!\n let done = false\n const planning: BreakRule = (node, queries) => {\n if (!done) {\n done = true\n const geometry: Geometry = { top: node.startPosition.top, continued, bottom: build.bodyBottom }\n for (const [index, row] of planBreaks(plan, ruled, hookRow, geometry, node, queries, rowOf).entries()) {\n // The first break is made by its first cell's own rule, which pdfmake asks next; the rest are set here.\n printing(rows[row]!).forEach((cell, at) => (index === 0 && at === 0 ? forced.add(cell) : (cell.pageBreak = 'before')))\n }\n }\n return forced.has(hook)\n }\n add(hook, planning, build)\n}\n\n/** The rows the blocks' rules will break before, from row `hookRow` on; none when what pdfmake reports of this page and the next is not what the arithmetic gives. */\nfunction planBreaks(\n plan: TablePlan,\n blocks: readonly KeepBlock[],\n hookRow: number,\n geometry: Geometry,\n node: Node,\n queries: NodeQueries,\n rowOf: ReadonlyMap<number, number>,\n): readonly number[] {\n // A row that did not fit reports where it would have stood, and nothing can be planned from it.\n if (geometry.top + plan.pitches[hookRow]! > geometry.bottom) return []\n const placed = naturalLayout(plan.pitches, hookRow, geometry)\n const page = node.startPosition.pageNumber\n for (const other of [...queries.getFollowingNodesOnPage(), ...queries.getNodesOnNextPage()]) {\n const row = other.headlineLevel === undefined ? undefined : rowOf.get(other.headlineLevel)\n const at = row === undefined ? undefined : placed[row - hookRow]\n if (at === undefined || at.first) continue\n if (other.startPosition.pageNumber !== page + at.page || Math.abs(other.startPosition.top - at.top) > 0.01) return []\n }\n return plannedBreaks(plan.pitches, blocks, hookRow, geometry).breaks\n}\n\n/** Sets `rule` on `cell`'s mark, asked before a rule it has: the planning rule, before the block rule of a row that starts a block. */\nfunction add(cell: Cell, rule: BreakRule, build: Build): void {\n const at = mark(cell, build)\n const had = build.rules.get(at)\n build.rules.set(at, had === undefined ? rule : (node, queries) => rule(node, queries) || had(node, queries))\n}\n\n/** The cells of a row that have text. */\nexport function printing(row: Row): Cell[] {\n return row.cells.filter((cell) => cell.text.trim() !== '')\n}\n","import type { TableColumn } from '@formancy/report-runtime'\n\n/** Points, or `'fill'` for an equal share of what the fixed widths leave. */\ntype Width = TableColumn['width']\n\n/**\n * Widths as the renderer hands them to pdfmake: always a number of points.\n * pdfmake widens a column it is handed as `'*'` to its longest word, so a\n * table, a columns block or a frame grew past the page with a long word in\n * it; a fill column is therefore its share of the width worked out here,\n * the one place the check (`check.ts`) and the content (`content.ts`,\n * `table.ts`) take it from.\n */\n\n/** Points, or nothing for `'fill'`. */\nexport function fixedWidth(width: Width): number {\n return width === 'fill' ? 0 : width\n}\n\n/** The width each `'fill'` gets of `width`: what the fixed widths leave, shared equally. Infinity when there is none. */\nexport function fillWidth(widths: readonly Width[], width: number): number {\n const fixed = widths.reduce<number>((sum, each) => sum + fixedWidth(each), 0)\n const fills = widths.filter((each) => each === 'fill').length\n return fills === 0 ? Infinity : (width - fixed) / fills\n}\n\n/** Each column's width in points, of `width`: a fixed one its own, each fill its share. */\nexport function columnWidths(widths: readonly Width[], width: number): number[] {\n const fill = fillWidth(widths, width)\n return widths.map((each) => (each === 'fill' ? fill : each))\n}\n","import type { Content, CustomTableLayout, TableCell } from 'pdfmake/interfaces.js'\nimport type { Table, TableColumn, TextStyle } from '@formancy/report-runtime'\nimport { mark, UNPLANNED, type Build, type RowKind } from './build.js'\nimport { textProperties } from './style.js'\nimport { tableRules } from './table-rules.js'\nimport { columnWidths } from './widths.js'\n\n/**\n * A table as pdfmake content: its header row repeated on every page it\n * spans, its rows styled, a row across the table as one cell spanning every\n * column, and the rule that keeps a group header with the row it heads.\n */\n\n/** A table's cells, whose size the document does not set: the body size the corpus's geometry assumes. */\nexport const TABLE_SIZE = 9\n\n/** The table layout: horizontal rules of half a point, no vertical ones, 4pt of padding at the sides and 2pt above and below. */\nexport const RULE = 0.5\nexport const PADDING_X = 4\nexport const PADDING_Y = 2\nconst TABLE_LAYOUT: CustomTableLayout = {\n hLineWidth: () => RULE,\n vLineWidth: () => 0,\n hLineColor: (index) => (index === 1 ? '#000000' : '#bfbfbf'),\n paddingLeft: () => PADDING_X,\n paddingRight: () => PADDING_X,\n paddingTop: () => PADDING_Y,\n paddingBottom: () => PADDING_Y,\n}\n\n/** Laid out as one line of text, as wide as a space, that no line break can fall in. */\nconst NO_BREAK_SPACE = String.fromCodePoint(0xa0)\n\n/** The renderer's own style for a row of each kind, under the document's: the column header and every row but a detail row in bold. */\nexport const KIND_BOLD: Readonly<Record<RowKind, boolean>> = { header: true, empty: false, detail: false, groupHeader: true, groupFooter: true, total: true }\n\n/** A table cell as the renderer makes it. A cell a column span covers is one too, as pdfmake requires, and pdfmake lays out nothing of it. */\nexport interface Cell {\n readonly text: string\n readonly alignment: TableColumn['align']\n readonly colSpan?: number\n headlineLevel?: number\n id?: string\n /** Set by a table's planned breaks (`table-rules.ts`). */\n pageBreak?: 'before'\n}\n\n/** A row as pdfmake lays it out: the header, the empty text in place of detail rows when there are none, the document's rows. */\nexport interface Row {\n readonly kind: RowKind\n readonly cells: readonly Cell[]\n}\n\n/**\n * The content of `table`, standing `width` wide: `kept` inside a keep-together\n * block or a page region, where no rule may break it; `record`ing its cells\n * for the word check; `top` the body's top, outside any frame, where its\n * breaks can be planned (`table-rules.ts`). Every column is handed to pdfmake\n * as a number, a fill column as its share, never as `'*'`, which pdfmake\n * widens to its longest word (`widths.ts`).\n */\nexport function tableContent(table: Table, build: Build, place: { readonly width: number; readonly kept: boolean; readonly record: boolean; readonly top: number }): Content {\n const { kept } = place\n const measuring = build.mode === 'measure'\n const columns = table.columns.length\n const widths = columnWidths(table.columns.map((column) => column.width), place.width).map((width) => width - 2 * PADDING_X)\n const across = place.width - 2 * PADDING_X\n // A no-break space where a cell is empty while measuring: every cell then\n // lays out one line, as tall as a cell of text beside it, so each row has a\n // first cell to mark.\n const cell = (text: string, column: number, kind: RowKind, style: TextStyle, span?: number): Cell => ({\n text: measuring && text === '' ? NO_BREAK_SPACE : text,\n alignment: style.align ?? table.columns[column]!.align,\n ...textProperties(style, { size: TABLE_SIZE, bold: KIND_BOLD[kind] }),\n ...(span === undefined ? {} : { colSpan: span }),\n })\n // The cells a span covers: one per column after the first, laid out as nothing.\n const covered = (): Cell[] => table.columns.slice(1).map((_, index) => cell('', index + 1, 'detail', {}))\n const empty = !table.rows.some((row) => row.kind === 'detail')\n const rows: Row[] = [\n { kind: 'header', cells: table.header.map((text, column) => cell(text, column, 'header', table.headerStyle ?? {})) },\n ...(empty ? [{ kind: 'empty' as const, cells: [cell(table.emptyText, 0, 'empty', { italic: true }, columns), ...covered()] }] : []),\n ...table.rows.map((row): Row => {\n const style = (column: number): TextStyle => row.cellStyles?.[column] ?? row.style ?? {}\n if (row.across === true) return { kind: row.kind, cells: [cell(row.cells[0]!, 0, row.kind, style(0), columns), ...covered()] }\n return { kind: row.kind, cells: row.cells.map((text, column) => cell(text, column, row.kind, style(column))) }\n }),\n ]\n if (place.record) recordWords(table, rows, widths, across, build)\n const plan = build.plans.get(table) ?? UNPLANNED\n if (measuring) {\n build.measuredRows.set(table, rows.map((row) => ({ kind: row.kind, mark: mark(row.cells[0]!, build) })))\n } else if (!kept) {\n // In the body outside any frame, a page the table continues on starts under its top rule and repeated header.\n tableRules(rows, plan, build, place.top === build.bodyTop ? build.bodyTop + RULE + (plan.pitches[0] ?? 0) : undefined)\n }\n return {\n table: {\n headerRows: measuring ? 0 : 1,\n ...(measuring || plan.keepWithHeaderRows === 0 ? {} : { keepWithHeaderRows: plan.keepWithHeaderRows }),\n ...(measuring ? {} : { dontBreakRows: plan.dontBreakRows }),\n widths,\n body: rows.map((row): TableCell[] => [...row.cells]),\n },\n layout: TABLE_LAYOUT,\n fontSize: TABLE_SIZE,\n }\n}\n\n/** Every cell of the table, held to its column's width, or the table's for a cell across it (`words.ts`). */\nfunction recordWords(table: Table, rows: readonly Row[], widths: readonly number[], across: number, build: Build): void {\n let row = 0\n for (const { kind, cells } of rows) {\n const which = kind === 'header' ? `the header of table ${table.id}` : kind === 'empty' ? `the empty text of table ${table.id}` : `row ${row++} of table ${table.id}`\n cells.forEach((cell, column) => {\n if (cell.text === '') return\n const spans = cell.colSpan !== undefined\n build.words.push({ node: cell, width: spans ? across : widths[column]!, lines: 1, what: spans ? which : `${which}, column ${column + 1}`, subject: table.id })\n })\n }\n}\n","import { RenderRefusal } from '@formancy/report-runtime'\n\n/**\n * Words wider than where they stand, refused before pdfmake breaks them.\n *\n * pdfmake measures every word of a document before it lays out a line --\n * the widest unbreakable run of each text node is its `_minWidth` -- and\n * only then breaks the lines. A word wider than its line it breaks one line\n * at a time, measuring all that is left of the word for each: 16,384 W in a\n * 20pt table column took 42 seconds (measured on 2026-10-15, on an Intel\n * i9-10900K under Node 24.21). And a word broken anywhere can print as\n * something else: 'CHF 10,612,357.00' in an 85pt column printed\n * 'CHF 10,612,357.0' on one line and '0' on the next.\n *\n * So once pdfmake has measured the words and before it lays out the first\n * line -- from the function it calls for the first page's background --\n * every recorded text node's widest word is held to its room:\n * - **a table cell** to its column, less its padding: a word wider than\n * that is refused, naming the table, the row and the column. A cell's\n * value is often a number or an identifier, which no break may split.\n * - **a paragraph** to `MAX_WORD_LINES` lines of its width: a longer word,\n * such as an identifier with no space in it, breaks across lines, as the\n * corpus's `long-paragraph` fixture asks; one longer than that is\n * refused, naming the block, before pdfmake breaks a line of it.\n *\n * `_minWidth` is pdfmake's own, not part of its API; `pdfmake.test.ts`\n * holds that 0.3.11 still writes it where the renderer reads it.\n */\n\n/**\n * The most lines one word of a paragraph may be broken across. Chosen: the\n * corpus's 300-character identifier takes four lines of the page; sixteen\n * lines of the narrowest column a document can have stay a moment's work.\n */\nexport const MAX_WORD_LINES = 16\n\n/** A text node pdfmake measures, and the room its widest word has. */\nexport interface WordRoom {\n /** The node as handed to pdfmake, which writes `_minWidth` onto it. */\n readonly node: object\n /** The width of one line, in points. */\n readonly width: number\n /** The lines its widest word may take: 1 for a table cell. */\n readonly lines: number\n /** Where it is, for a person: \"row 3 of table lines, column 2\". */\n readonly what: string\n readonly subject: string\n}\n\n/** How much wider than its room a word may measure and still be laid out unbroken: rounding, not layout. */\nconst SLACK = 0.001\n\n/** Refuses the first text node whose widest word, as pdfmake measured it, is wider than its room. Nodes pdfmake has not measured are passed over. */\nexport function checkWords(rooms: readonly WordRoom[]): void {\n for (const { node, width, lines, what, subject } of rooms) {\n const widest = (node as { readonly _minWidth?: unknown })._minWidth\n if (typeof widest !== 'number' || widest <= width * lines + SLACK) continue\n const room = lines === 1 ? `its column holds ${width.toFixed(2)} pt` : `${lines} lines of its width are ${(width * lines).toFixed(2)} pt`\n throw new RenderRefusal('content-too-large', `a word of ${what} is ${widest.toFixed(2)} pt wide, and ${room}; a word is broken only in a paragraph, and across no more than ${MAX_WORD_LINES} lines`, subject)\n }\n}\n","import type { Content, CustomTableLayout } from 'pdfmake/interfaces.js'\nimport type { Block, Columns, Image, ImageAsset, Inline, Paragraph, Rectangle, Rule, Section } from '@formancy/report-runtime'\nimport { base64 } from './bytes.js'\nimport { startsOnPage, type Build, type Fields } from './build.js'\nimport { epcContent } from './epc.js'\nimport { qrContent } from './qr.js'\nimport { DEFAULT_SIZE, textProperties } from './style.js'\nimport { svgContent } from './svg-content.js'\nimport { tableContent } from './table.js'\nimport { columnWidths } from './widths.js'\nimport { MAX_WORD_LINES } from './words.js'\n\n/**\n * The document's blocks as pdfmake content (`build.ts` says what a build\n * accumulates, and in which mode).\n *\n * Most blocks are one pdfmake node each. A section is its blocks: in a stack\n * of their own when it has no frame, as though it were not there, and in a\n * table of one cell when it has one, whose borders pdfmake draws around the\n * part of it on each page. A columns block is pdfmake's columns, with no gap\n * between them but what their widths leave.\n */\n\n/** Space above and below a rule's line. A rule block takes its line and both. */\nexport const RULE_GAP = 3\n\n/** The weight a rectangle's outline is drawn at, inside its box: the table rules' weight. */\nexport const OUTLINE = 0.5\n\n/** How far a node may start below the top of what it sits under and still be first there: rounding, not layout. */\nconst AT_TOP = 0.5\n\n/** Where a list of blocks stands. */\ninterface Scope {\n /** The width the blocks are laid out across. */\n readonly width: number\n /** No rule may break inside: a keep-together block, a page region, a column. */\n readonly kept: boolean\n /** Where a page's first line of these blocks would start: the body's top, below every frame around them. */\n readonly top: number\n readonly fields?: Fields\n /** Whether its text nodes are recorded for the word check: not a page region's in the last pass, which pdfmake builds anew for each page and a measuring pass has checked. */\n readonly record: boolean\n}\n\n/** Content for the body's blocks, laid out `width` wide, or a page region's when `fields` are given. */\nexport function contentOf(blocks: readonly Block[], build: Build, width: number, fields?: Fields): Content[] {\n const record = fields === undefined || build.mode === 'measure'\n return sequence(blocks, build, fields === undefined ? { width, kept: false, top: build.bodyTop, record } : { width, kept: true, top: 0, fields, record })\n}\n\n/** Border and padding on each side of a section: what it takes from the width, and from a page's height above and below. */\nexport function frameOf(section: Section): number {\n return (section.border?.thickness ?? 0) + (section.padding ?? 0)\n}\n\n/** A section with neither border, fill nor padding is its blocks and nothing more. */\nfunction framed(section: Section): boolean {\n return section.border !== undefined || section.fill !== undefined || (section.padding ?? 0) > 0\n}\n\n/** The blocks with every section that has no frame replaced by its blocks, which flow as though they stood in its place. */\nfunction unframed(blocks: readonly Block[]): Block[] {\n return blocks.flatMap((block) => (block.kind === 'section' && !framed(block) ? unframed(block.blocks) : [block]))\n}\n\n/**\n * The blocks' content. Outside a kept scope, a keep-with-next paragraph\n * breaks to the next page when the block it is kept with does not start on\n * its page -- unless it is first on its page already, where a break would\n * leave the page empty and the paragraph no better kept on the next.\n */\nfunction sequence(given: readonly Block[], build: Build, scope: Scope): Content[] {\n const blocks = unframed(given)\n const contents = blocks.map((block) => blockContent(block, build, scope))\n if (build.mode !== 'render' || scope.kept) return contents\n blocks.forEach((block, index) => {\n if (block.kind !== 'paragraph' || block.keepWithNext !== true) return\n const anchor = keptWith(blocks, contents, index)\n if (anchor === undefined) return\n anchor.id ??= `kept-${build.next++}`\n const ids = new Set([anchor.id])\n const own = build.next++\n ;(contents[index] as Anchor).headlineLevel = own\n build.rules.set(own, (node, queries) => node.startPosition.top > scope.top + AT_TOP && !startsOnPage(queries, ids, node.startPosition.pageNumber))\n })\n return contents\n}\n\n/** A node of the content the renderer builds, as far as a rule needs to know it: always an object, every table cell and column included. */\ninterface Anchor {\n readonly text?: unknown\n readonly image?: unknown\n /** A QR code or an EPC QR code: what the renderer draws as an SVG (`qr.ts`, `epc.ts`). */\n readonly svg?: unknown\n readonly stack?: readonly Anchor[]\n readonly columns?: readonly Anchor[]\n readonly table?: { readonly body: readonly (readonly Anchor[])[] }\n id?: string\n headlineLevel?: number\n}\n\n/** The first node of `node` that prints text, or an image or a QR code when no text comes first: where pdfmake records the content's start. */\nfunction anchorOf(node: Anchor): Anchor | undefined {\n const inner = node.stack ?? node.columns ?? node.table?.body.flat()\n if (inner !== undefined) {\n for (const each of inner) {\n const anchor = anchorOf(each)\n if (anchor !== undefined) return anchor\n }\n return undefined\n }\n // A paragraph's text is an array of runs, and the renderer keeps nothing with a paragraph that prints nothing.\n const printsText = typeof node.text === 'string' ? node.text.trim() !== '' : Array.isArray(node.text)\n return printsText || node.image !== undefined || node.svg !== undefined ? node : undefined\n}\n\n/**\n * Where the block a keep-with-next paragraph at `index` stays with starts:\n * the anchor of the next block that prints text, an image or a QR code,\n * past spacers, rules, rectangles and other keep-with-next paragraphs, so\n * that a run of headings moves as one. None when a page break or the end of\n * the list comes first: a heading over nothing is not kept with anything.\n */\nfunction keptWith(blocks: readonly Block[], contents: readonly Content[], index: number): Anchor | undefined {\n for (let next = index + 1; next < blocks.length; next++) {\n const block = blocks[next]!\n if (block.kind === 'pageBreak') return undefined\n const anchor = block.kind === 'paragraph' && block.keepWithNext === true ? undefined : anchorOf(contents[next] as Anchor)\n if (anchor !== undefined) return anchor\n }\n return undefined\n}\n\nfunction blockContent(block: Block, build: Build, scope: Scope): Content {\n switch (block.kind) {\n case 'paragraph':\n return paragraphContent(block, build, scope)\n case 'table':\n return tableContent(block, build, scope)\n case 'image':\n return imageContent(block, build)\n case 'qrCode':\n // check.ts encodes every QR code before anything is built.\n return qrContent(build.codes.get(block)!, block.size)\n case 'epcQrCode':\n // And every EPC QR code.\n return epcContent(build.codes.get(block)!, block)\n case 'rule':\n return ruleContent(block, scope.width)\n case 'rectangle':\n return rectangleContent(block)\n // An empty stack, never empty text: pdfmake lays out empty text as one\n // line of the default size, which would add 11.7pt to every spacer and\n // to the top of the page after every break. At the foot of a page with\n // less room than it asks for, a spacer moves to the next page and starts\n // there, without the space.\n case 'spacer':\n return { stack: [], margin: [0, block.height, 0, 0] }\n case 'pageBreak':\n return { stack: [], pageBreak: 'before' }\n case 'keepTogether':\n return { stack: sequence(block.blocks, build, { ...scope, kept: true }), unbreakable: build.mode === 'render' }\n case 'columns':\n return columnsContent(block, build, scope)\n case 'section':\n return sectionContent(block, build, scope)\n }\n}\n\nfunction paragraphContent(paragraph: Paragraph, build: Build, scope: Scope): Content {\n const style = paragraph.style ?? {}\n const content = {\n text: paragraph.runs.length === 0 ? '' : paragraph.runs.map((run) => inline(run, scope.fields)),\n alignment: style.align ?? 'left',\n ...textProperties(style, { size: DEFAULT_SIZE }),\n }\n // check.ts walks every paragraph, and records where it stands, before anything is built.\n const at = build.paths.get(paragraph) as string\n if (scope.record) build.words.push({ node: content, width: scope.width, lines: MAX_WORD_LINES, what: at, subject: at })\n return content\n}\n\nfunction inline(run: Inline, fields: Fields | undefined): { text: string; bold?: boolean } {\n if ('text' in run) return run.bold === undefined ? { text: run.text } : { text: run.text, bold: run.bold }\n // The renderer refuses a page field outside a page region before building anything.\n if (fields === undefined) throw new Error(`a ${run.field} field outside a page region`)\n return { text: String(fields[run.field]) }\n}\n\n/**\n * An image in its box, which the layout reserves whole. An SVG is drawn in\n * the box itself, by pdfmake's SVG converter, which fits and centres it\n * (`svg-content.ts`). For a PNG or a JPEG, `cover` is pdfmake's own: the box\n * clipped, the image scaled to fill it and centred. `contain` is drawn at\n * the size the box allows at the image's proportions, read from its pixels,\n * and centred in the box by margins that make up the rest of it.\n */\nfunction imageContent(image: Image, build: Build): Content {\n // The asset checks read every image's asset before anything is built.\n const checked = build.assets.get(image.asset)!\n if (checked.kind === 'vector') return svgContent(image, checked)\n const key = imageKey(image.asset, build)\n if (image.fit === 'cover') return { image: key, cover: { width: image.width, height: image.height, align: 'center', valign: 'center' } }\n const scale = Math.min(image.width / checked.width, image.height / checked.height)\n const [width, height] = [checked.width * scale, checked.height * scale]\n const [x, y] = [(image.width - width) / 2, (image.height - height) / 2]\n return { image: key, width, height, margin: [x, y, image.width - width - x, y] }\n}\n\nfunction imageKey(asset: ImageAsset, build: Build): string {\n const known = build.imageKeys.get(asset)\n if (known !== undefined) return known\n const key = `image${build.imageKeys.size}`\n build.imageKeys.set(asset, key)\n build.images[key] = `data:${asset.mediaType};base64,${base64(asset.bytes)}`\n return key\n}\n\n/**\n * pdfmake makes a canvas as tall as its lowest point and strokes a line half\n * its width to either side: the line half its width down, and the other half\n * of it in the margin below.\n */\nfunction ruleContent(rule: Rule, width: number): Content {\n const half = rule.thickness / 2\n return {\n canvas: [{ type: 'line', x1: 0, y1: half, x2: width, y2: half, lineWidth: rule.thickness, lineColor: rule.color ?? '#000000' }],\n margin: [0, RULE_GAP, 0, RULE_GAP + half],\n }\n}\n\n/**\n * A rectangle's box, exactly: its outline is stroked inside it, half the\n * weight in from each edge, and the canvas, as tall as its lowest point,\n * takes the rest of the box in a margin. A box no wider or taller than two\n * outlines is all outline, and is filled with the outline's colour.\n */\nfunction rectangleContent(rectangle: Rectangle): Content {\n const { width, height, fill, stroke } = rectangle\n if (stroke === undefined || Math.min(width, height) <= 2 * OUTLINE) {\n const color = stroke ?? fill\n return { canvas: color === undefined ? [] : [{ type: 'rect', x: 0, y: 0, w: width, h: height, color, lineWidth: 0 }], margin: [0, 0, 0, color === undefined ? height : 0] }\n }\n const half = OUTLINE / 2\n return {\n canvas: [{ type: 'rect', x: half, y: half, w: width - OUTLINE, h: height - OUTLINE, lineWidth: OUTLINE, lineColor: stroke, ...(fill === undefined ? {} : { color: fill }) }],\n margin: [0, 0, 0, half],\n }\n}\n\n/** Columns at the widths worked out here, never pdfmake's `'*'`, which a long word widens past the page (`widths.ts`). */\nfunction columnsContent(columns: Columns, build: Build, scope: Scope): Content {\n const widths = columnWidths(columns.columns.map((slot) => slot.width), scope.width)\n return {\n columns: columns.columns.map((slot, index) => {\n const width = widths[index]!\n return { width, stack: sequence(slot.blocks, build, { ...scope, width, kept: true }) }\n }),\n columnGap: 0,\n }\n}\n\n/**\n * A section with a frame is a table of one cell: pdfmake draws its border\n * and fill around the part of it on each page, and lays out its blocks\n * inside the padding as it lays out the body, tables with their repeated\n * headers and page breaks included.\n */\nfunction sectionContent(section: Section, build: Build, scope: Scope): Content {\n const frame = frameOf(section)\n const border = section.border?.thickness ?? 0\n const color = section.border?.color ?? '#000000'\n const padding = section.padding ?? 0\n const fill = section.fill\n const layout: CustomTableLayout = {\n hLineWidth: () => border,\n vLineWidth: () => border,\n hLineColor: () => color,\n vLineColor: () => color,\n paddingLeft: () => padding,\n paddingRight: () => padding,\n paddingTop: () => padding,\n paddingBottom: () => padding,\n ...(fill === undefined ? {} : { fillColor: () => fill }),\n }\n const width = scope.width - 2 * frame\n const inner = sequence(section.blocks, build, { ...scope, width, top: scope.top + frame })\n return { table: { widths: [width], body: [[{ stack: inner }]] }, layout }\n}\n","import { RenderRefusal, type Block, type Table, type TextStyle } from '@formancy/report-runtime'\nimport { frameOf } from './content.js'\nimport { DEFAULT_SIZE, LINE_FACTOR } from './style.js'\nimport { PADDING_Y, TABLE_SIZE } from './table.js'\n\n/**\n * A height the body cannot be shorter than, worked out from the document\n * alone, so that a job too long for its page limit is refused before\n * pdfmake measures it.\n *\n * pdfmake measures every node of a document before it lays out the first\n * page, and the page limit stops only the layout: refusing 100,000 table\n * rows against five pages took 20 seconds, all of it measuring, and nothing\n * could interrupt it (measured on 2026-10-15, on an Intel i9-10900K under\n * Node 24.21). A document whose least height is more than the limit's pages\n * of body is refused here, for nothing.\n *\n * Least, never more than pdfmake lays out, so that nothing that fits is\n * refused: a line of text is one line of its size, however it wraps; a\n * table row one line of its largest text and its padding, without its rule;\n * an image, a rectangle and a rule their own height, without the space\n * around a rule, and a QR code and an EPC QR code its side; a frame its border and padding\n * once. A spacer and a page break count nothing, since a spacer at the foot\n * of a page gives up its space, and a page region is not body.\n */\nexport function leastHeight(blocks: readonly Block[]): number {\n return blocks.reduce((sum, block) => sum + least(block), 0)\n}\n\nfunction least(block: Block): number {\n switch (block.kind) {\n case 'paragraph':\n return block.runs.length === 0 ? 0 : line(block.style, DEFAULT_SIZE)\n case 'table':\n return tableHeight(block)\n case 'image':\n case 'rectangle':\n return block.height\n case 'qrCode':\n case 'epcQrCode':\n return block.size\n case 'rule':\n return block.thickness\n case 'spacer':\n case 'pageBreak':\n return 0\n case 'keepTogether':\n return leastHeight(block.blocks)\n case 'section':\n return leastHeight(block.blocks) + 2 * frameOf(block)\n case 'columns':\n return Math.max(0, ...block.columns.map((slot) => leastHeight(slot.blocks)))\n }\n}\n\nfunction line(style: TextStyle | null | undefined, size: number): number {\n return (style?.size ?? size) * LINE_FACTOR\n}\n\n/** A row: one line of the largest text in it, and the cells' padding above and below. */\nfunction rowHeight(cells: readonly string[], style: (column: number) => TextStyle | null | undefined): number {\n return Math.max(0, ...cells.map((text, column) => (text === '' ? 0 : line(style(column), TABLE_SIZE)))) + 2 * PADDING_Y\n}\n\n/** The header once, and each row. */\nfunction tableHeight(table: Table): number {\n const header = rowHeight(table.header, () => table.headerStyle)\n return table.rows.reduce((sum, row) => sum + rowHeight(row.cells, (column) => row.cellStyles?.[column] ?? row.style), header)\n}\n\n/**\n * Refuses a body whose least height needs more than `maxPages` pages of\n * `bodyHeight`, with `reserved` points more at its end: the room a QR-bill's\n * slip keeps on the last page. That room is less than a page's body, so it\n * takes at least its own height of the pages whether it ends the last page\n * of the body or starts one of its own, and the two heights together stay\n * a least height.\n */\nexport function refuseOversized(blocks: readonly Block[], bodyHeight: number, maxPages: number, reserved = 0): void {\n const height = leastHeight(blocks) + reserved\n if (height > maxPages * bodyHeight) {\n const slip = reserved > 0 ? `, the ${reserved.toFixed(2)} pt the payment part's slip keeps at its end included` : ''\n throw new RenderRefusal('too-many-pages', `the report needs more than ${maxPages} pages: its body is at least ${height.toFixed(2)} pt tall${slip}, and ${maxPages} pages hold ${(maxPages * bodyHeight).toFixed(2)} pt`)\n }\n}\n","import { checkSvg, imageHeader, MAX_ASSET_BYTES, MAX_ASSET_SIDE, RenderRefusal, sniffImage, type CheckedSvg, type ImageAsset, type PngHeader, type SvgExtent } from '@formancy/report-runtime'\nimport { inflate } from './bytes.js'\n\n/**\n * Image assets checked before pdfmake sees them. pdfmake, through PDFKit,\n * copies a PNG's compressed data and a JPEG's scan into the PDF without\n * decoding either, so bytes that only look like an image arrive in the PDF\n * as a broken one, and bytes that do not look like one at all fail with an\n * error that names no asset. Both are refused here instead, naming it, as\n * `invalid-asset`.\n *\n * What is checked: the size limits; a PNG's or a JPEG's structure, by\n * report-spec's `imageHeader`, which a builder refuses an image a person\n * adds by too (0033) -- for a PNG, every chunk's length and CRC, the header\n * and the palette, and for a JPEG, the segment structure up to the scan,\n * one frame header, read where PDFKit reads it, its size and its component\n * count, and the end marker; and here, that a PNG's image data inflates to\n * exactly the scanlines the header promises, each with a known filter,\n * which needs the platform's decompressor. A JPEG's entropy-coded scan is\n * not decoded: a corrupt scan inside an otherwise well-formed JPEG still\n * reaches the PDF.\n *\n * An SVG is checked by report-spec's `checkSvg`, which the runtime hands\n * on: its bytes must be exactly the drawing `cleanSvg` writes, so that what\n * prints is in the form that was approved, and nothing is cleaned, dropped\n * or rewritten at print (0030). Its size is its viewBox's, and with it come\n * what it costs to draw, which `check.ts` holds a render to.\n *\n * The size returned is the size the image is shown at, as `imageHeader`\n * reads it: a JPEG whose Exif orientation turns it a quarter turn is as wide\n * as its frame is tall, as PDFKit draws it. The check runs on the standard\n * library alone, so that the browser entry makes exactly the same one\n * (`bytes.ts`).\n */\n\n/**\n * The image data one render may hold, once inflated: two images of the\n * largest kind an asset may be, 4096 by 4096 pixels of 16-bit RGBA, whose\n * scanlines inflate to 134,221,824 bytes each. PDFKit decodes such a PNG to\n * embed it: one took 1.8 seconds and grew the process by 343 MB, two 3.4\n * seconds, four 6.5 seconds (measured on 2026-10-15, on an Intel i9-10900K\n * under Node 24.21). A JPEG is embedded as it is, and counts its bytes.\n */\nexport const MAX_IMAGE_DATA = 2 * MAX_ASSET_SIDE * (1 + MAX_ASSET_SIDE * 8)\n\n/** A PNG's or a JPEG's size in pixels, as it is shown, how many bytes of image data it holds once a PNG's are inflated, and whether PDFKit draws it in DeviceCMYK. */\nexport interface Raster {\n readonly kind: 'raster'\n readonly width: number\n readonly height: number\n readonly data: number\n /**\n * A JPEG whose frame header says four components, which PDFKit draws in\n * DeviceCMYK (pdfkit.js 3808-3812), as it draws one of three in\n * DeviceRGB and one of one in DeviceGray, and no other count, which the\n * check refuses; never a PNG, which PDFKit draws in RGB or grey. An\n * e-invoice's PDF/A cannot hold one.\n */\n readonly cmyk: boolean\n}\n\n/**\n * An SVG in the form `cleanSvg` writes: its viewBox, whose proportions\n * `contain` and `cover` keep; the drawing, as the ASCII text it is, which\n * every pass hands pdfmake unchanged; what it costs, as `checkSvg` counts\n * it and `drawingUnits` weights it; and how far the converter's numbers for\n * it reach, which an e-invoice holds it to (`svg-pdfa.ts`).\n */\nexport interface Vector {\n readonly kind: 'vector'\n /** The viewBox's origin. */\n readonly x: number\n readonly y: number\n /** The viewBox's size. */\n readonly width: number\n readonly height: number\n readonly svg: string\n /** What a reader paints for it, in `MAX_SVG_SEGMENTS`' weighted segments. */\n readonly segments: number\n /** The page-sized transparency groups it makes, in `MAX_SVG_GROUPS`' units. */\n readonly groups: number\n /** What drawing it once costs the renderer, in `MAX_SVG_DRAWING`'s units. */\n readonly units: number\n /** How far the numbers the converter writes for it reach wherever it is placed, and how deep it nests the graphics state, as `checkSvg` measures them. */\n readonly extent: SvgExtent\n}\n\n/** An image asset as the checks read it. */\nexport type CheckedImage = Raster | Vector\n\n/** The asset as it is drawn, once its bytes pass; refused as `invalid-asset`, naming it and why, when they do not. */\nexport async function checkImageAsset(asset: ImageAsset): Promise<CheckedImage> {\n const read = await readAsset(asset)\n if (typeof read === 'string') throw new RenderRefusal('invalid-asset', `the image asset ${asset.id} ${read}`, asset.id)\n return read\n}\n\n/** The asset as it is drawn, or what is wrong with it. */\nasync function readAsset(asset: ImageAsset): Promise<CheckedImage | string> {\n const { bytes } = asset\n if (!(bytes instanceof Uint8Array)) return 'has no bytes'\n if (bytes.length > MAX_ASSET_BYTES) return `is ${bytes.length} bytes; the limit is ${MAX_ASSET_BYTES} (20 MB)`\n const sniffed = sniffImage(bytes)\n const isPng = sniffed === 'image/png'\n const isJpeg = sniffed === 'image/jpeg'\n // Read as an SVG only to say what bytes declared otherwise are; cleanSvg refuses bytes past a mebibyte unread.\n const actually = (): string => (isPng ? ': it is a PNG' : isJpeg ? ': it is a JPEG' : checkSvg(bytes).ok ? ': it is an SVG' : '')\n if (asset.mediaType === 'image/png') return isPng ? readRaster(bytes) : `is declared a PNG and is not one${actually()}`\n if (asset.mediaType === 'image/jpeg') return isJpeg ? readRaster(bytes) : `is declared a JPEG and is not one${actually()}`\n if (asset.mediaType === 'image/svg+xml') return isPng || isJpeg ? `is declared an SVG and is not one${actually()}` : readSvg(bytes)\n return `is of a media type the renderer does not draw (${String(asset.mediaType)})`\n}\n\n/**\n * The drawing one render may cost the renderer, in units of what\n * svg-to-pdfkit does each time it draws an SVG: once for each image of it in\n * the body, and on every page for one in a page region, which pdfmake lays\n * out and draws anew on each page (0030). A move, a line or a close is one\n * unit; a curve, an element, a gradient stop and a page-sized transparency\n * group are weighted by what each costs beside a line, rounded up; and every\n * `DRAWING_WEIGHT.bytes` bytes of the drawing are one unit more, since\n * pdfmake reads the whole text again with xmldoc in every pass and the\n * converter on every draw, whatever it draws. At the budget the renderer\n * spends about 2.9 seconds drawing SVGs, about what `MAX_IMAGE_DATA`'s two\n * largest PNGs cost it to decode.\n *\n * Measured on 2026-10-18 on an Intel i9-10900K, shared with other work,\n * under Node 24.21.0 with pdfmake 0.3.11: whole renders, every pass, of an\n * SVG 15 mm square in the page header of a report of so many pages, against\n * the same report with an SVG of one rectangle in its place, medians of five\n * (three at 400 pages). A line costs 2.9 microseconds a page (30,000 lines on\n * 32 pages, 2.79 s more); a cubic 6.8, 2.3 lines (9,999 on 32 pages, 2.18 s);\n * an element 33 beyond its segments, 11.4 lines (6,001 rectangles on 8 pages,\n * 2.29 s); a gradient stop 17, 5.9 lines (a 64-stop gradient on 400\n * rectangles on 7 pages, 3.2 s); a transparency group 0.10 ms beyond its\n * element and segments, 34 to 36 lines (four clipped shapes, and two shapes\n * painted with a translucent gradient, on 400 pages, 0.32 s and 0.25 s).\n * Those lines were short, seven bytes each. On 16 pages a line of 18.7\n * bytes cost 4.4 microseconds a page and one of 37 bytes 5.2, against 3.1\n * for a short one; and 10,506 arcs that draw nothing, a mebibyte of\n * seventeen-digit numbers, cost 109 ms a page on 8 pages, what 35,000 short\n * lines do, though each is counted as a line. With a unit more for every 32\n * bytes, each of these drawings costs from 13 % less than its units say\n * (900 rectangles of seventeen-digit numbers and dash arrays) to 27 % more\n * (the 37-byte lines).\n */\nexport const MAX_SVG_DRAWING = 1_000_000\n\n/** What each thing svg-to-pdfkit draws costs the renderer, in lines' worth of its time, rounded up, and how many bytes of the drawing are one more unit (`MAX_SVG_DRAWING`). */\nconst DRAWING_WEIGHT = { curve: 3, element: 12, stop: 6, group: 40, bytes: 32 } as const\n\n/** What drawing an SVG once costs the renderer, in `MAX_SVG_DRAWING`'s units. */\nexport function drawingUnits(checked: Pick<CheckedSvg, 'bytes' | 'drawn' | 'groups'>): number {\n const { lines, curves, elements, stops } = checked.drawn\n const commands = lines + DRAWING_WEIGHT.curve * curves + DRAWING_WEIGHT.element * elements + DRAWING_WEIGHT.stop * stops + DRAWING_WEIGHT.group * checked.groups\n return commands + Math.ceil(checked.bytes.length / DRAWING_WEIGHT.bytes)\n}\n\n/** An SVG's drawing, when its bytes are exactly what `cleanSvg` writes; report-spec's refusal, which repeats no value, when they are not. */\nfunction readSvg(bytes: Uint8Array): Vector | string {\n const checked = checkSvg(bytes)\n if (!checked.ok) return `is not an SVG the renderer draws: ${checked.message}`\n const { viewBox, segments, groups, extent } = checked\n return { kind: 'vector', x: viewBox.x, y: viewBox.y, width: viewBox.width, height: viewBox.height, svg: ascii(checked.bytes), segments, groups, units: drawingUnits(checked), extent }\n}\n\n/** ASCII bytes as text, a chunk at a time: a mebibyte is more than one call takes as arguments. */\nfunction ascii(bytes: Uint8Array): string {\n let text = ''\n for (let start = 0; start < bytes.length; start += 0x2000) text += String.fromCharCode(...bytes.subarray(start, start + 0x2000))\n return text\n}\n\n/**\n * A PNG or a JPEG as it is drawn, once its structure, read by\n * `imageHeader`, and a PNG's image data pass. A JPEG is embedded as it is,\n * and counts its bytes; a PNG counts its scanlines, which PDFKit decodes.\n */\nasync function readRaster(bytes: Uint8Array): Promise<Raster | string> {\n const header = imageHeader(bytes)\n if (!header.ok) return header.message\n if (header.mediaType === 'image/jpeg') return { kind: 'raster', width: header.width, height: header.height, data: bytes.length, cmyk: header.components === 4 }\n return (await scanlineProblem(header)) ?? { kind: 'raster', width: header.width, height: header.height, data: inflatedLength(header), cmyk: false }\n}\n\n/** Adam7's seven passes: the first column and row of each, and the steps between them. */\nconst ADAM7 = [\n [0, 0, 8, 8],\n [4, 0, 8, 8],\n [0, 4, 4, 8],\n [2, 0, 4, 4],\n [0, 2, 2, 4],\n [1, 0, 2, 2],\n [0, 1, 1, 2],\n] as const\n\n/** The scanlines of each pass of the image: the bytes of one, its filter byte included, and how many there are. */\nfunction scanlines(header: PngHeader): { readonly bytes: number; readonly count: number }[] {\n const passes = header.interlaced ? ADAM7.map(([x, y, dx, dy]) => [Math.ceil((header.width - x) / dx), Math.ceil((header.height - y) / dy)] as const) : [[header.width, header.height] as const]\n return passes.filter(([width, height]) => width > 0 && height > 0).map(([width, height]) => ({ bytes: 1 + Math.ceil((width * header.bitsPerPixel) / 8), count: height }))\n}\n\n/** The bytes the image data inflates to, as the header promises. */\nfunction inflatedLength(header: PngHeader): number {\n return scanlines(header).reduce((total, row) => total + row.bytes * row.count, 0)\n}\n\n/**\n * Whether the image data inflates to exactly the scanlines the header\n * promises, each starting with a filter type PNG defines. Read as it\n * inflates: the filter bytes are where the scanlines say, so nothing of the\n * image is kept.\n */\nasync function scanlineProblem(header: PngHeader): Promise<string | undefined> {\n const rows = scanlines(header)\n const expected = inflatedLength(header)\n const filters = filterOffsets(rows)\n let next = filters.next()\n let unknown: number | undefined\n const inflated = await inflate(header.data, expected, (chunk, offset) => {\n while (unknown === undefined && !next.done && next.value < offset + chunk.length) {\n const filter = chunk[next.value - offset]!\n if (filter > 4) unknown = filter\n next = filters.next()\n }\n })\n if (inflated.kind === 'too-long') return `has more image data than the ${expected} bytes its header promises`\n if (inflated.kind === 'invalid') return 'has image data that does not inflate'\n if (inflated.length < expected) return `has image data of ${inflated.length} bytes where its header promises ${expected}`\n return unknown === undefined ? undefined : `has a scanline with an unknown filter type (${unknown})`\n}\n\n/** Where each scanline's filter byte is in the inflated data, in order. */\nfunction* filterOffsets(rows: readonly { readonly bytes: number; readonly count: number }[]): Generator<number, void> {\n let offset = 0\n for (const row of rows) {\n for (let index = 0; index < row.count; index++, offset += row.bytes) yield offset\n }\n}\n","import { FACTUR_X, FACTUR_X_PROFILES, RenderRefusal } from '@formancy/report-runtime'\nimport type { EInvoiceFile } from '@formancy/report-runtime'\n\n/**\n * The e-invoice a document carries (0027): the XML the runtime wrote from\n * the values the page prints, and what to embed it as -- the file's name,\n * its relationship to the PDF and the conformance level the PDF's XMP\n * states, report-spec's `FACTUR_X` and `FACTUR_X_PROFILES` handed on by the\n * runtime. The renderer decides none of them, and writes nothing of the XML:\n * it draws the document as a PDF/A-3b that embeds the file (`pdfa.ts`,\n * 0031).\n *\n * **What it does not know it refuses**, before pdfmake sees the document:\n * a file it is not handed as one, XML that is not text or that holds a\n * lone surrogate, which UTF-8 cannot encode as it stands, and a name, a\n * conformance level or a relationship that is not report-spec's. A file\n * from a runtime that names it otherwise would be embedded as something\n * its reader does not look for. A refusal names what is unknown, never a\n * value: the XML holds people's names, accounts and VAT identifiers.\n */\n\n/** `file`, once the renderer knows it: report-spec's name, one of its profiles' conformance levels, and that profile's relationship. */\nexport function checkEInvoice(file: unknown): EInvoiceFile {\n const refusal = (message: string): RenderRefusal => new RenderRefusal('unsupported', message, 'eInvoice')\n if (typeof file !== 'object' || file === null) throw refusal('the e-invoice is not a file the renderer knows')\n const { xml, fileName, relationship, conformanceLevel } = file as Record<string, unknown>\n if (typeof xml !== 'string') throw refusal(\"the e-invoice's XML is not text\")\n // An encoder writes U+FFFD for a lone surrogate without a word: the PDF would embed other bytes than the runtime wrote.\n if (LONE_SURROGATE.test(xml)) throw refusal(\"the e-invoice's XML holds a lone surrogate, which UTF-8 cannot encode as it stands\")\n if (fileName !== FACTUR_X.fileName) throw refusal('the e-invoice is embedded under a file name the renderer does not know')\n // Each profile's own terms, by value: a lookup by the level's name would find 'constructor' on every object.\n const profile = Object.values(FACTUR_X_PROFILES).find((each) => each.conformanceLevel === conformanceLevel)\n if (profile === undefined) throw refusal('the e-invoice states a conformance level the renderer does not know')\n if (relationship !== profile.relationship) throw refusal('the e-invoice is related to the PDF otherwise than a file of its conformance level is')\n return { xml, fileName, relationship: profile.relationship, conformanceLevel: profile.conformanceLevel }\n}\n\nconst LONE_SURROGATE = /[\\uD800-\\uDBFF](?![\\uDC00-\\uDFFF])|(?<![\\uD800-\\uDBFF])[\\uDC00-\\uDFFF]/\n\n/**\n * Refuses an e-invoice's title that PDFKit cannot write into the PDF/A's\n * XMP: it puts the title into `dc:title` as it stands, unescaped (pdfkit.js\n * 6025-6032; `pdfmake.test.ts` holds it), so an ampersand or an angle\n * bracket, or a character XML 1.0 cannot write, leaves the XMP not\n * well-formed -- a PDF that says it is a PDF/A and is not one (veraPDF\n * 6.6.2.1-4). report-spec refuses such a title in an e-invoice report, so\n * a report the runtime resolved never reaches this; a document made\n * otherwise is refused here, naming the title and not quoting it. The\n * information dictionary would hold it as written, and in a report that is\n * no e-invoice it reaches no XMP and is drawn.\n */\nexport function checkEInvoiceTitle(title: string): void {\n if (/[&<>]/.test(title) || [...title].some((character) => !xmlCharacter(character.codePointAt(0)!))) {\n throw new RenderRefusal('unsupported', \"an e-invoice's title is written into its PDF/A's XMP as it stands, where it may hold no &, < or > and no character XML 1.0 cannot write: this one does\", 'info.title')\n }\n}\n\n/** XML 1.0's Char: tab, line feed and carriage return, and every code point from U+0020 but the surrogates, U+FFFE and U+FFFF. A lone surrogate is read as its own code point, and is none. */\nfunction xmlCharacter(code: number): boolean {\n return code === 0x9 || code === 0xa || code === 0xd || (code >= 0x20 && code <= 0xd7ff) || (code >= 0xe000 && code <= 0xfffd) || (code >= 0x10000 && code <= 0x10ffff)\n}\n","import { MAX_SVG_COORDINATE, MAX_SVG_DEPTH, RenderRefusal, type Image } from '@formancy/report-runtime'\nimport type { Vector } from './assets.js'\n\n/**\n * An SVG in an e-invoice (0030, beside 0031): what the PDF/A-3 an e-invoice\n * is drawn as holds an image of one to, checked before pdfmake runs. PDF/A-2\n * and -3 make ISO 32000-1's implementation limits requirements (ISO\n * 19005-2, 6.1.13): no integer past 2,147,483,647 in magnitude, and the\n * graphics state nested no deeper than 28. PDFKit writes a whole number\n * with no point, as an integer (pdfkit.js 173-178), and svg-to-pdfkit\n * computes some of its numbers through the inverse of the drawing's matrix\n * and the image's box: a drawing whose clip and transparency are shrunk a\n * millionfold, drawn a point square, wrote a group's /BBox of\n * 78,520,000,000 into an e-invoice that said it was a PDF/A-3b, which\n * veraPDF 1.30.3 failed on its rule 6.1.13-1 (measured 18 October 2026).\n *\n * So the check bounds, from above, every number the converter writes for\n * an image -- from report-spec's extent of the drawing (`svg-extent.ts`),\n * the image's box and fit, and the page, the image standing anywhere on it,\n * since where pdfmake puts it is not known before it runs -- and refuses an\n * image whose bound passes `SVG_INTEGER_BOUND`, or whose drawing nests\n * deeper than `PDF_A_NESTING`, as `unsupported`, naming it and saying what\n * to do. pdfmake draws an image in the page's own stream, whether it stands\n * in the body, a page region, a section, columns or a keep-together block,\n * and nests nothing around it (measured that day with veraPDF), so the\n * drawing's nesting is the stream's. A report that is no e-invoice is no\n * PDF/A, and draws such an image as it always did.\n */\n\n/** The largest integer, in magnitude, a PDF/A-2 or -3 may hold (ISO 19005-2, 6.1.13; veraPDF's rule 6.1.13-1). A real may reach 3.403 × 10^38, past the 10^21 at which PDFKit throws. */\nexport const PDF_A_INTEGER = 2_147_483_647\n\n/** The deepest a PDF/A-2 or -3 may nest the graphics state, q inside q (ISO 19005-2, 6.1.13; veraPDF's rule 6.1.13-8). */\nexport const PDF_A_NESTING = 28\n\n/**\n * What floating point may put between the bound and what the converter\n * writes, relative, derived and not measured. The groups' term is computed\n * from the matrix the cleaner composed, and the converter composes the same\n * matrices in its own order, the page's flip and the fit's scale first, and\n * inverts the product to find a group's box. Below the svg at most\n * `MAX_SVG_DEPTH` - 1 elements bring a matrix each, and the fit comes\n * before them, so the product is at most `MAX_SVG_DEPTH` products (the\n * flip is exact); an entry of a product's linear part is two products\n * summed, so each rounds it at most twice, by 2^-53 of an entry that no\n * cancellation shrank: 2 × `MAX_SVG_DEPTH` units. Inverting magnifies that\n * by the matrix's condition number, at most 4 × `MAX_SVG_COORDINATE`² for\n * a matrix whose entries and whose inverse's are each at most\n * `MAX_SVG_COORDINATE`, as the cleaner's `compose` holds them; and twice\n * that, for the two computations: 2 × 4 × 10^12 × 2 × 32 × 2^-53, 5.7 %.\n * The other terms invert nothing, and lose less. Not bounded by it:\n * matrices built to cancel one another term by term, whose products\n * floating point gets wrong in both (0030).\n */\nexport const SVG_INTEGER_MARGIN = 2 * (4 * MAX_SVG_COORDINATE ** 2) * (2 * MAX_SVG_DEPTH) * 2 ** -53\n\n/** The largest an SVG's numbers may be bounded at in an e-invoice: `PDF_A_INTEGER` less `SVG_INTEGER_MARGIN`. */\nexport const SVG_INTEGER_BOUND = Math.floor(PDF_A_INTEGER * (1 - SVG_INTEGER_MARGIN))\n\n/**\n * What the converter writes of the drawing besides its outlines' points,\n * which the extent's `own` holds: each element's own matrix, a stroke's\n * width and dashes, a gradient's ends, each a number the cleaner holds to\n * `MAX_SVG_COORDINATE`; and a radial gradient's focus, which the converter\n * moves inside its circle (`source.js:1884-1888`), within twice it.\n */\nconst WRITTEN = 2 * MAX_SVG_COORDINATE\n\n/** The paper, in points. */\nexport interface Paper {\n readonly paperWidth: number\n readonly paperHeight: number\n}\n\n/**\n * The largest magnitude, from above, of a number svg-to-pdfkit writes for\n * `vector` drawn as `image` anywhere on `paper`. The converter fits the\n * viewBox to the box with a scale `s` and the offset `d` that centres it\n * (`parseAspectRatio`, source.js:624-637); PDFKit's page matrix flips the\n * page, and the image's corner is somewhere on it. So a page corner, back\n * through the page and the image's corner, is at most the page's longer\n * side away from it in each coordinate, and back through the fit at most\n * that and `d`, over `s`, from the viewBox's origin. Then:\n *\n * - the fit itself is written as `s`, and `d` less `s` times the origin;\n * - a group's /BBox is that through the inverse of its matrix: at most\n * where the inverse takes the origin, and its row sum times the rest;\n * - a gradient's /Matrix outside every group is the page's and the fit's\n * times its own: `s` times its linear part, and its translation from the\n * origin `s` times as far from the image's corner, `d` and the page's\n * side further;\n * - a gradient's inside a group, and a clip's box, are the drawing's own,\n * wherever it stands: `local`;\n * - the outlines' points are written in their own coordinates: `own`.\n */\nexport function svgReach(vector: Vector, image: Pick<Image, 'width' | 'height' | 'fit'>, paper: Paper): number {\n return Math.max(placed(vector, image, paper), outlines(vector))\n}\n\n/** The numbers the drawing itself writes, wherever it is placed: its outlines' points, and the rest at `WRITTEN`. */\nfunction outlines({ extent }: Vector): number {\n return Math.max(WRITTEN, extent.own)\n}\n\n/** The numbers that grow with where the drawing is placed and how large: `svgReach`'s fit, groups, gradients and what is written in a group's own coordinates. */\nfunction placed(vector: Vector, image: Pick<Image, 'width' | 'height' | 'fit'>, paper: Paper): number {\n const { extent } = vector\n const across = { x: image.width / vector.width, y: image.height / vector.height }\n const s = image.fit === 'cover' ? Math.max(across.x, across.y) : Math.min(across.x, across.y)\n const dx = (image.width - vector.width * s) / 2\n const dy = (image.height - vector.height * s) / 2\n const side = Math.max(paper.paperWidth, paper.paperHeight)\n const d = Math.max(Math.abs(dx), Math.abs(dy))\n const fit = Math.max(s, Math.abs(dx - s * vector.x), Math.abs(dy - s * vector.y))\n const groups = extent.groups.inverse === 0 ? 0 : extent.groups.origin + (extent.groups.inverse * (side + d)) / s\n const patterns = Math.max(s * extent.patterns.linear, extent.patterns.linear === 0 ? 0 : side + s * extent.patterns.offset + d)\n return Math.max(fit, groups, patterns, extent.local)\n}\n\n/** Refuses `image`, an SVG of `vector`, where an e-invoice's PDF/A-3 cannot hold what the converter writes for it on `paper`. */\nexport function checkSvgInEInvoice(vector: Vector, image: Image, paper: Paper): void {\n const { id } = image.asset\n if (vector.extent.nesting > PDF_A_NESTING) {\n throw new RenderRefusal('unsupported', `the image ${id} is an SVG that pdfmake's converter draws ${vector.extent.nesting} graphics states deep, and an e-invoice is drawn as a PDF/A-3, which nests them ${PDF_A_NESTING} deep at most: flatten the groups it nests`, id)\n }\n const own = outlines(vector)\n const reach = Math.max(own, placed(vector, image, paper))\n if (reach > SVG_INTEGER_BOUND) {\n const advice = own === reach ? 'save it again from the drawing program, its arcs drawn with radii that reach their ends and its smooth curves with control points of their own' : 'draw it larger, or flatten the transforms under its clips, its transparency and its gradients'\n throw new RenderRefusal(\n 'unsupported',\n `the image ${id} is an SVG whose numbers, drawn ${image.width} × ${image.height} pt, could reach ${Math.ceil(reach)}, and an e-invoice is drawn as a PDF/A-3, which holds an integer to ${PDF_A_INTEGER}, ${SVG_INTEGER_BOUND} with the renderer's margin for rounding: ${advice}`,\n id,\n )\n }\n}\n","import { MAX_SVG_GROUPS, MAX_SVG_SEGMENTS, RenderRefusal, type Block, type Columns, type EInvoiceFile, type EpcQrCode, type Image, type ImageAsset, type KeepTogether, type QrCode, type Rectangle, type ResolvedDocument, type Section, type Table, type TextStyle } from '@formancy/report-runtime'\nimport { checkImageAsset, MAX_IMAGE_DATA, MAX_SVG_DRAWING, type CheckedImage, type Vector } from './assets.js'\nimport { frameOf, RULE_GAP } from './content.js'\nimport { epcSymbol } from './epc.js'\nimport { checkEInvoice, checkEInvoiceTitle } from './e-invoice.js'\nimport { codePoint, faceOf, missingGlyph, type Glyphs } from './glyphs.js'\nimport { qrSymbol, type QrSymbol } from './qr.js'\nimport { COLOR, FONTS, LINE_FACTOR } from './style.js'\nimport { checkSvgInEInvoice } from './svg-pdfa.js'\nimport { KIND_BOLD, PADDING_X, PADDING_Y } from './table.js'\nimport { fillWidth, fixedWidth } from './widths.js'\n\n/**\n * What the renderer refuses before pdfmake sees the document: what pdfmake\n * cannot print, what is malformed, what stands where it cannot be laid out,\n * what is wider than where it stands, text with a character the face it\n * prints in has no glyph for (`glyphs.ts`), an e-invoice the renderer does\n * not know (`e-invoice.ts`), and what an e-invoice's PDF/A-3 cannot hold:\n * a title PDFKit cannot write into its XMP, a CMYK JPEG beside its sRGB\n * output intent, and an SVG whose numbers could pass its integers' range\n * or whose nesting its graphics state's (`svg-pdfa.ts`). Every refusal names where the problem is --\n * `body[2].blocks[0]`, a table's id, an asset's id -- and none of them is a\n * partial render: a document that is refused has drawn nothing.\n *\n * The walk also collects what can only be judged once the page regions are\n * measured -- whatever is too tall for any page's body -- and what the body\n * pass measures: its tables and keep-together blocks, each at the width it\n * stands at. It encodes every QR code and EPC QR code, once, and what it\n * encodes is what every pass draws (`qr.ts`, `epc.ts`). It reads every image\n * asset once (`assets.ts`) and holds the render to what its images cost\n * together (`checkImages`).\n */\n\n/** The paper and its printable area, in points. */\nexport interface Page {\n readonly paperWidth: number\n readonly paperHeight: number\n readonly margins: ResolvedDocument['page']['margins']\n readonly width: number\n readonly height: number\n}\n\n/** Portrait sizes in points, as PDF engines write them: ISO A4 is 210 by 297 millimetres, US Letter 8.5 by 11 inches. */\nconst PAPER: Readonly<Record<ResolvedDocument['page']['size'], { readonly width: number; readonly height: number }>> = {\n A4: { width: 595.28, height: 841.89 },\n Letter: { width: 612, height: 792 },\n}\n\n/**\n * How deep blocks may nest. report-spec allows four containers; the\n * renderer recurses through whatever it is given, so a hostile document of\n * ten thousand nested sections would end in a stack overflow rather than a\n * refusal. This bounds the recursion, not a layout.\n */\nexport const MAX_DEPTH = 16\n\n/** A block that is drawn at a fixed height, which no page may be too short for. */\nexport interface Tall {\n readonly height: number\n /** The vertical space framed sections around it take from a page: their borders and padding, above and below. */\n readonly inset: number\n readonly what: string\n readonly subject: string\n}\n\n/** A table or keep-together block of the body that the body pass measures, at the width it stands at. */\nexport interface Measured {\n readonly block: Table | KeepTogether\n readonly at: string\n readonly width: number\n readonly inset: number\n}\n\nexport interface Checked {\n readonly page: Page\n readonly creationDate: Date\n /** The e-invoice the document carries, known to the renderer: drawn as a PDF/A-3b that embeds it (`pdfa.ts`). */\n readonly eInvoice: EInvoiceFile | undefined\n /** Every image asset as the checks read it: a PNG's or a JPEG's size in pixels, as it is shown, or an SVG's drawing. */\n readonly assets: ReadonlyMap<ImageAsset, CheckedImage>\n /** Every QR code's and EPC QR code's symbol, encoded once. */\n readonly codes: ReadonlyMap<QrCode | EpcQrCode, QrSymbol>\n /** Whether an EPC QR code is captioned: its caption prints in Liberation Sans, which the engine loads for it. */\n readonly captioned: boolean\n /** In the body: judged against its height once the regions are measured. */\n readonly tall: readonly Tall[]\n /** Where each paragraph stands, for a refusal about its words to name. */\n readonly paths: ReadonlyMap<Block, string>\n readonly measured: readonly Measured[]\n}\n\n/** Where a block stands. */\ninterface Place {\n readonly region: boolean\n /** Inside a keep-together block. */\n readonly kept: boolean\n /** Inside a columns block. */\n readonly column: boolean\n readonly width: number\n readonly inset: number\n readonly depth: number\n}\n\ninterface Walk {\n readonly glyphs: Glyphs\n readonly paths: Map<Block, string>\n readonly images: { readonly image: Image; readonly region: boolean }[]\n readonly codes: Map<QrCode | EpcQrCode, QrSymbol>\n captioned: boolean\n readonly tall: Tall[]\n readonly measured: Measured[]\n}\n\nexport async function checkDocument(document: ResolvedDocument, glyphs: Glyphs, maxPages: number): Promise<Checked> {\n const creationDate = new Date(document.info.creationDate)\n if (Number.isNaN(creationDate.getTime())) throw new RenderRefusal('unsupported', `the creation date '${document.info.creationDate}' is not a date`, 'info.creationDate')\n // The title goes into the PDF's metadata, never onto a page, so it is held to being text and not to the font.\n if (typeof document.info.title !== 'string') throw new RenderRefusal('unsupported', 'the title is not text', 'info.title')\n // An e-invoice it does not know is refused, never embedded as something else or drawn as a plain PDF (`e-invoice.ts`).\n const eInvoice = document.eInvoice === undefined ? undefined : checkEInvoice(document.eInvoice)\n if (eInvoice !== undefined) checkEInvoiceTitle(document.info.title)\n const page = pageOf(document.page)\n const walk: Walk = { glyphs, paths: new Map(), images: [], codes: new Map(), captioned: false, tall: [], measured: [] }\n const top: Omit<Place, 'region'> = { kept: false, column: false, width: page.width, inset: 0, depth: 0 }\n checkBlocks(document.pageHeader, 'pageHeader', { ...top, region: true }, walk)\n checkBlocks(document.pageFooter, 'pageFooter', { ...top, region: true }, walk)\n checkBlocks(document.body, 'body', { ...top, region: false }, walk)\n const assets = await checkImages(walk.images, maxPages, eInvoice !== undefined, page)\n return { page, creationDate, eInvoice, assets, codes: walk.codes, captioned: walk.captioned, tall: walk.tall, paths: walk.paths, measured: walk.measured }\n}\n\n/**\n * Every image's asset, read once however many images draw it, and what the\n * images cost together, each refusal naming the asset whose image crossed\n * it:\n *\n * - the image data the PNGs and JPEGs hold, once for each asset, against\n * `MAX_IMAGE_DATA`, as `content-too-large`: each is embedded once;\n * - in an e-invoice, a JPEG PDFKit draws in DeviceCMYK, refused as\n * `unsupported`: the PDF/A-3 it is drawn as has an sRGB output intent,\n * beside which no image may be CMYK (veraPDF 6.2.4.3-3), and a second\n * intent would have to share its profile (6.2.3-2);\n * - in an e-invoice, an image of an SVG whose numbers, at its box and on\n * its page, could pass the integers a PDF/A-3 holds, or whose drawing\n * nests the graphics state deeper than one may, refused as\n * `unsupported` (`svg-pdfa.ts`): each image, since its box decides;\n * - what drawing the SVGs costs the renderer, for every image of one,\n * against `MAX_SVG_DRAWING`, as `content-too-large`: the converter draws an SVG wherever it\n * stands, and one in a page region on every page, counted as `maxPages`,\n * the pages the report may have, which is known before the render;\n * - what the SVGs cost a reader to paint, against `MAX_SVG_SEGMENTS` and\n * `MAX_SVG_GROUPS`, as `content-too-large`, the bounds of one drawing, measured as what one page\n * may cost: every SVG image of the body counted as though all of them fell\n * on one page, beside those of the page regions, which every page draws.\n * Which page each lands on is known only once pdfmake has laid the body\n * out.\n */\nasync function checkImages(images: Walk['images'], maxPages: number, eInvoice: boolean, page: Page): Promise<ReadonlyMap<ImageAsset, CheckedImage>> {\n const assets = new Map<ImageAsset, CheckedImage>()\n const total = { data: 0, units: 0, segments: 0, groups: 0 }\n for (const { image, region } of images) {\n const { id } = image.asset\n let read = assets.get(image.asset)\n if (read === undefined) {\n read = await checkImageAsset(image.asset)\n if (eInvoice && read.kind === 'raster' && read.cmyk) {\n throw new RenderRefusal('unsupported', `the image ${id} is a CMYK JPEG, which an e-invoice cannot hold: it is drawn as a PDF/A-3 whose output intent is sRGB, beside which no image may be CMYK`, id)\n }\n assets.set(image.asset, read)\n total.data += read.kind === 'raster' ? read.data : 0\n if (total.data > MAX_IMAGE_DATA) throw new RenderRefusal('content-too-large', `the images up to ${id} hold ${total.data} bytes of image data; a render may hold ${MAX_IMAGE_DATA}`, id)\n }\n if (eInvoice && read.kind === 'vector') checkSvgInEInvoice(read, image, page)\n if (read.kind === 'vector') addVector(total, read, region ? maxPages : 1, id)\n }\n return assets\n}\n\n/** One more SVG image, drawn `times` times, added to what the render's SVG images cost; refused past a bound. */\nfunction addVector(total: { units: number; segments: number; groups: number }, vector: Vector, times: number, id: string): void {\n total.units += vector.units * times\n total.segments += vector.segments\n total.groups += vector.groups\n if (total.units > MAX_SVG_DRAWING) {\n throw new RenderRefusal('content-too-large', `the SVG images up to ${id} cost ${total.units} units to draw, each in a page region counted on every page the report may have; a render may draw ${MAX_SVG_DRAWING}`, id)\n }\n const onePage = 'on one page, every SVG image of the body counted as though it fell there beside those of the page regions'\n if (total.segments > MAX_SVG_SEGMENTS) throw new RenderRefusal('content-too-large', `the SVG images up to ${id} would cost a reader ${total.segments} weighted segments to paint ${onePage}; a page may cost ${MAX_SVG_SEGMENTS}`, id)\n if (total.groups > MAX_SVG_GROUPS) throw new RenderRefusal('content-too-large', `the SVG images up to ${id} would make ${total.groups} units of page-sized transparency groups ${onePage}; a page may make ${MAX_SVG_GROUPS}`, id)\n}\n\nfunction pageOf(setup: ResolvedDocument['page']): Page {\n // Own sizes only: 'constructor' or 'toString' would find Object's, and crash pdfmake.\n const paper = Object.hasOwn(PAPER, setup.size) ? PAPER[setup.size] : undefined\n if (paper === undefined) throw new RenderRefusal('unsupported', `the page size '${String(setup.size)}' is not one the renderer knows`, 'page.size')\n if (setup.orientation !== 'portrait' && setup.orientation !== 'landscape') throw new RenderRefusal('unsupported', `the orientation '${String(setup.orientation)}' is not one the renderer knows`, 'page.orientation')\n const [paperWidth, paperHeight] = setup.orientation === 'portrait' ? [paper.width, paper.height] : [paper.height, paper.width]\n const { margins } = setup\n if (![margins.top, margins.right, margins.bottom, margins.left].every((margin) => Number.isFinite(margin) && margin >= 0)) {\n throw new RenderRefusal('unsupported', 'a page margin is negative or not a number', 'page.margins')\n }\n const width = paperWidth - margins.left - margins.right\n const height = paperHeight - margins.top - margins.bottom\n if (width <= 0 || height <= 0) throw new RenderRefusal('content-too-large', `the margins leave no printable area (${width.toFixed(2)} × ${height.toFixed(2)} pt)`, 'page.margins')\n return { paperWidth, paperHeight, margins, width, height }\n}\n\nfunction checkBlocks(blocks: readonly Block[], path: string, place: Place, walk: Walk): void {\n if (place.depth > MAX_DEPTH) throw new RenderRefusal('unsupported', `${path} is nested more than ${MAX_DEPTH} blocks deep`, path)\n blocks.forEach((block, index) => checkBlock(block, `${path}[${index}]`, place, walk))\n}\n\nfunction checkBlock(block: Block, at: string, place: Place, walk: Walk): void {\n switch (block.kind) {\n case 'paragraph':\n walk.paths.set(block, at)\n if (!place.region && block.runs.some((run) => 'field' in run)) {\n throw new RenderRefusal('unsupported', `${at} prints a page field; pdfmake knows the page number only in the page header and footer`, at)\n }\n checkStyle(block.style, at)\n if (block.runs.some((run) => !('text' in run) && run.field !== 'pageNumber' && run.field !== 'pageCount')) throw new RenderRefusal('unsupported', `${at} prints a field the renderer does not know`, at)\n for (const run of block.runs) {\n if ('text' in run) checkText(run.text, faceOf(run.bold ?? block.style?.bold ?? false, block.style?.italic ?? false), walk, at)\n }\n tall(walk, place, (block.style?.size ?? 0) * LINE_FACTOR, `a line of ${at}`, at)\n return\n case 'table':\n if (place.column) throw new RenderRefusal('unsupported', `table ${block.id} stands inside a columns block; a table is part of the flow`, block.id)\n checkTable(block, place.width)\n checkTableText(block, walk)\n tall(walk, place, tallestCellLine(block), `a line of table ${block.id}`, block.id)\n if (!place.region && !place.kept) walk.measured.push({ block, at, width: place.width, inset: place.inset })\n return\n case 'image':\n checkImage(block, place, walk)\n walk.images.push({ image: block, region: place.region })\n return\n case 'qrCode':\n checkQrCode(block, place, walk)\n return\n case 'epcQrCode':\n checkEpcQrCode(block, place, walk)\n return\n case 'rule':\n if (!(block.thickness > 0 && Number.isFinite(block.thickness))) throw new RenderRefusal('unsupported', `${at} is a rule ${block.thickness} pt thick`, at)\n checkColor(block.color, at)\n // Its line and the space above and below it (`ruleContent`): taller than the body, it was stroked over the footer and off the paper, or crashed pdfmake.\n tall(walk, place, block.thickness + 2 * RULE_GAP, `the rule ${at}`, at)\n return\n case 'rectangle':\n checkRectangle(block, at, place, walk)\n return\n case 'spacer':\n if (!(block.height >= 0 && Number.isFinite(block.height))) throw new RenderRefusal('unsupported', `${at} is a spacer ${block.height} pt tall`, at)\n return\n case 'pageBreak': {\n const inside = place.region ? 'page region' : place.kept ? 'keep-together block' : place.column ? 'columns block' : undefined\n if (inside !== undefined) throw new RenderRefusal('unsupported', `${at} is a page break inside a ${inside}`, at)\n return\n }\n case 'keepTogether':\n if (!place.region && !place.kept) walk.measured.push({ block, at, width: place.width, inset: place.inset })\n checkBlocks(block.blocks, `${at}.blocks`, { ...place, kept: true, depth: place.depth + 1 }, walk)\n return\n case 'columns':\n checkColumns(block, at, place, walk)\n return\n case 'section':\n checkSection(block, at, place, walk)\n return\n default:\n // A document from a runtime that knows a block this renderer does not.\n throw new RenderRefusal('unsupported', `${at} is a ${String((block as { kind?: unknown }).kind)} block, which the renderer does not know`, at)\n }\n}\n\n/** Something drawn at a fixed height in the body: judged against the body once the regions are measured. A page region's is judged by measuring the region. */\nfunction tall(walk: Walk, place: Place, height: number, what: string, subject: string): void {\n if (!place.region) walk.tall.push({ height, inset: place.inset, what, subject })\n}\n\n/**\n * Text, held to being a string -- an array would reach pdfmake as inlines\n * carrying any property of its own, a link among them -- and to the face it\n * prints in, which must have a glyph for each of its characters.\n */\nfunction checkText(text: unknown, face: keyof Glyphs, walk: Walk, at: string, subject = at): void {\n if (typeof text !== 'string') throw new RenderRefusal('unsupported', `${at} prints something that is not text`, subject)\n const missing = missingGlyph(text, walk.glyphs[face])\n if (missing !== undefined) {\n throw new RenderRefusal('unsupported', `${at} prints ${codePoint(missing)}, which Roboto has no glyph for: it would print as an empty box, and as nothing in the PDF's text, and no other font is embedded`, subject)\n }\n}\n\n/** Every cell of `table` as text in the face it prints in: the renderer's weight for its row's kind, under the cell's style. */\nfunction checkTableText(table: Table, walk: Walk): void {\n const at = `table ${table.id}`\n const face = (style: TextStyle | null | undefined, bold: boolean, italic = false): keyof Glyphs => faceOf(style?.bold ?? bold, style?.italic ?? italic)\n table.header.forEach((text, column) => checkText(text, face(table.headerStyle, KIND_BOLD.header), walk, `${at}'s header, column ${column + 1},`, table.id))\n checkText(table.emptyText, face(undefined, KIND_BOLD.empty, true), walk, `${at}'s empty text`, table.id)\n table.rows.forEach((row, index) => {\n row.cells.forEach((text, column) => {\n checkText(text, face(row.cellStyles?.[column] ?? row.style, KIND_BOLD[row.kind]), walk, `${at}, row ${index}, column ${column + 1},`, table.id)\n })\n })\n}\n\nfunction checkStyle(style: TextStyle | undefined, at: string): void {\n if (style === undefined) return\n // Own tokens only: 'constructor' would find Object's, and crash pdfmake.\n if (style.font !== undefined && !Object.hasOwn(FONTS, style.font)) {\n throw new RenderRefusal('unsupported', `${at} is set in the ${String(style.font)} font; the renderer embeds Roboto alone, as the sans font, and prints no other in its place`, at)\n }\n if (style.size !== undefined && !(style.size > 0 && Number.isFinite(style.size))) throw new RenderRefusal('unsupported', `${at} is set at ${style.size} pt`, at)\n if (style.align !== undefined && style.align !== 'left' && style.align !== 'center' && style.align !== 'right') throw new RenderRefusal('unsupported', `${at} is aligned '${String(style.align)}'`, at)\n checkColor(style.color, at)\n}\n\nfunction checkColor(color: string | undefined, at: string): void {\n // pdfmake prints a colour it cannot read as black, without a word.\n if (color !== undefined && !COLOR.test(color)) throw new RenderRefusal('unsupported', `${at} names the colour '${color}', which is not #rrggbb in lower case`, at)\n}\n\nfunction checkTable(table: Table, width: number): void {\n const columns = table.columns.length\n if (columns === 0) throw new RenderRefusal('unsupported', `table ${table.id} has no columns`, table.id)\n if (table.columns.some((column) => column.align !== 'left' && column.align !== 'center' && column.align !== 'right')) throw new RenderRefusal('unsupported', `table ${table.id} aligns a column in a way the renderer does not know`, table.id)\n if (table.header.length !== columns) throw new RenderRefusal('unsupported', `the header of table ${table.id} has ${table.header.length} cells for ${columns} columns`, table.id)\n table.rows.forEach((row, index) => {\n const cells = row.across === true ? 1 : columns\n if (row.cells.length !== cells) {\n throw new RenderRefusal('unsupported', `row ${index} of table ${table.id} has ${row.cells.length} cells for ${row.across === true ? 'a row across the table, which has one' : `${columns} columns`}`, table.id)\n }\n if (row.cellStyles !== undefined && row.cellStyles.length !== row.cells.length) {\n throw new RenderRefusal('unsupported', `row ${index} of table ${table.id} has ${row.cellStyles.length} cell styles for ${row.cells.length} cells`, table.id)\n }\n for (const style of [row.style, ...(row.cellStyles ?? [])]) checkStyle(style ?? undefined, table.id)\n })\n checkStyle(table.headerStyle, table.id)\n const narrow = table.columns.find((column) => column.width !== 'fill' && !(column.width > 2 * PADDING_X && Number.isFinite(column.width)))\n if (narrow !== undefined) throw new RenderRefusal('unsupported', `table ${table.id} has a column of ${String(narrow.width)} pt, no wider than its cell padding`, table.id)\n const widths = table.columns.map((column) => column.width)\n const fixed = widths.reduce<number>((sum, each) => sum + fixedWidth(each), 0)\n if (fixed > width || fillWidth(widths, width) <= 2 * PADDING_X) {\n throw new RenderRefusal('content-too-large', `table ${table.id}'s fixed columns are ${fixed} pt wide; it stands ${width.toFixed(2)} pt wide`, table.id)\n }\n}\n\n/** The tallest line a cell of the table prints, with the cell's padding: a row no page can start. */\nfunction tallestCellLine(table: Table): number {\n const styles = [table.headerStyle, ...table.rows.flatMap((row) => [row.style, ...(row.cellStyles ?? [])])]\n const size = Math.max(0, ...styles.map((style) => style?.size ?? 0))\n return size * LINE_FACTOR + 2 * PADDING_Y\n}\n\nfunction checkImage(image: Image, place: Place, walk: Walk): void {\n const { id } = image.asset\n if (image.fit !== 'contain' && image.fit !== 'cover') throw new RenderRefusal('unsupported', `the image ${id} is fitted '${String(image.fit)}', which the renderer does not know`, id)\n if (!(image.width > 0 && image.height > 0 && Number.isFinite(image.width) && Number.isFinite(image.height))) {\n throw new RenderRefusal('unsupported', `the image ${id} is drawn ${image.width} × ${image.height} pt`, id)\n }\n if (image.width > place.width) throw new RenderRefusal('content-too-large', `the image ${id} is ${image.width} pt wide; it stands ${place.width.toFixed(2)} pt wide`, id)\n tall(walk, place, image.height, `the image ${id}`, id)\n}\n\n/** A QR code is a square that stands where an image may: no wider than where it stands, no taller than the body. */\nfunction checkQrCode(code: QrCode, place: Place, walk: Walk): void {\n const { id, size } = code\n if (!(size > 0 && Number.isFinite(size))) throw new RenderRefusal('unsupported', `the QR code ${id} is drawn ${size} pt a side`, id)\n if (size > place.width) throw new RenderRefusal('content-too-large', `the QR code ${id} is ${size} pt wide; it stands ${place.width.toFixed(2)} pt wide`, id)\n walk.codes.set(code, qrSymbol(code))\n tall(walk, place, size, `the QR code ${id}`, id)\n}\n\n/** An EPC QR code is a square that stands where a QR code may, and its caption, when it has one, is drawn inside it. */\nfunction checkEpcQrCode(code: EpcQrCode, place: Place, walk: Walk): void {\n const { id, size } = code\n if (!(size > 0 && Number.isFinite(size))) throw new RenderRefusal('unsupported', `the EPC QR code ${id} is drawn ${size} pt a side`, id)\n if (size > place.width) throw new RenderRefusal('content-too-large', `the EPC QR code ${id} is ${size} pt wide; it stands ${place.width.toFixed(2)} pt wide`, id)\n walk.codes.set(code, epcSymbol(code))\n walk.captioned ||= code.caption !== undefined\n tall(walk, place, size, `the EPC QR code ${id}`, id)\n}\n\nfunction checkRectangle(rectangle: Rectangle, at: string, place: Place, walk: Walk): void {\n if (!(rectangle.width > 0 && rectangle.height > 0 && Number.isFinite(rectangle.width) && Number.isFinite(rectangle.height))) {\n throw new RenderRefusal('unsupported', `${at} is a rectangle of ${rectangle.width} × ${rectangle.height} pt`, at)\n }\n checkColor(rectangle.fill, at)\n checkColor(rectangle.stroke, at)\n if (rectangle.width > place.width) throw new RenderRefusal('content-too-large', `${at} is a rectangle ${rectangle.width} pt wide; it stands ${place.width.toFixed(2)} pt wide`, at)\n tall(walk, place, rectangle.height, `the rectangle ${at}`, at)\n}\n\nfunction checkColumns(columns: Columns, at: string, place: Place, walk: Walk): void {\n if (columns.columns.length === 0) throw new RenderRefusal('unsupported', `${at} is a columns block with no columns`, at)\n const widths = columns.columns.map((slot) => slot.width)\n if (widths.some((width) => width !== 'fill' && !(width > 0 && Number.isFinite(width)))) throw new RenderRefusal('unsupported', `${at} has a column of no width`, at)\n const fixed = widths.reduce<number>((sum, each) => sum + fixedWidth(each), 0)\n const fill = fillWidth(widths, place.width)\n if (fixed > place.width || fill <= 0) throw new RenderRefusal('content-too-large', `${at}'s fixed columns are ${fixed} pt wide; it stands ${place.width.toFixed(2)} pt wide`, at)\n columns.columns.forEach((slot, index) => {\n const width = slot.width === 'fill' ? fill : slot.width\n checkBlocks(slot.blocks, `${at}.columns[${index}].blocks`, { ...place, column: true, width, depth: place.depth + 1 }, walk)\n })\n}\n\nfunction checkSection(section: Section, at: string, place: Place, walk: Walk): void {\n if (section.border !== undefined) {\n if (!(section.border.thickness > 0 && Number.isFinite(section.border.thickness))) throw new RenderRefusal('unsupported', `${at} has a border ${section.border.thickness} pt thick`, at)\n checkColor(section.border.color, at)\n }\n checkColor(section.fill, at)\n if (section.padding !== undefined && !(section.padding >= 0 && Number.isFinite(section.padding))) throw new RenderRefusal('unsupported', `${at} has a padding of ${section.padding} pt`, at)\n const frame = frameOf(section)\n const width = place.width - 2 * frame\n if (width <= 0) throw new RenderRefusal('content-too-large', `${at}'s border and padding leave its blocks no width`, at)\n // Its border and padding above and below, on every page it reaches: taller than the body, they leave its blocks no height.\n if (frame > 0) tall(walk, place, 2 * frame, `the border and padding of ${at}`, at)\n checkBlocks(section.blocks, `${at}.blocks`, { ...place, width, inset: place.inset + 2 * frame, depth: place.depth + 1 }, walk)\n}\n\n/**\n * Refuses what the body cannot hold once its height is known: a block of\n * fixed height, or a line, taller than a page's body less the frames around\n * it. pdfmake would draw it past the foot of the page, or not at all.\n */\nexport function refuseTall(tall: readonly Tall[], bodyHeight: number): void {\n for (const each of tall) {\n if (each.height > bodyHeight - each.inset) {\n throw new RenderRefusal('content-too-large', `${each.what} is ${each.height.toFixed(2)} pt tall; the body is ${(bodyHeight - each.inset).toFixed(2)} pt where it stands`, each.subject)\n }\n }\n}\n","import { FACTUR_X } from '@formancy/report-runtime'\nimport type { EInvoiceFile } from '@formancy/report-runtime'\n\n/**\n * An e-invoice drawn as what it is (0031, extending 0027): a PDF/A-3b that\n * embeds the XML the runtime wrote, as `factur-x.xml`, and says so in its\n * XMP. pdfmake takes the PDF/A part of it as two options of the definition\n * (`PDF_A_3B`), and PDFKit writes the rest -- the pdfaid identification,\n * the sRGB output intent and its ICC profile -- as it ends the document.\n * The file and the fx properties have no key in pdfmake's definition, so\n * they are added to PDFKit's document between layout and `end`, the one\n * hook the engines take (`Engine.run`'s `finish`), on the final pass alone.\n *\n * Only a document with an e-invoice is a PDF/A: the version, the subset and\n * the hook are all three its own, and every other report is drawn as it\n * always was (0031 weighs PDF/A for every report, and why not).\n *\n * The renderer decides none of what the file says. The XML is the\n * runtime's, encoded as UTF-8 and changed in nothing; its name, its\n * relationship and the conformance level are the document's, held to\n * report-spec's by `checkEInvoice`; the fx namespace, prefix, document type\n * and version are report-spec's `FACTUR_X`. Only the words that describe\n * the four properties in the extension schema are the renderer's own:\n * PDF/A asks that an extension schema describe each property it declares,\n * and no specification's wording is copied for it.\n */\n\n/**\n * pdfmake's options for a PDF/A-3b. Level b is the one within reach: level\n * a needs a structure tree, which pdfmake does not build, and PDFKit has\n * no level u (pdfkit.js 5320-5332). The version must be given, or PDFKit writes a PDF 1.3\n * with no XMP and says nothing (pdfkit.js 6070; `pdfmake.test.ts`).\n */\nexport const PDF_A_3B = { version: '1.7', subset: 'PDF/A-3b' } as const\n\n/** What `file` takes in PDFKit 0.19.1 (pdfkit.js 5160-5244): `relationship` among it, which @types/pdfkit 0.17.6 leaves out (`pdfmake.test.ts` pins it). */\nexport interface PdfKitFileOptions {\n readonly name: string\n /** The media type, written as the stream's /Subtype. */\n readonly type: string\n readonly description: string\n /** Written as the file specification's /AFRelationship. */\n readonly relationship: string\n readonly creationDate: Date\n readonly modifiedDate: Date\n}\n\n/**\n * PDFKit's document as pdfmake's `getStream` hands it over in either build,\n * laid out and not yet ended: the two of its methods an e-invoice adds\n * through, typed here at the boundary rather than through @types/pdfkit,\n * whose `file` options lack the relationship.\n */\nexport interface PdfKitDocument {\n /** `src` an ArrayBuffer: a typed array that is not a Node Buffer falls through to `fs.readFileSync(src)` (pdfkit.js 5172-5184). */\n file(src: ArrayBuffer, options: PdfKitFileOptions): unknown\n appendXML(xml: string): unknown\n}\n\n/** What acts on PDFKit's document between layout and `end`: the final pass's alone. */\nexport type Finish = (document: PdfKitDocument) => void\n\n/**\n * The hook that makes the final pass's PDF the e-invoice: `file` embedded,\n * dated `created`, the document's own creation date -- so that the same\n * document renders to the same bytes, and no file system's clock reaches\n * the PDF: PDFKit dates a file it reads from a path by `fs.statSync`, and\n * one it is handed by nothing but these options (pdfkit.js 5184-5200) --\n * and the fx properties appended to the XMP.\n */\nexport function embedEInvoice(file: EInvoiceFile, created: Date): Finish {\n const xml = exactBuffer(new TextEncoder().encode(file.xml))\n const description = `E-invoice XML, ${file.conformanceLevel}`\n return (document) => {\n document.file(xml, { name: file.fileName, type: FACTUR_X.mediaType, description, relationship: file.relationship, creationDate: created, modifiedDate: created })\n document.appendXML(facturXmp(file))\n }\n}\n\n/** The ArrayBuffer of exactly `bytes`: an encoder's view may sit in a larger buffer, all of which PDFKit would embed. */\nfunction exactBuffer(bytes: Uint8Array): ArrayBuffer {\n return bytes.buffer.slice(bytes.byteOffset, bytes.byteOffset + bytes.byteLength) as ArrayBuffer\n}\n\n/**\n * The extension schemas' own namespaces: the container's as veraPDF's rule\n * 6.6.2.3.3-1 names it, and the schema's and the property's as akretion's\n * factur-x and PDFlib's sample extension schema write them [S], which\n * veraPDF 1.30.3's 6.6.2.3.3 rules pass (0031; report-corpus's\n * `XMP_NAMESPACES` says the same).\n */\nconst PDFA_EXTENSION = 'http://www.aiim.org/pdfa/ns/extension/'\nconst PDFA_SCHEMA = 'http://www.aiim.org/pdfa/ns/schema#'\nconst PDFA_PROPERTY = 'http://www.aiim.org/pdfa/ns/property#'\n\n/**\n * The extension schema's name, as the Factur-X specification gives it in\n * its section 6.3.1 [S], as 0031 gives it: a name, the one item here not a value, and\n * one no validator in the gate reads.\n */\nconst SCHEMA_NAME = 'Factur-X PDFA Extension Schema'\n\n/** The four fx properties, each with its description: the renderer's own words, a Text of the external category, as PDF/A has an extension schema declare a property (6.6.2.3.3). */\nconst PROPERTIES = [\n ['DocumentFileName', 'The name under which this PDF embeds the invoice as XML'],\n ['DocumentType', 'What kind of business document the embedded XML is'],\n ['Version', 'The version of the hybrid format this PDF and its XML follow'],\n ['ConformanceLevel', 'The profile the embedded XML conforms to'],\n] as const\n\n/** Text as XML writes it between tags and in a double-quoted attribute. Every value here is report-spec's or checked against it, and is escaped all the same. */\nconst escaped = (text: string): string => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/\"/g, '"')\n\n/**\n * The fx description and the extension schema that declares its four\n * properties, as two `rdf:Description`s PDFKit puts into the packet before\n * its own (pdfkit.js 6011-6013). Without the schema, veraPDF fails the\n * properties (6.6.2.3.1-1, -2).\n */\nfunction facturXmp(file: EInvoiceFile): string {\n const fx = FACTUR_X.xmpPrefix\n const values: Readonly<Record<(typeof PROPERTIES)[number][0], string>> = {\n DocumentFileName: file.fileName,\n DocumentType: FACTUR_X.documentType,\n Version: FACTUR_X.version,\n ConformanceLevel: file.conformanceLevel,\n }\n const property = ([name, description]: (typeof PROPERTIES)[number]): string =>\n `<rdf:li rdf:parseType=\"Resource\"><pdfaProperty:name>${name}</pdfaProperty:name><pdfaProperty:valueType>Text</pdfaProperty:valueType><pdfaProperty:category>external</pdfaProperty:category><pdfaProperty:description>${escaped(description)}</pdfaProperty:description></rdf:li>`\n return [\n `<rdf:Description rdf:about=\"\" xmlns:${fx}=\"${escaped(FACTUR_X.xmpNamespace)}\">`,\n ...PROPERTIES.map(([name]) => `<${fx}:${name}>${escaped(values[name])}</${fx}:${name}>`),\n '</rdf:Description>',\n `<rdf:Description rdf:about=\"\" xmlns:pdfaExtension=\"${PDFA_EXTENSION}\" xmlns:pdfaSchema=\"${PDFA_SCHEMA}\" xmlns:pdfaProperty=\"${PDFA_PROPERTY}\">`,\n '<pdfaExtension:schemas><rdf:Bag><rdf:li rdf:parseType=\"Resource\">',\n `<pdfaSchema:schema>${SCHEMA_NAME}</pdfaSchema:schema>`,\n `<pdfaSchema:namespaceURI>${escaped(FACTUR_X.xmpNamespace)}</pdfaSchema:namespaceURI>`,\n `<pdfaSchema:prefix>${fx}</pdfaSchema:prefix>`,\n `<pdfaSchema:property><rdf:Seq>${PROPERTIES.map(property).join('')}</rdf:Seq></pdfaSchema:property>`,\n '</rdf:li></rdf:Bag></pdfaExtension:schemas>',\n '</rdf:Description>',\n ].join('\\n')\n}\n","import type { Content, ContentCanvas, ContentStack, ContentSvg, ContentText } from 'pdfmake/interfaces.js'\nimport { QR_BILL_SIZE, type QrBill } from '@formancy/report-runtime'\nimport type { CheckedBill } from './bill.js'\nimport { swissCodeContent } from './qr.js'\nimport { LIBERATION_ASCENDER, LIBERATION_LINE, LIBERATION_SANS } from './style.js'\n\n/**\n * A QR-bill's slip, the receipt and the payment part, as pdfmake content:\n * where SIX puts each heading, value, field, line and the code, and at what\n * size, in Liberation Sans. Nothing here formats a value: the runtime hands\n * every text as it prints (report-runtime's `QrBill`).\n *\n * The numbers are SIX's: \"IG\" is the Swiss Implementation Guidelines for\n * the QR-bill, version 2.4, and \"SG\" its Style Guide, version 1.1, whose\n * page 6 gives every section's place and size in millimetres, page 7 the\n * blank fields', and page 15 the sizes and line spacing. What neither gives\n * is taken from manuelbl's SwissQRBill generator, which matches SG 7 drawn\n * to scale: where the blank amount fields stand, and 2 pt between a\n * debtor's heading and its field.\n *\n * Positions are in points from the slip's top left. The slip is\n * report-spec's `QR_BILL_SIZE`, 210 by 105 mm, and stands at its\n * `QR_BILL_TOP`, spanning the paper's width and ending at its foot (IG\n * 3.1): the size and the place the editor draws its band at and refuses a\n * page by, decided there once. The layout draws it as the last page's\n * footer (`definition.ts`), each part placed on its own.\n */\n\n/** Millimetres in points. */\nconst mm = (value: number): number => (value * 72) / 25.4\n\n/** The receipt is 62 mm wide, and the payment part starts there (IG 3.3). */\nconst RECEIPT_WIDTH = mm(62)\n\n/**\n * \"Separate before paying in\", above the line along the slip's top, outside\n * the payment part, which a PDF's slip may print instead of a scissors\n * symbol (IG 3.7, SG 4): 8 pt, the payment part's heading size, centred\n * over the slip, its baseline 3 pt above the line. SIX gives neither.\n */\nconst INSTRUCTION = { size: 8, gap: 3 }\n\n/** How far above the slip its drawing starts: the top of the instruction's line. The body ends above it. */\nexport const ABOVE_SLIP = INSTRUCTION.gap + LIBERATION_ASCENDER * INSTRUCTION.size\n\n/** The lines the slip is cut along (IG 3.7): solid, half a point. SIX gives no weight. */\nconst SEPARATION = 0.5\n\n/**\n * The scissors symbol on the line between the receipt and the payment\n * part. IG 3.7 asks that each line \"bear the scissors symbol or\n * alternatively the instruction ... above the line (outside the payment\n * part)\": the line across the paper has the instruction above it, and a\n * line down the slip has no \"above\" outside the payment part, so it bears\n * the symbol. SIX gives it no size or place. It is manuelbl's generator's\n * (`BillLayout.drawBorder`, read on 17 October 2026): 3 mm tall, on the\n * line from 5 mm below the slip's top, the line broken where it stands.\n * 2.5 mm wide, so that it keeps to the 5 mm left unprinted on either side\n * of the line (SG 6). Drawn here, since Liberation Sans has no glyph for\n * U+2702, and the same in every language. In millimetres.\n */\nconst SCISSORS = { top: 5, width: 2.5, height: 3 }\n\n/** A blank field's corner marks: 3 mm arms, 0.75 pt (IG 3.5.3, SG 7). */\nconst CORNER = { arm: mm(3), weight: 0.75 }\n\n/** Between a debtor's heading's line and its blank field. */\nconst FIELD_GAP = 2\n\n/** The titles, \"Receipt\" and \"Payment part\": 11 pt bold (IG 3.5.1, 3.6.1). */\nconst TITLE = 11\n\n/** A part's text: headings bold and 2 pt smaller than their values, every line `pitch` below the one before (IG 3.4, SG 15). */\ninterface Lettering {\n readonly heading: number\n readonly value: number\n readonly pitch: number\n}\n\n/** A part of the slip: where each of its sections starts, and the room its information has. */\ninterface Part {\n readonly name: string\n readonly lettering: Lettering\n /** Where its title stands, and which heading it prints: \"Receipt\" or \"Payment part\". */\n readonly title: { readonly x: number; readonly top: number; readonly heading: 'receipt' | 'paymentPart' }\n /** Whether it prints the additional information: the payment part does, the receipt never (IG 3.6.2). */\n readonly additionalInformation: boolean\n readonly information: { readonly x: number; readonly top: number; readonly width: number; readonly height: number; readonly millimetres: number }\n /** The amount section: its headings' top, and how far the amount stands in from the currency. */\n readonly amount: { readonly x: number; readonly top: number; readonly indent: number; readonly pitch: number }\n /** The blank amount field: its box, and whether its top is the amount's line rather than the section's. */\n readonly amountField: { readonly x: number; readonly width: number; readonly height: number; readonly onAmountLine: boolean }\n readonly debtorField: { readonly width: number; readonly height: number }\n}\n\n/** The receipt, 62 by 105 mm (SG 6): 5 mm margins, its title, 56 mm of information, 14 of amount, 18 of acceptance point. */\nexport const RECEIPT: Part = {\n name: 'the receipt',\n lettering: { heading: 6, value: 8, pitch: 9 },\n title: { x: mm(5), top: mm(5), heading: 'receipt' },\n additionalInformation: false,\n information: { x: mm(5), top: mm(12), width: mm(52), height: mm(56), millimetres: 56 },\n // A receipt's amount is 8 pt on 11 pt (SG 15), 12 mm in (SG 7).\n amount: { x: mm(5), top: mm(68), indent: mm(12), pitch: 11 },\n // 30 by 10 mm, right-aligned to the receipt's text, at the section's top.\n amountField: { x: mm(27), width: mm(30), height: mm(10), onAmountLine: false },\n debtorField: { width: mm(52), height: mm(20) },\n}\n\n/** The payment part, 148 by 105 mm (SG 6): the code's 46 mm and the amount's 22 mm beside 87 by 85 mm of information. */\nexport const PAYMENT_PART: Part = {\n name: 'the payment part',\n lettering: { heading: 8, value: 10, pitch: 11 },\n title: { x: RECEIPT_WIDTH + mm(5), top: mm(5), heading: 'paymentPart' },\n additionalInformation: true,\n information: { x: RECEIPT_WIDTH + mm(56), top: mm(5), width: mm(87), height: mm(85), millimetres: 85 },\n // The payment part's amount is 10 pt on 13 pt (SG 15), 15 mm in (SG 7).\n amount: { x: RECEIPT_WIDTH + mm(5), top: mm(68), indent: mm(15), pitch: 13 },\n // 40 by 15 mm, its right edge at the information section's left, its top where the amount would stand.\n amountField: { x: RECEIPT_WIDTH + mm(16), width: mm(40), height: mm(15), onAmountLine: true },\n debtorField: { width: mm(65), height: mm(25) },\n}\n\n/** The Swiss QR Code's place: 5 mm in, below the title section and 5 mm of quiet zone (IG 3.5.2, SG 6). */\nconst CODE = { x: RECEIPT_WIDTH + mm(5), top: mm(17) }\n\n/** The acceptance point, right-aligned to the receipt's text at the top of its section (IG 3.6.4, SG 6). */\nconst ACCEPTANCE = { right: mm(57), top: mm(82) }\n\nconst ascender = (size: number): number => LIBERATION_ASCENDER * size\n\n/** A circle about `x`, `y` of radius `r`, as an SVG path of four quarters, each ending at one of its extremes. */\nfunction circle(x: number, y: number, r: number): string {\n const k = 0.5523 * r\n return `M${x + r} ${y}C${x + r} ${y + k} ${x + k} ${y + r} ${x} ${y + r}C${x - k} ${y + r} ${x - r} ${y + k} ${x - r} ${y}C${x - r} ${y - k} ${x - k} ${y - r} ${x} ${y - r}C${x + k} ${y - r} ${x + r} ${y - k} ${x + r} ${y}Z`\n}\n\n/**\n * The scissors, open, their points down the line they cut along, drawn in\n * tenths of a millimetre across `SCISSORS`. A ring either side of the line\n * at the top, 1.2 mm across and 0.2 mm thick, each touching the symbol's\n * side, filled with its hole left out; and from each ring a blade, a wedge\n * from the ring's side towards the line to a point 0.45 mm past it at the\n * symbol's foot, the two crossing on the line. Drawn here after the symbol\n * IG 3.7 prints, none of it taken from another generator's drawing.\n */\nfunction scissorsContent(): ContentSvg {\n const [across, tall] = [SCISSORS.width * 10, SCISSORS.height * 10]\n const [line, ring, hole, past] = [across / 2, 6, 4, 4.5]\n const sides = [-1, 1].map((sign) => {\n const centre = line + sign * (line - ring)\n const toward = (degrees: number): string => {\n const radians = (degrees * Math.PI) / 180\n return `${(centre - sign * ring * Math.cos(radians)).toFixed(3)} ${(ring + ring * Math.sin(radians)).toFixed(3)}`\n }\n return { rings: `${circle(centre, ring, ring)}${circle(centre, ring, hole)}`, blade: `M${toward(30)}L${toward(75)}L${line - sign * past} ${tall}Z` }\n })\n const [width, height] = [mm(SCISSORS.width), mm(SCISSORS.height)]\n const blades = sides.map(({ blade }) => `<path d=\"${blade}\" fill=\"#000000\"/>`).join('')\n const svg = `<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"${width}\" height=\"${height}\" viewBox=\"0 0 ${across} ${tall}\"><path d=\"${sides.map(({ rings }) => rings).join('')}\" fill=\"#000000\" fill-rule=\"evenodd\"/>${blades}</svg>`\n return { svg, width, height }\n}\n\n/** One line of text in Liberation Sans, `lineHeight` times its line tall. */\nfunction line(text: string, size: number, bold: boolean, lineHeight = 1): ContentText {\n return { text, font: LIBERATION_SANS, fontSize: size, bold, lineHeight }\n}\n\n/** A blank field's four corners, each two arms of a polyline, stroked inside the box `width` by `height` from the canvas's corner. */\nfunction corners(width: number, height: number): ContentCanvas['canvas'] {\n const [inset, arm] = [CORNER.weight / 2, CORNER.arm]\n const corner = (points: readonly (readonly [number, number])[]): ContentCanvas['canvas'][number] => ({\n type: 'polyline',\n points: points.map(([x, y]) => ({ x, y })),\n lineWidth: CORNER.weight,\n lineColor: '#000000',\n })\n const [left, top, right, bottom] = [inset, inset, width - inset, height - inset]\n return [\n corner([[left, arm], [left, top], [arm, top]]),\n corner([[width - arm, top], [right, top], [right, arm]]),\n corner([[right, height - arm], [right, bottom], [width - arm, bottom]]),\n corner([[arm, bottom], [left, bottom], [left, height - arm]]),\n ]\n}\n\n/** A block of a part's information: a heading over its values, or over a blank field for the payer's hand. */\ntype Block = { readonly heading: string; readonly values: readonly string[] } | { readonly heading: string; readonly field: Part['debtorField'] }\n\n/** The blocks a part's information holds, in SIX's order (IG 3.5.4, 3.6.2): the additional information in the payment part alone. */\nfunction blocks(bill: QrBill, part: Part): Block[] {\n const { headings } = bill\n return [\n { heading: headings.account, values: [bill.account, ...bill.creditor] },\n ...(bill.reference === null ? [] : [{ heading: headings.reference, values: [bill.reference] }]),\n ...(part.additionalInformation && bill.additionalInformation.length > 0 ? [{ heading: headings.additionalInformation, values: bill.additionalInformation }] : []),\n bill.debtor === null ? { heading: headings.payableBy, field: part.debtorField } : { heading: headings.payableBy, values: bill.debtor },\n ]\n}\n\n/**\n * A part's information, as one stack laid out from its section's top: the\n * first heading's line at the top, every line's baseline `pitch` below the\n * one before, and a blank line between blocks (SG 15). pdfmake sets each\n * baseline its ascender below its line's top, so a heading's line is made\n * shorter than the pitch by what a value's ascender is longer, and the\n * space before a heading longer by as much.\n */\nexport function informationContent(bill: QrBill, part: Part): Content[] {\n const { heading, value, pitch } = part.lettering\n const shift = ascender(value) - ascender(heading)\n return blocks(bill, part).flatMap((block, index): Content[] => {\n const title: ContentText = { ...line(block.heading, heading, true, (pitch - shift) / (LIBERATION_LINE * heading)), margin: [0, index === 0 ? 0 : pitch + shift, 0, 0] }\n if ('field' in block) return [title, { canvas: corners(block.field.width, block.field.height), margin: [0, FIELD_GAP, 0, CORNER.weight / 2] }]\n return [title, ...block.values.map((text) => line(text, value, false, pitch / (LIBERATION_LINE * value)))]\n })\n}\n\n/** `content` placed with its top left at `x`, `y` on the page, measured from the footer's top, `origin`, where pdfmake lays the footer out. */\nfunction at(content: ContentText | ContentStack | ContentCanvas | ContentSvg, x: number, y: number, origin: number): Content {\n return { ...content, absolutePosition: { x, y: y - origin } }\n}\n\n/** `content` laid out `width` wide where it is placed, on a page `paperWidth` wide. */\nfunction within(content: Content[], x: number, width: number, paperWidth: number): ContentStack {\n return { stack: [{ stack: content, margin: [0, 0, paperWidth - x - width, 0] }] }\n}\n\n/** A part's title, its amount section and its information, each placed on the page whose slip starts at `top`. */\nfunction partContent(bill: QrBill, part: Part, top: number, origin: number, paperWidth: number): Content[] {\n const { heading, value } = part.lettering\n const { amount } = part\n const headingTop = top + amount.top\n const amountTop = headingTop + ascender(heading) + amount.pitch - ascender(value)\n const field = part.amountField\n return [\n at(line(bill.headings[part.title.heading], TITLE, true), part.title.x, top + part.title.top, origin),\n at(line(bill.headings.currency, heading, true), amount.x, headingTop, origin),\n at(line(bill.currency, value, false), amount.x, amountTop, origin),\n at(line(bill.headings.amount, heading, true), amount.x + amount.indent, headingTop, origin),\n bill.amount === null\n ? at({ canvas: corners(field.width, field.height) }, field.x, field.onAmountLine ? amountTop : headingTop, origin)\n : at(line(bill.amount, value, false), amount.x + amount.indent, amountTop, origin),\n at(within(informationContent(bill, part), part.information.x, part.information.width, paperWidth), part.information.x, top + part.information.top, origin),\n ]\n}\n\n/**\n * The slip, as the last page's footer lays it out, its top `top` points\n * down a page `paperWidth` wide: the lines it is cut along, the\n * instruction above the one across and the scissors on the one down, the\n * receipt with its acceptance point, and the payment part with its code.\n * Made anew for each layout, since pdfmake writes its positions into the\n * content it lays out.\n */\nexport function slipContent({ bill, symbol }: CheckedBill, top: number, origin: number, paperWidth: number): Content[] {\n const down = (from: number, to: number): ContentCanvas['canvas'][number] => ({ type: 'line', x1: RECEIPT_WIDTH, y1: from, x2: RECEIPT_WIDTH, y2: to, lineWidth: SEPARATION, lineColor: '#000000' })\n const separation: ContentCanvas = {\n canvas: [\n { type: 'line', x1: 0, y1: 0, x2: QR_BILL_SIZE.width, y2: 0, lineWidth: SEPARATION, lineColor: '#000000' },\n down(0, mm(SCISSORS.top)),\n down(mm(SCISSORS.top + SCISSORS.height), QR_BILL_SIZE.height),\n ],\n }\n const instruction: ContentText = { ...line(bill.headings.separate, INSTRUCTION.size, false), alignment: 'center' }\n const acceptance: ContentText = { ...line(bill.headings.acceptancePoint, RECEIPT.lettering.heading, true), alignment: 'right' }\n return [\n at(instruction, 0, top - ABOVE_SLIP, origin),\n at(separation, 0, top, origin),\n at(scissorsContent(), RECEIPT_WIDTH - mm(SCISSORS.width / 2), top + mm(SCISSORS.top), origin),\n ...partContent(bill, RECEIPT, top, origin, paperWidth),\n at(within([acceptance], RECEIPT.information.x, ACCEPTANCE.right - RECEIPT.information.x, paperWidth), RECEIPT.information.x, top + ACCEPTANCE.top, origin),\n ...partContent(bill, PAYMENT_PART, top, origin, paperWidth),\n at(swissCodeContent(symbol), CODE.x, top + CODE.top, origin),\n ]\n}\n","import type { Content, DynamicContent, TDocumentDefinitions } from 'pdfmake/interfaces.js'\nimport { QR_BILL_TOP, RenderRefusal, type Block, type ResolvedDocument, type Table } from '@formancy/report-runtime'\nimport type { CheckedBill } from './bill.js'\nimport { newBuild, type Build, type Fields, type TablePlan } from './build.js'\nimport type { Checked, Measured, Page } from './check.js'\nimport { contentOf } from './content.js'\nimport { PDF_A_3B } from './pdfa.js'\nimport { ABOVE_SLIP, slipContent } from './slip.js'\nimport { DEFAULT_SIZE, ROBOTO } from './style.js'\nimport { checkWords } from './words.js'\n\n/**\n * The pdfmake document definitions a render hands pdfmake, built from the\n * resolved document and what was measured: pure, the same in Node and in a\n * browser, and the one place either entry's definitions come from. What\n * runs them is the entry's own (`node.ts`, `browser.ts`).\n *\n * The page regions: pdfmake draws its header inside the top page margin and\n * its footer inside the bottom one, and lays the body out between. So\n * pdfmake's margins are the document's enlarged by each region's measured\n * height and a 6pt gap, and each region is drawn at the document's own\n * margin: the header from the top of the printable area down, the footer\n * ending at its bottom. Nothing of the body can reach into either.\n */\n\nexport const DEFAULT_STYLE = { font: ROBOTO, fontSize: DEFAULT_SIZE }\n\n/** Between the page header and the body, and between the body and the page footer. */\nexport const REGION_GAP = 6\n\n/** Space each page region takes from the printable area, its gap to the body included; nothing for a region with no blocks. */\nexport interface Regions {\n readonly header: number\n readonly footer: number\n}\n\n/** What a measuring pass lays out: one item per thing measured, and the build that holds their images and marks. */\nexport interface Measurement {\n readonly items: readonly Content[]\n readonly build: Build\n}\n\n/**\n * The page header and footer that have blocks, each one item, with every\n * page field printed as the page limit: as many digits as the field can\n * have. A region that wraps only for some page numbers is measured at its\n * widest, which is not the same thing, and is not refused.\n */\nexport function regionsMeasurement(document: ResolvedDocument, checked: Checked, maxPages: number): Measurement & { readonly present: readonly (readonly Block[])[] } {\n const fields: Fields = { pageNumber: maxPages, pageCount: maxPages }\n const present = [document.pageHeader, document.pageFooter].filter((blocks) => blocks.length > 0)\n const build = newBuild('measure', checked)\n return { present, build, items: present.map((blocks): Content => ({ stack: contentOf(blocks, build, checked.page.width, fields) })) }\n}\n\n/** The body's tables and keep-together blocks, each one item laid out at the width it stands at. */\nexport function bodyMeasurement(measured: readonly Measured[], checked: Checked): Measurement {\n const build = newBuild('measure', checked)\n const items = measured.map(({ block, width }): Content => ({ stack: contentOf([block], build, width), margin: [0, 0, checked.page.width - width, 0] }))\n return { items, build }\n}\n\n/** Where the body starts and ends on every page, from the top of the paper: inside the margins and below and above the page regions. */\nexport function bodyBounds(page: Page, regions: Regions): { readonly top: number; readonly bottom: number } {\n return { top: page.margins.top + regions.header, bottom: page.paperHeight - page.margins.bottom - regions.footer }\n}\n\n/**\n * How much of the last page's body a QR-bill's slip takes: from where its\n * drawing starts, the instruction above it, to the body's foot. Nothing if\n * the body ends above the slip on every page.\n */\nexport function slipReservation(page: Page, regions: Regions): number {\n return Math.max(0, bodyBounds(page, regions).bottom - (QR_BILL_TOP - ABOVE_SLIP))\n}\n\n/**\n * The PDF's definition. pdfmake's own page limit, `maxPagesNumber`, cuts the\n * document short; the renderer's throws out of the layout instead, from the\n * function pdfmake calls for each page's background, as the page after the\n * last one allowed is added. So no more than one page past the limit is ever\n * laid out, and nothing is written.\n *\n * A QR-bill's slip is the last page's footer, in place of the page footer:\n * pdfmake lays the footer out once every page is, knowing their count, and\n * gives what is placed above the footer's top the room down to the paper's\n * foot (`pdfmake.test.ts` holds both). The body keeps the slip's room at\n * its end, a spacer as tall as `slipReservation`: where the last page has\n * less room left, pdfmake moves to a new page and starts it without the\n * space, and the slip has that page to itself.\n *\n * A document with an e-invoice is a PDF/A-3b, whose version and subset are\n * the definition's (`PDF_A_3B`); its file and XMP are the final pass's hook\n * (`render.ts`). Neither moves a line: the measuring passes, which have\n * neither, lay the page out as this one does.\n */\nexport function layoutDefinition(\n document: ResolvedDocument,\n checked: Checked,\n regions: Regions,\n plans: ReadonlyMap<Table, TablePlan>,\n maxPages: number,\n bill?: CheckedBill,\n): TDocumentDefinitions {\n const page: Page = checked.page\n const { margins } = page\n const { top: bodyTop, bottom: bodyBottom } = bodyBounds(page, regions)\n const build = newBuild('render', checked, { top: bodyTop, bottom: bodyBottom }, plans)\n const region = (blocks: readonly Block[], margin: [number, number, number, number]): DynamicContent | undefined => {\n if (blocks.length === 0) return undefined\n return (pageNumber, pageCount) => ({ stack: contentOf(blocks, build, page.width, { pageNumber, pageCount }), margin })\n }\n const header = region(document.pageHeader, [margins.left, margins.top, margins.right, 0])\n const footer = region(document.pageFooter, [margins.left, REGION_GAP, margins.right, 0])\n // Once now, so that their images are in the dictionary before pdfmake reads it.\n header?.(1, 1, { width: page.paperWidth, height: page.paperHeight, orientation: document.page.orientation })\n footer?.(1, 1, { width: page.paperWidth, height: page.paperHeight, orientation: document.page.orientation })\n // pdfmake lays the footer out from the body's foot, so the slip's parts are placed from there.\n const slip = bill === undefined ? undefined : (): Content => ({ stack: slipContent(bill, QR_BILL_TOP, bodyBottom, page.paperWidth) })\n const last: DynamicContent | undefined = slip === undefined ? footer : (pageNumber, pageCount, size) => (pageNumber === pageCount ? slip() : footer?.(pageNumber, pageCount, size))\n const reserved = bill === undefined ? [] : [{ stack: [], margin: [0, slipReservation(page, regions), 0, 0] } satisfies Content]\n return {\n ...(checked.eInvoice === undefined ? {} : PDF_A_3B),\n info: { title: document.info.title, creationDate: checked.creationDate },\n pageSize: { width: page.paperWidth, height: page.paperHeight },\n pageMargins: [margins.left, bodyTop, margins.right, page.paperHeight - bodyBottom],\n defaultStyle: DEFAULT_STYLE,\n content: [...contentOf(document.body, build, page.width), ...reserved],\n images: build.images,\n ...(header === undefined ? {} : { header }),\n ...(last === undefined ? {} : { footer: last }),\n background: (number) => {\n // pdfmake has measured every word, and laid out no line yet.\n if (number === 1) checkWords(build.words)\n if (number > maxPages) throw new RenderRefusal('too-many-pages', `the report needs more than ${maxPages} pages`)\n return null\n },\n pageBreakBefore: (node, queries) => {\n const rule = node.headlineLevel === undefined ? undefined : build.rules.get(node.headlineLevel)\n return rule?.(node, queries) ?? false\n },\n }\n}\n","import type { Content, TDocumentDefinitions } from 'pdfmake/interfaces.js'\nimport { keepBlocks, keptBlocks } from './breaks.js'\nimport type { RowKind, TablePlan } from './build.js'\nimport type { Engine } from './engine.js'\nimport { LINE_FACTOR } from './style.js'\nimport { checkWords, type WordRoom } from './words.js'\nimport { PADDING_Y, RULE } from './table.js'\n\n/**\n * Heights measured by laying content out with pdfmake itself, before the\n * PDF is laid out: pdfmake has no measuring call of its own, and the\n * renderer needs heights it cannot compute -- how tall the page header is,\n * whether a keep-together block or a table row fits on a page -- because\n * pdfmake drops content that does not fit where it must, without a word: a\n * page header taller than its margin loses lines, and an unbreakable block\n * or row taller than the page is not drawn at all.\n *\n * How: the items go on one tall page, one after another, each between two\n * sentinels -- one-point text, so that each has a position -- and the first\n * call of `pageBreakBefore`, which pdfmake makes once the layout is done,\n * reads the top of every marked node on the page and throws, so that no PDF\n * is written. A page break means the items did not fit on the page; the\n * `background` function pdfmake calls for every new page throws then.\n */\n\n/** The result of measuring: each item's height and where it ends, and the top of every node marked with a headline level, on the measuring page. */\nexport interface Measured {\n readonly heights: readonly number[]\n readonly ends: readonly number[]\n /** Throws for a mark pdfmake laid out no node for. */\n readonly top: (mark: number) => number\n}\n\n/** Thrown out of pdfmake's layout with what was read; never seen outside `measure`. */\nclass Measurement {\n readonly tops: ReadonlyMap<number, number>\n constructor(tops: ReadonlyMap<number, number>) {\n this.tops = tops\n }\n}\n\n/** Sentinels are marked with negative numbers, so that they never meet the marks content carries. */\nconst sentinel = (index: number): Content => ({ text: '.', fontSize: 1, headlineLevel: -1 - index })\n\n/** Room left on the measuring page for the sentinels: each is one line of one-point text, 1.17pt in Roboto. */\nexport const SENTINEL_ROOM = 2\n\n/** A sentinel's height exactly: one line of one-point Roboto, for a page that must hold its items and nothing more. */\nexport const SENTINEL_LINE = LINE_FACTOR\n\n/**\n * Lays `items` out on one page `height` tall, between those side margins,\n * and measures them; `overflow` is what to throw when they do not fit on it.\n * Before a line is laid out, the `words` of the items are held to their\n * room, so that pdfmake never breaks one too wide for it.\n */\nexport async function measure(\n engine: Engine,\n page: { readonly width: number; readonly height: number; readonly left: number; readonly right: number },\n items: readonly Content[],\n resources: Required<Pick<TDocumentDefinitions, 'defaultStyle' | 'images'>>,\n overflow: () => Error,\n words: readonly WordRoom[],\n): Promise<Measured> {\n const definition: TDocumentDefinitions = {\n pageSize: { width: page.width, height: page.height },\n pageMargins: [page.left, 0, page.right, 0],\n ...resources,\n content: [sentinel(0), sentinel(1), ...items.flatMap((item, index) => [item, sentinel(index + 2)])],\n background: (number) => {\n // pdfmake has measured every word, and laid out no line yet (`words.ts`).\n if (number === 1) checkWords(words)\n if (number > 1) throw overflow()\n return null\n },\n pageBreakBefore: (node, queries) => {\n const tops = new Map<number, number>()\n for (const each of [node, ...queries.getFollowingNodesOnPage()]) {\n if (each.headlineLevel !== undefined) tops.set(each.headlineLevel, each.startPosition.top)\n }\n throw new Measurement(tops)\n },\n }\n let tops: ReadonlyMap<number, number>\n try {\n await engine.run(definition)\n throw new Error('pdfmake wrote a PDF instead of measuring')\n } catch (error) {\n if (!(error instanceof Measurement)) throw error\n tops = error.tops\n }\n const top = (mark: number): number => {\n const found = tops.get(mark)\n if (found === undefined) throw new Error(`pdfmake laid out no node marked ${mark}`)\n return found\n }\n const pitch = top(-2) - top(-1)\n const ends = items.map((_, index) => top(-3 - index))\n return { heights: ends.map((end, index) => end - top(-2 - index) - pitch), ends, top }\n}\n\n/**\n * Each row's height, from the tops of the marks on their first cells: a\n * row's top to the next one's is its height and the rule under it. The last\n * row ends where the table does, which is where the sentinel after it\n * starts, measured from the top of its cell, which stands `PADDING_Y` below\n * the row's top.\n */\nexport function rowPitches(marks: readonly number[], top: Measured['top'], tableEnd: number): number[] {\n return marks.map((mark, index) => {\n const next = marks[index + 1]\n return next === undefined ? tableEnd - top(mark) + PADDING_Y : top(next) - top(mark)\n })\n}\n\n/**\n * pdfmake loses unbreakable content that misses its page by any amount.\n * Heights measured in one layout and used in another agree to the last bit\n * in practice; this much slack keeps rounding from ever deciding it.\n */\nexport const FIT_SLACK = 1\n\n/**\n * How a table breaks across pages of a body `bodyHeight` tall, from its\n * measured rows, the header row first:\n *\n * - rows are kept whole (`dontBreakRows`) only when every one fits on a\n * page under the repeated header, and the first row of each group under\n * its group header as well. pdfmake's option is the whole table's, so one\n * row that does not lets every row of the table split. Split is what a row\n * taller than the page needs, since pdfmake would otherwise not draw it,\n * and what the first row of a group needs to start on its group header's\n * page when the two cannot share one whole;\n * - the header moves with the first row, or with the first two when the\n * first is a group header, so that neither ends a page alone, and with\n * every row of a block of rows kept together that starts among them --\n * a one-line quotation's totals; not when they do not fit on a page\n * together, for the same reason;\n * - the rows kept together (`breaks.ts`) are the blocks that fit on a page\n * under the header and start after the rows that move with it. A table\n * whose rows may split keeps only its group headers with what they head.\n */\nexport function tablePlan(rows: readonly { readonly kind: RowKind; readonly pitch: number }[], bodyHeight: number): TablePlan {\n const [header, ...body] = rows\n const room = bodyHeight - RULE - (header?.pitch ?? 0) - FIT_SLACK\n const under = (index: number): number => (body[index - 1]?.kind === 'groupHeader' ? body[index - 1]!.pitch : 0)\n const dontBreakRows = body.every((row, index) => under(index) + row.pitch <= room)\n const pitches = rows.map((row) => row.pitch)\n const blocks = keepBlocks(rows.map((row) => row.kind), dontBreakRows)\n const first = body[0]?.kind === 'groupHeader' && body.length > 1 ? 2 : 1\n let lead = first\n for (const block of blocks) if (block.first <= lead) lead = Math.max(lead, block.last)\n const fits = (count: number): boolean => body.slice(0, count).reduce((sum, row) => sum + row.pitch, 0) <= room\n const keepWithHeaderRows = fits(lead) ? lead : fits(first) ? first : 0\n return { dontBreakRows, keepWithHeaderRows, pitches, blocks: keptBlocks(blocks, pitches, keepWithHeaderRows, room) }\n}\n","import type { Content, TDocumentDefinitions } from 'pdfmake/interfaces.js'\nimport { RenderRefusal, type Block, type PageSetup, type ResolvedDocument, type Table } from '@formancy/report-runtime'\nimport { checkBill, refusePage, type CheckedBill } from './bill.js'\nimport { refuseOversized } from './bound.js'\nimport type { TablePlan } from './build.js'\nimport { checkDocument, refuseTall, type Checked, type Page } from './check.js'\nimport { bodyMeasurement, DEFAULT_STYLE, layoutDefinition, REGION_GAP, regionsMeasurement, slipReservation, type Regions } from './definition.js'\nimport type { Engine } from './engine.js'\nimport { FIT_SLACK, measure, rowPitches, SENTINEL_LINE, SENTINEL_ROOM, tablePlan } from './measure.js'\nimport type { RenderOptions } from './options.js'\nimport { embedEInvoice } from './pdfa.js'\nimport { ABOVE_SLIP, informationContent, PAYMENT_PART, RECEIPT } from './slip.js'\n\n/**\n * A resolved document rendered with pdfmake, refused rather than truncated,\n * clipped or dropped: the renderer both entries share, given the one thing\n * they do differently, the engine that runs a pdfmake definition with its\n * fonts ([0005](../../../docs/decisions/0005-pdfmake-renders-reports-behind-one-adapter.md)).\n *\n * Three passes, each a pdfmake layout. The first measures the page header\n * and footer, and the second the body's keep-together blocks and table rows\n * (`measure.ts`), because pdfmake loses what does not fit where it must\n * without saying so. The third is the PDF, laid out again by pdfmake for\n * each page break a keep-with-next or table rule asks for. Before them the\n * renderer refuses what it cannot draw (`check.ts`, and `bill.ts` for a\n * QR-bill); between them it decides the page margins, refuses what cannot\n * fit on any page or within the page limit (`bound.ts`), and chooses how\n * each table breaks. A document with a QR-bill has two passes more, one for\n * each part of its slip, which measure their information (`measureSlip`).\n * A document with an e-invoice is drawn as a PDF/A-3b on the third pass,\n * which alone embeds its XML (`pdfa.ts`).\n */\n\nexport async function render(engine: Engine, document: ResolvedDocument, options: RenderOptions): Promise<Uint8Array> {\n const { signal, maxPages } = options\n if (!Number.isSafeInteger(maxPages) || maxPages < 1) throw new RangeError(`maxPages must be a whole number of pages, at least 1; it is ${String(maxPages)}`)\n stopIfCancelled(signal)\n const checked = await checkDocument(document, await engine.glyphs(), maxPages)\n const bill = document.paymentPart === undefined ? undefined : checkBill(document.paymentPart, document.page, await engine.billGlyphs())\n // An EPC QR code's caption prints in Liberation Sans too, which a browser loads only when asked; its words are the PSA's, which the face has glyphs for.\n if (checked.captioned) await engine.billGlyphs()\n await stopIfCancelledSoon(signal)\n const regions = await measureRegions(engine, document, checked, maxPages)\n await stopIfCancelledSoon(signal)\n const bodyHeight = checked.page.height - regions.header - regions.footer\n if (bodyHeight <= 0) throw new RenderRefusal('content-too-large', `the page header and footer leave no room for the body (${bodyHeight.toFixed(2)} pt)`)\n if (bill !== undefined) await measureSlip(engine, bill, checked.page, document.page, regions)\n refuseTall(checked.tall, bodyHeight)\n refuseOversized(document.body, bodyHeight, maxPages, bill === undefined ? 0 : slipReservation(checked.page, regions))\n const plans = await measureBody(engine, checked, bodyHeight, maxPages)\n await stopIfCancelledSoon(signal)\n const finish = checked.eInvoice === undefined ? undefined : embedEInvoice(checked.eInvoice, checked.creationDate)\n const pdf = await engine.run(layoutDefinition(document, checked, regions, plans, maxPages, bill), finish)\n await stopIfCancelledSoon(signal)\n return pdf\n}\n\n/** How much taller than its section a slip's information may lay out and still fit: rounding, not layout. */\nconst SECTION_SLACK = 0.01\n\n/**\n * Refuses a QR-bill's slip that cannot be drawn whole where SIX puts it: on\n * a page whose top margin, with the header under it and the instruction to\n * separate over the slip, reaches into it, by report-spec's rule\n * (`refusePage`); or with information taller than its section (SG 6),\n * which would run into the section below it or off the paper. Each part's\n * information is laid out as the slip lays it out (`slip.ts`), on a sheet\n * as tall as its section and the three sentinels around it: what does not\n * fit on the sheet is taller than the section, and pdfmake's next page\n * refuses it.\n */\nasync function measureSlip(engine: Engine, bill: CheckedBill, page: Page, setup: PageSetup, regions: Regions): Promise<void> {\n refusePage(setup, regions.header + ABOVE_SLIP)\n for (const part of [PAYMENT_PART, RECEIPT]) {\n const { width, height, millimetres } = part.information\n const refusal = (): RenderRefusal => new RenderRefusal('content-too-large', `${part.name}'s information is taller than its section: SIX gives it ${millimetres} mm (${height.toFixed(2)} pt)`, 'paymentPart')\n const item: Content = { stack: informationContent(bill.bill, part), margin: [0, 0, page.paperWidth - width, 0] }\n const sheet = { width: page.paperWidth, height: height + 3 * SENTINEL_LINE + SECTION_SLACK, left: 0, right: 0 }\n await measure(engine, sheet, [item], resources({}), refusal, [])\n }\n}\n\n/**\n * The page header's and footer's heights, measured once, on a page as tall\n * as the printable area: two regions that do not fit on it leave no body.\n */\nasync function measureRegions(engine: Engine, document: ResolvedDocument, checked: Checked, maxPages: number): Promise<Regions> {\n const { present, items, build } = regionsMeasurement(document, checked, maxPages)\n if (present.length === 0) return { header: 0, footer: 0 }\n const { page } = checked\n const { heights } = await measure(\n engine,\n { width: page.paperWidth, height: page.height + SENTINEL_ROOM * (items.length + 2), left: page.margins.left, right: page.margins.right },\n items,\n resources(build.images),\n () => new RenderRefusal('content-too-large', 'the page header and footer are taller than the printable area'),\n build.words,\n )\n const space = (blocks: readonly Block[]): number => (blocks.length === 0 ? 0 : heights[present.indexOf(blocks)]! + REGION_GAP)\n return { header: space(document.pageHeader), footer: space(document.pageFooter) }\n}\n\n/**\n * Measures the body's keep-together blocks and tables, refuses a block no\n * page can hold, and plans how each table breaks. On a page as tall as the\n * page limit's bodies and one more: content that does not fit on it needs\n * more pages than the limit, whatever else the body holds, so it is refused\n * here, after laying out at most that much of it.\n *\n * A block inside framed sections has less of each page than the body: their\n * borders and padding above and below it, which is what `inset` holds.\n */\nasync function measureBody(engine: Engine, checked: Checked, bodyHeight: number, maxPages: number): Promise<ReadonlyMap<Table, TablePlan>> {\n const { measured, page } = checked\n if (measured.length === 0) return new Map()\n const { items, build } = bodyMeasurement(measured, checked)\n const { heights, top, ends } = await measure(\n engine,\n { width: page.paperWidth, height: (maxPages + 1) * bodyHeight + SENTINEL_ROOM * (items.length + 2), left: page.margins.left, right: page.margins.right },\n items,\n resources(build.images),\n () => new RenderRefusal('too-many-pages', `the report needs more than ${maxPages} pages`),\n build.words,\n )\n const plans = new Map<Table, TablePlan>()\n measured.forEach(({ block, at, inset }, index) => {\n const room = bodyHeight - inset\n if (block.kind === 'keepTogether' && heights[index]! > room - FIT_SLACK) {\n throw new RenderRefusal('content-too-large', `the keep-together block ${at} is ${heights[index]!.toFixed(2)} pt tall; a page's body is ${room.toFixed(2)} pt where it stands`, at)\n }\n if (block.kind === 'table') {\n const rows = build.measuredRows.get(block)!\n const pitches = rowPitches(rows.map((row) => row.mark), top, ends[index]!)\n plans.set(block, tablePlan(rows.map((row, at) => ({ kind: row.kind, pitch: pitches[at]! })), room))\n }\n })\n return plans\n}\n\nfunction resources(images: Record<string, string>): Required<Pick<TDocumentDefinitions, 'defaultStyle' | 'images'>> {\n return { defaultStyle: DEFAULT_STYLE, images }\n}\n\nfunction stopIfCancelled(signal: AbortSignal | undefined): void {\n if (signal?.aborted === true) throw new RenderRefusal('cancelled', 'the render was cancelled')\n}\n\n/**\n * `stopIfCancelled`, once the event loop has turned. Every await of a pass\n * resolves without it turning -- pdfmake's work is synchronous and PDFKit's\n * stream events come on the microtask queue -- so without this an abort\n * from a timer arrived only once the PDF was written: a 417-page render\n * resolved after 10.7 seconds with a PDF its caller had abandoned after 50\n * milliseconds (2026-10-15).\n */\nasync function stopIfCancelledSoon(signal: AbortSignal | undefined): Promise<void> {\n if (signal !== undefined) await new Promise((resolve) => setTimeout(resolve, 0))\n stopIfCancelled(signal)\n}\n"],"mappings":";;;;AAiCA,SAAgB,OAAO,MAAe,QAAuB;CAC3D,OAAO,OAAQ,SAAS,gBAAgB,SAAU,SAAS,YAAY;AACzE;;AAGA,MAAM,8BAAmC,IAAI,IAAI,CAAC,IAAM,EAAI,CAAC;;AAG7D,SAAgB,aAAa,MAAc,MAA+C;CACxF,KAAK,MAAM,aAAa,MAAM;EAC5B,MAAM,QAAQ,UAAU,YAAY,CAAC;EACrC,IAAI,CAAC,KAAK,IAAI,KAAK,KAAK,CAAC,YAAY,IAAI,KAAK,GAAG,OAAO;CA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