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