@lglab/react-qr-code 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +501 -462
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsx as C, jsxs as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsx as C, jsxs as K, Fragment as rt } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as T, useCallback as st, useRef as it, useImperativeHandle as at } 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
|
|
8
|
+
var L;
|
|
9
9
|
((r) => {
|
|
10
10
|
const d = class d {
|
|
11
11
|
/*-- Constructor (low level) and fields --*/
|
|
@@ -13,12 +13,12 @@ var O;
|
|
|
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(
|
|
17
|
-
if (this.version =
|
|
16
|
+
constructor(t, o, n, a) {
|
|
17
|
+
if (this.version = t, this.errorCorrectionLevel = o, this.modules = [], this.isFunction = [], t < d.MIN_VERSION || t > d.MAX_VERSION)
|
|
18
18
|
throw new RangeError("Version value out of range");
|
|
19
|
-
if (
|
|
19
|
+
if (a < -1 || a > 7)
|
|
20
20
|
throw new RangeError("Mask value out of range");
|
|
21
|
-
this.size =
|
|
21
|
+
this.size = t * 4 + 17;
|
|
22
22
|
let h = [];
|
|
23
23
|
for (let f = 0; f < this.size; f++)
|
|
24
24
|
h.push(!1);
|
|
@@ -26,15 +26,15 @@ var O;
|
|
|
26
26
|
this.modules.push(h.slice()), this.isFunction.push(h.slice());
|
|
27
27
|
this.drawFunctionPatterns();
|
|
28
28
|
const $ = this.addEccAndInterleave(n);
|
|
29
|
-
if (this.drawCodewords($),
|
|
29
|
+
if (this.drawCodewords($), a == -1) {
|
|
30
30
|
let f = 1e9;
|
|
31
31
|
for (let p = 0; p < 8; p++) {
|
|
32
32
|
this.applyMask(p), this.drawFormatBits(p);
|
|
33
33
|
const M = this.getPenaltyScore();
|
|
34
|
-
M < f && (
|
|
34
|
+
M < f && (a = p, f = M), this.applyMask(p);
|
|
35
35
|
}
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
e(0 <= a && a <= 7), this.mask = a, this.applyMask(a), this.drawFormatBits(a), 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,16 +42,16 @@ var O;
|
|
|
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(
|
|
46
|
-
const n = r.QrSegment.makeSegments(
|
|
45
|
+
static encodeText(t, o) {
|
|
46
|
+
const n = r.QrSegment.makeSegments(t);
|
|
47
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(
|
|
54
|
-
const n = r.QrSegment.makeBytes(
|
|
53
|
+
static encodeBinary(t, o) {
|
|
54
|
+
const n = r.QrSegment.makeBytes(t);
|
|
55
55
|
return d.encodeSegments([n], o);
|
|
56
56
|
}
|
|
57
57
|
/*-- Static factory functions (mid level) --*/
|
|
@@ -64,32 +64,32 @@ var O;
|
|
|
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(
|
|
68
|
-
if (!(d.MIN_VERSION <= n && n <=
|
|
67
|
+
static encodeSegments(t, o, n = 1, a = 40, h = -1, $ = !0) {
|
|
68
|
+
if (!(d.MIN_VERSION <= n && n <= a && a <= d.MAX_VERSION) || h < -1 || h > 7)
|
|
69
69
|
throw new RangeError("Invalid value");
|
|
70
70
|
let f, p;
|
|
71
71
|
for (f = n; ; f++) {
|
|
72
|
-
const R = d.getNumDataCodewords(f, o) * 8, w =
|
|
72
|
+
const R = d.getNumDataCodewords(f, o) * 8, w = l.getTotalBits(t, f);
|
|
73
73
|
if (w <= R) {
|
|
74
74
|
p = w;
|
|
75
75
|
break;
|
|
76
76
|
}
|
|
77
|
-
if (f >=
|
|
77
|
+
if (f >= a)
|
|
78
78
|
throw new RangeError("Data too long");
|
|
79
79
|
}
|
|
80
80
|
for (const R of [d.Ecc.MEDIUM, d.Ecc.QUARTILE, d.Ecc.HIGH])
|
|
81
81
|
$ && p <= d.getNumDataCodewords(f, R) * 8 && (o = R);
|
|
82
82
|
let M = [];
|
|
83
|
-
for (const R of
|
|
84
|
-
|
|
83
|
+
for (const R of t) {
|
|
84
|
+
c(R.mode.modeBits, 4, M), c(R.numChars, R.mode.numCharCountBits(f), M);
|
|
85
85
|
for (const w of R.getData())
|
|
86
86
|
M.push(w);
|
|
87
87
|
}
|
|
88
|
-
|
|
88
|
+
e(M.length == p);
|
|
89
89
|
const E = d.getNumDataCodewords(f, o) * 8;
|
|
90
|
-
|
|
90
|
+
e(M.length <= E), c(0, Math.min(4, E - M.length), M), c(0, (8 - M.length % 8) % 8, M), e(M.length % 8 == 0);
|
|
91
91
|
for (let R = 236; M.length < E; R ^= 253)
|
|
92
|
-
|
|
92
|
+
c(R, 8, M);
|
|
93
93
|
let m = [];
|
|
94
94
|
for (; m.length * 8 < M.length; )
|
|
95
95
|
m.push(0);
|
|
@@ -99,8 +99,8 @@ var O;
|
|
|
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(
|
|
103
|
-
return 0 <=
|
|
102
|
+
getModule(t, o) {
|
|
103
|
+
return 0 <= t && t < this.size && 0 <= o && o < this.size && this.modules[o][t];
|
|
104
104
|
}
|
|
105
105
|
// Modified to expose modules for easy access
|
|
106
106
|
getModules() {
|
|
@@ -112,30 +112,30 @@ var O;
|
|
|
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
|
|
115
|
+
const t = this.getAlignmentPatternPositions(), o = t.length;
|
|
116
116
|
for (let n = 0; n < o; n++)
|
|
117
|
-
for (let
|
|
118
|
-
n == 0 &&
|
|
117
|
+
for (let a = 0; a < o; a++)
|
|
118
|
+
n == 0 && a == 0 || n == 0 && a == o - 1 || n == o - 1 && a == 0 || this.drawAlignmentPattern(t[n], t[a]);
|
|
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(
|
|
124
|
-
const o = this.errorCorrectionLevel.formatBits << 3 |
|
|
123
|
+
drawFormatBits(t) {
|
|
124
|
+
const o = this.errorCorrectionLevel.formatBits << 3 | t;
|
|
125
125
|
let n = o;
|
|
126
126
|
for (let h = 0; h < 10; h++)
|
|
127
127
|
n = n << 1 ^ (n >>> 9) * 1335;
|
|
128
|
-
const
|
|
129
|
-
|
|
128
|
+
const a = (o << 10 | n) ^ 21522;
|
|
129
|
+
e(a >>> 15 == 0);
|
|
130
130
|
for (let h = 0; h <= 5; h++)
|
|
131
|
-
this.setFunctionModule(8, h, a
|
|
132
|
-
this.setFunctionModule(8, 7, a
|
|
131
|
+
this.setFunctionModule(8, h, s(a, h));
|
|
132
|
+
this.setFunctionModule(8, 7, s(a, 6)), this.setFunctionModule(8, 8, s(a, 7)), this.setFunctionModule(7, 8, s(a, 8));
|
|
133
133
|
for (let h = 9; h < 15; h++)
|
|
134
|
-
this.setFunctionModule(14 - h, 8, a
|
|
134
|
+
this.setFunctionModule(14 - h, 8, s(a, h));
|
|
135
135
|
for (let h = 0; h < 8; h++)
|
|
136
|
-
this.setFunctionModule(this.size - 1 - h, 8, a
|
|
136
|
+
this.setFunctionModule(this.size - 1 - h, 8, s(a, h));
|
|
137
137
|
for (let h = 8; h < 15; h++)
|
|
138
|
-
this.setFunctionModule(8, this.size - 15 + h, a
|
|
138
|
+
this.setFunctionModule(8, this.size - 15 + h, s(a, 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,49 +143,49 @@ var O;
|
|
|
143
143
|
drawVersion() {
|
|
144
144
|
if (this.version < 7)
|
|
145
145
|
return;
|
|
146
|
-
let
|
|
146
|
+
let t = this.version;
|
|
147
147
|
for (let n = 0; n < 12; n++)
|
|
148
|
-
|
|
149
|
-
const o = this.version << 12 |
|
|
150
|
-
|
|
148
|
+
t = t << 1 ^ (t >>> 11) * 7973;
|
|
149
|
+
const o = this.version << 12 | t;
|
|
150
|
+
e(o >>> 18 == 0);
|
|
151
151
|
for (let n = 0; n < 18; n++) {
|
|
152
|
-
const
|
|
153
|
-
this.setFunctionModule(h, $,
|
|
152
|
+
const a = s(o, n), h = this.size - 11 + n % 3, $ = Math.floor(n / 3);
|
|
153
|
+
this.setFunctionModule(h, $, a), this.setFunctionModule($, h, a);
|
|
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(
|
|
158
|
+
drawFinderPattern(t, o) {
|
|
159
159
|
for (let n = -4; n <= 4; n++)
|
|
160
|
-
for (let
|
|
161
|
-
const h = Math.max(Math.abs(
|
|
160
|
+
for (let a = -4; a <= 4; a++) {
|
|
161
|
+
const h = Math.max(Math.abs(a), Math.abs(n)), $ = t + a, f = o + n;
|
|
162
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(
|
|
167
|
+
drawAlignmentPattern(t, o) {
|
|
168
168
|
for (let n = -2; n <= 2; n++)
|
|
169
|
-
for (let
|
|
170
|
-
this.setFunctionModule(
|
|
169
|
+
for (let a = -2; a <= 2; a++)
|
|
170
|
+
this.setFunctionModule(t + a, o + n, Math.max(Math.abs(a), 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(
|
|
175
|
-
this.modules[o][
|
|
174
|
+
setFunctionModule(t, o, n) {
|
|
175
|
+
this.modules[o][t] = n, this.isFunction[o][t] = !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(
|
|
180
|
+
addEccAndInterleave(t) {
|
|
181
181
|
const o = this.version, n = this.errorCorrectionLevel;
|
|
182
|
-
if (
|
|
182
|
+
if (t.length != d.getNumDataCodewords(o, n))
|
|
183
183
|
throw new RangeError("Invalid argument");
|
|
184
|
-
const
|
|
184
|
+
const a = d.NUM_ERROR_CORRECTION_BLOCKS[n.ordinal][o], h = d.ECC_CODEWORDS_PER_BLOCK[n.ordinal][o], $ = Math.floor(d.getNumRawDataModules(o) / 8), f = a - $ % a, p = Math.floor($ / a);
|
|
185
185
|
let M = [];
|
|
186
186
|
const E = d.reedSolomonComputeDivisor(h);
|
|
187
|
-
for (let R = 0, w = 0; R <
|
|
188
|
-
let A =
|
|
187
|
+
for (let R = 0, w = 0; R < a; R++) {
|
|
188
|
+
let A = t.slice(w, w + p - h + (R < f ? 0 : 1));
|
|
189
189
|
w += A.length;
|
|
190
190
|
const N = d.reedSolomonComputeRemainder(A, E);
|
|
191
191
|
R < f && A.push(0), M.push(A.concat(N));
|
|
@@ -195,92 +195,92 @@ var O;
|
|
|
195
195
|
M.forEach((w, A) => {
|
|
196
196
|
(R != p - h || A >= f) && m.push(w[R]);
|
|
197
197
|
});
|
|
198
|
-
return
|
|
198
|
+
return e(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(
|
|
203
|
-
if (
|
|
202
|
+
drawCodewords(t) {
|
|
203
|
+
if (t.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
|
-
for (let
|
|
208
|
+
for (let a = 0; a < this.size; a++)
|
|
209
209
|
for (let h = 0; h < 2; h++) {
|
|
210
|
-
const $ = n - h, p = (n + 1 & 2) == 0 ? this.size - 1 -
|
|
211
|
-
!this.isFunction[p][$] && o <
|
|
210
|
+
const $ = n - h, p = (n + 1 & 2) == 0 ? this.size - 1 - a : a;
|
|
211
|
+
!this.isFunction[p][$] && o < t.length * 8 && (this.modules[p][$] = s(t[o >>> 3], 7 - (o & 7)), o++);
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
|
|
214
|
+
e(o == t.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(
|
|
222
|
-
if (
|
|
221
|
+
applyMask(t) {
|
|
222
|
+
if (t < 0 || t > 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
|
-
let
|
|
227
|
-
switch (
|
|
226
|
+
let a;
|
|
227
|
+
switch (t) {
|
|
228
228
|
case 0:
|
|
229
|
-
|
|
229
|
+
a = (n + o) % 2 == 0;
|
|
230
230
|
break;
|
|
231
231
|
case 1:
|
|
232
|
-
|
|
232
|
+
a = o % 2 == 0;
|
|
233
233
|
break;
|
|
234
234
|
case 2:
|
|
235
|
-
|
|
235
|
+
a = n % 3 == 0;
|
|
236
236
|
break;
|
|
237
237
|
case 3:
|
|
238
|
-
|
|
238
|
+
a = (n + o) % 3 == 0;
|
|
239
239
|
break;
|
|
240
240
|
case 4:
|
|
241
|
-
|
|
241
|
+
a = (Math.floor(n / 3) + Math.floor(o / 2)) % 2 == 0;
|
|
242
242
|
break;
|
|
243
243
|
case 5:
|
|
244
|
-
|
|
244
|
+
a = n * o % 2 + n * o % 3 == 0;
|
|
245
245
|
break;
|
|
246
246
|
case 6:
|
|
247
|
-
|
|
247
|
+
a = (n * o % 2 + n * o % 3) % 2 == 0;
|
|
248
248
|
break;
|
|
249
249
|
case 7:
|
|
250
|
-
|
|
250
|
+
a = ((n + o) % 2 + n * o % 3) % 2 == 0;
|
|
251
251
|
break;
|
|
252
252
|
default:
|
|
253
253
|
throw new Error("Unreachable");
|
|
254
254
|
}
|
|
255
|
-
!this.isFunction[o][n] &&
|
|
255
|
+
!this.isFunction[o][n] && a && (this.modules[o][n] = !this.modules[o][n]);
|
|
256
256
|
}
|
|
257
257
|
}
|
|
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
|
|
261
|
+
let t = 0;
|
|
262
262
|
for (let h = 0; h < this.size; h++) {
|
|
263
263
|
let $ = !1, f = 0, p = [0, 0, 0, 0, 0, 0, 0];
|
|
264
264
|
for (let M = 0; M < this.size; M++)
|
|
265
|
-
this.modules[h][M] == $ ? (f++, f == 5 ?
|
|
266
|
-
|
|
265
|
+
this.modules[h][M] == $ ? (f++, f == 5 ? t += d.PENALTY_N1 : f > 5 && t++) : (this.finderPenaltyAddHistory(f, p), $ || (t += this.finderPenaltyCountPatterns(p) * d.PENALTY_N3), $ = this.modules[h][M], f = 1);
|
|
266
|
+
t += this.finderPenaltyTerminateAndCount($, f, p) * d.PENALTY_N3;
|
|
267
267
|
}
|
|
268
268
|
for (let h = 0; h < this.size; h++) {
|
|
269
269
|
let $ = !1, f = 0, p = [0, 0, 0, 0, 0, 0, 0];
|
|
270
270
|
for (let M = 0; M < this.size; M++)
|
|
271
|
-
this.modules[M][h] == $ ? (f++, f == 5 ?
|
|
272
|
-
|
|
271
|
+
this.modules[M][h] == $ ? (f++, f == 5 ? t += d.PENALTY_N1 : f > 5 && t++) : (this.finderPenaltyAddHistory(f, p), $ || (t += this.finderPenaltyCountPatterns(p) * d.PENALTY_N3), $ = this.modules[M][h], f = 1);
|
|
272
|
+
t += this.finderPenaltyTerminateAndCount($, f, p) * d.PENALTY_N3;
|
|
273
273
|
}
|
|
274
274
|
for (let h = 0; h < this.size - 1; h++)
|
|
275
275
|
for (let $ = 0; $ < this.size - 1; $++) {
|
|
276
276
|
const f = this.modules[h][$];
|
|
277
|
-
f == this.modules[h][$ + 1] && f == this.modules[h + 1][$] && f == this.modules[h + 1][$ + 1] && (
|
|
277
|
+
f == this.modules[h][$ + 1] && f == this.modules[h + 1][$] && f == this.modules[h + 1][$ + 1] && (t += d.PENALTY_N2);
|
|
278
278
|
}
|
|
279
279
|
let o = 0;
|
|
280
280
|
for (const h of this.modules)
|
|
281
281
|
o = h.reduce(($, f) => $ + (f ? 1 : 0), o);
|
|
282
|
-
const n = this.size * this.size,
|
|
283
|
-
return
|
|
282
|
+
const n = this.size * this.size, a = Math.ceil(Math.abs(o * 20 - n * 10) / n) - 1;
|
|
283
|
+
return e(0 <= a && a <= 9), t += a * d.PENALTY_N4, e(0 <= t && t <= 2568888), t;
|
|
284
284
|
}
|
|
285
285
|
/*-- Private helper functions --*/
|
|
286
286
|
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
@@ -290,43 +290,43 @@ var O;
|
|
|
290
290
|
if (this.version == 1)
|
|
291
291
|
return [];
|
|
292
292
|
{
|
|
293
|
-
const
|
|
293
|
+
const t = Math.floor(this.version / 7) + 2, o = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (t * 2 - 2)) * 2;
|
|
294
294
|
let n = [6];
|
|
295
|
-
for (let
|
|
296
|
-
n.splice(1, 0,
|
|
295
|
+
for (let a = this.size - 7; n.length < t; a -= o)
|
|
296
|
+
n.splice(1, 0, a);
|
|
297
297
|
return n;
|
|
298
298
|
}
|
|
299
299
|
}
|
|
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(
|
|
304
|
-
if (
|
|
303
|
+
static getNumRawDataModules(t) {
|
|
304
|
+
if (t < d.MIN_VERSION || t > d.MAX_VERSION)
|
|
305
305
|
throw new RangeError("Version number out of range");
|
|
306
|
-
let o = (16 *
|
|
307
|
-
if (
|
|
308
|
-
const n = Math.floor(
|
|
309
|
-
o -= (25 * n - 10) * n - 55,
|
|
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);
|
|
310
310
|
}
|
|
311
|
-
return
|
|
311
|
+
return e(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(
|
|
317
|
-
return Math.floor(d.getNumRawDataModules(
|
|
316
|
+
static getNumDataCodewords(t, o) {
|
|
317
|
+
return Math.floor(d.getNumRawDataModules(t) / 8) - d.ECC_CODEWORDS_PER_BLOCK[o.ordinal][t] * d.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][t];
|
|
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(
|
|
322
|
-
if (
|
|
321
|
+
static reedSolomonComputeDivisor(t) {
|
|
322
|
+
if (t < 1 || t > 255)
|
|
323
323
|
throw new RangeError("Degree out of range");
|
|
324
324
|
let o = [];
|
|
325
|
-
for (let
|
|
325
|
+
for (let a = 0; a < t - 1; a++)
|
|
326
326
|
o.push(0);
|
|
327
327
|
o.push(1);
|
|
328
328
|
let n = 1;
|
|
329
|
-
for (let
|
|
329
|
+
for (let a = 0; a < t; a++) {
|
|
330
330
|
for (let h = 0; h < o.length; h++)
|
|
331
331
|
o[h] = d.reedSolomonMultiply(o[h], n), h + 1 < o.length && (o[h] ^= o[h + 1]);
|
|
332
332
|
n = d.reedSolomonMultiply(n, 2);
|
|
@@ -334,39 +334,39 @@ var O;
|
|
|
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(
|
|
338
|
-
let n = o.map((
|
|
339
|
-
for (const
|
|
340
|
-
const h =
|
|
337
|
+
static reedSolomonComputeRemainder(t, o) {
|
|
338
|
+
let n = o.map((a) => 0);
|
|
339
|
+
for (const a of t) {
|
|
340
|
+
const h = a ^ n.shift();
|
|
341
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(
|
|
348
|
-
if (
|
|
347
|
+
static reedSolomonMultiply(t, o) {
|
|
348
|
+
if (t >>> 8 || o >>> 8)
|
|
349
349
|
throw new RangeError("Byte out of range");
|
|
350
350
|
let n = 0;
|
|
351
|
-
for (let
|
|
352
|
-
n = n << 1 ^ (n >>> 7) * 285, n ^= (o >>>
|
|
353
|
-
return
|
|
351
|
+
for (let a = 7; a >= 0; a--)
|
|
352
|
+
n = n << 1 ^ (n >>> 7) * 285, n ^= (o >>> a & 1) * t;
|
|
353
|
+
return e(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(
|
|
358
|
-
const o =
|
|
359
|
-
|
|
360
|
-
const n = o > 0 &&
|
|
361
|
-
return (n &&
|
|
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);
|
|
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(
|
|
365
|
-
return
|
|
364
|
+
finderPenaltyTerminateAndCount(t, o, n) {
|
|
365
|
+
return t && (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(
|
|
369
|
-
o[0] == 0 && (
|
|
368
|
+
finderPenaltyAddHistory(t, o) {
|
|
369
|
+
o[0] == 0 && (t += this.size), o.pop(), o.unshift(t);
|
|
370
370
|
}
|
|
371
371
|
};
|
|
372
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 = [
|
|
@@ -392,18 +392,18 @@ var O;
|
|
|
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
|
|
396
|
-
r.QrCode =
|
|
397
|
-
function
|
|
398
|
-
if (
|
|
395
|
+
let i = d;
|
|
396
|
+
r.QrCode = i;
|
|
397
|
+
function c(g, t, o) {
|
|
398
|
+
if (t < 0 || t > 31 || g >>> t)
|
|
399
399
|
throw new RangeError("Value out of range");
|
|
400
|
-
for (let n =
|
|
400
|
+
for (let n = t - 1; n >= 0; n--)
|
|
401
401
|
o.push(g >>> n & 1);
|
|
402
402
|
}
|
|
403
|
-
function
|
|
404
|
-
return (g >>>
|
|
403
|
+
function s(g, t) {
|
|
404
|
+
return (g >>> t & 1) != 0;
|
|
405
405
|
}
|
|
406
|
-
function
|
|
406
|
+
function e(g) {
|
|
407
407
|
if (!g)
|
|
408
408
|
throw new Error("Assertion error");
|
|
409
409
|
}
|
|
@@ -412,8 +412,8 @@ var O;
|
|
|
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(
|
|
416
|
-
if (this.mode =
|
|
415
|
+
constructor(t, o, n) {
|
|
416
|
+
if (this.mode = t, 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 O;
|
|
|
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(
|
|
424
|
+
static makeBytes(t) {
|
|
425
425
|
let o = [];
|
|
426
|
-
for (const n of
|
|
427
|
-
|
|
428
|
-
return new u(u.Mode.BYTE,
|
|
426
|
+
for (const n of t)
|
|
427
|
+
c(n, 8, o);
|
|
428
|
+
return new u(u.Mode.BYTE, t.length, o);
|
|
429
429
|
}
|
|
430
430
|
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
431
|
-
static makeNumeric(
|
|
432
|
-
if (!u.isNumeric(
|
|
431
|
+
static makeNumeric(t) {
|
|
432
|
+
if (!u.isNumeric(t))
|
|
433
433
|
throw new RangeError("String contains non-numeric characters");
|
|
434
434
|
let o = [];
|
|
435
|
-
for (let n = 0; n <
|
|
436
|
-
const
|
|
437
|
-
|
|
435
|
+
for (let n = 0; n < t.length; ) {
|
|
436
|
+
const a = Math.min(t.length - n, 3);
|
|
437
|
+
c(parseInt(t.substring(n, n + a), 10), a * 3 + 1, o), n += a;
|
|
438
438
|
}
|
|
439
|
-
return new u(u.Mode.NUMERIC,
|
|
439
|
+
return new u(u.Mode.NUMERIC, t.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(
|
|
445
|
-
if (!u.isAlphanumeric(
|
|
444
|
+
static makeAlphanumeric(t) {
|
|
445
|
+
if (!u.isAlphanumeric(t))
|
|
446
446
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
447
447
|
let o = [], n;
|
|
448
|
-
for (n = 0; n + 2 <=
|
|
449
|
-
let
|
|
450
|
-
|
|
448
|
+
for (n = 0; n + 2 <= t.length; n += 2) {
|
|
449
|
+
let a = u.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)) * 45;
|
|
450
|
+
a += u.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n + 1)), c(a, 11, o);
|
|
451
451
|
}
|
|
452
|
-
return n <
|
|
452
|
+
return n < t.length && c(u.ALPHANUMERIC_CHARSET.indexOf(t.charAt(n)), 6, o), new u(u.Mode.ALPHANUMERIC, t.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(
|
|
457
|
-
return
|
|
456
|
+
static makeSegments(t) {
|
|
457
|
+
return t == "" ? [] : u.isNumeric(t) ? [u.makeNumeric(t)] : u.isAlphanumeric(t) ? [u.makeAlphanumeric(t)] : [u.makeBytes(u.toUtf8ByteArray(t))];
|
|
458
458
|
}
|
|
459
459
|
// Returns a segment representing an Extended Channel Interpretation
|
|
460
460
|
// (ECI) designator with the given assignment value.
|
|
461
|
-
static makeEci(
|
|
461
|
+
static makeEci(t) {
|
|
462
462
|
let o = [];
|
|
463
|
-
if (
|
|
463
|
+
if (t < 0)
|
|
464
464
|
throw new RangeError("ECI assignment value out of range");
|
|
465
|
-
if (
|
|
466
|
-
|
|
467
|
-
else if (
|
|
468
|
-
|
|
469
|
-
else if (
|
|
470
|
-
|
|
465
|
+
if (t < 128)
|
|
466
|
+
c(t, 8, o);
|
|
467
|
+
else if (t < 16384)
|
|
468
|
+
c(2, 2, o), c(t, 14, o);
|
|
469
|
+
else if (t < 1e6)
|
|
470
|
+
c(6, 3, o), c(t, 21, o);
|
|
471
471
|
else
|
|
472
472
|
throw new RangeError("ECI assignment value out of range");
|
|
473
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(
|
|
478
|
-
return u.NUMERIC_REGEX.test(
|
|
477
|
+
static isNumeric(t) {
|
|
478
|
+
return u.NUMERIC_REGEX.test(t);
|
|
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(
|
|
484
|
-
return u.ALPHANUMERIC_REGEX.test(
|
|
483
|
+
static isAlphanumeric(t) {
|
|
484
|
+
return u.ALPHANUMERIC_REGEX.test(t);
|
|
485
485
|
}
|
|
486
486
|
/*-- Methods --*/
|
|
487
487
|
// Returns a new copy of the data bits of this segment.
|
|
@@ -490,68 +490,68 @@ var O;
|
|
|
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(
|
|
493
|
+
static getTotalBits(t, o) {
|
|
494
494
|
let n = 0;
|
|
495
|
-
for (const
|
|
496
|
-
const h =
|
|
497
|
-
if (
|
|
495
|
+
for (const a of t) {
|
|
496
|
+
const h = a.mode.numCharCountBits(o);
|
|
497
|
+
if (a.numChars >= 1 << h)
|
|
498
498
|
return 1 / 0;
|
|
499
|
-
n += 4 + h +
|
|
499
|
+
n += 4 + h + a.bitData.length;
|
|
500
500
|
}
|
|
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(
|
|
505
|
-
|
|
504
|
+
static toUtf8ByteArray(t) {
|
|
505
|
+
t = encodeURI(t);
|
|
506
506
|
let o = [];
|
|
507
|
-
for (let n = 0; n <
|
|
508
|
-
|
|
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);
|
|
509
509
|
return o;
|
|
510
510
|
}
|
|
511
511
|
};
|
|
512
512
|
u.NUMERIC_REGEX = /^[0-9]*$/, u.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, u.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
513
|
-
let
|
|
514
|
-
r.QrSegment =
|
|
515
|
-
})(
|
|
513
|
+
let l = u;
|
|
514
|
+
r.QrSegment = l;
|
|
515
|
+
})(L || (L = {}));
|
|
516
516
|
((r) => {
|
|
517
|
-
((
|
|
518
|
-
const
|
|
517
|
+
((i) => {
|
|
518
|
+
const s = class s {
|
|
519
519
|
// The QR Code can tolerate about 30% erroneous codewords
|
|
520
520
|
/*-- Constructor and fields --*/
|
|
521
|
-
constructor(
|
|
522
|
-
this.ordinal =
|
|
521
|
+
constructor(l, d) {
|
|
522
|
+
this.ordinal = l, this.formatBits = d;
|
|
523
523
|
}
|
|
524
524
|
};
|
|
525
|
-
|
|
526
|
-
let
|
|
527
|
-
|
|
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 c = s;
|
|
527
|
+
i.Ecc = c;
|
|
528
528
|
})(r.QrCode || (r.QrCode = {}));
|
|
529
|
-
})(
|
|
529
|
+
})(L || (L = {}));
|
|
530
530
|
((r) => {
|
|
531
|
-
((
|
|
532
|
-
const
|
|
531
|
+
((i) => {
|
|
532
|
+
const s = class s {
|
|
533
533
|
/*-- Constructor and fields --*/
|
|
534
|
-
constructor(
|
|
535
|
-
this.modeBits =
|
|
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(
|
|
541
|
-
return this.numBitsCharCount[Math.floor((
|
|
540
|
+
numCharCountBits(l) {
|
|
541
|
+
return this.numBitsCharCount[Math.floor((l + 7) / 17)];
|
|
542
542
|
}
|
|
543
543
|
};
|
|
544
|
-
|
|
545
|
-
let
|
|
546
|
-
|
|
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 c = s;
|
|
546
|
+
i.Mode = c;
|
|
547
547
|
})(r.QrSegment || (r.QrSegment = {}));
|
|
548
|
-
})(
|
|
549
|
-
const
|
|
550
|
-
L:
|
|
551
|
-
M:
|
|
552
|
-
Q:
|
|
553
|
-
H:
|
|
554
|
-
}, lt = 128,
|
|
548
|
+
})(L || (L = {}));
|
|
549
|
+
const S = L, ct = {
|
|
550
|
+
L: S.QrCode.Ecc.LOW,
|
|
551
|
+
M: S.QrCode.Ecc.MEDIUM,
|
|
552
|
+
Q: S.QrCode.Ecc.QUARTILE,
|
|
553
|
+
H: S.QrCode.Ecc.HIGH
|
|
554
|
+
}, lt = 128, ht = "M", ut = 1, dt = 4, W = 5, H = "#000000", ft = "square", $t = "square", pt = "square", mt = "react-qr-code", U = "react-qr-code-gradient", F = "react-qr-code-bg-gradient", Et = 0.1, I = 7, v = 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],
|
|
@@ -569,7 +569,7 @@ const y = O, at = {
|
|
|
569
569
|
"leaf-sm": [0, 90, -90],
|
|
570
570
|
leaf: [0, 90, -90],
|
|
571
571
|
"leaf-lg": [0, 90, -90]
|
|
572
|
-
},
|
|
572
|
+
}, Y = {
|
|
573
573
|
"rounded-sm": 3,
|
|
574
574
|
rounded: 4,
|
|
575
575
|
"rounded-lg": 5,
|
|
@@ -582,7 +582,7 @@ const y = O, at = {
|
|
|
582
582
|
"outpoint-sm": 3,
|
|
583
583
|
outpoint: 4,
|
|
584
584
|
"outpoint-lg": 5
|
|
585
|
-
},
|
|
585
|
+
}, G = {
|
|
586
586
|
square: 0,
|
|
587
587
|
diamond: 0,
|
|
588
588
|
circle: 3,
|
|
@@ -606,28 +606,60 @@ const y = O, at = {
|
|
|
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
|
-
],
|
|
610
|
-
function
|
|
611
|
-
return r.toFixed(7).replace(
|
|
609
|
+
], Mt = /\.?0+$/;
|
|
610
|
+
function Rt(r) {
|
|
611
|
+
return r.toFixed(7).replace(Mt, "");
|
|
612
612
|
}
|
|
613
613
|
const tt = (r) => {
|
|
614
|
-
const
|
|
614
|
+
const i = r % 360 * (Math.PI / 180), c = Math.max(0, Math.min(100, 50 - 50 * Math.cos(i))), s = Math.max(0, Math.min(100, 50 - 50 * Math.sin(i))), e = Math.max(0, Math.min(100, 50 + 50 * Math.cos(i))), l = Math.max(0, Math.min(100, 50 + 50 * Math.sin(i)));
|
|
615
615
|
return {
|
|
616
|
-
x1: `${
|
|
617
|
-
y1: `${
|
|
618
|
-
x2: `${
|
|
619
|
-
y2: `${
|
|
616
|
+
x1: `${c}%`,
|
|
617
|
+
y1: `${s}%`,
|
|
618
|
+
x2: `${e}%`,
|
|
619
|
+
y2: `${l}%`
|
|
620
620
|
};
|
|
621
|
-
}, et = (r,
|
|
622
|
-
const
|
|
621
|
+
}, et = (r, i, c, s) => {
|
|
622
|
+
const e = c / 2, l = e / 2, d = Math.PI / s;
|
|
623
623
|
let u = "";
|
|
624
|
-
for (let g = 0; g < 2 *
|
|
625
|
-
const
|
|
626
|
-
u += `${g === 0 ? "M" : "L"} ${n},${
|
|
624
|
+
for (let g = 0; g < 2 * s; g++) {
|
|
625
|
+
const t = g * d - Math.PI / 2, o = g % 2 === 0 ? e : l, n = r + o * Math.cos(t), a = i + o * Math.sin(t);
|
|
626
|
+
u += `${g === 0 ? "M" : "L"} ${n},${a} `;
|
|
627
627
|
}
|
|
628
628
|
return u + "Z";
|
|
629
|
-
}, ot = (r,
|
|
630
|
-
|
|
629
|
+
}, ot = (r, i, c) => {
|
|
630
|
+
const s = c / 8;
|
|
631
|
+
return `M ${r + c} ${i + s * 3}
|
|
632
|
+
V ${i + s}
|
|
633
|
+
h -${s}
|
|
634
|
+
V ${i}
|
|
635
|
+
H ${r + s * 5}
|
|
636
|
+
v ${s}
|
|
637
|
+
H ${r + s * 3}
|
|
638
|
+
V ${i}
|
|
639
|
+
H ${r + s}
|
|
640
|
+
v ${s}
|
|
641
|
+
H ${r}
|
|
642
|
+
v ${s * 2}
|
|
643
|
+
h ${s}
|
|
644
|
+
v ${s * 2}
|
|
645
|
+
H ${r}
|
|
646
|
+
v ${s * 2}
|
|
647
|
+
h ${s}
|
|
648
|
+
v ${s}
|
|
649
|
+
h ${s * 2}
|
|
650
|
+
v -${s}
|
|
651
|
+
h ${s * 2}
|
|
652
|
+
v ${s}
|
|
653
|
+
h ${s * 2}
|
|
654
|
+
v -${s}
|
|
655
|
+
h ${s}
|
|
656
|
+
V ${i + s * 5}
|
|
657
|
+
h -${s}
|
|
658
|
+
V ${i + s * 3}
|
|
659
|
+
h ${s}
|
|
660
|
+
Z`;
|
|
661
|
+
}, nt = (r, i, c) => {
|
|
662
|
+
let s = !1, e = 0;
|
|
631
663
|
return [
|
|
632
664
|
"M",
|
|
633
665
|
1,
|
|
@@ -739,18 +771,18 @@ const tt = (r) => {
|
|
|
739
771
|
1,
|
|
740
772
|
0.3262506,
|
|
741
773
|
"z"
|
|
742
|
-
].map((
|
|
743
|
-
},
|
|
774
|
+
].map((l) => typeof l == "string" ? (e = 0, s = l.toUpperCase() == l, l) : (e++, l = l * c, s && (l += e % 2 == 1 ? r : i), Rt(l))).join(" ");
|
|
775
|
+
}, x = {
|
|
744
776
|
"data-testid": "background"
|
|
745
|
-
},
|
|
746
|
-
var
|
|
777
|
+
}, gt = ({ background: r, numCells: i }) => {
|
|
778
|
+
var s, e;
|
|
747
779
|
if (!r)
|
|
748
780
|
return null;
|
|
749
781
|
if (typeof r == "string")
|
|
750
|
-
return /* @__PURE__ */ C("path", { fill: r, d: `M0,0 h${
|
|
751
|
-
const
|
|
752
|
-
return /* @__PURE__ */
|
|
753
|
-
/* @__PURE__ */ C("defs", { children: r.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: F, gradientUnits: "userSpaceOnUse", ...
|
|
782
|
+
return /* @__PURE__ */ C("path", { fill: r, d: `M0,0 h${i}v${i}H0z`, ...x });
|
|
783
|
+
const c = tt((r == null ? void 0 : r.rotation) || 0);
|
|
784
|
+
return /* @__PURE__ */ K(rt, { children: [
|
|
785
|
+
/* @__PURE__ */ C("defs", { children: r.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: F, gradientUnits: "userSpaceOnUse", ...c, children: (s = r.stops) == null ? void 0 : s.map((l, d) => /* @__PURE__ */ C("stop", { offset: l.offset, stopColor: l.color }, d)) }) : /* @__PURE__ */ C(
|
|
754
786
|
"radialGradient",
|
|
755
787
|
{
|
|
756
788
|
id: F,
|
|
@@ -758,217 +790,219 @@ const tt = (r) => {
|
|
|
758
790
|
cx: "50%",
|
|
759
791
|
cy: "50%",
|
|
760
792
|
r: "50%",
|
|
761
|
-
children: (
|
|
793
|
+
children: (e = r.stops) == null ? void 0 : e.map((l, d) => /* @__PURE__ */ C("stop", { offset: l.offset, stopColor: l.color }, d))
|
|
762
794
|
}
|
|
763
795
|
) }),
|
|
764
796
|
/* @__PURE__ */ C(
|
|
765
797
|
"path",
|
|
766
798
|
{
|
|
767
799
|
fill: `url(#${F})`,
|
|
768
|
-
d: `M0,0 h${
|
|
769
|
-
...
|
|
800
|
+
d: `M0,0 h${i}v${i}H0z`,
|
|
801
|
+
...x
|
|
770
802
|
}
|
|
771
803
|
)
|
|
772
804
|
] });
|
|
773
|
-
},
|
|
774
|
-
const
|
|
775
|
-
left: r === 0 ? !1 :
|
|
776
|
-
right: r ===
|
|
777
|
-
top:
|
|
778
|
-
bottom:
|
|
805
|
+
}, wt = (r) => r === "square" || r === "circle" || r === "star" || r === "heart" || r === "diamond" || r === "hashtag", At = (r, i) => r === "square-sm" ? 0.75 : i ? Math.random() * (1 - 0.75) + 0.75 : 1, b = (r, i, c) => {
|
|
806
|
+
const s = {
|
|
807
|
+
left: r === 0 ? !1 : c[i][r - 1],
|
|
808
|
+
right: r === c[i].length - 1 ? !1 : c[i][r + 1],
|
|
809
|
+
top: i === 0 ? !1 : c[i - 1][r],
|
|
810
|
+
bottom: i === c.length - 1 ? !1 : c[i + 1][r]
|
|
779
811
|
};
|
|
780
812
|
return {
|
|
781
|
-
...
|
|
782
|
-
count: Object.values(
|
|
813
|
+
...s,
|
|
814
|
+
count: Object.values(s).filter(Boolean).length
|
|
783
815
|
};
|
|
784
|
-
},
|
|
816
|
+
}, y = (r, i, c) => `M${r},${i}h${c}v${c}h-${c}Z`, D = (r, i, c) => `M${r},${i + c / 2}a${c / 2},${c / 2} 0 1,0 ${c},0a${c / 2},${c / 2} 0 1,0 -${c},0Z`, Ct = (r, i, c) => `M${r},${i + c / 2}l${c / 2},-${c / 2}l${c / 2},${c / 2}l-${c / 2},${c / 2}Z`, Nt = (r, i) => `M ${r} ${i}
|
|
785
817
|
v 1
|
|
786
818
|
h 1
|
|
787
819
|
v -0.5
|
|
788
|
-
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, q = (r,
|
|
820
|
+
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, q = (r, i) => `M ${r + 1} ${i}
|
|
789
821
|
v 1
|
|
790
822
|
h -1
|
|
791
823
|
v -0.5
|
|
792
|
-
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, j = (r,
|
|
824
|
+
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, j = (r, i) => `M ${r} ${i}
|
|
793
825
|
v 1
|
|
794
826
|
h 0.5
|
|
795
827
|
a 0.5 0.5, 0, 0, 0, 0.5 -0.5
|
|
796
828
|
v -0.5
|
|
797
|
-
h -1`,
|
|
829
|
+
h -1`, It = (r, i) => `M ${r + 1} ${i}
|
|
798
830
|
v 1
|
|
799
831
|
h -0.5
|
|
800
832
|
a 0.5 0.5, 0, 0, 1, -0.5 -0.5
|
|
801
833
|
v -0.5
|
|
802
|
-
h 1`,
|
|
834
|
+
h 1`, V = (r, i) => `M ${r} ${i}
|
|
803
835
|
v 1
|
|
804
836
|
h 0.5
|
|
805
|
-
a 0.5 0.5, 0, 0, 0, 0 -1`,
|
|
837
|
+
a 0.5 0.5, 0, 0, 0, 0 -1`, X = (r, i) => `M ${r + 1} ${i}
|
|
806
838
|
v 1
|
|
807
839
|
h -0.5
|
|
808
|
-
a 0.5 0.5, 0, 0, 1, 0 -1`, Z = (r,
|
|
840
|
+
a 0.5 0.5, 0, 0, 1, 0 -1`, Z = (r, i) => `M ${r} ${i + 1}
|
|
809
841
|
h 1
|
|
810
842
|
v -0.5
|
|
811
|
-
a 0.5 0.5, 0, 0, 0, -1 0`,
|
|
843
|
+
a 0.5 0.5, 0, 0, 0, -1 0`, Q = (r, i) => `M ${r} ${i}
|
|
812
844
|
h 1
|
|
813
845
|
v 0.5
|
|
814
|
-
a 0.5 0.5, 0, 0, 1, -1 0`,
|
|
846
|
+
a 0.5 0.5, 0, 0, 1, -1 0`, Pt = (r, i, c) => `M ${r + 1} ${i}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}`, vt = ({
|
|
815
847
|
x: r,
|
|
816
|
-
y:
|
|
817
|
-
numCells:
|
|
848
|
+
y: i,
|
|
849
|
+
numCells: c
|
|
818
850
|
}) => {
|
|
819
|
-
var
|
|
820
|
-
return !!((
|
|
851
|
+
var s, e, l;
|
|
852
|
+
return !!((s = z[r]) != null && s[i] || (e = z[r - c + 7]) != null && e[i] || (l = z[r]) != null && l[i - c + 7]);
|
|
821
853
|
}, Tt = ({
|
|
822
854
|
x: r,
|
|
823
|
-
y:
|
|
824
|
-
radius:
|
|
855
|
+
y: i,
|
|
856
|
+
radius: c
|
|
825
857
|
}) => {
|
|
826
|
-
const
|
|
827
|
-
return `M ${r} ${
|
|
858
|
+
const s = v - c, e = c / 2, l = v - e;
|
|
859
|
+
return `M ${r} ${i + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${l}v ${-l}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}H ${r}z`;
|
|
828
860
|
}, Lt = ({
|
|
829
861
|
x: r,
|
|
830
|
-
y:
|
|
831
|
-
radius:
|
|
862
|
+
y: i,
|
|
863
|
+
radius: c
|
|
832
864
|
}) => {
|
|
833
|
-
const
|
|
834
|
-
return `M ${r} ${
|
|
865
|
+
const s = v - c, e = c / 2, l = v - e;
|
|
866
|
+
return `M ${r} ${i + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${l}v ${-l}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}a ${e} ${e}, 0, 0, 0, ${-e} ${e}`;
|
|
835
867
|
}, Ot = ({
|
|
836
868
|
x: r,
|
|
837
|
-
y:
|
|
838
|
-
numCells:
|
|
869
|
+
y: i,
|
|
870
|
+
numCells: c
|
|
839
871
|
}) => {
|
|
840
|
-
var
|
|
841
|
-
return !!((
|
|
842
|
-
},
|
|
872
|
+
var s, e, l;
|
|
873
|
+
return !!((s = B[r]) != null && s[i] || (e = B[r - c + 7]) != null && e[i] || (l = B[r]) != null && l[i - c + 7]);
|
|
874
|
+
}, St = ({
|
|
843
875
|
x: r,
|
|
844
|
-
y:
|
|
845
|
-
radius:
|
|
876
|
+
y: i,
|
|
877
|
+
radius: c
|
|
846
878
|
}) => {
|
|
847
|
-
const
|
|
848
|
-
return `M ${r} ${
|
|
849
|
-
},
|
|
879
|
+
const s = I - c, e = c / 2;
|
|
880
|
+
return `M ${r} ${i + 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} ${i + 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)}`;
|
|
881
|
+
}, yt = ({
|
|
850
882
|
x: r,
|
|
851
|
-
y:
|
|
852
|
-
radius:
|
|
883
|
+
y: i,
|
|
884
|
+
radius: c
|
|
853
885
|
}) => {
|
|
854
|
-
const
|
|
855
|
-
return `M ${r} ${
|
|
856
|
-
},
|
|
886
|
+
const s = I - c, e = c / 2, l = I - e;
|
|
887
|
+
return `M ${r} ${i + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${l}v ${-l}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}H ${r}zM ${r + e} ${i + 1}h ${s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${e - 1}v ${l - 1}h ${-(l - 1)}a ${e - 1} ${e - 1}, 0, 0, 1, ${-(e - 1)} ${-(e - 1)}v ${-(l - 1)}z`;
|
|
888
|
+
}, Ut = ({
|
|
857
889
|
x: r,
|
|
858
|
-
y:
|
|
859
|
-
radius:
|
|
890
|
+
y: i,
|
|
891
|
+
radius: c
|
|
860
892
|
}) => {
|
|
861
|
-
const
|
|
862
|
-
return `M ${r} ${
|
|
863
|
-
},
|
|
864
|
-
color: (r == null ? void 0 : r.color) ||
|
|
865
|
-
style: (r == null ? void 0 : r.style) ||
|
|
893
|
+
const s = I - c, e = c / 2, l = I - e;
|
|
894
|
+
return `M ${r} ${i + e}v ${s}a ${e} ${e}, 0, 0, 0, ${e} ${e}h ${l}v ${-l}a ${e} ${e}, 0, 0, 0, ${-e} ${-e}h ${-s}a ${e} ${e}, 0, 0, 0, ${-e} ${e}M ${r + e} ${i + 1}h ${s}a ${e - 1} ${e - 1}, 0, 0, 1, ${e - 1} ${e - 1}v ${l - 1}h ${-(l - 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)}`;
|
|
895
|
+
}, bt = (r) => ({
|
|
896
|
+
color: (r == null ? void 0 : r.color) || H,
|
|
897
|
+
style: (r == null ? void 0 : r.style) || pt,
|
|
866
898
|
randomSize: (r == null ? void 0 : r.randomSize) || !1
|
|
867
|
-
}), bt = (r) => ({
|
|
868
|
-
color: (r == null ? void 0 : r.color) || x,
|
|
869
|
-
style: (r == null ? void 0 : r.style) || dt
|
|
870
899
|
}), Dt = (r) => ({
|
|
871
|
-
color: (r == null ? void 0 : r.color) ||
|
|
900
|
+
color: (r == null ? void 0 : r.color) || H,
|
|
872
901
|
style: (r == null ? void 0 : r.style) || ft
|
|
873
|
-
}), Ft = ({
|
|
902
|
+
}), Ft = (r) => ({
|
|
903
|
+
color: (r == null ? void 0 : r.color) || H,
|
|
904
|
+
style: (r == null ? void 0 : r.style) || $t
|
|
905
|
+
}), Bt = ({
|
|
874
906
|
modules: r,
|
|
875
|
-
margin:
|
|
876
|
-
settings:
|
|
877
|
-
gradient:
|
|
907
|
+
margin: i,
|
|
908
|
+
settings: c,
|
|
909
|
+
gradient: s
|
|
878
910
|
}) => {
|
|
879
|
-
const { color:
|
|
880
|
-
() =>
|
|
881
|
-
[
|
|
882
|
-
), u = [], g = r.length,
|
|
883
|
-
() =>
|
|
884
|
-
[
|
|
911
|
+
const { color: e, style: l, randomSize: d } = T(
|
|
912
|
+
() => bt(c),
|
|
913
|
+
[c]
|
|
914
|
+
), u = [], g = r.length, t = wt(l) && d, o = st(
|
|
915
|
+
() => At(l, t),
|
|
916
|
+
[l, t]
|
|
885
917
|
);
|
|
886
|
-
return r.forEach((n,
|
|
918
|
+
return r.forEach((n, a) => {
|
|
887
919
|
n.forEach((h, $) => {
|
|
888
|
-
if (Ot({ x: $, y:
|
|
920
|
+
if (Ot({ x: $, y: a, numCells: g }) || vt({ x: $, y: a, numCells: g }))
|
|
889
921
|
return;
|
|
890
|
-
const f = o(), p = 1 * f, M = (1 - 1 * f) / 2, E = $ +
|
|
922
|
+
const f = o(), p = 1 * f, M = (1 - 1 * f) / 2, E = $ + i + M, m = a + i + M;
|
|
891
923
|
if (h) {
|
|
892
|
-
if (
|
|
893
|
-
u.push(
|
|
894
|
-
else if (
|
|
924
|
+
if (l === "square" || l === "square-sm")
|
|
925
|
+
u.push(y(E, m, p));
|
|
926
|
+
else if (l === "circle")
|
|
895
927
|
u.push(D(E, m, p));
|
|
896
|
-
else if (
|
|
897
|
-
u.push(
|
|
898
|
-
else if (
|
|
928
|
+
else if (l === "diamond")
|
|
929
|
+
u.push(Ct(E, m, p));
|
|
930
|
+
else if (l === "star")
|
|
899
931
|
u.push(
|
|
900
932
|
et(E + p / 2, m + p / 2, p * 1.1, W)
|
|
901
933
|
);
|
|
902
|
-
else if (
|
|
934
|
+
else if (l === "heart")
|
|
935
|
+
u.push(nt(E, m, p));
|
|
936
|
+
else if (l === "hashtag")
|
|
903
937
|
u.push(ot(E, m, p));
|
|
904
|
-
else if (
|
|
905
|
-
const { left: R, right: w, top: A, bottom: N, count: P } = b($,
|
|
906
|
-
P === 0 ? u.push(D(E, m, 1)) : P > 2 || R && w || A && N ? u.push(
|
|
907
|
-
} else if (
|
|
908
|
-
const { left: R, right: w, top: A, bottom: N, count: P } = b($,
|
|
938
|
+
else if (l === "rounded") {
|
|
939
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, a, r);
|
|
940
|
+
P === 0 ? u.push(D(E, m, 1)) : P > 2 || R && w || A && N ? u.push(y(E, m, 1)) : P === 2 ? R && A ? u.push(j(E, m)) : A && w ? u.push(It(E, m)) : w && N ? u.push(q(E, m)) : u.push(Nt(E, m)) : A ? u.push(Q(E, m)) : w ? u.push(X(E, m)) : N ? u.push(Z(E, m)) : u.push(V(E, m));
|
|
941
|
+
} else if (l === "leaf") {
|
|
942
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, a, r);
|
|
909
943
|
if (P === 0)
|
|
910
|
-
u.push(
|
|
944
|
+
u.push(Pt(E, m, p));
|
|
911
945
|
else if (!R && !A) {
|
|
912
946
|
u.push(q(E, m));
|
|
913
947
|
return;
|
|
914
|
-
} else !w && !N ? u.push(j(E, m)) : u.push(
|
|
915
|
-
} else if (
|
|
916
|
-
const { left: R, right: w, top: A, bottom: N, count: P } = b($,
|
|
917
|
-
P === 0 || R && !(A || N) || w && !(A || N) ? u.push(D(E, m, 1)) : A && N ? u.push(
|
|
918
|
-
} else if (
|
|
919
|
-
const { left: R, right: w, top: A, bottom: N, count: P } = b($,
|
|
920
|
-
P === 0 || A && !(R || w) || N && !(R || w) ? u.push(D(E, m, 1)) : R && w ? u.push(
|
|
948
|
+
} else !w && !N ? u.push(j(E, m)) : u.push(y(E, m, 1));
|
|
949
|
+
} else if (l === "vertical-line") {
|
|
950
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, a, r);
|
|
951
|
+
P === 0 || R && !(A || N) || w && !(A || N) ? u.push(D(E, m, 1)) : A && N ? u.push(y(E, m, 1)) : A && !N ? u.push(Q(E, m)) : N && !A && u.push(Z(E, m));
|
|
952
|
+
} else if (l === "horizontal-line") {
|
|
953
|
+
const { left: R, right: w, top: A, bottom: N, count: P } = b($, a, r);
|
|
954
|
+
P === 0 || A && !(R || w) || N && !(R || w) ? u.push(D(E, m, 1)) : R && w ? u.push(y(E, m, 1)) : R && !w ? u.push(V(E, m)) : w && !R && u.push(X(E, m));
|
|
921
955
|
}
|
|
922
956
|
}
|
|
923
957
|
});
|
|
924
958
|
}), /* @__PURE__ */ C(
|
|
925
959
|
"path",
|
|
926
960
|
{
|
|
927
|
-
fill:
|
|
961
|
+
fill: s ? `url(#${U})` : e,
|
|
928
962
|
d: u.join(""),
|
|
929
|
-
shapeRendering:
|
|
963
|
+
shapeRendering: l === "square" ? "crispEdges" : "geometricPrecision",
|
|
930
964
|
"data-testid": "data-modules"
|
|
931
965
|
}
|
|
932
966
|
);
|
|
933
|
-
},
|
|
967
|
+
}, O = {
|
|
934
968
|
"data-testid": "finder-patterns-inner"
|
|
935
|
-
},
|
|
969
|
+
}, zt = ({
|
|
936
970
|
modules: r,
|
|
937
|
-
margin:
|
|
938
|
-
settings:
|
|
939
|
-
gradient:
|
|
971
|
+
margin: i,
|
|
972
|
+
settings: c,
|
|
973
|
+
gradient: s
|
|
940
974
|
}) => {
|
|
941
|
-
const { color:
|
|
942
|
-
() =>
|
|
943
|
-
[
|
|
944
|
-
), d =
|
|
975
|
+
const { color: e, style: l } = T(
|
|
976
|
+
() => Ft(c),
|
|
977
|
+
[c]
|
|
978
|
+
), d = s ? `url(#${U})` : e, u = T(
|
|
945
979
|
() => [
|
|
946
|
-
{ x:
|
|
947
|
-
{ x: r.length +
|
|
948
|
-
{ x:
|
|
980
|
+
{ x: i + 2, y: i + 2 },
|
|
981
|
+
{ x: r.length + i - I + 2, y: i + 2 },
|
|
982
|
+
{ x: i + 2, y: r.length + i - I + 2 }
|
|
949
983
|
],
|
|
950
|
-
[
|
|
951
|
-
), g = (
|
|
952
|
-
if (
|
|
953
|
-
return u.map((
|
|
954
|
-
const { x: o, y: n } =
|
|
984
|
+
[i, r.length]
|
|
985
|
+
), g = (t, o) => `finder-patterns-inner-${l}-${t}-${o}`;
|
|
986
|
+
if (l === "rounded-sm" || l === "rounded" || l === "rounded-lg" || l === "circle" || l === "square")
|
|
987
|
+
return u.map((t) => {
|
|
988
|
+
const { x: o, y: n } = t;
|
|
955
989
|
return /* @__PURE__ */ C(
|
|
956
990
|
"rect",
|
|
957
991
|
{
|
|
958
992
|
x: o,
|
|
959
993
|
y: n,
|
|
960
|
-
width:
|
|
961
|
-
height:
|
|
994
|
+
width: v,
|
|
995
|
+
height: v,
|
|
962
996
|
fill: d,
|
|
963
|
-
rx:
|
|
964
|
-
...
|
|
997
|
+
rx: G[l],
|
|
998
|
+
...O
|
|
965
999
|
},
|
|
966
1000
|
g(o, n)
|
|
967
1001
|
);
|
|
968
1002
|
});
|
|
969
|
-
if (
|
|
970
|
-
return u.map((
|
|
971
|
-
const { x: o, y: n } =
|
|
1003
|
+
if (l === "diamond")
|
|
1004
|
+
return u.map((t) => {
|
|
1005
|
+
const { x: o, y: n } = t, a = Math.sqrt(1.5), h = v / a, $ = h - h / a;
|
|
972
1006
|
return /* @__PURE__ */ C(
|
|
973
1007
|
"rect",
|
|
974
1008
|
{
|
|
@@ -982,21 +1016,21 @@ const tt = (r) => {
|
|
|
982
1016
|
transformOrigin: "center",
|
|
983
1017
|
transformBox: "fill-box"
|
|
984
1018
|
},
|
|
985
|
-
...
|
|
1019
|
+
...O
|
|
986
1020
|
},
|
|
987
1021
|
g(o, n)
|
|
988
1022
|
);
|
|
989
1023
|
});
|
|
990
|
-
if (
|
|
991
|
-
const
|
|
1024
|
+
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") {
|
|
1025
|
+
const t = l === "leaf-sm" || l === "leaf" || l === "leaf-lg" ? Tt : Lt;
|
|
992
1026
|
return u.map((o, n) => ({
|
|
993
1027
|
...o,
|
|
994
|
-
rotation: J[
|
|
995
|
-
})).map(({ x: o, y: n, rotation:
|
|
996
|
-
const h =
|
|
1028
|
+
rotation: J[l][n]
|
|
1029
|
+
})).map(({ x: o, y: n, rotation: a }) => {
|
|
1030
|
+
const h = t({
|
|
997
1031
|
x: o,
|
|
998
1032
|
y: n,
|
|
999
|
-
radius:
|
|
1033
|
+
radius: G[l]
|
|
1000
1034
|
});
|
|
1001
1035
|
return /* @__PURE__ */ C(
|
|
1002
1036
|
"path",
|
|
@@ -1004,77 +1038,82 @@ const tt = (r) => {
|
|
|
1004
1038
|
fill: d,
|
|
1005
1039
|
d: h,
|
|
1006
1040
|
style: {
|
|
1007
|
-
transform: `rotate(${
|
|
1041
|
+
transform: `rotate(${a}deg)`,
|
|
1008
1042
|
transformOrigin: "center",
|
|
1009
1043
|
transformBox: "fill-box"
|
|
1010
1044
|
},
|
|
1011
|
-
...
|
|
1045
|
+
...O
|
|
1012
1046
|
},
|
|
1013
1047
|
g(o, n)
|
|
1014
1048
|
);
|
|
1015
1049
|
});
|
|
1016
1050
|
}
|
|
1017
|
-
if (
|
|
1018
|
-
return u.map(({ x:
|
|
1051
|
+
if (l === "heart")
|
|
1052
|
+
return u.map(({ x: t, y: o }) => /* @__PURE__ */ C(
|
|
1019
1053
|
"path",
|
|
1020
1054
|
{
|
|
1021
1055
|
fill: d,
|
|
1022
|
-
d:
|
|
1023
|
-
...
|
|
1056
|
+
d: nt(t, o, v),
|
|
1057
|
+
...O
|
|
1024
1058
|
},
|
|
1025
|
-
g(
|
|
1059
|
+
g(t, o)
|
|
1026
1060
|
));
|
|
1027
|
-
if (
|
|
1028
|
-
return u.map(({ x:
|
|
1029
|
-
const n =
|
|
1030
|
-
return /* @__PURE__ */ C("path", { fill: d, d: h, ...
|
|
1061
|
+
if (l === "star")
|
|
1062
|
+
return u.map(({ x: t, y: o }) => {
|
|
1063
|
+
const n = t + v / 2, a = o + v / 2, h = et(n, a, v * 1.2, W);
|
|
1064
|
+
return /* @__PURE__ */ C("path", { fill: d, d: h, ...O }, g(t, o));
|
|
1031
1065
|
});
|
|
1032
|
-
|
|
1066
|
+
if (l === "hashtag")
|
|
1067
|
+
return u.map(({ x: t, y: o }) => {
|
|
1068
|
+
const n = ot(t - 0.25, o - 0.25, 3.5);
|
|
1069
|
+
return /* @__PURE__ */ C("path", { fill: d, d: n, ...O }, g(t, o));
|
|
1070
|
+
});
|
|
1071
|
+
}, _ = {
|
|
1033
1072
|
"data-testid": "finder-patterns-outer"
|
|
1034
|
-
},
|
|
1073
|
+
}, Ht = ({
|
|
1035
1074
|
modules: r,
|
|
1036
|
-
margin:
|
|
1037
|
-
settings:
|
|
1038
|
-
gradient:
|
|
1075
|
+
margin: i,
|
|
1076
|
+
settings: c,
|
|
1077
|
+
gradient: s
|
|
1039
1078
|
}) => {
|
|
1040
|
-
const { style:
|
|
1041
|
-
() =>
|
|
1042
|
-
[
|
|
1043
|
-
), d =
|
|
1079
|
+
const { style: e, color: l } = T(
|
|
1080
|
+
() => Dt(c),
|
|
1081
|
+
[c]
|
|
1082
|
+
), d = s ? `url(#${U})` : l, u = [], g = T(
|
|
1044
1083
|
() => [
|
|
1045
|
-
{ x:
|
|
1046
|
-
{ x: r.length +
|
|
1047
|
-
{ x:
|
|
1084
|
+
{ x: i, y: i },
|
|
1085
|
+
{ x: r.length + i - I, y: i },
|
|
1086
|
+
{ x: i, y: r.length + i - I }
|
|
1048
1087
|
],
|
|
1049
|
-
[
|
|
1088
|
+
[i, r.length]
|
|
1050
1089
|
);
|
|
1051
|
-
if (["rounded-sm", "rounded", "rounded-lg", "circle", "square"].includes(
|
|
1052
|
-
for (const
|
|
1053
|
-
const { x: o, y: n } =
|
|
1054
|
-
|
|
1055
|
-
|
|
1090
|
+
if (["rounded-sm", "rounded", "rounded-lg", "circle", "square"].includes(e)) {
|
|
1091
|
+
for (const t of g) {
|
|
1092
|
+
const { x: o, y: n } = t;
|
|
1093
|
+
e === "rounded-sm" || e === "rounded" || e === "rounded-lg" ? u.push(
|
|
1094
|
+
St({
|
|
1056
1095
|
x: o,
|
|
1057
1096
|
y: n,
|
|
1058
|
-
radius:
|
|
1097
|
+
radius: Y[e]
|
|
1059
1098
|
})
|
|
1060
|
-
) :
|
|
1099
|
+
) : e === "circle" ? u.push(
|
|
1061
1100
|
`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`
|
|
1062
1101
|
) : u.push(
|
|
1063
1102
|
`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`
|
|
1064
1103
|
);
|
|
1065
1104
|
}
|
|
1066
|
-
return /* @__PURE__ */ C("path", { fill: d, d: u.join(""), ...
|
|
1105
|
+
return /* @__PURE__ */ C("path", { fill: d, d: u.join(""), ..._ });
|
|
1067
1106
|
}
|
|
1068
|
-
if (
|
|
1069
|
-
const
|
|
1107
|
+
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") {
|
|
1108
|
+
const t = e === "leaf-sm" || e === "leaf" || e === "leaf-lg" ? yt : Ut;
|
|
1070
1109
|
return g.map((o, n) => ({
|
|
1071
1110
|
...o,
|
|
1072
|
-
rotation: J[
|
|
1073
|
-
})).map(({ x: o, y: n, rotation:
|
|
1074
|
-
const h =
|
|
1111
|
+
rotation: J[e][n]
|
|
1112
|
+
})).map(({ x: o, y: n, rotation: a }) => {
|
|
1113
|
+
const h = t({
|
|
1075
1114
|
x: o,
|
|
1076
1115
|
y: n,
|
|
1077
|
-
radius:
|
|
1116
|
+
radius: Y[e]
|
|
1078
1117
|
});
|
|
1079
1118
|
return /* @__PURE__ */ C(
|
|
1080
1119
|
"path",
|
|
@@ -1082,22 +1121,22 @@ const tt = (r) => {
|
|
|
1082
1121
|
fill: d,
|
|
1083
1122
|
d: h,
|
|
1084
1123
|
style: {
|
|
1085
|
-
transform: `rotate(${
|
|
1124
|
+
transform: `rotate(${a}deg)`,
|
|
1086
1125
|
transformOrigin: "center",
|
|
1087
1126
|
transformBox: "fill-box"
|
|
1088
1127
|
},
|
|
1089
|
-
...
|
|
1128
|
+
..._
|
|
1090
1129
|
},
|
|
1091
|
-
`finder-patterns-outer-${
|
|
1130
|
+
`finder-patterns-outer-${e}-${o}-${n}`
|
|
1092
1131
|
);
|
|
1093
1132
|
});
|
|
1094
1133
|
}
|
|
1095
|
-
},
|
|
1096
|
-
var
|
|
1134
|
+
}, kt = ({ gradient: r }) => {
|
|
1135
|
+
var c, s;
|
|
1097
1136
|
if (!r)
|
|
1098
1137
|
return null;
|
|
1099
|
-
const
|
|
1100
|
-
return /* @__PURE__ */ C("defs", { children: r.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: U, gradientUnits: "userSpaceOnUse", ...
|
|
1138
|
+
const i = tt((r == null ? void 0 : r.rotation) || 0);
|
|
1139
|
+
return /* @__PURE__ */ C("defs", { children: r.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: U, gradientUnits: "userSpaceOnUse", ...i, children: (c = r.stops) == null ? void 0 : c.map((e, l) => /* @__PURE__ */ C("stop", { offset: e.offset, stopColor: e.color }, l)) }) : /* @__PURE__ */ C(
|
|
1101
1140
|
"radialGradient",
|
|
1102
1141
|
{
|
|
1103
1142
|
id: U,
|
|
@@ -1105,140 +1144,140 @@ const tt = (r) => {
|
|
|
1105
1144
|
cx: "50%",
|
|
1106
1145
|
cy: "50%",
|
|
1107
1146
|
r: "50%",
|
|
1108
|
-
children: (
|
|
1147
|
+
children: (s = r.stops) == null ? void 0 : s.map((e, l) => /* @__PURE__ */ C("stop", { offset: e.offset, stopColor: e.color }, l))
|
|
1109
1148
|
}
|
|
1110
1149
|
) });
|
|
1111
|
-
},
|
|
1112
|
-
if (
|
|
1150
|
+
}, Yt = (r, i) => r.slice().map((c, s) => s < i.y || s >= i.y + i.h ? c : c.map((e, l) => l < i.x || l >= i.x + i.w ? e : !1)), Gt = (r, i, c, s) => {
|
|
1151
|
+
if (s == null)
|
|
1113
1152
|
return null;
|
|
1114
|
-
const
|
|
1115
|
-
let
|
|
1116
|
-
if (
|
|
1117
|
-
const $ = Math.floor(
|
|
1118
|
-
|
|
1153
|
+
const e = r.length + c * 2, l = Math.floor(i * Et), d = e / i, u = (s.width || l) * d, g = (s.height || l) * d, t = s.x == null ? r.length / 2 - u / 2 : s.x * d, o = s.y == null ? r.length / 2 - g / 2 : s.y * d, n = s.opacity == null ? 1 : s.opacity;
|
|
1154
|
+
let a = null;
|
|
1155
|
+
if (s.excavate) {
|
|
1156
|
+
const $ = Math.floor(t), f = Math.floor(o), p = Math.ceil(u + t - $), M = Math.ceil(g + o - f);
|
|
1157
|
+
a = { x: $, y: f, w: p, h: M };
|
|
1119
1158
|
}
|
|
1120
|
-
const h =
|
|
1121
|
-
return { x:
|
|
1122
|
-
},
|
|
1159
|
+
const h = s.crossOrigin;
|
|
1160
|
+
return { x: t, y: o, h: g, w: u, excavation: a, opacity: n, crossOrigin: h };
|
|
1161
|
+
}, xt = (r) => r != null ? Math.max(Math.floor(r), 0) : dt, qt = ({
|
|
1123
1162
|
value: r,
|
|
1124
|
-
level:
|
|
1125
|
-
minVersion:
|
|
1126
|
-
marginSize:
|
|
1127
|
-
imageSettings:
|
|
1128
|
-
size:
|
|
1163
|
+
level: i,
|
|
1164
|
+
minVersion: c,
|
|
1165
|
+
marginSize: s,
|
|
1166
|
+
imageSettings: e,
|
|
1167
|
+
size: l,
|
|
1129
1168
|
boostLevel: d
|
|
1130
1169
|
}) => {
|
|
1131
|
-
const u =
|
|
1132
|
-
const h = (Array.isArray(r) ? r : [r]).reduce(($, f) => ($.push(...
|
|
1133
|
-
return
|
|
1170
|
+
const u = T(() => {
|
|
1171
|
+
const h = (Array.isArray(r) ? r : [r]).reduce(($, f) => ($.push(...S.QrSegment.makeSegments(f)), $), []);
|
|
1172
|
+
return S.QrCode.encodeSegments(
|
|
1134
1173
|
h,
|
|
1135
|
-
|
|
1136
|
-
|
|
1174
|
+
ct[i],
|
|
1175
|
+
c,
|
|
1137
1176
|
void 0,
|
|
1138
1177
|
void 0,
|
|
1139
1178
|
d
|
|
1140
1179
|
);
|
|
1141
|
-
}, [r,
|
|
1142
|
-
const
|
|
1180
|
+
}, [r, i, c, d]), { cells: g, margin: t, numCells: o, calculatedImageSettings: n } = T(() => {
|
|
1181
|
+
const a = u.getModules(), h = xt(s), $ = a.length + h * 2, f = Gt(a, l, h, e);
|
|
1143
1182
|
return {
|
|
1144
|
-
cells:
|
|
1183
|
+
cells: a,
|
|
1145
1184
|
margin: h,
|
|
1146
1185
|
numCells: $,
|
|
1147
1186
|
calculatedImageSettings: f
|
|
1148
1187
|
};
|
|
1149
|
-
}, [u,
|
|
1188
|
+
}, [u, l, e, s]);
|
|
1150
1189
|
return {
|
|
1151
1190
|
qrcode: u,
|
|
1152
|
-
margin:
|
|
1191
|
+
margin: t,
|
|
1153
1192
|
cells: g,
|
|
1154
1193
|
numCells: o,
|
|
1155
1194
|
calculatedImageSettings: n
|
|
1156
1195
|
};
|
|
1157
|
-
},
|
|
1196
|
+
}, jt = ({ svgRef: r, fileSize: i, fileName: c }) => {
|
|
1158
1197
|
if (!r.current) return;
|
|
1159
|
-
const
|
|
1160
|
-
|
|
1161
|
-
const
|
|
1198
|
+
const s = r.current.cloneNode(!0);
|
|
1199
|
+
s.setAttribute("width", i.toString()), s.setAttribute("height", i.toString());
|
|
1200
|
+
const e = new XMLSerializer(), l = new Blob([e.serializeToString(s)], {
|
|
1162
1201
|
type: "image/svg+xml"
|
|
1163
|
-
}), d = URL.createObjectURL(
|
|
1164
|
-
u.href = d, u.download = `${
|
|
1165
|
-
},
|
|
1202
|
+
}), d = URL.createObjectURL(l), u = document.createElement("a");
|
|
1203
|
+
u.href = d, u.download = `${c}.svg`, document.body.appendChild(u), u.click(), document.body.removeChild(u), URL.revokeObjectURL(d);
|
|
1204
|
+
}, Vt = ({
|
|
1166
1205
|
svgRef: r,
|
|
1167
|
-
fileSize:
|
|
1168
|
-
fileName:
|
|
1169
|
-
fileFormat:
|
|
1170
|
-
imageSettings:
|
|
1171
|
-
calculatedImageSettings:
|
|
1206
|
+
fileSize: i,
|
|
1207
|
+
fileName: c,
|
|
1208
|
+
fileFormat: s,
|
|
1209
|
+
imageSettings: e,
|
|
1210
|
+
calculatedImageSettings: l,
|
|
1172
1211
|
size: d,
|
|
1173
1212
|
numCells: u,
|
|
1174
1213
|
margin: g
|
|
1175
1214
|
}) => {
|
|
1176
1215
|
if (!r.current) return;
|
|
1177
|
-
const
|
|
1216
|
+
const t = document.createElement("canvas"), o = t.getContext("2d");
|
|
1178
1217
|
if (!o) return;
|
|
1179
|
-
|
|
1180
|
-
const n = new XMLSerializer().serializeToString(r.current),
|
|
1218
|
+
t.width = i, t.height = i;
|
|
1219
|
+
const n = new XMLSerializer().serializeToString(r.current), a = new Blob([n], { type: "image/svg+xml;charset=utf-8" }), h = URL.createObjectURL(a), $ = new Image();
|
|
1181
1220
|
$.crossOrigin = "anonymous", $.src = h, $.onload = () => {
|
|
1182
|
-
if (o.drawImage($, 0, 0,
|
|
1221
|
+
if (o.drawImage($, 0, 0, i, i), URL.revokeObjectURL(h), e != null && e.src && l) {
|
|
1183
1222
|
const f = new Image();
|
|
1184
|
-
f.crossOrigin = "anonymous", f.src =
|
|
1185
|
-
const p =
|
|
1223
|
+
f.crossOrigin = "anonymous", f.src = e.src, f.onload = () => {
|
|
1224
|
+
const p = i / d, M = u / i, E = e.width * p, m = e.x ? (l.x + g) / M : (i - E) / 2, R = e.y ? (l.y + g) / M : (i - E) / 2;
|
|
1186
1225
|
o.drawImage(f, m, R, E, E);
|
|
1187
|
-
const w =
|
|
1188
|
-
A.href =
|
|
1226
|
+
const w = s === "png" ? "image/png" : "image/jpeg", A = document.createElement("a");
|
|
1227
|
+
A.href = t.toDataURL(w), A.download = `${c}.${s}`, document.body.appendChild(A), A.click(), document.body.removeChild(A);
|
|
1189
1228
|
}, f.onerror = (p) => console.error("Error loading logo:", p);
|
|
1190
1229
|
} else {
|
|
1191
|
-
const f =
|
|
1192
|
-
p.href =
|
|
1230
|
+
const f = s === "png" ? "image/png" : "image/jpeg", p = document.createElement("a");
|
|
1231
|
+
p.href = t.toDataURL(f), p.download = `${c}.${s}`, document.body.appendChild(p), p.click(), document.body.removeChild(p);
|
|
1193
1232
|
}
|
|
1194
1233
|
}, $.onerror = (f) => console.error("Error loading QR code:", f);
|
|
1195
1234
|
}, Xt = (r) => {
|
|
1196
1235
|
const {
|
|
1197
|
-
ref:
|
|
1198
|
-
value:
|
|
1199
|
-
size:
|
|
1200
|
-
level:
|
|
1201
|
-
background:
|
|
1236
|
+
ref: i,
|
|
1237
|
+
value: c,
|
|
1238
|
+
size: s = lt,
|
|
1239
|
+
level: e = ht,
|
|
1240
|
+
background: l,
|
|
1202
1241
|
gradient: d,
|
|
1203
|
-
minVersion: u =
|
|
1242
|
+
minVersion: u = ut,
|
|
1204
1243
|
boostLevel: g,
|
|
1205
|
-
marginSize:
|
|
1244
|
+
marginSize: t,
|
|
1206
1245
|
finderPatternOuterSettings: o,
|
|
1207
1246
|
finderPatternInnerSettings: n,
|
|
1208
|
-
dataModulesSettings:
|
|
1247
|
+
dataModulesSettings: a,
|
|
1209
1248
|
imageSettings: h,
|
|
1210
1249
|
svgProps: $
|
|
1211
|
-
} = r, f =
|
|
1212
|
-
value:
|
|
1213
|
-
level:
|
|
1250
|
+
} = r, f = it(null), { margin: p, cells: M, numCells: E, calculatedImageSettings: m } = qt({
|
|
1251
|
+
value: c,
|
|
1252
|
+
level: e,
|
|
1214
1253
|
minVersion: u,
|
|
1215
1254
|
boostLevel: g,
|
|
1216
|
-
marginSize:
|
|
1255
|
+
marginSize: t,
|
|
1217
1256
|
imageSettings: h,
|
|
1218
|
-
size:
|
|
1257
|
+
size: s
|
|
1219
1258
|
});
|
|
1220
|
-
|
|
1259
|
+
at(i, () => ({
|
|
1221
1260
|
svg: f.current,
|
|
1222
1261
|
download: ({
|
|
1223
|
-
name: N =
|
|
1262
|
+
name: N = mt,
|
|
1224
1263
|
format: P = "svg",
|
|
1225
1264
|
size: k = 500
|
|
1226
1265
|
}) => {
|
|
1227
|
-
f.current && (P === "svg" ?
|
|
1266
|
+
f.current && (P === "svg" ? jt({ svgRef: f, fileSize: k, fileName: N }) : Vt({
|
|
1228
1267
|
svgRef: f,
|
|
1229
1268
|
fileSize: k,
|
|
1230
1269
|
fileName: N,
|
|
1231
1270
|
fileFormat: P,
|
|
1232
1271
|
imageSettings: h,
|
|
1233
1272
|
calculatedImageSettings: m,
|
|
1234
|
-
size:
|
|
1273
|
+
size: s,
|
|
1235
1274
|
numCells: E,
|
|
1236
1275
|
margin: p
|
|
1237
1276
|
}));
|
|
1238
1277
|
}
|
|
1239
1278
|
}));
|
|
1240
1279
|
let R = M, w = null;
|
|
1241
|
-
h != null && m != null && (m.excavation != null && (R =
|
|
1280
|
+
h != null && m != null && (m.excavation != null && (R = Yt(M, m.excavation)), w = /* @__PURE__ */ C(
|
|
1242
1281
|
"image",
|
|
1243
1282
|
{
|
|
1244
1283
|
href: h.src,
|
|
@@ -1256,22 +1295,22 @@ const tt = (r) => {
|
|
|
1256
1295
|
margin: p,
|
|
1257
1296
|
gradient: d
|
|
1258
1297
|
};
|
|
1259
|
-
return /* @__PURE__ */
|
|
1298
|
+
return /* @__PURE__ */ K(
|
|
1260
1299
|
"svg",
|
|
1261
1300
|
{
|
|
1262
|
-
height:
|
|
1263
|
-
width:
|
|
1301
|
+
height: s,
|
|
1302
|
+
width: s,
|
|
1264
1303
|
viewBox: `0 0 ${E} ${E}`,
|
|
1265
1304
|
ref: f,
|
|
1266
1305
|
role: "img",
|
|
1267
1306
|
"aria-label": ($ == null ? void 0 : $["aria-label"]) || "QR Code",
|
|
1268
1307
|
...$,
|
|
1269
1308
|
children: [
|
|
1270
|
-
/* @__PURE__ */ C(
|
|
1271
|
-
/* @__PURE__ */ C(
|
|
1272
|
-
/* @__PURE__ */ C(
|
|
1273
|
-
/* @__PURE__ */ C(
|
|
1274
|
-
/* @__PURE__ */ C(
|
|
1309
|
+
/* @__PURE__ */ C(kt, { gradient: d }),
|
|
1310
|
+
/* @__PURE__ */ C(gt, { background: l, numCells: E }),
|
|
1311
|
+
/* @__PURE__ */ C(Ht, { settings: o, ...A }),
|
|
1312
|
+
/* @__PURE__ */ C(zt, { settings: n, ...A }),
|
|
1313
|
+
/* @__PURE__ */ C(Bt, { settings: a, ...A }),
|
|
1275
1314
|
w
|
|
1276
1315
|
]
|
|
1277
1316
|
}
|