@levischuck/receiptline 0.1.2 → 0.1.4

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/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { decodeBase64 as V, encodeBase64 as O } from "@levischuck/tiny-encodings";
2
- import { qrCode as _, EcLevel as C } from "@levischuck/tiny-qr";
1
+ import { decodeBase64 as O, encodeBase64 as _ } from "@levischuck/tiny-encodings";
2
+ import { qrCode as G, EcLevel as C } from "@levischuck/tiny-qr";
3
3
  import { toSvgString as it } from "@levischuck/tiny-qr-svg";
4
4
  class H {
5
5
  locked = !1;
@@ -26,7 +26,7 @@ class H {
26
26
  });
27
27
  return;
28
28
  }
29
- const e = new AbortController(), i = setTimeout(() => {
29
+ const e = new AbortController(), n = setTimeout(() => {
30
30
  e.abort();
31
31
  }, t);
32
32
  try {
@@ -39,7 +39,7 @@ class H {
39
39
  })
40
40
  ]);
41
41
  } finally {
42
- clearTimeout(i);
42
+ clearTimeout(n);
43
43
  }
44
44
  this.locked = !0, this.lockPromise = new Promise((a) => {
45
45
  this.lockResolve = a;
@@ -58,12 +58,12 @@ class H {
58
58
  * @returns {number} string width
59
59
  */
60
60
  measureText(t, e) {
61
- let i = 0;
61
+ let n = 0;
62
62
  const a = Array.from(t);
63
63
  switch (e) {
64
64
  case "cp932":
65
65
  case "shiftjis":
66
- i = a.reduce((s, h) => {
66
+ n = a.reduce((s, h) => {
67
67
  const o = h.codePointAt(0);
68
68
  return o === void 0 ? s : s + (o < 128 || o === 160 || o === 165 || o === 8254 || o > 65376 && o < 65440 ? 1 : 2);
69
69
  }, 0);
@@ -74,7 +74,7 @@ class H {
74
74
  case "ksc5601":
75
75
  case "cp950":
76
76
  case "big5":
77
- i = a.reduce((s, h) => {
77
+ n = a.reduce((s, h) => {
78
78
  const o = h.codePointAt(0);
79
79
  return o === void 0 ? s : s + (o < 128 || o === 160 ? 1 : 2);
80
80
  }, 0);
@@ -84,13 +84,13 @@ class H {
84
84
  const o = h.codePointAt(0);
85
85
  return o === void 0 || (s.consonant ? o === 3633 || o >= 3636 && o <= 3642 || o === 3655 ? s.vowel ? (s.length += 2, s.consonant = s.vowel = s.tone = !1) : s.vowel = !0 : o >= 3656 && o <= 3659 ? s.tone ? (s.length += 2, s.consonant = s.vowel = s.tone = !1) : s.tone = !0 : o === 3635 || o >= 3660 && o <= 3662 ? s.vowel || s.tone ? (s.length += 2, s.consonant = s.vowel = s.tone = !1) : (s.length += o === 3635 ? 2 : 1, s.consonant = !1) : o >= 3585 && o <= 3630 ? (s.length++, s.vowel = s.tone = !1) : (s.length += 2, s.consonant = s.vowel = s.tone = !1) : o >= 3585 && o <= 3630 ? s.consonant = !0 : s.length++), s;
86
86
  }, { length: 0, consonant: !1, vowel: !1, tone: !1 });
87
- r.consonant && (r.length++, r.consonant = r.vowel = r.tone = !1), i = r.length;
87
+ r.consonant && (r.length++, r.consonant = r.vowel = r.tone = !1), n = r.length;
88
88
  break;
89
89
  default:
90
- i = a.length;
90
+ n = a.length;
91
91
  break;
92
92
  }
93
- return i;
93
+ return n;
94
94
  }
95
95
  /**
96
96
  * Create character array from string (supporting Thai combining characters).
@@ -99,19 +99,19 @@ class H {
99
99
  * @returns {string[]} array instance
100
100
  */
101
101
  arrayFrom(t, e) {
102
- const i = Array.from(t);
102
+ const n = Array.from(t);
103
103
  switch (e) {
104
104
  case "cp932":
105
105
  case "shiftjis":
106
- return i.map((r) => r.replace(/\\/g, "¥").replace(/\u203e/g, "~").replace(/\u301c/g, "~"));
106
+ return n.map((r) => r.replace(/\\/g, "¥").replace(/\u203e/g, "~").replace(/\u301c/g, "~"));
107
107
  case "tis620":
108
- const a = i.reduce((r, s) => {
108
+ const a = n.reduce((r, s) => {
109
109
  const h = s.codePointAt(0);
110
110
  return h === void 0 || (r.consonant ? h === 3633 || h >= 3636 && h <= 3642 || h === 3655 ? r.vowel ? (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : r.vowel = s : h >= 3656 && h <= 3659 ? r.tone ? (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : r.tone = s : h === 3635 || h >= 3660 && h <= 3662 ? r.vowel || r.tone ? (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : (r.result.push(r.consonant + s), r.consonant = "") : h >= 3585 && h <= 3630 ? (r.result.push(r.consonant + r.vowel + r.tone), r.consonant = s, r.vowel = r.tone = "") : (r.result.push(r.consonant + r.vowel + r.tone, s), r.consonant = r.vowel = r.tone = "") : h >= 3585 && h <= 3630 ? r.consonant = s : r.result.push(s)), r;
111
111
  }, { result: [], consonant: "", vowel: "", tone: "" });
112
112
  return a.consonant && (a.result.push(a.consonant + a.vowel + a.tone), a.consonant = a.vowel = a.tone = ""), a.result;
113
113
  default:
114
- return i;
114
+ return n;
115
115
  }
116
116
  }
117
117
  /**
@@ -136,7 +136,7 @@ class H {
136
136
  * @param {number} right right margin (unit: characters)
137
137
  * @returns {Promise<string>} commands
138
138
  */
139
- async area(t, e, i) {
139
+ async area(t, e, n) {
140
140
  return "";
141
141
  }
142
142
  /**
@@ -163,6 +163,17 @@ class H {
163
163
  async relative(t) {
164
164
  return "";
165
165
  }
166
+ /**
167
+ * Set column context for text alignment.
168
+ * @param {number} index column index (0-based)
169
+ * @param {number} start column start position (unit: characters)
170
+ * @param {number} width column width (unit: characters)
171
+ * @param {number} align text alignment within column (0: left, 1: center, 2: right)
172
+ * @returns {Promise<string>} commands
173
+ */
174
+ async column(t, e, n, a) {
175
+ return "";
176
+ }
166
177
  /**
167
178
  * Print horizontal rule.
168
179
  * @param {number} width line width (unit: characters)
@@ -204,7 +215,7 @@ class H {
204
215
  * @param {number} dr difference in right position
205
216
  * @returns {Promise<string>} commands
206
217
  */
207
- async vrhr(t, e, i, a) {
218
+ async vrhr(t, e, n, a) {
208
219
  return "";
209
220
  }
210
221
  /**
@@ -329,49 +340,49 @@ const y = {
329
340
  shift: 98,
330
341
  stop: 106
331
342
  };
332
- function j(n, t, e) {
333
- n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[\x00-_])+/, (r) => (r.split("").forEach((s) => e.push((s.charCodeAt(0) + 64) % 96)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push((r.charCodeAt(0) + 64) % 96), ""));
334
- const i = t.slice(1), a = i.search(/[^ -_]/);
335
- /^\d{4,}/.test(t) ? L(y.atoc, t, e) : a >= 0 && i.charCodeAt(a) < 32 ? (e.push(y.shift, t.charCodeAt(0) - 32), j(y.shift, i, e)) : t.length > 0 && E(y.atob, t, e);
343
+ function I(i, t, e) {
344
+ i !== y.shift && e.push(i), t = t.replace(/^((?!\d{4,})[\x00-_])+/, (r) => (r.split("").forEach((s) => e.push((s.charCodeAt(0) + 64) % 96)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push((r.charCodeAt(0) + 64) % 96), ""));
345
+ const n = t.slice(1), a = n.search(/[^ -_]/);
346
+ /^\d{4,}/.test(t) ? B(y.atoc, t, e) : a >= 0 && n.charCodeAt(a) < 32 ? (e.push(y.shift, t.charCodeAt(0) - 32), I(y.shift, n, e)) : t.length > 0 && j(y.atob, t, e);
336
347
  }
337
- function E(n, t, e) {
338
- n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[ -\x7f])+/, (r) => (r.split("").forEach((s) => e.push(s.charCodeAt(0) - 32)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push(r.charCodeAt(0) - 32), ""));
339
- const i = t.slice(1), a = i.search(/[^ -_]/);
340
- /^\d{4,}/.test(t) ? L(y.btoc, t, e) : a >= 0 && i.charCodeAt(a) > 95 ? (e.push(y.shift, t.charCodeAt(0) + 64), E(y.shift, i, e)) : t.length > 0 && j(y.btoa, t, e);
348
+ function j(i, t, e) {
349
+ i !== y.shift && e.push(i), t = t.replace(/^((?!\d{4,})[ -\x7f])+/, (r) => (r.split("").forEach((s) => e.push(s.charCodeAt(0) - 32)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push(r.charCodeAt(0) - 32), ""));
350
+ const n = t.slice(1), a = n.search(/[^ -_]/);
351
+ /^\d{4,}/.test(t) ? B(y.btoc, t, e) : a >= 0 && n.charCodeAt(a) > 95 ? (e.push(y.shift, t.charCodeAt(0) + 64), j(y.shift, n, e)) : t.length > 0 && I(y.btoa, t, e);
341
352
  }
342
- function L(n, t, e) {
343
- n !== y.shift && e.push(n), t = t.replace(/^\d{4,}/g, (a) => a.replace(/\d{2}/g, (r) => (e.push(Number(r)), "")));
344
- const i = t.search(/[^ -_]/);
345
- i >= 0 && t.charCodeAt(i) < 32 ? j(y.ctoa, t, e) : t.length > 0 && E(y.ctob, t, e);
353
+ function B(i, t, e) {
354
+ i !== y.shift && e.push(i), t = t.replace(/^\d{4,}/g, (a) => a.replace(/\d{2}/g, (r) => (e.push(Number(r)), "")));
355
+ const n = t.search(/[^ -_]/);
356
+ n >= 0 && t.charCodeAt(n) < 32 ? I(y.ctoa, t, e) : t.length > 0 && j(y.ctob, t, e);
346
357
  }
347
- function st(n) {
358
+ function st(i) {
348
359
  const t = {};
349
- let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
360
+ let e = i.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
350
361
  if (e.length > 0) {
351
- t.hri = n.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
352
- const i = [], a = e.search(/[^ -_]/);
353
- /^\d{2}$/.test(e) ? i.push(y.startc, Number(e)) : /^\d{4,}/.test(e) ? L(y.startc, e, i) : a >= 0 && e.charCodeAt(a) < 32 ? j(y.starta, e, i) : e.length > 0 && E(y.startb, e, i), i.push(i.reduce((h, o, c) => h + o * c) % 103, y.stop);
354
- const r = n.quietZone ? "a" : "0", s = i.reduce((h, o) => h + y.element[o], r) + r;
355
- t.widths = s.split("").map((h) => parseInt(h, 16) * n.width), t.length = n.width * (i.length * 11 + (n.quietZone ? 22 : 2)), t.height = n.height;
362
+ t.hri = i.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
363
+ const n = [], a = e.search(/[^ -_]/);
364
+ /^\d{2}$/.test(e) ? n.push(y.startc, Number(e)) : /^\d{4,}/.test(e) ? B(y.startc, e, n) : a >= 0 && e.charCodeAt(a) < 32 ? I(y.starta, e, n) : e.length > 0 && j(y.startb, e, n), n.push(n.reduce((h, o, c) => h + o * c) % 103, y.stop);
365
+ const r = i.quietZone ? "a" : "0", s = n.reduce((h, o) => h + y.element[o], r) + r;
366
+ t.widths = s.split("").map((h) => parseInt(h, 16) * i.width), t.length = i.width * (n.length * 11 + (i.quietZone ? 22 : 2)), t.height = i.height;
356
367
  }
357
368
  return t;
358
369
  }
359
370
  const M = {
360
371
  escape: "cU,dA,dB,dC,dD,dE,dF,dG,dH,dI,dJ,dK,dL,dM,dN,dO,dP,dQ,dR,dS,dT,dU,dV,dW,dX,dY,dZ,cA,cB,cC,cD,cE, ,sA,sB,sC,$,%,sF,sG,sH,sI,sJ,+,sL,-,.,/,0,1,2,3,4,5,6,7,8,9,sZ,cF,cG,cH,cI,cJ,cV,A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z,cK,cL,cM,cN,cO,cW,pA,pB,pC,pD,pE,pF,pG,pH,pI,pJ,pK,pL,pM,pN,pO,pP,pQ,pR,pS,pT,pU,pV,pW,pX,pY,pZ,cP,cQ,cR,cS,cT".split(","),
361
- code: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%dcsp".split("").reduce((n, t, e) => (n[t] = e, n), {}),
372
+ code: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%dcsp".split("").reduce((i, t, e) => (i[t] = e, i), {}),
362
373
  element: "131112,111213,111312,111411,121113,121212,121311,111114,131211,141111,211113,211212,211311,221112,221211,231111,112113,112212,112311,122112,132111,111123,111222,111321,121122,131121,212112,212211,211122,211221,221121,222111,112122,112221,122121,123111,121131,311112,311211,321111,112131,113121,211131,121221,312111,311121,122211,111141,1111411".split(","),
363
374
  start: 47,
364
375
  stop: 48
365
376
  };
366
- function rt(n) {
377
+ function rt(i) {
367
378
  const t = {};
368
- let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
379
+ let e = i.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
369
380
  if (e.length > 0) {
370
- t.hri = n.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
371
- const i = e.split("").reduce((s, h) => s + M.escape[h.charCodeAt(0)], "").split("").map((s) => M.code[s]);
372
- i.push(i.reduceRight((s, h, o) => s + h * ((i.length - 1 - o) % 20 + 1)) % 47), i.push(i.reduceRight((s, h, o) => s + h * ((i.length - 1 - o) % 15 + 1)) % 47), i.unshift(M.start), i.push(M.stop);
373
- const a = n.quietZone ? "a" : "0", r = i.reduce((s, h) => s + M.element[h], a) + a;
374
- t.widths = r.split("").map((s) => parseInt(s, 16) * n.width), t.length = n.width * (i.length * 9 + (n.quietZone ? 21 : 1)), t.height = n.height;
381
+ t.hri = i.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
382
+ const n = e.split("").reduce((s, h) => s + M.escape[h.charCodeAt(0)], "").split("").map((s) => M.code[s]);
383
+ n.push(n.reduceRight((s, h, o) => s + h * ((n.length - 1 - o) % 20 + 1)) % 47), n.push(n.reduceRight((s, h, o) => s + h * ((n.length - 1 - o) % 15 + 1)) % 47), n.unshift(M.start), n.push(M.stop);
384
+ const a = i.quietZone ? "a" : "0", r = n.reduce((s, h) => s + M.element[h], a) + a;
385
+ t.widths = r.split("").map((s) => parseInt(s, 16) * i.width), t.length = i.width * (n.length * 9 + (i.quietZone ? 21 : 1)), t.height = i.height;
375
386
  }
376
387
  return t;
377
388
  }
@@ -397,15 +408,15 @@ const at = {
397
408
  C: "2225255",
398
409
  D: "2225552"
399
410
  };
400
- function ot(n) {
411
+ function ot(i) {
401
412
  const t = {};
402
- let e = n.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
413
+ let e = i.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
403
414
  if (e.length > 0) {
404
- t.hri = n.hri, t.text = e;
405
- const i = n.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((s, h) => s + at[h] + "2", i).slice(0, -1) + i;
406
- t.widths = a.split("").map((s) => parseInt(s, 16) * n.width + 1 >> 1);
415
+ t.hri = i.hri, t.text = e;
416
+ const n = i.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((s, h) => s + at[h] + "2", n).slice(0, -1) + n;
417
+ t.widths = a.split("").map((s) => parseInt(s, 16) * i.width + 1 >> 1);
407
418
  const r = [25, 39, 50, 3, 5, 6];
408
- t.length = e.length * r[n.width - 2] - (e.match(/[\d\-$]/g) || []).length * r[n.width + 1] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
419
+ t.length = e.length * r[i.width - 2] - (e.match(/[\d\-$]/g) || []).length * r[i.width + 1] + i.width * (i.quietZone ? 19 : -1), t.height = i.height;
409
420
  }
410
421
  return t;
411
422
  }
@@ -414,20 +425,20 @@ const q = {
414
425
  start: "2222",
415
426
  stop: "522"
416
427
  };
417
- function ht(n) {
428
+ function ht(i) {
418
429
  const t = {};
419
- let e = n.data.replace(/((?!^(\d{2})+$).)*/, "");
430
+ let e = i.data.replace(/((?!^(\d{2})+$).)*/, "");
420
431
  if (e.length > 0) {
421
- t.hri = n.hri, t.text = e;
422
- const i = e.split("").map((o) => Number(o)), a = n.quietZone ? "a" : "0";
432
+ t.hri = i.hri, t.text = e;
433
+ const n = e.split("").map((o) => Number(o)), a = i.quietZone ? "a" : "0";
423
434
  let r = a + q.start, s = 0;
424
- for (; s < i.length; ) {
425
- const o = q.element[i[s++]], c = q.element[i[s++]];
426
- r += o.split("").reduce((l, u, d) => l + u + c[d], "");
435
+ for (; s < n.length; ) {
436
+ const o = q.element[n[s++]], c = q.element[n[s++]];
437
+ r += o.split("").reduce((l, f, d) => l + f + c[d], "");
427
438
  }
428
- r += q.stop + a, t.widths = r.split("").map((o) => parseInt(o, 16) * n.width + 1 >> 1);
439
+ r += q.stop + a, t.widths = r.split("").map((o) => parseInt(o, 16) * i.width + 1 >> 1);
429
440
  const h = [16, 25, 32, 17, 26, 34];
430
- t.length = e.length * h[n.width - 2] + h[n.width + 1] + n.width * (n.quietZone ? 20 : 0), t.height = n.height;
441
+ t.length = e.length * h[i.width - 2] + h[i.width + 1] + i.width * (i.quietZone ? 20 : 0), t.height = i.height;
431
442
  }
432
443
  return t;
433
444
  }
@@ -477,19 +488,19 @@ const ct = {
477
488
  "%": "222525252",
478
489
  "*": "252252522"
479
490
  };
480
- function lt(n) {
491
+ function lt(i) {
481
492
  const t = {};
482
- let e = n.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
493
+ let e = i.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
483
494
  if (e.length > 0) {
484
- e = e.replace(/^\*?([^*]+)\*?$/, "*$1*"), t.hri = n.hri, t.text = e;
485
- const i = n.quietZone ? "a" : "0", a = e.split("").reduce((s, h) => s + ct[h] + "2", i).slice(0, -1) + i;
486
- t.widths = a.split("").map((s) => parseInt(s, 16) * n.width + 1 >> 1);
495
+ e = e.replace(/^\*?([^*]+)\*?$/, "*$1*"), t.hri = i.hri, t.text = e;
496
+ const n = i.quietZone ? "a" : "0", a = e.split("").reduce((s, h) => s + ct[h] + "2", n).slice(0, -1) + n;
497
+ t.widths = a.split("").map((s) => parseInt(s, 16) * i.width + 1 >> 1);
487
498
  const r = [29, 45, 58];
488
- t.length = e.length * r[n.width - 2] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
499
+ t.length = e.length * r[i.width - 2] + i.width * (i.quietZone ? 19 : -1), t.height = i.height;
489
500
  }
490
501
  return t;
491
502
  }
492
- const b = {
503
+ const x = {
493
504
  a: "3211,2221,2122,1411,1132,1231,1114,1312,1213,3112".split(","),
494
505
  b: "1123,1222,2212,1141,2311,1321,4111,2131,3121,2113".split(","),
495
506
  c: "3211,2221,2122,1411,1132,1231,1114,1312,1213,3112".split(","),
@@ -497,102 +508,102 @@ const b = {
497
508
  p: "aaaaaa,aababb,aabbab,aabbba,abaabb,abbaab,abbbaa,ababab,ababba,abbaba".split(","),
498
509
  e: "bbbaaa,bbabaa,bbaaba,bbaaab,babbaa,baabba,baaabb,bababa,babaab,baabab".split(",")
499
510
  };
500
- function dt(n) {
501
- const t = n.slice(0, 3);
502
- switch (n[6]) {
511
+ function dt(i) {
512
+ const t = i.slice(0, 3);
513
+ switch (i[6]) {
503
514
  case 0:
504
515
  case 1:
505
516
  case 2:
506
- t.push(n[6], 0, 0, 0, 0, n[3], n[4], n[5]);
517
+ t.push(i[6], 0, 0, 0, 0, i[3], i[4], i[5]);
507
518
  break;
508
519
  case 3:
509
- t.push(n[3], 0, 0, 0, 0, 0, n[4], n[5]);
520
+ t.push(i[3], 0, 0, 0, 0, 0, i[4], i[5]);
510
521
  break;
511
522
  case 4:
512
- t.push(n[3], n[4], 0, 0, 0, 0, 0, n[5]);
523
+ t.push(i[3], i[4], 0, 0, 0, 0, 0, i[5]);
513
524
  break;
514
525
  default:
515
- t.push(n[3], n[4], n[5], 0, 0, 0, 0, n[6]);
526
+ t.push(i[3], i[4], i[5], 0, 0, 0, 0, i[6]);
516
527
  break;
517
528
  }
518
- return t.push(n[7]), t;
529
+ return t.push(i[7]), t;
519
530
  }
520
- function G(n) {
521
- const t = {}, e = n.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((i) => Number(i));
531
+ function K(i) {
532
+ const t = {}, e = i.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((n) => Number(n));
522
533
  if (e.length > 0) {
523
- e[12] = 0, e[12] = (10 - e.reduce((a, r, s) => a + r * (s % 2 * 2 + 1)) % 10) % 10, t.hri = n.hri, t.text = e.join("");
524
- let i = (n.quietZone ? "b" : "0") + b.g[0];
525
- for (let a = 1; a < 7; a++) i += b[b.p[e[0]][a - 1]][e[a]];
526
- i += b.g[1];
527
- for (let a = 7; a < 13; a++) i += b.c[e[a]];
528
- i += b.g[0] + (n.quietZone ? "7" : "0"), t.widths = i.split("").map((a) => parseInt(a, 16) * n.width), t.length = n.width * (n.quietZone ? 113 : 95), t.height = n.height;
534
+ e[12] = 0, e[12] = (10 - e.reduce((a, r, s) => a + r * (s % 2 * 2 + 1)) % 10) % 10, t.hri = i.hri, t.text = e.join("");
535
+ let n = (i.quietZone ? "b" : "0") + x.g[0];
536
+ for (let a = 1; a < 7; a++) n += x[x.p[e[0]][a - 1]][e[a]];
537
+ n += x.g[1];
538
+ for (let a = 7; a < 13; a++) n += x.c[e[a]];
539
+ n += x.g[0] + (i.quietZone ? "7" : "0"), t.widths = n.split("").map((a) => parseInt(a, 16) * i.width), t.length = i.width * (i.quietZone ? 113 : 95), t.height = i.height;
529
540
  }
530
541
  return t;
531
542
  }
532
- function gt(n) {
533
- const t = {}, e = n.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((i) => Number(i));
543
+ function gt(i) {
544
+ const t = {}, e = i.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((n) => Number(n));
534
545
  if (e.length > 0) {
535
- e[7] = 0, e[7] = (10 - e.reduce((r, s, h) => r + s * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = n.hri, t.text = e.join("");
536
- const i = n.quietZone ? "7" : "0";
537
- let a = i + b.g[0];
538
- for (let r = 0; r < 4; r++) a += b.a[e[r] ?? 0];
539
- a += b.g[1];
540
- for (let r = 4; r < 8; r++) a += b.c[e[r] ?? 0];
541
- a += b.g[0] + i, t.widths = a.split("").map((r) => parseInt(r, 16) * n.width), t.length = n.width * (n.quietZone ? 81 : 67), t.height = n.height;
546
+ e[7] = 0, e[7] = (10 - e.reduce((r, s, h) => r + s * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = i.hri, t.text = e.join("");
547
+ const n = i.quietZone ? "7" : "0";
548
+ let a = n + x.g[0];
549
+ for (let r = 0; r < 4; r++) a += x.a[e[r] ?? 0];
550
+ a += x.g[1];
551
+ for (let r = 4; r < 8; r++) a += x.c[e[r] ?? 0];
552
+ a += x.g[0] + n, t.widths = a.split("").map((r) => parseInt(r, 16) * i.width), t.length = i.width * (i.quietZone ? 81 : 67), t.height = i.height;
542
553
  }
543
554
  return t;
544
555
  }
545
- function ut(n) {
556
+ function ut(i) {
546
557
  const t = {
547
- data: "0" + n.data,
548
- hri: n.hri,
549
- width: n.width,
550
- height: n.height,
551
- quietZone: n.quietZone
552
- }, e = G(t);
558
+ data: "0" + i.data,
559
+ hri: i.hri,
560
+ width: i.width,
561
+ height: i.height,
562
+ quietZone: i.quietZone
563
+ }, e = K(t);
553
564
  return e.text && (e.text = e.text.slice(1)), e;
554
565
  }
555
- function pt(n) {
556
- const t = {}, e = n.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((i) => Number(i));
566
+ function pt(i) {
567
+ const t = {}, e = i.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((n) => Number(n));
557
568
  if (e.length > 0) {
558
- e[7] = 0, e[7] = (10 - dt(e).reduce((r, s, h) => r + s * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = n.hri, t.text = e.join("");
559
- const i = n.quietZone ? "7" : "0";
560
- let a = i + b.g[0];
561
- for (let r = 1; r < 7; r++) a += b[b.e[e[7] ?? 0][r - 1]][e[r] ?? 0];
562
- a += b.g[2] + i, t.widths = a.split("").map((r) => parseInt(r, 16) * n.width), t.length = n.width * (n.quietZone ? 65 : 51), t.height = n.height;
569
+ e[7] = 0, e[7] = (10 - dt(e).reduce((r, s, h) => r + s * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = i.hri, t.text = e.join("");
570
+ const n = i.quietZone ? "7" : "0";
571
+ let a = n + x.g[0];
572
+ for (let r = 1; r < 7; r++) a += x[x.e[e[7] ?? 0][r - 1]][e[r] ?? 0];
573
+ a += x.g[2] + n, t.widths = a.split("").map((r) => parseInt(r, 16) * i.width), t.length = i.width * (i.quietZone ? 65 : 51), t.height = i.height;
563
574
  }
564
575
  return t;
565
576
  }
566
- function K(n) {
577
+ function J(i) {
567
578
  let t = {};
568
- switch (n.type) {
579
+ switch (i.type) {
569
580
  case "upc":
570
- t = n.data.length < 9 ? pt(n) : ut(n);
581
+ t = i.data.length < 9 ? pt(i) : ut(i);
571
582
  break;
572
583
  case "ean":
573
584
  case "jan":
574
- t = n.data.length < 9 ? gt(n) : G(n);
585
+ t = i.data.length < 9 ? gt(i) : K(i);
575
586
  break;
576
587
  case "code39":
577
- t = lt(n);
588
+ t = lt(i);
578
589
  break;
579
590
  case "itf":
580
- t = ht(n);
591
+ t = ht(i);
581
592
  break;
582
593
  case "codabar":
583
594
  case "nw7":
584
- t = ot(n);
595
+ t = ot(i);
585
596
  break;
586
597
  case "code93":
587
- t = rt(n);
598
+ t = rt(i);
588
599
  break;
589
600
  case "code128":
590
- t = st(n);
601
+ t = st(i);
591
602
  break;
592
603
  }
593
604
  return t;
594
605
  }
595
- class I extends H {
606
+ class z extends H {
596
607
  charWidth = 12;
597
608
  receiptId = "";
598
609
  svgWidth = 576;
@@ -647,12 +658,12 @@ class I extends H {
647
658
  break;
648
659
  }
649
660
  t.style.length > 0 && (t.style = `<style type="text/css"><![CDATA[${t.style}]]></style>`), t.lang.length > 0 && (t.lang = ` xml:lang="${t.lang}"`), this.fontSize = t.size;
650
- const e = this.calculatedWidth(), i = this.calculatedHeight();
651
- return `<svg width="${e}px" height="${i}px" viewBox="0 0 ${e} ${i}" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">${t.style}<defs><filter id="receipt-${this.receiptId}" x="0" y="0" width="100%" height="100%"><feFlood flood-color="#000"/><feComposite in2="SourceGraphic" operator="out"/></filter></defs><rect width="100%" height="100%" fill="white" /><g font-family="${t.font}" fill="#000" font-size="${t.size}" dominant-baseline="text-after-edge" text-anchor="middle"${t.lang}>${this.svgContent}</g></svg>
661
+ const e = this.calculatedWidth(), n = this.calculatedHeight();
662
+ return `<svg width="${e}px" height="${n}px" viewBox="0 0 ${e} ${n}" preserveAspectRatio="xMinYMin meet" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1">${t.style}<defs><filter id="receipt-${this.receiptId}" x="0" y="0" width="100%" height="100%"><feFlood flood-color="#000"/><feComposite in2="SourceGraphic" operator="out"/></filter></defs><rect width="100%" height="100%" fill="white" /><g font-family="${t.font}" fill="#000" font-size="${t.size}" dominant-baseline="text-after-edge" text-anchor="middle"${t.lang}>${this.svgContent}</g></svg>
652
663
  `;
653
664
  }
654
665
  // set print area:
655
- async area(t, e, i) {
666
+ async area(t, e, n) {
656
667
  return this.lineMargin = t, this.lineWidth = e, "";
657
668
  }
658
669
  // set line alignment:
@@ -669,30 +680,30 @@ class I extends H {
669
680
  }
670
681
  // print horizontal rule:
671
682
  async hr(t) {
672
- const e = this.charWidth, i = `<path d="M0,${e}h${e * t}" fill="none" stroke="#000" stroke-width="2"/>`;
673
- return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${i}</g>`, "";
683
+ const e = this.charWidth, n = `<path d="M0,${e}h${e * t}" fill="none" stroke="#000" stroke-width="2"/>`;
684
+ return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${n}</g>`, "";
674
685
  }
675
686
  // print vertical rules:
676
687
  async vr(t, e) {
677
- const i = this.charWidth, a = i / 2, r = (i + i) * e, s = '<path d="' + t.reduce((h, o) => h + `m${i * o + i},${-r}v${r}`, `M${a},0v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
678
- return this.svgContent += `<g transform="translate(${this.lineMargin * i},${this.svgHeight})">${s}</g>`, "";
688
+ const n = this.charWidth, a = n / 2, r = (n + n) * e, s = '<path d="' + t.reduce((h, o) => h + `m${n * o + n},${-r}v${r}`, `M${a},0v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
689
+ return this.svgContent += `<g transform="translate(${this.lineMargin * n},${this.svgHeight})">${s}</g>`, "";
679
690
  }
680
691
  // start rules:
681
692
  async vrstart(t) {
682
- const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((r, s) => r + `h${e * s}h${i}v${e}m0,${-e}h${i}`, `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`).replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
693
+ const e = this.charWidth, n = e / 2, a = '<path d="' + t.reduce((r, s) => r + `h${e * s}h${n}v${e}m0,${-e}h${n}`, `M${n},${e + e}v${-n}q0,${-n},${n},${-n}`).replace(/h\d+v\d+m0,-\d+h\d+$/, `q${n},0,${n},${n}v${n}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
683
694
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
684
695
  }
685
696
  // stop rules:
686
697
  async vrstop(t) {
687
- const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((r, s) => r + `h${e * s}h${i}v${-e}m0,${e}h${i}`, `M${i},0v${i}q0,${i},${i},${i}`).replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
698
+ const e = this.charWidth, n = e / 2, a = '<path d="' + t.reduce((r, s) => r + `h${e * s}h${n}v${-e}m0,${e}h${n}`, `M${n},0v${n}q0,${n},${n},${n}`).replace(/h\d+v-\d+m0,\d+h\d+$/, `q${n},0,${n},${-n}v${-n}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
688
699
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
689
700
  }
690
701
  // print vertical and horizontal rules:
691
- async vrhr(t, e, i, a) {
692
- const r = this.charWidth, s = r / 2, h = '<path d="' + t.reduce((c, l) => c + `h${r * l}h${s}v${-r}m0,${r}h${s}`, `M${s},0` + (i > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`)).replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${s},0,${s},${-s}v${-s}` : `h${s}v${-r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
693
- this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(-i, 0)) * r},${this.svgHeight})">${h}</g>`;
694
- const o = '<path d="' + e.reduce((c, l) => c + `h${r * l}h${s}v${r}m0,${-r}h${s}`, `M${s},${r + r}` + (i < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`)).replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${s},0,${s},${s}v${s}` : `h${s}v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
695
- return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(i, 0)) * r},${this.svgHeight})">${o}</g>`, "";
702
+ async vrhr(t, e, n, a) {
703
+ const r = this.charWidth, s = r / 2, h = '<path d="' + t.reduce((c, l) => c + `h${r * l}h${s}v${-r}m0,${r}h${s}`, `M${s},0` + (n > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`)).replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${s},0,${s},${-s}v${-s}` : `h${s}v${-r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
704
+ this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(-n, 0)) * r},${this.svgHeight})">${h}</g>`;
705
+ const o = '<path d="' + e.reduce((c, l) => c + `h${r * l}h${s}v${r}m0,${-r}h${s}`, `M${s},${r + r}` + (n < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`)).replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${s},0,${s},${s}v${s}` : `h${s}v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
706
+ return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(n, 0)) * r},${this.svgHeight})">${o}</g>`, "";
696
707
  }
697
708
  // set line spacing and feed new line:
698
709
  async vrlf(t) {
@@ -717,8 +728,8 @@ class I extends H {
717
728
  }
718
729
  // scale up text:
719
730
  async wh(t) {
720
- const e = t < 2 ? t + 1 : t - 1, i = t < 3 ? t : t - 1;
721
- return this.textAttributes.transform = `scale(${e},${i})`, this.lineHeight = Math.max(this.lineHeight, i), this.textScale = e, "";
731
+ const e = t < 2 ? t + 1 : t - 1, n = t < 3 ? t : t - 1;
732
+ return this.textAttributes.transform = `scale(${e},${n})`, this.lineHeight = Math.max(this.lineHeight, n), this.textScale = e, "";
722
733
  }
723
734
  // cancel text decoration:
724
735
  async normal() {
@@ -726,10 +737,10 @@ class I extends H {
726
737
  }
727
738
  // print text:
728
739
  async text(t, e) {
729
- let i = this.textPosition;
740
+ let n = this.textPosition;
730
741
  const a = this.arrayFrom(t, e).reduce((s, h) => {
731
- const o = this.measureText(h, e) * this.textScale, c = Math.floor((i + o / 2) * this.charWidth / this.textScale);
732
- return i += o, s + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
742
+ const o = this.measureText(h, e) * this.textScale, c = Math.floor((n + o / 2) * this.charWidth / this.textScale);
743
+ return n += o, s + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
733
744
  }, ""), r = Object.keys(this.textAttributes).reduce((s, h) => s + ` ${h}="${this.textAttributes[h]}"`, "");
734
745
  return this.textElement += `<text${r}>${a}</text>`, this.textPosition += this.measureText(t, e) * this.textScale, "";
735
746
  }
@@ -744,15 +755,15 @@ class I extends H {
744
755
  }
745
756
  // print image:
746
757
  async image(t) {
747
- const e = V(t), i = new DataView(e.buffer), a = i.getUint32(16, !1), r = i.getUint32(20, !1), s = `<image href="data:image/png;base64,${O(e)}" x="0" y="0" width="${a}" height="${r}"/>`, h = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - a) * this.lineAlign / 2);
758
+ const e = O(t), n = new DataView(e.buffer), a = n.getUint32(16, !1), r = n.getUint32(20, !1), s = `<image href="data:image/png;base64,${_(e)}" x="0" y="0" width="${a}" height="${r}"/>`, h = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - a) * this.lineAlign / 2);
748
759
  return this.svgContent += `<g transform="translate(${h},${this.svgHeight})">${s}</g>`, this.svgHeight += r, "";
749
760
  }
750
761
  // print QR Code:
751
762
  async qrcode(t, e) {
752
- const i = _({
763
+ const n = G({
753
764
  data: t.data,
754
765
  ec: t.level == "l" ? C.L : t.level == "m" ? C.M : t.level == "q" ? C.Q : C.H
755
- }), a = i.width, r = t.cell, s = await it(i, {
766
+ }), a = n.width, r = t.cell, s = await it(n, {
756
767
  moduleSize: r,
757
768
  margin: t.quietZone ? 4 : 0,
758
769
  output: "path"
@@ -763,12 +774,12 @@ class I extends H {
763
774
  }
764
775
  // print barcode:
765
776
  async barcode(t, e) {
766
- const i = K(t), a = i.height;
767
- if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
768
- const r = i.length, s = a + (i.hri ? this.charWidth * 2 + 2 : 0);
777
+ const n = J(t), a = n.height;
778
+ if (a !== void 0 && "length" in n && n.length !== void 0 && n.widths) {
779
+ const r = n.length, s = a + (n.hri ? this.charWidth * 2 + 2 : 0);
769
780
  let h = '<path d="';
770
- if (i.widths.reduce((c, l, u) => (u % 2 === 1 && (h += `M${c},0h${l}v${a}h${-l}z`), c + l), 0), h += '" fill="#000"/>', i.hri && i.text) {
771
- const c = Math.floor((r - (this.measureText(i.text, e) - 1) * this.charWidth) / 2), l = this.arrayFrom(i.text, e).reduce((u, d, g) => u + `<tspan x="${c + this.charWidth * g}">${d.replace(/[ &<>]/g, (p) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[p] || p)}</tspan>`, "");
781
+ if (n.widths.reduce((c, l, f) => (f % 2 === 1 && (h += `M${c},0h${l}v${a}h${-l}z`), c + l), 0), h += '" fill="#000"/>', n.hri && n.text) {
782
+ const c = Math.floor((r - (this.measureText(n.text, e) - 1) * this.charWidth) / 2), l = this.arrayFrom(n.text, e).reduce((f, d, g) => f + `<tspan x="${c + this.charWidth * g}">${d.replace(/[ &<>]/g, (u) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[u] || u)}</tspan>`, "");
772
783
  h += `<text y="${s}">${l}</text>`;
773
784
  }
774
785
  const o = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - r) * this.lineAlign / 2);
@@ -966,164 +977,164 @@ const ft = /* @__PURE__ */ new Set([
966
977
  rArr: "⇒",
967
978
  dArr: "⇓",
968
979
  hArr: "⇔"
969
- }, T = {};
970
- for (const [n, t] of Object.entries($t))
971
- T[t] || (T[t] = n);
972
- function F(n, t = !1) {
973
- if (!n || typeof n != "string")
974
- return n;
975
- let e = n;
980
+ }, V = {};
981
+ for (const [i, t] of Object.entries($t))
982
+ V[t] || (V[t] = i);
983
+ function F(i, t = !1) {
984
+ if (!i || typeof i != "string")
985
+ return i;
986
+ let e = i;
976
987
  return e = e.replace(/&/g, "&amp;"), e = e.replace(/</g, "&lt;"), e = e.replace(/>/g, "&gt;"), t && (e = e.replace(/"/g, "&quot;")), e;
977
988
  }
978
- function mt(n) {
979
- return n.replace(/\]\]>/g, "]]]]><![CDATA[>");
989
+ function mt(i) {
990
+ return i.replace(/\]\]>/g, "]]]]><![CDATA[>");
980
991
  }
981
- function yt(n) {
982
- return n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
992
+ function yt(i) {
993
+ return i.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
983
994
  }
984
995
  const vt = {
985
996
  className: "class",
986
997
  htmlFor: "for"
987
998
  };
988
- function bt(n, t) {
989
- return t === "reactName" ? n : t === "exactName" || t === "eitherName" ? vt[n] ?? n : n;
999
+ function bt(i, t) {
1000
+ return t === "reactName" ? i : t === "exactName" || t === "eitherName" ? vt[i] ?? i : i;
990
1001
  }
991
- function R(n, t = {}) {
1002
+ function R(i, t = {}) {
992
1003
  const e = [];
993
- let i, a, r;
994
- if (n && typeof n == "object" && "node" in n) {
995
- const l = n;
996
- i = l.node, a = l.xml ?? t.xml, r = l.doctype ?? t.doctype;
1004
+ let n, a, r;
1005
+ if (i && typeof i == "object" && "node" in i) {
1006
+ const l = i;
1007
+ n = l.node, a = l.xml ?? t.xml, r = l.doctype ?? t.doctype;
997
1008
  } else
998
- i = n, a = t.xml, r = t.doctype;
1009
+ n = i, a = t.xml, r = t.doctype;
999
1010
  a && (e.push(a), a.endsWith(`
1000
1011
  `) || e.push(`
1001
1012
  `)), r && (e.push(r), r.endsWith(`
1002
1013
  `) || e.push(`
1003
1014
  `));
1004
1015
  const s = t.useCDataForScripts ?? !1, h = t.useCDataForStyles ?? !1, o = t.voidTrailingSlash ?? !0, c = t.attributeNaming ?? "eitherName";
1005
- return P(i, e, "HTML", s, h, o, c), e.join("");
1016
+ return P(n, e, "HTML", s, h, o, c), e.join("");
1006
1017
  }
1007
- function P(n, t, e, i, a, r, s) {
1008
- if (n != null) {
1009
- if (typeof n == "string") {
1010
- t.push(F(n, !1));
1018
+ function P(i, t, e, n, a, r, s) {
1019
+ if (i != null) {
1020
+ if (typeof i == "string") {
1021
+ t.push(F(i, !1));
1011
1022
  return;
1012
1023
  }
1013
- if (typeof n == "number" || typeof n == "bigint") {
1014
- t.push(String(n));
1024
+ if (typeof i == "number" || typeof i == "bigint") {
1025
+ t.push(String(i));
1015
1026
  return;
1016
1027
  }
1017
- if (typeof n == "boolean") {
1018
- t.push(String(n));
1028
+ if (typeof i == "boolean") {
1029
+ t.push(String(i));
1019
1030
  return;
1020
1031
  }
1021
- if (Array.isArray(n)) {
1022
- for (const h of n)
1023
- P(h, t, e, i, a, r, s);
1032
+ if (Array.isArray(i)) {
1033
+ for (const h of i)
1034
+ P(h, t, e, n, a, r, s);
1024
1035
  return;
1025
1036
  }
1026
- if (typeof n != "function" && typeof n != "symbol" && !(n && typeof n == "object" && "then" in n && typeof n.then == "function") && n && typeof n == "object" && "type" in n && "props" in n) {
1027
- xt(n, t, e, i, a, r, s);
1037
+ if (typeof i != "function" && typeof i != "symbol" && !(i && typeof i == "object" && "then" in i && typeof i.then == "function") && i && typeof i == "object" && "type" in i && "props" in i) {
1038
+ xt(i, t, e, n, a, r, s);
1028
1039
  return;
1029
1040
  }
1030
1041
  }
1031
1042
  }
1032
- function xt(n, t, e, i, a, r, s) {
1043
+ function xt(i, t, e, n, a, r, s) {
1033
1044
  var h;
1034
- const o = n.type;
1045
+ const o = i.type;
1035
1046
  let c = e;
1036
- if (o === "svg" ? c = "SVG" : o === "math" && (c = "MATHML"), t.push("<"), t.push(o), n.props)
1037
- for (const [d, g] of Object.entries(n.props)) {
1047
+ if (o === "svg" ? c = "SVG" : o === "math" && (c = "MATHML"), t.push("<"), t.push(o), i.props)
1048
+ for (const [d, g] of Object.entries(i.props)) {
1038
1049
  if (d === "children" || g === !1 || g === null || g === void 0)
1039
1050
  continue;
1040
- const p = bt(d, s);
1051
+ const u = bt(d, s);
1041
1052
  if (g === !0)
1042
- t.push(" "), t.push(p);
1053
+ t.push(" "), t.push(u);
1043
1054
  else if (d === "style" && typeof g == "object") {
1044
- const f = kt(g);
1045
- f && (t.push(' style="'), t.push(F(f, !0)), t.push('"'));
1055
+ const p = Wt(g);
1056
+ p && (t.push(' style="'), t.push(F(p, !0)), t.push('"'));
1046
1057
  } else
1047
- t.push(" "), t.push(p), t.push('="'), t.push(F(String(g), !0)), t.push('"');
1058
+ t.push(" "), t.push(u), t.push('="'), t.push(F(String(g), !0)), t.push('"');
1048
1059
  }
1049
- const l = (h = n.props) == null ? void 0 : h.children;
1050
- let u;
1051
- if (l && typeof l == "object" && "then" in l && typeof l.then == "function" ? u = !1 : u = l != null && (Array.isArray(l) && l.length > 0 || !Array.isArray(l) && l !== !1), ft.has(o))
1060
+ const l = (h = i.props) == null ? void 0 : h.children;
1061
+ let f;
1062
+ if (l && typeof l == "object" && "then" in l && typeof l.then == "function" ? f = !1 : f = l != null && (Array.isArray(l) && l.length > 0 || !Array.isArray(l) && l !== !1), ft.has(o))
1052
1063
  r ? t.push(" />") : t.push(">");
1053
- else if (u) {
1064
+ else if (f) {
1054
1065
  t.push(">");
1055
1066
  const d = l;
1056
- o === "script" && i || o === "style" && a ? (t.push("<![CDATA["), J(d, t, c, i, a, r, s), t.push("]]>")) : o === "script" || o === "style" ? Q(d, t) : P(d, t, c, i, a, r, s), t.push("</"), t.push(o), t.push(">");
1067
+ o === "script" && n || o === "style" && a ? (t.push("<![CDATA["), Q(d, t, c, n, a, r, s), t.push("]]>")) : o === "script" || o === "style" ? X(d, t) : P(d, t, c, n, a, r, s), t.push("</"), t.push(o), t.push(">");
1057
1068
  } else wt.has(o), t.push("></"), t.push(o), t.push(">");
1058
1069
  }
1059
- function J(n, t, e, i, a, r, s, h) {
1060
- if (n != null) {
1061
- if (typeof n == "string") {
1062
- t.push(mt(n));
1070
+ function Q(i, t, e, n, a, r, s, h) {
1071
+ if (i != null) {
1072
+ if (typeof i == "string") {
1073
+ t.push(mt(i));
1063
1074
  return;
1064
1075
  }
1065
- if (typeof n == "number" || typeof n == "bigint" || typeof n == "boolean") {
1066
- t.push(String(n));
1076
+ if (typeof i == "number" || typeof i == "bigint" || typeof i == "boolean") {
1077
+ t.push(String(i));
1067
1078
  return;
1068
1079
  }
1069
- if (Array.isArray(n)) {
1070
- for (const o of n)
1071
- J(o, t, e, i, a, r, s);
1080
+ if (Array.isArray(i)) {
1081
+ for (const o of i)
1082
+ Q(o, t, e, n, a, r, s);
1072
1083
  return;
1073
1084
  }
1074
- P(n, t, e, i, a, r, s);
1085
+ P(i, t, e, n, a, r, s);
1075
1086
  }
1076
1087
  }
1077
- function Q(n, t) {
1078
- if (n != null) {
1079
- if (typeof n == "string") {
1080
- t.push(n);
1088
+ function X(i, t) {
1089
+ if (i != null) {
1090
+ if (typeof i == "string") {
1091
+ t.push(i);
1081
1092
  return;
1082
1093
  }
1083
- if (typeof n == "number" || typeof n == "bigint" || typeof n == "boolean") {
1084
- t.push(String(n));
1094
+ if (typeof i == "number" || typeof i == "bigint" || typeof i == "boolean") {
1095
+ t.push(String(i));
1085
1096
  return;
1086
1097
  }
1087
- if (Array.isArray(n)) {
1088
- for (const e of n)
1089
- Q(e, t);
1098
+ if (Array.isArray(i)) {
1099
+ for (const e of i)
1100
+ X(e, t);
1090
1101
  return;
1091
1102
  }
1092
1103
  }
1093
1104
  }
1094
- function kt(n) {
1105
+ function Wt(i) {
1095
1106
  const t = [];
1096
- for (const [e, i] of Object.entries(n))
1097
- if (i) {
1107
+ for (const [e, n] of Object.entries(i))
1108
+ if (n) {
1098
1109
  const a = yt(e);
1099
- t.push(`${a}: ${i}`);
1110
+ t.push(`${a}: ${n}`);
1100
1111
  }
1101
1112
  return t.join("; ");
1102
1113
  }
1103
- async function U(n) {
1104
- if (n == null)
1105
- return n;
1106
- if (n && typeof n == "object" && "then" in n && typeof n.then == "function") {
1107
- const t = await n;
1108
- return U(t);
1114
+ async function N(i) {
1115
+ if (i == null)
1116
+ return i;
1117
+ if (i && typeof i == "object" && "then" in i && typeof i.then == "function") {
1118
+ const t = await i;
1119
+ return N(t);
1109
1120
  }
1110
- if (typeof n == "string" || typeof n == "number" || typeof n == "boolean" || typeof n == "bigint")
1111
- return n;
1112
- if (typeof n != "function" && typeof n != "symbol") {
1113
- if (Array.isArray(n))
1121
+ if (typeof i == "string" || typeof i == "number" || typeof i == "boolean" || typeof i == "bigint")
1122
+ return i;
1123
+ if (typeof i != "function" && typeof i != "symbol") {
1124
+ if (Array.isArray(i))
1114
1125
  return await Promise.all(
1115
- n.filter((t) => !(t == null || typeof t == "function" || typeof t == "symbol")).map((t) => U(t))
1126
+ i.filter((t) => !(t == null || typeof t == "function" || typeof t == "symbol")).map((t) => N(t))
1116
1127
  );
1117
- if (n && typeof n == "object" && "type" in n && "props" in n) {
1118
- const t = n, e = {};
1119
- for (const [i, a] of Object.entries(t.props))
1120
- if (i === "children") {
1121
- const r = await U(a);
1128
+ if (i && typeof i == "object" && "type" in i && "props" in i) {
1129
+ const t = i, e = {};
1130
+ for (const [n, a] of Object.entries(t.props))
1131
+ if (n === "children") {
1132
+ const r = await N(a);
1122
1133
  r != null && (e.children = r);
1123
1134
  } else {
1124
1135
  if (typeof a == "function" || typeof a == "symbol")
1125
1136
  continue;
1126
- a != null && (e[i] = a);
1137
+ a != null && (e[n] = a);
1127
1138
  }
1128
1139
  return {
1129
1140
  type: t.type,
@@ -1132,28 +1143,28 @@ async function U(n) {
1132
1143
  }
1133
1144
  }
1134
1145
  }
1135
- function Wt(n, t = {}) {
1136
- return n && typeof n == "object" && "node" in n ? R(n, t) : n === void 0 ? "" : R(n, t);
1146
+ function kt(i, t = {}) {
1147
+ return i && typeof i == "object" && "node" in i ? R(i, t) : i === void 0 ? "" : R(i, t);
1137
1148
  }
1138
- async function At(n) {
1139
- return await U(n);
1149
+ async function At(i) {
1150
+ return await N(i);
1140
1151
  }
1141
- function St(...n) {
1152
+ function St(...i) {
1142
1153
  const t = new Uint8Array(
1143
- n.reduceRight((i, a) => i + a.length, 0)
1154
+ i.reduceRight((n, a) => n + a.length, 0)
1144
1155
  );
1145
1156
  let e = 0;
1146
- for (const i of n)
1147
- t.set(i, e), e += i.length;
1157
+ for (const n of i)
1158
+ t.set(n, e), e += n.length;
1148
1159
  return t;
1149
1160
  }
1150
- async function Ct(n) {
1161
+ async function Ct(i) {
1151
1162
  const t = new CompressionStream("deflate"), e = t.writable.getWriter();
1152
- e.write(n), e.close();
1153
- const i = t.readable.getReader(), a = [];
1163
+ e.write(i), e.close();
1164
+ const n = t.readable.getReader(), a = [];
1154
1165
  let r = 0;
1155
1166
  for (; ; ) {
1156
- const { done: o, value: c } = await i.read();
1167
+ const { done: o, value: c } = await n.read();
1157
1168
  if (o) break;
1158
1169
  a.push(c), r += c.length;
1159
1170
  }
@@ -1163,43 +1174,43 @@ async function Ct(n) {
1163
1174
  s.set(o, h), h += o.length;
1164
1175
  return s;
1165
1176
  }
1166
- const X = new Uint32Array(256);
1167
- for (let n = 0; n < 256; n++) {
1168
- let t = n;
1177
+ const Y = new Uint32Array(256);
1178
+ for (let i = 0; i < 256; i++) {
1179
+ let t = i;
1169
1180
  for (let e = 0; e < 8; e++)
1170
1181
  t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
1171
- X[n] = t;
1182
+ Y[i] = t;
1172
1183
  }
1173
- function Mt(n) {
1184
+ function Mt(i) {
1174
1185
  let t = 4294967295;
1175
- for (let e = 0; e < n.length; e++)
1176
- t = X[(t ^ n[e]) & 255] ^ t >>> 8;
1186
+ for (let e = 0; e < i.length; e++)
1187
+ t = Y[(t ^ i[e]) & 255] ^ t >>> 8;
1177
1188
  return (t ^ 4294967295) >>> 0;
1178
1189
  }
1179
1190
  const Ht = new TextEncoder();
1180
- function N(n, t) {
1181
- const e = new Uint8Array(8 + t.length + 4), i = new DataView(e.buffer);
1182
- i.setUint32(0, t.length), e.set(Ht.encode(n), 4), e.set(t, 8);
1191
+ function U(i, t) {
1192
+ const e = new Uint8Array(8 + t.length + 4), n = new DataView(e.buffer);
1193
+ n.setUint32(0, t.length), e.set(Ht.encode(i), 4), e.set(t, 8);
1183
1194
  const a = Mt(e.subarray(4, e.length - 4));
1184
- return i.setUint32(e.length - 4, a), e;
1195
+ return n.setUint32(e.length - 4, a), e;
1185
1196
  }
1186
- function qt(n) {
1187
- return n <= 1 ? 1 : n <= 3 ? 2 : n <= 15 ? 4 : 8;
1197
+ function qt(i) {
1198
+ return i <= 1 ? 1 : i <= 3 ? 2 : i <= 15 ? 4 : 8;
1188
1199
  }
1189
- function Nt(n, t, e, i) {
1190
- const a = 8 / i, r = Math.ceil(t / a) + 1, s = new Uint8Array(r * e), h = new DataView(s.buffer);
1200
+ function Ut(i, t, e, n) {
1201
+ const a = 8 / n, r = Math.ceil(t / a) + 1, s = new Uint8Array(r * e), h = new DataView(s.buffer);
1191
1202
  for (let o = 0; o < e; o++) {
1192
1203
  h.setUint8(o * r, 0);
1193
1204
  for (let c = 0; c < t; c++) {
1194
- const l = n.getUint8(o * t + c), u = o * r + 1 + Math.floor(c / a), d = (a - 1 - c % a) * i, g = h.getUint8(u);
1195
- h.setUint8(u, g | l << d);
1205
+ const l = i.getUint8(o * t + c), f = o * r + 1 + Math.floor(c / a), d = (a - 1 - c % a) * n, g = h.getUint8(f);
1206
+ h.setUint8(f, g | l << d);
1196
1207
  }
1197
1208
  }
1198
1209
  return s;
1199
1210
  }
1200
- const Ut = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), jt = new TextDecoder();
1201
- function Et(n) {
1202
- switch (n) {
1211
+ const Nt = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), It = new TextDecoder();
1212
+ function jt(i) {
1213
+ switch (i) {
1203
1214
  case 0:
1204
1215
  return "greyscale";
1205
1216
  case 2:
@@ -1211,20 +1222,20 @@ function Et(n) {
1211
1222
  case 6:
1212
1223
  return "truecolor-alpha";
1213
1224
  default:
1214
- throw new Error(`Invalid color type: ${n}`);
1225
+ throw new Error(`Invalid color type: ${i}`);
1215
1226
  }
1216
1227
  }
1217
- function Pt(n) {
1218
- switch (n) {
1228
+ function Pt(i) {
1229
+ switch (i) {
1219
1230
  case 0:
1220
1231
  return "none";
1221
1232
  case 1:
1222
1233
  return "adam7";
1223
1234
  default:
1224
- throw new Error(`Invalid interlace method: ${n}`);
1235
+ throw new Error(`Invalid interlace method: ${i}`);
1225
1236
  }
1226
1237
  }
1227
- function Dt(n, t) {
1238
+ function Et(i, t) {
1228
1239
  const e = {
1229
1240
  0: [1, 2, 4, 8, 16],
1230
1241
  // Greyscale
@@ -1239,23 +1250,23 @@ function Dt(n, t) {
1239
1250
  }[t];
1240
1251
  if (!e)
1241
1252
  throw new Error(`Invalid color type: ${t}`);
1242
- if (!e.includes(n))
1253
+ if (!e.includes(i))
1243
1254
  throw new Error(
1244
- `Invalid bit depth ${n} for color type ${t}. Allowed: ${e.join(", ")}`
1255
+ `Invalid bit depth ${i} for color type ${t}. Allowed: ${e.join(", ")}`
1245
1256
  );
1246
1257
  return !0;
1247
1258
  }
1248
- function zt(n, t) {
1249
- if (t + 12 > n.byteLength)
1259
+ function Dt(i, t) {
1260
+ if (t + 12 > i.byteLength)
1250
1261
  throw new Error(
1251
1262
  `Chunk at offset ${t} extends beyond data (need at least 12 bytes for header)`
1252
1263
  );
1253
- const e = n.getUint32(t, !1), i = new Uint8Array(n.buffer, n.byteOffset + t + 4, 4), a = jt.decode(i), r = 8 + e + 4;
1254
- if (t + r > n.byteLength)
1264
+ const e = i.getUint32(t, !1), n = new Uint8Array(i.buffer, i.byteOffset + t + 4, 4), a = It.decode(n), r = 8 + e + 4;
1265
+ if (t + r > i.byteLength)
1255
1266
  throw new Error(
1256
- `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${r}, available: ${n.byteLength - t})`
1267
+ `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${r}, available: ${i.byteLength - t})`
1257
1268
  );
1258
- const s = new DataView(n.buffer, n.byteOffset + t + 8, e);
1269
+ const s = new DataView(i.buffer, i.byteOffset + t + 8, e);
1259
1270
  return {
1260
1271
  type: a,
1261
1272
  data: s,
@@ -1263,22 +1274,22 @@ function zt(n, t) {
1263
1274
  totalSize: r
1264
1275
  };
1265
1276
  }
1266
- function* It(n, t = 0) {
1277
+ function* zt(i, t = 0) {
1267
1278
  let e = t;
1268
- for (; e < n.byteLength; ) {
1269
- const i = zt(n, e);
1270
- yield i, e += i.totalSize;
1279
+ for (; e < i.byteLength; ) {
1280
+ const n = Dt(i, e);
1281
+ yield n, e += n.totalSize;
1271
1282
  }
1272
1283
  }
1273
- function Ft(n, t, e, i = 0) {
1274
- for (const a of It(n, i))
1284
+ function Ft(i, t, e, n = 0) {
1285
+ for (const a of zt(i, n))
1275
1286
  if (a.type === t)
1276
1287
  return e(a.data);
1277
1288
  }
1278
- function Lt(n) {
1279
- if (n.byteLength !== 13)
1280
- throw new Error(`IHDR chunk must be 13 bytes, got ${n.byteLength}`);
1281
- const t = n.getUint32(0, !1), e = n.getUint32(4, !1), i = n.getUint8(8), a = n.getUint8(9), r = n.getUint8(10), s = n.getUint8(11), h = n.getUint8(12);
1289
+ function Bt(i) {
1290
+ if (i.byteLength !== 13)
1291
+ throw new Error(`IHDR chunk must be 13 bytes, got ${i.byteLength}`);
1292
+ const t = i.getUint32(0, !1), e = i.getUint32(4, !1), n = i.getUint8(8), a = i.getUint8(9), r = i.getUint8(10), s = i.getUint8(11), h = i.getUint8(12);
1282
1293
  if (t === 0)
1283
1294
  throw new Error("IHDR width cannot be zero");
1284
1295
  if (e === 0)
@@ -1291,36 +1302,36 @@ function Lt(n) {
1291
1302
  throw new Error(
1292
1303
  `Invalid filter method: ${s}. Only 0 (adaptive) is supported.`
1293
1304
  );
1294
- Dt(i, a);
1295
- const o = Et(a), c = Pt(h);
1305
+ Et(n, a);
1306
+ const o = jt(a), c = Pt(h);
1296
1307
  return {
1297
1308
  width: t,
1298
1309
  height: e,
1299
- bitDepth: i,
1310
+ bitDepth: n,
1300
1311
  colorType: o,
1301
1312
  compressionMethod: "deflate",
1302
1313
  filterMethod: "adaptive",
1303
1314
  interlaceMethod: c
1304
1315
  };
1305
1316
  }
1306
- function Bt(n) {
1307
- if (n.byteLength < 8)
1317
+ function Lt(i) {
1318
+ if (i.byteLength < 8)
1308
1319
  throw new Error("Data too short to contain PNG signature");
1309
1320
  for (let t = 0; t < 8; t++)
1310
- if (n.getUint8(t) !== Ut[t])
1321
+ if (i.getUint8(t) !== Nt[t])
1311
1322
  throw new Error("Invalid PNG signature");
1312
1323
  return !0;
1313
1324
  }
1314
- function Tt(n) {
1315
- const t = n instanceof Uint8Array ? n.buffer : n, e = n instanceof Uint8Array ? n.byteOffset : 0, i = n.byteLength, a = new DataView(t, e, i);
1316
- Bt(a);
1317
- const r = Ft(a, "IHDR", Lt, 8);
1325
+ function Tt(i) {
1326
+ const t = i instanceof Uint8Array ? i.buffer : i, e = i instanceof Uint8Array ? i.byteOffset : 0, n = i.byteLength, a = new DataView(t, e, n);
1327
+ Lt(a);
1328
+ const r = Ft(a, "IHDR", Bt, 8);
1318
1329
  if (r === void 0)
1319
1330
  throw new Error("IHDR chunk not found in PNG");
1320
1331
  return r;
1321
1332
  }
1322
- async function Rt(n, t, e, i) {
1323
- const a = new DataView(n.buffer), r = a.byteLength;
1333
+ async function Vt(i, t, e, n) {
1334
+ const a = new DataView(i.buffer), r = a.byteLength;
1324
1335
  if (r === 0)
1325
1336
  throw new Error("Received empty input");
1326
1337
  if (r !== t * e)
@@ -1332,48 +1343,48 @@ async function Rt(n, t, e, i) {
1332
1343
  const m = a.getUint8(w);
1333
1344
  m > s && (s = m);
1334
1345
  }
1335
- if (i.length <= s)
1346
+ if (n.length <= s)
1336
1347
  throw new Error(
1337
- `Color palette does not have enough colors (${s + 1}). Only ${i.length} were given!`
1348
+ `Color palette does not have enough colors (${s + 1}). Only ${n.length} were given!`
1338
1349
  );
1339
1350
  const h = qt(s), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), l = new DataView(c.buffer);
1340
1351
  l.setUint32(0, t), l.setUint32(4, e), l.setUint8(8, h), l.setUint8(9, 3), l.setUint8(10, 0), l.setUint8(11, 0), l.setUint8(12, 0);
1341
- const u = N("IHDR", c), d = new Uint8Array(i.length * 3), g = new DataView(d.buffer);
1352
+ const f = U("IHDR", c), d = new Uint8Array(n.length * 3), g = new DataView(d.buffer);
1342
1353
  for (let w = 0; w <= s; w++)
1343
- g.setUint8(w * 3, i[w][0]), g.setUint8(w * 3 + 1, i[w][1]), g.setUint8(w * 3 + 2, i[w][2]);
1344
- const p = N("PLTE", d), f = Nt(a, t, e, h), $ = N("IDAT", await Ct(f)), k = N("IEND", new Uint8Array(0));
1345
- return St(o, u, p, $, k);
1354
+ g.setUint8(w * 3, n[w][0]), g.setUint8(w * 3 + 1, n[w][1]), g.setUint8(w * 3 + 2, n[w][2]);
1355
+ const u = U("PLTE", d), p = Ut(a, t, e, h), $ = U("IDAT", await Ct(p)), v = U("IEND", new Uint8Array(0));
1356
+ return St(o, f, u, $, v);
1346
1357
  }
1347
- async function Zt(n, t = {}) {
1358
+ async function Rt(i, t = {}) {
1348
1359
  var e;
1349
1360
  const {
1350
- margin: i = 4,
1361
+ margin: n = 4,
1351
1362
  moduleSize: a = 4,
1352
1363
  backgroundColor: r = [255, 255, 255],
1353
1364
  foregroundColor: s = [0, 0, 0]
1354
- } = t, { matrix: h } = n, o = ((e = h[0]) == null ? void 0 : e.length) ?? 0, c = h.length, l = (o + i * 2) * a, u = (c + i * 2) * a, d = new Uint8Array(l * u);
1365
+ } = t, { matrix: h } = i, o = ((e = h[0]) == null ? void 0 : e.length) ?? 0, c = h.length, l = (o + n * 2) * a, f = (c + n * 2) * a, d = new Uint8Array(l * f);
1355
1366
  d.fill(0);
1356
1367
  for (let g = 0; g < c; g++)
1357
- for (let p = 0; p < o; p++)
1358
- if (h[g][p])
1359
- for (let f = 0; f < a; f++)
1368
+ for (let u = 0; u < o; u++)
1369
+ if (h[g][u])
1370
+ for (let p = 0; p < a; p++)
1360
1371
  for (let $ = 0; $ < a; $++) {
1361
- const k = (p + i) * a + $, w = (g + i) * a + f;
1362
- d[w * l + k] = 1;
1372
+ const v = (u + n) * a + $, w = (g + n) * a + p;
1373
+ d[w * l + v] = 1;
1363
1374
  }
1364
1375
  return {
1365
- bytes: await Rt(d, l, u, [r, s]),
1376
+ bytes: await Vt(d, l, f, [r, s]),
1366
1377
  width: l,
1367
- height: u
1378
+ height: f
1368
1379
  };
1369
1380
  }
1370
- function Vt(n) {
1381
+ function Zt(i) {
1371
1382
  const t = {};
1372
- for (const [e, i] of Object.entries(n))
1373
- i !== void 0 && (t[e] = i);
1383
+ for (const [e, n] of Object.entries(i))
1384
+ n !== void 0 && (t[e] = n);
1374
1385
  return t;
1375
1386
  }
1376
- class Y extends H {
1387
+ class tt extends H {
1377
1388
  charWidth = 12;
1378
1389
  charHeight = 24;
1379
1390
  // Default to charWidth * 2, can be overridden
@@ -1389,6 +1400,7 @@ class Y extends H {
1389
1400
  defaultFont = "'Courier Prime', monospace";
1390
1401
  actualFontCharacterWidth = void 0;
1391
1402
  explicitCharHeight = void 0;
1403
+ widthSpacingUnit = "px";
1392
1404
  // DOM building state
1393
1405
  contentNodes = [];
1394
1406
  currentStyles = {};
@@ -1400,9 +1412,11 @@ class Y extends H {
1400
1412
  // Queued text segments for current line
1401
1413
  pendingVrSvg = null;
1402
1414
  // Pending vertical rules SVG for overlay with text
1415
+ currentColumnInfo = null;
1416
+ // Current column context from parser
1403
1417
  // start printing:
1404
1418
  async open(t) {
1405
- return await super.open(t), this.charWidth = t.charWidth, this.charHeight = this.explicitCharHeight ?? t.charWidth * 2, this.actualFontCharacterWidth !== void 0 && this.actualFontCharacterWidth > 0 && (this._cpl = Math.floor(t.cpl * t.charWidth / this.actualFontCharacterWidth)), this.containerWidth = t.cpl * t.charWidth, this.estimatedHeight = 0, this.lineMargin = 0, this.lineAlign = 0, this.lineWidth = this.cpl, this.lineHeight = 1, this.textEncoding = t.encoding, this.feedMinimum = Number(t.spacing ? this.charHeight * 1.25 : this.charHeight), this.spacing = t.spacing, this.contentNodes = [], this.currentStyles = {}, this.textScale = 1, this.currentPosition = 0, this.lineSegments = [], this.pendingVrSvg = null, "";
1419
+ return await super.open(t), this.charWidth = t.charWidth, this.charHeight = this.explicitCharHeight ?? t.charWidth * 2, this.actualFontCharacterWidth !== void 0 && this.actualFontCharacterWidth > 0 && (this._cpl = Math.floor(t.cpl * t.charWidth / this.actualFontCharacterWidth)), this.containerWidth = t.cpl * t.charWidth, this.estimatedHeight = 0, this.lineMargin = 0, this.lineAlign = 0, this.lineWidth = this.cpl, this.lineHeight = 1, this.textEncoding = t.encoding, this.feedMinimum = Number(t.spacing ? this.charHeight * 1.25 : this.charHeight), this.spacing = t.spacing, this.contentNodes = [], this.currentStyles = {}, this.textScale = 1, this.currentPosition = 0, this.lineSegments = [], this.pendingVrSvg = null, this.currentColumnInfo = null, "";
1406
1420
  }
1407
1421
  setDefaultFont(t) {
1408
1422
  return this.defaultFont = t, this.defaultFont;
@@ -1413,6 +1427,25 @@ class Y extends H {
1413
1427
  setCharHeight(t) {
1414
1428
  this.explicitCharHeight = t;
1415
1429
  }
1430
+ setWidthSpacingUnit(t) {
1431
+ this.widthSpacingUnit = t;
1432
+ }
1433
+ /**
1434
+ * Converts a character width to the appropriate CSS unit based on widthSpacingUnit.
1435
+ * @param chars - Width in characters
1436
+ * @returns CSS value string (e.g., "12px", "50%", "12ch")
1437
+ */
1438
+ toWidthUnit(t) {
1439
+ const e = this.actualFontCharacterWidth ?? this.charWidth;
1440
+ switch (this.widthSpacingUnit) {
1441
+ case "px":
1442
+ return `${Math.floor(t * e)}px`;
1443
+ case "%":
1444
+ return `${t * e / this.containerWidth * 100}%`;
1445
+ default:
1446
+ return `${t}ch`;
1447
+ }
1448
+ }
1416
1449
  // finish printing (async to support Promise nodes like QR code PNGs):
1417
1450
  async close() {
1418
1451
  (this.lineSegments.length > 0 || this.pendingVrSvg) && await this.lf();
@@ -1460,10 +1493,10 @@ class Y extends H {
1460
1493
  type: "div",
1461
1494
  props: a
1462
1495
  });
1463
- return Wt(s);
1496
+ return kt(s);
1464
1497
  }
1465
1498
  // set print area:
1466
- async area(t, e, i) {
1499
+ async area(t, e, n) {
1467
1500
  return this.lineMargin = t, this.lineWidth = e, "";
1468
1501
  }
1469
1502
  // set line alignment:
@@ -1478,6 +1511,10 @@ class Y extends H {
1478
1511
  async relative(t) {
1479
1512
  return this.currentPosition += t, "";
1480
1513
  }
1514
+ // set column context for text alignment:
1515
+ async column(t, e, n, a) {
1516
+ return this.currentColumnInfo = { index: t, start: e, width: n, align: a }, "";
1517
+ }
1481
1518
  // print horizontal rule:
1482
1519
  async hr(t) {
1483
1520
  const e = {
@@ -1485,8 +1522,8 @@ class Y extends H {
1485
1522
  props: {
1486
1523
  style: {
1487
1524
  borderTop: "2px solid black",
1488
- marginLeft: `${this.lineMargin}ch`,
1489
- width: `${t}ch`,
1525
+ marginLeft: this.toWidthUnit(this.lineMargin),
1526
+ width: this.toWidthUnit(t),
1490
1527
  height: "0",
1491
1528
  display: "flex"
1492
1529
  }
@@ -1496,21 +1533,21 @@ class Y extends H {
1496
1533
  }
1497
1534
  // print vertical rules:
1498
1535
  async vr(t, e) {
1499
- const i = this.charWidth, a = i / 2, r = this.charHeight * e, s = t.reduce((l, u) => l + u, 0) + t.length + 1;
1536
+ const n = this.charWidth, a = n / 2, r = this.charHeight * e, s = t.reduce((l, f) => l + f, 0) + t.length + 1;
1500
1537
  let h = `M${a},0v${r}`;
1501
1538
  for (const l of t)
1502
- h += `m${l * i + i},${-r}v${r}`;
1503
- const o = s * i, c = {
1539
+ h += `m${l * n + n},${-r}v${r}`;
1540
+ const o = s * n, c = {
1504
1541
  type: "svg",
1505
1542
  props: {
1506
- width: `${s}ch`,
1543
+ width: this.toWidthUnit(s),
1507
1544
  height: `${r}`,
1508
1545
  viewBox: `0 0 ${o} ${r}`,
1509
1546
  preserveAspectRatio: "none",
1510
1547
  style: {
1511
1548
  position: "absolute",
1512
1549
  top: "0",
1513
- left: `${this.lineMargin}ch`
1550
+ left: this.toWidthUnit(this.lineMargin)
1514
1551
  },
1515
1552
  children: {
1516
1553
  type: "path",
@@ -1528,16 +1565,16 @@ class Y extends H {
1528
1565
  }
1529
1566
  // start rules:
1530
1567
  async vrstart(t) {
1531
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, r = e * 2, s = this.buildVrStartPath(t), h = {
1568
+ const e = this.charWidth, n = t.reduce((o, c) => o + c, 0) + t.length + 1, a = n * e, r = e * 2, s = this.buildVrStartPath(t), h = {
1532
1569
  type: "svg",
1533
1570
  props: {
1534
- width: `${i}ch`,
1571
+ width: this.toWidthUnit(n),
1535
1572
  height: `${r}`,
1536
1573
  viewBox: `0 0 ${a} ${r}`,
1537
1574
  preserveAspectRatio: "none",
1538
1575
  style: {
1539
1576
  display: "flex",
1540
- marginLeft: `${this.lineMargin}ch`
1577
+ marginLeft: this.toWidthUnit(this.lineMargin)
1541
1578
  },
1542
1579
  children: {
1543
1580
  type: "path",
@@ -1554,25 +1591,25 @@ class Y extends H {
1554
1591
  return this.contentNodes.push(h), "";
1555
1592
  }
1556
1593
  buildVrStartPath(t) {
1557
- const e = this.charWidth, i = e / 2;
1558
- let a = `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`;
1594
+ const e = this.charWidth, n = e / 2;
1595
+ let a = `M${n},${e + e}v${-n}q0,${-n},${n},${-n}`;
1559
1596
  for (let r = 0; r < t.length; r++) {
1560
1597
  const s = t[r] ?? 0;
1561
- a += `h${e * s}h${i}v${e}m0,${-e}h${i}`;
1598
+ a += `h${e * s}h${n}v${e}m0,${-e}h${n}`;
1562
1599
  }
1563
- return a = a.replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`), a;
1600
+ return a = a.replace(/h\d+v\d+m0,-\d+h\d+$/, `q${n},0,${n},${n}v${n}`), a;
1564
1601
  }
1565
1602
  // stop rules:
1566
1603
  async vrstop(t) {
1567
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, r = e * 2, s = this.buildVrStopPath(t), h = {
1604
+ const e = this.charWidth, n = t.reduce((o, c) => o + c, 0) + t.length + 1, a = n * e, r = e * 2, s = this.buildVrStopPath(t), h = {
1568
1605
  type: "svg",
1569
1606
  props: {
1570
- width: `${i}ch`,
1607
+ width: this.toWidthUnit(n),
1571
1608
  height: `${r}`,
1572
1609
  viewBox: `0 0 ${a} ${r}`,
1573
1610
  preserveAspectRatio: "none",
1574
1611
  style: {
1575
- marginLeft: `${this.lineMargin}ch`
1612
+ marginLeft: this.toWidthUnit(this.lineMargin)
1576
1613
  },
1577
1614
  children: {
1578
1615
  type: "path",
@@ -1589,34 +1626,34 @@ class Y extends H {
1589
1626
  return this.contentNodes.push(h), "";
1590
1627
  }
1591
1628
  buildVrStopPath(t) {
1592
- const e = this.charWidth, i = e / 2;
1593
- let a = `M${i},0v${i}q0,${i},${i},${i}`;
1629
+ const e = this.charWidth, n = e / 2;
1630
+ let a = `M${n},0v${n}q0,${n},${n},${n}`;
1594
1631
  for (let r = 0; r < t.length; r++) {
1595
1632
  const s = t[r] ?? 0;
1596
- a += `h${e * s}h${i}v${-e}m0,${e}h${i}`;
1633
+ a += `h${e * s}h${n}v${-e}m0,${e}h${n}`;
1597
1634
  }
1598
- return a = a.replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`), a;
1635
+ return a = a.replace(/h\d+v-\d+m0,\d+h\d+$/, `q${n},0,${n},${-n}v${-n}`), a;
1599
1636
  }
1600
1637
  // print vertical and horizontal rules:
1601
- async vrhr(t, e, i, a) {
1602
- const r = this.charWidth, s = r / 2, h = t.reduce((f, $) => f + $, 0) + t.length + 1, o = e.reduce((f, $) => f + $, 0) + e.length + 1, c = Math.max(h, o), l = c * r, u = r * 2;
1603
- let d = `M${s},0` + (i > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`);
1604
- for (const f of t)
1605
- d += `h${r * f}h${s}v${-r}m0,${r}h${s}`;
1638
+ async vrhr(t, e, n, a) {
1639
+ const r = this.charWidth, s = r / 2, h = t.reduce((p, $) => p + $, 0) + t.length + 1, o = e.reduce((p, $) => p + $, 0) + e.length + 1, c = Math.max(h, o), l = c * r, f = r * 2;
1640
+ let d = `M${s},0` + (n > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`);
1641
+ for (const p of t)
1642
+ d += `h${r * p}h${s}v${-r}m0,${r}h${s}`;
1606
1643
  d = d.replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${s},0,${s},${-s}v${-s}` : `h${s}v${-r}`);
1607
- let g = `M${s},${r + r}` + (i < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`);
1608
- for (const f of e)
1609
- g += `h${r * f}h${s}v${r}m0,${-r}h${s}`;
1644
+ let g = `M${s},${r + r}` + (n < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`);
1645
+ for (const p of e)
1646
+ g += `h${r * p}h${s}v${r}m0,${-r}h${s}`;
1610
1647
  g = g.replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${s},0,${s},${s}v${s}` : `h${s}v${r}`);
1611
- const p = {
1648
+ const u = {
1612
1649
  type: "svg",
1613
1650
  props: {
1614
- width: `${c}ch`,
1615
- height: `${u}`,
1616
- viewBox: `0 0 ${l} ${u}`,
1651
+ width: this.toWidthUnit(c),
1652
+ height: `${f}`,
1653
+ viewBox: `0 0 ${l} ${f}`,
1617
1654
  preserveAspectRatio: "none",
1618
1655
  style: {
1619
- marginLeft: `${this.lineMargin + Math.max(-i, 0)}ch`
1656
+ marginLeft: this.toWidthUnit(this.lineMargin + Math.max(-n, 0))
1620
1657
  },
1621
1658
  children: [
1622
1659
  { type: "path", props: { d, fill: "none", stroke: "black", "stroke-width": "2", "vector-effect": "non-scaling-stroke" } },
@@ -1624,7 +1661,7 @@ class Y extends H {
1624
1661
  ]
1625
1662
  }
1626
1663
  };
1627
- return this.contentNodes.push(p), "";
1664
+ return this.contentNodes.push(u), "";
1628
1665
  }
1629
1666
  // set line spacing and feed new line:
1630
1667
  async vrlf(t) {
@@ -1685,8 +1722,8 @@ class Y extends H {
1685
1722
  }
1686
1723
  // scale up text:
1687
1724
  async wh(t) {
1688
- const e = t < 2 ? t + 1 : t - 1, i = t < 3 ? t : t - 1;
1689
- return this.currentStyles.fontSize = `${i}em`, this.currentStyles.display = "flex", e !== i && (this.currentStyles.transform = `scaleX(${e / i})`, this.currentStyles.transformOrigin = "left"), this.lineHeight = Math.max(this.lineHeight, i), this.textScale = e, "";
1725
+ const e = t < 2 ? t + 1 : t - 1, n = t < 3 ? t : t - 1;
1726
+ return this.currentStyles.fontSize = `${n}em`, this.currentStyles.display = "flex", e !== n && (this.currentStyles.transform = `scaleX(${e / n})`, this.currentStyles.transformOrigin = "left"), this.lineHeight = Math.max(this.lineHeight, n), this.textScale = e, "";
1690
1727
  }
1691
1728
  // cancel text decoration:
1692
1729
  async normal() {
@@ -1694,18 +1731,19 @@ class Y extends H {
1694
1731
  }
1695
1732
  // print text:
1696
1733
  async text(t, e) {
1697
- const i = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, " "), a = this.measureText(t, e), r = {
1734
+ const n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, " "), a = this.measureText(t, e), r = {
1698
1735
  position: this.currentPosition,
1699
- text: i,
1736
+ text: n,
1700
1737
  styles: { ...this.currentStyles },
1701
1738
  scale: this.textScale,
1702
- charWidth: a
1739
+ charWidth: a,
1740
+ columnInfo: this.currentColumnInfo ? { ...this.currentColumnInfo } : null
1703
1741
  };
1704
1742
  return this.lineSegments.push(r), this.currentPosition += a * this.textScale, "";
1705
1743
  }
1706
1744
  // feed new line:
1707
1745
  async lf() {
1708
- const t = this.lineHeight * this.charHeight, e = Math.max(t, this.feedMinimum), i = this.lineMargin + this.lineWidth, a = [];
1746
+ const t = this.lineHeight * this.charHeight, e = Math.max(t, this.feedMinimum), n = this.lineMargin + this.lineWidth, a = [];
1709
1747
  if (this.lineSegments.length === 0) {
1710
1748
  if (this.pendingVrSvg) {
1711
1749
  const s = {
@@ -1722,65 +1760,135 @@ class Y extends H {
1722
1760
  };
1723
1761
  this.contentNodes.push(s), this.pendingVrSvg = null, this.estimatedHeight += e;
1724
1762
  }
1725
- return this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1763
+ return this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, this.currentColumnInfo = null, "";
1764
+ } else if (this.lineSegments.every((h) => h.columnInfo !== null)) {
1765
+ const h = ["left", "center", "right"], o = /* @__PURE__ */ new Map();
1766
+ for (const f of this.lineSegments) {
1767
+ const d = f.columnInfo.index;
1768
+ o.has(d) || o.set(d, []), o.get(d).push(f);
1769
+ }
1770
+ this.lineMargin > 0 && a.push({
1771
+ type: "span",
1772
+ props: {
1773
+ style: {
1774
+ flexBasis: this.toWidthUnit(this.lineMargin)
1775
+ }
1776
+ }
1777
+ });
1778
+ let c = this.lineMargin;
1779
+ const l = [...o.entries()].sort((f, d) => f[0] - d[0]);
1780
+ for (const [f, d] of l) {
1781
+ const g = d[0].columnInfo, u = this.lineMargin + g.start;
1782
+ if (u > c) {
1783
+ const m = u - c;
1784
+ a.push({
1785
+ type: "span",
1786
+ props: {
1787
+ style: {
1788
+ flexBasis: this.toWidthUnit(m)
1789
+ }
1790
+ }
1791
+ }), c = u;
1792
+ }
1793
+ const p = h[g.align] ?? "center", $ = g.align === 0 ? "flex-start" : g.align === 2 ? "flex-end" : "center", v = d.map((m) => m.styles && Object.keys(m.styles).length > 0 ? {
1794
+ type: "span",
1795
+ props: {
1796
+ style: m.styles,
1797
+ children: m.text
1798
+ }
1799
+ } : m.text), w = {
1800
+ type: "span",
1801
+ props: {
1802
+ style: {
1803
+ flexBasis: this.toWidthUnit(g.width),
1804
+ whiteSpace: "pre",
1805
+ display: "flex",
1806
+ justifyContent: $,
1807
+ textAlign: p
1808
+ },
1809
+ children: v.length === 1 ? v[0] : v
1810
+ }
1811
+ };
1812
+ a.push(w), c = u + g.width;
1813
+ }
1814
+ if (c < n) {
1815
+ const f = n - c;
1816
+ a.push({
1817
+ type: "span",
1818
+ props: {
1819
+ style: {
1820
+ flexBasis: this.toWidthUnit(f)
1821
+ }
1822
+ }
1823
+ });
1824
+ }
1726
1825
  } else {
1727
- const s = [...this.lineSegments].sort((u, d) => u.position - d.position);
1728
- let h = 0;
1729
- const o = (u) => Math.floor(u), c = (u) => `${o(u)}ch`, l = (u) => {
1730
- const d = u.match(/^(\d+(?:\.\d+)?)ch$/);
1731
- return d ? parseFloat(d[1]) : 0;
1826
+ const h = [...this.lineSegments].sort((d, g) => d.position - g.position);
1827
+ let o = 0;
1828
+ const c = (d) => Math.floor(d), l = (d) => {
1829
+ const g = c(d);
1830
+ return this.toWidthUnit(g);
1831
+ }, f = (d) => {
1832
+ const g = this.actualFontCharacterWidth ?? this.charWidth, u = d.match(/^(\d+(?:\.\d+)?)px$/);
1833
+ if (u)
1834
+ return parseFloat(u[1]) / g;
1835
+ const p = d.match(/^(\d+(?:\.\d+)?)%$/);
1836
+ if (p)
1837
+ return parseFloat(p[1]) / 100 * this.containerWidth / g;
1838
+ const $ = d.match(/^(\d+(?:\.\d+)?)ch$/);
1839
+ return $ ? parseFloat($[1]) : 0;
1732
1840
  };
1733
- for (let u = 0; u < s.length; u++) {
1734
- const d = s[u], g = this.lineMargin + d.position, p = d.charWidth * d.scale;
1735
- if (g > h && a.length > 0) {
1736
- const W = g - h, v = a[a.length - 1];
1737
- if (v && v.props && v.props.style && typeof v.props.style == "object" && !Array.isArray(v.props.style)) {
1738
- const A = v.props.style, x = A.flexBasis;
1739
- if (x) {
1740
- const D = l(x) + W;
1741
- A.flexBasis = c(D);
1841
+ for (let d = 0; d < h.length; d++) {
1842
+ const g = h[d], u = this.lineMargin + g.position, p = g.charWidth * g.scale;
1843
+ if (u > o && a.length > 0) {
1844
+ const b = u - o, W = a[a.length - 1];
1845
+ if (W && W.props && W.props.style && typeof W.props.style == "object" && !Array.isArray(W.props.style)) {
1846
+ const k = W.props.style, S = k.flexBasis;
1847
+ if (S) {
1848
+ const E = f(S) + b;
1849
+ k.flexBasis = l(E);
1742
1850
  } else
1743
- A.flexBasis = c(W);
1851
+ k.flexBasis = l(b);
1744
1852
  }
1745
- } else if (g > h && a.length === 0) {
1746
- const W = g - h;
1853
+ } else if (u > o && a.length === 0) {
1854
+ const b = u - o;
1747
1855
  a.push({
1748
1856
  type: "span",
1749
1857
  props: {
1750
1858
  style: {
1751
- flexBasis: c(W)
1859
+ flexBasis: l(b)
1752
1860
  }
1753
1861
  }
1754
1862
  });
1755
1863
  }
1756
- const $ = {
1757
- flexBasis: c(p),
1864
+ const v = {
1865
+ flexBasis: l(p),
1758
1866
  whiteSpace: "pre"
1759
- }, k = d.styles && Object.keys(d.styles).length > 0, w = k ? d.styles : void 0, m = {
1867
+ }, w = g.styles && Object.keys(g.styles).length > 0, m = w ? g.styles : void 0, A = {
1760
1868
  type: "span",
1761
1869
  props: {
1762
- style: $,
1763
- children: k ? {
1870
+ style: v,
1871
+ children: w ? {
1764
1872
  // Wrap text in inner span with content styles
1765
1873
  type: "span",
1766
1874
  props: {
1767
- style: w,
1768
- children: d.text
1875
+ style: m,
1876
+ children: g.text
1769
1877
  }
1770
- } : d.text
1878
+ } : g.text
1771
1879
  }
1772
1880
  };
1773
- a.push(m), h = g + p;
1881
+ a.push(A), o = u + p;
1774
1882
  }
1775
- if (h < i && a.length > 0) {
1776
- const u = i - h, d = a[a.length - 1];
1777
- if (d && d.props && d.props.style && typeof d.props.style == "object" && !Array.isArray(d.props.style)) {
1778
- const g = d.props.style, p = g.flexBasis;
1883
+ if (o < n && a.length > 0) {
1884
+ const d = n - o, g = a[a.length - 1];
1885
+ if (g && g.props && g.props.style && typeof g.props.style == "object" && !Array.isArray(g.props.style)) {
1886
+ const u = g.props.style, p = u.flexBasis;
1779
1887
  if (p) {
1780
- const $ = l(p) + u;
1781
- g.flexBasis = c($);
1888
+ const v = f(p) + d;
1889
+ u.flexBasis = l(v);
1782
1890
  } else
1783
- g.flexBasis = c(u);
1891
+ u.flexBasis = l(d);
1784
1892
  }
1785
1893
  }
1786
1894
  }
@@ -1791,7 +1899,7 @@ class Y extends H {
1791
1899
  display: "flex",
1792
1900
  flexDirection: "row",
1793
1901
  height: `${e}px`,
1794
- width: `${i}ch`
1902
+ width: this.toWidthUnit(n)
1795
1903
  },
1796
1904
  children: a
1797
1905
  }
@@ -1826,7 +1934,7 @@ class Y extends H {
1826
1934
  this.contentNodes.push(s), this.pendingVrSvg = null;
1827
1935
  } else
1828
1936
  this.contentNodes.push(r);
1829
- return this.estimatedHeight += e, this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1937
+ return this.estimatedHeight += e, this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, this.currentColumnInfo = null, "";
1830
1938
  }
1831
1939
  // insert commands:
1832
1940
  async command(t) {
@@ -1834,12 +1942,12 @@ class Y extends H {
1834
1942
  }
1835
1943
  // print image:
1836
1944
  async image(t) {
1837
- const e = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", i = V(t), a = Tt(i), r = a.width, s = a.height, h = {
1945
+ const e = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", n = O(t), a = Tt(n), r = a.width, s = a.height, h = {
1838
1946
  type: "img",
1839
1947
  props: {
1840
1948
  src: `data:image/png;base64,${t}`,
1841
- style: Vt({
1842
- maxWidth: `${this.lineWidth}ch`
1949
+ style: Zt({
1950
+ maxWidth: this.toWidthUnit(this.lineWidth)
1843
1951
  }),
1844
1952
  width: `${r}`,
1845
1953
  height: `${s}`
@@ -1849,8 +1957,8 @@ class Y extends H {
1849
1957
  props: {
1850
1958
  style: {
1851
1959
  justifyContent: e,
1852
- paddingLeft: `${this.lineMargin}ch`,
1853
- width: `${this.lineWidth}ch`,
1960
+ paddingLeft: this.toWidthUnit(this.lineMargin),
1961
+ width: this.toWidthUnit(this.lineWidth),
1854
1962
  display: "flex"
1855
1963
  },
1856
1964
  children: h
@@ -1860,16 +1968,16 @@ class Y extends H {
1860
1968
  }
1861
1969
  // print QR Code (async version using PNG):
1862
1970
  async qrcode(t, e) {
1863
- const i = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", a = _({
1971
+ const n = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", a = G({
1864
1972
  data: t.data,
1865
1973
  ec: t.level === "l" ? C.L : t.level === "m" ? C.M : t.level === "q" ? C.Q : C.H
1866
- }), r = t.cell, s = t.quietZone ? 4 : 0, { bytes: h, width: o, height: c } = await Zt(a, {
1974
+ }), r = t.cell, s = t.quietZone ? 4 : 0, { bytes: h, width: o, height: c } = await Rt(a, {
1867
1975
  moduleSize: r,
1868
1976
  margin: s
1869
- }), u = {
1977
+ }), f = {
1870
1978
  type: "img",
1871
1979
  props: {
1872
- src: `data:image/png;base64,${O(h)}`,
1980
+ src: `data:image/png;base64,${_(h)}`,
1873
1981
  width: `${o}`,
1874
1982
  height: `${c}`,
1875
1983
  style: {
@@ -1880,23 +1988,23 @@ class Y extends H {
1880
1988
  type: "div",
1881
1989
  props: {
1882
1990
  style: {
1883
- justifyContent: i,
1884
- paddingLeft: `${this.lineMargin}ch`,
1885
- width: `${this.lineWidth}ch`,
1991
+ justifyContent: n,
1992
+ paddingLeft: this.toWidthUnit(this.lineMargin),
1993
+ width: this.toWidthUnit(this.lineWidth),
1886
1994
  display: "flex"
1887
1995
  },
1888
- children: [u]
1996
+ children: [f]
1889
1997
  }
1890
1998
  };
1891
1999
  return this.contentNodes.push(d), this.estimatedHeight += c, "";
1892
2000
  }
1893
2001
  // print barcode:
1894
2002
  async barcode(t, e) {
1895
- const i = K(t), a = i.height, r = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end";
1896
- if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
1897
- const s = i.length, h = a + (i.hri ? this.charHeight + 2 : 0);
2003
+ const n = J(t), a = n.height, r = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end";
2004
+ if (a !== void 0 && "length" in n && n.length !== void 0 && n.widths) {
2005
+ const s = n.length, h = a + (n.hri ? this.charHeight + 2 : 0);
1898
2006
  let o = "";
1899
- i.widths.reduce((d, g, p) => (p % 2 === 1 && (o += `M${d},0h${g}v${a}h${-g}z`), d + g), 0);
2007
+ n.widths.reduce((d, g, u) => (u % 2 === 1 && (o += `M${d},0h${g}v${a}h${-g}z`), d + g), 0);
1900
2008
  const c = [
1901
2009
  {
1902
2010
  type: "path",
@@ -1906,7 +2014,7 @@ class Y extends H {
1906
2014
  }
1907
2015
  }
1908
2016
  ];
1909
- i.hri && i.text && c.push({
2017
+ n.hri && n.text && c.push({
1910
2018
  type: "text",
1911
2019
  props: {
1912
2020
  x: `${s / 2}`,
@@ -1915,7 +2023,7 @@ class Y extends H {
1915
2023
  "font-family": "monospace",
1916
2024
  "font-size": `${this.charWidth * 2}`,
1917
2025
  fill: "black",
1918
- children: i.text
2026
+ children: n.text
1919
2027
  }
1920
2028
  });
1921
2029
  const l = {
@@ -1926,19 +2034,19 @@ class Y extends H {
1926
2034
  viewBox: `0 0 ${s} ${h}`,
1927
2035
  children: c
1928
2036
  }
1929
- }, u = {
2037
+ }, f = {
1930
2038
  type: "div",
1931
2039
  props: {
1932
2040
  style: {
1933
2041
  justifyContent: r,
1934
- paddingLeft: `${this.lineMargin}ch`,
1935
- width: `${this.lineWidth}ch`,
2042
+ paddingLeft: this.toWidthUnit(this.lineMargin),
2043
+ width: this.toWidthUnit(this.lineWidth),
1936
2044
  display: "flex"
1937
2045
  },
1938
2046
  children: l
1939
2047
  }
1940
2048
  };
1941
- this.contentNodes.push(u), this.estimatedHeight += h;
2049
+ this.contentNodes.push(f), this.estimatedHeight += h;
1942
2050
  }
1943
2051
  return "";
1944
2052
  }
@@ -1949,7 +2057,7 @@ class Y extends H {
1949
2057
  return this.estimatedHeight;
1950
2058
  }
1951
2059
  }
1952
- class tt extends H {
2060
+ class et extends H {
1953
2061
  logs = [];
1954
2062
  /**
1955
2063
  * Start printing.
@@ -1974,8 +2082,8 @@ class tt extends H {
1974
2082
  * @param {number} right right margin (unit: characters)
1975
2083
  * @returns {Promise<string>} empty string
1976
2084
  */
1977
- async area(t, e, i) {
1978
- return this.logs.push(`area(left: ${t}, width: ${e}, right: ${i})`), "";
2085
+ async area(t, e, n) {
2086
+ return this.logs.push(`area(left: ${t}, width: ${e}, right: ${n})`), "";
1979
2087
  }
1980
2088
  /**
1981
2089
  * Set line alignment.
@@ -2001,6 +2109,18 @@ class tt extends H {
2001
2109
  async relative(t) {
2002
2110
  return this.logs.push(`relative(${t})`), "";
2003
2111
  }
2112
+ /**
2113
+ * Set column context for text alignment.
2114
+ * @param {number} index column index (0-based)
2115
+ * @param {number} start column start position (unit: characters)
2116
+ * @param {number} width column width (unit: characters)
2117
+ * @param {number} align text alignment within column (0: left, 1: center, 2: right)
2118
+ * @returns {Promise<string>} empty string
2119
+ */
2120
+ async column(t, e, n, a) {
2121
+ const r = ["left", "center", "right"];
2122
+ return this.logs.push(`column(index: ${t}, start: ${e}, width: ${n}, align: ${r[a] ?? a})`), "";
2123
+ }
2004
2124
  /**
2005
2125
  * Print horizontal rule.
2006
2126
  * @param {number} width line width (unit: characters)
@@ -2042,8 +2162,8 @@ class tt extends H {
2042
2162
  * @param {number} dr difference in right position
2043
2163
  * @returns {Promise<string>} empty string
2044
2164
  */
2045
- async vrhr(t, e, i, a) {
2046
- return this.logs.push(`vrhr(widths1: [${t.join(", ")}], widths2: [${e.join(", ")}], dl: ${i}, dr: ${a})`), "";
2165
+ async vrhr(t, e, n, a) {
2166
+ return this.logs.push(`vrhr(widths1: [${t.join(", ")}], widths2: [${e.join(", ")}], dl: ${n}, dr: ${a})`), "";
2047
2167
  }
2048
2168
  /**
2049
2169
  * Set line spacing and feed new line.
@@ -2154,16 +2274,16 @@ class tt extends H {
2154
2274
  return 0;
2155
2275
  }
2156
2276
  }
2157
- const z = {
2277
+ const D = {
2158
2278
  base: new H(),
2159
- svg: new I(),
2160
- html: new Y(),
2161
- audit: new tt()
2279
+ svg: new z(),
2280
+ html: new tt(),
2281
+ audit: new et()
2162
2282
  };
2163
- function Ot(n) {
2164
- const t = Object.assign({}, n), e = t.encoding && /^(cp(437|85[28]|86[0356]|1252|93[26]|949|950)|multilingual|shiftjis|gb18030|ksc5601|big5|tis620)$/.test(t.encoding) ? t.encoding : "cp437", i = typeof t.target == "string" ? t.target : void 0, r = (typeof t.target == "object" && t.target !== null ? t.target : void 0) || (i && i in z ? z[i] : z.svg);
2283
+ function Ot(i) {
2284
+ const t = Object.assign({}, i), e = t.encoding && /^(cp(437|85[28]|86[0356]|1252|93[26]|949|950)|multilingual|shiftjis|gb18030|ksc5601|big5|tis620)$/.test(t.encoding) ? t.encoding : "cp437", n = typeof t.target == "string" ? t.target : void 0, r = (typeof t.target == "object" && t.target !== null ? t.target : void 0) || (n && n in D ? D[n] : D.svg);
2165
2285
  let s;
2166
- return r instanceof Y || r instanceof I || r instanceof tt || r instanceof H ? s = r : s = new I(), {
2286
+ return r instanceof tt || r instanceof z || r instanceof et || r instanceof H ? s = r : s = new z(), {
2167
2287
  cpl: t.cpl || 48,
2168
2288
  charWidth: t.charWidth || 12,
2169
2289
  encoding: e,
@@ -2173,8 +2293,8 @@ function Ot(n) {
2173
2293
  target: s
2174
2294
  };
2175
2295
  }
2176
- function _t(n, t) {
2177
- const e = n.replace(/^[\t ]+|[\t ]+$/g, "").replace(/\\[\\{|}]/g, (i) => "\\x" + i.charCodeAt(1).toString(16)).replace(/^[^|]*[^\t |]\|/, " $&").replace(/\|[^\t |][^|]*$/, "$& ").replace(/^\|(.*)$/, "$1").replace(/^(.*)\|$/, "$1").split("|").map((i, a, r) => {
2296
+ function _t(i, t) {
2297
+ const e = i.replace(/^[\t ]+|[\t ]+$/g, "").replace(/\\[\\{|}]/g, (n) => "\\x" + n.charCodeAt(1).toString(16)).replace(/^[^|]*[^\t |]\|/, " $&").replace(/\|[^\t |][^|]*$/, "$& ").replace(/^\|(.*)$/, "$1").replace(/^(.*)\|$/, "$1").split("|").map((n, a, r) => {
2178
2298
  let s = {
2179
2299
  align: 1,
2180
2300
  wrap: t.wrap,
@@ -2182,15 +2302,15 @@ function _t(n, t) {
2182
2302
  width: 0,
2183
2303
  alignment: t.align
2184
2304
  };
2185
- const h = i.replace(/^[\t ]+|[\t ]+$/g, "");
2186
- if (s.align = 1 + Number(/^[\t ]/.test(i)) - Number(/[\t ]$/.test(i)), /^\{[^{}]*\}$/.test(h)) {
2305
+ const h = n.replace(/^[\t ]+|[\t ]+$/g, "");
2306
+ if (s.align = 1 + Number(/^[\t ]/.test(n)) - Number(/[\t ]$/.test(n)), /^\{[^{}]*\}$/.test(h)) {
2187
2307
  if (s.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2188
2308
  const l = { a: "align", b: "border", c: "code", i: "image", o: "option", t: "text", w: "width", x: "command", _: "comment" };
2189
2309
  return /^[\t ]*$/.test(c) || c.replace(
2190
2310
  /^[\t ]*([A-Za-z_]\w*)[\t ]*:[\t ]*([^\t ].*?)[\t ]*$/,
2191
- (d, g, p) => {
2192
- const f = g.replace(/^[abciotwx_]$/, ($) => l[$] || $);
2193
- return o[f] = Z(p.replace(/\\n/g, `
2311
+ (d, g, u) => {
2312
+ const p = g.replace(/^[abciotwx_]$/, ($) => l[$] || $);
2313
+ return o[p] = Z(u.replace(/\\n/g, `
2194
2314
  `)), d;
2195
2315
  }
2196
2316
  ) === c && (s.error = h), o;
@@ -2262,35 +2382,35 @@ function _t(n, t) {
2262
2382
  }
2263
2383
  return s.alignment = t.align, s;
2264
2384
  });
2265
- if (e.every((i) => "text" in i) && t.width.length > 0)
2385
+ if (e.every((n) => "text" in n) && t.width.length > 0)
2266
2386
  for (; e.length < t.width.length; )
2267
2387
  e.push({ align: 1, text: [""], wrap: t.wrap, border: t.border, width: t.width[e.length] ?? 0, alignment: t.align });
2268
2388
  return e;
2269
2389
  }
2270
- function Z(n) {
2271
- return n.replace(/\\$|\\x(.?$|[^\dA-Fa-f].|.[^\dA-Fa-f])/g, "").replace(/\\[^x]/g, "").replace(/\\x([\dA-Fa-f]{2})/g, (t, e) => String.fromCharCode(parseInt(e, 16)));
2390
+ function Z(i) {
2391
+ return i.replace(/\\$|\\x(.?$|[^\dA-Fa-f].|.[^\dA-Fa-f])/g, "").replace(/\\[^x]/g, "").replace(/\\x([\dA-Fa-f]{2})/g, (t, e) => String.fromCharCode(parseInt(e, 16)));
2272
2392
  }
2273
- function Gt(n, t) {
2393
+ function Gt(i, t) {
2274
2394
  const e = [];
2275
- let i = n.width, a = 1, r = [], s = !1, h = !1, o = !1, c = 0;
2276
- return n.text.forEach((l, u) => {
2277
- if (u % 2 === 0) {
2395
+ let n = i.width, a = 1, r = [], s = !1, h = !1, o = !1, c = 0;
2396
+ return i.text.forEach((l, f) => {
2397
+ if (f % 2 === 0) {
2278
2398
  let d = t.target.arrayFrom(l, t.encoding);
2279
2399
  for (; d.length > 0; ) {
2280
- let g = 0, p = 0;
2281
- for (; p < d.length && (g = t.target.measureText(d[p] ?? "", t.encoding) * (c < 2 ? c + 1 : c - 1), !(g > i)); )
2282
- i -= g, g = 0, p++;
2283
- if (p > 0 && (r.push((s ? "1" : "0") + (h ? "1" : "0") + (o ? "1" : "0") + c), r.push(d.slice(0, p).join("")), a = Math.max(a, c < 3 ? c : c - 1), d = d.slice(p)), g > n.width) {
2400
+ let g = 0, u = 0;
2401
+ for (; u < d.length && (g = t.target.measureText(d[u] ?? "", t.encoding) * (c < 2 ? c + 1 : c - 1), !(g > n)); )
2402
+ n -= g, g = 0, u++;
2403
+ if (u > 0 && (r.push((s ? "1" : "0") + (h ? "1" : "0") + (o ? "1" : "0") + c), r.push(d.slice(0, u).join("")), a = Math.max(a, c < 3 ? c : c - 1), d = d.slice(u)), g > i.width) {
2284
2404
  d = d.slice(1);
2285
2405
  continue;
2286
2406
  }
2287
- (g > i || i === 0) && (e.push({ data: r, margin: i * n.align / 2, height: a }), i = n.width, r = [], a = 1);
2407
+ (g > n || n === 0) && (e.push({ data: r, margin: n * i.align / 2, height: a }), n = i.width, r = [], a = 1);
2288
2408
  }
2289
2409
  } else
2290
2410
  switch (l) {
2291
2411
  case `
2292
2412
  `:
2293
- e.push({ data: r, margin: i * n.align / 2, height: a }), i = n.width, r = [], a = 1;
2413
+ e.push({ data: r, margin: n * i.align / 2, height: a }), n = i.width, r = [], a = 1;
2294
2414
  break;
2295
2415
  case "_":
2296
2416
  s = !s;
@@ -2306,61 +2426,61 @@ function Gt(n, t) {
2306
2426
  c = c === d ? 0 : d;
2307
2427
  break;
2308
2428
  }
2309
- }), r.length > 0 && e.push({ data: r, margin: i * n.align / 2, height: a }), e;
2429
+ }), r.length > 0 && e.push({ data: r, margin: n * i.align / 2, height: a }), e;
2310
2430
  }
2311
- async function Kt(n, t, e) {
2312
- const i = [], a = n.every((f) => "text" in f), r = n[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2313
- let s = n.filter((f) => f.width !== 0);
2431
+ async function Kt(i, t, e) {
2432
+ const n = [], a = i.every((p) => "text" in p), r = i[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2433
+ let s = i.filter((p) => p.width !== 0);
2314
2434
  a && (s = s.slice(0, Math.floor(r.border < 0 ? (t.target.cpl - 1) / 2 : (t.target.cpl + r.border) / (r.border + 1))));
2315
- const h = s.filter((f) => f.width > 0), o = s.filter((f) => f.width < 0);
2316
- let c = h.reduce((f, $) => f + $.width, 0), l = t.target.cpl - c;
2435
+ const h = s.filter((p) => p.width > 0), o = s.filter((p) => p.width < 0);
2436
+ let c = h.reduce((p, $) => p + $.width, 0), l = t.target.cpl - c;
2317
2437
  a && s.length > 0 && (l -= r.border < 0 ? s.length + 1 : (s.length - 1) * r.border);
2318
- const u = o.length;
2319
- for (; u > l; ) {
2320
- const f = h.reduce(($, k) => $.width > k.width ? $ : k);
2321
- f.width--, l++;
2438
+ const f = o.length;
2439
+ for (; f > l; ) {
2440
+ const p = h.reduce(($, v) => $.width > v.width ? $ : v);
2441
+ p.width--, l++;
2322
2442
  }
2323
- u > 0 && (o.forEach((f, $) => f.width = Math.floor((l + $) / u)), l = 0);
2324
- const d = Math.floor(l * r.alignment / 2), g = t.target.cpl - l, p = l - d;
2443
+ f > 0 && (o.forEach((p, $) => p.width = Math.floor((l + $) / f)), l = 0);
2444
+ const d = Math.floor(l * r.alignment / 2), g = t.target.cpl - l, u = l - d;
2325
2445
  if (a) {
2326
- const f = s.map((w) => Gt(w, t)), $ = s.map((w) => w.width);
2446
+ const p = s.map((w) => Gt(w, t)), $ = s.map((w) => w.width);
2327
2447
  switch (e.line) {
2328
2448
  case "ready":
2329
- i.push(
2330
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0) + await t.target.vrstart($) + await t.target.vrlf(!0)
2449
+ n.push(
2450
+ await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(0) + await t.target.vrstart($) + await t.target.vrlf(!0)
2331
2451
  ), e.line = "running";
2332
2452
  break;
2333
2453
  case "horizontal":
2334
- const w = d - e.rules.left, m = g - e.rules.width, W = Math.min(d, e.rules.left), v = Math.min(p, e.rules.right);
2335
- i.push(
2336
- await t.target.normal() + await t.target.area(W, t.target.cpl - W - v, v) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
2454
+ const w = d - e.rules.left, m = g - e.rules.width, A = Math.min(d, e.rules.left), b = Math.min(u, e.rules.right);
2455
+ n.push(
2456
+ await t.target.normal() + await t.target.area(A, t.target.cpl - A - b, b) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
2337
2457
  ), e.line = "running";
2338
2458
  break;
2339
2459
  }
2340
- e.rules = { left: d, width: g, right: p, widths: $ };
2341
- const k = r.wrap ? f.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2342
- for (let w = 0; w < k; w++) {
2343
- let m = await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0), W = 0;
2460
+ e.rules = { left: d, width: g, right: u, widths: $ };
2461
+ const v = r.wrap ? p.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2462
+ for (let w = 0; w < v; w++) {
2463
+ let m = await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(0), A = 0;
2344
2464
  if (e.line === "running") {
2345
- const v = f.reduce((A, x) => w < x.length ? Math.max(A, x[w]?.height ?? 1) : A, 1);
2346
- m += await t.target.normal() + await t.target.absolute(W++) + await t.target.vr($, v);
2465
+ const b = p.reduce((W, k) => w < k.length ? Math.max(W, k[w]?.height ?? 1) : W, 1);
2466
+ m += await t.target.normal() + await t.target.absolute(A++) + await t.target.vr($, b);
2347
2467
  }
2348
- for (let v = 0; v < f.length; v++) {
2349
- const A = f[v];
2350
- if (A) {
2351
- if (m += await t.target.absolute(W), w < A.length) {
2352
- m += await t.target.relative(A[w]?.margin ?? 0);
2353
- const x = A[w]?.data ?? [];
2354
- for (let S = 0; S < x.length; S += 2) {
2355
- const D = Number(String(x[S])[0]), et = Number(String(x[S])[1]), nt = Number(String(x[S])[2]), B = Number(String(x[S])[3]);
2356
- m += await t.target.normal(), D && (m += await t.target.ul()), et && (m += await t.target.em()), nt && (m += await t.target.iv()), B && (m += await t.target.wh(B)), m += await t.target.text(String(x[S + 1]), t.encoding);
2468
+ for (let b = 0; b < p.length; b++) {
2469
+ const W = p[b];
2470
+ if (W) {
2471
+ if (m += await t.target.column(b, A, s[b]?.width ?? 0, s[b]?.align ?? 1), m += await t.target.absolute(A), w < W.length) {
2472
+ m += await t.target.relative(W[w]?.margin ?? 0);
2473
+ const k = W[w]?.data ?? [];
2474
+ for (let S = 0; S < k.length; S += 2) {
2475
+ const L = Number(String(k[S])[0]), E = Number(String(k[S])[1]), nt = Number(String(k[S])[2]), T = Number(String(k[S])[3]);
2476
+ m += await t.target.normal(), L && (m += await t.target.ul()), E && (m += await t.target.em()), nt && (m += await t.target.iv()), T && (m += await t.target.wh(T)), m += await t.target.text(String(k[S + 1]), t.encoding);
2357
2477
  }
2358
2478
  } else
2359
2479
  m += await t.target.normal() + await t.target.text(" ", t.encoding);
2360
- W += (s[v]?.width ?? 0) + Math.abs(r.border);
2480
+ A += (s[b]?.width ?? 0) + Math.abs(r.border);
2361
2481
  }
2362
2482
  }
2363
- m += await t.target.lf(), i.push(m);
2483
+ m += await t.target.lf(), n.push(m);
2364
2484
  }
2365
2485
  }
2366
2486
  if ("hr" in r)
@@ -2368,19 +2488,19 @@ async function Kt(n, t, e) {
2368
2488
  switch (e.line) {
2369
2489
  case "running":
2370
2490
  case "horizontal":
2371
- i.push(
2491
+ n.push(
2372
2492
  await t.target.normal() + await t.target.area(e.rules.left, e.rules.width, e.rules.right) + await t.target.align(0) + await t.target.vrstop(e.rules.widths) + await t.target.vrlf(!1)
2373
- ), i.push(await t.target.cut()), e.line = "ready";
2493
+ ), n.push(await t.target.cut()), e.line = "ready";
2374
2494
  break;
2375
2495
  default:
2376
- i.push(await t.target.cut());
2496
+ n.push(await t.target.cut());
2377
2497
  break;
2378
2498
  }
2379
2499
  else
2380
2500
  switch (e.line) {
2381
2501
  case "waiting":
2382
- i.push(
2383
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0) + await t.target.hr(g) + await t.target.lf()
2502
+ n.push(
2503
+ await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(0) + await t.target.hr(g) + await t.target.lf()
2384
2504
  );
2385
2505
  break;
2386
2506
  case "running":
@@ -2397,26 +2517,26 @@ async function Kt(n, t, e) {
2397
2517
  break;
2398
2518
  case "running":
2399
2519
  case "horizontal":
2400
- i.push(
2520
+ n.push(
2401
2521
  await t.target.normal() + await t.target.area(e.rules.left, e.rules.width, e.rules.right) + await t.target.align(0) + await t.target.vrstop(e.rules.widths) + await t.target.vrlf(!1)
2402
2522
  ), e.line = "waiting";
2403
2523
  break;
2404
2524
  }
2405
- return "image" in r && r.image && i.push(
2406
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.image(r.image)
2407
- ), "code" in r && r.code && (r.code.type === "qrcode" ? i.push(
2408
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.qrcode(r.code, t.encoding)
2409
- ) : i.push(
2410
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.barcode(r.code, t.encoding)
2411
- )), "command" in r && r.command && i.push(
2412
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.command(r.command)
2413
- ), i.join("");
2525
+ return "image" in r && r.image && n.push(
2526
+ await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(r.align) + await t.target.image(r.image)
2527
+ ), "code" in r && r.code && (r.code.type === "qrcode" ? n.push(
2528
+ await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(r.align) + await t.target.qrcode(r.code, t.encoding)
2529
+ ) : n.push(
2530
+ await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(r.align) + await t.target.barcode(r.code, t.encoding)
2531
+ )), "command" in r && r.command && n.push(
2532
+ await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(r.align) + await t.target.command(r.command)
2533
+ ), n.join("");
2414
2534
  }
2415
- async function Yt(n, t) {
2535
+ async function Yt(i, t) {
2416
2536
  const e = Ot(t);
2417
2537
  await e.target.lock();
2418
2538
  try {
2419
- const i = {
2539
+ const n = {
2420
2540
  wrap: !0,
2421
2541
  border: 1,
2422
2542
  width: [],
@@ -2426,19 +2546,19 @@ async function Yt(n, t) {
2426
2546
  rules: { left: 0, width: 0, right: 0, widths: [] }
2427
2547
  };
2428
2548
  let a = await e.target.open(e);
2429
- n[0] === "\uFEFF" && (n = n.slice(1));
2430
- const r = n.normalize().split(/\n|\r\n|\r/), s = [];
2549
+ i[0] === "\uFEFF" && (i = i.slice(1));
2550
+ const r = i.normalize().split(/\n|\r\n|\r/), s = [];
2431
2551
  for (const h of r)
2432
- s.push(await Kt(_t(h, i), e, i));
2433
- switch (i.line) {
2552
+ s.push(await Kt(_t(h, n), e, n));
2553
+ switch (n.line) {
2434
2554
  case "ready":
2435
- i.line = "waiting";
2555
+ n.line = "waiting";
2436
2556
  break;
2437
2557
  case "running":
2438
2558
  case "horizontal":
2439
2559
  s.push(
2440
- await e.target.normal() + await e.target.area(i.rules.left, i.rules.width, i.rules.right) + await e.target.align(0) + await e.target.vrstop(i.rules.widths) + await e.target.vrlf(!1)
2441
- ), i.line = "waiting";
2560
+ await e.target.normal() + await e.target.area(n.rules.left, n.rules.width, n.rules.right) + await e.target.align(0) + await e.target.vrstop(n.rules.widths) + await e.target.vrlf(!1)
2561
+ ), n.line = "waiting";
2442
2562
  break;
2443
2563
  default:
2444
2564
  break;
@@ -2453,9 +2573,9 @@ async function Yt(n, t) {
2453
2573
  }
2454
2574
  }
2455
2575
  export {
2456
- tt as AuditTarget,
2576
+ et as AuditTarget,
2457
2577
  H as BaseTarget,
2458
- Y as HtmlTarget,
2459
- I as SvgTarget,
2578
+ tt as HtmlTarget,
2579
+ z as SvgTarget,
2460
2580
  Yt as transform
2461
2581
  };