@levischuck/receiptline 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +11 -11
  2. package/dist/index.js +582 -457
  3. package/package.json +2 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
- import { decodeBase64 as it, encodeBase64 as V } from "@levischuck/tiny-encodings";
2
- import { qrCode as O, EcLevel as C } from "@levischuck/tiny-qr";
3
- import { toSvgString as nt } from "@levischuck/tiny-qr-svg";
4
- class q {
1
+ import { decodeBase64 as V, encodeBase64 as O } from "@levischuck/tiny-encodings";
2
+ import { qrCode as _, EcLevel as C } from "@levischuck/tiny-qr";
3
+ import { toSvgString as it } from "@levischuck/tiny-qr-svg";
4
+ class H {
5
5
  locked = !1;
6
6
  lockPromise = null;
7
7
  lockResolve = null;
@@ -63,9 +63,9 @@ class q {
63
63
  switch (e) {
64
64
  case "cp932":
65
65
  case "shiftjis":
66
- i = a.reduce((n, h) => {
66
+ i = a.reduce((s, h) => {
67
67
  const o = h.codePointAt(0);
68
- return o === void 0 ? n : n + (o < 128 || o === 160 || o === 165 || o === 8254 || o > 65376 && o < 65440 ? 1 : 2);
68
+ return o === void 0 ? s : s + (o < 128 || o === 160 || o === 165 || o === 8254 || o > 65376 && o < 65440 ? 1 : 2);
69
69
  }, 0);
70
70
  break;
71
71
  case "cp936":
@@ -74,15 +74,15 @@ class q {
74
74
  case "ksc5601":
75
75
  case "cp950":
76
76
  case "big5":
77
- i = a.reduce((n, h) => {
77
+ i = a.reduce((s, h) => {
78
78
  const o = h.codePointAt(0);
79
- return o === void 0 ? n : n + (o < 128 || o === 160 ? 1 : 2);
79
+ return o === void 0 ? s : s + (o < 128 || o === 160 ? 1 : 2);
80
80
  }, 0);
81
81
  break;
82
82
  case "tis620":
83
- const r = a.reduce((n, h) => {
83
+ const r = a.reduce((s, h) => {
84
84
  const o = h.codePointAt(0);
85
- return o === void 0 || (n.consonant ? o === 3633 || o >= 3636 && o <= 3642 || o === 3655 ? n.vowel ? (n.length += 2, n.consonant = n.vowel = n.tone = !1) : n.vowel = !0 : o >= 3656 && o <= 3659 ? n.tone ? (n.length += 2, n.consonant = n.vowel = n.tone = !1) : n.tone = !0 : o === 3635 || o >= 3660 && o <= 3662 ? n.vowel || n.tone ? (n.length += 2, n.consonant = n.vowel = n.tone = !1) : (n.length += o === 3635 ? 2 : 1, n.consonant = !1) : o >= 3585 && o <= 3630 ? (n.length++, n.vowel = n.tone = !1) : (n.length += 2, n.consonant = n.vowel = n.tone = !1) : o >= 3585 && o <= 3630 ? n.consonant = !0 : n.length++), n;
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
87
  r.consonant && (r.length++, r.consonant = r.vowel = r.tone = !1), i = r.length;
88
88
  break;
@@ -105,9 +105,9 @@ class q {
105
105
  case "shiftjis":
106
106
  return i.map((r) => r.replace(/\\/g, "¥").replace(/\u203e/g, "~").replace(/\u301c/g, "~"));
107
107
  case "tis620":
108
- const a = i.reduce((r, n) => {
109
- const h = n.codePointAt(0);
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, n), r.consonant = r.vowel = r.tone = "") : r.vowel = n : h >= 3656 && h <= 3659 ? r.tone ? (r.result.push(r.consonant + r.vowel + r.tone, n), r.consonant = r.vowel = r.tone = "") : r.tone = n : h === 3635 || h >= 3660 && h <= 3662 ? r.vowel || r.tone ? (r.result.push(r.consonant + r.vowel + r.tone, n), r.consonant = r.vowel = r.tone = "") : (r.result.push(r.consonant + n), r.consonant = "") : h >= 3585 && h <= 3630 ? (r.result.push(r.consonant + r.vowel + r.tone), r.consonant = n, r.vowel = r.tone = "") : (r.result.push(r.consonant + r.vowel + r.tone, n), r.consonant = r.vowel = r.tone = "") : h >= 3585 && h <= 3630 ? r.consonant = n : r.result.push(n)), r;
108
+ const a = i.reduce((r, s) => {
109
+ const h = s.codePointAt(0);
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:
@@ -315,7 +315,7 @@ class q {
315
315
  return 0;
316
316
  }
317
317
  }
318
- const v = {
318
+ const y = {
319
319
  element: "212222,222122,222221,121223,121322,131222,122213,122312,132212,221213,221312,231212,112232,122132,122231,113222,123122,123221,223211,221132,221231,213212,223112,312131,311222,321122,321221,312212,322112,322211,212123,212321,232121,111323,131123,131321,112313,132113,132311,211313,231113,231311,112133,112331,132131,113123,113321,133121,313121,211331,231131,213113,213311,213131,311123,311321,331121,312113,312311,332111,314111,221411,431111,111224,111422,121124,121421,141122,141221,112214,112412,122114,122411,142112,142211,241211,221114,413111,241112,134111,111242,121142,121241,114212,124112,124211,411212,421112,421211,212141,214121,412121,111143,111341,131141,114113,114311,411113,411311,113141,114131,311141,411131,211412,211214,211232,2331112".split(","),
320
320
  starta: 103,
321
321
  startb: 104,
@@ -329,49 +329,49 @@ const v = {
329
329
  shift: 98,
330
330
  stop: 106
331
331
  };
332
- function P(s, t, e) {
333
- s !== v.shift && e.push(s), t = t.replace(/^((?!\d{4,})[\x00-_])+/, (r) => (r.split("").forEach((n) => e.push((n.charCodeAt(0) + 64) % 96)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push((r.charCodeAt(0) + 64) % 96), ""));
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
334
  const i = t.slice(1), a = i.search(/[^ -_]/);
335
- /^\d{4,}/.test(t) ? T(v.atoc, t, e) : a >= 0 && i.charCodeAt(a) < 32 ? (e.push(v.shift, t.charCodeAt(0) - 32), P(v.shift, i, e)) : t.length > 0 && U(v.atob, t, e);
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);
336
336
  }
337
- function U(s, t, e) {
338
- s !== v.shift && e.push(s), t = t.replace(/^((?!\d{4,})[ -\x7f])+/, (r) => (r.split("").forEach((n) => e.push(n.charCodeAt(0) - 32)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (r) => (e.push(r.charCodeAt(0) - 32), ""));
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
339
  const i = t.slice(1), a = i.search(/[^ -_]/);
340
- /^\d{4,}/.test(t) ? T(v.btoc, t, e) : a >= 0 && i.charCodeAt(a) > 95 ? (e.push(v.shift, t.charCodeAt(0) + 64), U(v.shift, i, e)) : t.length > 0 && P(v.btoa, t, e);
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);
341
341
  }
342
- function T(s, t, e) {
343
- s !== v.shift && e.push(s), t = t.replace(/^\d{4,}/g, (a) => a.replace(/\d{2}/g, (r) => (e.push(Number(r)), "")));
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
344
  const i = t.search(/[^ -_]/);
345
- i >= 0 && t.charCodeAt(i) < 32 ? P(v.ctoa, t, e) : t.length > 0 && U(v.ctob, t, e);
345
+ i >= 0 && t.charCodeAt(i) < 32 ? j(y.ctoa, t, e) : t.length > 0 && E(y.ctob, t, e);
346
346
  }
347
- function st(s) {
347
+ function st(n) {
348
348
  const t = {};
349
- let e = s.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
349
+ let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
350
350
  if (e.length > 0) {
351
- t.hri = s.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
351
+ t.hri = n.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
352
352
  const i = [], a = e.search(/[^ -_]/);
353
- /^\d{2}$/.test(e) ? i.push(v.startc, Number(e)) : /^\d{4,}/.test(e) ? T(v.startc, e, i) : a >= 0 && e.charCodeAt(a) < 32 ? P(v.starta, e, i) : e.length > 0 && U(v.startb, e, i), i.push(i.reduce((h, o, c) => h + o * c) % 103, v.stop);
354
- const r = s.quietZone ? "a" : "0", n = i.reduce((h, o) => h + v.element[o], r) + r;
355
- t.widths = n.split("").map((h) => parseInt(h, 16) * s.width), t.length = s.width * (i.length * 11 + (s.quietZone ? 22 : 2)), t.height = s.height;
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;
356
356
  }
357
357
  return t;
358
358
  }
359
359
  const M = {
360
360
  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((s, t, e) => (s[t] = e, s), {}),
361
+ code: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%dcsp".split("").reduce((n, t, e) => (n[t] = e, n), {}),
362
362
  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
363
  start: 47,
364
364
  stop: 48
365
365
  };
366
- function rt(s) {
366
+ function rt(n) {
367
367
  const t = {};
368
- let e = s.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
368
+ let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
369
369
  if (e.length > 0) {
370
- t.hri = s.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
371
- const i = e.split("").reduce((n, h) => n + M.escape[h.charCodeAt(0)], "").split("").map((n) => M.code[n]);
372
- i.push(i.reduceRight((n, h, o) => n + h * ((i.length - 1 - o) % 20 + 1)) % 47), i.push(i.reduceRight((n, h, o) => n + h * ((i.length - 1 - o) % 15 + 1)) % 47), i.unshift(M.start), i.push(M.stop);
373
- const a = s.quietZone ? "a" : "0", r = i.reduce((n, h) => n + M.element[h], a) + a;
374
- t.widths = r.split("").map((n) => parseInt(n, 16) * s.width), t.length = s.width * (i.length * 9 + (s.quietZone ? 21 : 1)), t.height = s.height;
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;
375
375
  }
376
376
  return t;
377
377
  }
@@ -397,37 +397,37 @@ const at = {
397
397
  C: "2225255",
398
398
  D: "2225552"
399
399
  };
400
- function ot(s) {
400
+ function ot(n) {
401
401
  const t = {};
402
- let e = s.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
402
+ let e = n.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
403
403
  if (e.length > 0) {
404
- t.hri = s.hri, t.text = e;
405
- const i = s.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((n, h) => n + at[h] + "2", i).slice(0, -1) + i;
406
- t.widths = a.split("").map((n) => parseInt(n, 16) * s.width + 1 >> 1);
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);
407
407
  const r = [25, 39, 50, 3, 5, 6];
408
- t.length = e.length * r[s.width - 2] - (e.match(/[\d\-$]/g) || []).length * r[s.width + 1] + s.width * (s.quietZone ? 19 : -1), t.height = s.height;
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;
409
409
  }
410
410
  return t;
411
411
  }
412
- const H = {
412
+ const q = {
413
413
  element: "22552,52225,25225,55222,22525,52522,25522,22255,52252,25252".split(","),
414
414
  start: "2222",
415
415
  stop: "522"
416
416
  };
417
- function ht(s) {
417
+ function ht(n) {
418
418
  const t = {};
419
- let e = s.data.replace(/((?!^(\d{2})+$).)*/, "");
419
+ let e = n.data.replace(/((?!^(\d{2})+$).)*/, "");
420
420
  if (e.length > 0) {
421
- t.hri = s.hri, t.text = e;
422
- const i = e.split("").map((o) => Number(o)), a = s.quietZone ? "a" : "0";
423
- let r = a + H.start, n = 0;
424
- for (; n < i.length; ) {
425
- const o = H.element[i[n++]], c = H.element[i[n++]];
426
- r += o.split("").reduce((l, p, d) => l + p + c[d], "");
421
+ t.hri = n.hri, t.text = e;
422
+ const i = e.split("").map((o) => Number(o)), a = n.quietZone ? "a" : "0";
423
+ 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], "");
427
427
  }
428
- r += H.stop + a, t.widths = r.split("").map((o) => parseInt(o, 16) * s.width + 1 >> 1);
428
+ r += q.stop + a, t.widths = r.split("").map((o) => parseInt(o, 16) * n.width + 1 >> 1);
429
429
  const h = [16, 25, 32, 17, 26, 34];
430
- t.length = e.length * h[s.width - 2] + h[s.width + 1] + s.width * (s.quietZone ? 20 : 0), t.height = s.height;
430
+ t.length = e.length * h[n.width - 2] + h[n.width + 1] + n.width * (n.quietZone ? 20 : 0), t.height = n.height;
431
431
  }
432
432
  return t;
433
433
  }
@@ -477,15 +477,15 @@ const ct = {
477
477
  "%": "222525252",
478
478
  "*": "252252522"
479
479
  };
480
- function lt(s) {
480
+ function lt(n) {
481
481
  const t = {};
482
- let e = s.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
482
+ let e = n.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
483
483
  if (e.length > 0) {
484
- e = e.replace(/^\*?([^*]+)\*?$/, "*$1*"), t.hri = s.hri, t.text = e;
485
- const i = s.quietZone ? "a" : "0", a = e.split("").reduce((n, h) => n + ct[h] + "2", i).slice(0, -1) + i;
486
- t.widths = a.split("").map((n) => parseInt(n, 16) * s.width + 1 >> 1);
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);
487
487
  const r = [29, 45, 58];
488
- t.length = e.length * r[s.width - 2] + s.width * (s.quietZone ? 19 : -1), t.height = s.height;
488
+ t.length = e.length * r[n.width - 2] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
489
489
  }
490
490
  return t;
491
491
  }
@@ -497,102 +497,102 @@ const b = {
497
497
  p: "aaaaaa,aababb,aabbab,aabbba,abaabb,abbaab,abbbaa,ababab,ababba,abbaba".split(","),
498
498
  e: "bbbaaa,bbabaa,bbaaba,bbaaab,babbaa,baabba,baaabb,bababa,babaab,baabab".split(",")
499
499
  };
500
- function dt(s) {
501
- const t = s.slice(0, 3);
502
- switch (s[6]) {
500
+ function dt(n) {
501
+ const t = n.slice(0, 3);
502
+ switch (n[6]) {
503
503
  case 0:
504
504
  case 1:
505
505
  case 2:
506
- t.push(s[6], 0, 0, 0, 0, s[3], s[4], s[5]);
506
+ t.push(n[6], 0, 0, 0, 0, n[3], n[4], n[5]);
507
507
  break;
508
508
  case 3:
509
- t.push(s[3], 0, 0, 0, 0, 0, s[4], s[5]);
509
+ t.push(n[3], 0, 0, 0, 0, 0, n[4], n[5]);
510
510
  break;
511
511
  case 4:
512
- t.push(s[3], s[4], 0, 0, 0, 0, 0, s[5]);
512
+ t.push(n[3], n[4], 0, 0, 0, 0, 0, n[5]);
513
513
  break;
514
514
  default:
515
- t.push(s[3], s[4], s[5], 0, 0, 0, 0, s[6]);
515
+ t.push(n[3], n[4], n[5], 0, 0, 0, 0, n[6]);
516
516
  break;
517
517
  }
518
- return t.push(s[7]), t;
518
+ return t.push(n[7]), t;
519
519
  }
520
- function _(s) {
521
- const t = {}, e = s.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((i) => Number(i));
520
+ function G(n) {
521
+ const t = {}, e = n.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((i) => Number(i));
522
522
  if (e.length > 0) {
523
- e[12] = 0, e[12] = (10 - e.reduce((a, r, n) => a + r * (n % 2 * 2 + 1)) % 10) % 10, t.hri = s.hri, t.text = e.join("");
524
- let i = (s.quietZone ? "b" : "0") + b.g[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
525
  for (let a = 1; a < 7; a++) i += b[b.p[e[0]][a - 1]][e[a]];
526
526
  i += b.g[1];
527
527
  for (let a = 7; a < 13; a++) i += b.c[e[a]];
528
- i += b.g[0] + (s.quietZone ? "7" : "0"), t.widths = i.split("").map((a) => parseInt(a, 16) * s.width), t.length = s.width * (s.quietZone ? 113 : 95), t.height = s.height;
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;
529
529
  }
530
530
  return t;
531
531
  }
532
- function gt(s) {
533
- const t = {}, e = s.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((i) => Number(i));
532
+ function gt(n) {
533
+ const t = {}, e = n.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((i) => Number(i));
534
534
  if (e.length > 0) {
535
- e[7] = 0, e[7] = (10 - e.reduce((r, n, h) => r + n * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = s.hri, t.text = e.join("");
536
- const i = s.quietZone ? "7" : "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
537
  let a = i + b.g[0];
538
538
  for (let r = 0; r < 4; r++) a += b.a[e[r] ?? 0];
539
539
  a += b.g[1];
540
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) * s.width), t.length = s.width * (s.quietZone ? 81 : 67), t.height = s.height;
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;
542
542
  }
543
543
  return t;
544
544
  }
545
- function pt(s) {
545
+ function ut(n) {
546
546
  const t = {
547
- data: "0" + s.data,
548
- hri: s.hri,
549
- width: s.width,
550
- height: s.height,
551
- quietZone: s.quietZone
552
- }, e = _(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);
553
553
  return e.text && (e.text = e.text.slice(1)), e;
554
554
  }
555
- function ut(s) {
556
- const t = {}, e = s.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((i) => Number(i));
555
+ function pt(n) {
556
+ const t = {}, e = n.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((i) => Number(i));
557
557
  if (e.length > 0) {
558
- e[7] = 0, e[7] = (10 - dt(e).reduce((r, n, h) => r + n * (3 - h % 2 * 2), 0) % 10) % 10, t.hri = s.hri, t.text = e.join("");
559
- const i = s.quietZone ? "7" : "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
560
  let a = i + b.g[0];
561
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) * s.width), t.length = s.width * (s.quietZone ? 65 : 51), t.height = s.height;
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;
563
563
  }
564
564
  return t;
565
565
  }
566
- function G(s) {
566
+ function K(n) {
567
567
  let t = {};
568
- switch (s.type) {
568
+ switch (n.type) {
569
569
  case "upc":
570
- t = s.data.length < 9 ? ut(s) : pt(s);
570
+ t = n.data.length < 9 ? pt(n) : ut(n);
571
571
  break;
572
572
  case "ean":
573
573
  case "jan":
574
- t = s.data.length < 9 ? gt(s) : _(s);
574
+ t = n.data.length < 9 ? gt(n) : G(n);
575
575
  break;
576
576
  case "code39":
577
- t = lt(s);
577
+ t = lt(n);
578
578
  break;
579
579
  case "itf":
580
- t = ht(s);
580
+ t = ht(n);
581
581
  break;
582
582
  case "codabar":
583
583
  case "nw7":
584
- t = ot(s);
584
+ t = ot(n);
585
585
  break;
586
586
  case "code93":
587
- t = rt(s);
587
+ t = rt(n);
588
588
  break;
589
589
  case "code128":
590
- t = st(s);
590
+ t = st(n);
591
591
  break;
592
592
  }
593
593
  return t;
594
594
  }
595
- class E extends q {
595
+ class I extends H {
596
596
  charWidth = 12;
597
597
  receiptId = "";
598
598
  svgWidth = 576;
@@ -606,7 +606,7 @@ class E extends q {
606
606
  textAttributes = {};
607
607
  textPosition = 0;
608
608
  textScale = 1;
609
- textEncoding = "multilingual";
609
+ textEncoding = "cp437";
610
610
  feedMinimum = 24;
611
611
  // printer configuration
612
612
  spacing = !1;
@@ -674,24 +674,24 @@ class E extends q {
674
674
  }
675
675
  // print vertical rules:
676
676
  async vr(t, e) {
677
- const i = this.charWidth, a = i / 2, r = (i + i) * e, n = '<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})">${n}</g>`, "";
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>`, "";
679
679
  }
680
680
  // start rules:
681
681
  async vrstart(t) {
682
- const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((r, n) => r + `h${e * n}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"/>';
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"/>';
683
683
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
684
684
  }
685
685
  // stop rules:
686
686
  async vrstop(t) {
687
- const e = this.charWidth, i = e / 2, a = '<path d="' + t.reduce((r, n) => r + `h${e * n}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"/>';
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"/>';
688
688
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
689
689
  }
690
690
  // print vertical and horizontal rules:
691
691
  async vrhr(t, e, i, a) {
692
- const r = this.charWidth, n = r / 2, h = '<path d="' + t.reduce((c, l) => c + `h${r * l}h${n}v${-r}m0,${r}h${n}`, `M${n},0` + (i > 0 ? `v${n}q0,${n},${n},${n}` : `v${r}h${n}`)).replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${n},0,${n},${-n}v${-n}` : `h${n}v${-r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
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
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${n}v${r}m0,${-r}h${n}`, `M${n},${r + r}` + (i < 0 ? `v${-n}q0,${-n},${n},${-n}` : `v${-r}h${n}`)).replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${n},0,${n},${n}v${n}` : `h${n}v${r}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
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
695
  return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(i, 0)) * r},${this.svgHeight})">${o}</g>`, "";
696
696
  }
697
697
  // set line spacing and feed new line:
@@ -727,10 +727,10 @@ class E extends q {
727
727
  // print text:
728
728
  async text(t, e) {
729
729
  let i = this.textPosition;
730
- const a = this.arrayFrom(t, e).reduce((n, h) => {
730
+ const a = this.arrayFrom(t, e).reduce((s, h) => {
731
731
  const o = this.measureText(h, e) * this.textScale, c = Math.floor((i + o / 2) * this.charWidth / this.textScale);
732
- return i += o, n + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
733
- }, ""), r = Object.keys(this.textAttributes).reduce((n, h) => n + ` ${h}="${this.textAttributes[h]}"`, "");
732
+ return i += o, s + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
733
+ }, ""), r = Object.keys(this.textAttributes).reduce((s, h) => s + ` ${h}="${this.textAttributes[h]}"`, "");
734
734
  return this.textElement += `<text${r}>${a}</text>`, this.textPosition += this.measureText(t, e) * this.textScale, "";
735
735
  }
736
736
  // feed new line:
@@ -744,35 +744,35 @@ class E extends q {
744
744
  }
745
745
  // print image:
746
746
  async image(t) {
747
- const e = it(t), i = new DataView(e.buffer), a = i.getUint32(16, !1), r = i.getUint32(20, !1), n = `<image href="data:image/png;base64,${V(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
- return this.svgContent += `<g transform="translate(${h},${this.svgHeight})">${n}</g>`, this.svgHeight += r, "";
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);
748
+ return this.svgContent += `<g transform="translate(${h},${this.svgHeight})">${s}</g>`, this.svgHeight += r, "";
749
749
  }
750
750
  // print QR Code:
751
751
  async qrcode(t, e) {
752
- const i = O({
752
+ const i = _({
753
753
  data: t.data,
754
754
  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, n = await nt(i, {
755
+ }), a = i.width, r = t.cell, s = await it(i, {
756
756
  moduleSize: r,
757
757
  margin: t.quietZone ? 4 : 0,
758
758
  output: "path"
759
- }), h = typeof n == "string" ? n : n.path || n.svg || String(n), o = a * r + (t.quietZone ? 8 : 0), c = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - o) * this.lineAlign / 2), l = Math.floor(this.svgHeight);
759
+ }), h = typeof s == "string" ? s : s.path || s.svg || String(s), o = a * r + (t.quietZone ? 8 : 0), c = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - o) * this.lineAlign / 2), l = Math.floor(this.svgHeight);
760
760
  return this.svgContent += `<g transform="translate(${c},${l})" shape-rendering="crispEdges">
761
761
  <path d="${h}" stroke="transparent" fill="black" shape-rendering="crispEdges" />
762
762
  </g>`, this.svgHeight += o, "";
763
763
  }
764
764
  // print barcode:
765
765
  async barcode(t, e) {
766
- const i = G(t), a = i.height;
766
+ const i = K(t), a = i.height;
767
767
  if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
768
- const r = i.length, n = a + (i.hri ? this.charWidth * 2 + 2 : 0);
768
+ const r = i.length, s = a + (i.hri ? this.charWidth * 2 + 2 : 0);
769
769
  let h = '<path d="';
770
- if (i.widths.reduce((c, l, p) => (p % 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((p, d, g) => p + `<tspan x="${c + this.charWidth * g}">${d.replace(/[ &<>]/g, (u) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[u] || u)}</tspan>`, "");
772
- h += `<text y="${n}">${l}</text>`;
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>`, "");
772
+ h += `<text y="${s}">${l}</text>`;
773
773
  }
774
774
  const o = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - r) * this.lineAlign / 2);
775
- this.svgContent += `<g transform="translate(${o},${this.svgHeight})">${h}</g>`, this.svgHeight += n;
775
+ this.svgContent += `<g transform="translate(${o},${this.svgHeight})">${h}</g>`, this.svgHeight += s;
776
776
  }
777
777
  return "";
778
778
  }
@@ -966,159 +966,159 @@ const ft = /* @__PURE__ */ new Set([
966
966
  rArr: "⇒",
967
967
  dArr: "⇓",
968
968
  hArr: "⇔"
969
- }, L = {};
970
- for (const [s, t] of Object.entries($t))
971
- L[t] || (L[t] = s);
972
- function D(s, t = !1) {
973
- if (!s || typeof s != "string")
974
- return s;
975
- let e = s;
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;
976
976
  return e = e.replace(/&/g, "&amp;"), e = e.replace(/</g, "&lt;"), e = e.replace(/>/g, "&gt;"), t && (e = e.replace(/"/g, "&quot;")), e;
977
977
  }
978
- function mt(s) {
979
- return s.replace(/\]\]>/g, "]]]]><![CDATA[>");
978
+ function mt(n) {
979
+ return n.replace(/\]\]>/g, "]]]]><![CDATA[>");
980
980
  }
981
- function vt(s) {
982
- return s.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
981
+ function yt(n) {
982
+ return n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
983
983
  }
984
- const yt = {
984
+ const vt = {
985
985
  className: "class",
986
986
  htmlFor: "for"
987
987
  };
988
- function bt(s, t) {
989
- return t === "reactName" ? s : t === "exactName" || t === "eitherName" ? yt[s] ?? s : s;
988
+ function bt(n, t) {
989
+ return t === "reactName" ? n : t === "exactName" || t === "eitherName" ? vt[n] ?? n : n;
990
990
  }
991
- function R(s, t = {}) {
991
+ function R(n, t = {}) {
992
992
  const e = [];
993
993
  let i, a, r;
994
- if (s && typeof s == "object" && "node" in s) {
995
- const l = s;
994
+ if (n && typeof n == "object" && "node" in n) {
995
+ const l = n;
996
996
  i = l.node, a = l.xml ?? t.xml, r = l.doctype ?? t.doctype;
997
997
  } else
998
- i = s, a = t.xml, r = t.doctype;
998
+ i = n, a = t.xml, r = t.doctype;
999
999
  a && (e.push(a), a.endsWith(`
1000
1000
  `) || e.push(`
1001
1001
  `)), r && (e.push(r), r.endsWith(`
1002
1002
  `) || e.push(`
1003
1003
  `));
1004
- const n = t.useCDataForScripts ?? !1, h = t.useCDataForStyles ?? !1, o = t.voidTrailingSlash ?? !0, c = t.attributeNaming ?? "eitherName";
1005
- return z(i, e, "HTML", n, h, o, c), e.join("");
1004
+ 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("");
1006
1006
  }
1007
- function z(s, t, e, i, a, r, n) {
1008
- if (s != null) {
1009
- if (typeof s == "string") {
1010
- t.push(D(s, !1));
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));
1011
1011
  return;
1012
1012
  }
1013
- if (typeof s == "number" || typeof s == "bigint") {
1014
- t.push(String(s));
1013
+ if (typeof n == "number" || typeof n == "bigint") {
1014
+ t.push(String(n));
1015
1015
  return;
1016
1016
  }
1017
- if (typeof s == "boolean") {
1018
- t.push(String(s));
1017
+ if (typeof n == "boolean") {
1018
+ t.push(String(n));
1019
1019
  return;
1020
1020
  }
1021
- if (Array.isArray(s)) {
1022
- for (const h of s)
1023
- z(h, t, e, i, a, r, n);
1021
+ if (Array.isArray(n)) {
1022
+ for (const h of n)
1023
+ P(h, t, e, i, a, r, s);
1024
1024
  return;
1025
1025
  }
1026
- if (typeof s != "function" && typeof s != "symbol" && !(s && typeof s == "object" && "then" in s && typeof s.then == "function") && s && typeof s == "object" && "type" in s && "props" in s) {
1027
- xt(s, t, e, i, a, r, n);
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);
1028
1028
  return;
1029
1029
  }
1030
1030
  }
1031
1031
  }
1032
- function xt(s, t, e, i, a, r, n) {
1032
+ function xt(n, t, e, i, a, r, s) {
1033
1033
  var h;
1034
- const o = s.type;
1034
+ const o = n.type;
1035
1035
  let c = e;
1036
- if (o === "svg" ? c = "SVG" : o === "math" && (c = "MATHML"), t.push("<"), t.push(o), s.props)
1037
- for (const [d, g] of Object.entries(s.props)) {
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)) {
1038
1038
  if (d === "children" || g === !1 || g === null || g === void 0)
1039
1039
  continue;
1040
- const u = bt(d, n);
1040
+ const p = bt(d, s);
1041
1041
  if (g === !0)
1042
- t.push(" "), t.push(u);
1042
+ t.push(" "), t.push(p);
1043
1043
  else if (d === "style" && typeof g == "object") {
1044
1044
  const f = kt(g);
1045
- f && (t.push(' style="'), t.push(D(f, !0)), t.push('"'));
1045
+ f && (t.push(' style="'), t.push(F(f, !0)), t.push('"'));
1046
1046
  } else
1047
- t.push(" "), t.push(u), t.push('="'), t.push(D(String(g), !0)), t.push('"');
1047
+ t.push(" "), t.push(p), t.push('="'), t.push(F(String(g), !0)), t.push('"');
1048
1048
  }
1049
- const l = (h = s.props) == null ? void 0 : h.children;
1050
- let p;
1051
- if (l && typeof l == "object" && "then" in l && typeof l.then == "function" ? p = !1 : p = l != null && (Array.isArray(l) && l.length > 0 || !Array.isArray(l) && l !== !1), ft.has(o))
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))
1052
1052
  r ? t.push(" />") : t.push(">");
1053
- else if (p) {
1053
+ else if (u) {
1054
1054
  t.push(">");
1055
1055
  const d = l;
1056
- o === "script" && i || o === "style" && a ? (t.push("<![CDATA["), K(d, t, c, i, a, r, n), t.push("]]>")) : o === "script" || o === "style" ? J(d, t) : z(d, t, c, i, a, r, n), t.push("</"), t.push(o), t.push(">");
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(">");
1057
1057
  } else wt.has(o), t.push("></"), t.push(o), t.push(">");
1058
1058
  }
1059
- function K(s, t, e, i, a, r, n, h) {
1060
- if (s != null) {
1061
- if (typeof s == "string") {
1062
- t.push(mt(s));
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));
1063
1063
  return;
1064
1064
  }
1065
- if (typeof s == "number" || typeof s == "bigint" || typeof s == "boolean") {
1066
- t.push(String(s));
1065
+ if (typeof n == "number" || typeof n == "bigint" || typeof n == "boolean") {
1066
+ t.push(String(n));
1067
1067
  return;
1068
1068
  }
1069
- if (Array.isArray(s)) {
1070
- for (const o of s)
1071
- K(o, t, e, i, a, r, n);
1069
+ if (Array.isArray(n)) {
1070
+ for (const o of n)
1071
+ J(o, t, e, i, a, r, s);
1072
1072
  return;
1073
1073
  }
1074
- z(s, t, e, i, a, r, n);
1074
+ P(n, t, e, i, a, r, s);
1075
1075
  }
1076
1076
  }
1077
- function J(s, t) {
1078
- if (s != null) {
1079
- if (typeof s == "string") {
1080
- t.push(s);
1077
+ function Q(n, t) {
1078
+ if (n != null) {
1079
+ if (typeof n == "string") {
1080
+ t.push(n);
1081
1081
  return;
1082
1082
  }
1083
- if (typeof s == "number" || typeof s == "bigint" || typeof s == "boolean") {
1084
- t.push(String(s));
1083
+ if (typeof n == "number" || typeof n == "bigint" || typeof n == "boolean") {
1084
+ t.push(String(n));
1085
1085
  return;
1086
1086
  }
1087
- if (Array.isArray(s)) {
1088
- for (const e of s)
1089
- J(e, t);
1087
+ if (Array.isArray(n)) {
1088
+ for (const e of n)
1089
+ Q(e, t);
1090
1090
  return;
1091
1091
  }
1092
1092
  }
1093
1093
  }
1094
- function kt(s) {
1094
+ function kt(n) {
1095
1095
  const t = [];
1096
- for (const [e, i] of Object.entries(s))
1096
+ for (const [e, i] of Object.entries(n))
1097
1097
  if (i) {
1098
- const a = vt(e);
1098
+ const a = yt(e);
1099
1099
  t.push(`${a}: ${i}`);
1100
1100
  }
1101
1101
  return t.join("; ");
1102
1102
  }
1103
- async function j(s) {
1104
- if (s == null)
1105
- return s;
1106
- if (s && typeof s == "object" && "then" in s && typeof s.then == "function") {
1107
- const t = await s;
1108
- return j(t);
1109
- }
1110
- if (typeof s == "string" || typeof s == "number" || typeof s == "boolean" || typeof s == "bigint")
1111
- return s;
1112
- if (typeof s != "function" && typeof s != "symbol") {
1113
- if (Array.isArray(s))
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);
1109
+ }
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))
1114
1114
  return await Promise.all(
1115
- s.filter((t) => !(t == null || typeof t == "function" || typeof t == "symbol")).map((t) => j(t))
1115
+ n.filter((t) => !(t == null || typeof t == "function" || typeof t == "symbol")).map((t) => U(t))
1116
1116
  );
1117
- if (s && typeof s == "object" && "type" in s && "props" in s) {
1118
- const t = s, e = {};
1117
+ if (n && typeof n == "object" && "type" in n && "props" in n) {
1118
+ const t = n, e = {};
1119
1119
  for (const [i, a] of Object.entries(t.props))
1120
1120
  if (i === "children") {
1121
- const r = await j(a);
1121
+ const r = await U(a);
1122
1122
  r != null && (e.children = r);
1123
1123
  } else {
1124
1124
  if (typeof a == "function" || typeof a == "symbol")
@@ -1132,24 +1132,24 @@ async function j(s) {
1132
1132
  }
1133
1133
  }
1134
1134
  }
1135
- function Wt(s, t = {}) {
1136
- return s && typeof s == "object" && "node" in s ? R(s, t) : s === void 0 ? "" : R(s, t);
1135
+ function Wt(n, t = {}) {
1136
+ return n && typeof n == "object" && "node" in n ? R(n, t) : n === void 0 ? "" : R(n, t);
1137
1137
  }
1138
- async function At(s) {
1139
- return await j(s);
1138
+ async function At(n) {
1139
+ return await U(n);
1140
1140
  }
1141
- function St(...s) {
1141
+ function St(...n) {
1142
1142
  const t = new Uint8Array(
1143
- s.reduceRight((i, a) => i + a.length, 0)
1143
+ n.reduceRight((i, a) => i + a.length, 0)
1144
1144
  );
1145
1145
  let e = 0;
1146
- for (const i of s)
1146
+ for (const i of n)
1147
1147
  t.set(i, e), e += i.length;
1148
1148
  return t;
1149
1149
  }
1150
- async function Ct(s) {
1150
+ async function Ct(n) {
1151
1151
  const t = new CompressionStream("deflate"), e = t.writable.getWriter();
1152
- e.write(s), e.close();
1152
+ e.write(n), e.close();
1153
1153
  const i = t.readable.getReader(), a = [];
1154
1154
  let r = 0;
1155
1155
  for (; ; ) {
@@ -1157,102 +1157,223 @@ async function Ct(s) {
1157
1157
  if (o) break;
1158
1158
  a.push(c), r += c.length;
1159
1159
  }
1160
- const n = new Uint8Array(r);
1160
+ const s = new Uint8Array(r);
1161
1161
  let h = 0;
1162
1162
  for (const o of a)
1163
- n.set(o, h), h += o.length;
1164
- return n;
1163
+ s.set(o, h), h += o.length;
1164
+ return s;
1165
1165
  }
1166
- const Q = new Uint32Array(256);
1167
- for (let s = 0; s < 256; s++) {
1168
- let t = s;
1166
+ const X = new Uint32Array(256);
1167
+ for (let n = 0; n < 256; n++) {
1168
+ let t = n;
1169
1169
  for (let e = 0; e < 8; e++)
1170
1170
  t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
1171
- Q[s] = t;
1171
+ X[n] = t;
1172
1172
  }
1173
- function Mt(s) {
1173
+ function Mt(n) {
1174
1174
  let t = 4294967295;
1175
- for (let e = 0; e < s.length; e++)
1176
- t = Q[(t ^ s[e]) & 255] ^ t >>> 8;
1175
+ for (let e = 0; e < n.length; e++)
1176
+ t = X[(t ^ n[e]) & 255] ^ t >>> 8;
1177
1177
  return (t ^ 4294967295) >>> 0;
1178
1178
  }
1179
- const qt = new TextEncoder();
1180
- function N(s, t) {
1179
+ const Ht = new TextEncoder();
1180
+ function N(n, t) {
1181
1181
  const e = new Uint8Array(8 + t.length + 4), i = new DataView(e.buffer);
1182
- i.setUint32(0, t.length), e.set(qt.encode(s), 4), e.set(t, 8);
1182
+ i.setUint32(0, t.length), e.set(Ht.encode(n), 4), e.set(t, 8);
1183
1183
  const a = Mt(e.subarray(4, e.length - 4));
1184
1184
  return i.setUint32(e.length - 4, a), e;
1185
1185
  }
1186
- function Ht(s) {
1187
- return s <= 1 ? 1 : s <= 3 ? 2 : s <= 15 ? 4 : 8;
1186
+ function qt(n) {
1187
+ return n <= 1 ? 1 : n <= 3 ? 2 : n <= 15 ? 4 : 8;
1188
1188
  }
1189
- function Nt(s, t, e, i) {
1190
- const a = 8 / i, r = Math.ceil(t / a) + 1, n = new Uint8Array(r * e), h = new DataView(n.buffer);
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);
1191
1191
  for (let o = 0; o < e; o++) {
1192
1192
  h.setUint8(o * r, 0);
1193
1193
  for (let c = 0; c < t; c++) {
1194
- const l = s.getUint8(o * t + c), p = o * r + 1 + Math.floor(c / a), d = (a - 1 - c % a) * i, g = h.getUint8(p);
1195
- h.setUint8(p, g | l << d);
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);
1196
1196
  }
1197
1197
  }
1198
- return n;
1198
+ return s;
1199
1199
  }
1200
- new TextDecoder();
1201
- async function jt(s, t, e, i) {
1202
- const a = new DataView(s.buffer), r = a.byteLength;
1200
+ const Ut = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), jt = new TextDecoder();
1201
+ function Et(n) {
1202
+ switch (n) {
1203
+ case 0:
1204
+ return "greyscale";
1205
+ case 2:
1206
+ return "truecolor";
1207
+ case 3:
1208
+ return "indexed";
1209
+ case 4:
1210
+ return "greyscale-alpha";
1211
+ case 6:
1212
+ return "truecolor-alpha";
1213
+ default:
1214
+ throw new Error(`Invalid color type: ${n}`);
1215
+ }
1216
+ }
1217
+ function Pt(n) {
1218
+ switch (n) {
1219
+ case 0:
1220
+ return "none";
1221
+ case 1:
1222
+ return "adam7";
1223
+ default:
1224
+ throw new Error(`Invalid interlace method: ${n}`);
1225
+ }
1226
+ }
1227
+ function Dt(n, t) {
1228
+ const e = {
1229
+ 0: [1, 2, 4, 8, 16],
1230
+ // Greyscale
1231
+ 2: [8, 16],
1232
+ // Truecolor
1233
+ 3: [1, 2, 4, 8],
1234
+ // Indexed
1235
+ 4: [8, 16],
1236
+ // Greyscale with alpha
1237
+ 6: [8, 16]
1238
+ // Truecolor with alpha
1239
+ }[t];
1240
+ if (!e)
1241
+ throw new Error(`Invalid color type: ${t}`);
1242
+ if (!e.includes(n))
1243
+ throw new Error(
1244
+ `Invalid bit depth ${n} for color type ${t}. Allowed: ${e.join(", ")}`
1245
+ );
1246
+ return !0;
1247
+ }
1248
+ function zt(n, t) {
1249
+ if (t + 12 > n.byteLength)
1250
+ throw new Error(
1251
+ `Chunk at offset ${t} extends beyond data (need at least 12 bytes for header)`
1252
+ );
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)
1255
+ throw new Error(
1256
+ `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${r}, available: ${n.byteLength - t})`
1257
+ );
1258
+ const s = new DataView(n.buffer, n.byteOffset + t + 8, e);
1259
+ return {
1260
+ type: a,
1261
+ data: s,
1262
+ offset: t,
1263
+ totalSize: r
1264
+ };
1265
+ }
1266
+ function* It(n, t = 0) {
1267
+ let e = t;
1268
+ for (; e < n.byteLength; ) {
1269
+ const i = zt(n, e);
1270
+ yield i, e += i.totalSize;
1271
+ }
1272
+ }
1273
+ function Ft(n, t, e, i = 0) {
1274
+ for (const a of It(n, i))
1275
+ if (a.type === t)
1276
+ return e(a.data);
1277
+ }
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);
1282
+ if (t === 0)
1283
+ throw new Error("IHDR width cannot be zero");
1284
+ if (e === 0)
1285
+ throw new Error("IHDR height cannot be zero");
1286
+ if (r !== 0)
1287
+ throw new Error(
1288
+ `Invalid compression method: ${r}. Only 0 (deflate) is supported.`
1289
+ );
1290
+ if (s !== 0)
1291
+ throw new Error(
1292
+ `Invalid filter method: ${s}. Only 0 (adaptive) is supported.`
1293
+ );
1294
+ Dt(i, a);
1295
+ const o = Et(a), c = Pt(h);
1296
+ return {
1297
+ width: t,
1298
+ height: e,
1299
+ bitDepth: i,
1300
+ colorType: o,
1301
+ compressionMethod: "deflate",
1302
+ filterMethod: "adaptive",
1303
+ interlaceMethod: c
1304
+ };
1305
+ }
1306
+ function Bt(n) {
1307
+ if (n.byteLength < 8)
1308
+ throw new Error("Data too short to contain PNG signature");
1309
+ for (let t = 0; t < 8; t++)
1310
+ if (n.getUint8(t) !== Ut[t])
1311
+ throw new Error("Invalid PNG signature");
1312
+ return !0;
1313
+ }
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);
1318
+ if (r === void 0)
1319
+ throw new Error("IHDR chunk not found in PNG");
1320
+ return r;
1321
+ }
1322
+ async function Rt(n, t, e, i) {
1323
+ const a = new DataView(n.buffer), r = a.byteLength;
1203
1324
  if (r === 0)
1204
1325
  throw new Error("Received empty input");
1205
1326
  if (r !== t * e)
1206
1327
  throw new Error(
1207
1328
  `Input does not match dimensions ${t}x${e}. Only ${r} bytes were given when ${t * e} are expected!`
1208
1329
  );
1209
- let n = 0;
1330
+ let s = 0;
1210
1331
  for (let w = 0; w < r; w++) {
1211
1332
  const m = a.getUint8(w);
1212
- m > n && (n = m);
1333
+ m > s && (s = m);
1213
1334
  }
1214
- if (i.length <= n)
1335
+ if (i.length <= s)
1215
1336
  throw new Error(
1216
- `Color palette does not have enough colors (${n + 1}). Only ${i.length} were given!`
1337
+ `Color palette does not have enough colors (${s + 1}). Only ${i.length} were given!`
1217
1338
  );
1218
- const h = Ht(n), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), l = new DataView(c.buffer);
1339
+ const h = qt(s), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), l = new DataView(c.buffer);
1219
1340
  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);
1220
- const p = N("IHDR", c), d = new Uint8Array(i.length * 3), g = new DataView(d.buffer);
1221
- for (let w = 0; w <= n; w++)
1341
+ const u = N("IHDR", c), d = new Uint8Array(i.length * 3), g = new DataView(d.buffer);
1342
+ for (let w = 0; w <= s; w++)
1222
1343
  g.setUint8(w * 3, i[w][0]), g.setUint8(w * 3 + 1, i[w][1]), g.setUint8(w * 3 + 2, i[w][2]);
1223
- const u = N("PLTE", d), f = Nt(a, t, e, h), $ = N("IDAT", await Ct(f)), k = N("IEND", new Uint8Array(0));
1224
- return St(o, p, u, $, k);
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);
1225
1346
  }
1226
- async function Pt(s, t = {}) {
1347
+ async function Zt(n, t = {}) {
1227
1348
  var e;
1228
1349
  const {
1229
1350
  margin: i = 4,
1230
1351
  moduleSize: a = 4,
1231
1352
  backgroundColor: r = [255, 255, 255],
1232
- foregroundColor: n = [0, 0, 0]
1233
- } = t, { matrix: h } = s, o = ((e = h[0]) == null ? void 0 : e.length) ?? 0, c = h.length, l = (o + i * 2) * a, p = (c + i * 2) * a, d = new Uint8Array(l * p);
1353
+ 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);
1234
1355
  d.fill(0);
1235
1356
  for (let g = 0; g < c; g++)
1236
- for (let u = 0; u < o; u++)
1237
- if (h[g][u])
1357
+ for (let p = 0; p < o; p++)
1358
+ if (h[g][p])
1238
1359
  for (let f = 0; f < a; f++)
1239
1360
  for (let $ = 0; $ < a; $++) {
1240
- const k = (u + i) * a + $, w = (g + i) * a + f;
1361
+ const k = (p + i) * a + $, w = (g + i) * a + f;
1241
1362
  d[w * l + k] = 1;
1242
1363
  }
1243
1364
  return {
1244
- bytes: await jt(d, l, p, [r, n]),
1365
+ bytes: await Rt(d, l, u, [r, s]),
1245
1366
  width: l,
1246
- height: p
1367
+ height: u
1247
1368
  };
1248
1369
  }
1249
- function Ut(s) {
1370
+ function Vt(n) {
1250
1371
  const t = {};
1251
- for (const [e, i] of Object.entries(s))
1372
+ for (const [e, i] of Object.entries(n))
1252
1373
  i !== void 0 && (t[e] = i);
1253
1374
  return t;
1254
1375
  }
1255
- class X extends q {
1376
+ class Y extends H {
1256
1377
  charWidth = 12;
1257
1378
  charHeight = 24;
1258
1379
  // Default to charWidth * 2, can be overridden
@@ -1262,7 +1383,7 @@ class X extends q {
1262
1383
  lineAlign = 0;
1263
1384
  lineWidth = 48;
1264
1385
  lineHeight = 1;
1265
- textEncoding = "multilingual";
1386
+ textEncoding = "cp437";
1266
1387
  feedMinimum = 24;
1267
1388
  spacing = !1;
1268
1389
  defaultFont = "'Courier Prime', monospace";
@@ -1328,16 +1449,18 @@ class X extends q {
1328
1449
  boxSizing: "border-box",
1329
1450
  wordWrap: "break-word",
1330
1451
  overflowWrap: "break-word",
1331
- overflow: "hidden"
1452
+ overflow: "hidden",
1453
+ display: "flex",
1454
+ flexDirection: "column"
1332
1455
  },
1333
1456
  children: this.contentNodes
1334
1457
  };
1335
1458
  e && (a.lang = e);
1336
- const n = await At({
1459
+ const s = await At({
1337
1460
  type: "div",
1338
1461
  props: a
1339
1462
  });
1340
- return Wt(n);
1463
+ return Wt(s);
1341
1464
  }
1342
1465
  // set print area:
1343
1466
  async area(t, e, i) {
@@ -1364,7 +1487,8 @@ class X extends q {
1364
1487
  borderTop: "2px solid black",
1365
1488
  marginLeft: `${this.lineMargin}ch`,
1366
1489
  width: `${t}ch`,
1367
- height: "0"
1490
+ height: "0",
1491
+ display: "flex"
1368
1492
  }
1369
1493
  }
1370
1494
  };
@@ -1372,14 +1496,14 @@ class X extends q {
1372
1496
  }
1373
1497
  // print vertical rules:
1374
1498
  async vr(t, e) {
1375
- const i = this.charWidth, a = i / 2, r = this.charHeight * e, n = t.reduce((l, p) => l + p, 0) + t.length + 1;
1499
+ const i = this.charWidth, a = i / 2, r = this.charHeight * e, s = t.reduce((l, u) => l + u, 0) + t.length + 1;
1376
1500
  let h = `M${a},0v${r}`;
1377
1501
  for (const l of t)
1378
1502
  h += `m${l * i + i},${-r}v${r}`;
1379
- const o = n * i, c = {
1503
+ const o = s * i, c = {
1380
1504
  type: "svg",
1381
1505
  props: {
1382
- width: `${n}ch`,
1506
+ width: `${s}ch`,
1383
1507
  height: `${r}`,
1384
1508
  viewBox: `0 0 ${o} ${r}`,
1385
1509
  preserveAspectRatio: "none",
@@ -1404,7 +1528,7 @@ class X extends q {
1404
1528
  }
1405
1529
  // start rules:
1406
1530
  async vrstart(t) {
1407
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, r = e * 2, n = this.buildVrStartPath(t), h = {
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 = {
1408
1532
  type: "svg",
1409
1533
  props: {
1410
1534
  width: `${i}ch`,
@@ -1412,13 +1536,13 @@ class X extends q {
1412
1536
  viewBox: `0 0 ${a} ${r}`,
1413
1537
  preserveAspectRatio: "none",
1414
1538
  style: {
1415
- display: "block",
1539
+ display: "flex",
1416
1540
  marginLeft: `${this.lineMargin}ch`
1417
1541
  },
1418
1542
  children: {
1419
1543
  type: "path",
1420
1544
  props: {
1421
- d: n,
1545
+ d: s,
1422
1546
  fill: "none",
1423
1547
  stroke: "black",
1424
1548
  "stroke-width": "2",
@@ -1433,14 +1557,14 @@ class X extends q {
1433
1557
  const e = this.charWidth, i = e / 2;
1434
1558
  let a = `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`;
1435
1559
  for (let r = 0; r < t.length; r++) {
1436
- const n = t[r] ?? 0;
1437
- a += `h${e * n}h${i}v${e}m0,${-e}h${i}`;
1560
+ const s = t[r] ?? 0;
1561
+ a += `h${e * s}h${i}v${e}m0,${-e}h${i}`;
1438
1562
  }
1439
1563
  return a = a.replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`), a;
1440
1564
  }
1441
1565
  // stop rules:
1442
1566
  async vrstop(t) {
1443
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, r = e * 2, n = this.buildVrStopPath(t), h = {
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 = {
1444
1568
  type: "svg",
1445
1569
  props: {
1446
1570
  width: `${i}ch`,
@@ -1448,13 +1572,12 @@ class X extends q {
1448
1572
  viewBox: `0 0 ${a} ${r}`,
1449
1573
  preserveAspectRatio: "none",
1450
1574
  style: {
1451
- display: "block",
1452
1575
  marginLeft: `${this.lineMargin}ch`
1453
1576
  },
1454
1577
  children: {
1455
1578
  type: "path",
1456
1579
  props: {
1457
- d: n,
1580
+ d: s,
1458
1581
  fill: "none",
1459
1582
  stroke: "black",
1460
1583
  "stroke-width": "2",
@@ -1469,31 +1592,30 @@ class X extends q {
1469
1592
  const e = this.charWidth, i = e / 2;
1470
1593
  let a = `M${i},0v${i}q0,${i},${i},${i}`;
1471
1594
  for (let r = 0; r < t.length; r++) {
1472
- const n = t[r] ?? 0;
1473
- a += `h${e * n}h${i}v${-e}m0,${e}h${i}`;
1595
+ const s = t[r] ?? 0;
1596
+ a += `h${e * s}h${i}v${-e}m0,${e}h${i}`;
1474
1597
  }
1475
1598
  return a = a.replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`), a;
1476
1599
  }
1477
1600
  // print vertical and horizontal rules:
1478
1601
  async vrhr(t, e, i, a) {
1479
- const r = this.charWidth, n = 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, p = r * 2;
1480
- let d = `M${n},0` + (i > 0 ? `v${n}q0,${n},${n},${n}` : `v${r}h${n}`);
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}`);
1481
1604
  for (const f of t)
1482
- d += `h${r * f}h${n}v${-r}m0,${r}h${n}`;
1483
- d = d.replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${n},0,${n},${-n}v${-n}` : `h${n}v${-r}`);
1484
- let g = `M${n},${r + r}` + (i < 0 ? `v${-n}q0,${-n},${n},${-n}` : `v${-r}h${n}`);
1605
+ d += `h${r * f}h${s}v${-r}m0,${r}h${s}`;
1606
+ 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}`);
1485
1608
  for (const f of e)
1486
- g += `h${r * f}h${n}v${r}m0,${-r}h${n}`;
1487
- g = g.replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${n},0,${n},${n}v${n}` : `h${n}v${r}`);
1488
- const u = {
1609
+ g += `h${r * f}h${s}v${r}m0,${-r}h${s}`;
1610
+ 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 = {
1489
1612
  type: "svg",
1490
1613
  props: {
1491
1614
  width: `${c}ch`,
1492
- height: `${p}`,
1493
- viewBox: `0 0 ${l} ${p}`,
1615
+ height: `${u}`,
1616
+ viewBox: `0 0 ${l} ${u}`,
1494
1617
  preserveAspectRatio: "none",
1495
1618
  style: {
1496
- display: "block",
1497
1619
  marginLeft: `${this.lineMargin + Math.max(-i, 0)}ch`
1498
1620
  },
1499
1621
  children: [
@@ -1502,7 +1624,7 @@ class X extends q {
1502
1624
  ]
1503
1625
  }
1504
1626
  };
1505
- return this.contentNodes.push(u), "";
1627
+ return this.contentNodes.push(p), "";
1506
1628
  }
1507
1629
  // set line spacing and feed new line:
1508
1630
  async vrlf(t) {
@@ -1539,7 +1661,8 @@ class X extends q {
1539
1661
  props: {
1540
1662
  style: {
1541
1663
  flex: "1",
1542
- borderTop: "2px dashed black"
1664
+ borderTop: "2px dashed black",
1665
+ display: "flex"
1543
1666
  }
1544
1667
  }
1545
1668
  }
@@ -1563,7 +1686,7 @@ class X extends q {
1563
1686
  // scale up text:
1564
1687
  async wh(t) {
1565
1688
  const e = t < 2 ? t + 1 : t - 1, i = t < 3 ? t : t - 1;
1566
- return this.currentStyles.fontSize = `${i}em`, this.currentStyles.display = "inline-block", e !== i && (this.currentStyles.transform = `scaleX(${e / i})`, this.currentStyles.transformOrigin = "left"), this.lineHeight = Math.max(this.lineHeight, i), this.textScale = e, "";
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, "";
1567
1690
  }
1568
1691
  // cancel text decoration:
1569
1692
  async normal() {
@@ -1585,36 +1708,37 @@ class X extends q {
1585
1708
  const t = this.lineHeight * this.charHeight, e = Math.max(t, this.feedMinimum), i = this.lineMargin + this.lineWidth, a = [];
1586
1709
  if (this.lineSegments.length === 0) {
1587
1710
  if (this.pendingVrSvg) {
1588
- const n = {
1711
+ const s = {
1589
1712
  type: "div",
1590
1713
  props: {
1591
1714
  style: {
1592
1715
  position: "relative",
1593
1716
  width: `${this.containerWidth}px`,
1594
- height: `${e}px`
1717
+ height: `${e}px`,
1718
+ display: "flex"
1595
1719
  },
1596
1720
  children: this.pendingVrSvg
1597
1721
  }
1598
1722
  };
1599
- this.contentNodes.push(n), this.pendingVrSvg = null, this.estimatedHeight += e;
1723
+ this.contentNodes.push(s), this.pendingVrSvg = null, this.estimatedHeight += e;
1600
1724
  }
1601
1725
  return this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1602
1726
  } else {
1603
- const n = [...this.lineSegments].sort((p, d) => p.position - d.position);
1727
+ const s = [...this.lineSegments].sort((u, d) => u.position - d.position);
1604
1728
  let h = 0;
1605
- const o = (p) => Math.floor(p), c = (p) => `${o(p)}ch`, l = (p) => {
1606
- const d = p.match(/^(\d+(?:\.\d+)?)ch$/);
1729
+ const o = (u) => Math.floor(u), c = (u) => `${o(u)}ch`, l = (u) => {
1730
+ const d = u.match(/^(\d+(?:\.\d+)?)ch$/);
1607
1731
  return d ? parseFloat(d[1]) : 0;
1608
1732
  };
1609
- for (let p = 0; p < n.length; p++) {
1610
- const d = n[p], g = this.lineMargin + d.position, u = d.charWidth * d.scale;
1733
+ for (let u = 0; u < s.length; u++) {
1734
+ const d = s[u], g = this.lineMargin + d.position, p = d.charWidth * d.scale;
1611
1735
  if (g > h && a.length > 0) {
1612
- const W = g - h, y = a[a.length - 1];
1613
- if (y && y.props && y.props.style && typeof y.props.style == "object" && !Array.isArray(y.props.style)) {
1614
- const A = y.props.style, x = A.flexBasis;
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;
1615
1739
  if (x) {
1616
- const F = l(x) + W;
1617
- A.flexBasis = c(F);
1740
+ const D = l(x) + W;
1741
+ A.flexBasis = c(D);
1618
1742
  } else
1619
1743
  A.flexBasis = c(W);
1620
1744
  }
@@ -1630,7 +1754,7 @@ class X extends q {
1630
1754
  });
1631
1755
  }
1632
1756
  const $ = {
1633
- flexBasis: c(u),
1757
+ flexBasis: c(p),
1634
1758
  whiteSpace: "pre"
1635
1759
  }, k = d.styles && Object.keys(d.styles).length > 0, w = k ? d.styles : void 0, m = {
1636
1760
  type: "span",
@@ -1646,17 +1770,17 @@ class X extends q {
1646
1770
  } : d.text
1647
1771
  }
1648
1772
  };
1649
- a.push(m), h = g + u;
1773
+ a.push(m), h = g + p;
1650
1774
  }
1651
1775
  if (h < i && a.length > 0) {
1652
- const p = i - h, d = a[a.length - 1];
1776
+ const u = i - h, d = a[a.length - 1];
1653
1777
  if (d && d.props && d.props.style && typeof d.props.style == "object" && !Array.isArray(d.props.style)) {
1654
- const g = d.props.style, u = g.flexBasis;
1655
- if (u) {
1656
- const $ = l(u) + p;
1778
+ const g = d.props.style, p = g.flexBasis;
1779
+ if (p) {
1780
+ const $ = l(p) + u;
1657
1781
  g.flexBasis = c($);
1658
1782
  } else
1659
- g.flexBasis = c(p);
1783
+ g.flexBasis = c(u);
1660
1784
  }
1661
1785
  }
1662
1786
  }
@@ -1673,13 +1797,14 @@ class X extends q {
1673
1797
  }
1674
1798
  };
1675
1799
  if (this.pendingVrSvg) {
1676
- const n = {
1800
+ const s = {
1677
1801
  type: "div",
1678
1802
  props: {
1679
1803
  style: {
1680
1804
  position: "relative",
1681
1805
  width: `${this.containerWidth}px`,
1682
- minHeight: `${e}px`
1806
+ minHeight: `${e}px`,
1807
+ display: "flex"
1683
1808
  },
1684
1809
  children: [
1685
1810
  // VR SVG positioned absolutely behind text
@@ -1698,7 +1823,7 @@ class X extends q {
1698
1823
  ]
1699
1824
  }
1700
1825
  };
1701
- this.contentNodes.push(n), this.pendingVrSvg = null;
1826
+ this.contentNodes.push(s), this.pendingVrSvg = null;
1702
1827
  } else
1703
1828
  this.contentNodes.push(r);
1704
1829
  return this.estimatedHeight += e, this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
@@ -1709,44 +1834,45 @@ class X extends q {
1709
1834
  }
1710
1835
  // print image:
1711
1836
  async image(t) {
1712
- const e = this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right", i = {
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 = {
1713
1838
  type: "img",
1714
1839
  props: {
1715
1840
  src: `data:image/png;base64,${t}`,
1716
- style: Ut({
1717
- display: "block",
1841
+ style: Vt({
1718
1842
  maxWidth: `${this.lineWidth}ch`
1719
- })
1843
+ }),
1844
+ width: `${r}`,
1845
+ height: `${s}`
1720
1846
  }
1721
- }, a = {
1847
+ }, o = {
1722
1848
  type: "div",
1723
1849
  props: {
1724
1850
  style: {
1725
- textAlign: e,
1851
+ justifyContent: e,
1726
1852
  paddingLeft: `${this.lineMargin}ch`,
1727
- width: `${this.lineWidth}ch`
1853
+ width: `${this.lineWidth}ch`,
1854
+ display: "flex"
1728
1855
  },
1729
- children: i
1856
+ children: h
1730
1857
  }
1731
1858
  };
1732
- return this.contentNodes.push(a), "";
1859
+ return this.contentNodes.push(o), "";
1733
1860
  }
1734
1861
  // print QR Code (async version using PNG):
1735
1862
  async qrcode(t, e) {
1736
- const i = O({
1863
+ const i = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", a = _({
1737
1864
  data: t.data,
1738
1865
  ec: t.level === "l" ? C.L : t.level === "m" ? C.M : t.level === "q" ? C.Q : C.H
1739
- }), a = t.cell, r = t.quietZone ? 4 : 0, { bytes: n, width: h, height: o } = await Pt(i, {
1740
- moduleSize: a,
1741
- margin: r
1742
- }), l = {
1866
+ }), r = t.cell, s = t.quietZone ? 4 : 0, { bytes: h, width: o, height: c } = await Zt(a, {
1867
+ moduleSize: r,
1868
+ margin: s
1869
+ }), u = {
1743
1870
  type: "img",
1744
1871
  props: {
1745
- src: `data:image/png;base64,${V(n)}`,
1746
- width: `${h}`,
1747
- height: `${o}`,
1872
+ src: `data:image/png;base64,${O(h)}`,
1873
+ width: `${o}`,
1874
+ height: `${c}`,
1748
1875
  style: {
1749
- display: "inline-block",
1750
1876
  imageRendering: "pixelated"
1751
1877
  }
1752
1878
  }
@@ -1754,36 +1880,37 @@ class X extends q {
1754
1880
  type: "div",
1755
1881
  props: {
1756
1882
  style: {
1757
- textAlign: this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right",
1883
+ justifyContent: i,
1758
1884
  paddingLeft: `${this.lineMargin}ch`,
1759
- width: `${this.lineWidth}ch`
1885
+ width: `${this.lineWidth}ch`,
1886
+ display: "flex"
1760
1887
  },
1761
- children: [l]
1888
+ children: [u]
1762
1889
  }
1763
1890
  };
1764
- return this.contentNodes.push(d), this.estimatedHeight += o, "";
1891
+ return this.contentNodes.push(d), this.estimatedHeight += c, "";
1765
1892
  }
1766
1893
  // print barcode:
1767
1894
  async barcode(t, e) {
1768
- const i = G(t), a = i.height;
1895
+ const i = K(t), a = i.height, r = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end";
1769
1896
  if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
1770
- const r = i.length, n = a + (i.hri ? this.charHeight + 2 : 0);
1771
- let h = "";
1772
- i.widths.reduce((d, g, u) => (u % 2 === 1 && (h += `M${d},0h${g}v${a}h${-g}z`), d + g), 0);
1773
- const o = [
1897
+ const s = i.length, h = a + (i.hri ? this.charHeight + 2 : 0);
1898
+ 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);
1900
+ const c = [
1774
1901
  {
1775
1902
  type: "path",
1776
1903
  props: {
1777
- d: h,
1904
+ d: o,
1778
1905
  fill: "black"
1779
1906
  }
1780
1907
  }
1781
1908
  ];
1782
- i.hri && i.text && o.push({
1909
+ i.hri && i.text && c.push({
1783
1910
  type: "text",
1784
1911
  props: {
1785
- x: `${r / 2}`,
1786
- y: `${n}`,
1912
+ x: `${s / 2}`,
1913
+ y: `${h}`,
1787
1914
  "text-anchor": "middle",
1788
1915
  "font-family": "monospace",
1789
1916
  "font-size": `${this.charWidth * 2}`,
@@ -1791,29 +1918,27 @@ class X extends q {
1791
1918
  children: i.text
1792
1919
  }
1793
1920
  });
1794
- const c = {
1921
+ const l = {
1795
1922
  type: "svg",
1796
1923
  props: {
1797
- width: `${r}`,
1798
- height: `${n}`,
1799
- viewBox: `0 0 ${r} ${n}`,
1800
- style: {
1801
- display: "inline-block"
1802
- },
1803
- children: o
1924
+ width: `${s}`,
1925
+ height: `${h}`,
1926
+ viewBox: `0 0 ${s} ${h}`,
1927
+ children: c
1804
1928
  }
1805
- }, p = {
1929
+ }, u = {
1806
1930
  type: "div",
1807
1931
  props: {
1808
1932
  style: {
1809
- textAlign: this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right",
1933
+ justifyContent: r,
1810
1934
  paddingLeft: `${this.lineMargin}ch`,
1811
- width: `${this.lineWidth}ch`
1935
+ width: `${this.lineWidth}ch`,
1936
+ display: "flex"
1812
1937
  },
1813
- children: c
1938
+ children: l
1814
1939
  }
1815
1940
  };
1816
- this.contentNodes.push(p), this.estimatedHeight += n;
1941
+ this.contentNodes.push(u), this.estimatedHeight += h;
1817
1942
  }
1818
1943
  return "";
1819
1944
  }
@@ -1824,7 +1949,7 @@ class X extends q {
1824
1949
  return this.estimatedHeight;
1825
1950
  }
1826
1951
  }
1827
- class Y extends q {
1952
+ class tt extends H {
1828
1953
  logs = [];
1829
1954
  /**
1830
1955
  * Start printing.
@@ -2029,28 +2154,28 @@ class Y extends q {
2029
2154
  return 0;
2030
2155
  }
2031
2156
  }
2032
- const B = {
2033
- base: new q(),
2034
- svg: new E(),
2035
- html: new X(),
2036
- audit: new Y()
2157
+ const z = {
2158
+ base: new H(),
2159
+ svg: new I(),
2160
+ html: new Y(),
2161
+ audit: new tt()
2037
2162
  };
2038
- function zt(s) {
2039
- const t = Object.assign({}, s), 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 B ? B[i] : B.svg);
2040
- let n;
2041
- return r instanceof X || r instanceof E || r instanceof Y || r instanceof q ? n = r : n = new E(), {
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);
2165
+ let s;
2166
+ return r instanceof Y || r instanceof I || r instanceof tt || r instanceof H ? s = r : s = new I(), {
2042
2167
  cpl: t.cpl || 48,
2043
2168
  charWidth: t.charWidth || 12,
2044
2169
  encoding: e,
2045
2170
  spacing: !!t.spacing,
2046
2171
  margin: t.margin || 0,
2047
2172
  marginRight: t.marginRight || 0,
2048
- target: n
2173
+ target: s
2049
2174
  };
2050
2175
  }
2051
- function Ft(s, t) {
2052
- const e = s.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) => {
2053
- let n = {
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) => {
2178
+ let s = {
2054
2179
  align: 1,
2055
2180
  wrap: t.wrap,
2056
2181
  border: t.border,
@@ -2058,36 +2183,36 @@ function Ft(s, t) {
2058
2183
  alignment: t.align
2059
2184
  };
2060
2185
  const h = i.replace(/^[\t ]+|[\t ]+$/g, "");
2061
- if (n.align = 1 + Number(/^[\t ]/.test(i)) - Number(/[\t ]$/.test(i)), /^\{[^{}]*\}$/.test(h)) {
2062
- if (n.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2186
+ if (s.align = 1 + Number(/^[\t ]/.test(i)) - Number(/[\t ]$/.test(i)), /^\{[^{}]*\}$/.test(h)) {
2187
+ if (s.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2063
2188
  const l = { a: "align", b: "border", c: "code", i: "image", o: "option", t: "text", w: "width", x: "command", _: "comment" };
2064
2189
  return /^[\t ]*$/.test(c) || c.replace(
2065
2190
  /^[\t ]*([A-Za-z_]\w*)[\t ]*:[\t ]*([^\t ].*?)[\t ]*$/,
2066
- (d, g, u) => {
2191
+ (d, g, p) => {
2067
2192
  const f = g.replace(/^[abciotwx_]$/, ($) => l[$] || $);
2068
- return o[f] = I(u.replace(/\\n/g, `
2193
+ return o[f] = Z(p.replace(/\\n/g, `
2069
2194
  `)), d;
2070
2195
  }
2071
- ) === c && (n.error = h), o;
2196
+ ) === c && (s.error = h), o;
2072
2197
  }, {}), r.length === 1) {
2073
- if ("text" in n.property && n.property.text) {
2074
- const o = n.property.text.toLowerCase();
2198
+ if ("text" in s.property && s.property.text) {
2199
+ const o = s.property.text.toLowerCase();
2075
2200
  t.wrap = !/^nowrap$/.test(o);
2076
2201
  }
2077
- if ("border" in n.property && n.property.border) {
2078
- const o = n.property.border.toLowerCase(), c = { line: -1, space: 1, none: 0 }, l = t.border;
2079
- t.border = /^(line|space|none)$/.test(o) ? c[o] ?? 1 : /^\d+$/.test(o) && Number(o) <= 2 ? Number(o) : 1, l >= 0 && t.border < 0 && (n.vr = "+"), l < 0 && t.border >= 0 && (n.vr = "-");
2202
+ if ("border" in s.property && s.property.border) {
2203
+ const o = s.property.border.toLowerCase(), c = { line: -1, space: 1, none: 0 }, l = t.border;
2204
+ t.border = /^(line|space|none)$/.test(o) ? c[o] ?? 1 : /^\d+$/.test(o) && Number(o) <= 2 ? Number(o) : 1, l >= 0 && t.border < 0 && (s.vr = "+"), l < 0 && t.border >= 0 && (s.vr = "-");
2080
2205
  }
2081
- if ("width" in n.property && n.property.width) {
2082
- const o = n.property.width.toLowerCase().split(/[\t ]+|,/);
2206
+ if ("width" in s.property && s.property.width) {
2207
+ const o = s.property.width.toLowerCase().split(/[\t ]+|,/);
2083
2208
  t.width = o.find((c) => /^auto$/.test(c)) ? [] : o.map((c) => /^\*$/.test(c) ? -1 : /^\d+$/.test(c) ? Number(c) : 0);
2084
2209
  }
2085
- if ("align" in n.property && n.property.align) {
2086
- const o = n.property.align.toLowerCase(), c = { left: 0, center: 1, right: 2 };
2210
+ if ("align" in s.property && s.property.align) {
2211
+ const o = s.property.align.toLowerCase(), c = { left: 0, center: 1, right: 2 };
2087
2212
  t.align = /^(left|center|right)$/.test(o) ? c[o] ?? 1 : 1;
2088
2213
  }
2089
- if ("option" in n.property && n.property.option) {
2090
- const o = n.property.option.toLowerCase().split(/[\t ]+|,/);
2214
+ if ("option" in s.property && s.property.option) {
2215
+ const o = s.property.option.toLowerCase().split(/[\t ]+|,/);
2091
2216
  t.option = {
2092
2217
  type: o.find((c) => /^(upc|ean|jan|code39|itf|codabar|nw7|code93|code128|qrcode)$/.test(c)) || "code128",
2093
2218
  width: Number(o.find((c) => /^\d+$/.test(c) && Number(c) >= 2 && Number(c) <= 4) || "2"),
@@ -2098,77 +2223,77 @@ function Ft(s, t) {
2098
2223
  quietZone: !1
2099
2224
  };
2100
2225
  }
2101
- if ("code" in n.property && n.property.code && (t.option.type === "qrcode" ? n.code = Object.assign({ data: n.property.code, type: "qrcode" }, t.option) : n.code = Object.assign({ data: n.property.code, type: t.option.type }, t.option)), "image" in n.property && n.property.image) {
2102
- const o = n.property.image.replace(/=.*|[^A-Za-z0-9+/]/g, "");
2226
+ if ("code" in s.property && s.property.code && (t.option.type === "qrcode" ? s.code = Object.assign({ data: s.property.code, type: "qrcode" }, t.option) : s.code = Object.assign({ data: s.property.code, type: t.option.type }, t.option)), "image" in s.property && s.property.image) {
2227
+ const o = s.property.image.replace(/=.*|[^A-Za-z0-9+/]/g, "");
2103
2228
  switch (o.length % 4) {
2104
2229
  case 1:
2105
- n.image = o.slice(0, -1);
2230
+ s.image = o.slice(0, -1);
2106
2231
  break;
2107
2232
  case 2:
2108
- n.image = o + "==";
2233
+ s.image = o + "==";
2109
2234
  break;
2110
2235
  case 3:
2111
- n.image = o + "=";
2236
+ s.image = o + "=";
2112
2237
  break;
2113
2238
  default:
2114
- n.image = o;
2239
+ s.image = o;
2115
2240
  break;
2116
2241
  }
2117
2242
  }
2118
- "command" in n.property && n.property.command && (n.command = n.property.command), "comment" in n.property && n.property.comment && (n.comment = n.property.comment);
2243
+ "command" in s.property && s.property.command && (s.command = s.property.command), "comment" in s.property && s.property.comment && (s.comment = s.property.comment);
2119
2244
  }
2120
2245
  } else if (/[{}]/.test(h))
2121
- n.error = h;
2246
+ s.error = h;
2122
2247
  else if (r.length === 1 && /^-+$|^=+$/.test(h)) {
2123
2248
  const o = h.slice(-1);
2124
- n.hr = o === "-" || o === "=" ? o : void 0;
2249
+ s.hr = o === "-" || o === "=" ? o : void 0;
2125
2250
  } else
2126
- n.text = h.replace(/[\x00-\x1f\x7f]|\\x[01][\dA-Fa-f]|\\x7[Ff]/g, "").replace(/\\[-=_"`^~]/g, (o) => "\\x" + o.charCodeAt(1).toString(16)).replace(/\\n/g, `
2127
- `).replace(/~/g, " ").split(/([_"`\n]|\^+)/).map((o) => I(o));
2128
- if (n.wrap = t.wrap, n.border = t.border, t.width.length === 0)
2129
- n.width = -1;
2130
- else if ("text" in n)
2131
- n.width = a < t.width.length ? t.width[a] ?? 0 : 0;
2251
+ s.text = h.replace(/[\x00-\x1f\x7f]|\\x[01][\dA-Fa-f]|\\x7[Ff]/g, "").replace(/\\[-=_"`^~]/g, (o) => "\\x" + o.charCodeAt(1).toString(16)).replace(/\\n/g, `
2252
+ `).replace(/~/g, " ").split(/([_"`\n]|\^+)/).map((o) => Z(o));
2253
+ if (s.wrap = t.wrap, s.border = t.border, t.width.length === 0)
2254
+ s.width = -1;
2255
+ else if ("text" in s)
2256
+ s.width = a < t.width.length ? t.width[a] ?? 0 : 0;
2132
2257
  else if (t.width.find((o) => o < 0))
2133
- n.width = -1;
2258
+ s.width = -1;
2134
2259
  else {
2135
2260
  const o = t.width.filter((c) => c > 0);
2136
- n.width = o.length > 0 ? o.reduce((c, l) => c + l, n.border < 0 ? o.length + 1 : (o.length - 1) * n.border) : 0;
2261
+ s.width = o.length > 0 ? o.reduce((c, l) => c + l, s.border < 0 ? o.length + 1 : (o.length - 1) * s.border) : 0;
2137
2262
  }
2138
- return n.alignment = t.align, n;
2263
+ return s.alignment = t.align, s;
2139
2264
  });
2140
2265
  if (e.every((i) => "text" in i) && t.width.length > 0)
2141
2266
  for (; e.length < t.width.length; )
2142
2267
  e.push({ align: 1, text: [""], wrap: t.wrap, border: t.border, width: t.width[e.length] ?? 0, alignment: t.align });
2143
2268
  return e;
2144
2269
  }
2145
- function I(s) {
2146
- return s.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)));
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)));
2147
2272
  }
2148
- function Bt(s, t) {
2273
+ function Gt(n, t) {
2149
2274
  const e = [];
2150
- let i = s.width, a = 1, r = [], n = !1, h = !1, o = !1, c = 0;
2151
- return s.text.forEach((l, p) => {
2152
- if (p % 2 === 0) {
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) {
2153
2278
  let d = t.target.arrayFrom(l, t.encoding);
2154
2279
  for (; d.length > 0; ) {
2155
- let g = 0, u = 0;
2156
- for (; u < d.length && (g = t.target.measureText(d[u] ?? "", t.encoding) * (c < 2 ? c + 1 : c - 1), !(g > i)); )
2157
- i -= g, g = 0, u++;
2158
- if (u > 0 && (r.push((n ? "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 > s.width) {
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) {
2159
2284
  d = d.slice(1);
2160
2285
  continue;
2161
2286
  }
2162
- (g > i || i === 0) && (e.push({ data: r, margin: i * s.align / 2, height: a }), i = s.width, r = [], a = 1);
2287
+ (g > i || i === 0) && (e.push({ data: r, margin: i * n.align / 2, height: a }), i = n.width, r = [], a = 1);
2163
2288
  }
2164
2289
  } else
2165
2290
  switch (l) {
2166
2291
  case `
2167
2292
  `:
2168
- e.push({ data: r, margin: i * s.align / 2, height: a }), i = s.width, r = [], a = 1;
2293
+ e.push({ data: r, margin: i * n.align / 2, height: a }), i = n.width, r = [], a = 1;
2169
2294
  break;
2170
2295
  case "_":
2171
- n = !n;
2296
+ s = !s;
2172
2297
  break;
2173
2298
  case '"':
2174
2299
  h = !h;
@@ -2181,58 +2306,58 @@ function Bt(s, t) {
2181
2306
  c = c === d ? 0 : d;
2182
2307
  break;
2183
2308
  }
2184
- }), r.length > 0 && e.push({ data: r, margin: i * s.align / 2, height: a }), e;
2309
+ }), r.length > 0 && e.push({ data: r, margin: i * n.align / 2, height: a }), e;
2185
2310
  }
2186
- async function Et(s, t, e) {
2187
- const i = [], a = s.every((f) => "text" in f), r = s[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2188
- let n = s.filter((f) => f.width !== 0);
2189
- a && (n = n.slice(0, Math.floor(r.border < 0 ? (t.target.cpl - 1) / 2 : (t.target.cpl + r.border) / (r.border + 1))));
2190
- const h = n.filter((f) => f.width > 0), o = n.filter((f) => f.width < 0);
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);
2314
+ 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);
2191
2316
  let c = h.reduce((f, $) => f + $.width, 0), l = t.target.cpl - c;
2192
- a && n.length > 0 && (l -= r.border < 0 ? n.length + 1 : (n.length - 1) * r.border);
2193
- const p = o.length;
2194
- for (; p > l; ) {
2317
+ 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; ) {
2195
2320
  const f = h.reduce(($, k) => $.width > k.width ? $ : k);
2196
2321
  f.width--, l++;
2197
2322
  }
2198
- p > 0 && (o.forEach((f, $) => f.width = Math.floor((l + $) / p)), l = 0);
2199
- const d = Math.floor(l * r.alignment / 2), g = t.target.cpl - l, u = l - d;
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;
2200
2325
  if (a) {
2201
- const f = n.map((w) => Bt(w, t)), $ = n.map((w) => w.width);
2326
+ const f = s.map((w) => Gt(w, t)), $ = s.map((w) => w.width);
2202
2327
  switch (e.line) {
2203
2328
  case "ready":
2204
2329
  i.push(
2205
- 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)
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)
2206
2331
  ), e.line = "running";
2207
2332
  break;
2208
2333
  case "horizontal":
2209
- const w = d - e.rules.left, m = g - e.rules.width, W = Math.min(d, e.rules.left), y = Math.min(u, e.rules.right);
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);
2210
2335
  i.push(
2211
- await t.target.normal() + await t.target.area(W, t.target.cpl - W - y, y) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
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()
2212
2337
  ), e.line = "running";
2213
2338
  break;
2214
2339
  }
2215
- e.rules = { left: d, width: g, right: u, widths: $ };
2340
+ e.rules = { left: d, width: g, right: p, widths: $ };
2216
2341
  const k = r.wrap ? f.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2217
2342
  for (let w = 0; w < k; w++) {
2218
- let m = await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(0), W = 0;
2343
+ let m = await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0), W = 0;
2219
2344
  if (e.line === "running") {
2220
- const y = f.reduce((A, x) => w < x.length ? Math.max(A, x[w]?.height ?? 1) : A, 1);
2221
- m += await t.target.normal() + await t.target.absolute(W++) + await t.target.vr($, y);
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);
2222
2347
  }
2223
- for (let y = 0; y < f.length; y++) {
2224
- const A = f[y];
2348
+ for (let v = 0; v < f.length; v++) {
2349
+ const A = f[v];
2225
2350
  if (A) {
2226
2351
  if (m += await t.target.absolute(W), w < A.length) {
2227
2352
  m += await t.target.relative(A[w]?.margin ?? 0);
2228
2353
  const x = A[w]?.data ?? [];
2229
2354
  for (let S = 0; S < x.length; S += 2) {
2230
- const F = Number(String(x[S])[0]), tt = Number(String(x[S])[1]), et = Number(String(x[S])[2]), Z = Number(String(x[S])[3]);
2231
- m += await t.target.normal(), F && (m += await t.target.ul()), tt && (m += await t.target.em()), et && (m += await t.target.iv()), Z && (m += await t.target.wh(Z)), m += await t.target.text(String(x[S + 1]), t.encoding);
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);
2232
2357
  }
2233
2358
  } else
2234
2359
  m += await t.target.normal() + await t.target.text(" ", t.encoding);
2235
- W += (n[y]?.width ?? 0) + Math.abs(r.border);
2360
+ W += (s[v]?.width ?? 0) + Math.abs(r.border);
2236
2361
  }
2237
2362
  }
2238
2363
  m += await t.target.lf(), i.push(m);
@@ -2255,7 +2380,7 @@ async function Et(s, t, e) {
2255
2380
  switch (e.line) {
2256
2381
  case "waiting":
2257
2382
  i.push(
2258
- 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()
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()
2259
2384
  );
2260
2385
  break;
2261
2386
  case "running":
@@ -2278,17 +2403,17 @@ async function Et(s, t, e) {
2278
2403
  break;
2279
2404
  }
2280
2405
  return "image" in r && r.image && i.push(
2281
- await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(r.align) + await t.target.image(r.image)
2406
+ await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.image(r.image)
2282
2407
  ), "code" in r && r.code && (r.code.type === "qrcode" ? i.push(
2283
- 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)
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)
2284
2409
  ) : i.push(
2285
- 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)
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)
2286
2411
  )), "command" in r && r.command && i.push(
2287
- await t.target.normal() + await t.target.area(d, g, u) + await t.target.align(r.align) + await t.target.command(r.command)
2412
+ await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(r.align) + await t.target.command(r.command)
2288
2413
  ), i.join("");
2289
2414
  }
2290
- async function Lt(s, t) {
2291
- const e = zt(t);
2415
+ async function Yt(n, t) {
2416
+ const e = Ot(t);
2292
2417
  await e.target.lock();
2293
2418
  try {
2294
2419
  const i = {
@@ -2301,24 +2426,24 @@ async function Lt(s, t) {
2301
2426
  rules: { left: 0, width: 0, right: 0, widths: [] }
2302
2427
  };
2303
2428
  let a = await e.target.open(e);
2304
- s[0] === "\uFEFF" && (s = s.slice(1));
2305
- const r = s.normalize().split(/\n|\r\n|\r/), n = [];
2429
+ n[0] === "\uFEFF" && (n = n.slice(1));
2430
+ const r = n.normalize().split(/\n|\r\n|\r/), s = [];
2306
2431
  for (const h of r)
2307
- n.push(await Et(Ft(h, i), e, i));
2432
+ s.push(await Kt(_t(h, i), e, i));
2308
2433
  switch (i.line) {
2309
2434
  case "ready":
2310
2435
  i.line = "waiting";
2311
2436
  break;
2312
2437
  case "running":
2313
2438
  case "horizontal":
2314
- n.push(
2439
+ s.push(
2315
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)
2316
2441
  ), i.line = "waiting";
2317
2442
  break;
2318
2443
  default:
2319
2444
  break;
2320
2445
  }
2321
- return a += n.join(""), a += await e.target.close(), {
2446
+ return a += s.join(""), a += await e.target.close(), {
2322
2447
  content: a,
2323
2448
  width: e.target.calculatedWidth(),
2324
2449
  height: Math.round(e.target.calculatedHeight())
@@ -2328,9 +2453,9 @@ async function Lt(s, t) {
2328
2453
  }
2329
2454
  }
2330
2455
  export {
2331
- Y as AuditTarget,
2332
- q as BaseTarget,
2333
- X as HtmlTarget,
2334
- E as SvgTarget,
2335
- Lt as transform
2456
+ tt as AuditTarget,
2457
+ H as BaseTarget,
2458
+ Y as HtmlTarget,
2459
+ I as SvgTarget,
2460
+ Yt as transform
2336
2461
  };