@lglab/react-qr-code 1.4.4 → 1.4.9
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 +361 -374
- package/package.json +12 -12
package/dist/index.es.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { jsx as C, jsxs as K, Fragment as
|
|
2
|
-
import { useMemo as
|
|
1
|
+
import { jsx as C, jsxs as K, Fragment as rt } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as L, useCallback as it, useId as at, forwardRef as ct, useRef as lt, useImperativeHandle as ht } from "react";
|
|
3
3
|
const ut = /\.?0+$/;
|
|
4
|
-
function dt(
|
|
5
|
-
return
|
|
4
|
+
function dt(s) {
|
|
5
|
+
return s.toFixed(7).replace(ut, "");
|
|
6
6
|
}
|
|
7
|
-
const W = (
|
|
8
|
-
const a =
|
|
7
|
+
const W = (s) => {
|
|
8
|
+
const a = s % 360 * (Math.PI / 180), c = Math.max(0, Math.min(100, 50 - 50 * Math.cos(a))), i = Math.max(0, Math.min(100, 50 - 50 * Math.sin(a))), o = Math.max(0, Math.min(100, 50 + 50 * Math.cos(a))), u = Math.max(0, Math.min(100, 50 + 50 * Math.sin(a)));
|
|
9
9
|
return {
|
|
10
10
|
x1: `${c}%`,
|
|
11
11
|
y1: `${i}%`,
|
|
12
|
-
x2: `${
|
|
12
|
+
x2: `${o}%`,
|
|
13
13
|
y2: `${u}%`
|
|
14
14
|
};
|
|
15
|
-
}, J = (
|
|
16
|
-
const
|
|
17
|
-
let
|
|
15
|
+
}, J = (s, a, c, i) => {
|
|
16
|
+
const o = c / 2, u = o / 2, l = Math.PI / i;
|
|
17
|
+
let m = "";
|
|
18
18
|
for (let f = 0; f < 2 * i; f++) {
|
|
19
|
-
const e = f * l - Math.PI / 2, n = f % 2 === 0 ?
|
|
20
|
-
|
|
19
|
+
const e = f * l - Math.PI / 2, n = f % 2 === 0 ? o : u, t = s + n * Math.cos(e), r = a + n * Math.sin(e);
|
|
20
|
+
m += `${f === 0 ? "M" : "L"} ${t},${r} `;
|
|
21
21
|
}
|
|
22
|
-
return
|
|
23
|
-
}, tt = (
|
|
22
|
+
return m + "Z";
|
|
23
|
+
}, tt = (s, a, c, i) => `M ${s} ${a}Q ${s + i} ${a + c / 2}, ${s} ${a + c}Q ${s + c / 2} ${a + c - i}, ${s + c} ${a + c}Q ${s + c - i} ${a + c / 2}, ${s + c} ${a}Q ${s + c / 2} ${a + i}, ${s} ${a}Z`, et = (s, a, c) => {
|
|
24
24
|
const i = c / 8;
|
|
25
|
-
return `M ${
|
|
25
|
+
return `M ${s + c} ${a + i * 3}
|
|
26
26
|
V ${a + i}
|
|
27
27
|
h -${i}
|
|
28
28
|
V ${a}
|
|
29
|
-
H ${
|
|
29
|
+
H ${s + i * 5}
|
|
30
30
|
v ${i}
|
|
31
|
-
H ${
|
|
31
|
+
H ${s + i * 3}
|
|
32
32
|
V ${a}
|
|
33
|
-
H ${
|
|
33
|
+
H ${s + i}
|
|
34
34
|
v ${i}
|
|
35
|
-
H ${
|
|
35
|
+
H ${s}
|
|
36
36
|
v ${i * 2}
|
|
37
37
|
h ${i}
|
|
38
38
|
v ${i * 2}
|
|
39
|
-
H ${
|
|
39
|
+
H ${s}
|
|
40
40
|
v ${i * 2}
|
|
41
41
|
h ${i}
|
|
42
42
|
v ${i}
|
|
@@ -52,8 +52,8 @@ const W = (o) => {
|
|
|
52
52
|
V ${a + i * 3}
|
|
53
53
|
h ${i}
|
|
54
54
|
Z`;
|
|
55
|
-
},
|
|
56
|
-
let i = !1,
|
|
55
|
+
}, nt = (s, a, c) => {
|
|
56
|
+
let i = !1, o = 0;
|
|
57
57
|
return [
|
|
58
58
|
"M",
|
|
59
59
|
1,
|
|
@@ -165,18 +165,17 @@ const W = (o) => {
|
|
|
165
165
|
1,
|
|
166
166
|
0.3262506,
|
|
167
167
|
"z"
|
|
168
|
-
].map((u) => typeof u == "string" ? (
|
|
169
|
-
},
|
|
168
|
+
].map((u) => typeof u == "string" ? (o = 0, i = u.toUpperCase() == u, u) : (o++, u = u * c, i && (u += o % 2 == 1 ? s : a), dt(u))).join(" ");
|
|
169
|
+
}, k = {
|
|
170
170
|
"data-testid": "background"
|
|
171
|
-
}, $t = ({ background:
|
|
172
|
-
|
|
173
|
-
if (!o)
|
|
171
|
+
}, $t = ({ background: s, bgGradientId: a, numCells: c }) => {
|
|
172
|
+
if (!s)
|
|
174
173
|
return null;
|
|
175
|
-
if (typeof
|
|
176
|
-
return /* @__PURE__ */ C("path", { fill:
|
|
177
|
-
const i = W(
|
|
178
|
-
return /* @__PURE__ */ K(
|
|
179
|
-
/* @__PURE__ */ C("defs", { children:
|
|
174
|
+
if (typeof s == "string")
|
|
175
|
+
return /* @__PURE__ */ C("path", { fill: s, d: `M0,0 h${c}v${c}H0z`, ...k });
|
|
176
|
+
const i = W(s?.rotation || 0);
|
|
177
|
+
return /* @__PURE__ */ K(rt, { children: [
|
|
178
|
+
/* @__PURE__ */ C("defs", { children: s.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: a, gradientUnits: "userSpaceOnUse", ...i, children: s.stops?.map((o, u) => /* @__PURE__ */ C("stop", { offset: o.offset, stopColor: o.color }, u)) }) : /* @__PURE__ */ C(
|
|
180
179
|
"radialGradient",
|
|
181
180
|
{
|
|
182
181
|
id: a,
|
|
@@ -184,7 +183,7 @@ const W = (o) => {
|
|
|
184
183
|
cx: "50%",
|
|
185
184
|
cy: "50%",
|
|
186
185
|
r: "50%",
|
|
187
|
-
children:
|
|
186
|
+
children: s.stops?.map((o, u) => /* @__PURE__ */ C("stop", { offset: o.offset, stopColor: o.color }, u))
|
|
188
187
|
}
|
|
189
188
|
) }),
|
|
190
189
|
/* @__PURE__ */ C(
|
|
@@ -192,28 +191,23 @@ const W = (o) => {
|
|
|
192
191
|
{
|
|
193
192
|
fill: `url(#${a})`,
|
|
194
193
|
d: `M0,0 h${c}v${c}H0z`,
|
|
195
|
-
...
|
|
194
|
+
...k
|
|
196
195
|
}
|
|
197
196
|
)
|
|
198
197
|
] });
|
|
199
198
|
};
|
|
200
|
-
/**
|
|
201
|
-
* @license QR Code generator library (TypeScript)
|
|
202
|
-
* Copyright (c) Project Nayuki.
|
|
203
|
-
* SPDX-License-Identifier: MIT
|
|
204
|
-
*/
|
|
205
199
|
var S;
|
|
206
|
-
((
|
|
200
|
+
((s) => {
|
|
207
201
|
const l = class l {
|
|
208
202
|
/*-- Constructor (low level) and fields --*/
|
|
209
203
|
// Creates a new QR Code with the given version number,
|
|
210
204
|
// error correction level, data codeword bytes, and mask number.
|
|
211
205
|
// This is a low-level API that most users should not use directly.
|
|
212
206
|
// A mid-level API is the encodeSegments() function.
|
|
213
|
-
constructor(e, n, t,
|
|
207
|
+
constructor(e, n, t, r) {
|
|
214
208
|
if (this.version = e, this.errorCorrectionLevel = n, this.modules = [], this.isFunction = [], e < l.MIN_VERSION || e > l.MAX_VERSION)
|
|
215
209
|
throw new RangeError("Version value out of range");
|
|
216
|
-
if (
|
|
210
|
+
if (r < -1 || r > 7)
|
|
217
211
|
throw new RangeError("Mask value out of range");
|
|
218
212
|
this.size = e * 4 + 17;
|
|
219
213
|
let h = [];
|
|
@@ -223,15 +217,15 @@ var S;
|
|
|
223
217
|
this.modules.push(h.slice()), this.isFunction.push(h.slice());
|
|
224
218
|
this.drawFunctionPatterns();
|
|
225
219
|
const $ = this.addEccAndInterleave(t);
|
|
226
|
-
if (this.drawCodewords($),
|
|
220
|
+
if (this.drawCodewords($), r == -1) {
|
|
227
221
|
let d = 1e9;
|
|
228
|
-
for (let
|
|
229
|
-
this.applyMask(
|
|
230
|
-
const
|
|
231
|
-
|
|
222
|
+
for (let M = 0; M < 8; M++) {
|
|
223
|
+
this.applyMask(M), this.drawFormatBits(M);
|
|
224
|
+
const g = this.getPenaltyScore();
|
|
225
|
+
g < d && (r = M, d = g), this.applyMask(M);
|
|
232
226
|
}
|
|
233
227
|
}
|
|
234
|
-
|
|
228
|
+
o(0 <= r && r <= 7), this.mask = r, this.applyMask(r), this.drawFormatBits(r), this.isFunction = [];
|
|
235
229
|
}
|
|
236
230
|
/*-- Static factory functions (high level) --*/
|
|
237
231
|
// Returns a QR Code representing the given Unicode text string at the given error correction level.
|
|
@@ -240,7 +234,7 @@ var S;
|
|
|
240
234
|
// QR Code version is automatically chosen for the output. The ECC level of the result may be higher than the
|
|
241
235
|
// ecl argument if it can be done without increasing the version.
|
|
242
236
|
static encodeText(e, n) {
|
|
243
|
-
const t =
|
|
237
|
+
const t = s.QrSegment.makeSegments(e);
|
|
244
238
|
return l.encodeSegments(t, n);
|
|
245
239
|
}
|
|
246
240
|
// Returns a QR Code representing the given binary data at the given error correction level.
|
|
@@ -248,7 +242,7 @@ var S;
|
|
|
248
242
|
// bytes allowed is 2953. The smallest possible QR Code version is automatically chosen for the output.
|
|
249
243
|
// The ECC level of the result may be higher than the ecl argument if it can be done without increasing the version.
|
|
250
244
|
static encodeBinary(e, n) {
|
|
251
|
-
const t =
|
|
245
|
+
const t = s.QrSegment.makeBytes(e);
|
|
252
246
|
return l.encodeSegments([t], n);
|
|
253
247
|
}
|
|
254
248
|
/*-- Static factory functions (mid level) --*/
|
|
@@ -261,36 +255,36 @@ var S;
|
|
|
261
255
|
// This function allows the user to create a custom sequence of segments that switches
|
|
262
256
|
// between modes (such as alphanumeric and byte) to encode text in less space.
|
|
263
257
|
// This is a mid-level API; the high-level API is encodeText() and encodeBinary().
|
|
264
|
-
static encodeSegments(e, n, t = 1,
|
|
265
|
-
if (!(l.MIN_VERSION <= t && t <=
|
|
258
|
+
static encodeSegments(e, n, t = 1, r = 40, h = -1, $ = !0) {
|
|
259
|
+
if (!(l.MIN_VERSION <= t && t <= r && r <= l.MAX_VERSION) || h < -1 || h > 7)
|
|
266
260
|
throw new RangeError("Invalid value");
|
|
267
|
-
let d,
|
|
261
|
+
let d, M;
|
|
268
262
|
for (d = t; ; d++) {
|
|
269
|
-
const
|
|
270
|
-
if (
|
|
271
|
-
|
|
263
|
+
const p = l.getNumDataCodewords(d, n) * 8, N = u.getTotalBits(e, d);
|
|
264
|
+
if (N <= p) {
|
|
265
|
+
M = N;
|
|
272
266
|
break;
|
|
273
267
|
}
|
|
274
|
-
if (d >=
|
|
268
|
+
if (d >= r)
|
|
275
269
|
throw new RangeError("Data too long");
|
|
276
270
|
}
|
|
277
|
-
for (const
|
|
278
|
-
$ &&
|
|
279
|
-
let
|
|
280
|
-
for (const
|
|
281
|
-
c(
|
|
282
|
-
for (const
|
|
283
|
-
|
|
271
|
+
for (const p of [l.Ecc.MEDIUM, l.Ecc.QUARTILE, l.Ecc.HIGH])
|
|
272
|
+
$ && M <= l.getNumDataCodewords(d, p) * 8 && (n = p);
|
|
273
|
+
let g = [];
|
|
274
|
+
for (const p of e) {
|
|
275
|
+
c(p.mode.modeBits, 4, g), c(p.numChars, p.mode.numCharCountBits(d), g);
|
|
276
|
+
for (const N of p.getData())
|
|
277
|
+
g.push(N);
|
|
284
278
|
}
|
|
285
|
-
|
|
279
|
+
o(g.length == M);
|
|
286
280
|
const A = l.getNumDataCodewords(d, n) * 8;
|
|
287
|
-
|
|
288
|
-
for (let
|
|
289
|
-
c(
|
|
290
|
-
let
|
|
291
|
-
for (;
|
|
292
|
-
|
|
293
|
-
return
|
|
281
|
+
o(g.length <= A), c(0, Math.min(4, A - g.length), g), c(0, (8 - g.length % 8) % 8, g), o(g.length % 8 == 0);
|
|
282
|
+
for (let p = 236; g.length < A; p ^= 253)
|
|
283
|
+
c(p, 8, g);
|
|
284
|
+
let E = [];
|
|
285
|
+
for (; E.length * 8 < g.length; )
|
|
286
|
+
E.push(0);
|
|
287
|
+
return g.forEach((p, N) => E[N >>> 3] |= p << 7 - (N & 7)), new l(d, n, E, h);
|
|
294
288
|
}
|
|
295
289
|
/*-- Accessor methods --*/
|
|
296
290
|
// Returns the color of the module (pixel) at the given coordinates, which is false
|
|
@@ -311,8 +305,8 @@ var S;
|
|
|
311
305
|
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
|
312
306
|
const e = this.getAlignmentPatternPositions(), n = e.length;
|
|
313
307
|
for (let t = 0; t < n; t++)
|
|
314
|
-
for (let
|
|
315
|
-
t == 0 &&
|
|
308
|
+
for (let r = 0; r < n; r++)
|
|
309
|
+
t == 0 && r == 0 || t == 0 && r == n - 1 || t == n - 1 && r == 0 || this.drawAlignmentPattern(e[t], e[r]);
|
|
316
310
|
this.drawFormatBits(0), this.drawVersion();
|
|
317
311
|
}
|
|
318
312
|
// Draws two copies of the format bits (with its own error correction code)
|
|
@@ -322,17 +316,17 @@ var S;
|
|
|
322
316
|
let t = n;
|
|
323
317
|
for (let h = 0; h < 10; h++)
|
|
324
318
|
t = t << 1 ^ (t >>> 9) * 1335;
|
|
325
|
-
const
|
|
326
|
-
r
|
|
319
|
+
const r = (n << 10 | t) ^ 21522;
|
|
320
|
+
o(r >>> 15 == 0);
|
|
327
321
|
for (let h = 0; h <= 5; h++)
|
|
328
|
-
this.setFunctionModule(8, h, i(
|
|
329
|
-
this.setFunctionModule(8, 7, i(
|
|
322
|
+
this.setFunctionModule(8, h, i(r, h));
|
|
323
|
+
this.setFunctionModule(8, 7, i(r, 6)), this.setFunctionModule(8, 8, i(r, 7)), this.setFunctionModule(7, 8, i(r, 8));
|
|
330
324
|
for (let h = 9; h < 15; h++)
|
|
331
|
-
this.setFunctionModule(14 - h, 8, i(
|
|
325
|
+
this.setFunctionModule(14 - h, 8, i(r, h));
|
|
332
326
|
for (let h = 0; h < 8; h++)
|
|
333
|
-
this.setFunctionModule(this.size - 1 - h, 8, i(
|
|
327
|
+
this.setFunctionModule(this.size - 1 - h, 8, i(r, h));
|
|
334
328
|
for (let h = 8; h < 15; h++)
|
|
335
|
-
this.setFunctionModule(8, this.size - 15 + h, i(
|
|
329
|
+
this.setFunctionModule(8, this.size - 15 + h, i(r, h));
|
|
336
330
|
this.setFunctionModule(8, this.size - 8, !0);
|
|
337
331
|
}
|
|
338
332
|
// Draws two copies of the version bits (with its own error correction code),
|
|
@@ -344,18 +338,18 @@ var S;
|
|
|
344
338
|
for (let t = 0; t < 12; t++)
|
|
345
339
|
e = e << 1 ^ (e >>> 11) * 7973;
|
|
346
340
|
const n = this.version << 12 | e;
|
|
347
|
-
|
|
341
|
+
o(n >>> 18 == 0);
|
|
348
342
|
for (let t = 0; t < 18; t++) {
|
|
349
|
-
const
|
|
350
|
-
this.setFunctionModule(h, $,
|
|
343
|
+
const r = i(n, t), h = this.size - 11 + t % 3, $ = Math.floor(t / 3);
|
|
344
|
+
this.setFunctionModule(h, $, r), this.setFunctionModule($, h, r);
|
|
351
345
|
}
|
|
352
346
|
}
|
|
353
347
|
// Draws a 9*9 finder pattern including the border separator,
|
|
354
348
|
// with the center module at (x, y). Modules can be out of bounds.
|
|
355
349
|
drawFinderPattern(e, n) {
|
|
356
350
|
for (let t = -4; t <= 4; t++)
|
|
357
|
-
for (let
|
|
358
|
-
const h = Math.max(Math.abs(
|
|
351
|
+
for (let r = -4; r <= 4; r++) {
|
|
352
|
+
const h = Math.max(Math.abs(r), Math.abs(t)), $ = e + r, d = n + t;
|
|
359
353
|
0 <= $ && $ < this.size && 0 <= d && d < this.size && this.setFunctionModule($, d, h != 2 && h != 4);
|
|
360
354
|
}
|
|
361
355
|
}
|
|
@@ -363,8 +357,8 @@ var S;
|
|
|
363
357
|
// at (x, y). All modules must be in bounds.
|
|
364
358
|
drawAlignmentPattern(e, n) {
|
|
365
359
|
for (let t = -2; t <= 2; t++)
|
|
366
|
-
for (let
|
|
367
|
-
this.setFunctionModule(e +
|
|
360
|
+
for (let r = -2; r <= 2; r++)
|
|
361
|
+
this.setFunctionModule(e + r, n + t, Math.max(Math.abs(r), Math.abs(t)) != 1);
|
|
368
362
|
}
|
|
369
363
|
// Sets the color of a module and marks it as a function module.
|
|
370
364
|
// Only used by the constructor. Coordinates must be in bounds.
|
|
@@ -378,21 +372,21 @@ var S;
|
|
|
378
372
|
const n = this.version, t = this.errorCorrectionLevel;
|
|
379
373
|
if (e.length != l.getNumDataCodewords(n, t))
|
|
380
374
|
throw new RangeError("Invalid argument");
|
|
381
|
-
const
|
|
382
|
-
let
|
|
375
|
+
const r = l.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][n], h = l.ECC_CODEWORDS_PER_BLOCK[t.ordinal][n], $ = Math.floor(l.getNumRawDataModules(n) / 8), d = r - $ % r, M = Math.floor($ / r);
|
|
376
|
+
let g = [];
|
|
383
377
|
const A = l.reedSolomonComputeDivisor(h);
|
|
384
|
-
for (let
|
|
385
|
-
let I = e.slice(
|
|
386
|
-
|
|
378
|
+
for (let p = 0, N = 0; p < r; p++) {
|
|
379
|
+
let I = e.slice(N, N + M - h + (p < d ? 0 : 1));
|
|
380
|
+
N += I.length;
|
|
387
381
|
const w = l.reedSolomonComputeRemainder(I, A);
|
|
388
|
-
|
|
382
|
+
p < d && I.push(0), g.push(I.concat(w));
|
|
389
383
|
}
|
|
390
|
-
let
|
|
391
|
-
for (let
|
|
392
|
-
|
|
393
|
-
(
|
|
384
|
+
let E = [];
|
|
385
|
+
for (let p = 0; p < g[0].length; p++)
|
|
386
|
+
g.forEach((N, I) => {
|
|
387
|
+
(p != M - h || I >= d) && E.push(N[p]);
|
|
394
388
|
});
|
|
395
|
-
return
|
|
389
|
+
return o(E.length == $), E;
|
|
396
390
|
}
|
|
397
391
|
// Draws the given sequence of 8-bit codewords (data and error correction) onto the entire
|
|
398
392
|
// data area of this QR Code. Function modules need to be marked off before this is called.
|
|
@@ -402,13 +396,13 @@ var S;
|
|
|
402
396
|
let n = 0;
|
|
403
397
|
for (let t = this.size - 1; t >= 1; t -= 2) {
|
|
404
398
|
t == 6 && (t = 5);
|
|
405
|
-
for (let
|
|
399
|
+
for (let r = 0; r < this.size; r++)
|
|
406
400
|
for (let h = 0; h < 2; h++) {
|
|
407
|
-
const $ = t - h,
|
|
408
|
-
!this.isFunction[
|
|
401
|
+
const $ = t - h, M = (t + 1 & 2) == 0 ? this.size - 1 - r : r;
|
|
402
|
+
!this.isFunction[M][$] && n < e.length * 8 && (this.modules[M][$] = i(e[n >>> 3], 7 - (n & 7)), n++);
|
|
409
403
|
}
|
|
410
404
|
}
|
|
411
|
-
|
|
405
|
+
o(n == e.length * 8);
|
|
412
406
|
}
|
|
413
407
|
// XORs the codeword modules in this QR Code with the given mask pattern.
|
|
414
408
|
// The function modules must be marked and the codeword bits must be drawn
|
|
@@ -420,36 +414,36 @@ var S;
|
|
|
420
414
|
throw new RangeError("Mask value out of range");
|
|
421
415
|
for (let n = 0; n < this.size; n++)
|
|
422
416
|
for (let t = 0; t < this.size; t++) {
|
|
423
|
-
let
|
|
417
|
+
let r;
|
|
424
418
|
switch (e) {
|
|
425
419
|
case 0:
|
|
426
|
-
|
|
420
|
+
r = (t + n) % 2 == 0;
|
|
427
421
|
break;
|
|
428
422
|
case 1:
|
|
429
|
-
|
|
423
|
+
r = n % 2 == 0;
|
|
430
424
|
break;
|
|
431
425
|
case 2:
|
|
432
|
-
|
|
426
|
+
r = t % 3 == 0;
|
|
433
427
|
break;
|
|
434
428
|
case 3:
|
|
435
|
-
|
|
429
|
+
r = (t + n) % 3 == 0;
|
|
436
430
|
break;
|
|
437
431
|
case 4:
|
|
438
|
-
|
|
432
|
+
r = (Math.floor(t / 3) + Math.floor(n / 2)) % 2 == 0;
|
|
439
433
|
break;
|
|
440
434
|
case 5:
|
|
441
|
-
|
|
435
|
+
r = t * n % 2 + t * n % 3 == 0;
|
|
442
436
|
break;
|
|
443
437
|
case 6:
|
|
444
|
-
|
|
438
|
+
r = (t * n % 2 + t * n % 3) % 2 == 0;
|
|
445
439
|
break;
|
|
446
440
|
case 7:
|
|
447
|
-
|
|
441
|
+
r = ((t + n) % 2 + t * n % 3) % 2 == 0;
|
|
448
442
|
break;
|
|
449
443
|
default:
|
|
450
444
|
throw new Error("Unreachable");
|
|
451
445
|
}
|
|
452
|
-
!this.isFunction[n][t] &&
|
|
446
|
+
!this.isFunction[n][t] && r && (this.modules[n][t] = !this.modules[n][t]);
|
|
453
447
|
}
|
|
454
448
|
}
|
|
455
449
|
// Calculates and returns the penalty score based on state of this QR Code's current modules.
|
|
@@ -457,16 +451,16 @@ var S;
|
|
|
457
451
|
getPenaltyScore() {
|
|
458
452
|
let e = 0;
|
|
459
453
|
for (let h = 0; h < this.size; h++) {
|
|
460
|
-
let $ = !1, d = 0,
|
|
461
|
-
for (let
|
|
462
|
-
this.modules[h][
|
|
463
|
-
e += this.finderPenaltyTerminateAndCount($, d,
|
|
454
|
+
let $ = !1, d = 0, M = [0, 0, 0, 0, 0, 0, 0];
|
|
455
|
+
for (let g = 0; g < this.size; g++)
|
|
456
|
+
this.modules[h][g] == $ ? (d++, d == 5 ? e += l.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, M), $ || (e += this.finderPenaltyCountPatterns(M) * l.PENALTY_N3), $ = this.modules[h][g], d = 1);
|
|
457
|
+
e += this.finderPenaltyTerminateAndCount($, d, M) * l.PENALTY_N3;
|
|
464
458
|
}
|
|
465
459
|
for (let h = 0; h < this.size; h++) {
|
|
466
|
-
let $ = !1, d = 0,
|
|
467
|
-
for (let
|
|
468
|
-
this.modules[
|
|
469
|
-
e += this.finderPenaltyTerminateAndCount($, d,
|
|
460
|
+
let $ = !1, d = 0, M = [0, 0, 0, 0, 0, 0, 0];
|
|
461
|
+
for (let g = 0; g < this.size; g++)
|
|
462
|
+
this.modules[g][h] == $ ? (d++, d == 5 ? e += l.PENALTY_N1 : d > 5 && e++) : (this.finderPenaltyAddHistory(d, M), $ || (e += this.finderPenaltyCountPatterns(M) * l.PENALTY_N3), $ = this.modules[g][h], d = 1);
|
|
463
|
+
e += this.finderPenaltyTerminateAndCount($, d, M) * l.PENALTY_N3;
|
|
470
464
|
}
|
|
471
465
|
for (let h = 0; h < this.size - 1; h++)
|
|
472
466
|
for (let $ = 0; $ < this.size - 1; $++) {
|
|
@@ -476,8 +470,8 @@ var S;
|
|
|
476
470
|
let n = 0;
|
|
477
471
|
for (const h of this.modules)
|
|
478
472
|
n = h.reduce(($, d) => $ + (d ? 1 : 0), n);
|
|
479
|
-
const t = this.size * this.size,
|
|
480
|
-
return
|
|
473
|
+
const t = this.size * this.size, r = Math.ceil(Math.abs(n * 20 - t * 10) / t) - 1;
|
|
474
|
+
return o(0 <= r && r <= 9), e += r * l.PENALTY_N4, o(0 <= e && e <= 2568888), e;
|
|
481
475
|
}
|
|
482
476
|
/*-- Private helper functions --*/
|
|
483
477
|
// Returns an ascending list of positions of alignment patterns for this version number.
|
|
@@ -489,8 +483,8 @@ var S;
|
|
|
489
483
|
{
|
|
490
484
|
const e = Math.floor(this.version / 7) + 2, n = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
|
|
491
485
|
let t = [6];
|
|
492
|
-
for (let
|
|
493
|
-
t.splice(1, 0,
|
|
486
|
+
for (let r = this.size - 7; t.length < e; r -= n)
|
|
487
|
+
t.splice(1, 0, r);
|
|
494
488
|
return t;
|
|
495
489
|
}
|
|
496
490
|
}
|
|
@@ -505,7 +499,7 @@ var S;
|
|
|
505
499
|
const t = Math.floor(e / 7) + 2;
|
|
506
500
|
n -= (25 * t - 10) * t - 55, e >= 7 && (n -= 36);
|
|
507
501
|
}
|
|
508
|
-
return
|
|
502
|
+
return o(208 <= n && n <= 29648), n;
|
|
509
503
|
}
|
|
510
504
|
// Returns the number of 8-bit data (i.e. not error correction) codewords contained in any
|
|
511
505
|
// QR Code of the given version number and error correction level, with remainder bits discarded.
|
|
@@ -519,11 +513,11 @@ var S;
|
|
|
519
513
|
if (e < 1 || e > 255)
|
|
520
514
|
throw new RangeError("Degree out of range");
|
|
521
515
|
let n = [];
|
|
522
|
-
for (let
|
|
516
|
+
for (let r = 0; r < e - 1; r++)
|
|
523
517
|
n.push(0);
|
|
524
518
|
n.push(1);
|
|
525
519
|
let t = 1;
|
|
526
|
-
for (let
|
|
520
|
+
for (let r = 0; r < e; r++) {
|
|
527
521
|
for (let h = 0; h < n.length; h++)
|
|
528
522
|
n[h] = l.reedSolomonMultiply(n[h], t), h + 1 < n.length && (n[h] ^= n[h + 1]);
|
|
529
523
|
t = l.reedSolomonMultiply(t, 2);
|
|
@@ -532,9 +526,9 @@ var S;
|
|
|
532
526
|
}
|
|
533
527
|
// Returns the Reed-Solomon error correction codeword for the given data and divisor polynomials.
|
|
534
528
|
static reedSolomonComputeRemainder(e, n) {
|
|
535
|
-
let t = n.map((
|
|
536
|
-
for (const
|
|
537
|
-
const h =
|
|
529
|
+
let t = n.map((r) => 0);
|
|
530
|
+
for (const r of e) {
|
|
531
|
+
const h = r ^ t.shift();
|
|
538
532
|
t.push(0), n.forEach(($, d) => t[d] ^= l.reedSolomonMultiply($, h));
|
|
539
533
|
}
|
|
540
534
|
return t;
|
|
@@ -545,15 +539,15 @@ var S;
|
|
|
545
539
|
if (e >>> 8 || n >>> 8)
|
|
546
540
|
throw new RangeError("Byte out of range");
|
|
547
541
|
let t = 0;
|
|
548
|
-
for (let
|
|
549
|
-
t = t << 1 ^ (t >>> 7) * 285, t ^= (n >>>
|
|
550
|
-
return
|
|
542
|
+
for (let r = 7; r >= 0; r--)
|
|
543
|
+
t = t << 1 ^ (t >>> 7) * 285, t ^= (n >>> r & 1) * e;
|
|
544
|
+
return o(t >>> 8 == 0), t;
|
|
551
545
|
}
|
|
552
546
|
// Can only be called immediately after a light run is added, and
|
|
553
547
|
// returns either 0, 1, or 2. A helper function for getPenaltyScore().
|
|
554
548
|
finderPenaltyCountPatterns(e) {
|
|
555
549
|
const n = e[1];
|
|
556
|
-
|
|
550
|
+
o(n <= this.size * 3);
|
|
557
551
|
const t = n > 0 && e[2] == n && e[3] == n * 3 && e[4] == n && e[5] == n;
|
|
558
552
|
return (t && e[0] >= n * 4 && e[6] >= n ? 1 : 0) + (t && e[6] >= n * 4 && e[0] >= n ? 1 : 0);
|
|
559
553
|
}
|
|
@@ -590,7 +584,7 @@ var S;
|
|
|
590
584
|
// High
|
|
591
585
|
];
|
|
592
586
|
let a = l;
|
|
593
|
-
|
|
587
|
+
s.QrCode = a;
|
|
594
588
|
function c(f, e, n) {
|
|
595
589
|
if (e < 0 || e > 31 || f >>> e)
|
|
596
590
|
throw new RangeError("Value out of range");
|
|
@@ -600,11 +594,11 @@ var S;
|
|
|
600
594
|
function i(f, e) {
|
|
601
595
|
return (f >>> e & 1) != 0;
|
|
602
596
|
}
|
|
603
|
-
function
|
|
597
|
+
function o(f) {
|
|
604
598
|
if (!f)
|
|
605
599
|
throw new Error("Assertion error");
|
|
606
600
|
}
|
|
607
|
-
const
|
|
601
|
+
const m = class m {
|
|
608
602
|
/*-- Constructor (low level) and fields --*/
|
|
609
603
|
// Creates a new QR Code segment with the given attributes and data.
|
|
610
604
|
// The character count (numChars) must agree with the mode and the bit buffer length,
|
|
@@ -622,36 +616,36 @@ var S;
|
|
|
622
616
|
let n = [];
|
|
623
617
|
for (const t of e)
|
|
624
618
|
c(t, 8, n);
|
|
625
|
-
return new
|
|
619
|
+
return new m(m.Mode.BYTE, e.length, n);
|
|
626
620
|
}
|
|
627
621
|
// Returns a segment representing the given string of decimal digits encoded in numeric mode.
|
|
628
622
|
static makeNumeric(e) {
|
|
629
|
-
if (!
|
|
623
|
+
if (!m.isNumeric(e))
|
|
630
624
|
throw new RangeError("String contains non-numeric characters");
|
|
631
625
|
let n = [];
|
|
632
626
|
for (let t = 0; t < e.length; ) {
|
|
633
|
-
const
|
|
634
|
-
c(parseInt(e.substring(t, t +
|
|
627
|
+
const r = Math.min(e.length - t, 3);
|
|
628
|
+
c(parseInt(e.substring(t, t + r), 10), r * 3 + 1, n), t += r;
|
|
635
629
|
}
|
|
636
|
-
return new
|
|
630
|
+
return new m(m.Mode.NUMERIC, e.length, n);
|
|
637
631
|
}
|
|
638
632
|
// Returns a segment representing the given text string encoded in alphanumeric mode.
|
|
639
633
|
// The characters allowed are: 0 to 9, A to Z (uppercase only), space,
|
|
640
634
|
// dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
641
635
|
static makeAlphanumeric(e) {
|
|
642
|
-
if (!
|
|
636
|
+
if (!m.isAlphanumeric(e))
|
|
643
637
|
throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
644
638
|
let n = [], t;
|
|
645
639
|
for (t = 0; t + 2 <= e.length; t += 2) {
|
|
646
|
-
let
|
|
647
|
-
|
|
640
|
+
let r = m.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)) * 45;
|
|
641
|
+
r += m.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t + 1)), c(r, 11, n);
|
|
648
642
|
}
|
|
649
|
-
return t < e.length && c(
|
|
643
|
+
return t < e.length && c(m.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)), 6, n), new m(m.Mode.ALPHANUMERIC, e.length, n);
|
|
650
644
|
}
|
|
651
645
|
// Returns a new mutable list of zero or more segments to represent the given Unicode text string.
|
|
652
646
|
// The result may use various segment modes and switch modes to optimize the length of the bit stream.
|
|
653
647
|
static makeSegments(e) {
|
|
654
|
-
return e == "" ? [] :
|
|
648
|
+
return e == "" ? [] : m.isNumeric(e) ? [m.makeNumeric(e)] : m.isAlphanumeric(e) ? [m.makeAlphanumeric(e)] : [m.makeBytes(m.toUtf8ByteArray(e))];
|
|
655
649
|
}
|
|
656
650
|
// Returns a segment representing an Extended Channel Interpretation
|
|
657
651
|
// (ECI) designator with the given assignment value.
|
|
@@ -667,18 +661,18 @@ var S;
|
|
|
667
661
|
c(6, 3, n), c(e, 21, n);
|
|
668
662
|
else
|
|
669
663
|
throw new RangeError("ECI assignment value out of range");
|
|
670
|
-
return new
|
|
664
|
+
return new m(m.Mode.ECI, 0, n);
|
|
671
665
|
}
|
|
672
666
|
// Tests whether the given string can be encoded as a segment in numeric mode.
|
|
673
667
|
// A string is encodable iff each character is in the range 0 to 9.
|
|
674
668
|
static isNumeric(e) {
|
|
675
|
-
return
|
|
669
|
+
return m.NUMERIC_REGEX.test(e);
|
|
676
670
|
}
|
|
677
671
|
// Tests whether the given string can be encoded as a segment in alphanumeric mode.
|
|
678
672
|
// A string is encodable iff each character is in the following set: 0 to 9, A to Z
|
|
679
673
|
// (uppercase only), space, dollar, percent, asterisk, plus, hyphen, period, slash, colon.
|
|
680
674
|
static isAlphanumeric(e) {
|
|
681
|
-
return
|
|
675
|
+
return m.ALPHANUMERIC_REGEX.test(e);
|
|
682
676
|
}
|
|
683
677
|
/*-- Methods --*/
|
|
684
678
|
// Returns a new copy of the data bits of this segment.
|
|
@@ -689,11 +683,11 @@ var S;
|
|
|
689
683
|
// the given version. The result is infinity if a segment has too many characters to fit its length field.
|
|
690
684
|
static getTotalBits(e, n) {
|
|
691
685
|
let t = 0;
|
|
692
|
-
for (const
|
|
693
|
-
const h =
|
|
694
|
-
if (
|
|
686
|
+
for (const r of e) {
|
|
687
|
+
const h = r.mode.numCharCountBits(n);
|
|
688
|
+
if (r.numChars >= 1 << h)
|
|
695
689
|
return 1 / 0;
|
|
696
|
-
t += 4 + h +
|
|
690
|
+
t += 4 + h + r.bitData.length;
|
|
697
691
|
}
|
|
698
692
|
return t;
|
|
699
693
|
}
|
|
@@ -706,11 +700,11 @@ var S;
|
|
|
706
700
|
return n;
|
|
707
701
|
}
|
|
708
702
|
};
|
|
709
|
-
|
|
710
|
-
let u =
|
|
711
|
-
|
|
703
|
+
m.NUMERIC_REGEX = /^[0-9]*$/, m.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, m.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
704
|
+
let u = m;
|
|
705
|
+
s.QrSegment = u;
|
|
712
706
|
})(S || (S = {}));
|
|
713
|
-
((
|
|
707
|
+
((s) => {
|
|
714
708
|
((a) => {
|
|
715
709
|
const i = class i {
|
|
716
710
|
// The QR Code can tolerate about 30% erroneous codewords
|
|
@@ -722,9 +716,9 @@ var S;
|
|
|
722
716
|
i.LOW = new i(0, 1), i.MEDIUM = new i(1, 0), i.QUARTILE = new i(2, 3), i.HIGH = new i(3, 2);
|
|
723
717
|
let c = i;
|
|
724
718
|
a.Ecc = c;
|
|
725
|
-
})(
|
|
719
|
+
})(s.QrCode || (s.QrCode = {}));
|
|
726
720
|
})(S || (S = {}));
|
|
727
|
-
((
|
|
721
|
+
((s) => {
|
|
728
722
|
((a) => {
|
|
729
723
|
const i = class i {
|
|
730
724
|
/*-- Constructor and fields --*/
|
|
@@ -741,14 +735,14 @@ var S;
|
|
|
741
735
|
i.NUMERIC = new i(1, [10, 12, 14]), i.ALPHANUMERIC = new i(2, [9, 11, 13]), i.BYTE = new i(4, [8, 16, 16]), i.KANJI = new i(8, [8, 10, 12]), i.ECI = new i(7, [0, 0, 0]);
|
|
742
736
|
let c = i;
|
|
743
737
|
a.Mode = c;
|
|
744
|
-
})(
|
|
738
|
+
})(s.QrSegment || (s.QrSegment = {}));
|
|
745
739
|
})(S || (S = {}));
|
|
746
|
-
const
|
|
747
|
-
L:
|
|
748
|
-
M:
|
|
749
|
-
Q:
|
|
750
|
-
H:
|
|
751
|
-
}, pt = 128, mt = "M",
|
|
740
|
+
const b = S, ft = {
|
|
741
|
+
L: b.QrCode.Ecc.LOW,
|
|
742
|
+
M: b.QrCode.Ecc.MEDIUM,
|
|
743
|
+
Q: b.QrCode.Ecc.QUARTILE,
|
|
744
|
+
H: b.QrCode.Ecc.HIGH
|
|
745
|
+
}, pt = 128, mt = "M", gt = 1, Et = 4, ot = 5, H = "#000000", Mt = "square", Rt = "square", Nt = "square", It = "react-qr-code", Ct = "react-qr-code-gradient", wt = "react-qr-code-bg-gradient", At = 0.1, R = 7, T = 3, y = [
|
|
752
746
|
[1, 1, 1, 1, 1, 1, 1],
|
|
753
747
|
[1, 0, 0, 0, 0, 0, 1],
|
|
754
748
|
[1, 0, 0, 0, 0, 0, 1],
|
|
@@ -756,7 +750,7 @@ const U = S, ft = {
|
|
|
756
750
|
[1, 0, 0, 0, 0, 0, 1],
|
|
757
751
|
[1, 0, 0, 0, 0, 0, 1],
|
|
758
752
|
[1, 1, 1, 1, 1, 1, 1]
|
|
759
|
-
],
|
|
753
|
+
], st = {
|
|
760
754
|
"inpoint-sm": [0, 90, -90],
|
|
761
755
|
inpoint: [0, 90, -90],
|
|
762
756
|
"inpoint-lg": [0, 90, -90],
|
|
@@ -766,7 +760,7 @@ const U = S, ft = {
|
|
|
766
760
|
"leaf-sm": [0, 90, -90],
|
|
767
761
|
leaf: [0, 90, -90],
|
|
768
762
|
"leaf-lg": [0, 90, -90]
|
|
769
|
-
},
|
|
763
|
+
}, Q = {
|
|
770
764
|
"rounded-sm": 3,
|
|
771
765
|
rounded: 4,
|
|
772
766
|
"rounded-lg": 5,
|
|
@@ -803,258 +797,252 @@ const U = S, ft = {
|
|
|
803
797
|
[0, 0, 1, 1, 1, 0, 0],
|
|
804
798
|
[0, 0, 0, 0, 0, 0, 0],
|
|
805
799
|
[0, 0, 0, 0, 0, 0, 0]
|
|
806
|
-
], Pt = (
|
|
800
|
+
], Pt = (s) => s === "square" || s === "pinched-square" || s === "circle" || s === "star" || s === "heart" || s === "diamond" || s === "hashtag", Ot = (s, a) => s === "square-sm" ? 0.75 : a ? Math.random() * (1 - 0.75) + 0.75 : 1, D = (s, a, c) => {
|
|
807
801
|
const i = {
|
|
808
|
-
left:
|
|
809
|
-
right:
|
|
810
|
-
top: a === 0 ? !1 : c[a - 1][
|
|
811
|
-
bottom: a === c.length - 1 ? !1 : c[a + 1][
|
|
802
|
+
left: s === 0 ? !1 : c[a][s - 1],
|
|
803
|
+
right: s === c[a].length - 1 ? !1 : c[a][s + 1],
|
|
804
|
+
top: a === 0 ? !1 : c[a - 1][s],
|
|
805
|
+
bottom: a === c.length - 1 ? !1 : c[a + 1][s]
|
|
812
806
|
};
|
|
813
807
|
return {
|
|
814
808
|
...i,
|
|
815
809
|
count: Object.values(i).filter(Boolean).length
|
|
816
810
|
};
|
|
817
|
-
},
|
|
811
|
+
}, U = (s, a, c) => `M${s},${a}h${c}v${c}h-${c}Z`, F = (s, a, c) => `M${s},${a + c / 2}a${c / 2},${c / 2} 0 1,0 ${c},0a${c / 2},${c / 2} 0 1,0 -${c},0Z`, Tt = (s, a, c) => `M${s},${a + c / 2}l${c / 2},-${c / 2}l${c / 2},${c / 2}l-${c / 2},${c / 2}Z`, vt = (s, a) => `M ${s} ${a}
|
|
818
812
|
v 1
|
|
819
813
|
h 1
|
|
820
814
|
v -0.5
|
|
821
|
-
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, Y = (
|
|
815
|
+
a 0.5 0.5, 0, 0, 0, -0.5 -0.5`, Y = (s, a) => `M ${s + 1} ${a}
|
|
822
816
|
v 1
|
|
823
817
|
h -1
|
|
824
818
|
v -0.5
|
|
825
|
-
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, G = (
|
|
819
|
+
a 0.5 0.5, 0, 0, 1, 0.5 -0.5`, G = (s, a) => `M ${s} ${a}
|
|
826
820
|
v 1
|
|
827
821
|
h 0.5
|
|
828
822
|
a 0.5 0.5, 0, 0, 0, 0.5 -0.5
|
|
829
823
|
v -0.5
|
|
830
|
-
h -1`,
|
|
824
|
+
h -1`, Lt = (s, a) => `M ${s + 1} ${a}
|
|
831
825
|
v 1
|
|
832
826
|
h -0.5
|
|
833
827
|
a 0.5 0.5, 0, 0, 1, -0.5 -0.5
|
|
834
828
|
v -0.5
|
|
835
|
-
h 1`, j = (
|
|
829
|
+
h 1`, j = (s, a) => `M ${s} ${a}
|
|
836
830
|
v 1
|
|
837
831
|
h 0.5
|
|
838
|
-
a 0.5 0.5, 0, 0, 0, 0 -1`, V = (
|
|
832
|
+
a 0.5 0.5, 0, 0, 0, 0 -1`, V = (s, a) => `M ${s + 1} ${a}
|
|
839
833
|
v 1
|
|
840
834
|
h -0.5
|
|
841
|
-
a 0.5 0.5, 0, 0, 1, 0 -1`, X = (
|
|
835
|
+
a 0.5 0.5, 0, 0, 1, 0 -1`, X = (s, a) => `M ${s} ${a + 1}
|
|
842
836
|
h 1
|
|
843
837
|
v -0.5
|
|
844
|
-
a 0.5 0.5, 0, 0, 0, -1 0`, Z = (
|
|
838
|
+
a 0.5 0.5, 0, 0, 0, -1 0`, Z = (s, a) => `M ${s} ${a}
|
|
845
839
|
h 1
|
|
846
840
|
v 0.5
|
|
847
|
-
a 0.5 0.5, 0, 0, 1, -1 0`, St = (
|
|
848
|
-
x:
|
|
841
|
+
a 0.5 0.5, 0, 0, 1, -1 0`, St = (s, a, c) => `M ${s + 1} ${a}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}`, bt = ({
|
|
842
|
+
x: s,
|
|
849
843
|
y: a,
|
|
850
844
|
numCells: c
|
|
851
|
-
}) => {
|
|
852
|
-
|
|
853
|
-
return !!((i = B[o]) != null && i[a] || (r = B[o - c + 7]) != null && r[a] || (u = B[o]) != null && u[a - c + 7]);
|
|
854
|
-
}, bt = ({
|
|
855
|
-
x: o,
|
|
845
|
+
}) => !!(B[s]?.[a] || B[s - c + 7]?.[a] || B[s]?.[a - c + 7]), Ut = ({
|
|
846
|
+
x: s,
|
|
856
847
|
y: a,
|
|
857
848
|
radius: c
|
|
858
849
|
}) => {
|
|
859
|
-
const i = T - c,
|
|
860
|
-
return `M ${
|
|
850
|
+
const i = T - c, o = c / 2, u = T - o;
|
|
851
|
+
return `M ${s} ${a + o}v ${i}a ${o} ${o}, 0, 0, 0, ${o} ${o}h ${u}v ${-u}a ${o} ${o}, 0, 0, 0, ${-o} ${-o}h ${-i}H ${s}z`;
|
|
861
852
|
}, Dt = ({
|
|
862
|
-
x:
|
|
853
|
+
x: s,
|
|
863
854
|
y: a,
|
|
864
855
|
radius: c
|
|
865
856
|
}) => {
|
|
866
|
-
const i = T - c,
|
|
867
|
-
return `M ${
|
|
857
|
+
const i = T - c, o = c / 2, u = T - o;
|
|
858
|
+
return `M ${s} ${a + o}v ${i}a ${o} ${o}, 0, 0, 0, ${o} ${o}h ${u}v ${-u}a ${o} ${o}, 0, 0, 0, ${-o} ${-o}h ${-i}a ${o} ${o}, 0, 0, 0, ${-o} ${o}`;
|
|
868
859
|
}, Ft = ({
|
|
869
|
-
x:
|
|
860
|
+
x: s,
|
|
870
861
|
y: a,
|
|
871
862
|
numCells: c
|
|
872
|
-
}) => {
|
|
873
|
-
|
|
874
|
-
return !!((i = y[o]) != null && i[a] || (r = y[o - c + 7]) != null && r[a] || (u = y[o]) != null && u[a - c + 7]);
|
|
875
|
-
}, yt = ({
|
|
876
|
-
x: o,
|
|
863
|
+
}) => !!(y[s]?.[a] || y[s - c + 7]?.[a] || y[s]?.[a - c + 7]), yt = ({
|
|
864
|
+
x: s,
|
|
877
865
|
y: a,
|
|
878
866
|
radius: c
|
|
879
867
|
}) => {
|
|
880
|
-
const i =
|
|
881
|
-
return `M ${
|
|
868
|
+
const i = R - c, o = c / 2;
|
|
869
|
+
return `M ${s} ${a + o}v ${i}a ${o} ${o}, 0, 0, 0, ${o} ${o}h ${i}a ${o} ${o}, 0, 0, 0, ${o} ${-o}v ${-i}a ${o} ${o}, 0, 0, 0, ${-o} ${-o}h ${-i}a ${o} ${o}, 0, 0, 0, ${-o} ${o}M ${s + o} ${a + 1}h ${i}a ${o - 1} ${o - 1}, 0, 0, 1, ${o - 1} ${o - 1}v ${i}a ${o - 1} ${o - 1}, 0, 0, 1, ${-(o - 1)} ${o - 1}h ${-i}a ${o - 1} ${o - 1}, 0, 0, 1, ${-(o - 1)} ${-(o - 1)}v ${-i}a ${o - 1} ${o - 1}, 0, 0, 1, ${o - 1} ${-(o - 1)}`;
|
|
882
870
|
}, Bt = ({
|
|
883
|
-
x:
|
|
871
|
+
x: s,
|
|
884
872
|
y: a,
|
|
885
873
|
radius: c
|
|
886
874
|
}) => {
|
|
887
|
-
const i =
|
|
888
|
-
return `M ${
|
|
875
|
+
const i = R - c, o = c / 2, u = R - o;
|
|
876
|
+
return `M ${s} ${a + o}v ${i}a ${o} ${o}, 0, 0, 0, ${o} ${o}h ${u}v ${-u}a ${o} ${o}, 0, 0, 0, ${-o} ${-o}h ${-i}H ${s}zM ${s + o} ${a + 1}h ${i}a ${o - 1} ${o - 1}, 0, 0, 1, ${o - 1} ${o - 1}v ${u - 1}h ${-(u - 1)}a ${o - 1} ${o - 1}, 0, 0, 1, ${-(o - 1)} ${-(o - 1)}v ${-(u - 1)}z`;
|
|
889
877
|
}, Ht = ({
|
|
890
|
-
x:
|
|
878
|
+
x: s,
|
|
891
879
|
y: a,
|
|
892
880
|
radius: c
|
|
893
881
|
}) => {
|
|
894
|
-
const i =
|
|
895
|
-
return `M ${
|
|
896
|
-
}, _t = (
|
|
897
|
-
color:
|
|
898
|
-
style:
|
|
899
|
-
randomSize:
|
|
900
|
-
}), zt = (
|
|
901
|
-
color:
|
|
902
|
-
style:
|
|
903
|
-
}),
|
|
904
|
-
color:
|
|
905
|
-
style:
|
|
906
|
-
}),
|
|
907
|
-
modules:
|
|
882
|
+
const i = R - c, o = c / 2, u = R - o;
|
|
883
|
+
return `M ${s} ${a + o}v ${i}a ${o} ${o}, 0, 0, 0, ${o} ${o}h ${u}v ${-u}a ${o} ${o}, 0, 0, 0, ${-o} ${-o}h ${-i}a ${o} ${o}, 0, 0, 0, ${-o} ${o}M ${s + o} ${a + 1}h ${i}a ${o - 1} ${o - 1}, 0, 0, 1, ${o - 1} ${o - 1}v ${u - 1}h ${-(u - 1)}a ${o - 1} ${o - 1}, 0, 0, 1, ${-(o - 1)} ${-(o - 1)}v ${-i}a ${o - 1} ${o - 1}, 0, 0, 1, ${o - 1} ${-(o - 1)}`;
|
|
884
|
+
}, _t = (s) => ({
|
|
885
|
+
color: s?.color || H,
|
|
886
|
+
style: s?.style || Nt,
|
|
887
|
+
randomSize: s?.randomSize || !1
|
|
888
|
+
}), zt = (s) => ({
|
|
889
|
+
color: s?.color || H,
|
|
890
|
+
style: s?.style || Mt
|
|
891
|
+
}), kt = (s) => ({
|
|
892
|
+
color: s?.color || H,
|
|
893
|
+
style: s?.style || Rt
|
|
894
|
+
}), Qt = ({
|
|
895
|
+
modules: s,
|
|
908
896
|
margin: a,
|
|
909
897
|
settings: c,
|
|
910
898
|
gradient: i,
|
|
911
|
-
gradientId:
|
|
899
|
+
gradientId: o
|
|
912
900
|
}) => {
|
|
913
|
-
const { color: u, style: l, randomSize:
|
|
901
|
+
const { color: u, style: l, randomSize: m } = L(
|
|
914
902
|
() => _t(c),
|
|
915
903
|
[c]
|
|
916
|
-
), f = [], e =
|
|
904
|
+
), f = [], e = s.length, n = Pt(l) && m, t = it(
|
|
917
905
|
() => Ot(l, n),
|
|
918
906
|
[l, n]
|
|
919
907
|
);
|
|
920
|
-
return
|
|
921
|
-
|
|
922
|
-
if (Ft({ x: d, y: h, numCells: e }) ||
|
|
908
|
+
return s.forEach((r, h) => {
|
|
909
|
+
r.forEach(($, d) => {
|
|
910
|
+
if (Ft({ x: d, y: h, numCells: e }) || bt({ x: d, y: h, numCells: e }))
|
|
923
911
|
return;
|
|
924
|
-
const
|
|
912
|
+
const M = t(), g = 1 * M, A = (1 - 1 * M) / 2, E = d + a + A, p = h + a + A;
|
|
925
913
|
if ($) {
|
|
926
914
|
if (l === "square" || l === "square-sm")
|
|
927
|
-
f.push(
|
|
915
|
+
f.push(U(E, p, g));
|
|
928
916
|
else if (l === "pinched-square")
|
|
929
|
-
f.push(tt(
|
|
917
|
+
f.push(tt(E, p, g, 0.25));
|
|
930
918
|
else if (l === "circle")
|
|
931
|
-
f.push(F(
|
|
919
|
+
f.push(F(E, p, g));
|
|
932
920
|
else if (l === "diamond")
|
|
933
|
-
f.push(Tt(
|
|
921
|
+
f.push(Tt(E, p, g));
|
|
934
922
|
else if (l === "star")
|
|
935
923
|
f.push(
|
|
936
|
-
J(
|
|
924
|
+
J(E + g / 2, p + g / 2, g * 1.1, ot)
|
|
937
925
|
);
|
|
938
926
|
else if (l === "heart")
|
|
939
|
-
f.push(
|
|
927
|
+
f.push(nt(E, p, g));
|
|
940
928
|
else if (l === "hashtag")
|
|
941
|
-
f.push(et(
|
|
929
|
+
f.push(et(E, p, g));
|
|
942
930
|
else if (l === "rounded") {
|
|
943
|
-
const { left:
|
|
944
|
-
O === 0 ? f.push(F(
|
|
931
|
+
const { left: N, right: I, top: w, bottom: P, count: O } = D(d, h, s);
|
|
932
|
+
O === 0 ? f.push(F(E, p, 1)) : O > 2 || N && I || w && P ? f.push(U(E, p, 1)) : O === 2 ? N && w ? f.push(G(E, p)) : w && I ? f.push(Lt(E, p)) : I && P ? f.push(Y(E, p)) : f.push(vt(E, p)) : w ? f.push(Z(E, p)) : I ? f.push(V(E, p)) : P ? f.push(X(E, p)) : f.push(j(E, p));
|
|
945
933
|
} else if (l === "leaf") {
|
|
946
|
-
const { left:
|
|
934
|
+
const { left: N, right: I, top: w, bottom: P, count: O } = D(d, h, s);
|
|
947
935
|
if (O === 0)
|
|
948
|
-
f.push(St(
|
|
949
|
-
else if (!
|
|
950
|
-
f.push(Y(
|
|
936
|
+
f.push(St(E, p, g));
|
|
937
|
+
else if (!N && !w) {
|
|
938
|
+
f.push(Y(E, p));
|
|
951
939
|
return;
|
|
952
|
-
} else !I && !P ? f.push(G(
|
|
940
|
+
} else !I && !P ? f.push(G(E, p)) : f.push(U(E, p, 1));
|
|
953
941
|
} else if (l === "vertical-line") {
|
|
954
|
-
const { left:
|
|
955
|
-
O === 0 ||
|
|
942
|
+
const { left: N, right: I, top: w, bottom: P, count: O } = D(d, h, s);
|
|
943
|
+
O === 0 || N && !(w || P) || I && !(w || P) ? f.push(F(E, p, 1)) : w && P ? f.push(U(E, p, 1)) : w && !P ? f.push(Z(E, p)) : P && !w && f.push(X(E, p));
|
|
956
944
|
} else if (l === "horizontal-line") {
|
|
957
|
-
const { left:
|
|
958
|
-
O === 0 || w && !(
|
|
945
|
+
const { left: N, right: I, top: w, bottom: P, count: O } = D(d, h, s);
|
|
946
|
+
O === 0 || w && !(N || I) || P && !(N || I) ? f.push(F(E, p, 1)) : N && I ? f.push(U(E, p, 1)) : N && !I ? f.push(j(E, p)) : I && !N && f.push(V(E, p));
|
|
959
947
|
}
|
|
960
948
|
}
|
|
961
949
|
});
|
|
962
950
|
}), /* @__PURE__ */ C(
|
|
963
951
|
"path",
|
|
964
952
|
{
|
|
965
|
-
fill: i ? `url(#${
|
|
953
|
+
fill: i ? `url(#${o})` : u,
|
|
966
954
|
d: f.join(""),
|
|
967
955
|
shapeRendering: l === "square" ? "crispEdges" : "geometricPrecision",
|
|
968
956
|
"data-testid": "data-modules"
|
|
969
957
|
}
|
|
970
958
|
);
|
|
971
|
-
},
|
|
959
|
+
}, v = {
|
|
972
960
|
"data-testid": "finder-patterns-inner"
|
|
973
961
|
}, qt = ({
|
|
974
|
-
modules:
|
|
962
|
+
modules: s,
|
|
975
963
|
margin: a,
|
|
976
964
|
settings: c,
|
|
977
965
|
gradient: i,
|
|
978
|
-
gradientId:
|
|
966
|
+
gradientId: o
|
|
979
967
|
}) => {
|
|
980
|
-
const { color: u, style: l } =
|
|
981
|
-
() =>
|
|
968
|
+
const { color: u, style: l } = L(
|
|
969
|
+
() => kt(c),
|
|
982
970
|
[c]
|
|
983
|
-
),
|
|
971
|
+
), m = i ? `url(#${o})` : u, f = L(
|
|
984
972
|
() => [
|
|
985
973
|
{ x: a + 2, y: a + 2 },
|
|
986
|
-
{ x:
|
|
987
|
-
{ x: a + 2, y:
|
|
974
|
+
{ x: s.length + a - R + 2, y: a + 2 },
|
|
975
|
+
{ x: a + 2, y: s.length + a - R + 2 }
|
|
988
976
|
],
|
|
989
|
-
[a,
|
|
977
|
+
[a, s.length]
|
|
990
978
|
), e = (n, t) => `finder-patterns-inner-${l}-${n}-${t}`;
|
|
991
979
|
if (l === "rounded-sm" || l === "rounded" || l === "rounded-lg" || l === "circle" || l === "square")
|
|
992
980
|
return f.map((n) => {
|
|
993
|
-
const { x: t, y:
|
|
981
|
+
const { x: t, y: r } = n;
|
|
994
982
|
return /* @__PURE__ */ C(
|
|
995
983
|
"rect",
|
|
996
984
|
{
|
|
997
985
|
x: t,
|
|
998
|
-
y:
|
|
986
|
+
y: r,
|
|
999
987
|
width: T,
|
|
1000
988
|
height: T,
|
|
1001
|
-
fill:
|
|
989
|
+
fill: m,
|
|
1002
990
|
rx: q[l],
|
|
1003
|
-
...
|
|
991
|
+
...v
|
|
1004
992
|
},
|
|
1005
|
-
e(t,
|
|
993
|
+
e(t, r)
|
|
1006
994
|
);
|
|
1007
995
|
});
|
|
1008
996
|
if (l === "pinched-square")
|
|
1009
997
|
return f.map((n) => {
|
|
1010
|
-
const { x: t, y:
|
|
1011
|
-
return /* @__PURE__ */ C("path", { fill:
|
|
998
|
+
const { x: t, y: r } = n, h = tt(t, r, T, 0.25);
|
|
999
|
+
return /* @__PURE__ */ C("path", { fill: m, d: h, ...v }, e(t, r));
|
|
1012
1000
|
});
|
|
1013
1001
|
if (l === "diamond")
|
|
1014
1002
|
return f.map((n) => {
|
|
1015
|
-
const { x: t, y:
|
|
1003
|
+
const { x: t, y: r } = n, h = Math.sqrt(1.5), $ = T / h, d = $ - $ / h;
|
|
1016
1004
|
return /* @__PURE__ */ C(
|
|
1017
1005
|
"rect",
|
|
1018
1006
|
{
|
|
1019
1007
|
x: t + d / 2,
|
|
1020
|
-
y:
|
|
1008
|
+
y: r + d / 2,
|
|
1021
1009
|
width: $,
|
|
1022
1010
|
height: $,
|
|
1023
|
-
fill:
|
|
1011
|
+
fill: m,
|
|
1024
1012
|
style: {
|
|
1025
1013
|
transform: "rotate(45deg)",
|
|
1026
1014
|
transformOrigin: "center",
|
|
1027
1015
|
transformBox: "fill-box"
|
|
1028
1016
|
},
|
|
1029
|
-
...
|
|
1017
|
+
...v
|
|
1030
1018
|
},
|
|
1031
|
-
e(t,
|
|
1019
|
+
e(t, r)
|
|
1032
1020
|
);
|
|
1033
1021
|
});
|
|
1034
1022
|
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") {
|
|
1035
|
-
const n = l === "leaf-sm" || l === "leaf" || l === "leaf-lg" ?
|
|
1036
|
-
return f.map((t,
|
|
1023
|
+
const n = l === "leaf-sm" || l === "leaf" || l === "leaf-lg" ? Ut : Dt;
|
|
1024
|
+
return f.map((t, r) => ({
|
|
1037
1025
|
...t,
|
|
1038
|
-
rotation:
|
|
1039
|
-
})).map(({ x: t, y:
|
|
1026
|
+
rotation: st[l][r]
|
|
1027
|
+
})).map(({ x: t, y: r, rotation: h }) => {
|
|
1040
1028
|
const $ = n({
|
|
1041
1029
|
x: t,
|
|
1042
|
-
y:
|
|
1030
|
+
y: r,
|
|
1043
1031
|
radius: q[l]
|
|
1044
1032
|
});
|
|
1045
1033
|
return /* @__PURE__ */ C(
|
|
1046
1034
|
"path",
|
|
1047
1035
|
{
|
|
1048
|
-
fill:
|
|
1036
|
+
fill: m,
|
|
1049
1037
|
d: $,
|
|
1050
1038
|
style: {
|
|
1051
1039
|
transform: `rotate(${h}deg)`,
|
|
1052
1040
|
transformOrigin: "center",
|
|
1053
1041
|
transformBox: "fill-box"
|
|
1054
1042
|
},
|
|
1055
|
-
...
|
|
1043
|
+
...v
|
|
1056
1044
|
},
|
|
1057
|
-
e(t,
|
|
1045
|
+
e(t, r)
|
|
1058
1046
|
);
|
|
1059
1047
|
});
|
|
1060
1048
|
}
|
|
@@ -1062,41 +1050,41 @@ const U = S, ft = {
|
|
|
1062
1050
|
return f.map(({ x: n, y: t }) => /* @__PURE__ */ C(
|
|
1063
1051
|
"path",
|
|
1064
1052
|
{
|
|
1065
|
-
fill:
|
|
1066
|
-
d:
|
|
1067
|
-
...
|
|
1053
|
+
fill: m,
|
|
1054
|
+
d: nt(n, t, T),
|
|
1055
|
+
...v
|
|
1068
1056
|
},
|
|
1069
1057
|
e(n, t)
|
|
1070
1058
|
));
|
|
1071
1059
|
if (l === "star")
|
|
1072
1060
|
return f.map(({ x: n, y: t }) => {
|
|
1073
|
-
const
|
|
1074
|
-
return /* @__PURE__ */ C("path", { fill:
|
|
1061
|
+
const r = n + T / 2, h = t + T / 2, $ = J(r, h, T * 1.2, ot);
|
|
1062
|
+
return /* @__PURE__ */ C("path", { fill: m, d: $, ...v }, e(n, t));
|
|
1075
1063
|
});
|
|
1076
1064
|
if (l === "hashtag")
|
|
1077
1065
|
return f.map(({ x: n, y: t }) => {
|
|
1078
|
-
const
|
|
1079
|
-
return /* @__PURE__ */ C("path", { fill:
|
|
1066
|
+
const r = et(n - 0.25, t - 0.25, 3.5);
|
|
1067
|
+
return /* @__PURE__ */ C("path", { fill: m, d: r, ...v }, e(n, t));
|
|
1080
1068
|
});
|
|
1081
1069
|
}, x = {
|
|
1082
1070
|
"data-testid": "finder-patterns-outer"
|
|
1083
1071
|
}, Yt = ({
|
|
1084
|
-
modules:
|
|
1072
|
+
modules: s,
|
|
1085
1073
|
margin: a,
|
|
1086
1074
|
settings: c,
|
|
1087
1075
|
gradient: i,
|
|
1088
|
-
gradientId:
|
|
1076
|
+
gradientId: o
|
|
1089
1077
|
}) => {
|
|
1090
|
-
const { style: u, color: l } =
|
|
1078
|
+
const { style: u, color: l } = L(
|
|
1091
1079
|
() => zt(c),
|
|
1092
1080
|
[c]
|
|
1093
|
-
),
|
|
1081
|
+
), m = i ? `url(#${o})` : l, f = [], e = L(
|
|
1094
1082
|
() => [
|
|
1095
1083
|
{ x: a, y: a },
|
|
1096
|
-
{ x:
|
|
1097
|
-
{ x: a, y:
|
|
1084
|
+
{ x: s.length + a - R, y: a },
|
|
1085
|
+
{ x: a, y: s.length + a - R }
|
|
1098
1086
|
],
|
|
1099
|
-
[a,
|
|
1087
|
+
[a, s.length]
|
|
1100
1088
|
);
|
|
1101
1089
|
if ([
|
|
1102
1090
|
"rounded-sm",
|
|
@@ -1107,38 +1095,38 @@ const U = S, ft = {
|
|
|
1107
1095
|
"pinched-square"
|
|
1108
1096
|
].includes(u)) {
|
|
1109
1097
|
for (const n of e) {
|
|
1110
|
-
const { x: t, y:
|
|
1098
|
+
const { x: t, y: r } = n;
|
|
1111
1099
|
u === "rounded-sm" || u === "rounded" || u === "rounded-lg" ? f.push(
|
|
1112
1100
|
yt({
|
|
1113
1101
|
x: t,
|
|
1114
|
-
y:
|
|
1115
|
-
radius:
|
|
1102
|
+
y: r,
|
|
1103
|
+
radius: Q[u]
|
|
1116
1104
|
})
|
|
1117
1105
|
) : u === "circle" ? f.push(
|
|
1118
|
-
`M ${t +
|
|
1106
|
+
`M ${t + R / 2} ${r}a ${R / 2} ${R / 2} 0 1 0 0.01 0zzm 0 1a ${R / 2 - 1} ${R / 2 - 1} 0 1 1 -0.01 0Z`
|
|
1119
1107
|
) : u === "pinched-square" ? f.push(
|
|
1120
|
-
`M ${t} ${
|
|
1108
|
+
`M ${t} ${r}Q ${t + 0.5} ${r + R / 2}, ${t} ${r + R}Q ${t + R / 2} ${r + R - 0.5}, ${t + R} ${r + R}Q ${t + R - 0.5} ${r + R / 2}, ${t + R} ${r}Q ${t + R / 2} ${r + 0.5}, ${t} ${r}zM ${t + 1} ${r + 1}Q ${t + R / 2} ${r + 1.25}, ${t + R - 1} ${r + 1}Q ${t + R - 1.25} ${r + R / 2}, ${t + R - 1} ${r + R - 1}Q ${t + R / 2} ${r + R - 1.25}, ${t + 1} ${r + R - 1}Q ${t + 1.25} ${r + R / 2}, ${t + 1} ${r + 1}z`
|
|
1121
1109
|
) : f.push(
|
|
1122
|
-
`M ${t} ${
|
|
1110
|
+
`M ${t} ${r}v ${R}h ${R}v ${-R}zM ${t + 1} ${r + 1}h ${R - 2}v ${R - 2}h ${-R + 2}z`
|
|
1123
1111
|
);
|
|
1124
1112
|
}
|
|
1125
|
-
return /* @__PURE__ */ C("path", { fill:
|
|
1113
|
+
return /* @__PURE__ */ C("path", { fill: m, d: f.join(""), ...x });
|
|
1126
1114
|
}
|
|
1127
1115
|
if (u === "inpoint-sm" || u === "inpoint" || u === "inpoint-lg" || u === "outpoint-sm" || u === "outpoint" || u === "outpoint-lg" || u === "leaf-sm" || u === "leaf" || u === "leaf-lg") {
|
|
1128
1116
|
const n = u === "leaf-sm" || u === "leaf" || u === "leaf-lg" ? Bt : Ht;
|
|
1129
|
-
return e.map((t,
|
|
1117
|
+
return e.map((t, r) => ({
|
|
1130
1118
|
...t,
|
|
1131
|
-
rotation:
|
|
1132
|
-
})).map(({ x: t, y:
|
|
1119
|
+
rotation: st[u][r]
|
|
1120
|
+
})).map(({ x: t, y: r, rotation: h }) => {
|
|
1133
1121
|
const $ = n({
|
|
1134
1122
|
x: t,
|
|
1135
|
-
y:
|
|
1136
|
-
radius:
|
|
1123
|
+
y: r,
|
|
1124
|
+
radius: Q[u]
|
|
1137
1125
|
});
|
|
1138
1126
|
return /* @__PURE__ */ C(
|
|
1139
1127
|
"path",
|
|
1140
1128
|
{
|
|
1141
|
-
fill:
|
|
1129
|
+
fill: m,
|
|
1142
1130
|
d: $,
|
|
1143
1131
|
style: {
|
|
1144
1132
|
transform: `rotate(${h}deg)`,
|
|
@@ -1147,16 +1135,15 @@ const U = S, ft = {
|
|
|
1147
1135
|
},
|
|
1148
1136
|
...x
|
|
1149
1137
|
},
|
|
1150
|
-
`finder-patterns-outer-${u}-${t}-${
|
|
1138
|
+
`finder-patterns-outer-${u}-${t}-${r}`
|
|
1151
1139
|
);
|
|
1152
1140
|
});
|
|
1153
1141
|
}
|
|
1154
|
-
}, Gt = ({ gradient:
|
|
1155
|
-
|
|
1156
|
-
if (!o)
|
|
1142
|
+
}, Gt = ({ gradient: s, gradientId: a }) => {
|
|
1143
|
+
if (!s)
|
|
1157
1144
|
return null;
|
|
1158
|
-
const c = W(
|
|
1159
|
-
return /* @__PURE__ */ C("defs", { children:
|
|
1145
|
+
const c = W(s?.rotation || 0);
|
|
1146
|
+
return /* @__PURE__ */ C("defs", { children: s.type === "linear" ? /* @__PURE__ */ C("linearGradient", { id: a, gradientUnits: "userSpaceOnUse", ...c, children: s.stops?.map((i, o) => /* @__PURE__ */ C("stop", { offset: i.offset, stopColor: i.color }, o)) }) : /* @__PURE__ */ C(
|
|
1160
1147
|
"radialGradient",
|
|
1161
1148
|
{
|
|
1162
1149
|
id: a,
|
|
@@ -1164,38 +1151,38 @@ const U = S, ft = {
|
|
|
1164
1151
|
cx: "50%",
|
|
1165
1152
|
cy: "50%",
|
|
1166
1153
|
r: "50%",
|
|
1167
|
-
children:
|
|
1154
|
+
children: s.stops?.map((i, o) => /* @__PURE__ */ C("stop", { offset: i.offset, stopColor: i.color }, o))
|
|
1168
1155
|
}
|
|
1169
1156
|
) });
|
|
1170
1157
|
}, jt = () => {
|
|
1171
|
-
const
|
|
1158
|
+
const s = at();
|
|
1172
1159
|
return {
|
|
1173
|
-
gradientId: `${Ct}-${
|
|
1174
|
-
bgGradientId: `${wt}-${
|
|
1160
|
+
gradientId: `${Ct}-${s}`,
|
|
1161
|
+
bgGradientId: `${wt}-${s}`
|
|
1175
1162
|
};
|
|
1176
|
-
}, Vt = (
|
|
1163
|
+
}, Vt = (s, a) => s.slice().map((c, i) => i < a.y || i >= a.y + a.h ? c : c.map((o, u) => u < a.x || u >= a.x + a.w ? o : !1)), Xt = (s, a, c, i) => {
|
|
1177
1164
|
if (i == null)
|
|
1178
1165
|
return null;
|
|
1179
|
-
const
|
|
1180
|
-
let
|
|
1166
|
+
const o = s.length + c * 2, u = Math.floor(a * At), l = o / a, m = (i.width || u) * l, f = (i.height || u) * l, e = i.x == null ? s.length / 2 - m / 2 : i.x * l, n = i.y == null ? s.length / 2 - f / 2 : i.y * l, t = i.opacity == null ? 1 : i.opacity;
|
|
1167
|
+
let r = null;
|
|
1181
1168
|
if (i.excavate) {
|
|
1182
|
-
const $ = Math.floor(e), d = Math.floor(n),
|
|
1183
|
-
|
|
1169
|
+
const $ = Math.floor(e), d = Math.floor(n), M = Math.ceil(m + e - $), g = Math.ceil(f + n - d);
|
|
1170
|
+
r = { x: $, y: d, w: M, h: g };
|
|
1184
1171
|
}
|
|
1185
1172
|
const h = i.crossOrigin;
|
|
1186
|
-
return { x: e, y: n, h: f, w:
|
|
1187
|
-
}, Zt = (
|
|
1188
|
-
value:
|
|
1173
|
+
return { x: e, y: n, h: f, w: m, excavation: r, opacity: t, crossOrigin: h };
|
|
1174
|
+
}, Zt = (s) => s != null ? Math.max(Math.floor(s), 0) : Et, xt = ({
|
|
1175
|
+
value: s,
|
|
1189
1176
|
level: a,
|
|
1190
1177
|
minVersion: c,
|
|
1191
1178
|
marginSize: i,
|
|
1192
|
-
imageSettings:
|
|
1179
|
+
imageSettings: o,
|
|
1193
1180
|
size: u,
|
|
1194
1181
|
boostLevel: l
|
|
1195
1182
|
}) => {
|
|
1196
|
-
const
|
|
1197
|
-
const h = (Array.isArray(
|
|
1198
|
-
return
|
|
1183
|
+
const m = L(() => {
|
|
1184
|
+
const h = (Array.isArray(s) ? s : [s]).reduce(($, d) => ($.push(...b.QrSegment.makeSegments(d)), $), []);
|
|
1185
|
+
return b.QrCode.encodeSegments(
|
|
1199
1186
|
h,
|
|
1200
1187
|
ft[a],
|
|
1201
1188
|
c,
|
|
@@ -1203,79 +1190,79 @@ const U = S, ft = {
|
|
|
1203
1190
|
void 0,
|
|
1204
1191
|
l
|
|
1205
1192
|
);
|
|
1206
|
-
}, [
|
|
1207
|
-
const
|
|
1193
|
+
}, [s, a, c, l]), { cells: f, margin: e, numCells: n, calculatedImageSettings: t } = L(() => {
|
|
1194
|
+
const r = m.getModules(), h = Zt(i), $ = r.length + h * 2, d = Xt(r, u, h, o);
|
|
1208
1195
|
return {
|
|
1209
|
-
cells:
|
|
1196
|
+
cells: r,
|
|
1210
1197
|
margin: h,
|
|
1211
1198
|
numCells: $,
|
|
1212
1199
|
calculatedImageSettings: d
|
|
1213
1200
|
};
|
|
1214
|
-
}, [
|
|
1201
|
+
}, [m, u, o, i]);
|
|
1215
1202
|
return {
|
|
1216
|
-
qrcode:
|
|
1203
|
+
qrcode: m,
|
|
1217
1204
|
margin: e,
|
|
1218
1205
|
cells: f,
|
|
1219
1206
|
numCells: n,
|
|
1220
1207
|
calculatedImageSettings: t
|
|
1221
1208
|
};
|
|
1222
|
-
}, Kt = ({ svgRef:
|
|
1223
|
-
if (!
|
|
1224
|
-
const i =
|
|
1209
|
+
}, Kt = ({ svgRef: s, fileSize: a, fileName: c }) => {
|
|
1210
|
+
if (!s.current) return;
|
|
1211
|
+
const i = s.current.cloneNode(!0);
|
|
1225
1212
|
i.setAttribute("width", a.toString()), i.setAttribute("height", a.toString());
|
|
1226
|
-
const
|
|
1213
|
+
const o = new XMLSerializer(), u = new Blob([o.serializeToString(i)], {
|
|
1227
1214
|
type: "image/svg+xml"
|
|
1228
|
-
}), l = URL.createObjectURL(u),
|
|
1229
|
-
|
|
1215
|
+
}), l = URL.createObjectURL(u), m = document.createElement("a");
|
|
1216
|
+
m.href = l, m.download = `${c}.svg`, document.body.appendChild(m), m.click(), document.body.removeChild(m), URL.revokeObjectURL(l);
|
|
1230
1217
|
}, Wt = ({
|
|
1231
|
-
svgRef:
|
|
1218
|
+
svgRef: s,
|
|
1232
1219
|
fileSize: a,
|
|
1233
1220
|
fileName: c,
|
|
1234
1221
|
fileFormat: i,
|
|
1235
|
-
imageSettings:
|
|
1222
|
+
imageSettings: o,
|
|
1236
1223
|
calculatedImageSettings: u,
|
|
1237
1224
|
size: l,
|
|
1238
|
-
numCells:
|
|
1225
|
+
numCells: m,
|
|
1239
1226
|
margin: f
|
|
1240
1227
|
}) => {
|
|
1241
|
-
if (!
|
|
1228
|
+
if (!s.current) return;
|
|
1242
1229
|
const e = document.createElement("canvas"), n = e.getContext("2d");
|
|
1243
1230
|
if (!n) return;
|
|
1244
1231
|
e.width = a, e.height = a;
|
|
1245
|
-
const t = new XMLSerializer().serializeToString(
|
|
1232
|
+
const t = new XMLSerializer().serializeToString(s.current), r = new Blob([t], { type: "image/svg+xml;charset=utf-8" }), h = URL.createObjectURL(r), $ = new Image();
|
|
1246
1233
|
$.crossOrigin = "anonymous", $.src = h, $.onload = () => {
|
|
1247
|
-
if (n.drawImage($, 0, 0, a, a), URL.revokeObjectURL(h),
|
|
1234
|
+
if (n.drawImage($, 0, 0, a, a), URL.revokeObjectURL(h), o?.src && u) {
|
|
1248
1235
|
const d = new Image();
|
|
1249
|
-
d.crossOrigin = "anonymous", d.src =
|
|
1250
|
-
const
|
|
1251
|
-
n.drawImage(d,
|
|
1252
|
-
const
|
|
1253
|
-
I.href = e.toDataURL(
|
|
1254
|
-
}, d.onerror = (
|
|
1236
|
+
d.crossOrigin = "anonymous", d.src = o.src, d.onload = () => {
|
|
1237
|
+
const M = a / l, g = m / a, A = o.width * M, E = o.x ? (u.x + f) / g : (a - A) / 2, p = o.y ? (u.y + f) / g : (a - A) / 2;
|
|
1238
|
+
n.drawImage(d, E, p, A, A);
|
|
1239
|
+
const N = i === "png" ? "image/png" : "image/jpeg", I = document.createElement("a");
|
|
1240
|
+
I.href = e.toDataURL(N), I.download = `${c}.${i}`, document.body.appendChild(I), I.click(), document.body.removeChild(I);
|
|
1241
|
+
}, d.onerror = (M) => console.error("Error loading logo:", M);
|
|
1255
1242
|
} else {
|
|
1256
|
-
const d = i === "png" ? "image/png" : "image/jpeg",
|
|
1257
|
-
|
|
1243
|
+
const d = i === "png" ? "image/png" : "image/jpeg", M = document.createElement("a");
|
|
1244
|
+
M.href = e.toDataURL(d), M.download = `${c}.${i}`, document.body.appendChild(M), M.click(), document.body.removeChild(M);
|
|
1258
1245
|
}
|
|
1259
1246
|
}, $.onerror = (d) => console.error("Error loading QR code:", d);
|
|
1260
|
-
}, Jt = ct((
|
|
1247
|
+
}, Jt = ct((s, a) => {
|
|
1261
1248
|
const {
|
|
1262
1249
|
value: c,
|
|
1263
1250
|
size: i = pt,
|
|
1264
|
-
level:
|
|
1251
|
+
level: o = mt,
|
|
1265
1252
|
background: u,
|
|
1266
1253
|
gradient: l,
|
|
1267
|
-
minVersion:
|
|
1254
|
+
minVersion: m = gt,
|
|
1268
1255
|
boostLevel: f,
|
|
1269
1256
|
marginSize: e,
|
|
1270
1257
|
finderPatternOuterSettings: n,
|
|
1271
1258
|
finderPatternInnerSettings: t,
|
|
1272
|
-
dataModulesSettings:
|
|
1259
|
+
dataModulesSettings: r,
|
|
1273
1260
|
imageSettings: h,
|
|
1274
1261
|
svgProps: $
|
|
1275
|
-
} =
|
|
1262
|
+
} = s, d = lt(null), { gradientId: M, bgGradientId: g } = jt(), { margin: A, cells: E, numCells: p, calculatedImageSettings: N } = xt({
|
|
1276
1263
|
value: c,
|
|
1277
|
-
level:
|
|
1278
|
-
minVersion:
|
|
1264
|
+
level: o,
|
|
1265
|
+
minVersion: m,
|
|
1279
1266
|
boostLevel: f,
|
|
1280
1267
|
marginSize: e,
|
|
1281
1268
|
imageSettings: h,
|
|
@@ -1294,56 +1281,56 @@ const U = S, ft = {
|
|
|
1294
1281
|
fileName: O,
|
|
1295
1282
|
fileFormat: _,
|
|
1296
1283
|
imageSettings: h,
|
|
1297
|
-
calculatedImageSettings:
|
|
1284
|
+
calculatedImageSettings: N,
|
|
1298
1285
|
size: i,
|
|
1299
|
-
numCells:
|
|
1286
|
+
numCells: p,
|
|
1300
1287
|
margin: A
|
|
1301
1288
|
}));
|
|
1302
1289
|
}
|
|
1303
1290
|
}));
|
|
1304
|
-
let I =
|
|
1305
|
-
h != null &&
|
|
1291
|
+
let I = E, w = null;
|
|
1292
|
+
h != null && N != null && (N.excavation != null && (I = Vt(E, N.excavation)), w = /* @__PURE__ */ C(
|
|
1306
1293
|
"image",
|
|
1307
1294
|
{
|
|
1308
1295
|
href: h.src,
|
|
1309
|
-
height:
|
|
1310
|
-
width:
|
|
1311
|
-
x:
|
|
1312
|
-
y:
|
|
1296
|
+
height: N.h,
|
|
1297
|
+
width: N.w,
|
|
1298
|
+
x: N.x + A,
|
|
1299
|
+
y: N.y + A,
|
|
1313
1300
|
preserveAspectRatio: "none",
|
|
1314
|
-
opacity:
|
|
1315
|
-
crossOrigin:
|
|
1301
|
+
opacity: N.opacity,
|
|
1302
|
+
crossOrigin: N.crossOrigin
|
|
1316
1303
|
}
|
|
1317
1304
|
));
|
|
1318
1305
|
const P = {
|
|
1319
1306
|
modules: I,
|
|
1320
1307
|
margin: A,
|
|
1321
1308
|
gradient: l,
|
|
1322
|
-
gradientId:
|
|
1309
|
+
gradientId: M
|
|
1323
1310
|
};
|
|
1324
1311
|
return /* @__PURE__ */ K(
|
|
1325
1312
|
"svg",
|
|
1326
1313
|
{
|
|
1327
1314
|
height: i,
|
|
1328
1315
|
width: i,
|
|
1329
|
-
viewBox: `0 0 ${
|
|
1316
|
+
viewBox: `0 0 ${p} ${p}`,
|
|
1330
1317
|
ref: d,
|
|
1331
1318
|
role: "img",
|
|
1332
|
-
"aria-label":
|
|
1319
|
+
"aria-label": $?.["aria-label"] || "QR Code",
|
|
1333
1320
|
...$,
|
|
1334
1321
|
children: [
|
|
1335
|
-
/* @__PURE__ */ C(Gt, { gradient: l, gradientId:
|
|
1322
|
+
/* @__PURE__ */ C(Gt, { gradient: l, gradientId: M }),
|
|
1336
1323
|
/* @__PURE__ */ C(
|
|
1337
1324
|
$t,
|
|
1338
1325
|
{
|
|
1339
1326
|
background: u,
|
|
1340
|
-
bgGradientId:
|
|
1341
|
-
numCells:
|
|
1327
|
+
bgGradientId: g,
|
|
1328
|
+
numCells: p
|
|
1342
1329
|
}
|
|
1343
1330
|
),
|
|
1344
1331
|
/* @__PURE__ */ C(Yt, { settings: n, ...P }),
|
|
1345
1332
|
/* @__PURE__ */ C(qt, { settings: t, ...P }),
|
|
1346
|
-
/* @__PURE__ */ C(
|
|
1333
|
+
/* @__PURE__ */ C(Qt, { settings: r, ...P }),
|
|
1347
1334
|
w
|
|
1348
1335
|
]
|
|
1349
1336
|
}
|