@levischuck/receiptline 0.1.1 → 0.1.3

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,6 +1,6 @@
1
- import { decodeBase64 as V, encodeBase64 as O } from "@levischuck/tiny-encodings";
1
+ import { decodeBase64 as Z, encodeBase64 as O } from "@levischuck/tiny-encodings";
2
2
  import { qrCode as _, EcLevel as M } from "@levischuck/tiny-qr";
3
- import { toSvgString as it } from "@levischuck/tiny-qr-svg";
3
+ import { toSvgString as nt } from "@levischuck/tiny-qr-svg";
4
4
  class H {
5
5
  locked = !1;
6
6
  lockPromise = null;
@@ -26,20 +26,20 @@ 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 {
33
33
  await Promise.race([
34
34
  this.lockPromise,
35
- new Promise((a, s) => {
35
+ new Promise((a, r) => {
36
36
  e.signal.addEventListener("abort", () => {
37
- s(new Error(`Lock timeout after ${t}ms`));
37
+ r(new Error(`Lock timeout after ${t}ms`));
38
38
  });
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,14 +58,14 @@ 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((r, h) => {
66
+ n = a.reduce((s, h) => {
67
67
  const o = h.codePointAt(0);
68
- return o === void 0 ? r : r + (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,23 +74,23 @@ class H {
74
74
  case "ksc5601":
75
75
  case "cp950":
76
76
  case "big5":
77
- i = a.reduce((r, h) => {
77
+ n = a.reduce((s, h) => {
78
78
  const o = h.codePointAt(0);
79
- return o === void 0 ? r : r + (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 s = a.reduce((r, h) => {
83
+ const r = a.reduce((s, h) => {
84
84
  const o = h.codePointAt(0);
85
- return o === void 0 || (r.consonant ? o === 3633 || o >= 3636 && o <= 3642 || o === 3655 ? r.vowel ? (r.length += 2, r.consonant = r.vowel = r.tone = !1) : r.vowel = !0 : o >= 3656 && o <= 3659 ? r.tone ? (r.length += 2, r.consonant = r.vowel = r.tone = !1) : r.tone = !0 : o === 3635 || o >= 3660 && o <= 3662 ? r.vowel || r.tone ? (r.length += 2, r.consonant = r.vowel = r.tone = !1) : (r.length += o === 3635 ? 2 : 1, r.consonant = !1) : o >= 3585 && o <= 3630 ? (r.length++, r.vowel = r.tone = !1) : (r.length += 2, r.consonant = r.vowel = r.tone = !1) : o >= 3585 && o <= 3630 ? r.consonant = !0 : r.length++), r;
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
- s.consonant && (s.length++, s.consonant = s.vowel = s.tone = !1), i = s.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((s) => s.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((s, r) => {
109
- const h = r.codePointAt(0);
110
- return h === void 0 || (s.consonant ? h === 3633 || h >= 3636 && h <= 3642 || h === 3655 ? s.vowel ? (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : s.vowel = r : h >= 3656 && h <= 3659 ? s.tone ? (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : s.tone = r : h === 3635 || h >= 3660 && h <= 3662 ? s.vowel || s.tone ? (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : (s.result.push(s.consonant + r), s.consonant = "") : h >= 3585 && h <= 3630 ? (s.result.push(s.consonant + s.vowel + s.tone), s.consonant = r, s.vowel = s.tone = "") : (s.result.push(s.consonant + s.vowel + s.tone, r), s.consonant = s.vowel = s.tone = "") : h >= 3585 && h <= 3630 ? s.consonant = r : s.result.push(r)), s;
108
+ const a = n.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:
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
  /**
@@ -204,7 +204,7 @@ class H {
204
204
  * @param {number} dr difference in right position
205
205
  * @returns {Promise<string>} commands
206
206
  */
207
- async vrhr(t, e, i, a) {
207
+ async vrhr(t, e, n, a) {
208
208
  return "";
209
209
  }
210
210
  /**
@@ -329,49 +329,49 @@ const y = {
329
329
  shift: 98,
330
330
  stop: 106
331
331
  };
332
- function E(n, t, e) {
333
- n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[\x00-_])+/, (s) => (s.split("").forEach((r) => e.push((r.charCodeAt(0) + 64) % 96)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (s) => (e.push((s.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), E(y.shift, i, e)) : t.length > 0 && P(y.atob, t, e);
332
+ function j(i, t, e) {
333
+ 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), ""));
334
+ const n = t.slice(1), a = n.search(/[^ -_]/);
335
+ /^\d{4,}/.test(t) ? L(y.atoc, t, e) : a >= 0 && n.charCodeAt(a) < 32 ? (e.push(y.shift, t.charCodeAt(0) - 32), j(y.shift, n, e)) : t.length > 0 && E(y.atob, t, e);
336
336
  }
337
- function P(n, t, e) {
338
- n !== y.shift && e.push(n), t = t.replace(/^((?!\d{4,})[ -\x7f])+/, (s) => (s.split("").forEach((r) => e.push(r.charCodeAt(0) - 32)), "")), t = t.replace(/^\d(?=(\d\d){2,}(\D|$))/, (s) => (e.push(s.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), P(y.shift, i, e)) : t.length > 0 && E(y.btoa, t, e);
337
+ function E(i, t, e) {
338
+ 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), ""));
339
+ const n = t.slice(1), a = n.search(/[^ -_]/);
340
+ /^\d{4,}/.test(t) ? L(y.btoc, t, e) : a >= 0 && n.charCodeAt(a) > 95 ? (e.push(y.shift, t.charCodeAt(0) + 64), E(y.shift, n, e)) : t.length > 0 && j(y.btoa, t, e);
341
341
  }
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, (s) => (e.push(Number(s)), "")));
344
- const i = t.search(/[^ -_]/);
345
- i >= 0 && t.charCodeAt(i) < 32 ? E(y.ctoa, t, e) : t.length > 0 && P(y.ctob, t, e);
342
+ function L(i, t, e) {
343
+ i !== y.shift && e.push(i), t = t.replace(/^\d{4,}/g, (a) => a.replace(/\d{2}/g, (r) => (e.push(Number(r)), "")));
344
+ const n = t.search(/[^ -_]/);
345
+ n >= 0 && t.charCodeAt(n) < 32 ? j(y.ctoa, t, e) : t.length > 0 && E(y.ctob, t, e);
346
346
  }
347
- function rt(n) {
347
+ function st(i) {
348
348
  const t = {};
349
- let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
349
+ let e = i.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
350
350
  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 ? E(y.starta, e, i) : e.length > 0 && P(y.startb, e, i), i.push(i.reduce((h, o, c) => h + o * c) % 103, y.stop);
354
- const s = n.quietZone ? "a" : "0", r = i.reduce((h, o) => h + y.element[o], s) + s;
355
- t.widths = r.split("").map((h) => parseInt(h, 16) * n.width), t.length = n.width * (i.length * 11 + (n.quietZone ? 22 : 2)), t.height = n.height;
351
+ t.hri = i.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
352
+ const n = [], a = e.search(/[^ -_]/);
353
+ /^\d{2}$/.test(e) ? n.push(y.startc, Number(e)) : /^\d{4,}/.test(e) ? L(y.startc, e, n) : a >= 0 && e.charCodeAt(a) < 32 ? j(y.starta, e, n) : e.length > 0 && E(y.startb, e, n), n.push(n.reduce((h, o, c) => h + o * c) % 103, y.stop);
354
+ const r = i.quietZone ? "a" : "0", s = n.reduce((h, o) => h + y.element[o], r) + r;
355
+ 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
356
  }
357
357
  return t;
358
358
  }
359
359
  const C = {
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((n, t, e) => (n[t] = e, n), {}),
361
+ code: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-. $/+%dcsp".split("").reduce((i, t, e) => (i[t] = e, i), {}),
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 st(n) {
366
+ function rt(i) {
367
367
  const t = {};
368
- let e = n.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
368
+ let e = i.data.replace(/((?!^[\x00-\x7f]+$).)*/, "");
369
369
  if (e.length > 0) {
370
- t.hri = n.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
371
- const i = e.split("").reduce((r, h) => r + C.escape[h.charCodeAt(0)], "").split("").map((r) => C.code[r]);
372
- i.push(i.reduceRight((r, h, o) => r + h * ((i.length - 1 - o) % 20 + 1)) % 47), i.push(i.reduceRight((r, h, o) => r + h * ((i.length - 1 - o) % 15 + 1)) % 47), i.unshift(C.start), i.push(C.stop);
373
- const a = n.quietZone ? "a" : "0", s = i.reduce((r, h) => r + C.element[h], a) + a;
374
- t.widths = s.split("").map((r) => parseInt(r, 16) * n.width), t.length = n.width * (i.length * 9 + (n.quietZone ? 21 : 1)), t.height = n.height;
370
+ t.hri = i.hri, t.text = e.replace(/[\x00- \x7f]/g, " ");
371
+ const n = e.split("").reduce((s, h) => s + C.escape[h.charCodeAt(0)], "").split("").map((s) => C.code[s]);
372
+ 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(C.start), n.push(C.stop);
373
+ const a = i.quietZone ? "a" : "0", r = n.reduce((s, h) => s + C.element[h], a) + a;
374
+ 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
375
  }
376
376
  return t;
377
377
  }
@@ -397,15 +397,15 @@ const at = {
397
397
  C: "2225255",
398
398
  D: "2225552"
399
399
  };
400
- function ot(n) {
400
+ function ot(i) {
401
401
  const t = {};
402
- let e = n.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
402
+ let e = i.data.replace(/((?!^[A-D][0-9\-$:/.+]+[A-D]$).)*/i, "");
403
403
  if (e.length > 0) {
404
- t.hri = n.hri, t.text = e;
405
- const i = n.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((r, h) => r + at[h] + "2", i).slice(0, -1) + i;
406
- t.widths = a.split("").map((r) => parseInt(r, 16) * n.width + 1 >> 1);
407
- const s = [25, 39, 50, 3, 5, 6];
408
- t.length = e.length * s[n.width - 2] - (e.match(/[\d\-$]/g) || []).length * s[n.width + 1] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
404
+ t.hri = i.hri, t.text = e;
405
+ const n = i.quietZone ? "a" : "0", a = e.toUpperCase().split("").reduce((s, h) => s + at[h] + "2", n).slice(0, -1) + n;
406
+ t.widths = a.split("").map((s) => parseInt(s, 16) * i.width + 1 >> 1);
407
+ const r = [25, 39, 50, 3, 5, 6];
408
+ 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
409
  }
410
410
  return t;
411
411
  }
@@ -414,20 +414,20 @@ const q = {
414
414
  start: "2222",
415
415
  stop: "522"
416
416
  };
417
- function ht(n) {
417
+ function ht(i) {
418
418
  const t = {};
419
- let e = n.data.replace(/((?!^(\d{2})+$).)*/, "");
419
+ let e = i.data.replace(/((?!^(\d{2})+$).)*/, "");
420
420
  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";
423
- let s = a + q.start, r = 0;
424
- for (; r < i.length; ) {
425
- const o = q.element[i[r++]], c = q.element[i[r++]];
426
- s += o.split("").reduce((l, u, d) => l + u + c[d], "");
421
+ t.hri = i.hri, t.text = e;
422
+ const n = e.split("").map((o) => Number(o)), a = i.quietZone ? "a" : "0";
423
+ let r = a + q.start, s = 0;
424
+ for (; s < n.length; ) {
425
+ const o = q.element[n[s++]], c = q.element[n[s++]];
426
+ r += o.split("").reduce((d, u, l) => d + u + c[l], "");
427
427
  }
428
- s += q.stop + a, t.widths = s.split("").map((o) => parseInt(o, 16) * n.width + 1 >> 1);
428
+ r += q.stop + a, t.widths = r.split("").map((o) => parseInt(o, 16) * i.width + 1 >> 1);
429
429
  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;
430
+ t.length = e.length * h[i.width - 2] + h[i.width + 1] + i.width * (i.quietZone ? 20 : 0), t.height = i.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(n) {
480
+ function lt(i) {
481
481
  const t = {};
482
- let e = n.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
482
+ let e = i.data.replace(/((?!^\*?[0-9A-Z\-. $/+%]+\*?$).)*/, "");
483
483
  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((r, h) => r + ct[h] + "2", i).slice(0, -1) + i;
486
- t.widths = a.split("").map((r) => parseInt(r, 16) * n.width + 1 >> 1);
487
- const s = [29, 45, 58];
488
- t.length = e.length * s[n.width - 2] + n.width * (n.quietZone ? 19 : -1), t.height = n.height;
484
+ e = e.replace(/^\*?([^*]+)\*?$/, "*$1*"), t.hri = i.hri, t.text = e;
485
+ const n = i.quietZone ? "a" : "0", a = e.split("").reduce((s, h) => s + ct[h] + "2", n).slice(0, -1) + n;
486
+ t.widths = a.split("").map((s) => parseInt(s, 16) * i.width + 1 >> 1);
487
+ const r = [29, 45, 58];
488
+ t.length = e.length * r[i.width - 2] + i.width * (i.quietZone ? 19 : -1), t.height = i.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(n) {
501
- const t = n.slice(0, 3);
502
- switch (n[6]) {
500
+ function dt(i) {
501
+ const t = i.slice(0, 3);
502
+ switch (i[6]) {
503
503
  case 0:
504
504
  case 1:
505
505
  case 2:
506
- t.push(n[6], 0, 0, 0, 0, n[3], n[4], n[5]);
506
+ t.push(i[6], 0, 0, 0, 0, i[3], i[4], i[5]);
507
507
  break;
508
508
  case 3:
509
- t.push(n[3], 0, 0, 0, 0, 0, n[4], n[5]);
509
+ t.push(i[3], 0, 0, 0, 0, 0, i[4], i[5]);
510
510
  break;
511
511
  case 4:
512
- t.push(n[3], n[4], 0, 0, 0, 0, 0, n[5]);
512
+ t.push(i[3], i[4], 0, 0, 0, 0, 0, i[5]);
513
513
  break;
514
514
  default:
515
- t.push(n[3], n[4], n[5], 0, 0, 0, 0, n[6]);
515
+ t.push(i[3], i[4], i[5], 0, 0, 0, 0, i[6]);
516
516
  break;
517
517
  }
518
- return t.push(n[7]), t;
518
+ return t.push(i[7]), t;
519
519
  }
520
- function G(n) {
521
- const t = {}, e = n.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((i) => Number(i));
520
+ function G(i) {
521
+ const t = {}, e = i.data.replace(/((?!^\d{12,13}$).)*/, "").split("").map((n) => Number(n));
522
522
  if (e.length > 0) {
523
- e[12] = 0, e[12] = (10 - e.reduce((a, s, r) => a + s * (r % 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;
523
+ 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("");
524
+ let n = (i.quietZone ? "b" : "0") + b.g[0];
525
+ for (let a = 1; a < 7; a++) n += b[b.p[e[0]][a - 1]][e[a]];
526
+ n += b.g[1];
527
+ for (let a = 7; a < 13; a++) n += b.c[e[a]];
528
+ n += b.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
529
  }
530
530
  return t;
531
531
  }
532
- function gt(n) {
533
- const t = {}, e = n.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((i) => Number(i));
532
+ function gt(i) {
533
+ const t = {}, e = i.data.replace(/((?!^\d{7,8}$).)*/, "").split("").map((n) => Number(n));
534
534
  if (e.length > 0) {
535
- e[7] = 0, e[7] = (10 - e.reduce((s, r, h) => s + r * (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 s = 0; s < 4; s++) a += b.a[e[s] ?? 0];
535
+ 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("");
536
+ const n = i.quietZone ? "7" : "0";
537
+ let a = n + b.g[0];
538
+ for (let r = 0; r < 4; r++) a += b.a[e[r] ?? 0];
539
539
  a += b.g[1];
540
- for (let s = 4; s < 8; s++) a += b.c[e[s] ?? 0];
541
- a += b.g[0] + i, t.widths = a.split("").map((s) => parseInt(s, 16) * n.width), t.length = n.width * (n.quietZone ? 81 : 67), t.height = n.height;
540
+ for (let r = 4; r < 8; r++) a += b.c[e[r] ?? 0];
541
+ a += b.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
542
  }
543
543
  return t;
544
544
  }
545
- function ut(n) {
545
+ function ut(i) {
546
546
  const t = {
547
- data: "0" + n.data,
548
- hri: n.hri,
549
- width: n.width,
550
- height: n.height,
551
- quietZone: n.quietZone
547
+ data: "0" + i.data,
548
+ hri: i.hri,
549
+ width: i.width,
550
+ height: i.height,
551
+ quietZone: i.quietZone
552
552
  }, e = G(t);
553
553
  return e.text && (e.text = e.text.slice(1)), e;
554
554
  }
555
- function pt(n) {
556
- const t = {}, e = n.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((i) => Number(i));
555
+ function pt(i) {
556
+ const t = {}, e = i.data.replace(/((?!^0\d{6,7}$).)*/, "").split("").map((n) => Number(n));
557
557
  if (e.length > 0) {
558
- e[7] = 0, e[7] = (10 - dt(e).reduce((s, r, h) => s + r * (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 s = 1; s < 7; s++) a += b[b.e[e[7] ?? 0][s - 1]][e[s] ?? 0];
562
- a += b.g[2] + i, t.widths = a.split("").map((s) => parseInt(s, 16) * n.width), t.length = n.width * (n.quietZone ? 65 : 51), t.height = n.height;
558
+ 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("");
559
+ const n = i.quietZone ? "7" : "0";
560
+ let a = n + 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] + 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
563
  }
564
564
  return t;
565
565
  }
566
- function K(n) {
566
+ function K(i) {
567
567
  let t = {};
568
- switch (n.type) {
568
+ switch (i.type) {
569
569
  case "upc":
570
- t = n.data.length < 9 ? pt(n) : ut(n);
570
+ t = i.data.length < 9 ? pt(i) : ut(i);
571
571
  break;
572
572
  case "ean":
573
573
  case "jan":
574
- t = n.data.length < 9 ? gt(n) : G(n);
574
+ t = i.data.length < 9 ? gt(i) : G(i);
575
575
  break;
576
576
  case "code39":
577
- t = lt(n);
577
+ t = lt(i);
578
578
  break;
579
579
  case "itf":
580
- t = ht(n);
580
+ t = ht(i);
581
581
  break;
582
582
  case "codabar":
583
583
  case "nw7":
584
- t = ot(n);
584
+ t = ot(i);
585
585
  break;
586
586
  case "code93":
587
- t = st(n);
587
+ t = rt(i);
588
588
  break;
589
589
  case "code128":
590
- t = rt(n);
590
+ t = st(i);
591
591
  break;
592
592
  }
593
593
  return t;
594
594
  }
595
- class I extends H {
595
+ class F extends H {
596
596
  charWidth = 12;
597
597
  receiptId = "";
598
598
  svgWidth = 576;
@@ -647,12 +647,12 @@ class I extends H {
647
647
  break;
648
648
  }
649
649
  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>
650
+ const e = this.calculatedWidth(), n = this.calculatedHeight();
651
+ 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
652
  `;
653
653
  }
654
654
  // set print area:
655
- async area(t, e, i) {
655
+ async area(t, e, n) {
656
656
  return this.lineMargin = t, this.lineWidth = e, "";
657
657
  }
658
658
  // set line alignment:
@@ -669,30 +669,30 @@ class I extends H {
669
669
  }
670
670
  // print horizontal rule:
671
671
  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>`, "";
672
+ const e = this.charWidth, n = `<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})">${n}</g>`, "";
674
674
  }
675
675
  // print vertical rules:
676
676
  async vr(t, e) {
677
- const i = this.charWidth, a = i / 2, s = (i + i) * e, r = '<path d="' + t.reduce((h, o) => h + `m${i * o + i},${-s}v${s}`, `M${a},0v${s}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
678
- return this.svgContent += `<g transform="translate(${this.lineMargin * i},${this.svgHeight})">${r}</g>`, "";
677
+ 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"/>';
678
+ return this.svgContent += `<g transform="translate(${this.lineMargin * n},${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((s, r) => s + `h${e * r}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, 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
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((s, r) => s + `h${e * r}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, 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
688
  return this.svgContent += `<g transform="translate(${this.lineMargin * e},${this.svgHeight})">${a}</g>`, "";
689
689
  }
690
690
  // print vertical and horizontal rules:
691
- async vrhr(t, e, i, a) {
692
- const s = this.charWidth, r = s / 2, h = '<path d="' + t.reduce((c, l) => c + `h${s * l}h${r}v${-s}m0,${s}h${r}`, `M${r},0` + (i > 0 ? `v${r}q0,${r},${r},${r}` : `v${s}h${r}`)).replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${r},0,${r},${-r}v${-r}` : `h${r}v${-s}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
693
- this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(-i, 0)) * s},${this.svgHeight})">${h}</g>`;
694
- const o = '<path d="' + e.reduce((c, l) => c + `h${s * l}h${r}v${s}m0,${-s}h${r}`, `M${r},${s + s}` + (i < 0 ? `v${-r}q0,${-r},${r},${-r}` : `v${-s}h${r}`)).replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${r},0,${r},${r}v${r}` : `h${r}v${s}`) + '" fill="none" stroke="#000" stroke-width="2"/>';
695
- return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(i, 0)) * s},${this.svgHeight})">${o}</g>`, "";
691
+ async vrhr(t, e, n, a) {
692
+ const r = this.charWidth, s = r / 2, h = '<path d="' + t.reduce((c, d) => c + `h${r * d}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"/>';
693
+ this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(-n, 0)) * r},${this.svgHeight})">${h}</g>`;
694
+ const o = '<path d="' + e.reduce((c, d) => c + `h${r * d}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"/>';
695
+ return this.svgContent += `<g transform="translate(${(this.lineMargin + Math.max(n, 0)) * r},${this.svgHeight})">${o}</g>`, "";
696
696
  }
697
697
  // set line spacing and feed new line:
698
698
  async vrlf(t) {
@@ -717,8 +717,8 @@ class I extends H {
717
717
  }
718
718
  // scale up text:
719
719
  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, "";
720
+ const e = t < 2 ? t + 1 : t - 1, n = t < 3 ? t : t - 1;
721
+ return this.textAttributes.transform = `scale(${e},${n})`, this.lineHeight = Math.max(this.lineHeight, n), this.textScale = e, "";
722
722
  }
723
723
  // cancel text decoration:
724
724
  async normal() {
@@ -726,12 +726,12 @@ class I extends H {
726
726
  }
727
727
  // print text:
728
728
  async text(t, e) {
729
- let i = this.textPosition;
730
- const a = this.arrayFrom(t, e).reduce((r, h) => {
731
- const o = this.measureText(h, e) * this.textScale, c = Math.floor((i + o / 2) * this.charWidth / this.textScale);
732
- return i += o, r + `<tspan x="${c}">${h.replace(/[ &<>]/g, (l) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[l] || l)}</tspan>`;
733
- }, ""), s = Object.keys(this.textAttributes).reduce((r, h) => r + ` ${h}="${this.textAttributes[h]}"`, "");
734
- return this.textElement += `<text${s}>${a}</text>`, this.textPosition += this.measureText(t, e) * this.textScale, "";
729
+ let n = this.textPosition;
730
+ const a = this.arrayFrom(t, e).reduce((s, h) => {
731
+ const o = this.measureText(h, e) * this.textScale, c = Math.floor((n + o / 2) * this.charWidth / this.textScale);
732
+ return n += o, s + `<tspan x="${c}">${h.replace(/[ &<>]/g, (d) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[d] || d)}</tspan>`;
733
+ }, ""), r = Object.keys(this.textAttributes).reduce((s, h) => s + ` ${h}="${this.textAttributes[h]}"`, "");
734
+ return this.textElement += `<text${r}>${a}</text>`, this.textPosition += this.measureText(t, e) * this.textScale, "";
735
735
  }
736
736
  // feed new line:
737
737
  async lf() {
@@ -744,35 +744,35 @@ class I extends H {
744
744
  }
745
745
  // print image:
746
746
  async image(t) {
747
- const e = V(t), i = new DataView(e.buffer), a = i.getUint32(16, !1), s = i.getUint32(20, !1), r = `<image href="data:image/png;base64,${O(e)}" x="0" y="0" width="${a}" height="${s}"/>`, 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})">${r}</g>`, this.svgHeight += s, "";
747
+ const e = Z(t), n = new DataView(e.buffer), a = n.getUint32(16, !1), r = n.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 = _({
752
+ const n = _({
753
753
  data: t.data,
754
754
  ec: t.level == "l" ? M.L : t.level == "m" ? M.M : t.level == "q" ? M.Q : M.H
755
- }), a = i.width, s = t.cell, r = await it(i, {
756
- moduleSize: s,
755
+ }), a = n.width, r = t.cell, s = await nt(n, {
756
+ moduleSize: r,
757
757
  margin: t.quietZone ? 4 : 0,
758
758
  output: "path"
759
- }), h = typeof r == "string" ? r : r.path || r.svg || String(r), o = a * s + (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
- return this.svgContent += `<g transform="translate(${c},${l})" shape-rendering="crispEdges">
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), d = Math.floor(this.svgHeight);
760
+ return this.svgContent += `<g transform="translate(${c},${d})" 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 = K(t), a = i.height;
767
- if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
768
- const s = i.length, r = a + (i.hri ? this.charWidth * 2 + 2 : 0);
766
+ const n = K(t), a = n.height;
767
+ if (a !== void 0 && "length" in n && n.length !== void 0 && n.widths) {
768
+ const r = n.length, s = a + (n.hri ? this.charWidth * 2 + 2 : 0);
769
769
  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((s - (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="${r}">${l}</text>`;
770
+ if (n.widths.reduce((c, d, u) => (u % 2 === 1 && (h += `M${c},0h${d}v${a}h${-d}z`), c + d), 0), h += '" fill="#000"/>', n.hri && n.text) {
771
+ const c = Math.floor((r - (this.measureText(n.text, e) - 1) * this.charWidth) / 2), d = this.arrayFrom(n.text, e).reduce((u, l, g) => u + `<tspan x="${c + this.charWidth * g}">${l.replace(/[ &<>]/g, (p) => ({ " ": "&#xa0;", "&": "&amp;", "<": "&lt;", ">": "&gt;" })[p] || p)}</tspan>`, "");
772
+ h += `<text y="${s}">${d}</text>`;
773
773
  }
774
- const o = Math.floor(this.lineMargin * this.charWidth + (this.lineWidth * this.charWidth - s) * this.lineAlign / 2);
775
- this.svgContent += `<g transform="translate(${o},${this.svgHeight})">${h}</g>`, this.svgHeight += r;
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 += s;
776
776
  }
777
777
  return "";
778
778
  }
@@ -967,163 +967,163 @@ const ft = /* @__PURE__ */ new Set([
967
967
  dArr: "⇓",
968
968
  hArr: "⇔"
969
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;
970
+ for (const [i, t] of Object.entries($t))
971
+ T[t] || (T[t] = i);
972
+ function I(i, t = !1) {
973
+ if (!i || typeof i != "string")
974
+ return i;
975
+ let e = i;
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(n) {
979
- return n.replace(/\]\]>/g, "]]]]><![CDATA[>");
978
+ function mt(i) {
979
+ return i.replace(/\]\]>/g, "]]]]><![CDATA[>");
980
980
  }
981
- function yt(n) {
982
- return n.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
981
+ function yt(i) {
982
+ return i.replace(/[A-Z]/g, (t) => `-${t.toLowerCase()}`);
983
983
  }
984
984
  const vt = {
985
985
  className: "class",
986
986
  htmlFor: "for"
987
987
  };
988
- function bt(n, t) {
989
- return t === "reactName" ? n : t === "exactName" || t === "eitherName" ? vt[n] ?? n : n;
988
+ function bt(i, t) {
989
+ return t === "reactName" ? i : t === "exactName" || t === "eitherName" ? vt[i] ?? i : i;
990
990
  }
991
- function R(n, t = {}) {
991
+ function V(i, t = {}) {
992
992
  const e = [];
993
- let i, a, s;
994
- if (n && typeof n == "object" && "node" in n) {
995
- const l = n;
996
- i = l.node, a = l.xml ?? t.xml, s = l.doctype ?? t.doctype;
993
+ let n, a, r;
994
+ if (i && typeof i == "object" && "node" in i) {
995
+ const d = i;
996
+ n = d.node, a = d.xml ?? t.xml, r = d.doctype ?? t.doctype;
997
997
  } else
998
- i = n, a = t.xml, s = t.doctype;
998
+ n = i, a = t.xml, r = t.doctype;
999
999
  a && (e.push(a), a.endsWith(`
1000
1000
  `) || e.push(`
1001
- `)), s && (e.push(s), s.endsWith(`
1001
+ `)), r && (e.push(r), r.endsWith(`
1002
1002
  `) || e.push(`
1003
1003
  `));
1004
- const r = t.useCDataForScripts ?? !1, h = t.useCDataForStyles ?? !1, o = t.voidTrailingSlash ?? !0, c = t.attributeNaming ?? "eitherName";
1005
- return j(i, e, "HTML", r, 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(n, e, "HTML", s, h, o, c), e.join("");
1006
1006
  }
1007
- function j(n, t, e, i, a, s, r) {
1008
- if (n != null) {
1009
- if (typeof n == "string") {
1010
- t.push(F(n, !1));
1007
+ function P(i, t, e, n, a, r, s) {
1008
+ if (i != null) {
1009
+ if (typeof i == "string") {
1010
+ t.push(I(i, !1));
1011
1011
  return;
1012
1012
  }
1013
- if (typeof n == "number" || typeof n == "bigint") {
1014
- t.push(String(n));
1013
+ if (typeof i == "number" || typeof i == "bigint") {
1014
+ t.push(String(i));
1015
1015
  return;
1016
1016
  }
1017
- if (typeof n == "boolean") {
1018
- t.push(String(n));
1017
+ if (typeof i == "boolean") {
1018
+ t.push(String(i));
1019
1019
  return;
1020
1020
  }
1021
- if (Array.isArray(n)) {
1022
- for (const h of n)
1023
- j(h, t, e, i, a, s, r);
1021
+ if (Array.isArray(i)) {
1022
+ for (const h of i)
1023
+ P(h, t, e, n, a, r, s);
1024
1024
  return;
1025
1025
  }
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, s, r);
1026
+ 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) {
1027
+ xt(i, t, e, n, a, r, s);
1028
1028
  return;
1029
1029
  }
1030
1030
  }
1031
1031
  }
1032
- function xt(n, t, e, i, a, s, r) {
1032
+ function xt(i, t, e, n, a, r, s) {
1033
1033
  var h;
1034
- const o = n.type;
1034
+ const o = i.type;
1035
1035
  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)) {
1038
- if (d === "children" || g === !1 || g === null || g === void 0)
1036
+ if (o === "svg" ? c = "SVG" : o === "math" && (c = "MATHML"), t.push("<"), t.push(o), i.props)
1037
+ for (const [l, g] of Object.entries(i.props)) {
1038
+ if (l === "children" || g === !1 || g === null || g === void 0)
1039
1039
  continue;
1040
- const p = bt(d, r);
1040
+ const p = bt(l, s);
1041
1041
  if (g === !0)
1042
1042
  t.push(" "), t.push(p);
1043
- else if (d === "style" && typeof g == "object") {
1044
- const f = kt(g);
1045
- f && (t.push(' style="'), t.push(F(f, !0)), t.push('"'));
1043
+ else if (l === "style" && typeof g == "object") {
1044
+ const f = Wt(g);
1045
+ f && (t.push(' style="'), t.push(I(f, !0)), t.push('"'));
1046
1046
  } else
1047
- t.push(" "), t.push(p), t.push('="'), t.push(F(String(g), !0)), t.push('"');
1047
+ t.push(" "), t.push(p), t.push('="'), t.push(I(String(g), !0)), t.push('"');
1048
1048
  }
1049
- const l = (h = n.props) == null ? void 0 : h.children;
1049
+ const d = (h = i.props) == null ? void 0 : h.children;
1050
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
- s ? t.push(" />") : t.push(">");
1051
+ if (d && typeof d == "object" && "then" in d && typeof d.then == "function" ? u = !1 : u = d != null && (Array.isArray(d) && d.length > 0 || !Array.isArray(d) && d !== !1), ft.has(o))
1052
+ r ? t.push(" />") : t.push(">");
1053
1053
  else if (u) {
1054
1054
  t.push(">");
1055
- const d = l;
1056
- o === "script" && i || o === "style" && a ? (t.push("<![CDATA["), J(d, t, c, i, a, s, r), t.push("]]>")) : o === "script" || o === "style" ? Q(d, t) : j(d, t, c, i, a, s, r), t.push("</"), t.push(o), t.push(">");
1055
+ const l = d;
1056
+ o === "script" && n || o === "style" && a ? (t.push("<![CDATA["), J(l, t, c, n, a, r, s), t.push("]]>")) : o === "script" || o === "style" ? Q(l, t) : P(l, t, c, n, 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 J(n, t, e, i, a, s, r, h) {
1060
- if (n != null) {
1061
- if (typeof n == "string") {
1062
- t.push(mt(n));
1059
+ function J(i, t, e, n, a, r, s, h) {
1060
+ if (i != null) {
1061
+ if (typeof i == "string") {
1062
+ t.push(mt(i));
1063
1063
  return;
1064
1064
  }
1065
- if (typeof n == "number" || typeof n == "bigint" || typeof n == "boolean") {
1066
- t.push(String(n));
1065
+ if (typeof i == "number" || typeof i == "bigint" || typeof i == "boolean") {
1066
+ t.push(String(i));
1067
1067
  return;
1068
1068
  }
1069
- if (Array.isArray(n)) {
1070
- for (const o of n)
1071
- J(o, t, e, i, a, s, r);
1069
+ if (Array.isArray(i)) {
1070
+ for (const o of i)
1071
+ J(o, t, e, n, a, r, s);
1072
1072
  return;
1073
1073
  }
1074
- j(n, t, e, i, a, s, r);
1074
+ P(i, t, e, n, a, r, s);
1075
1075
  }
1076
1076
  }
1077
- function Q(n, t) {
1078
- if (n != null) {
1079
- if (typeof n == "string") {
1080
- t.push(n);
1077
+ function Q(i, t) {
1078
+ if (i != null) {
1079
+ if (typeof i == "string") {
1080
+ t.push(i);
1081
1081
  return;
1082
1082
  }
1083
- if (typeof n == "number" || typeof n == "bigint" || typeof n == "boolean") {
1084
- t.push(String(n));
1083
+ if (typeof i == "number" || typeof i == "bigint" || typeof i == "boolean") {
1084
+ t.push(String(i));
1085
1085
  return;
1086
1086
  }
1087
- if (Array.isArray(n)) {
1088
- for (const e of n)
1087
+ if (Array.isArray(i)) {
1088
+ for (const e of i)
1089
1089
  Q(e, t);
1090
1090
  return;
1091
1091
  }
1092
1092
  }
1093
1093
  }
1094
- function kt(n) {
1094
+ function Wt(i) {
1095
1095
  const t = [];
1096
- for (const [e, i] of Object.entries(n))
1097
- if (i) {
1096
+ for (const [e, n] of Object.entries(i))
1097
+ if (n) {
1098
1098
  const a = yt(e);
1099
- t.push(`${a}: ${i}`);
1099
+ t.push(`${a}: ${n}`);
1100
1100
  }
1101
1101
  return t.join("; ");
1102
1102
  }
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);
1103
+ async function N(i) {
1104
+ if (i == null)
1105
+ return i;
1106
+ if (i && typeof i == "object" && "then" in i && typeof i.then == "function") {
1107
+ const t = await i;
1108
+ return N(t);
1109
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))
1110
+ if (typeof i == "string" || typeof i == "number" || typeof i == "boolean" || typeof i == "bigint")
1111
+ return i;
1112
+ if (typeof i != "function" && typeof i != "symbol") {
1113
+ if (Array.isArray(i))
1114
1114
  return await Promise.all(
1115
- n.filter((t) => !(t == null || typeof t == "function" || typeof t == "symbol")).map((t) => U(t))
1115
+ i.filter((t) => !(t == null || typeof t == "function" || typeof t == "symbol")).map((t) => N(t))
1116
1116
  );
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 s = await U(a);
1122
- s != null && (e.children = s);
1117
+ if (i && typeof i == "object" && "type" in i && "props" in i) {
1118
+ const t = i, e = {};
1119
+ for (const [n, a] of Object.entries(t.props))
1120
+ if (n === "children") {
1121
+ const r = await N(a);
1122
+ r != null && (e.children = r);
1123
1123
  } else {
1124
1124
  if (typeof a == "function" || typeof a == "symbol")
1125
1125
  continue;
1126
- a != null && (e[i] = a);
1126
+ a != null && (e[n] = a);
1127
1127
  }
1128
1128
  return {
1129
1129
  type: t.type,
@@ -1132,74 +1132,74 @@ async function U(n) {
1132
1132
  }
1133
1133
  }
1134
1134
  }
1135
- function At(n, t = {}) {
1136
- return n && typeof n == "object" && "node" in n ? R(n, t) : n === void 0 ? "" : R(n, t);
1135
+ function kt(i, t = {}) {
1136
+ return i && typeof i == "object" && "node" in i ? V(i, t) : i === void 0 ? "" : V(i, t);
1137
1137
  }
1138
- async function Wt(n) {
1139
- return await U(n);
1138
+ async function At(i) {
1139
+ return await N(i);
1140
1140
  }
1141
- function St(...n) {
1141
+ function St(...i) {
1142
1142
  const t = new Uint8Array(
1143
- n.reduceRight((i, a) => i + a.length, 0)
1143
+ i.reduceRight((n, a) => n + a.length, 0)
1144
1144
  );
1145
1145
  let e = 0;
1146
- for (const i of n)
1147
- t.set(i, e), e += i.length;
1146
+ for (const n of i)
1147
+ t.set(n, e), e += n.length;
1148
1148
  return t;
1149
1149
  }
1150
- async function Mt(n) {
1150
+ async function Mt(i) {
1151
1151
  const t = new CompressionStream("deflate"), e = t.writable.getWriter();
1152
- e.write(n), e.close();
1153
- const i = t.readable.getReader(), a = [];
1154
- let s = 0;
1152
+ e.write(i), e.close();
1153
+ const n = t.readable.getReader(), a = [];
1154
+ let r = 0;
1155
1155
  for (; ; ) {
1156
- const { done: o, value: c } = await i.read();
1156
+ const { done: o, value: c } = await n.read();
1157
1157
  if (o) break;
1158
- a.push(c), s += c.length;
1158
+ a.push(c), r += c.length;
1159
1159
  }
1160
- const r = new Uint8Array(s);
1160
+ const s = new Uint8Array(r);
1161
1161
  let h = 0;
1162
1162
  for (const o of a)
1163
- r.set(o, h), h += o.length;
1164
- return r;
1163
+ s.set(o, h), h += o.length;
1164
+ return s;
1165
1165
  }
1166
1166
  const X = new Uint32Array(256);
1167
- for (let n = 0; n < 256; n++) {
1168
- let t = n;
1167
+ for (let i = 0; i < 256; i++) {
1168
+ let t = i;
1169
1169
  for (let e = 0; e < 8; e++)
1170
1170
  t = t & 1 ? 3988292384 ^ t >>> 1 : t >>> 1;
1171
- X[n] = t;
1171
+ X[i] = t;
1172
1172
  }
1173
- function Ct(n) {
1173
+ function Ct(i) {
1174
1174
  let t = 4294967295;
1175
- for (let e = 0; e < n.length; e++)
1176
- t = X[(t ^ n[e]) & 255] ^ t >>> 8;
1175
+ for (let e = 0; e < i.length; e++)
1176
+ t = X[(t ^ i[e]) & 255] ^ t >>> 8;
1177
1177
  return (t ^ 4294967295) >>> 0;
1178
1178
  }
1179
1179
  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);
1180
+ function U(i, t) {
1181
+ const e = new Uint8Array(8 + t.length + 4), n = new DataView(e.buffer);
1182
+ n.setUint32(0, t.length), e.set(Ht.encode(i), 4), e.set(t, 8);
1183
1183
  const a = Ct(e.subarray(4, e.length - 4));
1184
- return i.setUint32(e.length - 4, a), e;
1184
+ return n.setUint32(e.length - 4, a), e;
1185
1185
  }
1186
- function qt(n) {
1187
- return n <= 1 ? 1 : n <= 3 ? 2 : n <= 15 ? 4 : 8;
1186
+ function qt(i) {
1187
+ return i <= 1 ? 1 : i <= 3 ? 2 : i <= 15 ? 4 : 8;
1188
1188
  }
1189
- function Nt(n, t, e, i) {
1190
- const a = 8 / i, s = Math.ceil(t / a) + 1, r = new Uint8Array(s * e), h = new DataView(r.buffer);
1189
+ function Ut(i, t, e, n) {
1190
+ const a = 8 / n, 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
- h.setUint8(o * s, 0);
1192
+ h.setUint8(o * r, 0);
1193
1193
  for (let c = 0; c < t; c++) {
1194
- const l = n.getUint8(o * t + c), u = o * s + 1 + Math.floor(c / a), d = (a - 1 - c % a) * i, g = h.getUint8(u);
1195
- h.setUint8(u, g | l << d);
1194
+ const d = i.getUint8(o * t + c), u = o * r + 1 + Math.floor(c / a), l = (a - 1 - c % a) * n, g = h.getUint8(u);
1195
+ h.setUint8(u, g | d << l);
1196
1196
  }
1197
1197
  }
1198
- return r;
1198
+ return s;
1199
1199
  }
1200
- const Ut = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), Et = new TextDecoder();
1201
- function Pt(n) {
1202
- switch (n) {
1200
+ const Nt = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), jt = new TextDecoder();
1201
+ function Et(i) {
1202
+ switch (i) {
1203
1203
  case 0:
1204
1204
  return "greyscale";
1205
1205
  case 2:
@@ -1211,20 +1211,20 @@ function Pt(n) {
1211
1211
  case 6:
1212
1212
  return "truecolor-alpha";
1213
1213
  default:
1214
- throw new Error(`Invalid color type: ${n}`);
1214
+ throw new Error(`Invalid color type: ${i}`);
1215
1215
  }
1216
1216
  }
1217
- function jt(n) {
1218
- switch (n) {
1217
+ function Pt(i) {
1218
+ switch (i) {
1219
1219
  case 0:
1220
1220
  return "none";
1221
1221
  case 1:
1222
1222
  return "adam7";
1223
1223
  default:
1224
- throw new Error(`Invalid interlace method: ${n}`);
1224
+ throw new Error(`Invalid interlace method: ${i}`);
1225
1225
  }
1226
1226
  }
1227
- function Dt(n, t) {
1227
+ function Dt(i, t) {
1228
1228
  const e = {
1229
1229
  0: [1, 2, 4, 8, 16],
1230
1230
  // Greyscale
@@ -1239,138 +1239,138 @@ function Dt(n, t) {
1239
1239
  }[t];
1240
1240
  if (!e)
1241
1241
  throw new Error(`Invalid color type: ${t}`);
1242
- if (!e.includes(n))
1242
+ if (!e.includes(i))
1243
1243
  throw new Error(
1244
- `Invalid bit depth ${n} for color type ${t}. Allowed: ${e.join(", ")}`
1244
+ `Invalid bit depth ${i} for color type ${t}. Allowed: ${e.join(", ")}`
1245
1245
  );
1246
1246
  return !0;
1247
1247
  }
1248
- function zt(n, t) {
1249
- if (t + 12 > n.byteLength)
1248
+ function zt(i, t) {
1249
+ if (t + 12 > i.byteLength)
1250
1250
  throw new Error(
1251
1251
  `Chunk at offset ${t} extends beyond data (need at least 12 bytes for header)`
1252
1252
  );
1253
- const e = n.getUint32(t, !1), i = new Uint8Array(n.buffer, n.byteOffset + t + 4, 4), a = Et.decode(i), s = 8 + e + 4;
1254
- if (t + s > n.byteLength)
1253
+ const e = i.getUint32(t, !1), n = new Uint8Array(i.buffer, i.byteOffset + t + 4, 4), a = jt.decode(n), r = 8 + e + 4;
1254
+ if (t + r > i.byteLength)
1255
1255
  throw new Error(
1256
- `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${s}, available: ${n.byteLength - t})`
1256
+ `Chunk "${a}" at offset ${t} extends beyond data (chunk size: ${r}, available: ${i.byteLength - t})`
1257
1257
  );
1258
- const r = new DataView(n.buffer, n.byteOffset + t + 8, e);
1258
+ const s = new DataView(i.buffer, i.byteOffset + t + 8, e);
1259
1259
  return {
1260
1260
  type: a,
1261
- data: r,
1261
+ data: s,
1262
1262
  offset: t,
1263
- totalSize: s
1263
+ totalSize: r
1264
1264
  };
1265
1265
  }
1266
- function* It(n, t = 0) {
1266
+ function* Ft(i, t = 0) {
1267
1267
  let e = t;
1268
- for (; e < n.byteLength; ) {
1269
- const i = zt(n, e);
1270
- yield i, e += i.totalSize;
1268
+ for (; e < i.byteLength; ) {
1269
+ const n = zt(i, e);
1270
+ yield n, e += n.totalSize;
1271
1271
  }
1272
1272
  }
1273
- function Ft(n, t, e, i = 0) {
1274
- for (const a of It(n, i))
1273
+ function It(i, t, e, n = 0) {
1274
+ for (const a of Ft(i, n))
1275
1275
  if (a.type === t)
1276
1276
  return e(a.data);
1277
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), s = n.getUint8(10), r = n.getUint8(11), h = n.getUint8(12);
1278
+ function Lt(i) {
1279
+ if (i.byteLength !== 13)
1280
+ throw new Error(`IHDR chunk must be 13 bytes, got ${i.byteLength}`);
1281
+ 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
1282
  if (t === 0)
1283
1283
  throw new Error("IHDR width cannot be zero");
1284
1284
  if (e === 0)
1285
1285
  throw new Error("IHDR height cannot be zero");
1286
- if (s !== 0)
1286
+ if (r !== 0)
1287
1287
  throw new Error(
1288
- `Invalid compression method: ${s}. Only 0 (deflate) is supported.`
1288
+ `Invalid compression method: ${r}. Only 0 (deflate) is supported.`
1289
1289
  );
1290
- if (r !== 0)
1290
+ if (s !== 0)
1291
1291
  throw new Error(
1292
- `Invalid filter method: ${r}. Only 0 (adaptive) is supported.`
1292
+ `Invalid filter method: ${s}. Only 0 (adaptive) is supported.`
1293
1293
  );
1294
- Dt(i, a);
1295
- const o = Pt(a), c = jt(h);
1294
+ Dt(n, a);
1295
+ const o = Et(a), c = Pt(h);
1296
1296
  return {
1297
1297
  width: t,
1298
1298
  height: e,
1299
- bitDepth: i,
1299
+ bitDepth: n,
1300
1300
  colorType: o,
1301
1301
  compressionMethod: "deflate",
1302
1302
  filterMethod: "adaptive",
1303
1303
  interlaceMethod: c
1304
1304
  };
1305
1305
  }
1306
- function Bt(n) {
1307
- if (n.byteLength < 8)
1306
+ function Bt(i) {
1307
+ if (i.byteLength < 8)
1308
1308
  throw new Error("Data too short to contain PNG signature");
1309
1309
  for (let t = 0; t < 8; t++)
1310
- if (n.getUint8(t) !== Ut[t])
1310
+ if (i.getUint8(t) !== Nt[t])
1311
1311
  throw new Error("Invalid PNG signature");
1312
1312
  return !0;
1313
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);
1314
+ function Tt(i) {
1315
+ const t = i instanceof Uint8Array ? i.buffer : i, e = i instanceof Uint8Array ? i.byteOffset : 0, n = i.byteLength, a = new DataView(t, e, n);
1316
1316
  Bt(a);
1317
- const s = Ft(a, "IHDR", Lt, 8);
1318
- if (s === void 0)
1317
+ const r = It(a, "IHDR", Lt, 8);
1318
+ if (r === void 0)
1319
1319
  throw new Error("IHDR chunk not found in PNG");
1320
- return s;
1320
+ return r;
1321
1321
  }
1322
- async function Rt(n, t, e, i) {
1323
- const a = new DataView(n.buffer), s = a.byteLength;
1324
- if (s === 0)
1322
+ async function Vt(i, t, e, n) {
1323
+ const a = new DataView(i.buffer), r = a.byteLength;
1324
+ if (r === 0)
1325
1325
  throw new Error("Received empty input");
1326
- if (s !== t * e)
1326
+ if (r !== t * e)
1327
1327
  throw new Error(
1328
- `Input does not match dimensions ${t}x${e}. Only ${s} bytes were given when ${t * e} are expected!`
1328
+ `Input does not match dimensions ${t}x${e}. Only ${r} bytes were given when ${t * e} are expected!`
1329
1329
  );
1330
- let r = 0;
1331
- for (let w = 0; w < s; w++) {
1330
+ let s = 0;
1331
+ for (let w = 0; w < r; w++) {
1332
1332
  const m = a.getUint8(w);
1333
- m > r && (r = m);
1333
+ m > s && (s = m);
1334
1334
  }
1335
- if (i.length <= r)
1335
+ if (n.length <= s)
1336
1336
  throw new Error(
1337
- `Color palette does not have enough colors (${r + 1}). Only ${i.length} were given!`
1337
+ `Color palette does not have enough colors (${s + 1}). Only ${n.length} were given!`
1338
1338
  );
1339
- const h = qt(r), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), l = new DataView(c.buffer);
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);
1341
- const u = N("IHDR", c), d = new Uint8Array(i.length * 3), g = new DataView(d.buffer);
1342
- for (let w = 0; w <= r; 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 Mt(f)), k = N("IEND", new Uint8Array(0));
1345
- return St(o, u, p, $, k);
1339
+ const h = qt(s), o = new Uint8Array([137, 80, 78, 71, 13, 10, 26, 10]), c = new Uint8Array(13), d = new DataView(c.buffer);
1340
+ d.setUint32(0, t), d.setUint32(4, e), d.setUint8(8, h), d.setUint8(9, 3), d.setUint8(10, 0), d.setUint8(11, 0), d.setUint8(12, 0);
1341
+ const u = U("IHDR", c), l = new Uint8Array(n.length * 3), g = new DataView(l.buffer);
1342
+ for (let w = 0; w <= s; w++)
1343
+ g.setUint8(w * 3, n[w][0]), g.setUint8(w * 3 + 1, n[w][1]), g.setUint8(w * 3 + 2, n[w][2]);
1344
+ const p = U("PLTE", l), f = Ut(a, t, e, h), $ = U("IDAT", await Mt(f)), x = U("IEND", new Uint8Array(0));
1345
+ return St(o, u, p, $, x);
1346
1346
  }
1347
- async function Zt(n, t = {}) {
1347
+ async function Rt(i, t = {}) {
1348
1348
  var e;
1349
1349
  const {
1350
- margin: i = 4,
1350
+ margin: n = 4,
1351
1351
  moduleSize: a = 4,
1352
- backgroundColor: s = [255, 255, 255],
1353
- foregroundColor: r = [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);
1355
- d.fill(0);
1352
+ backgroundColor: r = [255, 255, 255],
1353
+ foregroundColor: s = [0, 0, 0]
1354
+ } = t, { matrix: h } = i, o = ((e = h[0]) == null ? void 0 : e.length) ?? 0, c = h.length, d = (o + n * 2) * a, u = (c + n * 2) * a, l = new Uint8Array(d * u);
1355
+ l.fill(0);
1356
1356
  for (let g = 0; g < c; g++)
1357
1357
  for (let p = 0; p < o; p++)
1358
1358
  if (h[g][p])
1359
1359
  for (let f = 0; f < a; f++)
1360
1360
  for (let $ = 0; $ < a; $++) {
1361
- const k = (p + i) * a + $, w = (g + i) * a + f;
1362
- d[w * l + k] = 1;
1361
+ const x = (p + n) * a + $, w = (g + n) * a + f;
1362
+ l[w * d + x] = 1;
1363
1363
  }
1364
1364
  return {
1365
- bytes: await Rt(d, l, u, [s, r]),
1366
- width: l,
1365
+ bytes: await Vt(l, d, u, [r, s]),
1366
+ width: d,
1367
1367
  height: u
1368
1368
  };
1369
1369
  }
1370
- function Vt(n) {
1370
+ function Zt(i) {
1371
1371
  const t = {};
1372
- for (const [e, i] of Object.entries(n))
1373
- i !== void 0 && (t[e] = i);
1372
+ for (const [e, n] of Object.entries(i))
1373
+ n !== void 0 && (t[e] = n);
1374
1374
  return t;
1375
1375
  }
1376
1376
  class Y extends H {
@@ -1389,6 +1389,7 @@ class Y extends H {
1389
1389
  defaultFont = "'Courier Prime', monospace";
1390
1390
  actualFontCharacterWidth = void 0;
1391
1391
  explicitCharHeight = void 0;
1392
+ widthSpacingUnit = "px";
1392
1393
  // DOM building state
1393
1394
  contentNodes = [];
1394
1395
  currentStyles = {};
@@ -1413,6 +1414,25 @@ class Y extends H {
1413
1414
  setCharHeight(t) {
1414
1415
  this.explicitCharHeight = t;
1415
1416
  }
1417
+ setWidthSpacingUnit(t) {
1418
+ this.widthSpacingUnit = t;
1419
+ }
1420
+ /**
1421
+ * Converts a character width to the appropriate CSS unit based on widthSpacingUnit.
1422
+ * @param chars - Width in characters
1423
+ * @returns CSS value string (e.g., "12px", "50%", "12ch")
1424
+ */
1425
+ toWidthUnit(t) {
1426
+ const e = this.actualFontCharacterWidth ?? this.charWidth;
1427
+ switch (this.widthSpacingUnit) {
1428
+ case "px":
1429
+ return `${Math.floor(t * e)}px`;
1430
+ case "%":
1431
+ return `${t * e / this.containerWidth * 100}%`;
1432
+ default:
1433
+ return `${t}ch`;
1434
+ }
1435
+ }
1416
1436
  // finish printing (async to support Promise nodes like QR code PNGs):
1417
1437
  async close() {
1418
1438
  (this.lineSegments.length > 0 || this.pendingVrSvg) && await this.lf();
@@ -1456,14 +1476,14 @@ class Y extends H {
1456
1476
  children: this.contentNodes
1457
1477
  };
1458
1478
  e && (a.lang = e);
1459
- const r = await Wt({
1479
+ const s = await At({
1460
1480
  type: "div",
1461
1481
  props: a
1462
1482
  });
1463
- return At(r);
1483
+ return kt(s);
1464
1484
  }
1465
1485
  // set print area:
1466
- async area(t, e, i) {
1486
+ async area(t, e, n) {
1467
1487
  return this.lineMargin = t, this.lineWidth = e, "";
1468
1488
  }
1469
1489
  // set line alignment:
@@ -1485,10 +1505,10 @@ class Y extends H {
1485
1505
  props: {
1486
1506
  style: {
1487
1507
  borderTop: "2px solid black",
1488
- marginLeft: `${this.lineMargin}ch`,
1489
- width: `${t}ch`,
1508
+ marginLeft: this.toWidthUnit(this.lineMargin),
1509
+ width: this.toWidthUnit(t),
1490
1510
  height: "0",
1491
- display: "block"
1511
+ display: "flex"
1492
1512
  }
1493
1513
  }
1494
1514
  };
@@ -1496,21 +1516,21 @@ class Y extends H {
1496
1516
  }
1497
1517
  // print vertical rules:
1498
1518
  async vr(t, e) {
1499
- const i = this.charWidth, a = i / 2, s = this.charHeight * e, r = t.reduce((l, u) => l + u, 0) + t.length + 1;
1500
- let h = `M${a},0v${s}`;
1501
- for (const l of t)
1502
- h += `m${l * i + i},${-s}v${s}`;
1503
- const o = r * i, c = {
1519
+ const n = this.charWidth, a = n / 2, r = this.charHeight * e, s = t.reduce((d, u) => d + u, 0) + t.length + 1;
1520
+ let h = `M${a},0v${r}`;
1521
+ for (const d of t)
1522
+ h += `m${d * n + n},${-r}v${r}`;
1523
+ const o = s * n, c = {
1504
1524
  type: "svg",
1505
1525
  props: {
1506
- width: `${r}ch`,
1507
- height: `${s}`,
1508
- viewBox: `0 0 ${o} ${s}`,
1526
+ width: this.toWidthUnit(s),
1527
+ height: `${r}`,
1528
+ viewBox: `0 0 ${o} ${r}`,
1509
1529
  preserveAspectRatio: "none",
1510
1530
  style: {
1511
1531
  position: "absolute",
1512
1532
  top: "0",
1513
- left: `${this.lineMargin}ch`
1533
+ left: this.toWidthUnit(this.lineMargin)
1514
1534
  },
1515
1535
  children: {
1516
1536
  type: "path",
@@ -1528,21 +1548,21 @@ class Y extends H {
1528
1548
  }
1529
1549
  // start rules:
1530
1550
  async vrstart(t) {
1531
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, s = e * 2, r = this.buildVrStartPath(t), h = {
1551
+ 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
1552
  type: "svg",
1533
1553
  props: {
1534
- width: `${i}ch`,
1535
- height: `${s}`,
1536
- viewBox: `0 0 ${a} ${s}`,
1554
+ width: this.toWidthUnit(n),
1555
+ height: `${r}`,
1556
+ viewBox: `0 0 ${a} ${r}`,
1537
1557
  preserveAspectRatio: "none",
1538
1558
  style: {
1539
- display: "block",
1540
- marginLeft: `${this.lineMargin}ch`
1559
+ display: "flex",
1560
+ marginLeft: this.toWidthUnit(this.lineMargin)
1541
1561
  },
1542
1562
  children: {
1543
1563
  type: "path",
1544
1564
  props: {
1545
- d: r,
1565
+ d: s,
1546
1566
  fill: "none",
1547
1567
  stroke: "black",
1548
1568
  "stroke-width": "2",
@@ -1554,31 +1574,30 @@ class Y extends H {
1554
1574
  return this.contentNodes.push(h), "";
1555
1575
  }
1556
1576
  buildVrStartPath(t) {
1557
- const e = this.charWidth, i = e / 2;
1558
- let a = `M${i},${e + e}v${-i}q0,${-i},${i},${-i}`;
1559
- for (let s = 0; s < t.length; s++) {
1560
- const r = t[s] ?? 0;
1561
- a += `h${e * r}h${i}v${e}m0,${-e}h${i}`;
1577
+ const e = this.charWidth, n = e / 2;
1578
+ let a = `M${n},${e + e}v${-n}q0,${-n},${n},${-n}`;
1579
+ for (let r = 0; r < t.length; r++) {
1580
+ const s = t[r] ?? 0;
1581
+ a += `h${e * s}h${n}v${e}m0,${-e}h${n}`;
1562
1582
  }
1563
- return a = a.replace(/h\d+v\d+m0,-\d+h\d+$/, `q${i},0,${i},${i}v${i}`), a;
1583
+ return a = a.replace(/h\d+v\d+m0,-\d+h\d+$/, `q${n},0,${n},${n}v${n}`), a;
1564
1584
  }
1565
1585
  // stop rules:
1566
1586
  async vrstop(t) {
1567
- const e = this.charWidth, i = t.reduce((o, c) => o + c, 0) + t.length + 1, a = i * e, s = e * 2, r = this.buildVrStopPath(t), h = {
1587
+ 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
1588
  type: "svg",
1569
1589
  props: {
1570
- width: `${i}ch`,
1571
- height: `${s}`,
1572
- viewBox: `0 0 ${a} ${s}`,
1590
+ width: this.toWidthUnit(n),
1591
+ height: `${r}`,
1592
+ viewBox: `0 0 ${a} ${r}`,
1573
1593
  preserveAspectRatio: "none",
1574
1594
  style: {
1575
- display: "block",
1576
- marginLeft: `${this.lineMargin}ch`
1595
+ marginLeft: this.toWidthUnit(this.lineMargin)
1577
1596
  },
1578
1597
  children: {
1579
1598
  type: "path",
1580
1599
  props: {
1581
- d: r,
1600
+ d: s,
1582
1601
  fill: "none",
1583
1602
  stroke: "black",
1584
1603
  "stroke-width": "2",
@@ -1590,38 +1609,37 @@ class Y extends H {
1590
1609
  return this.contentNodes.push(h), "";
1591
1610
  }
1592
1611
  buildVrStopPath(t) {
1593
- const e = this.charWidth, i = e / 2;
1594
- let a = `M${i},0v${i}q0,${i},${i},${i}`;
1595
- for (let s = 0; s < t.length; s++) {
1596
- const r = t[s] ?? 0;
1597
- a += `h${e * r}h${i}v${-e}m0,${e}h${i}`;
1612
+ const e = this.charWidth, n = e / 2;
1613
+ let a = `M${n},0v${n}q0,${n},${n},${n}`;
1614
+ for (let r = 0; r < t.length; r++) {
1615
+ const s = t[r] ?? 0;
1616
+ a += `h${e * s}h${n}v${-e}m0,${e}h${n}`;
1598
1617
  }
1599
- return a = a.replace(/h\d+v-\d+m0,\d+h\d+$/, `q${i},0,${i},${-i}v${-i}`), a;
1618
+ return a = a.replace(/h\d+v-\d+m0,\d+h\d+$/, `q${n},0,${n},${-n}v${-n}`), a;
1600
1619
  }
1601
1620
  // print vertical and horizontal rules:
1602
- async vrhr(t, e, i, a) {
1603
- const s = this.charWidth, r = s / 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 * s, u = s * 2;
1604
- let d = `M${r},0` + (i > 0 ? `v${r}q0,${r},${r},${r}` : `v${s}h${r}`);
1621
+ async vrhr(t, e, n, a) {
1622
+ 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), d = c * r, u = r * 2;
1623
+ let l = `M${s},0` + (n > 0 ? `v${s}q0,${s},${s},${s}` : `v${r}h${s}`);
1605
1624
  for (const f of t)
1606
- d += `h${s * f}h${r}v${-s}m0,${s}h${r}`;
1607
- d = d.replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${r},0,${r},${-r}v${-r}` : `h${r}v${-s}`);
1608
- let g = `M${r},${s + s}` + (i < 0 ? `v${-r}q0,${-r},${r},${-r}` : `v${-s}h${r}`);
1625
+ l += `h${r * f}h${s}v${-r}m0,${r}h${s}`;
1626
+ l = l.replace(/h\d+v-\d+m0,\d+h\d+$/, a < 0 ? `q${s},0,${s},${-s}v${-s}` : `h${s}v${-r}`);
1627
+ let g = `M${s},${r + r}` + (n < 0 ? `v${-s}q0,${-s},${s},${-s}` : `v${-r}h${s}`);
1609
1628
  for (const f of e)
1610
- g += `h${s * f}h${r}v${s}m0,${-s}h${r}`;
1611
- g = g.replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${r},0,${r},${r}v${r}` : `h${r}v${s}`);
1629
+ g += `h${r * f}h${s}v${r}m0,${-r}h${s}`;
1630
+ g = g.replace(/h\d+v\d+m0,-\d+h\d+$/, a > 0 ? `q${s},0,${s},${s}v${s}` : `h${s}v${r}`);
1612
1631
  const p = {
1613
1632
  type: "svg",
1614
1633
  props: {
1615
- width: `${c}ch`,
1634
+ width: this.toWidthUnit(c),
1616
1635
  height: `${u}`,
1617
- viewBox: `0 0 ${l} ${u}`,
1636
+ viewBox: `0 0 ${d} ${u}`,
1618
1637
  preserveAspectRatio: "none",
1619
1638
  style: {
1620
- display: "block",
1621
- marginLeft: `${this.lineMargin + Math.max(-i, 0)}ch`
1639
+ marginLeft: this.toWidthUnit(this.lineMargin + Math.max(-n, 0))
1622
1640
  },
1623
1641
  children: [
1624
- { type: "path", props: { d, fill: "none", stroke: "black", "stroke-width": "2", "vector-effect": "non-scaling-stroke" } },
1642
+ { type: "path", props: { d: l, fill: "none", stroke: "black", "stroke-width": "2", "vector-effect": "non-scaling-stroke" } },
1625
1643
  { type: "path", props: { d: g, fill: "none", stroke: "black", "stroke-width": "2", "vector-effect": "non-scaling-stroke" } }
1626
1644
  ]
1627
1645
  }
@@ -1664,7 +1682,7 @@ class Y extends H {
1664
1682
  style: {
1665
1683
  flex: "1",
1666
1684
  borderTop: "2px dashed black",
1667
- display: "block"
1685
+ display: "flex"
1668
1686
  }
1669
1687
  }
1670
1688
  }
@@ -1687,8 +1705,8 @@ class Y extends H {
1687
1705
  }
1688
1706
  // scale up text:
1689
1707
  async wh(t) {
1690
- const e = t < 2 ? t + 1 : t - 1, i = t < 3 ? t : t - 1;
1691
- return this.currentStyles.fontSize = `${i}em`, this.currentStyles.display = "block", e !== i && (this.currentStyles.transform = `scaleX(${e / i})`, this.currentStyles.transformOrigin = "left"), this.lineHeight = Math.max(this.lineHeight, i), this.textScale = e, "";
1708
+ const e = t < 2 ? t + 1 : t - 1, n = t < 3 ? t : t - 1;
1709
+ 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, "";
1692
1710
  }
1693
1711
  // cancel text decoration:
1694
1712
  async normal() {
@@ -1696,61 +1714,70 @@ class Y extends H {
1696
1714
  }
1697
1715
  // print text:
1698
1716
  async text(t, e) {
1699
- const i = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, " "), a = this.measureText(t, e), s = {
1717
+ const n = t.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/ /g, " "), a = this.measureText(t, e), r = {
1700
1718
  position: this.currentPosition,
1701
- text: i,
1719
+ text: n,
1702
1720
  styles: { ...this.currentStyles },
1703
1721
  scale: this.textScale,
1704
1722
  charWidth: a
1705
1723
  };
1706
- return this.lineSegments.push(s), this.currentPosition += a * this.textScale, "";
1724
+ return this.lineSegments.push(r), this.currentPosition += a * this.textScale, "";
1707
1725
  }
1708
1726
  // feed new line:
1709
1727
  async lf() {
1710
- const t = this.lineHeight * this.charHeight, e = Math.max(t, this.feedMinimum), i = this.lineMargin + this.lineWidth, a = [];
1728
+ const t = this.lineHeight * this.charHeight, e = Math.max(t, this.feedMinimum), n = this.lineMargin + this.lineWidth, a = [];
1711
1729
  if (this.lineSegments.length === 0) {
1712
1730
  if (this.pendingVrSvg) {
1713
- const r = {
1731
+ const s = {
1714
1732
  type: "div",
1715
1733
  props: {
1716
1734
  style: {
1717
1735
  position: "relative",
1718
1736
  width: `${this.containerWidth}px`,
1719
1737
  height: `${e}px`,
1720
- display: "block"
1738
+ display: "flex"
1721
1739
  },
1722
1740
  children: this.pendingVrSvg
1723
1741
  }
1724
1742
  };
1725
- this.contentNodes.push(r), this.pendingVrSvg = null, this.estimatedHeight += e;
1743
+ this.contentNodes.push(s), this.pendingVrSvg = null, this.estimatedHeight += e;
1726
1744
  }
1727
1745
  return this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1728
1746
  } else {
1729
- const r = [...this.lineSegments].sort((u, d) => u.position - d.position);
1747
+ const s = [...this.lineSegments].sort((u, l) => u.position - l.position);
1730
1748
  let h = 0;
1731
- const o = (u) => Math.floor(u), c = (u) => `${o(u)}ch`, l = (u) => {
1732
- const d = u.match(/^(\d+(?:\.\d+)?)ch$/);
1733
- return d ? parseFloat(d[1]) : 0;
1749
+ const o = (u) => Math.floor(u), c = (u) => {
1750
+ const l = o(u);
1751
+ return this.toWidthUnit(l);
1752
+ }, d = (u) => {
1753
+ const l = this.actualFontCharacterWidth ?? this.charWidth, g = u.match(/^(\d+(?:\.\d+)?)px$/);
1754
+ if (g)
1755
+ return parseFloat(g[1]) / l;
1756
+ const p = u.match(/^(\d+(?:\.\d+)?)%$/);
1757
+ if (p)
1758
+ return parseFloat(p[1]) / 100 * this.containerWidth / l;
1759
+ const f = u.match(/^(\d+(?:\.\d+)?)ch$/);
1760
+ return f ? parseFloat(f[1]) : 0;
1734
1761
  };
1735
- for (let u = 0; u < r.length; u++) {
1736
- const d = r[u], g = this.lineMargin + d.position, p = d.charWidth * d.scale;
1762
+ for (let u = 0; u < s.length; u++) {
1763
+ const l = s[u], g = this.lineMargin + l.position, p = l.charWidth * l.scale;
1737
1764
  if (g > h && a.length > 0) {
1738
- const A = g - h, v = a[a.length - 1];
1765
+ const k = g - h, v = a[a.length - 1];
1739
1766
  if (v && v.props && v.props.style && typeof v.props.style == "object" && !Array.isArray(v.props.style)) {
1740
- const W = v.props.style, x = W.flexBasis;
1741
- if (x) {
1742
- const D = l(x) + A;
1743
- W.flexBasis = c(D);
1767
+ const A = v.props.style, W = A.flexBasis;
1768
+ if (W) {
1769
+ const D = d(W) + k;
1770
+ A.flexBasis = c(D);
1744
1771
  } else
1745
- W.flexBasis = c(A);
1772
+ A.flexBasis = c(k);
1746
1773
  }
1747
1774
  } else if (g > h && a.length === 0) {
1748
- const A = g - h;
1775
+ const k = g - h;
1749
1776
  a.push({
1750
1777
  type: "span",
1751
1778
  props: {
1752
1779
  style: {
1753
- flexBasis: c(A)
1780
+ flexBasis: c(k)
1754
1781
  }
1755
1782
  }
1756
1783
  });
@@ -1758,66 +1785,66 @@ class Y extends H {
1758
1785
  const $ = {
1759
1786
  flexBasis: c(p),
1760
1787
  whiteSpace: "pre"
1761
- }, k = d.styles && Object.keys(d.styles).length > 0, w = k ? d.styles : void 0, m = {
1788
+ }, x = l.styles && Object.keys(l.styles).length > 0, w = x ? l.styles : void 0, m = {
1762
1789
  type: "span",
1763
1790
  props: {
1764
1791
  style: $,
1765
- children: k ? {
1792
+ children: x ? {
1766
1793
  // Wrap text in inner span with content styles
1767
1794
  type: "span",
1768
1795
  props: {
1769
1796
  style: w,
1770
- children: d.text
1797
+ children: l.text
1771
1798
  }
1772
- } : d.text
1799
+ } : l.text
1773
1800
  }
1774
1801
  };
1775
1802
  a.push(m), h = g + p;
1776
1803
  }
1777
- if (h < i && a.length > 0) {
1778
- const u = i - h, d = a[a.length - 1];
1779
- if (d && d.props && d.props.style && typeof d.props.style == "object" && !Array.isArray(d.props.style)) {
1780
- const g = d.props.style, p = g.flexBasis;
1804
+ if (h < n && a.length > 0) {
1805
+ const u = n - h, l = a[a.length - 1];
1806
+ if (l && l.props && l.props.style && typeof l.props.style == "object" && !Array.isArray(l.props.style)) {
1807
+ const g = l.props.style, p = g.flexBasis;
1781
1808
  if (p) {
1782
- const $ = l(p) + u;
1809
+ const $ = d(p) + u;
1783
1810
  g.flexBasis = c($);
1784
1811
  } else
1785
1812
  g.flexBasis = c(u);
1786
1813
  }
1787
1814
  }
1788
1815
  }
1789
- const s = {
1816
+ const r = {
1790
1817
  type: "div",
1791
1818
  props: {
1792
1819
  style: {
1793
1820
  display: "flex",
1794
1821
  flexDirection: "row",
1795
1822
  height: `${e}px`,
1796
- width: `${i}ch`
1823
+ width: this.toWidthUnit(n)
1797
1824
  },
1798
1825
  children: a
1799
1826
  }
1800
1827
  };
1801
1828
  if (this.pendingVrSvg) {
1802
- const r = {
1829
+ const s = {
1803
1830
  type: "div",
1804
1831
  props: {
1805
1832
  style: {
1806
1833
  position: "relative",
1807
1834
  width: `${this.containerWidth}px`,
1808
1835
  minHeight: `${e}px`,
1809
- display: "block"
1836
+ display: "flex"
1810
1837
  },
1811
1838
  children: [
1812
1839
  // VR SVG positioned absolutely behind text
1813
1840
  this.pendingVrSvg,
1814
1841
  // Text line positioned relatively on top
1815
1842
  {
1816
- ...s,
1843
+ ...r,
1817
1844
  props: {
1818
- ...s.props,
1845
+ ...r.props,
1819
1846
  style: {
1820
- ...s.props?.style,
1847
+ ...r.props?.style,
1821
1848
  position: "relative"
1822
1849
  }
1823
1850
  }
@@ -1825,9 +1852,9 @@ class Y extends H {
1825
1852
  ]
1826
1853
  }
1827
1854
  };
1828
- this.contentNodes.push(r), this.pendingVrSvg = null;
1855
+ this.contentNodes.push(s), this.pendingVrSvg = null;
1829
1856
  } else
1830
- this.contentNodes.push(s);
1857
+ this.contentNodes.push(r);
1831
1858
  return this.estimatedHeight += e, this.lineHeight = 1, this.lineSegments = [], this.currentPosition = 0, "";
1832
1859
  }
1833
1860
  // insert commands:
@@ -1836,24 +1863,24 @@ class Y extends H {
1836
1863
  }
1837
1864
  // print image:
1838
1865
  async image(t) {
1839
- const e = this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right", i = V(t), a = Tt(i), s = a.width, r = a.height, h = {
1866
+ const e = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", n = Z(t), a = Tt(n), r = a.width, s = a.height, h = {
1840
1867
  type: "img",
1841
1868
  props: {
1842
1869
  src: `data:image/png;base64,${t}`,
1843
- style: Vt({
1844
- maxWidth: `${this.lineWidth}ch`
1870
+ style: Zt({
1871
+ maxWidth: this.toWidthUnit(this.lineWidth)
1845
1872
  }),
1846
- width: `${s}`,
1847
- height: `${r}`
1873
+ width: `${r}`,
1874
+ height: `${s}`
1848
1875
  }
1849
1876
  }, o = {
1850
1877
  type: "div",
1851
1878
  props: {
1852
1879
  style: {
1853
- textAlign: e,
1854
- paddingLeft: `${this.lineMargin}ch`,
1855
- width: `${this.lineWidth}ch`,
1856
- display: "block"
1880
+ justifyContent: e,
1881
+ paddingLeft: this.toWidthUnit(this.lineMargin),
1882
+ width: this.toWidthUnit(this.lineWidth),
1883
+ display: "flex"
1857
1884
  },
1858
1885
  children: h
1859
1886
  }
@@ -1862,88 +1889,85 @@ class Y extends H {
1862
1889
  }
1863
1890
  // print QR Code (async version using PNG):
1864
1891
  async qrcode(t, e) {
1865
- const i = _({
1892
+ const n = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end", a = _({
1866
1893
  data: t.data,
1867
1894
  ec: t.level === "l" ? M.L : t.level === "m" ? M.M : t.level === "q" ? M.Q : M.H
1868
- }), a = t.cell, s = t.quietZone ? 4 : 0, { bytes: r, width: h, height: o } = await Zt(i, {
1869
- moduleSize: a,
1895
+ }), r = t.cell, s = t.quietZone ? 4 : 0, { bytes: h, width: o, height: c } = await Rt(a, {
1896
+ moduleSize: r,
1870
1897
  margin: s
1871
- }), l = {
1898
+ }), u = {
1872
1899
  type: "img",
1873
1900
  props: {
1874
- src: `data:image/png;base64,${O(r)}`,
1875
- width: `${h}`,
1876
- height: `${o}`,
1901
+ src: `data:image/png;base64,${O(h)}`,
1902
+ width: `${o}`,
1903
+ height: `${c}`,
1877
1904
  style: {
1878
1905
  imageRendering: "pixelated"
1879
1906
  }
1880
1907
  }
1881
- }, d = {
1908
+ }, l = {
1882
1909
  type: "div",
1883
1910
  props: {
1884
1911
  style: {
1885
- textAlign: this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right",
1886
- paddingLeft: `${this.lineMargin}ch`,
1887
- width: `${this.lineWidth}ch`,
1888
- display: "block"
1912
+ justifyContent: n,
1913
+ paddingLeft: this.toWidthUnit(this.lineMargin),
1914
+ width: this.toWidthUnit(this.lineWidth),
1915
+ display: "flex"
1889
1916
  },
1890
- children: [l]
1917
+ children: [u]
1891
1918
  }
1892
1919
  };
1893
- return this.contentNodes.push(d), this.estimatedHeight += o, "";
1920
+ return this.contentNodes.push(l), this.estimatedHeight += c, "";
1894
1921
  }
1895
1922
  // print barcode:
1896
1923
  async barcode(t, e) {
1897
- const i = K(t), a = i.height;
1898
- if (a !== void 0 && "length" in i && i.length !== void 0 && i.widths) {
1899
- const s = i.length, r = a + (i.hri ? this.charHeight + 2 : 0);
1900
- let h = "";
1901
- i.widths.reduce((d, g, p) => (p % 2 === 1 && (h += `M${d},0h${g}v${a}h${-g}z`), d + g), 0);
1902
- const o = [
1924
+ const n = K(t), a = n.height, r = this.lineAlign === 0 ? "flex-start" : this.lineAlign === 1 ? "center" : "flex-end";
1925
+ if (a !== void 0 && "length" in n && n.length !== void 0 && n.widths) {
1926
+ const s = n.length, h = a + (n.hri ? this.charHeight + 2 : 0);
1927
+ let o = "";
1928
+ n.widths.reduce((l, g, p) => (p % 2 === 1 && (o += `M${l},0h${g}v${a}h${-g}z`), l + g), 0);
1929
+ const c = [
1903
1930
  {
1904
1931
  type: "path",
1905
1932
  props: {
1906
- d: h,
1933
+ d: o,
1907
1934
  fill: "black"
1908
1935
  }
1909
1936
  }
1910
1937
  ];
1911
- i.hri && i.text && o.push({
1938
+ n.hri && n.text && c.push({
1912
1939
  type: "text",
1913
1940
  props: {
1914
1941
  x: `${s / 2}`,
1915
- y: `${r}`,
1942
+ y: `${h}`,
1916
1943
  "text-anchor": "middle",
1917
1944
  "font-family": "monospace",
1918
1945
  "font-size": `${this.charWidth * 2}`,
1919
1946
  fill: "black",
1920
- children: i.text
1947
+ children: n.text
1921
1948
  }
1922
1949
  });
1923
- const c = {
1950
+ const d = {
1924
1951
  type: "svg",
1925
1952
  props: {
1926
1953
  width: `${s}`,
1927
- height: `${r}`,
1928
- viewBox: `0 0 ${s} ${r}`,
1929
- style: {
1930
- display: "block"
1931
- },
1932
- children: o
1954
+ height: `${h}`,
1955
+ viewBox: `0 0 ${s} ${h}`,
1956
+ children: c
1933
1957
  }
1934
1958
  }, u = {
1935
1959
  type: "div",
1936
1960
  props: {
1937
1961
  style: {
1938
- textAlign: this.lineAlign === 0 ? "left" : this.lineAlign === 1 ? "center" : "right",
1939
- paddingLeft: `${this.lineMargin}ch`,
1940
- width: `${this.lineWidth}ch`,
1941
- display: "block"
1962
+ justifyContent: r,
1963
+ paddingLeft: this.toWidthUnit(this.lineMargin),
1964
+ width: this.toWidthUnit(this.lineWidth),
1965
+ display: "flex"
1942
1966
  },
1943
- children: c
1967
+ children: d
1944
1968
  }
1945
1969
  };
1946
- this.contentNodes.push(u), this.estimatedHeight += r;
1970
+ this.contentNodes.push(u), this.estimatedHeight += h;
1947
1971
  }
1948
1972
  return "";
1949
1973
  }
@@ -1979,8 +2003,8 @@ class tt extends H {
1979
2003
  * @param {number} right right margin (unit: characters)
1980
2004
  * @returns {Promise<string>} empty string
1981
2005
  */
1982
- async area(t, e, i) {
1983
- return this.logs.push(`area(left: ${t}, width: ${e}, right: ${i})`), "";
2006
+ async area(t, e, n) {
2007
+ return this.logs.push(`area(left: ${t}, width: ${e}, right: ${n})`), "";
1984
2008
  }
1985
2009
  /**
1986
2010
  * Set line alignment.
@@ -2047,8 +2071,8 @@ class tt extends H {
2047
2071
  * @param {number} dr difference in right position
2048
2072
  * @returns {Promise<string>} empty string
2049
2073
  */
2050
- async vrhr(t, e, i, a) {
2051
- return this.logs.push(`vrhr(widths1: [${t.join(", ")}], widths2: [${e.join(", ")}], dl: ${i}, dr: ${a})`), "";
2074
+ async vrhr(t, e, n, a) {
2075
+ return this.logs.push(`vrhr(widths1: [${t.join(", ")}], widths2: [${e.join(", ")}], dl: ${n}, dr: ${a})`), "";
2052
2076
  }
2053
2077
  /**
2054
2078
  * Set line spacing and feed new line.
@@ -2161,63 +2185,63 @@ class tt extends H {
2161
2185
  }
2162
2186
  const z = {
2163
2187
  base: new H(),
2164
- svg: new I(),
2188
+ svg: new F(),
2165
2189
  html: new Y(),
2166
2190
  audit: new tt()
2167
2191
  };
2168
- function Ot(n) {
2169
- 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, s = (typeof t.target == "object" && t.target !== null ? t.target : void 0) || (i && i in z ? z[i] : z.svg);
2170
- let r;
2171
- return s instanceof Y || s instanceof I || s instanceof tt || s instanceof H ? r = s : r = new I(), {
2192
+ function Ot(i) {
2193
+ 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 z ? z[n] : z.svg);
2194
+ let s;
2195
+ return r instanceof Y || r instanceof F || r instanceof tt || r instanceof H ? s = r : s = new F(), {
2172
2196
  cpl: t.cpl || 48,
2173
2197
  charWidth: t.charWidth || 12,
2174
2198
  encoding: e,
2175
2199
  spacing: !!t.spacing,
2176
2200
  margin: t.margin || 0,
2177
2201
  marginRight: t.marginRight || 0,
2178
- target: r
2202
+ target: s
2179
2203
  };
2180
2204
  }
2181
- function _t(n, t) {
2182
- 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, s) => {
2183
- let r = {
2205
+ function _t(i, t) {
2206
+ 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) => {
2207
+ let s = {
2184
2208
  align: 1,
2185
2209
  wrap: t.wrap,
2186
2210
  border: t.border,
2187
2211
  width: 0,
2188
2212
  alignment: t.align
2189
2213
  };
2190
- const h = i.replace(/^[\t ]+|[\t ]+$/g, "");
2191
- if (r.align = 1 + Number(/^[\t ]/.test(i)) - Number(/[\t ]$/.test(i)), /^\{[^{}]*\}$/.test(h)) {
2192
- if (r.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2193
- const l = { a: "align", b: "border", c: "code", i: "image", o: "option", t: "text", w: "width", x: "command", _: "comment" };
2214
+ const h = n.replace(/^[\t ]+|[\t ]+$/g, "");
2215
+ if (s.align = 1 + Number(/^[\t ]/.test(n)) - Number(/[\t ]$/.test(n)), /^\{[^{}]*\}$/.test(h)) {
2216
+ if (s.property = h.slice(1, -1).replace(/\\;/g, "\\x3b").split(";").reduce((o, c) => {
2217
+ const d = { a: "align", b: "border", c: "code", i: "image", o: "option", t: "text", w: "width", x: "command", _: "comment" };
2194
2218
  return /^[\t ]*$/.test(c) || c.replace(
2195
2219
  /^[\t ]*([A-Za-z_]\w*)[\t ]*:[\t ]*([^\t ].*?)[\t ]*$/,
2196
- (d, g, p) => {
2197
- const f = g.replace(/^[abciotwx_]$/, ($) => l[$] || $);
2198
- return o[f] = Z(p.replace(/\\n/g, `
2199
- `)), d;
2220
+ (l, g, p) => {
2221
+ const f = g.replace(/^[abciotwx_]$/, ($) => d[$] || $);
2222
+ return o[f] = R(p.replace(/\\n/g, `
2223
+ `)), l;
2200
2224
  }
2201
- ) === c && (r.error = h), o;
2202
- }, {}), s.length === 1) {
2203
- if ("text" in r.property && r.property.text) {
2204
- const o = r.property.text.toLowerCase();
2225
+ ) === c && (s.error = h), o;
2226
+ }, {}), r.length === 1) {
2227
+ if ("text" in s.property && s.property.text) {
2228
+ const o = s.property.text.toLowerCase();
2205
2229
  t.wrap = !/^nowrap$/.test(o);
2206
2230
  }
2207
- if ("border" in r.property && r.property.border) {
2208
- const o = r.property.border.toLowerCase(), c = { line: -1, space: 1, none: 0 }, l = t.border;
2209
- t.border = /^(line|space|none)$/.test(o) ? c[o] ?? 1 : /^\d+$/.test(o) && Number(o) <= 2 ? Number(o) : 1, l >= 0 && t.border < 0 && (r.vr = "+"), l < 0 && t.border >= 0 && (r.vr = "-");
2231
+ if ("border" in s.property && s.property.border) {
2232
+ const o = s.property.border.toLowerCase(), c = { line: -1, space: 1, none: 0 }, d = t.border;
2233
+ t.border = /^(line|space|none)$/.test(o) ? c[o] ?? 1 : /^\d+$/.test(o) && Number(o) <= 2 ? Number(o) : 1, d >= 0 && t.border < 0 && (s.vr = "+"), d < 0 && t.border >= 0 && (s.vr = "-");
2210
2234
  }
2211
- if ("width" in r.property && r.property.width) {
2212
- const o = r.property.width.toLowerCase().split(/[\t ]+|,/);
2235
+ if ("width" in s.property && s.property.width) {
2236
+ const o = s.property.width.toLowerCase().split(/[\t ]+|,/);
2213
2237
  t.width = o.find((c) => /^auto$/.test(c)) ? [] : o.map((c) => /^\*$/.test(c) ? -1 : /^\d+$/.test(c) ? Number(c) : 0);
2214
2238
  }
2215
- if ("align" in r.property && r.property.align) {
2216
- const o = r.property.align.toLowerCase(), c = { left: 0, center: 1, right: 2 };
2239
+ if ("align" in s.property && s.property.align) {
2240
+ const o = s.property.align.toLowerCase(), c = { left: 0, center: 1, right: 2 };
2217
2241
  t.align = /^(left|center|right)$/.test(o) ? c[o] ?? 1 : 1;
2218
2242
  }
2219
- if ("option" in r.property && r.property.option) {
2220
- const o = r.property.option.toLowerCase().split(/[\t ]+|,/);
2243
+ if ("option" in s.property && s.property.option) {
2244
+ const o = s.property.option.toLowerCase().split(/[\t ]+|,/);
2221
2245
  t.option = {
2222
2246
  type: o.find((c) => /^(upc|ean|jan|code39|itf|codabar|nw7|code93|code128|qrcode)$/.test(c)) || "code128",
2223
2247
  width: Number(o.find((c) => /^\d+$/.test(c) && Number(c) >= 2 && Number(c) <= 4) || "2"),
@@ -2228,77 +2252,77 @@ function _t(n, t) {
2228
2252
  quietZone: !1
2229
2253
  };
2230
2254
  }
2231
- if ("code" in r.property && r.property.code && (t.option.type === "qrcode" ? r.code = Object.assign({ data: r.property.code, type: "qrcode" }, t.option) : r.code = Object.assign({ data: r.property.code, type: t.option.type }, t.option)), "image" in r.property && r.property.image) {
2232
- const o = r.property.image.replace(/=.*|[^A-Za-z0-9+/]/g, "");
2255
+ 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) {
2256
+ const o = s.property.image.replace(/=.*|[^A-Za-z0-9+/]/g, "");
2233
2257
  switch (o.length % 4) {
2234
2258
  case 1:
2235
- r.image = o.slice(0, -1);
2259
+ s.image = o.slice(0, -1);
2236
2260
  break;
2237
2261
  case 2:
2238
- r.image = o + "==";
2262
+ s.image = o + "==";
2239
2263
  break;
2240
2264
  case 3:
2241
- r.image = o + "=";
2265
+ s.image = o + "=";
2242
2266
  break;
2243
2267
  default:
2244
- r.image = o;
2268
+ s.image = o;
2245
2269
  break;
2246
2270
  }
2247
2271
  }
2248
- "command" in r.property && r.property.command && (r.command = r.property.command), "comment" in r.property && r.property.comment && (r.comment = r.property.comment);
2272
+ "command" in s.property && s.property.command && (s.command = s.property.command), "comment" in s.property && s.property.comment && (s.comment = s.property.comment);
2249
2273
  }
2250
2274
  } else if (/[{}]/.test(h))
2251
- r.error = h;
2252
- else if (s.length === 1 && /^-+$|^=+$/.test(h)) {
2275
+ s.error = h;
2276
+ else if (r.length === 1 && /^-+$|^=+$/.test(h)) {
2253
2277
  const o = h.slice(-1);
2254
- r.hr = o === "-" || o === "=" ? o : void 0;
2278
+ s.hr = o === "-" || o === "=" ? o : void 0;
2255
2279
  } else
2256
- r.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, `
2257
- `).replace(/~/g, " ").split(/([_"`\n]|\^+)/).map((o) => Z(o));
2258
- if (r.wrap = t.wrap, r.border = t.border, t.width.length === 0)
2259
- r.width = -1;
2260
- else if ("text" in r)
2261
- r.width = a < t.width.length ? t.width[a] ?? 0 : 0;
2280
+ 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, `
2281
+ `).replace(/~/g, " ").split(/([_"`\n]|\^+)/).map((o) => R(o));
2282
+ if (s.wrap = t.wrap, s.border = t.border, t.width.length === 0)
2283
+ s.width = -1;
2284
+ else if ("text" in s)
2285
+ s.width = a < t.width.length ? t.width[a] ?? 0 : 0;
2262
2286
  else if (t.width.find((o) => o < 0))
2263
- r.width = -1;
2287
+ s.width = -1;
2264
2288
  else {
2265
2289
  const o = t.width.filter((c) => c > 0);
2266
- r.width = o.length > 0 ? o.reduce((c, l) => c + l, r.border < 0 ? o.length + 1 : (o.length - 1) * r.border) : 0;
2290
+ s.width = o.length > 0 ? o.reduce((c, d) => c + d, s.border < 0 ? o.length + 1 : (o.length - 1) * s.border) : 0;
2267
2291
  }
2268
- return r.alignment = t.align, r;
2292
+ return s.alignment = t.align, s;
2269
2293
  });
2270
- if (e.every((i) => "text" in i) && t.width.length > 0)
2294
+ if (e.every((n) => "text" in n) && t.width.length > 0)
2271
2295
  for (; e.length < t.width.length; )
2272
2296
  e.push({ align: 1, text: [""], wrap: t.wrap, border: t.border, width: t.width[e.length] ?? 0, alignment: t.align });
2273
2297
  return e;
2274
2298
  }
2275
- function Z(n) {
2276
- 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)));
2299
+ function R(i) {
2300
+ 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)));
2277
2301
  }
2278
- function Gt(n, t) {
2302
+ function Gt(i, t) {
2279
2303
  const e = [];
2280
- let i = n.width, a = 1, s = [], r = !1, h = !1, o = !1, c = 0;
2281
- return n.text.forEach((l, u) => {
2304
+ let n = i.width, a = 1, r = [], s = !1, h = !1, o = !1, c = 0;
2305
+ return i.text.forEach((d, u) => {
2282
2306
  if (u % 2 === 0) {
2283
- let d = t.target.arrayFrom(l, t.encoding);
2284
- for (; d.length > 0; ) {
2307
+ let l = t.target.arrayFrom(d, t.encoding);
2308
+ for (; l.length > 0; ) {
2285
2309
  let g = 0, p = 0;
2286
- for (; p < d.length && (g = t.target.measureText(d[p] ?? "", t.encoding) * (c < 2 ? c + 1 : c - 1), !(g > i)); )
2287
- i -= g, g = 0, p++;
2288
- if (p > 0 && (s.push((r ? "1" : "0") + (h ? "1" : "0") + (o ? "1" : "0") + c), s.push(d.slice(0, p).join("")), a = Math.max(a, c < 3 ? c : c - 1), d = d.slice(p)), g > n.width) {
2289
- d = d.slice(1);
2310
+ for (; p < l.length && (g = t.target.measureText(l[p] ?? "", t.encoding) * (c < 2 ? c + 1 : c - 1), !(g > n)); )
2311
+ n -= g, g = 0, p++;
2312
+ if (p > 0 && (r.push((s ? "1" : "0") + (h ? "1" : "0") + (o ? "1" : "0") + c), r.push(l.slice(0, p).join("")), a = Math.max(a, c < 3 ? c : c - 1), l = l.slice(p)), g > i.width) {
2313
+ l = l.slice(1);
2290
2314
  continue;
2291
2315
  }
2292
- (g > i || i === 0) && (e.push({ data: s, margin: i * n.align / 2, height: a }), i = n.width, s = [], a = 1);
2316
+ (g > n || n === 0) && (e.push({ data: r, margin: n * i.align / 2, height: a }), n = i.width, r = [], a = 1);
2293
2317
  }
2294
2318
  } else
2295
- switch (l) {
2319
+ switch (d) {
2296
2320
  case `
2297
2321
  `:
2298
- e.push({ data: s, margin: i * n.align / 2, height: a }), i = n.width, s = [], a = 1;
2322
+ e.push({ data: r, margin: n * i.align / 2, height: a }), n = i.width, r = [], a = 1;
2299
2323
  break;
2300
2324
  case "_":
2301
- r = !r;
2325
+ s = !s;
2302
2326
  break;
2303
2327
  case '"':
2304
2328
  h = !h;
@@ -2307,93 +2331,93 @@ function Gt(n, t) {
2307
2331
  o = !o;
2308
2332
  break;
2309
2333
  default:
2310
- const d = Math.min(l.length, 7);
2311
- c = c === d ? 0 : d;
2334
+ const l = Math.min(d.length, 7);
2335
+ c = c === l ? 0 : l;
2312
2336
  break;
2313
2337
  }
2314
- }), s.length > 0 && e.push({ data: s, margin: i * n.align / 2, height: a }), e;
2338
+ }), r.length > 0 && e.push({ data: r, margin: n * i.align / 2, height: a }), e;
2315
2339
  }
2316
- async function Kt(n, t, e) {
2317
- const i = [], a = n.every((f) => "text" in f), s = n[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2318
- let r = n.filter((f) => f.width !== 0);
2319
- a && (r = r.slice(0, Math.floor(s.border < 0 ? (t.target.cpl - 1) / 2 : (t.target.cpl + s.border) / (s.border + 1))));
2320
- const h = r.filter((f) => f.width > 0), o = r.filter((f) => f.width < 0);
2321
- let c = h.reduce((f, $) => f + $.width, 0), l = t.target.cpl - c;
2322
- a && r.length > 0 && (l -= s.border < 0 ? r.length + 1 : (r.length - 1) * s.border);
2340
+ async function Kt(i, t, e) {
2341
+ const n = [], a = i.every((f) => "text" in f), r = i[0] ?? { align: 1, text: [""], wrap: !0, border: 0, width: 0, alignment: 1 };
2342
+ let s = i.filter((f) => f.width !== 0);
2343
+ a && (s = s.slice(0, Math.floor(r.border < 0 ? (t.target.cpl - 1) / 2 : (t.target.cpl + r.border) / (r.border + 1))));
2344
+ const h = s.filter((f) => f.width > 0), o = s.filter((f) => f.width < 0);
2345
+ let c = h.reduce((f, $) => f + $.width, 0), d = t.target.cpl - c;
2346
+ a && s.length > 0 && (d -= r.border < 0 ? s.length + 1 : (s.length - 1) * r.border);
2323
2347
  const u = o.length;
2324
- for (; u > l; ) {
2325
- const f = h.reduce(($, k) => $.width > k.width ? $ : k);
2326
- f.width--, l++;
2348
+ for (; u > d; ) {
2349
+ const f = h.reduce(($, x) => $.width > x.width ? $ : x);
2350
+ f.width--, d++;
2327
2351
  }
2328
- u > 0 && (o.forEach((f, $) => f.width = Math.floor((l + $) / u)), l = 0);
2329
- const d = Math.floor(l * s.alignment / 2), g = t.target.cpl - l, p = l - d;
2352
+ u > 0 && (o.forEach((f, $) => f.width = Math.floor((d + $) / u)), d = 0);
2353
+ const l = Math.floor(d * r.alignment / 2), g = t.target.cpl - d, p = d - l;
2330
2354
  if (a) {
2331
- const f = r.map((w) => Gt(w, t)), $ = r.map((w) => w.width);
2355
+ const f = s.map((w) => Gt(w, t)), $ = s.map((w) => w.width);
2332
2356
  switch (e.line) {
2333
2357
  case "ready":
2334
- i.push(
2335
- 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)
2358
+ n.push(
2359
+ await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(0) + await t.target.vrstart($) + await t.target.vrlf(!0)
2336
2360
  ), e.line = "running";
2337
2361
  break;
2338
2362
  case "horizontal":
2339
- const w = d - e.rules.left, m = g - e.rules.width, A = Math.min(d, e.rules.left), v = Math.min(p, e.rules.right);
2340
- i.push(
2341
- await t.target.normal() + await t.target.area(A, t.target.cpl - A - v, v) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
2363
+ const w = l - e.rules.left, m = g - e.rules.width, k = Math.min(l, e.rules.left), v = Math.min(p, e.rules.right);
2364
+ n.push(
2365
+ await t.target.normal() + await t.target.area(k, t.target.cpl - k - v, v) + await t.target.align(0) + await t.target.vrhr(e.rules.widths, $, w, w + m) + await t.target.lf()
2342
2366
  ), e.line = "running";
2343
2367
  break;
2344
2368
  }
2345
- e.rules = { left: d, width: g, right: p, widths: $ };
2346
- const k = s.wrap ? f.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2347
- for (let w = 0; w < k; w++) {
2348
- let m = await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(0), A = 0;
2369
+ e.rules = { left: l, width: g, right: p, widths: $ };
2370
+ const x = r.wrap ? f.reduce((w, m) => Math.max(w, m.length), 1) : 1;
2371
+ for (let w = 0; w < x; w++) {
2372
+ let m = await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(0), k = 0;
2349
2373
  if (e.line === "running") {
2350
- const v = f.reduce((W, x) => w < x.length ? Math.max(W, x[w]?.height ?? 1) : W, 1);
2351
- m += await t.target.normal() + await t.target.absolute(A++) + await t.target.vr($, v);
2374
+ const v = f.reduce((A, W) => w < W.length ? Math.max(A, W[w]?.height ?? 1) : A, 1);
2375
+ m += await t.target.normal() + await t.target.absolute(k++) + await t.target.vr($, v);
2352
2376
  }
2353
2377
  for (let v = 0; v < f.length; v++) {
2354
- const W = f[v];
2355
- if (W) {
2356
- if (m += await t.target.absolute(A), w < W.length) {
2357
- m += await t.target.relative(W[w]?.margin ?? 0);
2358
- const x = W[w]?.data ?? [];
2359
- for (let S = 0; S < x.length; S += 2) {
2360
- 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]);
2361
- 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);
2378
+ const A = f[v];
2379
+ if (A) {
2380
+ if (m += await t.target.absolute(k), w < A.length) {
2381
+ m += await t.target.relative(A[w]?.margin ?? 0);
2382
+ const W = A[w]?.data ?? [];
2383
+ for (let S = 0; S < W.length; S += 2) {
2384
+ const D = Number(String(W[S])[0]), et = Number(String(W[S])[1]), it = Number(String(W[S])[2]), B = Number(String(W[S])[3]);
2385
+ m += await t.target.normal(), D && (m += await t.target.ul()), et && (m += await t.target.em()), it && (m += await t.target.iv()), B && (m += await t.target.wh(B)), m += await t.target.text(String(W[S + 1]), t.encoding);
2362
2386
  }
2363
2387
  } else
2364
2388
  m += await t.target.normal() + await t.target.text(" ", t.encoding);
2365
- A += (r[v]?.width ?? 0) + Math.abs(s.border);
2389
+ k += (s[v]?.width ?? 0) + Math.abs(r.border);
2366
2390
  }
2367
2391
  }
2368
- m += await t.target.lf(), i.push(m);
2392
+ m += await t.target.lf(), n.push(m);
2369
2393
  }
2370
2394
  }
2371
- if ("hr" in s)
2372
- if (s.hr === "=")
2395
+ if ("hr" in r)
2396
+ if (r.hr === "=")
2373
2397
  switch (e.line) {
2374
2398
  case "running":
2375
2399
  case "horizontal":
2376
- i.push(
2400
+ n.push(
2377
2401
  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)
2378
- ), i.push(await t.target.cut()), e.line = "ready";
2402
+ ), n.push(await t.target.cut()), e.line = "ready";
2379
2403
  break;
2380
2404
  default:
2381
- i.push(await t.target.cut());
2405
+ n.push(await t.target.cut());
2382
2406
  break;
2383
2407
  }
2384
2408
  else
2385
2409
  switch (e.line) {
2386
2410
  case "waiting":
2387
- i.push(
2388
- 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()
2411
+ n.push(
2412
+ await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(0) + await t.target.hr(g) + await t.target.lf()
2389
2413
  );
2390
2414
  break;
2391
2415
  case "running":
2392
2416
  e.line = "horizontal";
2393
2417
  break;
2394
2418
  }
2395
- if ("vr" in s)
2396
- if (s.vr === "+")
2419
+ if ("vr" in r)
2420
+ if (r.vr === "+")
2397
2421
  e.line = "ready";
2398
2422
  else
2399
2423
  switch (e.line) {
@@ -2402,26 +2426,26 @@ async function Kt(n, t, e) {
2402
2426
  break;
2403
2427
  case "running":
2404
2428
  case "horizontal":
2405
- i.push(
2429
+ n.push(
2406
2430
  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)
2407
2431
  ), e.line = "waiting";
2408
2432
  break;
2409
2433
  }
2410
- return "image" in s && s.image && i.push(
2411
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.image(s.image)
2412
- ), "code" in s && s.code && (s.code.type === "qrcode" ? i.push(
2413
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.qrcode(s.code, t.encoding)
2414
- ) : i.push(
2415
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.barcode(s.code, t.encoding)
2416
- )), "command" in s && s.command && i.push(
2417
- await t.target.normal() + await t.target.area(d, g, p) + await t.target.align(s.align) + await t.target.command(s.command)
2418
- ), i.join("");
2434
+ return "image" in r && r.image && n.push(
2435
+ await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(r.align) + await t.target.image(r.image)
2436
+ ), "code" in r && r.code && (r.code.type === "qrcode" ? n.push(
2437
+ await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(r.align) + await t.target.qrcode(r.code, t.encoding)
2438
+ ) : n.push(
2439
+ await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(r.align) + await t.target.barcode(r.code, t.encoding)
2440
+ )), "command" in r && r.command && n.push(
2441
+ await t.target.normal() + await t.target.area(l, g, p) + await t.target.align(r.align) + await t.target.command(r.command)
2442
+ ), n.join("");
2419
2443
  }
2420
- async function Yt(n, t) {
2444
+ async function Yt(i, t) {
2421
2445
  const e = Ot(t);
2422
2446
  await e.target.lock();
2423
2447
  try {
2424
- const i = {
2448
+ const n = {
2425
2449
  wrap: !0,
2426
2450
  border: 1,
2427
2451
  width: [],
@@ -2431,24 +2455,24 @@ async function Yt(n, t) {
2431
2455
  rules: { left: 0, width: 0, right: 0, widths: [] }
2432
2456
  };
2433
2457
  let a = await e.target.open(e);
2434
- n[0] === "\uFEFF" && (n = n.slice(1));
2435
- const s = n.normalize().split(/\n|\r\n|\r/), r = [];
2436
- for (const h of s)
2437
- r.push(await Kt(_t(h, i), e, i));
2438
- switch (i.line) {
2458
+ i[0] === "\uFEFF" && (i = i.slice(1));
2459
+ const r = i.normalize().split(/\n|\r\n|\r/), s = [];
2460
+ for (const h of r)
2461
+ s.push(await Kt(_t(h, n), e, n));
2462
+ switch (n.line) {
2439
2463
  case "ready":
2440
- i.line = "waiting";
2464
+ n.line = "waiting";
2441
2465
  break;
2442
2466
  case "running":
2443
2467
  case "horizontal":
2444
- r.push(
2445
- 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)
2446
- ), i.line = "waiting";
2468
+ s.push(
2469
+ 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)
2470
+ ), n.line = "waiting";
2447
2471
  break;
2448
2472
  default:
2449
2473
  break;
2450
2474
  }
2451
- return a += r.join(""), a += await e.target.close(), {
2475
+ return a += s.join(""), a += await e.target.close(), {
2452
2476
  content: a,
2453
2477
  width: e.target.calculatedWidth(),
2454
2478
  height: Math.round(e.target.calculatedHeight())
@@ -2461,6 +2485,6 @@ export {
2461
2485
  tt as AuditTarget,
2462
2486
  H as BaseTarget,
2463
2487
  Y as HtmlTarget,
2464
- I as SvgTarget,
2488
+ F as SvgTarget,
2465
2489
  Yt as transform
2466
2490
  };