@infuro/cms-core 1.0.67 → 1.0.68

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.
Files changed (48) hide show
  1. package/dist/admin.cjs +121 -12
  2. package/dist/admin.js +121 -12
  3. package/dist/api.cjs +43 -40
  4. package/dist/api.js +11 -8
  5. package/dist/auth.cjs +12 -12
  6. package/dist/auth.js +2 -2
  7. package/dist/{chunk-BVLN75LP.cjs → chunk-22XKONB5.cjs} +201 -71
  8. package/dist/{chunk-TU23GJPJ.js → chunk-7JCCPQEF.js} +1 -1
  9. package/dist/{chunk-WMMZZRDJ.cjs → chunk-GN4LKG4V.cjs} +1 -1
  10. package/dist/chunk-IKTBZJHT.js +16 -0
  11. package/dist/chunk-M5GPOPGX.cjs +49 -0
  12. package/dist/{chunk-GLLCLRCQ.js → chunk-MYUGQHU4.js} +158 -28
  13. package/dist/{chunk-NV5IRHI3.js → chunk-N4LBZXBG.js} +2 -2
  14. package/dist/chunk-P6S4XFZO.cjs +18 -0
  15. package/dist/{chunk-RCE5SJBA.js → chunk-SKJH7PX4.js} +1 -1
  16. package/dist/{chunk-5MZFQRDW.cjs → chunk-SMHQV3WL.cjs} +4 -4
  17. package/dist/chunk-SUUD7OUG.cjs +455 -0
  18. package/dist/{chunk-XFDIIVZB.cjs → chunk-UMC7W5G3.cjs} +3 -3
  19. package/dist/chunk-WKDBMDUX.js +45 -0
  20. package/dist/chunk-Z5OB5QGN.js +465 -0
  21. package/dist/chunk-ZIT4IP6N.js +445 -0
  22. package/dist/chunk-ZX5U3VCB.cjs +471 -0
  23. package/dist/email-queue-3QBQ63F7.js +8 -0
  24. package/dist/{email-queue-4OY45JIU.cjs → email-queue-K4E4OFI7.cjs} +9 -6
  25. package/dist/{emit-order-notification-trigger-ZD5YN3JM.cjs → emit-order-notification-trigger-ROASTYQP.cjs} +3 -3
  26. package/dist/{emit-order-notification-trigger-EJJZ6XTS.js → emit-order-notification-trigger-YUQTPELC.js} +1 -1
  27. package/dist/{erp-order-invoice-YUSPZ7CE.cjs → erp-order-invoice-AZ5MX2JB.cjs} +8 -5
  28. package/dist/{erp-order-invoice-H6HCJ7YS.js → erp-order-invoice-XSYHAMBS.js} +4 -1
  29. package/dist/generate-local-invoice-pdf-BQTCL5MW.cjs +12 -0
  30. package/dist/generate-local-invoice-pdf-OCFG47SE.js +3 -0
  31. package/dist/index.cjs +286 -283
  32. package/dist/index.d.cts +7 -1
  33. package/dist/index.d.ts +7 -1
  34. package/dist/index.js +16 -13
  35. package/dist/invoice-templates-GZ33OENC.js +2 -0
  36. package/dist/invoice-templates-RB462AQN.cjs +19 -0
  37. package/dist/{order-completion-otp-handlers-DZAXK4GQ.cjs → order-completion-otp-handlers-DDQREULW.cjs} +8 -5
  38. package/dist/{order-completion-otp-handlers-HFGCPC4O.js → order-completion-otp-handlers-NROWBGXN.js} +6 -3
  39. package/dist/{order-notification-dispatcher-LL7ETKLU.cjs → order-notification-dispatcher-6HCJ6Q75.cjs} +12 -9
  40. package/dist/{order-notification-dispatcher-ECPFI7CD.js → order-notification-dispatcher-KM2SY7TX.js} +7 -4
  41. package/dist/resolve-invoice-asset-url-JEZRENJW.cjs +11 -0
  42. package/dist/resolve-invoice-asset-url-QZ2FRDHI.js +2 -0
  43. package/package.json +1 -1
  44. package/dist/chunk-GLD263KW.cjs +0 -862
  45. package/dist/chunk-OPJEV44S.js +0 -847
  46. package/dist/email-queue-HGXB2FIS.js +0 -5
  47. package/dist/{chunk-SS3K7OIM.cjs → chunk-HBUV73RB.cjs} +1 -1
  48. package/dist/{chunk-2ISSXYBZ.js → chunk-Z5G54EGD.js} +1 -1
