@lglab/react-qr-code 1.0.1 → 1.2.0

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.es.js CHANGED
@@ -1,40 +1,40 @@
1
- import { jsx as w, jsxs as j } from "react/jsx-runtime";
2
- import { useMemo as S, useCallback as x } from "react";
1
+ import { jsx as N, jsxs as Q, Fragment as tt } from "react/jsx-runtime";
2
+ import { useMemo as L, useCallback as et, useRef as ot, useImperativeHandle as nt } from "react";
3
3
  /**
4
4
  * @license QR Code generator library (TypeScript)
5
5
  * Copyright (c) Project Nayuki.
6
6
  * SPDX-License-Identifier: MIT
7
7
  */
8
- var T;
8
+ var O;
9
9
  ((r) => {
10
- const l = class l {
10
+ const d = class d {
11
11
  /*-- Constructor (low level) and fields --*/
12
12
  // Creates a new QR Code with the given version number,
13
13
  // error correction level, data codeword bytes, and mask number.
14
14
  // This is a low-level API that most users should not use directly.
15
15
  // A mid-level API is the encodeSegments() function.
16
- constructor(t, o, n, i) {
17
- if (this.version = t, this.errorCorrectionLevel = o, this.modules = [], this.isFunction = [], t < l.MIN_VERSION || t > l.MAX_VERSION)
16
+ constructor(e, o, n, i) {
17
+ if (this.version = e, this.errorCorrectionLevel = o, this.modules = [], this.isFunction = [], e < d.MIN_VERSION || e > d.MAX_VERSION)
18
18
  throw new RangeError("Version value out of range");
19
19
  if (i < -1 || i > 7)
20
20
  throw new RangeError("Mask value out of range");
21
- this.size = t * 4 + 17;
21
+ this.size = e * 4 + 17;
22
22
  let h = [];
23
- for (let d = 0; d < this.size; d++)
23
+ for (let f = 0; f < this.size; f++)
24
24
  h.push(!1);
25
- for (let d = 0; d < this.size; d++)
25
+ for (let f = 0; f < this.size; f++)
26
26
  this.modules.push(h.slice()), this.isFunction.push(h.slice());
27
27
  this.drawFunctionPatterns();
28
- const p = this.addEccAndInterleave(n);
29
- if (this.drawCodewords(p), i == -1) {
30
- let d = 1e9;
31
- for (let R = 0; R < 8; R++) {
32
- this.applyMask(R), this.drawFormatBits(R);
33
- const u = this.getPenaltyScore();
34
- u < d && (i = R, d = u), this.applyMask(R);
28
+ const $ = this.addEccAndInterleave(n);
29
+ if (this.drawCodewords($), i == -1) {
30
+ let f = 1e9;
31
+ for (let p = 0; p < 8; p++) {
32
+ this.applyMask(p), this.drawFormatBits(p);
33
+ const M = this.getPenaltyScore();
34
+ M < f && (i = p, f = M), this.applyMask(p);
35
35
  }
36
36
  }
37
- e(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
37
+ t(0 <= i && i <= 7), this.mask = i, this.applyMask(i), this.drawFormatBits(i), this.isFunction = [];
38
38
  }
39
39
  /*-- Static factory functions (high level) --*/
40
40
  // Returns a QR Code representing the given Unicode text string at the given error correction level.
@@ -42,17 +42,17 @@ var T;
42
42
  // Unicode code points (not UTF-16 code units) if the low error correction level is used. The smallest possible
43
43
  // QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
44
44
  // ecl argument if it can be done without increasing the version.
45
- static encodeText(t, o) {
46
- const n = r.QrSegment.makeSegments(t);
47
- return l.encodeSegments(n, o);
45
+ static encodeText(e, o) {
46
+ const n = r.QrSegment.makeSegments(e);
47
+ return d.encodeSegments(n, o);
48
48
  }
49
49
  // Returns a QR Code representing the given binary data at the given error correction level.
50
50
  // This function always encodes using the binary segment mode, not any text mode. The maximum number of
51
51
  // bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
52
52
  // The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
53
- static encodeBinary(t, o) {
54
- const n = r.QrSegment.makeBytes(t);
55
- return l.encodeSegments([n], o);
53
+ static encodeBinary(e, o) {
54
+ const n = r.QrSegment.makeBytes(e);
55
+ return d.encodeSegments([n], o);
56
56
  }
57
57
  /*-- Static factory functions (mid level) --*/
58
58
  // Returns a QR Code representing the given segments with the given encoding parameters.
@@ -64,43 +64,43 @@ var T;
64
64
  // This function allows the user to create a custom sequence of segments that switches
65
65
  // between modes (such as alphanumeric and byte) to encode text in less space.
66
66
  // This is a mid-level API; the high-level API is encodeText() and encodeBinary().
67
- static encodeSegments(t, o, n = 1, i = 40, h = -1, p = !0) {
68
- if (!(l.MIN_VERSION <= n && n <= i && i <= l.MAX_VERSION) || h < -1 || h > 7)
67
+ static encodeSegments(e, o, n = 1, i = 40, h = -1, $ = !0) {
68
+ if (!(d.MIN_VERSION <= n && n <= i && i <= d.MAX_VERSION) || h < -1 || h > 7)
69
69
  throw new RangeError("Invalid value");
70
- let d, R;
71
- for (d = n; ; d++) {
72
- const m = l.getNumDataCodewords(d, o) * 8, g = f.getTotalBits(t, d);
73
- if (g <= m) {
74
- R = g;
70
+ let f, p;
71
+ for (f = n; ; f++) {
72
+ const R = d.getNumDataCodewords(f, o) * 8, A = l.getTotalBits(e, f);
73
+ if (A <= R) {
74
+ p = A;
75
75
  break;
76
76
  }
77
- if (d >= i)
77
+ if (f >= i)
78
78
  throw new RangeError("Data too long");
79
79
  }
80
- for (const m of [l.Ecc.MEDIUM, l.Ecc.QUARTILE, l.Ecc.HIGH])
81
- p && R <= l.getNumDataCodewords(d, m) * 8 && (o = m);
82
- let u = [];
83
- for (const m of t) {
84
- a(m.mode.modeBits, 4, u), a(m.numChars, m.mode.numCharCountBits(d), u);
85
- for (const g of m.getData())
86
- u.push(g);
80
+ for (const R of [d.Ecc.MEDIUM, d.Ecc.QUARTILE, d.Ecc.HIGH])
81
+ $ && p <= d.getNumDataCodewords(f, R) * 8 && (o = R);
82
+ let M = [];
83
+ for (const R of e) {
84
+ c(R.mode.modeBits, 4, M), c(R.numChars, R.mode.numCharCountBits(f), M);
85
+ for (const A of R.getData())
86
+ M.push(A);
87
87
  }
88
- e(u.length == R);
89
- const M = l.getNumDataCodewords(d, o) * 8;
90
- e(u.length <= M), a(0, Math.min(4, M - u.length), u), a(0, (8 - u.length % 8) % 8, u), e(u.length % 8 == 0);
91
- for (let m = 236; u.length < M; m ^= 253)
92
- a(m, 8, u);
93
- let A = [];
94
- for (; A.length * 8 < u.length; )
95
- A.push(0);
96
- return u.forEach((m, g) => A[g >>> 3] |= m << 7 - (g & 7)), new l(d, o, A, h);
88
+ t(M.length == p);
89
+ const E = d.getNumDataCodewords(f, o) * 8;
90
+ t(M.length <= E), c(0, Math.min(4, E - M.length), M), c(0, (8 - M.length % 8) % 8, M), t(M.length % 8 == 0);
91
+ for (let R = 236; M.length < E; R ^= 253)
92
+ c(R, 8, M);
93
+ let m = [];
94
+ for (; m.length * 8 < M.length; )
95
+ m.push(0);
96
+ return M.forEach((R, A) => m[A >>> 3] |= R << 7 - (A & 7)), new d(f, o, m, h);
97
97
  }
98
98
  /*-- Accessor methods --*/
99
99
  // Returns the color of the module (pixel) at the given coordinates, which is false
100
100
  // for light or true for dark. The top left corner has the coordinates (x=0, y=0).
101
101
  // If the given coordinates are out of bounds, then false (light) is returned.
102
- getModule(t, o) {
103
- return 0 <= t && t < this.size && 0 <= o && o < this.size && this.modules[o][t];
102
+ getModule(e, o) {
103
+ return 0 <= e && e < this.size && 0 <= o && o < this.size && this.modules[o][e];
104
104
  }
105
105
  // Modified to expose modules for easy access
106
106
  getModules() {
@@ -112,30 +112,30 @@ var T;
112
112
  for (let n = 0; n < this.size; n++)
113
113
  this.setFunctionModule(6, n, n % 2 == 0), this.setFunctionModule(n, 6, n % 2 == 0);
114
114
  this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
115
- const t = this.getAlignmentPatternPositions(), o = t.length;
115
+ const e = this.getAlignmentPatternPositions(), o = e.length;
116
116
  for (let n = 0; n < o; n++)
117
117
  for (let i = 0; i < o; i++)
118
- n == 0 && i == 0 || n == 0 && i == o - 1 || n == o - 1 && i == 0 || this.drawAlignmentPattern(t[n], t[i]);
118
+ n == 0 && i == 0 || n == 0 && i == o - 1 || n == o - 1 && i == 0 || this.drawAlignmentPattern(e[n], e[i]);
119
119
  this.drawFormatBits(0), this.drawVersion();
120
120
  }
121
121
  // Draws two copies of the format bits (with its own error correction code)
122
122
  // based on the given mask and this object's error correction level field.
123
- drawFormatBits(t) {
124
- const o = this.errorCorrectionLevel.formatBits << 3 | t;
123
+ drawFormatBits(e) {
124
+ const o = this.errorCorrectionLevel.formatBits << 3 | e;
125
125
  let n = o;
126
126
  for (let h = 0; h < 10; h++)
127
127
  n = n << 1 ^ (n >>> 9) * 1335;
128
128
  const i = (o << 10 | n) ^ 21522;
129
- e(i >>> 15 == 0);
129
+ t(i >>> 15 == 0);
130
130
  for (let h = 0; h <= 5; h++)
131
- this.setFunctionModule(8, h, s(i, h));
132
- this.setFunctionModule(8, 7, s(i, 6)), this.setFunctionModule(8, 8, s(i, 7)), this.setFunctionModule(7, 8, s(i, 8));
131
+ this.setFunctionModule(8, h, a(i, h));
132
+ this.setFunctionModule(8, 7, a(i, 6)), this.setFunctionModule(8, 8, a(i, 7)), this.setFunctionModule(7, 8, a(i, 8));
133
133
  for (let h = 9; h < 15; h++)
134
- this.setFunctionModule(14 - h, 8, s(i, h));
134
+ this.setFunctionModule(14 - h, 8, a(i, h));
135
135
  for (let h = 0; h < 8; h++)
136
- this.setFunctionModule(this.size - 1 - h, 8, s(i, h));
136
+ this.setFunctionModule(this.size - 1 - h, 8, a(i, h));
137
137
  for (let h = 8; h < 15; h++)
138
- this.setFunctionModule(8, this.size - 15 + h, s(i, h));
138
+ this.setFunctionModule(8, this.size - 15 + h, a(i, h));
139
139
  this.setFunctionModule(8, this.size - 8, !0);
140
140
  }
141
141
  // Draws two copies of the version bits (with its own error correction code),
@@ -143,88 +143,88 @@ var T;
143
143
  drawVersion() {
144
144
  if (this.version < 7)
145
145
  return;
146
- let t = this.version;
146
+ let e = this.version;
147
147
  for (let n = 0; n < 12; n++)
148
- t = t << 1 ^ (t >>> 11) * 7973;
149
- const o = this.version << 12 | t;
150
- e(o >>> 18 == 0);
148
+ e = e << 1 ^ (e >>> 11) * 7973;
149
+ const o = this.version << 12 | e;
150
+ t(o >>> 18 == 0);
151
151
  for (let n = 0; n < 18; n++) {
152
- const i = s(o, n), h = this.size - 11 + n % 3, p = Math.floor(n / 3);
153
- this.setFunctionModule(h, p, i), this.setFunctionModule(p, h, i);
152
+ const i = a(o, n), h = this.size - 11 + n % 3, $ = Math.floor(n / 3);
153
+ this.setFunctionModule(h, $, i), this.setFunctionModule($, h, i);
154
154
  }
155
155
  }
156
156
  // Draws a 9*9 finder pattern including the border separator,
157
157
  // with the center module at (x, y). Modules can be out of bounds.
158
- drawFinderPattern(t, o) {
158
+ drawFinderPattern(e, o) {
159
159
  for (let n = -4; n <= 4; n++)
160
160
  for (let i = -4; i <= 4; i++) {
161
- const h = Math.max(Math.abs(i), Math.abs(n)), p = t + i, d = o + n;
162
- 0 <= p && p < this.size && 0 <= d && d < this.size && this.setFunctionModule(p, d, h != 2 && h != 4);
161
+ const h = Math.max(Math.abs(i), Math.abs(n)), $ = e + i, f = o + n;
162
+ 0 <= $ && $ < this.size && 0 <= f && f < this.size && this.setFunctionModule($, f, h != 2 && h != 4);
163
163
  }
164
164
  }
165
165
  // Draws a 5*5 alignment pattern, with the center module
166
166
  // at (x, y). All modules must be in bounds.
167
- drawAlignmentPattern(t, o) {
167
+ drawAlignmentPattern(e, o) {
168
168
  for (let n = -2; n <= 2; n++)
169
169
  for (let i = -2; i <= 2; i++)
170
- this.setFunctionModule(t + i, o + n, Math.max(Math.abs(i), Math.abs(n)) != 1);
170
+ this.setFunctionModule(e + i, o + n, Math.max(Math.abs(i), Math.abs(n)) != 1);
171
171
  }
172
172
  // Sets the color of a module and marks it as a function module.
173
173
  // Only used by the constructor. Coordinates must be in bounds.
174
- setFunctionModule(t, o, n) {
175
- this.modules[o][t] = n, this.isFunction[o][t] = !0;
174
+ setFunctionModule(e, o, n) {
175
+ this.modules[o][e] = n, this.isFunction[o][e] = !0;
176
176
  }
177
177
  /*-- Private helper methods for constructor: Codewords and masking --*/
178
178
  // Returns a new byte string representing the given data with the appropriate error correction
179
179
  // codewords appended to it, based on this object's version and error correction level.
180
- addEccAndInterleave(t) {
180
+ addEccAndInterleave(e) {
181
181
  const o = this.version, n = this.errorCorrectionLevel;
182
- if (t.length != l.getNumDataCodewords(o, n))
182
+ if (e.length != d.getNumDataCodewords(o, n))
183
183
  throw new RangeError("Invalid argument");
184
- const i = l.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][o], h = l.ECC_CODEWORDS_PER_BLOCK[n.ordinal][o], p = Math.floor(l.getNumRawDataModules(o) / 8), d = i - p % i, R = Math.floor(p / i);
185
- let u = [];
186
- const M = l.reedSolomonComputeDivisor(h);
187
- for (let m = 0, g = 0; m < i; m++) {
188
- let N = t.slice(g, g + R - h + (m < d ? 0 : 1));
189
- g += N.length;
190
- const I = l.reedSolomonComputeRemainder(N, M);
191
- m < d && N.push(0), u.push(N.concat(I));
184
+ const i = d.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][o], h = d.ECC_CODEWORDS_PER_BLOCK[n.ordinal][o], $ = Math.floor(d.getNumRawDataModules(o) / 8), f = i - $ % i, p = Math.floor($ / i);
185
+ let M = [];
186
+ const E = d.reedSolomonComputeDivisor(h);
187
+ for (let R = 0, A = 0; R < i; R++) {
188
+ let w = e.slice(A, A + p - h + (R < f ? 0 : 1));
189
+ A += w.length;
190
+ const C = d.reedSolomonComputeRemainder(w, E);
191
+ R < f && w.push(0), M.push(w.concat(C));
192
192
  }
193
- let A = [];
194
- for (let m = 0; m < u[0].length; m++)
195
- u.forEach((g, N) => {
196
- (m != R - h || N >= d) && A.push(g[m]);
193
+ let m = [];
194
+ for (let R = 0; R < M[0].length; R++)
195
+ M.forEach((A, w) => {
196
+ (R != p - h || w >= f) && m.push(A[R]);
197
197
  });
198
- return e(A.length == p), A;
198
+ return t(m.length == $), m;
199
199
  }
200
200
  // Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
201
201
  // data area of this QR Code. Function modules need to be marked off before this is called.
202
- drawCodewords(t) {
203
- if (t.length != Math.floor(l.getNumRawDataModules(this.version) / 8))
202
+ drawCodewords(e) {
203
+ if (e.length != Math.floor(d.getNumRawDataModules(this.version) / 8))
204
204
  throw new RangeError("Invalid argument");
205
205
  let o = 0;
206
206
  for (let n = this.size - 1; n >= 1; n -= 2) {
207
207
  n == 6 && (n = 5);
208
208
  for (let i = 0; i < this.size; i++)
209
209
  for (let h = 0; h < 2; h++) {
210
- const p = n - h, R = (n + 1 & 2) == 0 ? this.size - 1 - i : i;
211
- !this.isFunction[R][p] && o < t.length * 8 && (this.modules[R][p] = s(t[o >>> 3], 7 - (o & 7)), o++);
210
+ const $ = n - h, p = (n + 1 & 2) == 0 ? this.size - 1 - i : i;
211
+ !this.isFunction[p][$] && o < e.length * 8 && (this.modules[p][$] = a(e[o >>> 3], 7 - (o & 7)), o++);
212
212
  }
213
213
  }
214
- e(o == t.length * 8);
214
+ t(o == e.length * 8);
215
215
  }
216
216
  // XORs the codeword modules in this QR Code with the given mask pattern.
217
217
  // The function modules must be marked and the codeword bits must be drawn
218
218
  // before masking. Due to the arithmetic of XOR, calling applyMask() with
219
219
  // the same mask value a second time will undo the mask. A final well-formed
220
220
  // QR Code needs exactly one (not zero, two, etc.) mask applied.
221
- applyMask(t) {
222
- if (t < 0 || t > 7)
221
+ applyMask(e) {
222
+ if (e < 0 || e > 7)
223
223
  throw new RangeError("Mask value out of range");
224
224
  for (let o = 0; o < this.size; o++)
225
225
  for (let n = 0; n < this.size; n++) {
226
226
  let i;
227
- switch (t) {
227
+ switch (e) {
228
228
  case 0:
229
229
  i = (n + o) % 2 == 0;
230
230
  break;
@@ -258,29 +258,29 @@ var T;
258
258
  // Calculates and returns the penalty score based on state of this QR Code's current modules.
259
259
  // This is used by the automatic mask choice algorithm to find the mask pattern that yields the lowest score.
260
260
  getPenaltyScore() {
261
- let t = 0;
261
+ let e = 0;
262
262
  for (let h = 0; h < this.size; h++) {
263
- let p = !1, d = 0, R = [0, 0, 0, 0, 0, 0, 0];
264
- for (let u = 0; u < this.size; u++)
265
- this.modules[h][u] == p ? (d++, d == 5 ? t += l.PENALTY_N1 : d > 5 && t++) : (this.finderPenaltyAddHistory(d, R), p || (t += this.finderPenaltyCountPatterns(R) * l.PENALTY_N3), p = this.modules[h][u], d = 1);
266
- t += this.finderPenaltyTerminateAndCount(p, d, R) * l.PENALTY_N3;
263
+ let $ = !1, f = 0, p = [0, 0, 0, 0, 0, 0, 0];
264
+ for (let M = 0; M < this.size; M++)
265
+ this.modules[h][M] == $ ? (f++, f == 5 ? e += d.PENALTY_N1 : f > 5 && e++) : (this.finderPenaltyAddHistory(f, p), $ || (e += this.finderPenaltyCountPatterns(p) * d.PENALTY_N3), $ = this.modules[h][M], f = 1);
266
+ e += this.finderPenaltyTerminateAndCount($, f, p) * d.PENALTY_N3;
267
267
  }
268
268
  for (let h = 0; h < this.size; h++) {
269
- let p = !1, d = 0, R = [0, 0, 0, 0, 0, 0, 0];
270
- for (let u = 0; u < this.size; u++)
271
- this.modules[u][h] == p ? (d++, d == 5 ? t += l.PENALTY_N1 : d > 5 && t++) : (this.finderPenaltyAddHistory(d, R), p || (t += this.finderPenaltyCountPatterns(R) * l.PENALTY_N3), p = this.modules[u][h], d = 1);
272
- t += this.finderPenaltyTerminateAndCount(p, d, R) * l.PENALTY_N3;
269
+ let $ = !1, f = 0, p = [0, 0, 0, 0, 0, 0, 0];
270
+ for (let M = 0; M < this.size; M++)
271
+ this.modules[M][h] == $ ? (f++, f == 5 ? e += d.PENALTY_N1 : f > 5 && e++) : (this.finderPenaltyAddHistory(f, p), $ || (e += this.finderPenaltyCountPatterns(p) * d.PENALTY_N3), $ = this.modules[M][h], f = 1);
272
+ e += this.finderPenaltyTerminateAndCount($, f, p) * d.PENALTY_N3;
273
273
  }
274
274
  for (let h = 0; h < this.size - 1; h++)
275
- for (let p = 0; p < this.size - 1; p++) {
276
- const d = this.modules[h][p];
277
- d == this.modules[h][p + 1] && d == this.modules[h + 1][p] && d == this.modules[h + 1][p + 1] && (t += l.PENALTY_N2);
275
+ for (let $ = 0; $ < this.size - 1; $++) {
276
+ const f = this.modules[h][$];
277
+ f == this.modules[h][$ + 1] && f == this.modules[h + 1][$] && f == this.modules[h + 1][$ + 1] && (e += d.PENALTY_N2);
278
278
  }
279
279
  let o = 0;
280
280
  for (const h of this.modules)
281
- o = h.reduce((p, d) => p + (d ? 1 : 0), o);
281
+ o = h.reduce(($, f) => $ + (f ? 1 : 0), o);
282
282
  const n = this.size * this.size, i = Math.ceil(Math.abs(o * 20 - n * 10) / n) - 1;
283
- return e(0 <= i && i <= 9), t += i * l.PENALTY_N4, e(0 <= t && t <= 2568888), t;
283
+ return t(0 <= i && i <= 9), e += i * d.PENALTY_N4, t(0 <= e && e <= 2568888), e;
284
284
  }
285
285
  /*-- Private helper functions --*/
286
286
  // Returns an ascending list of positions of alignment patterns for this version number.
@@ -290,9 +290,9 @@ var T;
290
290
  if (this.version == 1)
291
291
  return [];
292
292
  {
293
- const t = Math.floor(this.version / 7) + 2, o = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (t * 2 - 2)) * 2;
293
+ const e = Math.floor(this.version / 7) + 2, o = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
294
294
  let n = [6];
295
- for (let i = this.size - 7; n.length < t; i -= o)
295
+ for (let i = this.size - 7; n.length < e; i -= o)
296
296
  n.splice(1, 0, i);
297
297
  return n;
298
298
  }
@@ -300,76 +300,76 @@ var T;
300
300
  // Returns the number of data bits that can be stored in a QR Code of the given version number, after
301
301
  // all function modules are excluded. This includes remainder bits, so it might not be a multiple of 8.
302
302
  // The result is in the range [208, 29648]. This could be implemented as a 40-entry lookup table.
303
- static getNumRawDataModules(t) {
304
- if (t < l.MIN_VERSION || t > l.MAX_VERSION)
303
+ static getNumRawDataModules(e) {
304
+ if (e < d.MIN_VERSION || e > d.MAX_VERSION)
305
305
  throw new RangeError("Version number out of range");
306
- let o = (16 * t + 128) * t + 64;
307
- if (t >= 2) {
308
- const n = Math.floor(t / 7) + 2;
309
- o -= (25 * n - 10) * n - 55, t >= 7 && (o -= 36);
306
+ let o = (16 * e + 128) * e + 64;
307
+ if (e >= 2) {
308
+ const n = Math.floor(e / 7) + 2;
309
+ o -= (25 * n - 10) * n - 55, e >= 7 && (o -= 36);
310
310
  }
311
- return e(208 <= o && o <= 29648), o;
311
+ return t(208 <= o && o <= 29648), o;
312
312
  }
313
313
  // Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
314
314
  // QR Code of the given version number and error correction level, with remainder bits discarded.
315
315
  // This stateless pure function could be implemented as a (40*4)-cell lookup table.
316
- static getNumDataCodewords(t, o) {
317
- return Math.floor(l.getNumRawDataModules(t) / 8) - l.ECC_CODEWORDS_PER_BLOCK[o.ordinal][t] * l.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][t];
316
+ static getNumDataCodewords(e, o) {
317
+ return Math.floor(d.getNumRawDataModules(e) / 8) - d.ECC_CODEWORDS_PER_BLOCK[o.ordinal][e] * d.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][e];
318
318
  }
319
319
  // Returns a Reed-Solomon ECC generator polynomial for the given degree. This could be
320
320
  // implemented as a lookup table over all possible parameter values, instead of as an algorithm.
321
- static reedSolomonComputeDivisor(t) {
322
- if (t < 1 || t > 255)
321
+ static reedSolomonComputeDivisor(e) {
322
+ if (e < 1 || e > 255)
323
323
  throw new RangeError("Degree out of range");
324
324
  let o = [];
325
- for (let i = 0; i < t - 1; i++)
325
+ for (let i = 0; i < e - 1; i++)
326
326
  o.push(0);
327
327
  o.push(1);
328
328
  let n = 1;
329
- for (let i = 0; i < t; i++) {
329
+ for (let i = 0; i < e; i++) {
330
330
  for (let h = 0; h < o.length; h++)
331
- o[h] = l.reedSolomonMultiply(o[h], n), h + 1 < o.length && (o[h] ^= o[h + 1]);
332
- n = l.reedSolomonMultiply(n, 2);
331
+ o[h] = d.reedSolomonMultiply(o[h], n), h + 1 < o.length && (o[h] ^= o[h + 1]);
332
+ n = d.reedSolomonMultiply(n, 2);
333
333
  }
334
334
  return o;
335
335
  }
336
336
  // Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
337
- static reedSolomonComputeRemainder(t, o) {
337
+ static reedSolomonComputeRemainder(e, o) {
338
338
  let n = o.map((i) => 0);
339
- for (const i of t) {
339
+ for (const i of e) {
340
340
  const h = i ^ n.shift();
341
- n.push(0), o.forEach((p, d) => n[d] ^= l.reedSolomonMultiply(p, h));
341
+ n.push(0), o.forEach(($, f) => n[f] ^= d.reedSolomonMultiply($, h));
342
342
  }
343
343
  return n;
344
344
  }
345
345
  // Returns the product of the two given field elements modulo GF(2^8/0x11D). The arguments and result
346
346
  // are unsigned 8-bit integers. This could be implemented as a lookup table of 256*256 entries of uint8.
347
- static reedSolomonMultiply(t, o) {
348
- if (t >>> 8 || o >>> 8)
347
+ static reedSolomonMultiply(e, o) {
348
+ if (e >>> 8 || o >>> 8)
349
349
  throw new RangeError("Byte out of range");
350
350
  let n = 0;
351
351
  for (let i = 7; i >= 0; i--)
352
- n = n << 1 ^ (n >>> 7) * 285, n ^= (o >>> i & 1) * t;
353
- return e(n >>> 8 == 0), n;
352
+ n = n << 1 ^ (n >>> 7) * 285, n ^= (o >>> i & 1) * e;
353
+ return t(n >>> 8 == 0), n;
354
354
  }
355
355
  // Can only be called immediately after a light run is added, and
356
356
  // returns either 0, 1, or 2. A helper function for getPenaltyScore().
357
- finderPenaltyCountPatterns(t) {
358
- const o = t[1];
359
- e(o <= this.size * 3);
360
- const n = o > 0 && t[2] == o && t[3] == o * 3 && t[4] == o && t[5] == o;
361
- return (n && t[0] >= o * 4 && t[6] >= o ? 1 : 0) + (n && t[6] >= o * 4 && t[0] >= o ? 1 : 0);
357
+ finderPenaltyCountPatterns(e) {
358
+ const o = e[1];
359
+ t(o <= this.size * 3);
360
+ const n = o > 0 && e[2] == o && e[3] == o * 3 && e[4] == o && e[5] == o;
361
+ return (n && e[0] >= o * 4 && e[6] >= o ? 1 : 0) + (n && e[6] >= o * 4 && e[0] >= o ? 1 : 0);
362
362
  }
363
363
  // Must be called at the end of a line (row or column) of modules. A helper function for getPenaltyScore().
364
- finderPenaltyTerminateAndCount(t, o, n) {
365
- return t && (this.finderPenaltyAddHistory(o, n), o = 0), o += this.size, this.finderPenaltyAddHistory(o, n), this.finderPenaltyCountPatterns(n);
364
+ finderPenaltyTerminateAndCount(e, o, n) {
365
+ return e && (this.finderPenaltyAddHistory(o, n), o = 0), o += this.size, this.finderPenaltyAddHistory(o, n), this.finderPenaltyCountPatterns(n);
366
366
  }
367
367
  // Pushes the given value to the front and drops the last value. A helper function for getPenaltyScore().
368
- finderPenaltyAddHistory(t, o) {
369
- o[0] == 0 && (t += this.size), o.pop(), o.unshift(t);
368
+ finderPenaltyAddHistory(e, o) {
369
+ o[0] == 0 && (e += this.size), o.pop(), o.unshift(e);
370
370
  }
371
371
  };
372
- l.MIN_VERSION = 1, l.MAX_VERSION = 40, l.PENALTY_N1 = 3, l.PENALTY_N2 = 3, l.PENALTY_N3 = 40, l.PENALTY_N4 = 10, l.ECC_CODEWORDS_PER_BLOCK = [
372
+ d.MIN_VERSION = 1, d.MAX_VERSION = 40, d.PENALTY_N1 = 3, d.PENALTY_N2 = 3, d.PENALTY_N3 = 40, d.PENALTY_N4 = 10, d.ECC_CODEWORDS_PER_BLOCK = [
373
373
  // Version: (note that index 0 is for padding, and is set to an illegal value)
374
374
  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
375
375
  [-1, 7, 10, 15, 20, 26, 18, 20, 24, 30, 18, 20, 24, 26, 30, 22, 24, 28, 30, 28, 28, 28, 28, 30, 30, 26, 28, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30],
@@ -380,7 +380,7 @@ var T;
380
380
  // Quartile
381
381
  [-1, 17, 28, 22, 16, 22, 28, 26, 26, 24, 28, 24, 28, 22, 24, 24, 30, 28, 28, 26, 28, 30, 24, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30, 30]
382
382
  // High
383
- ], l.NUM_ERROR_CORRECTION_BLOCKS = [
383
+ ], d.NUM_ERROR_CORRECTION_BLOCKS = [
384
384
  // Version: (note that index 0 is for padding, and is set to an illegal value)
385
385
  //0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40 Error correction level
386
386
  [-1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 4, 4, 4, 4, 4, 6, 6, 6, 6, 7, 8, 8, 9, 9, 10, 12, 12, 12, 13, 14, 15, 16, 17, 18, 19, 19, 20, 21, 22, 24, 25],
@@ -392,28 +392,28 @@ var T;
392
392
  [-1, 1, 1, 2, 4, 4, 4, 5, 6, 8, 8, 11, 11, 16, 16, 18, 16, 19, 21, 25, 25, 25, 34, 30, 32, 35, 37, 40, 42, 45, 48, 51, 54, 57, 60, 63, 66, 70, 74, 77, 81]
393
393
  // High
394
394
  ];
395
- let c = l;
396
- r.QrCode = c;
397
- function a(E, t, o) {
398
- if (t < 0 || t > 31 || E >>> t)
395
+ let s = d;
396
+ r.QrCode = s;
397
+ function c(g, e, o) {
398
+ if (e < 0 || e > 31 || g >>> e)
399
399
  throw new RangeError("Value out of range");
400
- for (let n = t - 1; n >= 0; n--)
401
- o.push(E >>> n & 1);
400
+ for (let n = e - 1; n >= 0; n--)
401
+ o.push(g >>> n & 1);
402
402
  }
403
- function s(E, t) {
404
- return (E >>> t & 1) != 0;
403
+ function a(g, e) {
404
+ return (g >>> e & 1) != 0;
405
405
  }
406
- function e(E) {
407
- if (!E)
406
+ function t(g) {
407
+ if (!g)
408
408
  throw new Error("Assertion error");
409
409
  }
410
- const $ = class $ {
410
+ const u = class u {
411
411
  /*-- Constructor (low level) and fields --*/
412
412
  // Creates a new QR Code segment with the given attributes and data.
413
413
  // The character count (numChars) must agree with the mode and the bit buffer length,
414
414
  // but the constraint isn't checked. The given bit buffer is cloned and stored.
415
- constructor(t, o, n) {
416
- if (this.mode = t, this.numChars = o, this.bitData = n, o < 0)
415
+ constructor(e, o, n) {
416
+ if (this.mode = e, this.numChars = o, this.bitData = n, o < 0)
417
417
  throw new RangeError("Invalid argument");
418
418
  this.bitData = n.slice();
419
419
  }
@@ -421,67 +421,67 @@ var T;
421
421
  // Returns a segment representing the given binary data encoded in
422
422
  // byte mode. All input byte arrays are acceptable. Any text string
423
423
  // can be converted to UTF-8 bytes and encoded as a byte mode segment.
424
- static makeBytes(t) {
424
+ static makeBytes(e) {
425
425
  let o = [];
426
- for (const n of t)
427
- a(n, 8, o);
428
- return new $($.Mode.BYTE, t.length, o);
426
+ for (const n of e)
427
+ c(n, 8, o);
428
+ return new u(u.Mode.BYTE, e.length, o);
429
429
  }
430
430
  // Returns a segment representing the given string of decimal digits encoded in numeric mode.
431
- static makeNumeric(t) {
432
- if (!$.isNumeric(t))
431
+ static makeNumeric(e) {
432
+ if (!u.isNumeric(e))
433
433
  throw new RangeError("String contains non-numeric characters");
434
434
  let o = [];
435
- for (let n = 0; n < t.length; ) {
436
- const i = Math.min(t.length - n, 3);
437
- a(parseInt(t.substring(n, n + i), 10), i * 3 + 1, o), n += i;
435
+ for (let n = 0; n < e.length; ) {
436
+ const i = Math.min(e.length - n, 3);
437
+ c(parseInt(e.substring(n, n + i), 10), i * 3 + 1, o), n += i;
438
438
  }
439
- return new $($.Mode.NUMERIC, t.length, o);
439
+ return new u(u.Mode.NUMERIC, e.length, o);
440
440
  }
441
441
  // Returns a segment representing the given text string encoded in alphanumeric mode.
442
442
  // The characters allowed are: 0 to 9, A to Z (uppercase only), space,
443
443
  // dollar, percent, asterisk, plus, hyphen, period, slash, colon.
444
- static makeAlphanumeric(t) {
445
- if (!$.isAlphanumeric(t))
444
+ static makeAlphanumeric(e) {
445
+ if (!u.isAlphanumeric(e))
446
446
  throw new RangeError("String contains unencodable characters in alphanumeric mode");
447
447
  let o = [], n;
448
- for (n = 0; n + 2 <= t.length; n += 2) {
449
- let i = $.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)) * 45;
450
- i += $.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n + 1)), a(i, 11, o);
448
+ for (n = 0; n + 2 <= e.length; n += 2) {
449
+ let i = u.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)) * 45;
450
+ i += u.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n + 1)), c(i, 11, o);
451
451
  }
452
- return n < t.length && a($.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)), 6, o), new $($.Mode.ALPHANUMERIC, t.length, o);
452
+ return n < e.length && c(u.ALPHANUMERIC_CHARSET.indexOf(e.charAt(n)), 6, o), new u(u.Mode.ALPHANUMERIC, e.length, o);
453
453
  }
454
454
  // Returns a new mutable list of zero or more segments to represent the given Unicode text string.
455
455
  // The result may use various segment modes and switch modes to optimize the length of the bit stream.
456
- static makeSegments(t) {
457
- return t == "" ? [] : $.isNumeric(t) ? [$.makeNumeric(t)] : $.isAlphanumeric(t) ? [$.makeAlphanumeric(t)] : [$.makeBytes($.toUtf8ByteArray(t))];
456
+ static makeSegments(e) {
457
+ return e == "" ? [] : u.isNumeric(e) ? [u.makeNumeric(e)] : u.isAlphanumeric(e) ? [u.makeAlphanumeric(e)] : [u.makeBytes(u.toUtf8ByteArray(e))];
458
458
  }
459
459
  // Returns a segment representing an Extended Channel Interpretation
460
460
  // (ECI) designator with the given assignment value.
461
- static makeEci(t) {
461
+ static makeEci(e) {
462
462
  let o = [];
463
- if (t < 0)
463
+ if (e < 0)
464
464
  throw new RangeError("ECI assignment value out of range");
465
- if (t < 128)
466
- a(t, 8, o);
467
- else if (t < 16384)
468
- a(2, 2, o), a(t, 14, o);
469
- else if (t < 1e6)
470
- a(6, 3, o), a(t, 21, o);
465
+ if (e < 128)
466
+ c(e, 8, o);
467
+ else if (e < 16384)
468
+ c(2, 2, o), c(e, 14, o);
469
+ else if (e < 1e6)
470
+ c(6, 3, o), c(e, 21, o);
471
471
  else
472
472
  throw new RangeError("ECI assignment value out of range");
473
- return new $($.Mode.ECI, 0, o);
473
+ return new u(u.Mode.ECI, 0, o);
474
474
  }
475
475
  // Tests whether the given string can be encoded as a segment in numeric mode.
476
476
  // A string is encodable iff each character is in the range 0 to 9.
477
- static isNumeric(t) {
478
- return $.NUMERIC_REGEX.test(t);
477
+ static isNumeric(e) {
478
+ return u.NUMERIC_REGEX.test(e);
479
479
  }
480
480
  // Tests whether the given string can be encoded as a segment in alphanumeric mode.
481
481
  // A string is encodable iff each character is in the following set: 0 to 9, A to Z
482
482
  // (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
483
- static isAlphanumeric(t) {
484
- return $.ALPHANUMERIC_REGEX.test(t);
483
+ static isAlphanumeric(e) {
484
+ return u.ALPHANUMERIC_REGEX.test(e);
485
485
  }
486
486
  /*-- Methods --*/
487
487
  // Returns a new copy of the data bits of this segment.
@@ -490,9 +490,9 @@ var T;
490
490
  }
491
491
  // (Package-private) Calculates and returns the number of bits needed to encode the given segments at
492
492
  // the given version. The result is infinity if a segment has too many characters to fit its length field.
493
- static getTotalBits(t, o) {
493
+ static getTotalBits(e, o) {
494
494
  let n = 0;
495
- for (const i of t) {
495
+ for (const i of e) {
496
496
  const h = i.mode.numCharCountBits(o);
497
497
  if (i.numChars >= 1 << h)
498
498
  return 1 / 0;
@@ -501,57 +501,57 @@ var T;
501
501
  return n;
502
502
  }
503
503
  // Returns a new array of bytes representing the given string encoded in UTF-8.
504
- static toUtf8ByteArray(t) {
505
- t = encodeURI(t);
504
+ static toUtf8ByteArray(e) {
505
+ e = encodeURI(e);
506
506
  let o = [];
507
- for (let n = 0; n < t.length; n++)
508
- t.charAt(n) != "%" ? o.push(t.charCodeAt(n)) : (o.push(parseInt(t.substring(n + 1, n + 3), 16)), n += 2);
507
+ for (let n = 0; n < e.length; n++)
508
+ e.charAt(n) != "%" ? o.push(e.charCodeAt(n)) : (o.push(parseInt(e.substring(n + 1, n + 3), 16)), n += 2);
509
509
  return o;
510
510
  }
511
511
  };
512
- $.NUMERIC_REGEX = /^[0-9]*$/, $.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, $.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
513
- let f = $;
514
- r.QrSegment = f;
515
- })(T || (T = {}));
512
+ u.NUMERIC_REGEX = /^[0-9]*$/, u.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, u.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
513
+ let l = u;
514
+ r.QrSegment = l;
515
+ })(O || (O = {}));
516
516
  ((r) => {
517
- ((c) => {
518
- const s = class s {
517
+ ((s) => {
518
+ const a = class a {
519
519
  // The QR Code can tolerate about 30% erroneous codewords
520
520
  /*-- Constructor and fields --*/
521
- constructor(f, l) {
522
- this.ordinal = f, this.formatBits = l;
521
+ constructor(l, d) {
522
+ this.ordinal = l, this.formatBits = d;
523
523
  }
524
524
  };
525
- s.LOW = new s(0, 1), s.MEDIUM = new s(1, 0), s.QUARTILE = new s(2, 3), s.HIGH = new s(3, 2);
526
- let a = s;
527
- c.Ecc = a;
525
+ a.LOW = new a(0, 1), a.MEDIUM = new a(1, 0), a.QUARTILE = new a(2, 3), a.HIGH = new a(3, 2);
526
+ let c = a;
527
+ s.Ecc = c;
528
528
  })(r.QrCode || (r.QrCode = {}));
529
- })(T || (T = {}));
529
+ })(O || (O = {}));
530
530
  ((r) => {
531
- ((c) => {
532
- const s = class s {
531
+ ((s) => {
532
+ const a = class a {
533
533
  /*-- Constructor and fields --*/
534
- constructor(f, l) {
535
- this.modeBits = f, this.numBitsCharCount = l;
534
+ constructor(l, d) {
535
+ this.modeBits = l, this.numBitsCharCount = d;
536
536
  }
537
537
  /*-- Method --*/
538
538
  // (Package-private) Returns the bit width of the character count field for a segment in
539
539
  // this mode in a QR Code at the given version number. The result is in the range [0, 16].
540
- numCharCountBits(f) {
541
- return this.numBitsCharCount[Math.floor((f + 7) / 17)];
540
+ numCharCountBits(l) {
541
+ return this.numBitsCharCount[Math.floor((l + 7) / 17)];
542
542
  }
543
543
  };
544
- s.NUMERIC = new s(1, [10, 12, 14]), s.ALPHANUMERIC = new s(2, [9, 11, 13]), s.BYTE = new s(4, [8, 16, 16]), s.KANJI = new s(8, [8, 10, 12]), s.ECI = new s(7, [0, 0, 0]);
545
- let a = s;
546
- c.Mode = a;
544
+ a.NUMERIC = new a(1, [10, 12, 14]), a.ALPHANUMERIC = new a(2, [9, 11, 13]), a.BYTE = new a(4, [8, 16, 16]), a.KANJI = new a(8, [8, 10, 12]), a.ECI = new a(7, [0, 0, 0]);
545
+ let c = a;
546
+ s.Mode = c;
547
547
  })(r.QrSegment || (r.QrSegment = {}));
548
- })(T || (T = {}));
549
- const F = T, _ = {
550
- L: F.QrCode.Ecc.LOW,
551
- M: F.QrCode.Ecc.MEDIUM,
552
- Q: F.QrCode.Ecc.QUARTILE,
553
- H: F.QrCode.Ecc.HIGH
554
- }, V = 128, W = "M", J = "#FFFFFF", tt = 1, et = 4, X = 5, y = "#000000", nt = "square", ot = "square", rt = "square", st = 0.1, C = 7, P = 3, b = [
548
+ })(O || (O = {}));
549
+ const v = O, rt = {
550
+ L: v.QrCode.Ecc.LOW,
551
+ M: v.QrCode.Ecc.MEDIUM,
552
+ Q: v.QrCode.Ecc.QUARTILE,
553
+ H: v.QrCode.Ecc.HIGH
554
+ }, st = 128, it = "M", at = "#FFFFFF", ct = 1, lt = 4, Z = 5, z = "#000000", ht = "square", ut = "square", dt = "square", ft = "react-qr-code", S = "react-qr-code-gradient", D = "react-qr-code-bg-gradient", $t = 0.1, I = 7, T = 3, b = [
555
555
  [1, 1, 1, 1, 1, 1, 1],
556
556
  [1, 0, 0, 0, 0, 0, 1],
557
557
  [1, 0, 0, 0, 0, 0, 1],
@@ -559,7 +559,7 @@ const F = T, _ = {
559
559
  [1, 0, 0, 0, 0, 0, 1],
560
560
  [1, 0, 0, 0, 0, 0, 1],
561
561
  [1, 1, 1, 1, 1, 1, 1]
562
- ], Z = {
562
+ ], K = {
563
563
  "inpoint-sm": [0, 90, -90],
564
564
  inpoint: [0, 90, -90],
565
565
  "inpoint-lg": [0, 90, -90],
@@ -569,7 +569,7 @@ const F = T, _ = {
569
569
  "leaf-sm": [0, 90, -90],
570
570
  leaf: [0, 90, -90],
571
571
  "leaf-lg": [0, 90, -90]
572
- }, B = {
572
+ }, H = {
573
573
  "rounded-sm": 3,
574
574
  rounded: 4,
575
575
  "rounded-lg": 5,
@@ -582,7 +582,7 @@ const F = T, _ = {
582
582
  "outpoint-sm": 3,
583
583
  outpoint: 4,
584
584
  "outpoint-lg": 5
585
- }, U = {
585
+ }, k = {
586
586
  square: 0,
587
587
  diamond: 0,
588
588
  circle: 3,
@@ -598,7 +598,7 @@ const F = T, _ = {
598
598
  "outpoint-sm": 1.5,
599
599
  outpoint: 2,
600
600
  "outpoint-lg": 2.3
601
- }, v = [
601
+ }, B = [
602
602
  [0, 0, 0, 0, 0, 0, 0],
603
603
  [0, 0, 0, 0, 0, 0, 0],
604
604
  [0, 0, 1, 1, 1, 0, 0],
@@ -606,120 +606,28 @@ const F = T, _ = {
606
606
  [0, 0, 1, 1, 1, 0, 0],
607
607
  [0, 0, 0, 0, 0, 0, 0],
608
608
  [0, 0, 0, 0, 0, 0, 0]
609
- ], it = (r) => r === "square" || r === "circle" || r === "star" || r === "heart" || r === "diamond", L = (r, c, a) => {
610
- const s = {
611
- left: r === 0 ? 0 : a[c][r - 1],
612
- right: r === a[c].length - 1 ? 0 : a[c][r + 1],
613
- top: c === 0 ? 0 : a[c - 1][r],
614
- bottom: c === a.length - 1 ? 0 : a[c + 1][r]
615
- };
609
+ ], pt = /\.?0+$/;
610
+ function mt(r) {
611
+ return r.toFixed(7).replace(pt, "");
612
+ }
613
+ const V = (r) => {
614
+ const s = r % 360 * (Math.PI / 180), c = Math.max(0, Math.min(100, 50 - 50 * Math.cos(s))), a = Math.max(0, Math.min(100, 50 - 50 * Math.sin(s))), t = Math.max(0, Math.min(100, 50 + 50 * Math.cos(s))), l = Math.max(0, Math.min(100, 50 + 50 * Math.sin(s)));
616
615
  return {
617
- ...s,
618
- count: Object.values(s).filter(Boolean).length
616
+ x1: `${c}%`,
617
+ y1: `${a}%`,
618
+ x2: `${t}%`,
619
+ y2: `${l}%`
619
620
  };
620
- }, O = (r, c, a) => `M${r},${c}h${a}v${a}h-${a}Z`, D = (r, c, a) => `M${r},${c + a / 2}a${a / 2},${a / 2} 0 1,0 ${a},0a${a / 2},${a / 2} 0 1,0 -${a},0Z`, at = (r, c, a) => `M${r},${c + a / 2}l${a / 2},-${a / 2}l${a / 2},${a / 2}l-${a / 2},${a / 2}Z`, lt = (r, c) => `M ${r} ${c}
621
- v 1
622
- h 1
623
- v -0.5
624
- a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, z = (r, c) => `M ${r + 1} ${c}
625
- v 1
626
- h -1
627
- v -0.5
628
- a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, k = (r, c) => `M ${r} ${c}
629
- v 1
630
- h 0.5
631
- a 0.5 0.5, 0, 0, 0, 0.5 -0.5
632
- v -0.5
633
- h -1`, ct = (r, c) => `M ${r + 1} ${c}
634
- v 1
635
- h -0.5
636
- a 0.5 0.5, 0, 0, 1, -0.5 -0.5
637
- v -0.5
638
- h 1`, Y = (r, c) => `M ${r} ${c}
639
- v 1
640
- h 0.5
641
- a 0.5 0.5, 0, 0, 0, 0 -1`, H = (r, c) => `M ${r + 1} ${c}
642
- v 1
643
- h -0.5
644
- a 0.5 0.5, 0, 0, 1, 0 -1`, q = (r, c) => `M ${r} ${c + 1}
645
- h 1
646
- v -0.5
647
- a 0.5 0.5, 0, 0, 0, -1 0`, G = (r, c) => `M ${r} ${c}
648
- h 1
649
- v 0.5
650
- a 0.5 0.5, 0, 0, 1, -1 0`, ht = (r, c, a) => `M ${r + 1} ${c}h -${a / 2}a ${a / 2.5} ${a / 2.5}, 0, 0, 0, ${-a / 2.5} ${a / 2.5}v ${a / 2}h ${a / 2}a ${a / 2.5} ${a / 2.5}, 0, 0, 0, ${a / 2.5} ${-a / 2.5}`, ut = ({
651
- x: r,
652
- y: c,
653
- numCells: a
654
- }) => {
655
- var s, e, f;
656
- return !!((s = v[r]) != null && s[c] || (e = v[r - a + 7]) != null && e[c] || (f = v[r]) != null && f[c - a + 7]);
657
- }, ft = ({
658
- x: r,
659
- y: c,
660
- radius: a
661
- }) => {
662
- const s = P - a, e = a / 2, f = P - e;
663
- return `M ${r} ${c + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${f}v ${-f}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}H ${r}z`;
664
- }, dt = ({
665
- x: r,
666
- y: c,
667
- radius: a
668
- }) => {
669
- const s = P - a, e = a / 2, f = P - e;
670
- return `M ${r} ${c + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${f}v ${-f}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}a ${e} ${e}, 0, 0, 0, ${-e} ${e}`;
671
- }, $t = ({
672
- x: r,
673
- y: c,
674
- numCells: a
675
- }) => {
676
- var s, e, f;
677
- return !!((s = b[r]) != null && s[c] || (e = b[r - a + 7]) != null && e[c] || (f = b[r]) != null && f[c - a + 7]);
678
- }, pt = ({
679
- x: r,
680
- y: c,
681
- radius: a
682
- }) => {
683
- const s = C - a, e = a / 2;
684
- return `M ${r} ${c + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${s}a ${e} ${e}, 0, 0, 0, ${e} ${-e}v ${-s}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}a ${e} ${e}, 0, 0, 0, ${-e} ${e}M ${r + e} ${c + 1}h ${s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${e - 1}v ${s}a ${e - 1} ${e - 1}, 0, 0, 1, ${-(e - 1)} ${e - 1}h ${-s}a ${e - 1} ${e - 1}, 0, 0, 1, ${-(e - 1)} ${-(e - 1)}v ${-s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${-(e - 1)}`;
685
- }, Et = ({
686
- x: r,
687
- y: c,
688
- radius: a
689
- }) => {
690
- const s = C - a, e = a / 2, f = C - e;
691
- return `M ${r} ${c + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${f}v ${-f}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}H ${r}zM ${r + e} ${c + 1}h ${s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${e - 1}v ${f - 1}h ${-(f - 1)}a ${e - 1} ${e - 1}, 0, 0, 1, ${-(e - 1)} ${-(e - 1)}v ${-(f - 1)}z`;
692
- }, mt = ({
693
- x: r,
694
- y: c,
695
- radius: a
696
- }) => {
697
- const s = C - a, e = a / 2, f = C - e;
698
- return `M ${r} ${c + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${f}v ${-f}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}a ${e} ${e}, 0, 0, 0, ${-e} ${e}M ${r + e} ${c + 1}h ${s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${e - 1}v ${f - 1}h ${-(f - 1)}a ${e - 1} ${e - 1}, 0, 0, 1, ${-(e - 1)} ${-(e - 1)}v ${-s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${-(e - 1)}`;
699
- }, Mt = (r) => ({
700
- color: (r == null ? void 0 : r.color) || y,
701
- style: (r == null ? void 0 : r.style) || rt,
702
- randomSize: (r == null ? void 0 : r.randomSize) || !1
703
- }), Rt = (r) => ({
704
- color: (r == null ? void 0 : r.color) || y,
705
- style: (r == null ? void 0 : r.style) || nt
706
- }), gt = (r) => ({
707
- color: (r == null ? void 0 : r.color) || y,
708
- style: (r == null ? void 0 : r.style) || ot
709
- }), At = /\.?0+$/;
710
- function Nt(r) {
711
- return r.toFixed(7).replace(At, "");
712
- }
713
- const K = (r, c, a, s) => {
714
- const e = a / 2, f = e / 2, l = Math.PI / s;
715
- let $ = "";
716
- for (let E = 0; E < 2 * s; E++) {
717
- const t = E * l - Math.PI / 2, o = E % 2 === 0 ? e : f, n = r + o * Math.cos(t), i = c + o * Math.sin(t);
718
- $ += `${E === 0 ? "M" : "L"} ${n},${i} `;
621
+ }, W = (r, s, c, a) => {
622
+ const t = c / 2, l = t / 2, d = Math.PI / a;
623
+ let u = "";
624
+ for (let g = 0; g < 2 * a; g++) {
625
+ const e = g * d - Math.PI / 2, o = g % 2 === 0 ? t : l, n = r + o * Math.cos(e), i = s + o * Math.sin(e);
626
+ u += `${g === 0 ? "M" : "L"} ${n},${i} `;
719
627
  }
720
- return $ + "Z";
721
- }, Q = (r, c, a) => {
722
- let s = !1, e = 0;
628
+ return u + "Z";
629
+ }, J = (r, s, c) => {
630
+ let a = !1, t = 0;
723
631
  return [
724
632
  "M",
725
633
  1,
@@ -831,322 +739,514 @@ const K = (r, c, a, s) => {
831
739
  1,
832
740
  0.3262506,
833
741
  "z"
834
- ].map((f) => typeof f == "string" ? (e = 0, s = f.toUpperCase() == f, f) : (e++, f = f * a, s && (f += e % 2 == 1 ? r : c), Nt(f))).join(" ");
742
+ ].map((l) => typeof l == "string" ? (t = 0, a = l.toUpperCase() == l, l) : (t++, l = l * c, a && (l += t % 2 == 1 ? r : s), mt(l))).join(" ");
743
+ }, Et = ({ background: r, numCells: s }) => {
744
+ var a, t;
745
+ if (!r)
746
+ return /* @__PURE__ */ N("path", { fill: at, d: `M0,0 h${s}v${s}H0z` });
747
+ if (typeof r == "string")
748
+ return /* @__PURE__ */ N("path", { fill: r, d: `M0,0 h${s}v${s}H0z` });
749
+ const c = V((r == null ? void 0 : r.rotation) || 0);
750
+ return /* @__PURE__ */ Q(tt, { children: [
751
+ /* @__PURE__ */ N("defs", { children: r.type === "linear" ? /* @__PURE__ */ N("linearGradient", { id: D, gradientUnits: "userSpaceOnUse", ...c, children: (a = r.stops) == null ? void 0 : a.map((l, d) => /* @__PURE__ */ N("stop", { offset: l.offset, stopColor: l.color }, d)) }) : /* @__PURE__ */ N(
752
+ "radialGradient",
753
+ {
754
+ id: D,
755
+ gradientUnits: "userSpaceOnUse",
756
+ cx: "50%",
757
+ cy: "50%",
758
+ r: "50%",
759
+ children: (t = r.stops) == null ? void 0 : t.map((l, d) => /* @__PURE__ */ N("stop", { offset: l.offset, stopColor: l.color }, d))
760
+ }
761
+ ) }),
762
+ /* @__PURE__ */ N("path", { fill: `url(#${D})`, d: `M0,0 h${s}v${s}H0z` })
763
+ ] });
764
+ }, Mt = (r) => r === "square" || r === "circle" || r === "star" || r === "heart" || r === "diamond", F = (r, s, c) => {
765
+ const a = {
766
+ left: r === 0 ? 0 : c[s][r - 1],
767
+ right: r === c[s].length - 1 ? 0 : c[s][r + 1],
768
+ top: s === 0 ? 0 : c[s - 1][r],
769
+ bottom: s === c.length - 1 ? 0 : c[s + 1][r]
770
+ };
771
+ return {
772
+ ...a,
773
+ count: Object.values(a).filter(Boolean).length
774
+ };
775
+ }, y = (r, s, c) => `M${r},${s}h${c}v${c}h-${c}Z`, U = (r, s, c) => `M${r},${s + c / 2}a${c / 2},${c / 2} 0 1,0 ${c},0a${c / 2},${c / 2} 0 1,0 -${c},0Z`, Rt = (r, s, c) => `M${r},${s + c / 2}l${c / 2},-${c / 2}l${c / 2},${c / 2}l-${c / 2},${c / 2}Z`, gt = (r, s) => `M ${r} ${s}
776
+ v 1
777
+ h 1
778
+ v -0.5
779
+ a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, G = (r, s) => `M ${r + 1} ${s}
780
+ v 1
781
+ h -1
782
+ v -0.5
783
+ a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, Y = (r, s) => `M ${r} ${s}
784
+ v 1
785
+ h 0.5
786
+ a 0.5 0.5, 0, 0, 0, 0.5 -0.5
787
+ v -0.5
788
+ h -1`, At = (r, s) => `M ${r + 1} ${s}
789
+ v 1
790
+ h -0.5
791
+ a 0.5 0.5, 0, 0, 1, -0.5 -0.5
792
+ v -0.5
793
+ h 1`, q = (r, s) => `M ${r} ${s}
794
+ v 1
795
+ h 0.5
796
+ a 0.5 0.5, 0, 0, 0, 0 -1`, j = (r, s) => `M ${r + 1} ${s}
797
+ v 1
798
+ h -0.5
799
+ a 0.5 0.5, 0, 0, 1, 0 -1`, X = (r, s) => `M ${r} ${s + 1}
800
+ h 1
801
+ v -0.5
802
+ a 0.5 0.5, 0, 0, 0, -1 0`, _ = (r, s) => `M ${r} ${s}
803
+ h 1
804
+ v 0.5
805
+ a 0.5 0.5, 0, 0, 1, -1 0`, wt = (r, s, c) => `M ${r + 1} ${s}h -${c / 2}a ${c / 2.5} ${c / 2.5}, 0, 0, 0, ${-c / 2.5} ${c / 2.5}v ${c / 2}h ${c / 2}a ${c / 2.5} ${c / 2.5}, 0, 0, 0, ${c / 2.5} ${-c / 2.5}`, Nt = ({
806
+ x: r,
807
+ y: s,
808
+ numCells: c
809
+ }) => {
810
+ var a, t, l;
811
+ return !!((a = B[r]) != null && a[s] || (t = B[r - c + 7]) != null && t[s] || (l = B[r]) != null && l[s - c + 7]);
835
812
  }, Ct = ({
813
+ x: r,
814
+ y: s,
815
+ radius: c
816
+ }) => {
817
+ const a = T - c, t = c / 2, l = T - t;
818
+ return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${l}v ${-l}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}H ${r}z`;
819
+ }, It = ({
820
+ x: r,
821
+ y: s,
822
+ radius: c
823
+ }) => {
824
+ const a = T - c, t = c / 2, l = T - t;
825
+ return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${l}v ${-l}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${t}`;
826
+ }, Pt = ({
827
+ x: r,
828
+ y: s,
829
+ numCells: c
830
+ }) => {
831
+ var a, t, l;
832
+ return !!((a = b[r]) != null && a[s] || (t = b[r - c + 7]) != null && t[s] || (l = b[r]) != null && l[s - c + 7]);
833
+ }, Tt = ({
834
+ x: r,
835
+ y: s,
836
+ radius: c
837
+ }) => {
838
+ const a = I - c, t = c / 2;
839
+ return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${a}a ${t} ${t}, 0, 0, 0, ${t} ${-t}v ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${t}M ${r + t} ${s + 1}h ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${t - 1}h ${-a}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${-(t - 1)}`;
840
+ }, Lt = ({
841
+ x: r,
842
+ y: s,
843
+ radius: c
844
+ }) => {
845
+ const a = I - c, t = c / 2, l = I - t;
846
+ return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${l}v ${-l}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}H ${r}zM ${r + t} ${s + 1}h ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${l - 1}h ${-(l - 1)}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-(l - 1)}z`;
847
+ }, Ot = ({
848
+ x: r,
849
+ y: s,
850
+ radius: c
851
+ }) => {
852
+ const a = I - c, t = c / 2, l = I - t;
853
+ return `M ${r} ${s + t}v ${a}a ${t} ${t}, 0, 0, 0, ${t} ${t}h ${l}v ${-l}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}h ${-a}a ${t} ${t}, 0, 0, 0, ${-t} ${t}M ${r + t} ${s + 1}h ${a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${t - 1}v ${l - 1}h ${-(l - 1)}a ${t - 1} ${t - 1}, 0, 0, 1, ${-(t - 1)} ${-(t - 1)}v ${-a}a ${t - 1} ${t - 1}, 0, 0, 1, ${t - 1} ${-(t - 1)}`;
854
+ }, vt = (r) => ({
855
+ color: (r == null ? void 0 : r.color) || z,
856
+ style: (r == null ? void 0 : r.style) || dt,
857
+ randomSize: (r == null ? void 0 : r.randomSize) || !1
858
+ }), yt = (r) => ({
859
+ color: (r == null ? void 0 : r.color) || z,
860
+ style: (r == null ? void 0 : r.style) || ht
861
+ }), St = (r) => ({
862
+ color: (r == null ? void 0 : r.color) || z,
863
+ style: (r == null ? void 0 : r.style) || ut
864
+ }), Ft = ({
836
865
  modules: r,
837
- margin: c,
838
- settings: a
866
+ margin: s,
867
+ settings: c,
868
+ gradient: a
839
869
  }) => {
840
- const { color: s, style: e, randomSize: f } = S(
841
- () => Mt(a),
842
- [a]
843
- ), l = [], $ = r.length, E = it(e) && f, t = x(() => e === "square-sm" ? 0.75 : E ? Math.random() * (1 - 0.75) + 0.75 : 1, [e, E]);
844
- return r.forEach((o, n) => {
845
- o.forEach((i, h) => {
846
- if ($t({ x: h, y: n, numCells: $ }) || ut({ x: h, y: n, numCells: $ }))
870
+ const { color: t, style: l, randomSize: d } = L(
871
+ () => vt(c),
872
+ [c]
873
+ ), u = [], g = r.length, e = Mt(l) && d, o = et(() => l === "square-sm" ? 0.75 : e ? Math.random() * (1 - 0.75) + 0.75 : 1, [l, e]);
874
+ return r.forEach((n, i) => {
875
+ n.forEach((h, $) => {
876
+ if (Pt({ x: $, y: i, numCells: g }) || Nt({ x: $, y: i, numCells: g }))
847
877
  return;
848
- const p = t(), d = 1 * p, R = (1 - 1 * p) / 2, u = h + c + R, M = n + c + R;
849
- if (i) {
850
- if (e === "square" || e === "square-sm")
851
- l.push(O(u, M, d));
852
- else if (e === "circle")
853
- l.push(D(u, M, d));
854
- else if (e === "diamond")
855
- l.push(at(u, M, d));
856
- else if (e === "star")
857
- l.push(
858
- K(u + d / 2, M + d / 2, d * 1.1, X)
878
+ const f = o(), p = 1 * f, M = (1 - 1 * f) / 2, E = $ + s + M, m = i + s + M;
879
+ if (h) {
880
+ if (l === "square" || l === "square-sm")
881
+ u.push(y(E, m, p));
882
+ else if (l === "circle")
883
+ u.push(U(E, m, p));
884
+ else if (l === "diamond")
885
+ u.push(Rt(E, m, p));
886
+ else if (l === "star")
887
+ u.push(
888
+ W(E + p / 2, m + p / 2, p * 1.1, Z)
859
889
  );
860
- else if (e === "heart")
861
- l.push(Q(u, M, d));
862
- else if (e === "rounded") {
863
- const { left: A, right: m, top: g, bottom: N, count: I } = L(h, n, r);
864
- I === 0 ? l.push(D(u, M, 1)) : I > 2 || A && m || g && N ? l.push(O(u, M, 1)) : I === 2 ? A && g ? l.push(k(u, M)) : g && m ? l.push(ct(u, M)) : m && N ? l.push(z(u, M)) : l.push(lt(u, M)) : g ? l.push(G(u, M)) : m ? l.push(H(u, M)) : N ? l.push(q(u, M)) : l.push(Y(u, M));
865
- } else if (e === "leaf") {
866
- const { left: A, right: m, top: g, bottom: N, count: I } = L(h, n, r);
867
- if (I === 0)
868
- l.push(ht(u, M, d));
869
- else if (!A && !g) {
870
- l.push(z(u, M));
890
+ else if (l === "heart")
891
+ u.push(J(E, m, p));
892
+ else if (l === "rounded") {
893
+ const { left: R, right: A, top: w, bottom: C, count: P } = F($, i, r);
894
+ P === 0 ? u.push(U(E, m, 1)) : P > 2 || R && A || w && C ? u.push(y(E, m, 1)) : P === 2 ? R && w ? u.push(Y(E, m)) : w && A ? u.push(At(E, m)) : A && C ? u.push(G(E, m)) : u.push(gt(E, m)) : w ? u.push(_(E, m)) : A ? u.push(j(E, m)) : C ? u.push(X(E, m)) : u.push(q(E, m));
895
+ } else if (l === "leaf") {
896
+ const { left: R, right: A, top: w, bottom: C, count: P } = F($, i, r);
897
+ if (P === 0)
898
+ u.push(wt(E, m, p));
899
+ else if (!R && !w) {
900
+ u.push(G(E, m));
871
901
  return;
872
- } else !m && !N ? l.push(k(u, M)) : l.push(O(u, M, 1));
873
- } else if (e === "vertical-line") {
874
- const { left: A, right: m, top: g, bottom: N, count: I } = L(h, n, r);
875
- I === 0 || A && !(g || N) || m && !(g || N) ? l.push(D(u, M, 1)) : g && N ? l.push(O(u, M, 1)) : g && !N ? l.push(G(u, M)) : N && !g && l.push(q(u, M));
876
- } else if (e === "horizontal-line") {
877
- const { left: A, right: m, top: g, bottom: N, count: I } = L(h, n, r);
878
- I === 0 || g && !(A || m) || N && !(A || m) ? l.push(D(u, M, 1)) : A && m ? l.push(O(u, M, 1)) : A && !m ? l.push(Y(u, M)) : m && !A && l.push(H(u, M));
902
+ } else !A && !C ? u.push(Y(E, m)) : u.push(y(E, m, 1));
903
+ } else if (l === "vertical-line") {
904
+ const { left: R, right: A, top: w, bottom: C, count: P } = F($, i, r);
905
+ P === 0 || R && !(w || C) || A && !(w || C) ? u.push(U(E, m, 1)) : w && C ? u.push(y(E, m, 1)) : w && !C ? u.push(_(E, m)) : C && !w && u.push(X(E, m));
906
+ } else if (l === "horizontal-line") {
907
+ const { left: R, right: A, top: w, bottom: C, count: P } = F($, i, r);
908
+ P === 0 || w && !(R || A) || C && !(R || A) ? u.push(U(E, m, 1)) : R && A ? u.push(y(E, m, 1)) : R && !A ? u.push(q(E, m)) : A && !R && u.push(j(E, m));
879
909
  }
880
910
  }
881
911
  });
882
- }), /* @__PURE__ */ w(
912
+ }), /* @__PURE__ */ N(
883
913
  "path",
884
914
  {
885
- fill: s,
886
- d: l.join(""),
887
- shapeRendering: e === "square" ? "crispEdges" : "geometricPrecision"
915
+ fill: a ? `url(#${S})` : t,
916
+ d: u.join(""),
917
+ shapeRendering: l === "square" ? "crispEdges" : "geometricPrecision"
888
918
  }
889
919
  );
890
- }, wt = ({
920
+ }, Ut = ({
891
921
  modules: r,
892
- margin: c,
893
- settings: a
922
+ margin: s,
923
+ settings: c,
924
+ gradient: a
894
925
  }) => {
895
- const { color: s, style: e } = S(
896
- () => gt(a),
897
- [a]
898
- ), f = S(
926
+ const { color: t, style: l } = L(
927
+ () => St(c),
928
+ [c]
929
+ ), d = a ? `url(#${S})` : t, u = L(
899
930
  () => [
900
- { x: c + 2, y: c + 2 },
901
- { x: r.length + c - C + 2, y: c + 2 },
902
- { x: c + 2, y: r.length + c - C + 2 }
931
+ { x: s + 2, y: s + 2 },
932
+ { x: r.length + s - I + 2, y: s + 2 },
933
+ { x: s + 2, y: r.length + s - I + 2 }
903
934
  ],
904
- [c, r.length]
905
- ), l = ($, E) => `finder-patterns-inner-${e}-${$}-${E}`;
906
- if (e === "rounded-sm" || e === "rounded" || e === "rounded-lg" || e === "circle" || e === "square")
907
- return f.map(($) => {
908
- const { x: E, y: t } = $;
909
- return /* @__PURE__ */ w(
935
+ [s, r.length]
936
+ ), g = (e, o) => `finder-patterns-inner-${l}-${e}-${o}`;
937
+ if (l === "rounded-sm" || l === "rounded" || l === "rounded-lg" || l === "circle" || l === "square")
938
+ return u.map((e) => {
939
+ const { x: o, y: n } = e;
940
+ return /* @__PURE__ */ N(
910
941
  "rect",
911
942
  {
912
- x: E,
913
- y: t,
914
- width: P,
915
- height: P,
916
- fill: s,
917
- rx: U[e]
943
+ x: o,
944
+ y: n,
945
+ width: T,
946
+ height: T,
947
+ fill: d,
948
+ rx: k[l]
918
949
  },
919
- l(E, t)
950
+ g(o, n)
920
951
  );
921
952
  });
922
- if (e === "diamond")
923
- return f.map(($) => {
924
- const { x: E, y: t } = $, o = Math.sqrt(1.5), n = P / o, i = n - n / o;
925
- return /* @__PURE__ */ w(
953
+ if (l === "diamond")
954
+ return u.map((e) => {
955
+ const { x: o, y: n } = e, i = Math.sqrt(1.5), h = T / i, $ = h - h / i;
956
+ return /* @__PURE__ */ N(
926
957
  "rect",
927
958
  {
928
- x: E + i / 2,
929
- y: t + i / 2,
930
- width: n,
931
- height: n,
932
- fill: s,
959
+ x: o + $ / 2,
960
+ y: n + $ / 2,
961
+ width: h,
962
+ height: h,
963
+ fill: d,
933
964
  style: {
934
965
  transform: "rotate(45deg)",
935
966
  transformOrigin: "center",
936
967
  transformBox: "fill-box"
937
968
  }
938
969
  },
939
- l(E, t)
970
+ g(o, n)
940
971
  );
941
972
  });
942
- if (e === "inpoint-sm" || e === "inpoint" || e === "inpoint-lg" || e === "outpoint-sm" || e === "outpoint" || e === "outpoint-lg" || e === "leaf-sm" || e === "leaf" || e === "leaf-lg") {
943
- const $ = e === "leaf-sm" || e === "leaf" || e === "leaf-lg" ? ft : dt;
944
- return f.map((E, t) => ({
945
- ...E,
946
- rotation: Z[e][t]
947
- })).map(({ x: E, y: t, rotation: o }) => {
948
- const n = $({
949
- x: E,
950
- y: t,
951
- radius: U[e]
973
+ if (l === "inpoint-sm" || l === "inpoint" || l === "inpoint-lg" || l === "outpoint-sm" || l === "outpoint" || l === "outpoint-lg" || l === "leaf-sm" || l === "leaf" || l === "leaf-lg") {
974
+ const e = l === "leaf-sm" || l === "leaf" || l === "leaf-lg" ? Ct : It;
975
+ return u.map((o, n) => ({
976
+ ...o,
977
+ rotation: K[l][n]
978
+ })).map(({ x: o, y: n, rotation: i }) => {
979
+ const h = e({
980
+ x: o,
981
+ y: n,
982
+ radius: k[l]
952
983
  });
953
- return /* @__PURE__ */ w(
984
+ return /* @__PURE__ */ N(
954
985
  "path",
955
986
  {
956
- fill: s,
957
- d: n,
987
+ fill: d,
988
+ d: h,
958
989
  style: {
959
- transform: `rotate(${o}deg)`,
990
+ transform: `rotate(${i}deg)`,
960
991
  transformOrigin: "center",
961
992
  transformBox: "fill-box"
962
993
  }
963
994
  },
964
- l(E, t)
995
+ g(o, n)
965
996
  );
966
997
  });
967
998
  }
968
- return e === "heart" ? f.map(({ x: $, y: E }) => /* @__PURE__ */ w("path", { fill: s, d: Q($, E, P) }, l($, E))) : e === "star" ? f.map(({ x: $, y: E }) => {
969
- const t = $ + P / 2, o = E + P / 2, n = K(t, o, P * 1.2, X);
970
- return /* @__PURE__ */ w("path", { fill: s, d: n }, l($, E));
999
+ return l === "heart" ? u.map(({ x: e, y: o }) => /* @__PURE__ */ N("path", { fill: d, d: J(e, o, T) }, g(e, o))) : l === "star" ? u.map(({ x: e, y: o }) => {
1000
+ const n = e + T / 2, i = o + T / 2, h = W(n, i, T * 1.2, Z);
1001
+ return /* @__PURE__ */ N("path", { fill: d, d: h }, g(e, o));
971
1002
  }) : null;
972
- }, It = ({
1003
+ }, Dt = ({
973
1004
  modules: r,
974
- margin: c,
975
- settings: a
1005
+ margin: s,
1006
+ settings: c,
1007
+ gradient: a
976
1008
  }) => {
977
- const { style: s, color: e } = S(
978
- () => Rt(a),
979
- [a]
980
- ), f = [], l = S(
1009
+ const { style: t, color: l } = L(
1010
+ () => yt(c),
1011
+ [c]
1012
+ ), d = a ? `url(#${S})` : l, u = [], g = L(
981
1013
  () => [
982
- { x: c, y: c },
983
- { x: r.length + c - C, y: c },
984
- { x: c, y: r.length + c - C }
1014
+ { x: s, y: s },
1015
+ { x: r.length + s - I, y: s },
1016
+ { x: s, y: r.length + s - I }
985
1017
  ],
986
- [c, r.length]
1018
+ [s, r.length]
987
1019
  );
988
- if (console.log("modules.length", r.length), console.log("coordinates", l), ["rounded-sm", "rounded", "rounded-lg", "circle", "square"].includes(s)) {
989
- for (const $ of l) {
990
- const { x: E, y: t } = $;
991
- s === "rounded-sm" || s === "rounded" || s === "rounded-lg" ? f.push(
992
- pt({
993
- x: E,
994
- y: t,
995
- radius: B[s]
1020
+ if (["rounded-sm", "rounded", "rounded-lg", "circle", "square"].includes(t)) {
1021
+ for (const e of g) {
1022
+ const { x: o, y: n } = e;
1023
+ t === "rounded-sm" || t === "rounded" || t === "rounded-lg" ? u.push(
1024
+ Tt({
1025
+ x: o,
1026
+ y: n,
1027
+ radius: H[t]
996
1028
  })
997
- ) : s === "circle" ? f.push(
998
- `M ${E + C / 2} ${t}a ${C / 2} ${C / 2} 0 1 0 0.01 0zzm 0 1a ${C / 2 - 1} ${C / 2 - 1} 0 1 1 -0.01 0Z`
999
- ) : f.push(
1000
- `M ${E} ${t}v ${C}h ${C}v -7zM ${E + 1} ${t + 1}h ${C - 2 * 1}v ${C - 2 * 1}h ${-7 + 2 * 1}z`
1029
+ ) : t === "circle" ? u.push(
1030
+ `M ${o + I / 2} ${n}a ${I / 2} ${I / 2} 0 1 0 0.01 0zzm 0 1a ${I / 2 - 1} ${I / 2 - 1} 0 1 1 -0.01 0Z`
1031
+ ) : u.push(
1032
+ `M ${o} ${n}v ${I}h ${I}v -7zM ${o + 1} ${n + 1}h ${I - 2 * 1}v ${I - 2 * 1}h ${-7 + 2 * 1}z`
1001
1033
  );
1002
1034
  }
1003
- return /* @__PURE__ */ w("path", { fill: e, d: f.join("") });
1035
+ return /* @__PURE__ */ N("path", { fill: d, d: u.join("") });
1004
1036
  }
1005
- if (s === "inpoint-sm" || s === "inpoint" || s === "inpoint-lg" || s === "outpoint-sm" || s === "outpoint" || s === "outpoint-lg" || s === "leaf-sm" || s === "leaf" || s === "leaf-lg") {
1006
- const $ = s === "leaf-sm" || s === "leaf" || s === "leaf-lg" ? Et : mt;
1007
- return l.map((E, t) => ({
1008
- ...E,
1009
- rotation: Z[s][t]
1010
- })).map(({ x: E, y: t, rotation: o }) => {
1011
- const n = $({
1012
- x: E,
1013
- y: t,
1014
- radius: B[s]
1037
+ if (t === "inpoint-sm" || t === "inpoint" || t === "inpoint-lg" || t === "outpoint-sm" || t === "outpoint" || t === "outpoint-lg" || t === "leaf-sm" || t === "leaf" || t === "leaf-lg") {
1038
+ const e = t === "leaf-sm" || t === "leaf" || t === "leaf-lg" ? Lt : Ot;
1039
+ return g.map((o, n) => ({
1040
+ ...o,
1041
+ rotation: K[t][n]
1042
+ })).map(({ x: o, y: n, rotation: i }) => {
1043
+ const h = e({
1044
+ x: o,
1045
+ y: n,
1046
+ radius: H[t]
1015
1047
  });
1016
- return /* @__PURE__ */ w(
1048
+ return /* @__PURE__ */ N(
1017
1049
  "path",
1018
1050
  {
1019
- fill: e,
1020
- d: n,
1051
+ fill: d,
1052
+ d: h,
1021
1053
  style: {
1022
- transform: `rotate(${o}deg)`,
1054
+ transform: `rotate(${i}deg)`,
1023
1055
  transformOrigin: "center",
1024
1056
  transformBox: "fill-box"
1025
1057
  }
1026
1058
  },
1027
- `finder-patterns-outer-${s}-${E}-${t}`
1059
+ `finder-patterns-outer-${t}-${o}-${n}`
1028
1060
  );
1029
1061
  });
1030
1062
  }
1031
1063
  return null;
1032
- }, Pt = (r, c) => r.slice().map((a, s) => s < c.y || s >= c.y + c.h ? a : a.map((e, f) => f < c.x || f >= c.x + c.w ? e : !1)), St = (r, c, a, s) => {
1033
- if (s == null)
1064
+ }, bt = ({ gradient: r }) => {
1065
+ var c, a;
1066
+ if (!r)
1067
+ return null;
1068
+ const s = V((r == null ? void 0 : r.rotation) || 0);
1069
+ return /* @__PURE__ */ N("defs", { children: r.type === "linear" ? /* @__PURE__ */ N("linearGradient", { id: S, gradientUnits: "userSpaceOnUse", ...s, children: (c = r.stops) == null ? void 0 : c.map((t, l) => /* @__PURE__ */ N("stop", { offset: t.offset, stopColor: t.color }, l)) }) : /* @__PURE__ */ N(
1070
+ "radialGradient",
1071
+ {
1072
+ id: S,
1073
+ gradientUnits: "userSpaceOnUse",
1074
+ cx: "50%",
1075
+ cy: "50%",
1076
+ r: "50%",
1077
+ children: (a = r.stops) == null ? void 0 : a.map((t, l) => /* @__PURE__ */ N("stop", { offset: t.offset, stopColor: t.color }, l))
1078
+ }
1079
+ ) });
1080
+ }, Bt = (r, s) => r.slice().map((c, a) => a < s.y || a >= s.y + s.h ? c : c.map((t, l) => l < s.x || l >= s.x + s.w ? t : !1)), zt = (r, s, c, a) => {
1081
+ if (a == null)
1034
1082
  return null;
1035
- const e = r.length + a * 2, f = Math.floor(c * st), l = e / c, $ = (s.width || f) * l, E = (s.height || f) * l, t = s.x == null ? r.length / 2 - $ / 2 : s.x * l, o = s.y == null ? r.length / 2 - E / 2 : s.y * l, n = s.opacity == null ? 1 : s.opacity;
1083
+ const t = r.length + c * 2, l = Math.floor(s * $t), d = t / s, u = (a.width || l) * d, g = (a.height || l) * d, e = a.x == null ? r.length / 2 - u / 2 : a.x * d, o = a.y == null ? r.length / 2 - g / 2 : a.y * d, n = a.opacity == null ? 1 : a.opacity;
1036
1084
  let i = null;
1037
- if (s.excavate) {
1038
- const p = Math.floor(t), d = Math.floor(o), R = Math.ceil($ + t - p), u = Math.ceil(E + o - d);
1039
- i = { x: p, y: d, w: R, h: u };
1085
+ if (a.excavate) {
1086
+ const $ = Math.floor(e), f = Math.floor(o), p = Math.ceil(u + e - $), M = Math.ceil(g + o - f);
1087
+ i = { x: $, y: f, w: p, h: M };
1040
1088
  }
1041
- const h = s.crossOrigin;
1042
- return { x: t, y: o, h: E, w: $, excavation: i, opacity: n, crossOrigin: h };
1043
- }, Tt = (r) => r != null ? Math.max(Math.floor(r), 0) : et, Ft = ({
1089
+ const h = a.crossOrigin;
1090
+ return { x: e, y: o, h: g, w: u, excavation: i, opacity: n, crossOrigin: h };
1091
+ }, xt = (r) => r != null ? Math.max(Math.floor(r), 0) : lt, Ht = ({
1044
1092
  value: r,
1045
- level: c,
1046
- minVersion: a,
1047
- marginSize: s,
1048
- imageSettings: e,
1049
- size: f,
1050
- boostLevel: l
1093
+ level: s,
1094
+ minVersion: c,
1095
+ marginSize: a,
1096
+ imageSettings: t,
1097
+ size: l,
1098
+ boostLevel: d
1051
1099
  }) => {
1052
- const $ = S(() => {
1053
- const h = (Array.isArray(r) ? r : [r]).reduce((p, d) => (p.push(...F.QrSegment.makeSegments(d)), p), []);
1054
- return F.QrCode.encodeSegments(
1100
+ const u = L(() => {
1101
+ const h = (Array.isArray(r) ? r : [r]).reduce(($, f) => ($.push(...v.QrSegment.makeSegments(f)), $), []);
1102
+ return v.QrCode.encodeSegments(
1055
1103
  h,
1056
- _[c],
1057
- a,
1104
+ rt[s],
1105
+ c,
1058
1106
  void 0,
1059
1107
  void 0,
1060
- l
1108
+ d
1061
1109
  );
1062
- }, [r, c, a, l]), { cells: E, margin: t, numCells: o, calculatedImageSettings: n } = S(() => {
1063
- const i = $.getModules(), h = Tt(s), p = i.length + h * 2, d = St(i, f, h, e);
1110
+ }, [r, s, c, d]), { cells: g, margin: e, numCells: o, calculatedImageSettings: n } = L(() => {
1111
+ const i = u.getModules(), h = xt(a), $ = i.length + h * 2, f = zt(i, l, h, t);
1064
1112
  return {
1065
1113
  cells: i,
1066
1114
  margin: h,
1067
- numCells: p,
1068
- calculatedImageSettings: d
1115
+ numCells: $,
1116
+ calculatedImageSettings: f
1069
1117
  };
1070
- }, [$, f, e, s]);
1118
+ }, [u, l, t, a]);
1071
1119
  return {
1072
- qrcode: $,
1073
- margin: t,
1074
- cells: E,
1120
+ qrcode: u,
1121
+ margin: e,
1122
+ cells: g,
1075
1123
  numCells: o,
1076
1124
  calculatedImageSettings: n
1077
1125
  };
1078
- }, Ot = (r) => {
1126
+ }, kt = ({ svgRef: r, fileSize: s, fileName: c }) => {
1127
+ if (!r.current) return;
1128
+ const a = r.current.cloneNode(!0);
1129
+ a.setAttribute("width", s.toString()), a.setAttribute("height", s.toString());
1130
+ const t = new XMLSerializer(), l = new Blob([t.serializeToString(a)], {
1131
+ type: "image/svg+xml"
1132
+ }), d = URL.createObjectURL(l), u = document.createElement("a");
1133
+ u.href = d, u.download = `${c}.svg`, document.body.appendChild(u), u.click(), document.body.removeChild(u), URL.revokeObjectURL(d);
1134
+ }, Gt = ({
1135
+ svgRef: r,
1136
+ fileSize: s,
1137
+ fileName: c,
1138
+ fileFormat: a,
1139
+ imageSettings: t,
1140
+ calculatedImageSettings: l,
1141
+ size: d,
1142
+ numCells: u,
1143
+ margin: g
1144
+ }) => {
1145
+ if (!r.current) return;
1146
+ const e = document.createElement("canvas"), o = e.getContext("2d");
1147
+ if (!o) return;
1148
+ e.width = s, e.height = s;
1149
+ const n = new XMLSerializer().serializeToString(r.current), i = new Blob([n], { type: "image/svg+xml;charset=utf-8" }), h = URL.createObjectURL(i), $ = new Image();
1150
+ $.crossOrigin = "anonymous", $.src = h, $.onload = () => {
1151
+ if (o.drawImage($, 0, 0, s, s), URL.revokeObjectURL(h), t != null && t.src && l) {
1152
+ const f = new Image();
1153
+ f.crossOrigin = "anonymous", f.src = t.src, f.onload = () => {
1154
+ const p = s / d, M = u / s, E = t.width * p, m = t.x ? (l.x + g) / M : (s - E) / 2, R = t.y ? (l.y + g) / M : (s - E) / 2;
1155
+ o.drawImage(f, m, R, E, E);
1156
+ const A = a === "png" ? "image/png" : "image/jpeg", w = document.createElement("a");
1157
+ w.href = e.toDataURL(A), w.download = `${c}.${a}`, document.body.appendChild(w), w.click(), document.body.removeChild(w);
1158
+ }, f.onerror = (p) => console.error("Error loading logo:", p);
1159
+ } else {
1160
+ const f = a === "png" ? "image/png" : "image/jpeg", p = document.createElement("a");
1161
+ p.href = e.toDataURL(f), p.download = `${c}.${a}`, document.body.appendChild(p), p.click(), document.body.removeChild(p);
1162
+ }
1163
+ }, $.onerror = (f) => console.error("Error loading QR code:", f);
1164
+ }, Yt = (r) => {
1079
1165
  const {
1080
- ref: c,
1081
- value: a,
1082
- size: s = V,
1083
- level: e = W,
1084
- bgColor: f = J,
1085
- minVersion: l = tt,
1086
- boostLevel: $,
1087
- marginSize: E,
1088
- finderPatternOuterSettings: t,
1089
- finderPatternInnerSettings: o,
1090
- dataModulesSettings: n,
1091
- imageSettings: i,
1092
- svgProps: h
1093
- } = r, { margin: p, cells: d, numCells: R, calculatedImageSettings: u } = Ft({
1094
- value: a,
1095
- level: e,
1096
- minVersion: l,
1097
- boostLevel: $,
1098
- marginSize: E,
1099
- imageSettings: i,
1100
- size: s
1166
+ ref: s,
1167
+ value: c,
1168
+ size: a = st,
1169
+ level: t = it,
1170
+ background: l,
1171
+ gradient: d,
1172
+ minVersion: u = ct,
1173
+ boostLevel: g,
1174
+ marginSize: e,
1175
+ finderPatternOuterSettings: o,
1176
+ finderPatternInnerSettings: n,
1177
+ dataModulesSettings: i,
1178
+ imageSettings: h,
1179
+ svgProps: $
1180
+ } = r, f = ot(null), { margin: p, cells: M, numCells: E, calculatedImageSettings: m } = Ht({
1181
+ value: c,
1182
+ level: t,
1183
+ minVersion: u,
1184
+ boostLevel: g,
1185
+ marginSize: e,
1186
+ imageSettings: h,
1187
+ size: a
1101
1188
  });
1102
- let M = d, A = null;
1103
- return i != null && u != null && (u.excavation != null && (M = Pt(d, u.excavation)), A = /* @__PURE__ */ w(
1189
+ nt(s, () => ({
1190
+ svg: f.current,
1191
+ download: ({
1192
+ name: C = ft,
1193
+ format: P = "svg",
1194
+ size: x = 500
1195
+ }) => {
1196
+ f.current && (P === "svg" ? kt({ svgRef: f, fileSize: x, fileName: C }) : Gt({
1197
+ svgRef: f,
1198
+ fileSize: x,
1199
+ fileName: C,
1200
+ fileFormat: P,
1201
+ imageSettings: h,
1202
+ calculatedImageSettings: m,
1203
+ size: a,
1204
+ numCells: E,
1205
+ margin: p
1206
+ }));
1207
+ }
1208
+ }));
1209
+ let R = M, A = null;
1210
+ h != null && m != null && (m.excavation != null && (R = Bt(M, m.excavation)), A = /* @__PURE__ */ N(
1104
1211
  "image",
1105
1212
  {
1106
- href: i.src,
1107
- height: u.h,
1108
- width: u.w,
1109
- x: u.x + p,
1110
- y: u.y + p,
1213
+ href: h.src,
1214
+ height: m.h,
1215
+ width: m.w,
1216
+ x: m.x + p,
1217
+ y: m.y + p,
1111
1218
  preserveAspectRatio: "none",
1112
- opacity: u.opacity,
1113
- crossOrigin: u.crossOrigin
1219
+ opacity: m.opacity,
1220
+ crossOrigin: m.crossOrigin
1114
1221
  }
1115
- )), /* @__PURE__ */ j(
1222
+ ));
1223
+ const w = {
1224
+ modules: R,
1225
+ margin: p,
1226
+ gradient: d
1227
+ };
1228
+ return /* @__PURE__ */ Q(
1116
1229
  "svg",
1117
1230
  {
1118
- height: s,
1119
- width: s,
1120
- viewBox: `0 0 ${R} ${R}`,
1121
- ref: c,
1231
+ height: a,
1232
+ width: a,
1233
+ viewBox: `0 0 ${E} ${E}`,
1234
+ ref: f,
1122
1235
  role: "img",
1123
- "aria-label": (h == null ? void 0 : h["aria-label"]) || "QR Code",
1124
- ...h,
1236
+ "aria-label": ($ == null ? void 0 : $["aria-label"]) || "QR Code",
1237
+ ...$,
1125
1238
  children: [
1126
- /* @__PURE__ */ w("path", { fill: f, d: `M0,0 h${R}v${R}H0z` }),
1127
- /* @__PURE__ */ w(
1128
- It,
1129
- {
1130
- modules: M,
1131
- margin: p,
1132
- settings: t
1133
- }
1134
- ),
1135
- /* @__PURE__ */ w(
1136
- wt,
1137
- {
1138
- modules: M,
1139
- margin: p,
1140
- settings: o
1141
- }
1142
- ),
1143
- /* @__PURE__ */ w(Ct, { modules: M, margin: p, settings: n }),
1239
+ /* @__PURE__ */ N(bt, { gradient: d }),
1240
+ /* @__PURE__ */ N(Et, { background: l, numCells: E }),
1241
+ /* @__PURE__ */ N(Dt, { settings: o, ...w }),
1242
+ /* @__PURE__ */ N(Ut, { settings: n, ...w }),
1243
+ /* @__PURE__ */ N(Ft, { settings: i, ...w }),
1144
1244
  A
1145
1245
  ]
1146
1246
  }
1147
1247
  );
1148
1248
  };
1149
- Ot.displayName = "ReactQRCode";
1249
+ Yt.displayName = "ReactQRCode";
1150
1250
  export {
1151
- Ot as ReactQRCode
1251
+ Yt as ReactQRCode
1152
1252
  };