@memobit/libs 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.css +1 -1
- package/dist/index.d.ts +0 -7
- package/dist/index.esm.js +5898 -7631
- package/dist/memobit-icons.json +25 -0
- package/dist/mfa.d.ts +17 -0
- package/dist/mfa.esm.js +1293 -0
- package/dist/useAuth-BBqdDG2z.js +467 -0
- package/dist/version.json +4 -4
- package/package.json +7 -5
package/dist/mfa.esm.js
ADDED
|
@@ -0,0 +1,1293 @@
|
|
|
1
|
+
import { a as ne, i as we, l as P, o as re, s as ve, t as ye } from "./useAuth-BBqdDG2z.js";
|
|
2
|
+
import N, { useCallback as se, useEffect as Re, useState as O } from "react";
|
|
3
|
+
import { Fragment as ae, jsx as C, jsxs as _ } from "react/jsx-runtime";
|
|
4
|
+
var Se = Object.defineProperty, x = Object.getOwnPropertySymbols, le = Object.prototype.hasOwnProperty, ce = Object.prototype.propertyIsEnumerable, ie = (u, i, s) => i in u ? Se(u, i, {
|
|
5
|
+
enumerable: !0,
|
|
6
|
+
configurable: !0,
|
|
7
|
+
writable: !0,
|
|
8
|
+
value: s
|
|
9
|
+
}) : u[i] = s, X = (u, i) => {
|
|
10
|
+
for (var s in i || (i = {})) le.call(i, s) && ie(u, s, i[s]);
|
|
11
|
+
if (x)
|
|
12
|
+
for (var s of x(i)) ce.call(i, s) && ie(u, s, i[s]);
|
|
13
|
+
return u;
|
|
14
|
+
}, K = (u, i) => {
|
|
15
|
+
var s = {};
|
|
16
|
+
for (var c in u) le.call(u, c) && i.indexOf(c) < 0 && (s[c] = u[c]);
|
|
17
|
+
if (u != null && x)
|
|
18
|
+
for (var c of x(u)) i.indexOf(c) < 0 && ce.call(u, c) && (s[c] = u[c]);
|
|
19
|
+
return s;
|
|
20
|
+
}, Q;
|
|
21
|
+
((u) => {
|
|
22
|
+
const i = class g {
|
|
23
|
+
constructor(e, o, t, n) {
|
|
24
|
+
if (this.version = e, this.errorCorrectionLevel = o, this.modules = [], this.isFunction = [], e < g.MIN_VERSION || e > g.MAX_VERSION) throw new RangeError("Version value out of range");
|
|
25
|
+
if (n < -1 || n > 7) throw new RangeError("Mask value out of range");
|
|
26
|
+
this.size = e * 4 + 17;
|
|
27
|
+
let r = [];
|
|
28
|
+
for (let a = 0; a < this.size; a++) r.push(!1);
|
|
29
|
+
for (let a = 0; a < this.size; a++)
|
|
30
|
+
this.modules.push(r.slice()), this.isFunction.push(r.slice());
|
|
31
|
+
this.drawFunctionPatterns();
|
|
32
|
+
const l = this.addEccAndInterleave(t);
|
|
33
|
+
if (this.drawCodewords(l), n == -1) {
|
|
34
|
+
let a = 1e9;
|
|
35
|
+
for (let p = 0; p < 8; p++) {
|
|
36
|
+
this.applyMask(p), this.drawFormatBits(p);
|
|
37
|
+
const f = this.getPenaltyScore();
|
|
38
|
+
f < a && (n = p, a = f), this.applyMask(p);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
d(0 <= n && n <= 7), this.mask = n, this.applyMask(n), this.drawFormatBits(n), this.isFunction = [];
|
|
42
|
+
}
|
|
43
|
+
static encodeText(e, o) {
|
|
44
|
+
const t = u.QrSegment.makeSegments(e);
|
|
45
|
+
return g.encodeSegments(t, o);
|
|
46
|
+
}
|
|
47
|
+
static encodeBinary(e, o) {
|
|
48
|
+
const t = u.QrSegment.makeBytes(e);
|
|
49
|
+
return g.encodeSegments([t], o);
|
|
50
|
+
}
|
|
51
|
+
static encodeSegments(e, o, t = 1, n = 40, r = -1, l = !0) {
|
|
52
|
+
if (!(g.MIN_VERSION <= t && t <= n && n <= g.MAX_VERSION) || r < -1 || r > 7) throw new RangeError("Invalid value");
|
|
53
|
+
let a, p;
|
|
54
|
+
for (a = t; ; a++) {
|
|
55
|
+
const m = g.getNumDataCodewords(a, o) * 8, w = S.getTotalBits(e, a);
|
|
56
|
+
if (w <= m) {
|
|
57
|
+
p = w;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
if (a >= n) throw new RangeError("Data too long");
|
|
61
|
+
}
|
|
62
|
+
for (const m of [
|
|
63
|
+
g.Ecc.MEDIUM,
|
|
64
|
+
g.Ecc.QUARTILE,
|
|
65
|
+
g.Ecc.HIGH
|
|
66
|
+
]) l && p <= g.getNumDataCodewords(a, m) * 8 && (o = m);
|
|
67
|
+
let f = [];
|
|
68
|
+
for (const m of e) {
|
|
69
|
+
s(m.mode.modeBits, 4, f), s(m.numChars, m.mode.numCharCountBits(a), f);
|
|
70
|
+
for (const w of m.getData()) f.push(w);
|
|
71
|
+
}
|
|
72
|
+
d(f.length == p);
|
|
73
|
+
const A = g.getNumDataCodewords(a, o) * 8;
|
|
74
|
+
d(f.length <= A), s(0, Math.min(4, A - f.length), f), s(0, (8 - f.length % 8) % 8, f), d(f.length % 8 == 0);
|
|
75
|
+
for (let m = 236; f.length < A; m ^= 253) s(m, 8, f);
|
|
76
|
+
let v = [];
|
|
77
|
+
for (; v.length * 8 < f.length; ) v.push(0);
|
|
78
|
+
return f.forEach((m, w) => v[w >>> 3] |= m << 7 - (w & 7)), new g(a, o, v, r);
|
|
79
|
+
}
|
|
80
|
+
getModule(e, o) {
|
|
81
|
+
return 0 <= e && e < this.size && 0 <= o && o < this.size && this.modules[o][e];
|
|
82
|
+
}
|
|
83
|
+
getModules() {
|
|
84
|
+
return this.modules;
|
|
85
|
+
}
|
|
86
|
+
drawFunctionPatterns() {
|
|
87
|
+
for (let t = 0; t < this.size; t++)
|
|
88
|
+
this.setFunctionModule(6, t, t % 2 == 0), this.setFunctionModule(t, 6, t % 2 == 0);
|
|
89
|
+
this.drawFinderPattern(3, 3), this.drawFinderPattern(this.size - 4, 3), this.drawFinderPattern(3, this.size - 4);
|
|
90
|
+
const e = this.getAlignmentPatternPositions(), o = e.length;
|
|
91
|
+
for (let t = 0; t < o; t++) for (let n = 0; n < o; n++) t == 0 && n == 0 || t == 0 && n == o - 1 || t == o - 1 && n == 0 || this.drawAlignmentPattern(e[t], e[n]);
|
|
92
|
+
this.drawFormatBits(0), this.drawVersion();
|
|
93
|
+
}
|
|
94
|
+
drawFormatBits(e) {
|
|
95
|
+
const o = this.errorCorrectionLevel.formatBits << 3 | e;
|
|
96
|
+
let t = o;
|
|
97
|
+
for (let r = 0; r < 10; r++) t = t << 1 ^ (t >>> 9) * 1335;
|
|
98
|
+
const n = (o << 10 | t) ^ 21522;
|
|
99
|
+
d(n >>> 15 == 0);
|
|
100
|
+
for (let r = 0; r <= 5; r++) this.setFunctionModule(8, r, c(n, r));
|
|
101
|
+
this.setFunctionModule(8, 7, c(n, 6)), this.setFunctionModule(8, 8, c(n, 7)), this.setFunctionModule(7, 8, c(n, 8));
|
|
102
|
+
for (let r = 9; r < 15; r++) this.setFunctionModule(14 - r, 8, c(n, r));
|
|
103
|
+
for (let r = 0; r < 8; r++) this.setFunctionModule(this.size - 1 - r, 8, c(n, r));
|
|
104
|
+
for (let r = 8; r < 15; r++) this.setFunctionModule(8, this.size - 15 + r, c(n, r));
|
|
105
|
+
this.setFunctionModule(8, this.size - 8, !0);
|
|
106
|
+
}
|
|
107
|
+
drawVersion() {
|
|
108
|
+
if (this.version < 7) return;
|
|
109
|
+
let e = this.version;
|
|
110
|
+
for (let t = 0; t < 12; t++) e = e << 1 ^ (e >>> 11) * 7973;
|
|
111
|
+
const o = this.version << 12 | e;
|
|
112
|
+
d(o >>> 18 == 0);
|
|
113
|
+
for (let t = 0; t < 18; t++) {
|
|
114
|
+
const n = c(o, t), r = this.size - 11 + t % 3, l = Math.floor(t / 3);
|
|
115
|
+
this.setFunctionModule(r, l, n), this.setFunctionModule(l, r, n);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
drawFinderPattern(e, o) {
|
|
119
|
+
for (let t = -4; t <= 4; t++) for (let n = -4; n <= 4; n++) {
|
|
120
|
+
const r = Math.max(Math.abs(n), Math.abs(t)), l = e + n, a = o + t;
|
|
121
|
+
0 <= l && l < this.size && 0 <= a && a < this.size && this.setFunctionModule(l, a, r != 2 && r != 4);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
drawAlignmentPattern(e, o) {
|
|
125
|
+
for (let t = -2; t <= 2; t++) for (let n = -2; n <= 2; n++) this.setFunctionModule(e + n, o + t, Math.max(Math.abs(n), Math.abs(t)) != 1);
|
|
126
|
+
}
|
|
127
|
+
setFunctionModule(e, o, t) {
|
|
128
|
+
this.modules[o][e] = t, this.isFunction[o][e] = !0;
|
|
129
|
+
}
|
|
130
|
+
addEccAndInterleave(e) {
|
|
131
|
+
const o = this.version, t = this.errorCorrectionLevel;
|
|
132
|
+
if (e.length != g.getNumDataCodewords(o, t)) throw new RangeError("Invalid argument");
|
|
133
|
+
const n = g.NUM_ERROR_CORRECTION_BLOCKS[t.ordinal][o], r = g.ECC_CODEWORDS_PER_BLOCK[t.ordinal][o], l = Math.floor(g.getNumRawDataModules(o) / 8), a = n - l % n, p = Math.floor(l / n);
|
|
134
|
+
let f = [];
|
|
135
|
+
const A = g.reedSolomonComputeDivisor(r);
|
|
136
|
+
for (let m = 0, w = 0; m < n; m++) {
|
|
137
|
+
let M = e.slice(w, w + p - r + (m < a ? 0 : 1));
|
|
138
|
+
w += M.length;
|
|
139
|
+
const L = g.reedSolomonComputeRemainder(M, A);
|
|
140
|
+
m < a && M.push(0), f.push(M.concat(L));
|
|
141
|
+
}
|
|
142
|
+
let v = [];
|
|
143
|
+
for (let m = 0; m < f[0].length; m++) f.forEach((w, M) => {
|
|
144
|
+
(m != p - r || M >= a) && v.push(w[m]);
|
|
145
|
+
});
|
|
146
|
+
return d(v.length == l), v;
|
|
147
|
+
}
|
|
148
|
+
drawCodewords(e) {
|
|
149
|
+
if (e.length != Math.floor(g.getNumRawDataModules(this.version) / 8)) throw new RangeError("Invalid argument");
|
|
150
|
+
let o = 0;
|
|
151
|
+
for (let t = this.size - 1; t >= 1; t -= 2) {
|
|
152
|
+
t == 6 && (t = 5);
|
|
153
|
+
for (let n = 0; n < this.size; n++) for (let r = 0; r < 2; r++) {
|
|
154
|
+
const l = t - r, a = (t + 1 & 2) == 0 ? this.size - 1 - n : n;
|
|
155
|
+
!this.isFunction[a][l] && o < e.length * 8 && (this.modules[a][l] = c(e[o >>> 3], 7 - (o & 7)), o++);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
d(o == e.length * 8);
|
|
159
|
+
}
|
|
160
|
+
applyMask(e) {
|
|
161
|
+
if (e < 0 || e > 7) throw new RangeError("Mask value out of range");
|
|
162
|
+
for (let o = 0; o < this.size; o++) for (let t = 0; t < this.size; t++) {
|
|
163
|
+
let n;
|
|
164
|
+
switch (e) {
|
|
165
|
+
case 0:
|
|
166
|
+
n = (t + o) % 2 == 0;
|
|
167
|
+
break;
|
|
168
|
+
case 1:
|
|
169
|
+
n = o % 2 == 0;
|
|
170
|
+
break;
|
|
171
|
+
case 2:
|
|
172
|
+
n = t % 3 == 0;
|
|
173
|
+
break;
|
|
174
|
+
case 3:
|
|
175
|
+
n = (t + o) % 3 == 0;
|
|
176
|
+
break;
|
|
177
|
+
case 4:
|
|
178
|
+
n = (Math.floor(t / 3) + Math.floor(o / 2)) % 2 == 0;
|
|
179
|
+
break;
|
|
180
|
+
case 5:
|
|
181
|
+
n = t * o % 2 + t * o % 3 == 0;
|
|
182
|
+
break;
|
|
183
|
+
case 6:
|
|
184
|
+
n = (t * o % 2 + t * o % 3) % 2 == 0;
|
|
185
|
+
break;
|
|
186
|
+
case 7:
|
|
187
|
+
n = ((t + o) % 2 + t * o % 3) % 2 == 0;
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
throw new Error("Unreachable");
|
|
191
|
+
}
|
|
192
|
+
!this.isFunction[o][t] && n && (this.modules[o][t] = !this.modules[o][t]);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
getPenaltyScore() {
|
|
196
|
+
let e = 0;
|
|
197
|
+
for (let r = 0; r < this.size; r++) {
|
|
198
|
+
let l = !1, a = 0, p = [
|
|
199
|
+
0,
|
|
200
|
+
0,
|
|
201
|
+
0,
|
|
202
|
+
0,
|
|
203
|
+
0,
|
|
204
|
+
0,
|
|
205
|
+
0
|
|
206
|
+
];
|
|
207
|
+
for (let f = 0; f < this.size; f++) this.modules[r][f] == l ? (a++, a == 5 ? e += g.PENALTY_N1 : a > 5 && e++) : (this.finderPenaltyAddHistory(a, p), l || (e += this.finderPenaltyCountPatterns(p) * g.PENALTY_N3), l = this.modules[r][f], a = 1);
|
|
208
|
+
e += this.finderPenaltyTerminateAndCount(l, a, p) * g.PENALTY_N3;
|
|
209
|
+
}
|
|
210
|
+
for (let r = 0; r < this.size; r++) {
|
|
211
|
+
let l = !1, a = 0, p = [
|
|
212
|
+
0,
|
|
213
|
+
0,
|
|
214
|
+
0,
|
|
215
|
+
0,
|
|
216
|
+
0,
|
|
217
|
+
0,
|
|
218
|
+
0
|
|
219
|
+
];
|
|
220
|
+
for (let f = 0; f < this.size; f++) this.modules[f][r] == l ? (a++, a == 5 ? e += g.PENALTY_N1 : a > 5 && e++) : (this.finderPenaltyAddHistory(a, p), l || (e += this.finderPenaltyCountPatterns(p) * g.PENALTY_N3), l = this.modules[f][r], a = 1);
|
|
221
|
+
e += this.finderPenaltyTerminateAndCount(l, a, p) * g.PENALTY_N3;
|
|
222
|
+
}
|
|
223
|
+
for (let r = 0; r < this.size - 1; r++) for (let l = 0; l < this.size - 1; l++) {
|
|
224
|
+
const a = this.modules[r][l];
|
|
225
|
+
a == this.modules[r][l + 1] && a == this.modules[r + 1][l] && a == this.modules[r + 1][l + 1] && (e += g.PENALTY_N2);
|
|
226
|
+
}
|
|
227
|
+
let o = 0;
|
|
228
|
+
for (const r of this.modules) o = r.reduce((l, a) => l + (a ? 1 : 0), o);
|
|
229
|
+
const t = this.size * this.size, n = Math.ceil(Math.abs(o * 20 - t * 10) / t) - 1;
|
|
230
|
+
return d(0 <= n && n <= 9), e += n * g.PENALTY_N4, d(0 <= e && e <= 2568888), e;
|
|
231
|
+
}
|
|
232
|
+
getAlignmentPatternPositions() {
|
|
233
|
+
if (this.version == 1) return [];
|
|
234
|
+
{
|
|
235
|
+
const e = Math.floor(this.version / 7) + 2, o = this.version == 32 ? 26 : Math.ceil((this.version * 4 + 4) / (e * 2 - 2)) * 2;
|
|
236
|
+
let t = [6];
|
|
237
|
+
for (let n = this.size - 7; t.length < e; n -= o) t.splice(1, 0, n);
|
|
238
|
+
return t;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
static getNumRawDataModules(e) {
|
|
242
|
+
if (e < g.MIN_VERSION || e > g.MAX_VERSION) throw new RangeError("Version number out of range");
|
|
243
|
+
let o = (16 * e + 128) * e + 64;
|
|
244
|
+
if (e >= 2) {
|
|
245
|
+
const t = Math.floor(e / 7) + 2;
|
|
246
|
+
o -= (25 * t - 10) * t - 55, e >= 7 && (o -= 36);
|
|
247
|
+
}
|
|
248
|
+
return d(208 <= o && o <= 29648), o;
|
|
249
|
+
}
|
|
250
|
+
static getNumDataCodewords(e, o) {
|
|
251
|
+
return Math.floor(g.getNumRawDataModules(e) / 8) - g.ECC_CODEWORDS_PER_BLOCK[o.ordinal][e] * g.NUM_ERROR_CORRECTION_BLOCKS[o.ordinal][e];
|
|
252
|
+
}
|
|
253
|
+
static reedSolomonComputeDivisor(e) {
|
|
254
|
+
if (e < 1 || e > 255) throw new RangeError("Degree out of range");
|
|
255
|
+
let o = [];
|
|
256
|
+
for (let n = 0; n < e - 1; n++) o.push(0);
|
|
257
|
+
o.push(1);
|
|
258
|
+
let t = 1;
|
|
259
|
+
for (let n = 0; n < e; n++) {
|
|
260
|
+
for (let r = 0; r < o.length; r++)
|
|
261
|
+
o[r] = g.reedSolomonMultiply(o[r], t), r + 1 < o.length && (o[r] ^= o[r + 1]);
|
|
262
|
+
t = g.reedSolomonMultiply(t, 2);
|
|
263
|
+
}
|
|
264
|
+
return o;
|
|
265
|
+
}
|
|
266
|
+
static reedSolomonComputeRemainder(e, o) {
|
|
267
|
+
let t = o.map((n) => 0);
|
|
268
|
+
for (const n of e) {
|
|
269
|
+
const r = n ^ t.shift();
|
|
270
|
+
t.push(0), o.forEach((l, a) => t[a] ^= g.reedSolomonMultiply(l, r));
|
|
271
|
+
}
|
|
272
|
+
return t;
|
|
273
|
+
}
|
|
274
|
+
static reedSolomonMultiply(e, o) {
|
|
275
|
+
if (e >>> 8 || o >>> 8) throw new RangeError("Byte out of range");
|
|
276
|
+
let t = 0;
|
|
277
|
+
for (let n = 7; n >= 0; n--)
|
|
278
|
+
t = t << 1 ^ (t >>> 7) * 285, t ^= (o >>> n & 1) * e;
|
|
279
|
+
return d(t >>> 8 == 0), t;
|
|
280
|
+
}
|
|
281
|
+
finderPenaltyCountPatterns(e) {
|
|
282
|
+
const o = e[1];
|
|
283
|
+
d(o <= this.size * 3);
|
|
284
|
+
const t = o > 0 && e[2] == o && e[3] == o * 3 && e[4] == o && e[5] == o;
|
|
285
|
+
return (t && e[0] >= o * 4 && e[6] >= o ? 1 : 0) + (t && e[6] >= o * 4 && e[0] >= o ? 1 : 0);
|
|
286
|
+
}
|
|
287
|
+
finderPenaltyTerminateAndCount(e, o, t) {
|
|
288
|
+
return e && (this.finderPenaltyAddHistory(o, t), o = 0), o += this.size, this.finderPenaltyAddHistory(o, t), this.finderPenaltyCountPatterns(t);
|
|
289
|
+
}
|
|
290
|
+
finderPenaltyAddHistory(e, o) {
|
|
291
|
+
o[0] == 0 && (e += this.size), o.pop(), o.unshift(e);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
i.MIN_VERSION = 1, i.MAX_VERSION = 40, i.PENALTY_N1 = 3, i.PENALTY_N2 = 3, i.PENALTY_N3 = 40, i.PENALTY_N4 = 10, i.ECC_CODEWORDS_PER_BLOCK = [
|
|
295
|
+
[
|
|
296
|
+
-1,
|
|
297
|
+
7,
|
|
298
|
+
10,
|
|
299
|
+
15,
|
|
300
|
+
20,
|
|
301
|
+
26,
|
|
302
|
+
18,
|
|
303
|
+
20,
|
|
304
|
+
24,
|
|
305
|
+
30,
|
|
306
|
+
18,
|
|
307
|
+
20,
|
|
308
|
+
24,
|
|
309
|
+
26,
|
|
310
|
+
30,
|
|
311
|
+
22,
|
|
312
|
+
24,
|
|
313
|
+
28,
|
|
314
|
+
30,
|
|
315
|
+
28,
|
|
316
|
+
28,
|
|
317
|
+
28,
|
|
318
|
+
28,
|
|
319
|
+
30,
|
|
320
|
+
30,
|
|
321
|
+
26,
|
|
322
|
+
28,
|
|
323
|
+
30,
|
|
324
|
+
30,
|
|
325
|
+
30,
|
|
326
|
+
30,
|
|
327
|
+
30,
|
|
328
|
+
30,
|
|
329
|
+
30,
|
|
330
|
+
30,
|
|
331
|
+
30,
|
|
332
|
+
30,
|
|
333
|
+
30,
|
|
334
|
+
30,
|
|
335
|
+
30,
|
|
336
|
+
30
|
|
337
|
+
],
|
|
338
|
+
[
|
|
339
|
+
-1,
|
|
340
|
+
10,
|
|
341
|
+
16,
|
|
342
|
+
26,
|
|
343
|
+
18,
|
|
344
|
+
24,
|
|
345
|
+
16,
|
|
346
|
+
18,
|
|
347
|
+
22,
|
|
348
|
+
22,
|
|
349
|
+
26,
|
|
350
|
+
30,
|
|
351
|
+
22,
|
|
352
|
+
22,
|
|
353
|
+
24,
|
|
354
|
+
24,
|
|
355
|
+
28,
|
|
356
|
+
28,
|
|
357
|
+
26,
|
|
358
|
+
26,
|
|
359
|
+
26,
|
|
360
|
+
26,
|
|
361
|
+
28,
|
|
362
|
+
28,
|
|
363
|
+
28,
|
|
364
|
+
28,
|
|
365
|
+
28,
|
|
366
|
+
28,
|
|
367
|
+
28,
|
|
368
|
+
28,
|
|
369
|
+
28,
|
|
370
|
+
28,
|
|
371
|
+
28,
|
|
372
|
+
28,
|
|
373
|
+
28,
|
|
374
|
+
28,
|
|
375
|
+
28,
|
|
376
|
+
28,
|
|
377
|
+
28,
|
|
378
|
+
28,
|
|
379
|
+
28
|
|
380
|
+
],
|
|
381
|
+
[
|
|
382
|
+
-1,
|
|
383
|
+
13,
|
|
384
|
+
22,
|
|
385
|
+
18,
|
|
386
|
+
26,
|
|
387
|
+
18,
|
|
388
|
+
24,
|
|
389
|
+
18,
|
|
390
|
+
22,
|
|
391
|
+
20,
|
|
392
|
+
24,
|
|
393
|
+
28,
|
|
394
|
+
26,
|
|
395
|
+
24,
|
|
396
|
+
20,
|
|
397
|
+
30,
|
|
398
|
+
24,
|
|
399
|
+
28,
|
|
400
|
+
28,
|
|
401
|
+
26,
|
|
402
|
+
30,
|
|
403
|
+
28,
|
|
404
|
+
30,
|
|
405
|
+
30,
|
|
406
|
+
30,
|
|
407
|
+
30,
|
|
408
|
+
28,
|
|
409
|
+
30,
|
|
410
|
+
30,
|
|
411
|
+
30,
|
|
412
|
+
30,
|
|
413
|
+
30,
|
|
414
|
+
30,
|
|
415
|
+
30,
|
|
416
|
+
30,
|
|
417
|
+
30,
|
|
418
|
+
30,
|
|
419
|
+
30,
|
|
420
|
+
30,
|
|
421
|
+
30,
|
|
422
|
+
30
|
|
423
|
+
],
|
|
424
|
+
[
|
|
425
|
+
-1,
|
|
426
|
+
17,
|
|
427
|
+
28,
|
|
428
|
+
22,
|
|
429
|
+
16,
|
|
430
|
+
22,
|
|
431
|
+
28,
|
|
432
|
+
26,
|
|
433
|
+
26,
|
|
434
|
+
24,
|
|
435
|
+
28,
|
|
436
|
+
24,
|
|
437
|
+
28,
|
|
438
|
+
22,
|
|
439
|
+
24,
|
|
440
|
+
24,
|
|
441
|
+
30,
|
|
442
|
+
28,
|
|
443
|
+
28,
|
|
444
|
+
26,
|
|
445
|
+
28,
|
|
446
|
+
30,
|
|
447
|
+
24,
|
|
448
|
+
30,
|
|
449
|
+
30,
|
|
450
|
+
30,
|
|
451
|
+
30,
|
|
452
|
+
30,
|
|
453
|
+
30,
|
|
454
|
+
30,
|
|
455
|
+
30,
|
|
456
|
+
30,
|
|
457
|
+
30,
|
|
458
|
+
30,
|
|
459
|
+
30,
|
|
460
|
+
30,
|
|
461
|
+
30,
|
|
462
|
+
30,
|
|
463
|
+
30,
|
|
464
|
+
30,
|
|
465
|
+
30
|
|
466
|
+
]
|
|
467
|
+
], i.NUM_ERROR_CORRECTION_BLOCKS = [
|
|
468
|
+
[
|
|
469
|
+
-1,
|
|
470
|
+
1,
|
|
471
|
+
1,
|
|
472
|
+
1,
|
|
473
|
+
1,
|
|
474
|
+
1,
|
|
475
|
+
2,
|
|
476
|
+
2,
|
|
477
|
+
2,
|
|
478
|
+
2,
|
|
479
|
+
4,
|
|
480
|
+
4,
|
|
481
|
+
4,
|
|
482
|
+
4,
|
|
483
|
+
4,
|
|
484
|
+
6,
|
|
485
|
+
6,
|
|
486
|
+
6,
|
|
487
|
+
6,
|
|
488
|
+
7,
|
|
489
|
+
8,
|
|
490
|
+
8,
|
|
491
|
+
9,
|
|
492
|
+
9,
|
|
493
|
+
10,
|
|
494
|
+
12,
|
|
495
|
+
12,
|
|
496
|
+
12,
|
|
497
|
+
13,
|
|
498
|
+
14,
|
|
499
|
+
15,
|
|
500
|
+
16,
|
|
501
|
+
17,
|
|
502
|
+
18,
|
|
503
|
+
19,
|
|
504
|
+
19,
|
|
505
|
+
20,
|
|
506
|
+
21,
|
|
507
|
+
22,
|
|
508
|
+
24,
|
|
509
|
+
25
|
|
510
|
+
],
|
|
511
|
+
[
|
|
512
|
+
-1,
|
|
513
|
+
1,
|
|
514
|
+
1,
|
|
515
|
+
1,
|
|
516
|
+
2,
|
|
517
|
+
2,
|
|
518
|
+
4,
|
|
519
|
+
4,
|
|
520
|
+
4,
|
|
521
|
+
5,
|
|
522
|
+
5,
|
|
523
|
+
5,
|
|
524
|
+
8,
|
|
525
|
+
9,
|
|
526
|
+
9,
|
|
527
|
+
10,
|
|
528
|
+
10,
|
|
529
|
+
11,
|
|
530
|
+
13,
|
|
531
|
+
14,
|
|
532
|
+
16,
|
|
533
|
+
17,
|
|
534
|
+
17,
|
|
535
|
+
18,
|
|
536
|
+
20,
|
|
537
|
+
21,
|
|
538
|
+
23,
|
|
539
|
+
25,
|
|
540
|
+
26,
|
|
541
|
+
28,
|
|
542
|
+
29,
|
|
543
|
+
31,
|
|
544
|
+
33,
|
|
545
|
+
35,
|
|
546
|
+
37,
|
|
547
|
+
38,
|
|
548
|
+
40,
|
|
549
|
+
43,
|
|
550
|
+
45,
|
|
551
|
+
47,
|
|
552
|
+
49
|
|
553
|
+
],
|
|
554
|
+
[
|
|
555
|
+
-1,
|
|
556
|
+
1,
|
|
557
|
+
1,
|
|
558
|
+
2,
|
|
559
|
+
2,
|
|
560
|
+
4,
|
|
561
|
+
4,
|
|
562
|
+
6,
|
|
563
|
+
6,
|
|
564
|
+
8,
|
|
565
|
+
8,
|
|
566
|
+
8,
|
|
567
|
+
10,
|
|
568
|
+
12,
|
|
569
|
+
16,
|
|
570
|
+
12,
|
|
571
|
+
17,
|
|
572
|
+
16,
|
|
573
|
+
18,
|
|
574
|
+
21,
|
|
575
|
+
20,
|
|
576
|
+
23,
|
|
577
|
+
23,
|
|
578
|
+
25,
|
|
579
|
+
27,
|
|
580
|
+
29,
|
|
581
|
+
34,
|
|
582
|
+
34,
|
|
583
|
+
35,
|
|
584
|
+
38,
|
|
585
|
+
40,
|
|
586
|
+
43,
|
|
587
|
+
45,
|
|
588
|
+
48,
|
|
589
|
+
51,
|
|
590
|
+
53,
|
|
591
|
+
56,
|
|
592
|
+
59,
|
|
593
|
+
62,
|
|
594
|
+
65,
|
|
595
|
+
68
|
|
596
|
+
],
|
|
597
|
+
[
|
|
598
|
+
-1,
|
|
599
|
+
1,
|
|
600
|
+
1,
|
|
601
|
+
2,
|
|
602
|
+
4,
|
|
603
|
+
4,
|
|
604
|
+
4,
|
|
605
|
+
5,
|
|
606
|
+
6,
|
|
607
|
+
8,
|
|
608
|
+
8,
|
|
609
|
+
11,
|
|
610
|
+
11,
|
|
611
|
+
16,
|
|
612
|
+
16,
|
|
613
|
+
18,
|
|
614
|
+
16,
|
|
615
|
+
19,
|
|
616
|
+
21,
|
|
617
|
+
25,
|
|
618
|
+
25,
|
|
619
|
+
25,
|
|
620
|
+
34,
|
|
621
|
+
30,
|
|
622
|
+
32,
|
|
623
|
+
35,
|
|
624
|
+
37,
|
|
625
|
+
40,
|
|
626
|
+
42,
|
|
627
|
+
45,
|
|
628
|
+
48,
|
|
629
|
+
51,
|
|
630
|
+
54,
|
|
631
|
+
57,
|
|
632
|
+
60,
|
|
633
|
+
63,
|
|
634
|
+
66,
|
|
635
|
+
70,
|
|
636
|
+
74,
|
|
637
|
+
77,
|
|
638
|
+
81
|
|
639
|
+
]
|
|
640
|
+
], u.QrCode = i;
|
|
641
|
+
function s(E, e, o) {
|
|
642
|
+
if (e < 0 || e > 31 || E >>> e) throw new RangeError("Value out of range");
|
|
643
|
+
for (let t = e - 1; t >= 0; t--) o.push(E >>> t & 1);
|
|
644
|
+
}
|
|
645
|
+
function c(E, e) {
|
|
646
|
+
return (E >>> e & 1) != 0;
|
|
647
|
+
}
|
|
648
|
+
function d(E) {
|
|
649
|
+
if (!E) throw new Error("Assertion error");
|
|
650
|
+
}
|
|
651
|
+
const h = class y {
|
|
652
|
+
constructor(e, o, t) {
|
|
653
|
+
if (this.mode = e, this.numChars = o, this.bitData = t, o < 0) throw new RangeError("Invalid argument");
|
|
654
|
+
this.bitData = t.slice();
|
|
655
|
+
}
|
|
656
|
+
static makeBytes(e) {
|
|
657
|
+
let o = [];
|
|
658
|
+
for (const t of e) s(t, 8, o);
|
|
659
|
+
return new y(y.Mode.BYTE, e.length, o);
|
|
660
|
+
}
|
|
661
|
+
static makeNumeric(e) {
|
|
662
|
+
if (!y.isNumeric(e)) throw new RangeError("String contains non-numeric characters");
|
|
663
|
+
let o = [];
|
|
664
|
+
for (let t = 0; t < e.length; ) {
|
|
665
|
+
const n = Math.min(e.length - t, 3);
|
|
666
|
+
s(parseInt(e.substring(t, t + n), 10), n * 3 + 1, o), t += n;
|
|
667
|
+
}
|
|
668
|
+
return new y(y.Mode.NUMERIC, e.length, o);
|
|
669
|
+
}
|
|
670
|
+
static makeAlphanumeric(e) {
|
|
671
|
+
if (!y.isAlphanumeric(e)) throw new RangeError("String contains unencodable characters in alphanumeric mode");
|
|
672
|
+
let o = [], t;
|
|
673
|
+
for (t = 0; t + 2 <= e.length; t += 2) {
|
|
674
|
+
let n = y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)) * 45;
|
|
675
|
+
n += y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t + 1)), s(n, 11, o);
|
|
676
|
+
}
|
|
677
|
+
return t < e.length && s(y.ALPHANUMERIC_CHARSET.indexOf(e.charAt(t)), 6, o), new y(y.Mode.ALPHANUMERIC, e.length, o);
|
|
678
|
+
}
|
|
679
|
+
static makeSegments(e) {
|
|
680
|
+
return e == "" ? [] : y.isNumeric(e) ? [y.makeNumeric(e)] : y.isAlphanumeric(e) ? [y.makeAlphanumeric(e)] : [y.makeBytes(y.toUtf8ByteArray(e))];
|
|
681
|
+
}
|
|
682
|
+
static makeEci(e) {
|
|
683
|
+
let o = [];
|
|
684
|
+
if (e < 0) throw new RangeError("ECI assignment value out of range");
|
|
685
|
+
if (e < 128) s(e, 8, o);
|
|
686
|
+
else if (e < 16384)
|
|
687
|
+
s(2, 2, o), s(e, 14, o);
|
|
688
|
+
else if (e < 1e6)
|
|
689
|
+
s(6, 3, o), s(e, 21, o);
|
|
690
|
+
else throw new RangeError("ECI assignment value out of range");
|
|
691
|
+
return new y(y.Mode.ECI, 0, o);
|
|
692
|
+
}
|
|
693
|
+
static isNumeric(e) {
|
|
694
|
+
return y.NUMERIC_REGEX.test(e);
|
|
695
|
+
}
|
|
696
|
+
static isAlphanumeric(e) {
|
|
697
|
+
return y.ALPHANUMERIC_REGEX.test(e);
|
|
698
|
+
}
|
|
699
|
+
getData() {
|
|
700
|
+
return this.bitData.slice();
|
|
701
|
+
}
|
|
702
|
+
static getTotalBits(e, o) {
|
|
703
|
+
let t = 0;
|
|
704
|
+
for (const n of e) {
|
|
705
|
+
const r = n.mode.numCharCountBits(o);
|
|
706
|
+
if (n.numChars >= 1 << r) return 1 / 0;
|
|
707
|
+
t += 4 + r + n.bitData.length;
|
|
708
|
+
}
|
|
709
|
+
return t;
|
|
710
|
+
}
|
|
711
|
+
static toUtf8ByteArray(e) {
|
|
712
|
+
e = encodeURI(e);
|
|
713
|
+
let o = [];
|
|
714
|
+
for (let t = 0; t < e.length; t++) e.charAt(t) != "%" ? o.push(e.charCodeAt(t)) : (o.push(parseInt(e.substring(t + 1, t + 3), 16)), t += 2);
|
|
715
|
+
return o;
|
|
716
|
+
}
|
|
717
|
+
};
|
|
718
|
+
h.NUMERIC_REGEX = /^[0-9]*$/, h.ALPHANUMERIC_REGEX = /^[A-Z0-9 $%*+.\/:-]*$/, h.ALPHANUMERIC_CHARSET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";
|
|
719
|
+
let S = h;
|
|
720
|
+
u.QrSegment = h;
|
|
721
|
+
})(Q || (Q = {}));
|
|
722
|
+
((u) => {
|
|
723
|
+
((i) => {
|
|
724
|
+
const s = class {
|
|
725
|
+
constructor(d, h) {
|
|
726
|
+
this.ordinal = d, this.formatBits = h;
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
s.LOW = new s(0, 1), s.MEDIUM = new s(1, 0), s.QUARTILE = new s(2, 3), s.HIGH = new s(3, 2), i.Ecc = s;
|
|
730
|
+
})(u.QrCode || (u.QrCode = {}));
|
|
731
|
+
})(Q || (Q = {}));
|
|
732
|
+
((u) => {
|
|
733
|
+
((i) => {
|
|
734
|
+
const s = class {
|
|
735
|
+
constructor(d, h) {
|
|
736
|
+
this.modeBits = d, this.numBitsCharCount = h;
|
|
737
|
+
}
|
|
738
|
+
numCharCountBits(d) {
|
|
739
|
+
return this.numBitsCharCount[Math.floor((d + 7) / 17)];
|
|
740
|
+
}
|
|
741
|
+
};
|
|
742
|
+
s.NUMERIC = new s(1, [
|
|
743
|
+
10,
|
|
744
|
+
12,
|
|
745
|
+
14
|
|
746
|
+
]), s.ALPHANUMERIC = new s(2, [
|
|
747
|
+
9,
|
|
748
|
+
11,
|
|
749
|
+
13
|
|
750
|
+
]), s.BYTE = new s(4, [
|
|
751
|
+
8,
|
|
752
|
+
16,
|
|
753
|
+
16
|
|
754
|
+
]), s.KANJI = new s(8, [
|
|
755
|
+
8,
|
|
756
|
+
10,
|
|
757
|
+
12
|
|
758
|
+
]), s.ECI = new s(7, [
|
|
759
|
+
0,
|
|
760
|
+
0,
|
|
761
|
+
0
|
|
762
|
+
]), i.Mode = s;
|
|
763
|
+
})(u.QrSegment || (u.QrSegment = {}));
|
|
764
|
+
})(Q || (Q = {}));
|
|
765
|
+
var $ = Q, Ne = {
|
|
766
|
+
L: $.QrCode.Ecc.LOW,
|
|
767
|
+
M: $.QrCode.Ecc.MEDIUM,
|
|
768
|
+
Q: $.QrCode.Ecc.QUARTILE,
|
|
769
|
+
H: $.QrCode.Ecc.HIGH
|
|
770
|
+
}, ue = 128, de = "L", he = "#FFFFFF", fe = "#000000", me = !1, ge = 1, Ae = 4, be = 0, Pe = 0.1;
|
|
771
|
+
function pe(u, i = 0) {
|
|
772
|
+
const s = [];
|
|
773
|
+
return u.forEach(function(c, d) {
|
|
774
|
+
let h = null;
|
|
775
|
+
c.forEach(function(S, E) {
|
|
776
|
+
if (!S && h !== null) {
|
|
777
|
+
s.push(`M${h + i} ${d + i}h${E - h}v1H${h + i}z`), h = null;
|
|
778
|
+
return;
|
|
779
|
+
}
|
|
780
|
+
if (E === c.length - 1) {
|
|
781
|
+
if (!S) return;
|
|
782
|
+
h === null ? s.push(`M${E + i},${d + i} h1v1H${E + i}z`) : s.push(`M${h + i},${d + i} h${E + 1 - h}v1H${h + i}z`);
|
|
783
|
+
return;
|
|
784
|
+
}
|
|
785
|
+
S && h === null && (h = E);
|
|
786
|
+
});
|
|
787
|
+
}), s.join("");
|
|
788
|
+
}
|
|
789
|
+
function Ce(u, i) {
|
|
790
|
+
return u.slice().map((s, c) => c < i.y || c >= i.y + i.h ? s : s.map((d, h) => h < i.x || h >= i.x + i.w ? d : !1));
|
|
791
|
+
}
|
|
792
|
+
function Ie(u, i, s, c) {
|
|
793
|
+
if (c == null) return null;
|
|
794
|
+
const d = u.length + s * 2, h = Math.floor(i * Pe), S = d / i, E = (c.width || h) * S, e = (c.height || h) * S, o = c.x == null ? u.length / 2 - E / 2 : c.x * S, t = c.y == null ? u.length / 2 - e / 2 : c.y * S, n = c.opacity == null ? 1 : c.opacity;
|
|
795
|
+
let r = null;
|
|
796
|
+
if (c.excavate) {
|
|
797
|
+
let a = Math.floor(o), p = Math.floor(t);
|
|
798
|
+
r = {
|
|
799
|
+
x: a,
|
|
800
|
+
y: p,
|
|
801
|
+
w: Math.ceil(E + o - a),
|
|
802
|
+
h: Math.ceil(e + t - p)
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
const l = c.crossOrigin;
|
|
806
|
+
return {
|
|
807
|
+
x: o,
|
|
808
|
+
y: t,
|
|
809
|
+
h: e,
|
|
810
|
+
w: E,
|
|
811
|
+
excavation: r,
|
|
812
|
+
opacity: n,
|
|
813
|
+
crossOrigin: l
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function _e(u, i) {
|
|
817
|
+
return i != null ? Math.max(Math.floor(i), 0) : u ? Ae : be;
|
|
818
|
+
}
|
|
819
|
+
function Me({ value: u, level: i, minVersion: s, includeMargin: c, marginSize: d, imageSettings: h, size: S, boostLevel: E }) {
|
|
820
|
+
let e = N.useMemo(() => {
|
|
821
|
+
const l = (Array.isArray(u) ? u : [u]).reduce((a, p) => (a.push(...$.QrSegment.makeSegments(p)), a), []);
|
|
822
|
+
return $.QrCode.encodeSegments(l, Ne[i], s, void 0, void 0, E);
|
|
823
|
+
}, [
|
|
824
|
+
u,
|
|
825
|
+
i,
|
|
826
|
+
s,
|
|
827
|
+
E
|
|
828
|
+
]);
|
|
829
|
+
const { cells: o, margin: t, numCells: n, calculatedImageSettings: r } = N.useMemo(() => {
|
|
830
|
+
let l = e.getModules();
|
|
831
|
+
const a = _e(c, d);
|
|
832
|
+
return {
|
|
833
|
+
cells: l,
|
|
834
|
+
margin: a,
|
|
835
|
+
numCells: l.length + a * 2,
|
|
836
|
+
calculatedImageSettings: Ie(l, S, a, h)
|
|
837
|
+
};
|
|
838
|
+
}, [
|
|
839
|
+
e,
|
|
840
|
+
S,
|
|
841
|
+
h,
|
|
842
|
+
c,
|
|
843
|
+
d
|
|
844
|
+
]);
|
|
845
|
+
return {
|
|
846
|
+
qrcode: e,
|
|
847
|
+
margin: t,
|
|
848
|
+
cells: o,
|
|
849
|
+
numCells: n,
|
|
850
|
+
calculatedImageSettings: r
|
|
851
|
+
};
|
|
852
|
+
}
|
|
853
|
+
var Te = (function() {
|
|
854
|
+
try {
|
|
855
|
+
new Path2D().addPath(new Path2D());
|
|
856
|
+
} catch {
|
|
857
|
+
return !1;
|
|
858
|
+
}
|
|
859
|
+
return !0;
|
|
860
|
+
})(), Oe = N.forwardRef(function(i, s) {
|
|
861
|
+
const c = i, { value: d, size: h = ue, level: S = de, bgColor: E = he, fgColor: e = fe, includeMargin: o = me, minVersion: t = ge, boostLevel: n, marginSize: r, imageSettings: l } = c, a = K(c, [
|
|
862
|
+
"value",
|
|
863
|
+
"size",
|
|
864
|
+
"level",
|
|
865
|
+
"bgColor",
|
|
866
|
+
"fgColor",
|
|
867
|
+
"includeMargin",
|
|
868
|
+
"minVersion",
|
|
869
|
+
"boostLevel",
|
|
870
|
+
"marginSize",
|
|
871
|
+
"imageSettings"
|
|
872
|
+
]), { style: p } = a, f = K(a, ["style"]), A = l?.src, v = N.useRef(null), m = N.useRef(null), w = N.useCallback((B) => {
|
|
873
|
+
v.current = B, typeof s == "function" ? s(B) : s && (s.current = B);
|
|
874
|
+
}, [s]), [M, L] = N.useState(!1), { margin: k, cells: D, numCells: T, calculatedImageSettings: b } = Me({
|
|
875
|
+
value: d,
|
|
876
|
+
level: S,
|
|
877
|
+
minVersion: t,
|
|
878
|
+
boostLevel: n,
|
|
879
|
+
includeMargin: o,
|
|
880
|
+
marginSize: r,
|
|
881
|
+
imageSettings: l,
|
|
882
|
+
size: h
|
|
883
|
+
});
|
|
884
|
+
N.useEffect(() => {
|
|
885
|
+
if (v.current != null) {
|
|
886
|
+
const B = v.current, I = B.getContext("2d");
|
|
887
|
+
if (!I) return;
|
|
888
|
+
let H = D;
|
|
889
|
+
const z = m.current, G = b != null && z !== null && z.complete && z.naturalHeight !== 0 && z.naturalWidth !== 0;
|
|
890
|
+
G && b.excavation != null && (H = Ce(D, b.excavation));
|
|
891
|
+
const V = window.devicePixelRatio || 1;
|
|
892
|
+
B.height = B.width = h * V;
|
|
893
|
+
const Y = h / T * V;
|
|
894
|
+
I.scale(Y, Y), I.fillStyle = E, I.fillRect(0, 0, T, T), I.fillStyle = e, Te ? I.fill(new Path2D(pe(H, k))) : D.forEach(function(j, Z) {
|
|
895
|
+
j.forEach(function(R, U) {
|
|
896
|
+
R && I.fillRect(U + k, Z + k, 1, 1);
|
|
897
|
+
});
|
|
898
|
+
}), b && (I.globalAlpha = b.opacity), G && I.drawImage(z, b.x + k, b.y + k, b.w, b.h);
|
|
899
|
+
}
|
|
900
|
+
}), N.useEffect(() => {
|
|
901
|
+
L(!1);
|
|
902
|
+
}, [A]);
|
|
903
|
+
const F = X({
|
|
904
|
+
height: h,
|
|
905
|
+
width: h
|
|
906
|
+
}, p);
|
|
907
|
+
let W = null;
|
|
908
|
+
return A != null && (W = /* @__PURE__ */ N.createElement("img", {
|
|
909
|
+
src: A,
|
|
910
|
+
key: A,
|
|
911
|
+
style: { display: "none" },
|
|
912
|
+
onLoad: () => {
|
|
913
|
+
L(!0);
|
|
914
|
+
},
|
|
915
|
+
ref: m,
|
|
916
|
+
crossOrigin: b?.crossOrigin
|
|
917
|
+
})), /* @__PURE__ */ N.createElement(N.Fragment, null, /* @__PURE__ */ N.createElement("canvas", X({
|
|
918
|
+
style: F,
|
|
919
|
+
height: h,
|
|
920
|
+
width: h,
|
|
921
|
+
ref: w,
|
|
922
|
+
role: "img"
|
|
923
|
+
}, f)), W);
|
|
924
|
+
});
|
|
925
|
+
Oe.displayName = "QRCodeCanvas";
|
|
926
|
+
var Ee = N.forwardRef(function(i, s) {
|
|
927
|
+
const c = i, { value: d, size: h = ue, level: S = de, bgColor: E = he, fgColor: e = fe, includeMargin: o = me, minVersion: t = ge, boostLevel: n, title: r, marginSize: l, imageSettings: a } = c, p = K(c, [
|
|
928
|
+
"value",
|
|
929
|
+
"size",
|
|
930
|
+
"level",
|
|
931
|
+
"bgColor",
|
|
932
|
+
"fgColor",
|
|
933
|
+
"includeMargin",
|
|
934
|
+
"minVersion",
|
|
935
|
+
"boostLevel",
|
|
936
|
+
"title",
|
|
937
|
+
"marginSize",
|
|
938
|
+
"imageSettings"
|
|
939
|
+
]), { margin: f, cells: A, numCells: v, calculatedImageSettings: m } = Me({
|
|
940
|
+
value: d,
|
|
941
|
+
level: S,
|
|
942
|
+
minVersion: t,
|
|
943
|
+
boostLevel: n,
|
|
944
|
+
includeMargin: o,
|
|
945
|
+
marginSize: l,
|
|
946
|
+
imageSettings: a,
|
|
947
|
+
size: h
|
|
948
|
+
});
|
|
949
|
+
let w = A, M = null;
|
|
950
|
+
a != null && m != null && (m.excavation != null && (w = Ce(A, m.excavation)), M = /* @__PURE__ */ N.createElement("image", {
|
|
951
|
+
href: a.src,
|
|
952
|
+
height: m.h,
|
|
953
|
+
width: m.w,
|
|
954
|
+
x: m.x + f,
|
|
955
|
+
y: m.y + f,
|
|
956
|
+
preserveAspectRatio: "none",
|
|
957
|
+
opacity: m.opacity,
|
|
958
|
+
crossOrigin: m.crossOrigin
|
|
959
|
+
}));
|
|
960
|
+
const L = pe(w, f);
|
|
961
|
+
return /* @__PURE__ */ N.createElement("svg", X({
|
|
962
|
+
height: h,
|
|
963
|
+
width: h,
|
|
964
|
+
viewBox: `0 0 ${v} ${v}`,
|
|
965
|
+
ref: s,
|
|
966
|
+
role: "img"
|
|
967
|
+
}, p), !!r && /* @__PURE__ */ N.createElement("title", null, r), /* @__PURE__ */ N.createElement("path", {
|
|
968
|
+
fill: E,
|
|
969
|
+
d: `M0,0 h${v}v${v}H0z`,
|
|
970
|
+
shapeRendering: "crispEdges"
|
|
971
|
+
}), /* @__PURE__ */ N.createElement("path", {
|
|
972
|
+
fill: e,
|
|
973
|
+
d: L,
|
|
974
|
+
shapeRendering: "crispEdges"
|
|
975
|
+
}), M);
|
|
976
|
+
});
|
|
977
|
+
Ee.displayName = "QRCodeSVG";
|
|
978
|
+
function ze({ isOpen: u, onClose: i }) {
|
|
979
|
+
const { config: s } = ye(), [c, d] = O("loading"), [h, S] = O(!1), [E, e] = O(null), [o, t] = O(""), [n, r] = O(""), [l, a] = O(""), [p, f] = O(""), [A, v] = O([]), [m, w] = O(""), [M, L] = O(!1), [k, D] = O(null), T = se(async (R, U) => {
|
|
980
|
+
const J = document.cookie.match(/(?:^|;\s*)csrf_token=([^;]+)/), q = J ? decodeURIComponent(J[1]) : null, ee = { "Content-Type": "application/json" };
|
|
981
|
+
q && (ee["X-CSRF-Token"] = q);
|
|
982
|
+
const te = await fetch(`${s.apiBaseUrl}${R}`, {
|
|
983
|
+
method: "POST",
|
|
984
|
+
credentials: "include",
|
|
985
|
+
headers: ee,
|
|
986
|
+
body: U ? JSON.stringify(U) : void 0
|
|
987
|
+
}), oe = await te.json().catch(() => ({}));
|
|
988
|
+
if (!te.ok) throw new Error(oe.error || "Request failed");
|
|
989
|
+
return oe;
|
|
990
|
+
}, [s.apiBaseUrl]), b = se(async () => {
|
|
991
|
+
d("loading"), w("");
|
|
992
|
+
try {
|
|
993
|
+
const R = await (await fetch(`${s.apiBaseUrl}/auth/mfaStatus`, { credentials: "include" })).json();
|
|
994
|
+
S(!!R.enabled), e(R.method ?? null), d("overview");
|
|
995
|
+
} catch {
|
|
996
|
+
w("Could not load MFA status."), d("overview");
|
|
997
|
+
}
|
|
998
|
+
}, [s.apiBaseUrl]);
|
|
999
|
+
Re(() => {
|
|
1000
|
+
u && (a(""), f(""), w(""), v([]), b());
|
|
1001
|
+
}, [u, b]);
|
|
1002
|
+
const F = async (R) => {
|
|
1003
|
+
L(!0), w("");
|
|
1004
|
+
try {
|
|
1005
|
+
await R();
|
|
1006
|
+
} catch (U) {
|
|
1007
|
+
w(U instanceof Error ? U.message : "Something went wrong.");
|
|
1008
|
+
} finally {
|
|
1009
|
+
L(!1);
|
|
1010
|
+
}
|
|
1011
|
+
}, W = () => F(async () => {
|
|
1012
|
+
const R = await T("/auth/mfaSetupTotp");
|
|
1013
|
+
t(R.secret || ""), r(R.otpauthUri || ""), a(""), d("totp-setup");
|
|
1014
|
+
}), B = () => F(async () => {
|
|
1015
|
+
const R = await T("/auth/mfaConfirmTotp", { code: l.trim() });
|
|
1016
|
+
v(R.recoveryCodes || []), d("recovery");
|
|
1017
|
+
}), I = () => F(async () => {
|
|
1018
|
+
await T("/auth/mfaEnableEmail"), a(""), d("email-setup");
|
|
1019
|
+
}), H = () => F(async () => {
|
|
1020
|
+
const R = await T("/auth/mfaConfirmEmail", { code: l.trim() });
|
|
1021
|
+
v(R.recoveryCodes || []), d("recovery");
|
|
1022
|
+
}), z = () => F(async () => {
|
|
1023
|
+
await T("/auth/mfaDisable", { password: p }), D({
|
|
1024
|
+
message: "Two-factor authentication disabled.",
|
|
1025
|
+
type: "success"
|
|
1026
|
+
}), f(""), await b();
|
|
1027
|
+
}), G = () => F(async () => {
|
|
1028
|
+
const R = await T("/auth/mfaRegenRecovery", { password: p });
|
|
1029
|
+
v(R.recoveryCodes || []), f(""), d("recovery");
|
|
1030
|
+
}), V = () => F(async () => {
|
|
1031
|
+
await T("/auth/mfaForgetDevices"), D({
|
|
1032
|
+
message: "All trusted devices have been signed out.",
|
|
1033
|
+
type: "success"
|
|
1034
|
+
});
|
|
1035
|
+
}), Y = () => {
|
|
1036
|
+
navigator.clipboard?.writeText(A.join(`
|
|
1037
|
+
`)), D({
|
|
1038
|
+
message: "Recovery codes copied.",
|
|
1039
|
+
type: "success"
|
|
1040
|
+
});
|
|
1041
|
+
}, j = o.replace(/(.{4})/g, "$1 ").trim();
|
|
1042
|
+
return /* @__PURE__ */ _(ve, {
|
|
1043
|
+
isOpen: u,
|
|
1044
|
+
onClose: i,
|
|
1045
|
+
title: "Two-factor authentication",
|
|
1046
|
+
titleIcon: "key",
|
|
1047
|
+
size: "medium",
|
|
1048
|
+
children: [/* @__PURE__ */ _("div", {
|
|
1049
|
+
className: "MfaSetupModal",
|
|
1050
|
+
children: [(() => {
|
|
1051
|
+
switch (c) {
|
|
1052
|
+
case "loading":
|
|
1053
|
+
return /* @__PURE__ */ C("p", {
|
|
1054
|
+
className: "MfaSetupModal__hint",
|
|
1055
|
+
children: "Loading…"
|
|
1056
|
+
});
|
|
1057
|
+
case "overview":
|
|
1058
|
+
return /* @__PURE__ */ _("div", {
|
|
1059
|
+
className: "MfaSetupModal__section",
|
|
1060
|
+
children: [/* @__PURE__ */ _("p", {
|
|
1061
|
+
className: "MfaSetupModal__status",
|
|
1062
|
+
children: ["Status: ", /* @__PURE__ */ C("strong", { children: h ? `Enabled (${E === "email" ? "email codes" : "authenticator app"})` : "Disabled" })]
|
|
1063
|
+
}), h ? /* @__PURE__ */ _(ae, { children: [
|
|
1064
|
+
/* @__PURE__ */ C(P, {
|
|
1065
|
+
variant: "default",
|
|
1066
|
+
fullWidth: !0,
|
|
1067
|
+
disabled: M,
|
|
1068
|
+
onClick: () => d("regen"),
|
|
1069
|
+
children: "Regenerate recovery codes"
|
|
1070
|
+
}),
|
|
1071
|
+
/* @__PURE__ */ C(P, {
|
|
1072
|
+
variant: "default",
|
|
1073
|
+
fullWidth: !0,
|
|
1074
|
+
disabled: M,
|
|
1075
|
+
onClick: () => F(V),
|
|
1076
|
+
children: "Sign out trusted devices"
|
|
1077
|
+
}),
|
|
1078
|
+
/* @__PURE__ */ C(P, {
|
|
1079
|
+
variant: "danger",
|
|
1080
|
+
icon: "lock",
|
|
1081
|
+
fullWidth: !0,
|
|
1082
|
+
disabled: M,
|
|
1083
|
+
onClick: () => d("disable"),
|
|
1084
|
+
children: "Disable two-factor"
|
|
1085
|
+
})
|
|
1086
|
+
] }) : /* @__PURE__ */ _(ae, { children: [
|
|
1087
|
+
/* @__PURE__ */ C("p", {
|
|
1088
|
+
className: "MfaSetupModal__hint",
|
|
1089
|
+
children: "Add a second step at sign-in. Choose a method:"
|
|
1090
|
+
}),
|
|
1091
|
+
/* @__PURE__ */ C(P, {
|
|
1092
|
+
variant: "info",
|
|
1093
|
+
fullWidth: !0,
|
|
1094
|
+
disabled: M,
|
|
1095
|
+
onClick: W,
|
|
1096
|
+
children: "Set up authenticator app"
|
|
1097
|
+
}),
|
|
1098
|
+
/* @__PURE__ */ C(P, {
|
|
1099
|
+
variant: "default",
|
|
1100
|
+
fullWidth: !0,
|
|
1101
|
+
disabled: M,
|
|
1102
|
+
onClick: I,
|
|
1103
|
+
children: "Set up email codes"
|
|
1104
|
+
})
|
|
1105
|
+
] })]
|
|
1106
|
+
});
|
|
1107
|
+
case "totp-setup":
|
|
1108
|
+
return /* @__PURE__ */ _("div", {
|
|
1109
|
+
className: "MfaSetupModal__section",
|
|
1110
|
+
children: [
|
|
1111
|
+
/* @__PURE__ */ C("p", {
|
|
1112
|
+
className: "MfaSetupModal__hint",
|
|
1113
|
+
children: "Scan this with your authenticator app (Google Authenticator, Aegis, 1Password…)."
|
|
1114
|
+
}),
|
|
1115
|
+
n && /* @__PURE__ */ C("div", {
|
|
1116
|
+
className: "MfaSetupModal__qr",
|
|
1117
|
+
children: /* @__PURE__ */ C(Ee, {
|
|
1118
|
+
value: n,
|
|
1119
|
+
size: 192,
|
|
1120
|
+
marginSize: 2
|
|
1121
|
+
})
|
|
1122
|
+
}),
|
|
1123
|
+
/* @__PURE__ */ C("p", {
|
|
1124
|
+
className: "MfaSetupModal__hint MfaSetupModal__hint--muted",
|
|
1125
|
+
children: "Can’t scan? Choose “Enter a setup key” and type this key (time-based):"
|
|
1126
|
+
}),
|
|
1127
|
+
/* @__PURE__ */ C("div", {
|
|
1128
|
+
className: "MfaSetupModal__secret",
|
|
1129
|
+
children: j
|
|
1130
|
+
}),
|
|
1131
|
+
/* @__PURE__ */ C(re, {
|
|
1132
|
+
placeholder: "6-digit code from the app",
|
|
1133
|
+
value: l,
|
|
1134
|
+
onChange: a,
|
|
1135
|
+
autoFocus: !0,
|
|
1136
|
+
disabled: M
|
|
1137
|
+
}),
|
|
1138
|
+
/* @__PURE__ */ C(P, {
|
|
1139
|
+
variant: "info",
|
|
1140
|
+
icon: "key",
|
|
1141
|
+
fullWidth: !0,
|
|
1142
|
+
loading: M,
|
|
1143
|
+
onClick: B,
|
|
1144
|
+
children: "Verify & enable"
|
|
1145
|
+
})
|
|
1146
|
+
]
|
|
1147
|
+
});
|
|
1148
|
+
case "email-setup":
|
|
1149
|
+
return /* @__PURE__ */ _("div", {
|
|
1150
|
+
className: "MfaSetupModal__section",
|
|
1151
|
+
children: [
|
|
1152
|
+
/* @__PURE__ */ C("p", {
|
|
1153
|
+
className: "MfaSetupModal__hint",
|
|
1154
|
+
children: "We emailed you a 6-digit code. Enter it below to enable email verification."
|
|
1155
|
+
}),
|
|
1156
|
+
/* @__PURE__ */ C(re, {
|
|
1157
|
+
placeholder: "6-digit code",
|
|
1158
|
+
value: l,
|
|
1159
|
+
onChange: a,
|
|
1160
|
+
autoFocus: !0,
|
|
1161
|
+
disabled: M
|
|
1162
|
+
}),
|
|
1163
|
+
/* @__PURE__ */ C(P, {
|
|
1164
|
+
variant: "info",
|
|
1165
|
+
icon: "key",
|
|
1166
|
+
fullWidth: !0,
|
|
1167
|
+
loading: M,
|
|
1168
|
+
onClick: H,
|
|
1169
|
+
children: "Verify & enable"
|
|
1170
|
+
}),
|
|
1171
|
+
/* @__PURE__ */ C(P, {
|
|
1172
|
+
variant: "default",
|
|
1173
|
+
fullWidth: !0,
|
|
1174
|
+
disabled: M,
|
|
1175
|
+
onClick: I,
|
|
1176
|
+
children: "Resend code"
|
|
1177
|
+
})
|
|
1178
|
+
]
|
|
1179
|
+
});
|
|
1180
|
+
case "recovery":
|
|
1181
|
+
return /* @__PURE__ */ _("div", {
|
|
1182
|
+
className: "MfaSetupModal__section",
|
|
1183
|
+
children: [
|
|
1184
|
+
/* @__PURE__ */ _("p", {
|
|
1185
|
+
className: "MfaSetupModal__hint",
|
|
1186
|
+
children: [
|
|
1187
|
+
"Save these one-time recovery codes somewhere safe. Each works once if you lose access to your",
|
|
1188
|
+
" ",
|
|
1189
|
+
E === "email" ? "email" : "authenticator",
|
|
1190
|
+
". They are shown only now."
|
|
1191
|
+
]
|
|
1192
|
+
}),
|
|
1193
|
+
/* @__PURE__ */ C("ul", {
|
|
1194
|
+
className: "MfaSetupModal__codes",
|
|
1195
|
+
children: A.map((R) => /* @__PURE__ */ C("li", { children: R }, R))
|
|
1196
|
+
}),
|
|
1197
|
+
/* @__PURE__ */ C(P, {
|
|
1198
|
+
variant: "default",
|
|
1199
|
+
fullWidth: !0,
|
|
1200
|
+
disabled: M,
|
|
1201
|
+
onClick: Y,
|
|
1202
|
+
children: "Copy codes"
|
|
1203
|
+
}),
|
|
1204
|
+
/* @__PURE__ */ C(P, {
|
|
1205
|
+
variant: "success",
|
|
1206
|
+
fullWidth: !0,
|
|
1207
|
+
disabled: M,
|
|
1208
|
+
onClick: b,
|
|
1209
|
+
children: "I've saved them"
|
|
1210
|
+
})
|
|
1211
|
+
]
|
|
1212
|
+
});
|
|
1213
|
+
case "disable":
|
|
1214
|
+
return /* @__PURE__ */ _("div", {
|
|
1215
|
+
className: "MfaSetupModal__section",
|
|
1216
|
+
children: [
|
|
1217
|
+
/* @__PURE__ */ C("p", {
|
|
1218
|
+
className: "MfaSetupModal__hint",
|
|
1219
|
+
children: "Confirm your password to disable two-factor authentication."
|
|
1220
|
+
}),
|
|
1221
|
+
/* @__PURE__ */ C(ne, {
|
|
1222
|
+
placeholder: "Current password",
|
|
1223
|
+
value: p,
|
|
1224
|
+
onChange: f,
|
|
1225
|
+
autoFocus: !0,
|
|
1226
|
+
disabled: M
|
|
1227
|
+
}),
|
|
1228
|
+
/* @__PURE__ */ C(P, {
|
|
1229
|
+
variant: "danger",
|
|
1230
|
+
icon: "lock",
|
|
1231
|
+
fullWidth: !0,
|
|
1232
|
+
loading: M,
|
|
1233
|
+
onClick: z,
|
|
1234
|
+
children: "Disable two-factor"
|
|
1235
|
+
}),
|
|
1236
|
+
/* @__PURE__ */ C(P, {
|
|
1237
|
+
variant: "default",
|
|
1238
|
+
icon: "clear",
|
|
1239
|
+
fullWidth: !0,
|
|
1240
|
+
disabled: M,
|
|
1241
|
+
onClick: () => d("overview"),
|
|
1242
|
+
children: "Cancel"
|
|
1243
|
+
})
|
|
1244
|
+
]
|
|
1245
|
+
});
|
|
1246
|
+
case "regen":
|
|
1247
|
+
return /* @__PURE__ */ _("div", {
|
|
1248
|
+
className: "MfaSetupModal__section",
|
|
1249
|
+
children: [
|
|
1250
|
+
/* @__PURE__ */ C("p", {
|
|
1251
|
+
className: "MfaSetupModal__hint",
|
|
1252
|
+
children: "Confirm your password to generate a new set of recovery codes. The old codes stop working."
|
|
1253
|
+
}),
|
|
1254
|
+
/* @__PURE__ */ C(ne, {
|
|
1255
|
+
placeholder: "Current password",
|
|
1256
|
+
value: p,
|
|
1257
|
+
onChange: f,
|
|
1258
|
+
autoFocus: !0,
|
|
1259
|
+
disabled: M
|
|
1260
|
+
}),
|
|
1261
|
+
/* @__PURE__ */ C(P, {
|
|
1262
|
+
variant: "info",
|
|
1263
|
+
icon: "key",
|
|
1264
|
+
fullWidth: !0,
|
|
1265
|
+
loading: M,
|
|
1266
|
+
onClick: G,
|
|
1267
|
+
children: "Generate new codes"
|
|
1268
|
+
}),
|
|
1269
|
+
/* @__PURE__ */ C(P, {
|
|
1270
|
+
variant: "default",
|
|
1271
|
+
icon: "clear",
|
|
1272
|
+
fullWidth: !0,
|
|
1273
|
+
disabled: M,
|
|
1274
|
+
onClick: () => d("overview"),
|
|
1275
|
+
children: "Cancel"
|
|
1276
|
+
})
|
|
1277
|
+
]
|
|
1278
|
+
});
|
|
1279
|
+
}
|
|
1280
|
+
})(), m && /* @__PURE__ */ C("div", {
|
|
1281
|
+
className: "MfaSetupModal__error",
|
|
1282
|
+
children: m
|
|
1283
|
+
})]
|
|
1284
|
+
}), k && /* @__PURE__ */ C(we, {
|
|
1285
|
+
message: k.message,
|
|
1286
|
+
type: k.type,
|
|
1287
|
+
onClose: () => D(null)
|
|
1288
|
+
})]
|
|
1289
|
+
});
|
|
1290
|
+
}
|
|
1291
|
+
export {
|
|
1292
|
+
ze as MfaSetupModal
|
|
1293
|
+
};
|