@@ -0,0 +1,465 @@
1
+ import { normalizeInvoiceTemplateId } from './chunk-WKDBMDUX.js';
2
+ import { __name } from './chunk-SHUYVCID.js';
3
+ import { rgb, PDFDocument, StandardFonts } from 'pdf-lib';
4
+ import qrcode from 'qr.js';
5
+
6
+ var THEMES = {
7
+ classic: {
8
+ accent: rgb(0.15, 0.25, 0.45),
9
+ headerBg: rgb(0.96, 0.96, 0.97),
10
+ headerText: rgb(0.12, 0.12, 0.14),
11
+ text: rgb(0.12, 0.12, 0.14),
12
+ muted: rgb(0.4, 0.42, 0.45),
13
+ line: rgb(0.82, 0.84, 0.86),
14
+ bandText: rgb(1, 1, 1)
15
+ },
16
+ modern: {
17
+ accent: rgb(0.1, 0.45, 0.55),
18
+ headerBg: rgb(0.93, 0.97, 0.98),
19
+ headerText: rgb(0.1, 0.12, 0.14),
20
+ text: rgb(0.1, 0.12, 0.14),
21
+ muted: rgb(0.38, 0.42, 0.45),
22
+ line: rgb(0.78, 0.86, 0.88),
23
+ bandText: rgb(1, 1, 1)
24
+ },
25
+ compact: {
26
+ accent: rgb(0.2, 0.2, 0.22),
27
+ headerBg: rgb(0.95, 0.95, 0.95),
28
+ headerText: rgb(0.1, 0.1, 0.1),
29
+ text: rgb(0.1, 0.1, 0.1),
30
+ muted: rgb(0.45, 0.45, 0.45),
31
+ line: rgb(0.85, 0.85, 0.85),
32
+ bandText: rgb(1, 1, 1)
33
+ },
34
+ bold: {
35
+ accent: rgb(0.55, 0.12, 0.12),
36
+ headerBg: rgb(0.55, 0.12, 0.12),
37
+ headerText: rgb(1, 1, 1),
38
+ text: rgb(0.1, 0.1, 0.1),
39
+ muted: rgb(0.4, 0.4, 0.4),
40
+ line: rgb(0.8, 0.75, 0.75),
41
+ bandText: rgb(1, 1, 1)
42
+ },
43
+ service_detailed: {
44
+ accent: rgb(0.15, 0.25, 0.45),
45
+ headerBg: rgb(0.96, 0.96, 0.97),
46
+ headerText: rgb(0.12, 0.12, 0.14),
47
+ text: rgb(0.12, 0.12, 0.14),
48
+ muted: rgb(0.4, 0.42, 0.45),
49
+ line: rgb(0.82, 0.84, 0.86),
50
+ bandText: rgb(1, 1, 1)
51
+ }
52
+ };
53
+ function money(amount, currency) {
54
+ const n = Number.isFinite(amount) ? amount : 0;
55
+ const code = (currency || "INR").trim().toUpperCase() || "INR";
56
+ return `${code} ${n.toFixed(2)}`;
57
+ }
58
+ __name(money, "money");
59
+ function fmtDate(d) {
60
+ const date = d instanceof Date ? d : new Date(d);
61
+ if (Number.isNaN(date.getTime())) return String(d);
62
+ const y = date.getFullYear();
63
+ const m = String(date.getMonth() + 1).padStart(2, "0");
64
+ const day = String(date.getDate()).padStart(2, "0");
65
+ return `${day}-${m}-${y}`;
66
+ }
67
+ __name(fmtDate, "fmtDate");
68
+ function winAnsiSafe(input) {
69
+ return String(input ?? "").replace(/\u20B9/g, "INR ").replace(/\u20AC/g, "EUR ").replace(/\u00A3/g, "GBP ").replace(/[^\x09\x0A\x0D\x20-\x7E]/g, "?");
70
+ }
71
+ __name(winAnsiSafe, "winAnsiSafe");
72
+ function addrLines(a) {
73
+ if (!a) return [];
74
+ const out = [];
75
+ if (a.line1?.trim()) out.push(a.line1.trim());
76
+ if (a.line2?.trim()) out.push(a.line2.trim());
77
+ const cityLine = [
78
+ a.city,
79
+ a.state,
80
+ a.postalCode
81
+ ].filter((x) => x && String(x).trim()).join(", ");
82
+ if (cityLine) out.push(cityLine);
83
+ if (a.country?.trim()) out.push(a.country.trim());
84
+ return out.map(winAnsiSafe);
85
+ }
86
+ __name(addrLines, "addrLines");
87
+ function companyHeaderDetailLines(company) {
88
+ const lines = [];
89
+ if (company.supportEmail?.trim()) {
90
+ lines.push(`Email: ${company.supportEmail.trim()}`);
91
+ }
92
+ if (company.supportPhone?.trim()) {
93
+ lines.push(`Phone: ${company.supportPhone.trim()}`);
94
+ }
95
+ if (company.address?.trim()) {
96
+ const parts = company.address.split(/\r?\n/).map((l) => l.trim()).filter(Boolean);
97
+ if (parts.length === 1) {
98
+ lines.push(`Address: ${parts[0]}`);
99
+ } else if (parts.length > 1) {
100
+ lines.push(`Address: ${parts[0]}`);
101
+ lines.push(...parts.slice(1));
102
+ }
103
+ }
104
+ return lines.map(winAnsiSafe);
105
+ }
106
+ __name(companyHeaderDetailLines, "companyHeaderDetailLines");
107
+ function drawText(page, text, x, y, font, size, color) {
108
+ const safe = winAnsiSafe(text).slice(0, 120);
109
+ if (!safe) return;
110
+ page.drawText(safe, {
111
+ x,
112
+ y,
113
+ size,
114
+ font,
115
+ color
116
+ });
117
+ }
118
+ __name(drawText, "drawText");
119
+ function wrapText(text, font, size, maxWidth) {
120
+ const words = winAnsiSafe(text).split(/\s+/).filter(Boolean);
121
+ if (!words.length) return [
122
+ ""
123
+ ];
124
+ const lines = [];
125
+ let cur = "";
126
+ for (const w of words) {
127
+ const next = cur ? `${cur} ${w}` : w;
128
+ if (font.widthOfTextAtSize(next, size) <= maxWidth) {
129
+ cur = next;
130
+ } else {
131
+ if (cur) lines.push(cur);
132
+ cur = w;
133
+ }
134
+ }
135
+ if (cur) lines.push(cur);
136
+ return lines.slice(0, 4);
137
+ }
138
+ __name(wrapText, "wrapText");
139
+ async function tryEmbedLogo(doc, logoUrl, maxW, maxH) {
140
+ const url = String(logoUrl ?? "").trim();
141
+ if (!url || !/^https?:\/\//i.test(url)) return null;
142
+ try {
143
+ const res = await fetch(url, {
144
+ signal: AbortSignal.timeout(8e3)
145
+ });
146
+ if (!res.ok) return null;
147
+ const buf = new Uint8Array(await res.arrayBuffer());
148
+ if (buf.byteLength < 24 || buf.byteLength > 25e5) return null;
149
+ const ct = (res.headers.get("content-type") || "").toLowerCase();
150
+ const isPng = ct.includes("png") || buf[0] === 137 && buf[1] === 80 && buf[2] === 78 && buf[3] === 71;
151
+ const isJpg = ct.includes("jpeg") || ct.includes("jpg") || buf[0] === 255 && buf[1] === 216;
152
+ let image;
153
+ if (isPng) image = await doc.embedPng(buf);
154
+ else if (isJpg) image = await doc.embedJpg(buf);
155
+ else {
156
+ try {
157
+ image = await doc.embedPng(buf);
158
+ } catch {
159
+ image = await doc.embedJpg(buf);
160
+ }
161
+ }
162
+ const scale = Math.min(maxW / image.width, maxH / image.height, 1);
163
+ return {
164
+ image,
165
+ width: image.width * scale,
166
+ height: image.height * scale
167
+ };
168
+ } catch {
169
+ return null;
170
+ }
171
+ }
172
+ __name(tryEmbedLogo, "tryEmbedLogo");
173
+ function drawQrCode(page, text, x, y, size) {
174
+ try {
175
+ const fn = typeof qrcode === "function" ? qrcode : qrcode?.default;
176
+ if (!fn) return;
177
+ const qr = fn(text, {
178
+ errorCorrectLevel: 2
179
+ });
180
+ const modules = qr.modules;
181
+ if (!modules || !modules.length) return;
182
+ const count = modules.length;
183
+ const cellSize = size / count;
184
+ page.drawRectangle({
185
+ x: x - 3,
186
+ y: y - 3,
187
+ width: size + 6,
188
+ height: size + 6,
189
+ color: rgb(1, 1, 1)
190
+ });
191
+ for (let r = 0; r < count; r++) {
192
+ for (let c = 0; c < count; c++) {
193
+ if (modules[r][c]) {
194
+ page.drawRectangle({
195
+ x: x + c * cellSize,
196
+ y: y + (count - 1 - r) * cellSize,
197
+ width: cellSize + 0.05,
198
+ height: cellSize + 0.05,
199
+ color: rgb(0.1, 0.1, 0.1)
200
+ });
201
+ }
202
+ }
203
+ }
204
+ } catch (err) {
205
+ console.error("[invoice-pdf] Failed to draw QR code:", err);
206
+ }
207
+ }
208
+ __name(drawQrCode, "drawQrCode");
209
+ async function generateLocalInvoicePdf(input) {
210
+ const templateId = normalizeInvoiceTemplateId(input.templateId);
211
+ const theme = THEMES[templateId];
212
+ const doc = await PDFDocument.create();
213
+ const font = await doc.embedFont(StandardFonts.Helvetica);
214
+ const fontBold = await doc.embedFont(StandardFonts.HelveticaBold);
215
+ const pageWidth = 595.28;
216
+ const pageHeight = 841.89;
217
+ const margin = templateId === "compact" ? 36 : 48;
218
+ let page = doc.addPage([
219
+ pageWidth,
220
+ pageHeight
221
+ ]);
222
+ let y = pageHeight - margin;
223
+ const companyName = input.company.name || "Store";
224
+ const logo = await tryEmbedLogo(doc, input.company.logoUrl, 120, 40);
225
+ const ensureSpace = /* @__PURE__ */ __name((need) => {
226
+ if (y - need < margin + 40) {
227
+ page = doc.addPage([
228
+ pageWidth,
229
+ pageHeight
230
+ ]);
231
+ y = pageHeight - margin;
232
+ }
233
+ }, "ensureSpace");
234
+ const companyDetails = companyHeaderDetailLines(input.company);
235
+ const detailLineH = 11;
236
+ const detailsBlockH = companyDetails.length * detailLineH;
237
+ if (templateId === "bold" || templateId === "modern") {
238
+ const contentH = 22 + 16 + detailsBlockH;
239
+ const bandH = Math.max(templateId === "bold" ? 72 : 56, logo ? logo.height + 24 : 56, contentH + 20);
240
+ page.drawRectangle({
241
+ x: 0,
242
+ y: pageHeight - bandH,
243
+ width: pageWidth,
244
+ height: bandH,
245
+ color: theme.accent
246
+ });
247
+ if (logo) {
248
+ page.drawImage(logo.image, {
249
+ x: pageWidth - margin - logo.width,
250
+ y: pageHeight - bandH + (bandH - logo.height) / 2,
251
+ width: logo.width,
252
+ height: logo.height
253
+ });
254
+ }
255
+ let hy = pageHeight - 26;
256
+ drawText(page, "TAX INVOICE", margin, hy, fontBold, 18, theme.bandText);
257
+ hy -= 18;
258
+ drawText(page, companyName, margin, hy, font, 11, theme.bandText);
259
+ hy -= 14;
260
+ for (const line of companyDetails) {
261
+ drawText(page, line, margin, hy, font, 8, theme.bandText);
262
+ hy -= detailLineH;
263
+ }
264
+ y = pageHeight - bandH - 24;
265
+ } else {
266
+ const contentH = 18 + 14 + detailsBlockH;
267
+ const headerH = Math.max(44, logo ? logo.height + 16 : 44, contentH + 20);
268
+ page.drawRectangle({
269
+ x: margin,
270
+ y: y - headerH + 16,
271
+ width: pageWidth - margin * 2,
272
+ height: headerH,
273
+ color: theme.headerBg
274
+ });
275
+ if (logo) {
276
+ page.drawImage(logo.image, {
277
+ x: pageWidth - margin - 12 - logo.width,
278
+ y: y - headerH + 16 + (headerH - logo.height) / 2,
279
+ width: logo.width,
280
+ height: logo.height
281
+ });
282
+ }
283
+ let hy = y + 2;
284
+ drawText(page, "TAX INVOICE", margin + 12, hy, fontBold, 16, theme.accent);
285
+ hy -= 16;
286
+ drawText(page, companyName, margin + 12, hy, font, 10, theme.muted);
287
+ hy -= 13;
288
+ for (const line of companyDetails) {
289
+ drawText(page, line, margin + 12, hy, font, 8, theme.muted);
290
+ hy -= detailLineH;
291
+ }
292
+ y -= headerH + 16;
293
+ }
294
+ drawText(page, `Invoice #: ${input.orderNumber}`, margin, y, fontBold, 11, theme.text);
295
+ drawText(page, `Date: ${fmtDate(input.orderDate)}`, pageWidth / 2, y, font, 10, theme.muted);
296
+ y -= 22;
297
+ ensureSpace(100);
298
+ const colW = (pageWidth - margin * 2 - 16) / 2;
299
+ drawText(page, "Bill to", margin, y, fontBold, 10, theme.accent);
300
+ drawText(page, "Ship to", margin + colW + 16, y, fontBold, 10, theme.accent);
301
+ y -= 14;
302
+ const bill = [
303
+ input.customerName,
304
+ input.customerEmail || "",
305
+ input.customerPhone || "",
306
+ ...addrLines(input.billingAddress)
307
+ ].filter(Boolean);
308
+ const ship = addrLines(input.shippingAddress).length ? [
309
+ input.customerName,
310
+ ...addrLines(input.shippingAddress)
311
+ ] : bill;
312
+ const rows = Math.max(bill.length, ship.length, 1);
313
+ for (let i = 0; i < rows; i++) {
314
+ ensureSpace(14);
315
+ if (bill[i]) drawText(page, bill[i], margin, y, font, 9, theme.text);
316
+ if (ship[i]) drawText(page, ship[i], margin + colW + 16, y, font, 9, theme.text);
317
+ y -= 12;
318
+ }
319
+ y -= 12;
320
+ const isServiceTemplate = templateId === "service_detailed";
321
+ if (isServiceTemplate) {
322
+ y -= 6;
323
+ ensureSpace(50);
324
+ const sCol1 = margin;
325
+ const sCol2 = margin + colW + 16;
326
+ drawText(page, "Order Date:", sCol1, y, fontBold, 9.5, theme.accent);
327
+ drawText(page, fmtDate(input.orderDate), sCol1 + 75, y, font, 9.5, theme.text);
328
+ drawText(page, "Service Date:", sCol2, y, fontBold, 9.5, theme.accent);
329
+ drawText(page, input.serviceDate ? fmtDate(input.serviceDate) : "Not scheduled", sCol2 + 85, y, font, 9.5, theme.text);
330
+ y -= 16;
331
+ drawText(page, "Slot:", sCol1, y, fontBold, 9.5, theme.accent);
332
+ drawText(page, input.timeSlot ? String(input.timeSlot) : "Standard", sCol1 + 75, y, font, 9.5, theme.text);
333
+ drawText(page, "Assigned to:", sCol2, y, fontBold, 9.5, theme.accent);
334
+ drawText(page, input.assignedTo ? String(input.assignedTo) : "Pending Assignment", sCol2 + 85, y, font, 9.5, theme.text);
335
+ y -= 24;
336
+ }
337
+ const right = pageWidth - margin;
338
+ const contentRight = right - 4;
339
+ const colTotalW = 100;
340
+ const colTaxW = 100;
341
+ const colPriceW = 100;
342
+ const colQtyW = 40;
343
+ const totalRight = contentRight;
344
+ const taxRight = totalRight - colTotalW;
345
+ const priceRight = taxRight - colTaxW;
346
+ const qtyRight = priceRight - colPriceW;
347
+ const itemMaxW = Math.max(80, qtyRight - colQtyW - margin - 8);
348
+ const drawRight = /* @__PURE__ */ __name((text, rightEdge, atY, f, size, color) => {
349
+ const safe = winAnsiSafe(text).slice(0, 40);
350
+ if (!safe) return;
351
+ const w = f.widthOfTextAtSize(safe, size);
352
+ page.drawText(safe, {
353
+ x: rightEdge - w,
354
+ y: atY,
355
+ size,
356
+ font: f,
357
+ color
358
+ });
359
+ }, "drawRight");
360
+ ensureSpace(30);
361
+ const headerBarH = 20;
362
+ const headerBarBottom = y - 5;
363
+ page.drawRectangle({
364
+ x: margin,
365
+ y: headerBarBottom,
366
+ width: pageWidth - margin * 2,
367
+ height: headerBarH,
368
+ color: theme.headerBg
369
+ });
370
+ const headerTextY = headerBarBottom + 6;
371
+ drawText(page, "Item", margin + 4, headerTextY, fontBold, 9, theme.headerText);
372
+ drawRight("Qty", qtyRight, headerTextY, fontBold, 9, theme.headerText);
373
+ drawRight("Price", priceRight, headerTextY, fontBold, 9, theme.headerText);
374
+ drawRight("Tax", taxRight, headerTextY, fontBold, 9, theme.headerText);
375
+ drawRight("Total", totalRight, headerTextY, fontBold, 9, theme.headerText);
376
+ y = headerBarBottom - 10;
377
+ for (const line of input.lineItems) {
378
+ const nameLines = wrapText(line.name || "Item", font, 9, itemMaxW);
379
+ const skuText = line.sku ? winAnsiSafe(`SKU: ${line.sku}`).slice(0, 80) : "";
380
+ const nameH = Math.max(11, nameLines.length * 11);
381
+ const skuH = skuText ? 10 : 0;
382
+ const blockH = nameH + skuH + 6;
383
+ ensureSpace(blockH + 10);
384
+ let ty = y;
385
+ for (const nl of nameLines) {
386
+ drawText(page, nl, margin + 4, ty, font, 9, theme.text);
387
+ ty -= 11;
388
+ }
389
+ if (skuText) {
390
+ drawText(page, skuText, margin + 4, ty, font, 7, theme.muted);
391
+ ty -= 10;
392
+ }
393
+ drawRight(String(line.quantity), qtyRight, y, font, 9, theme.text);
394
+ drawRight(money(line.unitPrice, input.currency), priceRight, y, font, 9, theme.text);
395
+ drawRight(money(line.tax ?? 0, input.currency), taxRight, y, font, 9, theme.text);
396
+ drawRight(money(line.total, input.currency), totalRight, y, font, 9, theme.text);
397
+ const contentBottom = Math.min(ty, y - 12);
398
+ y = contentBottom - 2;
399
+ page.drawLine({
400
+ start: {
401
+ x: margin,
402
+ y
403
+ },
404
+ end: {
405
+ x: pageWidth - margin,
406
+ y
407
+ },
408
+ thickness: 0.5,
409
+ color: theme.line
410
+ });
411
+ y -= 8;
412
+ }
413
+ y -= 16;
414
+ ensureSpace(95);
415
+ const summaryTopY = y;
416
+ const summaryLabelX = totalRight - colTotalW - colTaxW - 8;
417
+ const rowsSummary = [
418
+ [
419
+ "Subtotal",
420
+ money(input.subtotal, input.currency),
421
+ false
422
+ ],
423
+ [
424
+ "Discount",
425
+ money(input.discount, input.currency),
426
+ false
427
+ ],
428
+ [
429
+ "Tax",
430
+ money(input.tax, input.currency),
431
+ false
432
+ ],
433
+ [
434
+ "Total",
435
+ money(input.total, input.currency),
436
+ true
437
+ ]
438
+ ];
439
+ let sy = summaryTopY;
440
+ for (const [label, value, strong] of rowsSummary) {
441
+ const f = strong ? fontBold : font;
442
+ const size = strong ? 11 : 9;
443
+ drawText(page, label, summaryLabelX, sy, f, size, strong ? theme.accent : theme.muted);
444
+ drawRight(value, totalRight, sy, f, size, theme.text);
445
+ sy -= strong ? 18 : 14;
446
+ }
447
+ let qrBottomY = summaryTopY;
448
+ const shouldDrawQr = input.includeQrCode === true && Boolean(input.qrData || input.qrToken);
449
+ if (shouldDrawQr) {
450
+ const qrSize = 64;
451
+ const qrX = margin + 4;
452
+ const qrY = summaryTopY - qrSize + 8;
453
+ const qrContent = input.qrData || String(input.orderNumber);
454
+ drawQrCode(page, qrContent, qrX, qrY, qrSize);
455
+ qrBottomY = qrY - 10;
456
+ }
457
+ y = Math.min(sy, qrBottomY) - 16;
458
+ ensureSpace(30);
459
+ drawText(page, "Thank you for your purchase.", margin, y, font, 9, theme.muted);
460
+ y -= 12;
461
+ return doc.save();
462
+ }
463
+ __name(generateLocalInvoicePdf, "generateLocalInvoicePdf");
464
+
465
+ export { generateLocalInvoicePdf };