@veruspay/react 0.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.cjs +9 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +151 -0
- package/dist/index.js +1937 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/dist/index.js
ADDED
|
@@ -0,0 +1,1937 @@
|
|
|
1
|
+
var Wt = Object.defineProperty;
|
|
2
|
+
var Gt = (e, t, i) => t in e ? Wt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
|
|
3
|
+
var At = (e, t, i) => Gt(e, typeof t != "symbol" ? t + "" : t, i);
|
|
4
|
+
import { jsx as I, jsxs as v, Fragment as Pt } from "react/jsx-runtime";
|
|
5
|
+
import { useState as G, useRef as H, useCallback as X, useEffect as it } from "react";
|
|
6
|
+
const Xt = "https://api-bank.veruspay.co", Zt = "https://dev-api-bank.veruspay.co";
|
|
7
|
+
class $t {
|
|
8
|
+
constructor(t) {
|
|
9
|
+
At(this, "apiUrl");
|
|
10
|
+
this.apiUrl = (t ?? Xt).replace(/\/$/, "");
|
|
11
|
+
}
|
|
12
|
+
async getToken(t, i) {
|
|
13
|
+
const o = new URLSearchParams();
|
|
14
|
+
o.append("grant_type", "client_credentials"), o.append("client_id", t), o.append("client_secret", i);
|
|
15
|
+
const n = await fetch(`${this.apiUrl}/auth/token`, {
|
|
16
|
+
method: "POST",
|
|
17
|
+
headers: { "Content-Type": "application/x-www-form-urlencoded" },
|
|
18
|
+
body: o.toString()
|
|
19
|
+
});
|
|
20
|
+
if (!n.ok) {
|
|
21
|
+
const s = await n.text();
|
|
22
|
+
throw new Error(`Falha ao autenticar: ${n.status} ${s}`);
|
|
23
|
+
}
|
|
24
|
+
return (await n.json()).access_token;
|
|
25
|
+
}
|
|
26
|
+
async createStaticQrCode(t, i) {
|
|
27
|
+
const o = crypto.randomUUID(), n = await fetch(
|
|
28
|
+
`${this.apiUrl}/v1/accounts/${i.accountId}/pix/qr-codes/static`,
|
|
29
|
+
{
|
|
30
|
+
method: "POST",
|
|
31
|
+
headers: {
|
|
32
|
+
"Content-Type": "application/json",
|
|
33
|
+
Authorization: `Bearer ${t}`,
|
|
34
|
+
"Idempotency-Key": o
|
|
35
|
+
},
|
|
36
|
+
body: JSON.stringify({
|
|
37
|
+
accountId: i.accountId,
|
|
38
|
+
pixKey: i.pixKey,
|
|
39
|
+
keyType: "evp",
|
|
40
|
+
amount: i.amount,
|
|
41
|
+
description: i.description,
|
|
42
|
+
name: i.name,
|
|
43
|
+
city: i.city ?? "Brasil",
|
|
44
|
+
postalCode: i.postalCode ?? "00000000"
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
if (!n.ok) {
|
|
49
|
+
const r = await n.text();
|
|
50
|
+
throw new Error(`Erro ao criar QR Code: ${n.status} ${r}`);
|
|
51
|
+
}
|
|
52
|
+
return n.json();
|
|
53
|
+
}
|
|
54
|
+
async createDynamicQrCode(t, i) {
|
|
55
|
+
const o = crypto.randomUUID(), n = await fetch(
|
|
56
|
+
`${this.apiUrl}/v1/accounts/${i.accountId}/pix/qr-codes/dynamic`,
|
|
57
|
+
{
|
|
58
|
+
method: "POST",
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
Authorization: `Bearer ${t}`,
|
|
62
|
+
"Idempotency-Key": o
|
|
63
|
+
},
|
|
64
|
+
body: JSON.stringify({
|
|
65
|
+
accountId: i.accountId,
|
|
66
|
+
pixKey: i.pixKey,
|
|
67
|
+
amount: i.amount,
|
|
68
|
+
description: i.description,
|
|
69
|
+
expirationSeconds: i.expirationSeconds ?? 3600
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
);
|
|
73
|
+
if (!n.ok) {
|
|
74
|
+
const r = await n.text();
|
|
75
|
+
throw new Error(`Erro ao criar QR Code: ${n.status} ${r}`);
|
|
76
|
+
}
|
|
77
|
+
return n.json();
|
|
78
|
+
}
|
|
79
|
+
async getQrCodeStatus(t, i, o) {
|
|
80
|
+
const n = await fetch(
|
|
81
|
+
`${this.apiUrl}/v1/accounts/${i}/pix/qr-codes/${o}/status`,
|
|
82
|
+
{
|
|
83
|
+
headers: { Authorization: `Bearer ${t}` }
|
|
84
|
+
}
|
|
85
|
+
);
|
|
86
|
+
if (!n.ok) {
|
|
87
|
+
const r = await n.text();
|
|
88
|
+
throw new Error(`Erro ao consultar status: ${n.status} ${r}`);
|
|
89
|
+
}
|
|
90
|
+
return n.json();
|
|
91
|
+
}
|
|
92
|
+
async simulatePayment(t, i, o, n, r) {
|
|
93
|
+
const s = await fetch(
|
|
94
|
+
`${this.apiUrl}/v1/accounts/${i}/pix/qr-codes/simulate-payment`,
|
|
95
|
+
{
|
|
96
|
+
method: "POST",
|
|
97
|
+
headers: {
|
|
98
|
+
"Content-Type": "application/json",
|
|
99
|
+
Authorization: `Bearer ${t}`
|
|
100
|
+
},
|
|
101
|
+
body: JSON.stringify({ transactionId: o, amount: n, type: r })
|
|
102
|
+
}
|
|
103
|
+
);
|
|
104
|
+
if (!s.ok) {
|
|
105
|
+
const a = await s.text();
|
|
106
|
+
throw new Error(`Erro ao simular pagamento: ${s.status} ${a}`);
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
const te = 3e3;
|
|
111
|
+
function ee(e) {
|
|
112
|
+
const {
|
|
113
|
+
clientId: t,
|
|
114
|
+
clientSecret: i,
|
|
115
|
+
accountId: o,
|
|
116
|
+
pixKey: n,
|
|
117
|
+
amount: r,
|
|
118
|
+
description: s,
|
|
119
|
+
type: a = "static",
|
|
120
|
+
name: c = "VerusPay",
|
|
121
|
+
city: u,
|
|
122
|
+
postalCode: l,
|
|
123
|
+
expirationSeconds: E,
|
|
124
|
+
apiUrl: p,
|
|
125
|
+
sandbox: d = !1,
|
|
126
|
+
onSuccess: m,
|
|
127
|
+
onError: g
|
|
128
|
+
} = e, [b, y] = G(null), [w, h] = G(null), [f, C] = G("idle"), [B, S] = G(null), [R, M] = G(!1), P = H(null), _ = H(0), D = H(null), k = p ?? (d ? Zt : void 0), q = H(new $t(k)), W = H(!0), V = X(async () => {
|
|
129
|
+
const A = Date.now();
|
|
130
|
+
if (P.current && A < _.current - 6e4)
|
|
131
|
+
return P.current;
|
|
132
|
+
const L = await q.current.getToken(t, i);
|
|
133
|
+
return P.current = L, _.current = A + 59 * 60 * 1e3, L;
|
|
134
|
+
}, [t, i]), O = X(() => {
|
|
135
|
+
D.current && (clearInterval(D.current), D.current = null);
|
|
136
|
+
}, []), nt = X(
|
|
137
|
+
async (A) => {
|
|
138
|
+
try {
|
|
139
|
+
const L = await V(), N = await q.current.getQrCodeStatus(L, o, A);
|
|
140
|
+
if (!W.current) return;
|
|
141
|
+
N.status === "completed" ? (O(), C("completed"), m == null || m(A)) : (N.status === "expired" || N.status === "cancelled") && (O(), C("error"), S(`QR Code ${N.status === "expired" ? "expirado" : "cancelado"}.`));
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
},
|
|
145
|
+
[o, V, m, O]
|
|
146
|
+
);
|
|
147
|
+
it(() => {
|
|
148
|
+
W.current = !0;
|
|
149
|
+
let A = !1;
|
|
150
|
+
async function L() {
|
|
151
|
+
C("loading"), S(null);
|
|
152
|
+
try {
|
|
153
|
+
const N = await V();
|
|
154
|
+
if (A) return;
|
|
155
|
+
let K;
|
|
156
|
+
if (a === "dynamic" ? K = await q.current.createDynamicQrCode(N, {
|
|
157
|
+
accountId: o,
|
|
158
|
+
pixKey: n,
|
|
159
|
+
amount: r,
|
|
160
|
+
description: s,
|
|
161
|
+
expirationSeconds: E
|
|
162
|
+
}) : K = await q.current.createStaticQrCode(N, {
|
|
163
|
+
accountId: o,
|
|
164
|
+
pixKey: n,
|
|
165
|
+
amount: r,
|
|
166
|
+
description: s,
|
|
167
|
+
name: c,
|
|
168
|
+
city: u,
|
|
169
|
+
postalCode: l
|
|
170
|
+
}), A || !W.current) return;
|
|
171
|
+
y(K.qrCodeEmv), h(K.txId), C("active");
|
|
172
|
+
} catch (N) {
|
|
173
|
+
if (A || !W.current) return;
|
|
174
|
+
const K = N instanceof Error ? N.message : "Erro ao gerar QR Code";
|
|
175
|
+
C("error"), S(K), g == null || g(N instanceof Error ? N : new Error(K));
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
return L(), () => {
|
|
179
|
+
A = !0;
|
|
180
|
+
};
|
|
181
|
+
}, [
|
|
182
|
+
o,
|
|
183
|
+
r,
|
|
184
|
+
u,
|
|
185
|
+
s,
|
|
186
|
+
E,
|
|
187
|
+
V,
|
|
188
|
+
c,
|
|
189
|
+
g,
|
|
190
|
+
n,
|
|
191
|
+
l,
|
|
192
|
+
a
|
|
193
|
+
]), it(() => {
|
|
194
|
+
if (!(f !== "active" || !w))
|
|
195
|
+
return D.current = setInterval(() => {
|
|
196
|
+
nt(w);
|
|
197
|
+
}, te), () => O();
|
|
198
|
+
}, [f, w, nt, O]), it(() => () => {
|
|
199
|
+
W.current = !1, O();
|
|
200
|
+
}, [O]);
|
|
201
|
+
const Yt = X(() => {
|
|
202
|
+
b && navigator.clipboard.writeText(b).then(() => {
|
|
203
|
+
M(!0), setTimeout(() => M(!1), 2e3);
|
|
204
|
+
});
|
|
205
|
+
}, [b]), qt = X(async () => {
|
|
206
|
+
if (!(!d || !w))
|
|
207
|
+
try {
|
|
208
|
+
const A = await V(), L = a === "dynamic" ? "cob" : "static";
|
|
209
|
+
await q.current.simulatePayment(A, o, w, r, L), await new Promise((N) => setTimeout(N, 1e3)), await nt(w);
|
|
210
|
+
} catch (A) {
|
|
211
|
+
const L = A instanceof Error ? A.message : "Erro ao simular pagamento";
|
|
212
|
+
C("error"), S(L), g == null || g(A instanceof Error ? A : new Error(L));
|
|
213
|
+
}
|
|
214
|
+
}, [d, w, V, a, o, r, nt, g]);
|
|
215
|
+
return {
|
|
216
|
+
qrCodeEmv: b,
|
|
217
|
+
txId: w,
|
|
218
|
+
status: f,
|
|
219
|
+
error: B,
|
|
220
|
+
copyCode: Yt,
|
|
221
|
+
copied: R,
|
|
222
|
+
simulatePayment: qt
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
var tt = {}, ne = function() {
|
|
226
|
+
return typeof Promise == "function" && Promise.prototype && Promise.prototype.then;
|
|
227
|
+
}, Mt = {}, x = {};
|
|
228
|
+
let bt;
|
|
229
|
+
const oe = [
|
|
230
|
+
0,
|
|
231
|
+
// Not used
|
|
232
|
+
26,
|
|
233
|
+
44,
|
|
234
|
+
70,
|
|
235
|
+
100,
|
|
236
|
+
134,
|
|
237
|
+
172,
|
|
238
|
+
196,
|
|
239
|
+
242,
|
|
240
|
+
292,
|
|
241
|
+
346,
|
|
242
|
+
404,
|
|
243
|
+
466,
|
|
244
|
+
532,
|
|
245
|
+
581,
|
|
246
|
+
655,
|
|
247
|
+
733,
|
|
248
|
+
815,
|
|
249
|
+
901,
|
|
250
|
+
991,
|
|
251
|
+
1085,
|
|
252
|
+
1156,
|
|
253
|
+
1258,
|
|
254
|
+
1364,
|
|
255
|
+
1474,
|
|
256
|
+
1588,
|
|
257
|
+
1706,
|
|
258
|
+
1828,
|
|
259
|
+
1921,
|
|
260
|
+
2051,
|
|
261
|
+
2185,
|
|
262
|
+
2323,
|
|
263
|
+
2465,
|
|
264
|
+
2611,
|
|
265
|
+
2761,
|
|
266
|
+
2876,
|
|
267
|
+
3034,
|
|
268
|
+
3196,
|
|
269
|
+
3362,
|
|
270
|
+
3532,
|
|
271
|
+
3706
|
|
272
|
+
];
|
|
273
|
+
x.getSymbolSize = function(t) {
|
|
274
|
+
if (!t) throw new Error('"version" cannot be null or undefined');
|
|
275
|
+
if (t < 1 || t > 40) throw new Error('"version" should be in range from 1 to 40');
|
|
276
|
+
return t * 4 + 17;
|
|
277
|
+
};
|
|
278
|
+
x.getSymbolTotalCodewords = function(t) {
|
|
279
|
+
return oe[t];
|
|
280
|
+
};
|
|
281
|
+
x.getBCHDigit = function(e) {
|
|
282
|
+
let t = 0;
|
|
283
|
+
for (; e !== 0; )
|
|
284
|
+
t++, e >>>= 1;
|
|
285
|
+
return t;
|
|
286
|
+
};
|
|
287
|
+
x.setToSJISFunction = function(t) {
|
|
288
|
+
if (typeof t != "function")
|
|
289
|
+
throw new Error('"toSJISFunc" is not a valid function.');
|
|
290
|
+
bt = t;
|
|
291
|
+
};
|
|
292
|
+
x.isKanjiModeEnabled = function() {
|
|
293
|
+
return typeof bt < "u";
|
|
294
|
+
};
|
|
295
|
+
x.toSJIS = function(t) {
|
|
296
|
+
return bt(t);
|
|
297
|
+
};
|
|
298
|
+
var ct = {};
|
|
299
|
+
(function(e) {
|
|
300
|
+
e.L = { bit: 1 }, e.M = { bit: 0 }, e.Q = { bit: 3 }, e.H = { bit: 2 };
|
|
301
|
+
function t(i) {
|
|
302
|
+
if (typeof i != "string")
|
|
303
|
+
throw new Error("Param is not a string");
|
|
304
|
+
switch (i.toLowerCase()) {
|
|
305
|
+
case "l":
|
|
306
|
+
case "low":
|
|
307
|
+
return e.L;
|
|
308
|
+
case "m":
|
|
309
|
+
case "medium":
|
|
310
|
+
return e.M;
|
|
311
|
+
case "q":
|
|
312
|
+
case "quartile":
|
|
313
|
+
return e.Q;
|
|
314
|
+
case "h":
|
|
315
|
+
case "high":
|
|
316
|
+
return e.H;
|
|
317
|
+
default:
|
|
318
|
+
throw new Error("Unknown EC Level: " + i);
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
e.isValid = function(o) {
|
|
322
|
+
return o && typeof o.bit < "u" && o.bit >= 0 && o.bit < 4;
|
|
323
|
+
}, e.from = function(o, n) {
|
|
324
|
+
if (e.isValid(o))
|
|
325
|
+
return o;
|
|
326
|
+
try {
|
|
327
|
+
return t(o);
|
|
328
|
+
} catch {
|
|
329
|
+
return n;
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
})(ct);
|
|
333
|
+
function kt() {
|
|
334
|
+
this.buffer = [], this.length = 0;
|
|
335
|
+
}
|
|
336
|
+
kt.prototype = {
|
|
337
|
+
get: function(e) {
|
|
338
|
+
const t = Math.floor(e / 8);
|
|
339
|
+
return (this.buffer[t] >>> 7 - e % 8 & 1) === 1;
|
|
340
|
+
},
|
|
341
|
+
put: function(e, t) {
|
|
342
|
+
for (let i = 0; i < t; i++)
|
|
343
|
+
this.putBit((e >>> t - i - 1 & 1) === 1);
|
|
344
|
+
},
|
|
345
|
+
getLengthInBits: function() {
|
|
346
|
+
return this.length;
|
|
347
|
+
},
|
|
348
|
+
putBit: function(e) {
|
|
349
|
+
const t = Math.floor(this.length / 8);
|
|
350
|
+
this.buffer.length <= t && this.buffer.push(0), e && (this.buffer[t] |= 128 >>> this.length % 8), this.length++;
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
var re = kt;
|
|
354
|
+
function et(e) {
|
|
355
|
+
if (!e || e < 1)
|
|
356
|
+
throw new Error("BitMatrix size must be defined and greater than 0");
|
|
357
|
+
this.size = e, this.data = new Uint8Array(e * e), this.reservedBit = new Uint8Array(e * e);
|
|
358
|
+
}
|
|
359
|
+
et.prototype.set = function(e, t, i, o) {
|
|
360
|
+
const n = e * this.size + t;
|
|
361
|
+
this.data[n] = i, o && (this.reservedBit[n] = !0);
|
|
362
|
+
};
|
|
363
|
+
et.prototype.get = function(e, t) {
|
|
364
|
+
return this.data[e * this.size + t];
|
|
365
|
+
};
|
|
366
|
+
et.prototype.xor = function(e, t, i) {
|
|
367
|
+
this.data[e * this.size + t] ^= i;
|
|
368
|
+
};
|
|
369
|
+
et.prototype.isReserved = function(e, t) {
|
|
370
|
+
return this.reservedBit[e * this.size + t];
|
|
371
|
+
};
|
|
372
|
+
var ie = et, Lt = {};
|
|
373
|
+
(function(e) {
|
|
374
|
+
const t = x.getSymbolSize;
|
|
375
|
+
e.getRowColCoords = function(o) {
|
|
376
|
+
if (o === 1) return [];
|
|
377
|
+
const n = Math.floor(o / 7) + 2, r = t(o), s = r === 145 ? 26 : Math.ceil((r - 13) / (2 * n - 2)) * 2, a = [r - 7];
|
|
378
|
+
for (let c = 1; c < n - 1; c++)
|
|
379
|
+
a[c] = a[c - 1] - s;
|
|
380
|
+
return a.push(6), a.reverse();
|
|
381
|
+
}, e.getPositions = function(o) {
|
|
382
|
+
const n = [], r = e.getRowColCoords(o), s = r.length;
|
|
383
|
+
for (let a = 0; a < s; a++)
|
|
384
|
+
for (let c = 0; c < s; c++)
|
|
385
|
+
a === 0 && c === 0 || // top-left
|
|
386
|
+
a === 0 && c === s - 1 || // bottom-left
|
|
387
|
+
a === s - 1 && c === 0 || n.push([r[a], r[c]]);
|
|
388
|
+
return n;
|
|
389
|
+
};
|
|
390
|
+
})(Lt);
|
|
391
|
+
var vt = {};
|
|
392
|
+
const se = x.getSymbolSize, Nt = 7;
|
|
393
|
+
vt.getPositions = function(t) {
|
|
394
|
+
const i = se(t);
|
|
395
|
+
return [
|
|
396
|
+
// top-left
|
|
397
|
+
[0, 0],
|
|
398
|
+
// top-right
|
|
399
|
+
[i - Nt, 0],
|
|
400
|
+
// bottom-left
|
|
401
|
+
[0, i - Nt]
|
|
402
|
+
];
|
|
403
|
+
};
|
|
404
|
+
var Ut = {};
|
|
405
|
+
(function(e) {
|
|
406
|
+
e.Patterns = {
|
|
407
|
+
PATTERN000: 0,
|
|
408
|
+
PATTERN001: 1,
|
|
409
|
+
PATTERN010: 2,
|
|
410
|
+
PATTERN011: 3,
|
|
411
|
+
PATTERN100: 4,
|
|
412
|
+
PATTERN101: 5,
|
|
413
|
+
PATTERN110: 6,
|
|
414
|
+
PATTERN111: 7
|
|
415
|
+
};
|
|
416
|
+
const t = {
|
|
417
|
+
N1: 3,
|
|
418
|
+
N2: 3,
|
|
419
|
+
N3: 40,
|
|
420
|
+
N4: 10
|
|
421
|
+
};
|
|
422
|
+
e.isValid = function(n) {
|
|
423
|
+
return n != null && n !== "" && !isNaN(n) && n >= 0 && n <= 7;
|
|
424
|
+
}, e.from = function(n) {
|
|
425
|
+
return e.isValid(n) ? parseInt(n, 10) : void 0;
|
|
426
|
+
}, e.getPenaltyN1 = function(n) {
|
|
427
|
+
const r = n.size;
|
|
428
|
+
let s = 0, a = 0, c = 0, u = null, l = null;
|
|
429
|
+
for (let E = 0; E < r; E++) {
|
|
430
|
+
a = c = 0, u = l = null;
|
|
431
|
+
for (let p = 0; p < r; p++) {
|
|
432
|
+
let d = n.get(E, p);
|
|
433
|
+
d === u ? a++ : (a >= 5 && (s += t.N1 + (a - 5)), u = d, a = 1), d = n.get(p, E), d === l ? c++ : (c >= 5 && (s += t.N1 + (c - 5)), l = d, c = 1);
|
|
434
|
+
}
|
|
435
|
+
a >= 5 && (s += t.N1 + (a - 5)), c >= 5 && (s += t.N1 + (c - 5));
|
|
436
|
+
}
|
|
437
|
+
return s;
|
|
438
|
+
}, e.getPenaltyN2 = function(n) {
|
|
439
|
+
const r = n.size;
|
|
440
|
+
let s = 0;
|
|
441
|
+
for (let a = 0; a < r - 1; a++)
|
|
442
|
+
for (let c = 0; c < r - 1; c++) {
|
|
443
|
+
const u = n.get(a, c) + n.get(a, c + 1) + n.get(a + 1, c) + n.get(a + 1, c + 1);
|
|
444
|
+
(u === 4 || u === 0) && s++;
|
|
445
|
+
}
|
|
446
|
+
return s * t.N2;
|
|
447
|
+
}, e.getPenaltyN3 = function(n) {
|
|
448
|
+
const r = n.size;
|
|
449
|
+
let s = 0, a = 0, c = 0;
|
|
450
|
+
for (let u = 0; u < r; u++) {
|
|
451
|
+
a = c = 0;
|
|
452
|
+
for (let l = 0; l < r; l++)
|
|
453
|
+
a = a << 1 & 2047 | n.get(u, l), l >= 10 && (a === 1488 || a === 93) && s++, c = c << 1 & 2047 | n.get(l, u), l >= 10 && (c === 1488 || c === 93) && s++;
|
|
454
|
+
}
|
|
455
|
+
return s * t.N3;
|
|
456
|
+
}, e.getPenaltyN4 = function(n) {
|
|
457
|
+
let r = 0;
|
|
458
|
+
const s = n.data.length;
|
|
459
|
+
for (let c = 0; c < s; c++) r += n.data[c];
|
|
460
|
+
return Math.abs(Math.ceil(r * 100 / s / 5) - 10) * t.N4;
|
|
461
|
+
};
|
|
462
|
+
function i(o, n, r) {
|
|
463
|
+
switch (o) {
|
|
464
|
+
case e.Patterns.PATTERN000:
|
|
465
|
+
return (n + r) % 2 === 0;
|
|
466
|
+
case e.Patterns.PATTERN001:
|
|
467
|
+
return n % 2 === 0;
|
|
468
|
+
case e.Patterns.PATTERN010:
|
|
469
|
+
return r % 3 === 0;
|
|
470
|
+
case e.Patterns.PATTERN011:
|
|
471
|
+
return (n + r) % 3 === 0;
|
|
472
|
+
case e.Patterns.PATTERN100:
|
|
473
|
+
return (Math.floor(n / 2) + Math.floor(r / 3)) % 2 === 0;
|
|
474
|
+
case e.Patterns.PATTERN101:
|
|
475
|
+
return n * r % 2 + n * r % 3 === 0;
|
|
476
|
+
case e.Patterns.PATTERN110:
|
|
477
|
+
return (n * r % 2 + n * r % 3) % 2 === 0;
|
|
478
|
+
case e.Patterns.PATTERN111:
|
|
479
|
+
return (n * r % 3 + (n + r) % 2) % 2 === 0;
|
|
480
|
+
default:
|
|
481
|
+
throw new Error("bad maskPattern:" + o);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
e.applyMask = function(n, r) {
|
|
485
|
+
const s = r.size;
|
|
486
|
+
for (let a = 0; a < s; a++)
|
|
487
|
+
for (let c = 0; c < s; c++)
|
|
488
|
+
r.isReserved(c, a) || r.xor(c, a, i(n, c, a));
|
|
489
|
+
}, e.getBestMask = function(n, r) {
|
|
490
|
+
const s = Object.keys(e.Patterns).length;
|
|
491
|
+
let a = 0, c = 1 / 0;
|
|
492
|
+
for (let u = 0; u < s; u++) {
|
|
493
|
+
r(u), e.applyMask(u, n);
|
|
494
|
+
const l = e.getPenaltyN1(n) + e.getPenaltyN2(n) + e.getPenaltyN3(n) + e.getPenaltyN4(n);
|
|
495
|
+
e.applyMask(u, n), l < c && (c = l, a = u);
|
|
496
|
+
}
|
|
497
|
+
return a;
|
|
498
|
+
};
|
|
499
|
+
})(Ut);
|
|
500
|
+
var ut = {};
|
|
501
|
+
const F = ct, ot = [
|
|
502
|
+
// L M Q H
|
|
503
|
+
1,
|
|
504
|
+
1,
|
|
505
|
+
1,
|
|
506
|
+
1,
|
|
507
|
+
1,
|
|
508
|
+
1,
|
|
509
|
+
1,
|
|
510
|
+
1,
|
|
511
|
+
1,
|
|
512
|
+
1,
|
|
513
|
+
2,
|
|
514
|
+
2,
|
|
515
|
+
1,
|
|
516
|
+
2,
|
|
517
|
+
2,
|
|
518
|
+
4,
|
|
519
|
+
1,
|
|
520
|
+
2,
|
|
521
|
+
4,
|
|
522
|
+
4,
|
|
523
|
+
2,
|
|
524
|
+
4,
|
|
525
|
+
4,
|
|
526
|
+
4,
|
|
527
|
+
2,
|
|
528
|
+
4,
|
|
529
|
+
6,
|
|
530
|
+
5,
|
|
531
|
+
2,
|
|
532
|
+
4,
|
|
533
|
+
6,
|
|
534
|
+
6,
|
|
535
|
+
2,
|
|
536
|
+
5,
|
|
537
|
+
8,
|
|
538
|
+
8,
|
|
539
|
+
4,
|
|
540
|
+
5,
|
|
541
|
+
8,
|
|
542
|
+
8,
|
|
543
|
+
4,
|
|
544
|
+
5,
|
|
545
|
+
8,
|
|
546
|
+
11,
|
|
547
|
+
4,
|
|
548
|
+
8,
|
|
549
|
+
10,
|
|
550
|
+
11,
|
|
551
|
+
4,
|
|
552
|
+
9,
|
|
553
|
+
12,
|
|
554
|
+
16,
|
|
555
|
+
4,
|
|
556
|
+
9,
|
|
557
|
+
16,
|
|
558
|
+
16,
|
|
559
|
+
6,
|
|
560
|
+
10,
|
|
561
|
+
12,
|
|
562
|
+
18,
|
|
563
|
+
6,
|
|
564
|
+
10,
|
|
565
|
+
17,
|
|
566
|
+
16,
|
|
567
|
+
6,
|
|
568
|
+
11,
|
|
569
|
+
16,
|
|
570
|
+
19,
|
|
571
|
+
6,
|
|
572
|
+
13,
|
|
573
|
+
18,
|
|
574
|
+
21,
|
|
575
|
+
7,
|
|
576
|
+
14,
|
|
577
|
+
21,
|
|
578
|
+
25,
|
|
579
|
+
8,
|
|
580
|
+
16,
|
|
581
|
+
20,
|
|
582
|
+
25,
|
|
583
|
+
8,
|
|
584
|
+
17,
|
|
585
|
+
23,
|
|
586
|
+
25,
|
|
587
|
+
9,
|
|
588
|
+
17,
|
|
589
|
+
23,
|
|
590
|
+
34,
|
|
591
|
+
9,
|
|
592
|
+
18,
|
|
593
|
+
25,
|
|
594
|
+
30,
|
|
595
|
+
10,
|
|
596
|
+
20,
|
|
597
|
+
27,
|
|
598
|
+
32,
|
|
599
|
+
12,
|
|
600
|
+
21,
|
|
601
|
+
29,
|
|
602
|
+
35,
|
|
603
|
+
12,
|
|
604
|
+
23,
|
|
605
|
+
34,
|
|
606
|
+
37,
|
|
607
|
+
12,
|
|
608
|
+
25,
|
|
609
|
+
34,
|
|
610
|
+
40,
|
|
611
|
+
13,
|
|
612
|
+
26,
|
|
613
|
+
35,
|
|
614
|
+
42,
|
|
615
|
+
14,
|
|
616
|
+
28,
|
|
617
|
+
38,
|
|
618
|
+
45,
|
|
619
|
+
15,
|
|
620
|
+
29,
|
|
621
|
+
40,
|
|
622
|
+
48,
|
|
623
|
+
16,
|
|
624
|
+
31,
|
|
625
|
+
43,
|
|
626
|
+
51,
|
|
627
|
+
17,
|
|
628
|
+
33,
|
|
629
|
+
45,
|
|
630
|
+
54,
|
|
631
|
+
18,
|
|
632
|
+
35,
|
|
633
|
+
48,
|
|
634
|
+
57,
|
|
635
|
+
19,
|
|
636
|
+
37,
|
|
637
|
+
51,
|
|
638
|
+
60,
|
|
639
|
+
19,
|
|
640
|
+
38,
|
|
641
|
+
53,
|
|
642
|
+
63,
|
|
643
|
+
20,
|
|
644
|
+
40,
|
|
645
|
+
56,
|
|
646
|
+
66,
|
|
647
|
+
21,
|
|
648
|
+
43,
|
|
649
|
+
59,
|
|
650
|
+
70,
|
|
651
|
+
22,
|
|
652
|
+
45,
|
|
653
|
+
62,
|
|
654
|
+
74,
|
|
655
|
+
24,
|
|
656
|
+
47,
|
|
657
|
+
65,
|
|
658
|
+
77,
|
|
659
|
+
25,
|
|
660
|
+
49,
|
|
661
|
+
68,
|
|
662
|
+
81
|
|
663
|
+
], rt = [
|
|
664
|
+
// L M Q H
|
|
665
|
+
7,
|
|
666
|
+
10,
|
|
667
|
+
13,
|
|
668
|
+
17,
|
|
669
|
+
10,
|
|
670
|
+
16,
|
|
671
|
+
22,
|
|
672
|
+
28,
|
|
673
|
+
15,
|
|
674
|
+
26,
|
|
675
|
+
36,
|
|
676
|
+
44,
|
|
677
|
+
20,
|
|
678
|
+
36,
|
|
679
|
+
52,
|
|
680
|
+
64,
|
|
681
|
+
26,
|
|
682
|
+
48,
|
|
683
|
+
72,
|
|
684
|
+
88,
|
|
685
|
+
36,
|
|
686
|
+
64,
|
|
687
|
+
96,
|
|
688
|
+
112,
|
|
689
|
+
40,
|
|
690
|
+
72,
|
|
691
|
+
108,
|
|
692
|
+
130,
|
|
693
|
+
48,
|
|
694
|
+
88,
|
|
695
|
+
132,
|
|
696
|
+
156,
|
|
697
|
+
60,
|
|
698
|
+
110,
|
|
699
|
+
160,
|
|
700
|
+
192,
|
|
701
|
+
72,
|
|
702
|
+
130,
|
|
703
|
+
192,
|
|
704
|
+
224,
|
|
705
|
+
80,
|
|
706
|
+
150,
|
|
707
|
+
224,
|
|
708
|
+
264,
|
|
709
|
+
96,
|
|
710
|
+
176,
|
|
711
|
+
260,
|
|
712
|
+
308,
|
|
713
|
+
104,
|
|
714
|
+
198,
|
|
715
|
+
288,
|
|
716
|
+
352,
|
|
717
|
+
120,
|
|
718
|
+
216,
|
|
719
|
+
320,
|
|
720
|
+
384,
|
|
721
|
+
132,
|
|
722
|
+
240,
|
|
723
|
+
360,
|
|
724
|
+
432,
|
|
725
|
+
144,
|
|
726
|
+
280,
|
|
727
|
+
408,
|
|
728
|
+
480,
|
|
729
|
+
168,
|
|
730
|
+
308,
|
|
731
|
+
448,
|
|
732
|
+
532,
|
|
733
|
+
180,
|
|
734
|
+
338,
|
|
735
|
+
504,
|
|
736
|
+
588,
|
|
737
|
+
196,
|
|
738
|
+
364,
|
|
739
|
+
546,
|
|
740
|
+
650,
|
|
741
|
+
224,
|
|
742
|
+
416,
|
|
743
|
+
600,
|
|
744
|
+
700,
|
|
745
|
+
224,
|
|
746
|
+
442,
|
|
747
|
+
644,
|
|
748
|
+
750,
|
|
749
|
+
252,
|
|
750
|
+
476,
|
|
751
|
+
690,
|
|
752
|
+
816,
|
|
753
|
+
270,
|
|
754
|
+
504,
|
|
755
|
+
750,
|
|
756
|
+
900,
|
|
757
|
+
300,
|
|
758
|
+
560,
|
|
759
|
+
810,
|
|
760
|
+
960,
|
|
761
|
+
312,
|
|
762
|
+
588,
|
|
763
|
+
870,
|
|
764
|
+
1050,
|
|
765
|
+
336,
|
|
766
|
+
644,
|
|
767
|
+
952,
|
|
768
|
+
1110,
|
|
769
|
+
360,
|
|
770
|
+
700,
|
|
771
|
+
1020,
|
|
772
|
+
1200,
|
|
773
|
+
390,
|
|
774
|
+
728,
|
|
775
|
+
1050,
|
|
776
|
+
1260,
|
|
777
|
+
420,
|
|
778
|
+
784,
|
|
779
|
+
1140,
|
|
780
|
+
1350,
|
|
781
|
+
450,
|
|
782
|
+
812,
|
|
783
|
+
1200,
|
|
784
|
+
1440,
|
|
785
|
+
480,
|
|
786
|
+
868,
|
|
787
|
+
1290,
|
|
788
|
+
1530,
|
|
789
|
+
510,
|
|
790
|
+
924,
|
|
791
|
+
1350,
|
|
792
|
+
1620,
|
|
793
|
+
540,
|
|
794
|
+
980,
|
|
795
|
+
1440,
|
|
796
|
+
1710,
|
|
797
|
+
570,
|
|
798
|
+
1036,
|
|
799
|
+
1530,
|
|
800
|
+
1800,
|
|
801
|
+
570,
|
|
802
|
+
1064,
|
|
803
|
+
1590,
|
|
804
|
+
1890,
|
|
805
|
+
600,
|
|
806
|
+
1120,
|
|
807
|
+
1680,
|
|
808
|
+
1980,
|
|
809
|
+
630,
|
|
810
|
+
1204,
|
|
811
|
+
1770,
|
|
812
|
+
2100,
|
|
813
|
+
660,
|
|
814
|
+
1260,
|
|
815
|
+
1860,
|
|
816
|
+
2220,
|
|
817
|
+
720,
|
|
818
|
+
1316,
|
|
819
|
+
1950,
|
|
820
|
+
2310,
|
|
821
|
+
750,
|
|
822
|
+
1372,
|
|
823
|
+
2040,
|
|
824
|
+
2430
|
|
825
|
+
];
|
|
826
|
+
ut.getBlocksCount = function(t, i) {
|
|
827
|
+
switch (i) {
|
|
828
|
+
case F.L:
|
|
829
|
+
return ot[(t - 1) * 4 + 0];
|
|
830
|
+
case F.M:
|
|
831
|
+
return ot[(t - 1) * 4 + 1];
|
|
832
|
+
case F.Q:
|
|
833
|
+
return ot[(t - 1) * 4 + 2];
|
|
834
|
+
case F.H:
|
|
835
|
+
return ot[(t - 1) * 4 + 3];
|
|
836
|
+
default:
|
|
837
|
+
return;
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
ut.getTotalCodewordsCount = function(t, i) {
|
|
841
|
+
switch (i) {
|
|
842
|
+
case F.L:
|
|
843
|
+
return rt[(t - 1) * 4 + 0];
|
|
844
|
+
case F.M:
|
|
845
|
+
return rt[(t - 1) * 4 + 1];
|
|
846
|
+
case F.Q:
|
|
847
|
+
return rt[(t - 1) * 4 + 2];
|
|
848
|
+
case F.H:
|
|
849
|
+
return rt[(t - 1) * 4 + 3];
|
|
850
|
+
default:
|
|
851
|
+
return;
|
|
852
|
+
}
|
|
853
|
+
};
|
|
854
|
+
var _t = {}, lt = {};
|
|
855
|
+
const Z = new Uint8Array(512), st = new Uint8Array(256);
|
|
856
|
+
(function() {
|
|
857
|
+
let t = 1;
|
|
858
|
+
for (let i = 0; i < 255; i++)
|
|
859
|
+
Z[i] = t, st[t] = i, t <<= 1, t & 256 && (t ^= 285);
|
|
860
|
+
for (let i = 255; i < 512; i++)
|
|
861
|
+
Z[i] = Z[i - 255];
|
|
862
|
+
})();
|
|
863
|
+
lt.log = function(t) {
|
|
864
|
+
if (t < 1) throw new Error("log(" + t + ")");
|
|
865
|
+
return st[t];
|
|
866
|
+
};
|
|
867
|
+
lt.exp = function(t) {
|
|
868
|
+
return Z[t];
|
|
869
|
+
};
|
|
870
|
+
lt.mul = function(t, i) {
|
|
871
|
+
return t === 0 || i === 0 ? 0 : Z[st[t] + st[i]];
|
|
872
|
+
};
|
|
873
|
+
(function(e) {
|
|
874
|
+
const t = lt;
|
|
875
|
+
e.mul = function(o, n) {
|
|
876
|
+
const r = new Uint8Array(o.length + n.length - 1);
|
|
877
|
+
for (let s = 0; s < o.length; s++)
|
|
878
|
+
for (let a = 0; a < n.length; a++)
|
|
879
|
+
r[s + a] ^= t.mul(o[s], n[a]);
|
|
880
|
+
return r;
|
|
881
|
+
}, e.mod = function(o, n) {
|
|
882
|
+
let r = new Uint8Array(o);
|
|
883
|
+
for (; r.length - n.length >= 0; ) {
|
|
884
|
+
const s = r[0];
|
|
885
|
+
for (let c = 0; c < n.length; c++)
|
|
886
|
+
r[c] ^= t.mul(n[c], s);
|
|
887
|
+
let a = 0;
|
|
888
|
+
for (; a < r.length && r[a] === 0; ) a++;
|
|
889
|
+
r = r.slice(a);
|
|
890
|
+
}
|
|
891
|
+
return r;
|
|
892
|
+
}, e.generateECPolynomial = function(o) {
|
|
893
|
+
let n = new Uint8Array([1]);
|
|
894
|
+
for (let r = 0; r < o; r++)
|
|
895
|
+
n = e.mul(n, new Uint8Array([1, t.exp(r)]));
|
|
896
|
+
return n;
|
|
897
|
+
};
|
|
898
|
+
})(_t);
|
|
899
|
+
const Dt = _t;
|
|
900
|
+
function Bt(e) {
|
|
901
|
+
this.genPoly = void 0, this.degree = e, this.degree && this.initialize(this.degree);
|
|
902
|
+
}
|
|
903
|
+
Bt.prototype.initialize = function(t) {
|
|
904
|
+
this.degree = t, this.genPoly = Dt.generateECPolynomial(this.degree);
|
|
905
|
+
};
|
|
906
|
+
Bt.prototype.encode = function(t) {
|
|
907
|
+
if (!this.genPoly)
|
|
908
|
+
throw new Error("Encoder not initialized");
|
|
909
|
+
const i = new Uint8Array(t.length + this.degree);
|
|
910
|
+
i.set(t);
|
|
911
|
+
const o = Dt.mod(i, this.genPoly), n = this.degree - o.length;
|
|
912
|
+
if (n > 0) {
|
|
913
|
+
const r = new Uint8Array(this.degree);
|
|
914
|
+
return r.set(o, n), r;
|
|
915
|
+
}
|
|
916
|
+
return o;
|
|
917
|
+
};
|
|
918
|
+
var ae = Bt, Ft = {}, z = {}, St = {};
|
|
919
|
+
St.isValid = function(t) {
|
|
920
|
+
return !isNaN(t) && t >= 1 && t <= 40;
|
|
921
|
+
};
|
|
922
|
+
var U = {};
|
|
923
|
+
const zt = "[0-9]+", ce = "[A-Z $%*+\\-./:]+";
|
|
924
|
+
let $ = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
|
|
925
|
+
$ = $.replace(/u/g, "\\u");
|
|
926
|
+
const ue = "(?:(?![A-Z0-9 $%*+\\-./:]|" + $ + `)(?:.|[\r
|
|
927
|
+
]))+`;
|
|
928
|
+
U.KANJI = new RegExp($, "g");
|
|
929
|
+
U.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
|
|
930
|
+
U.BYTE = new RegExp(ue, "g");
|
|
931
|
+
U.NUMERIC = new RegExp(zt, "g");
|
|
932
|
+
U.ALPHANUMERIC = new RegExp(ce, "g");
|
|
933
|
+
const le = new RegExp("^" + $ + "$"), de = new RegExp("^" + zt + "$"), fe = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
|
|
934
|
+
U.testKanji = function(t) {
|
|
935
|
+
return le.test(t);
|
|
936
|
+
};
|
|
937
|
+
U.testNumeric = function(t) {
|
|
938
|
+
return de.test(t);
|
|
939
|
+
};
|
|
940
|
+
U.testAlphanumeric = function(t) {
|
|
941
|
+
return fe.test(t);
|
|
942
|
+
};
|
|
943
|
+
(function(e) {
|
|
944
|
+
const t = St, i = U;
|
|
945
|
+
e.NUMERIC = {
|
|
946
|
+
id: "Numeric",
|
|
947
|
+
bit: 1,
|
|
948
|
+
ccBits: [10, 12, 14]
|
|
949
|
+
}, e.ALPHANUMERIC = {
|
|
950
|
+
id: "Alphanumeric",
|
|
951
|
+
bit: 2,
|
|
952
|
+
ccBits: [9, 11, 13]
|
|
953
|
+
}, e.BYTE = {
|
|
954
|
+
id: "Byte",
|
|
955
|
+
bit: 4,
|
|
956
|
+
ccBits: [8, 16, 16]
|
|
957
|
+
}, e.KANJI = {
|
|
958
|
+
id: "Kanji",
|
|
959
|
+
bit: 8,
|
|
960
|
+
ccBits: [8, 10, 12]
|
|
961
|
+
}, e.MIXED = {
|
|
962
|
+
bit: -1
|
|
963
|
+
}, e.getCharCountIndicator = function(r, s) {
|
|
964
|
+
if (!r.ccBits) throw new Error("Invalid mode: " + r);
|
|
965
|
+
if (!t.isValid(s))
|
|
966
|
+
throw new Error("Invalid version: " + s);
|
|
967
|
+
return s >= 1 && s < 10 ? r.ccBits[0] : s < 27 ? r.ccBits[1] : r.ccBits[2];
|
|
968
|
+
}, e.getBestModeForData = function(r) {
|
|
969
|
+
return i.testNumeric(r) ? e.NUMERIC : i.testAlphanumeric(r) ? e.ALPHANUMERIC : i.testKanji(r) ? e.KANJI : e.BYTE;
|
|
970
|
+
}, e.toString = function(r) {
|
|
971
|
+
if (r && r.id) return r.id;
|
|
972
|
+
throw new Error("Invalid mode");
|
|
973
|
+
}, e.isValid = function(r) {
|
|
974
|
+
return r && r.bit && r.ccBits;
|
|
975
|
+
};
|
|
976
|
+
function o(n) {
|
|
977
|
+
if (typeof n != "string")
|
|
978
|
+
throw new Error("Param is not a string");
|
|
979
|
+
switch (n.toLowerCase()) {
|
|
980
|
+
case "numeric":
|
|
981
|
+
return e.NUMERIC;
|
|
982
|
+
case "alphanumeric":
|
|
983
|
+
return e.ALPHANUMERIC;
|
|
984
|
+
case "kanji":
|
|
985
|
+
return e.KANJI;
|
|
986
|
+
case "byte":
|
|
987
|
+
return e.BYTE;
|
|
988
|
+
default:
|
|
989
|
+
throw new Error("Unknown mode: " + n);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
e.from = function(r, s) {
|
|
993
|
+
if (e.isValid(r))
|
|
994
|
+
return r;
|
|
995
|
+
try {
|
|
996
|
+
return o(r);
|
|
997
|
+
} catch {
|
|
998
|
+
return s;
|
|
999
|
+
}
|
|
1000
|
+
};
|
|
1001
|
+
})(z);
|
|
1002
|
+
(function(e) {
|
|
1003
|
+
const t = x, i = ut, o = ct, n = z, r = St, s = 7973, a = t.getBCHDigit(s);
|
|
1004
|
+
function c(p, d, m) {
|
|
1005
|
+
for (let g = 1; g <= 40; g++)
|
|
1006
|
+
if (d <= e.getCapacity(g, m, p))
|
|
1007
|
+
return g;
|
|
1008
|
+
}
|
|
1009
|
+
function u(p, d) {
|
|
1010
|
+
return n.getCharCountIndicator(p, d) + 4;
|
|
1011
|
+
}
|
|
1012
|
+
function l(p, d) {
|
|
1013
|
+
let m = 0;
|
|
1014
|
+
return p.forEach(function(g) {
|
|
1015
|
+
const b = u(g.mode, d);
|
|
1016
|
+
m += b + g.getBitsLength();
|
|
1017
|
+
}), m;
|
|
1018
|
+
}
|
|
1019
|
+
function E(p, d) {
|
|
1020
|
+
for (let m = 1; m <= 40; m++)
|
|
1021
|
+
if (l(p, m) <= e.getCapacity(m, d, n.MIXED))
|
|
1022
|
+
return m;
|
|
1023
|
+
}
|
|
1024
|
+
e.from = function(d, m) {
|
|
1025
|
+
return r.isValid(d) ? parseInt(d, 10) : m;
|
|
1026
|
+
}, e.getCapacity = function(d, m, g) {
|
|
1027
|
+
if (!r.isValid(d))
|
|
1028
|
+
throw new Error("Invalid QR Code version");
|
|
1029
|
+
typeof g > "u" && (g = n.BYTE);
|
|
1030
|
+
const b = t.getSymbolTotalCodewords(d), y = i.getTotalCodewordsCount(d, m), w = (b - y) * 8;
|
|
1031
|
+
if (g === n.MIXED) return w;
|
|
1032
|
+
const h = w - u(g, d);
|
|
1033
|
+
switch (g) {
|
|
1034
|
+
case n.NUMERIC:
|
|
1035
|
+
return Math.floor(h / 10 * 3);
|
|
1036
|
+
case n.ALPHANUMERIC:
|
|
1037
|
+
return Math.floor(h / 11 * 2);
|
|
1038
|
+
case n.KANJI:
|
|
1039
|
+
return Math.floor(h / 13);
|
|
1040
|
+
case n.BYTE:
|
|
1041
|
+
default:
|
|
1042
|
+
return Math.floor(h / 8);
|
|
1043
|
+
}
|
|
1044
|
+
}, e.getBestVersionForData = function(d, m) {
|
|
1045
|
+
let g;
|
|
1046
|
+
const b = o.from(m, o.M);
|
|
1047
|
+
if (Array.isArray(d)) {
|
|
1048
|
+
if (d.length > 1)
|
|
1049
|
+
return E(d, b);
|
|
1050
|
+
if (d.length === 0)
|
|
1051
|
+
return 1;
|
|
1052
|
+
g = d[0];
|
|
1053
|
+
} else
|
|
1054
|
+
g = d;
|
|
1055
|
+
return c(g.mode, g.getLength(), b);
|
|
1056
|
+
}, e.getEncodedBits = function(d) {
|
|
1057
|
+
if (!r.isValid(d) || d < 7)
|
|
1058
|
+
throw new Error("Invalid QR Code version");
|
|
1059
|
+
let m = d << 12;
|
|
1060
|
+
for (; t.getBCHDigit(m) - a >= 0; )
|
|
1061
|
+
m ^= s << t.getBCHDigit(m) - a;
|
|
1062
|
+
return d << 12 | m;
|
|
1063
|
+
};
|
|
1064
|
+
})(Ft);
|
|
1065
|
+
var Ot = {};
|
|
1066
|
+
const yt = x, Kt = 1335, ge = 21522, Rt = yt.getBCHDigit(Kt);
|
|
1067
|
+
Ot.getEncodedBits = function(t, i) {
|
|
1068
|
+
const o = t.bit << 3 | i;
|
|
1069
|
+
let n = o << 10;
|
|
1070
|
+
for (; yt.getBCHDigit(n) - Rt >= 0; )
|
|
1071
|
+
n ^= Kt << yt.getBCHDigit(n) - Rt;
|
|
1072
|
+
return (o << 10 | n) ^ ge;
|
|
1073
|
+
};
|
|
1074
|
+
var Vt = {};
|
|
1075
|
+
const he = z;
|
|
1076
|
+
function J(e) {
|
|
1077
|
+
this.mode = he.NUMERIC, this.data = e.toString();
|
|
1078
|
+
}
|
|
1079
|
+
J.getBitsLength = function(t) {
|
|
1080
|
+
return 10 * Math.floor(t / 3) + (t % 3 ? t % 3 * 3 + 1 : 0);
|
|
1081
|
+
};
|
|
1082
|
+
J.prototype.getLength = function() {
|
|
1083
|
+
return this.data.length;
|
|
1084
|
+
};
|
|
1085
|
+
J.prototype.getBitsLength = function() {
|
|
1086
|
+
return J.getBitsLength(this.data.length);
|
|
1087
|
+
};
|
|
1088
|
+
J.prototype.write = function(t) {
|
|
1089
|
+
let i, o, n;
|
|
1090
|
+
for (i = 0; i + 3 <= this.data.length; i += 3)
|
|
1091
|
+
o = this.data.substr(i, 3), n = parseInt(o, 10), t.put(n, 10);
|
|
1092
|
+
const r = this.data.length - i;
|
|
1093
|
+
r > 0 && (o = this.data.substr(i), n = parseInt(o, 10), t.put(n, r * 3 + 1));
|
|
1094
|
+
};
|
|
1095
|
+
var pe = J;
|
|
1096
|
+
const me = z, ft = [
|
|
1097
|
+
"0",
|
|
1098
|
+
"1",
|
|
1099
|
+
"2",
|
|
1100
|
+
"3",
|
|
1101
|
+
"4",
|
|
1102
|
+
"5",
|
|
1103
|
+
"6",
|
|
1104
|
+
"7",
|
|
1105
|
+
"8",
|
|
1106
|
+
"9",
|
|
1107
|
+
"A",
|
|
1108
|
+
"B",
|
|
1109
|
+
"C",
|
|
1110
|
+
"D",
|
|
1111
|
+
"E",
|
|
1112
|
+
"F",
|
|
1113
|
+
"G",
|
|
1114
|
+
"H",
|
|
1115
|
+
"I",
|
|
1116
|
+
"J",
|
|
1117
|
+
"K",
|
|
1118
|
+
"L",
|
|
1119
|
+
"M",
|
|
1120
|
+
"N",
|
|
1121
|
+
"O",
|
|
1122
|
+
"P",
|
|
1123
|
+
"Q",
|
|
1124
|
+
"R",
|
|
1125
|
+
"S",
|
|
1126
|
+
"T",
|
|
1127
|
+
"U",
|
|
1128
|
+
"V",
|
|
1129
|
+
"W",
|
|
1130
|
+
"X",
|
|
1131
|
+
"Y",
|
|
1132
|
+
"Z",
|
|
1133
|
+
" ",
|
|
1134
|
+
"$",
|
|
1135
|
+
"%",
|
|
1136
|
+
"*",
|
|
1137
|
+
"+",
|
|
1138
|
+
"-",
|
|
1139
|
+
".",
|
|
1140
|
+
"/",
|
|
1141
|
+
":"
|
|
1142
|
+
];
|
|
1143
|
+
function j(e) {
|
|
1144
|
+
this.mode = me.ALPHANUMERIC, this.data = e;
|
|
1145
|
+
}
|
|
1146
|
+
j.getBitsLength = function(t) {
|
|
1147
|
+
return 11 * Math.floor(t / 2) + 6 * (t % 2);
|
|
1148
|
+
};
|
|
1149
|
+
j.prototype.getLength = function() {
|
|
1150
|
+
return this.data.length;
|
|
1151
|
+
};
|
|
1152
|
+
j.prototype.getBitsLength = function() {
|
|
1153
|
+
return j.getBitsLength(this.data.length);
|
|
1154
|
+
};
|
|
1155
|
+
j.prototype.write = function(t) {
|
|
1156
|
+
let i;
|
|
1157
|
+
for (i = 0; i + 2 <= this.data.length; i += 2) {
|
|
1158
|
+
let o = ft.indexOf(this.data[i]) * 45;
|
|
1159
|
+
o += ft.indexOf(this.data[i + 1]), t.put(o, 11);
|
|
1160
|
+
}
|
|
1161
|
+
this.data.length % 2 && t.put(ft.indexOf(this.data[i]), 6);
|
|
1162
|
+
};
|
|
1163
|
+
var ye = j;
|
|
1164
|
+
const we = z;
|
|
1165
|
+
function Q(e) {
|
|
1166
|
+
this.mode = we.BYTE, typeof e == "string" ? this.data = new TextEncoder().encode(e) : this.data = new Uint8Array(e);
|
|
1167
|
+
}
|
|
1168
|
+
Q.getBitsLength = function(t) {
|
|
1169
|
+
return t * 8;
|
|
1170
|
+
};
|
|
1171
|
+
Q.prototype.getLength = function() {
|
|
1172
|
+
return this.data.length;
|
|
1173
|
+
};
|
|
1174
|
+
Q.prototype.getBitsLength = function() {
|
|
1175
|
+
return Q.getBitsLength(this.data.length);
|
|
1176
|
+
};
|
|
1177
|
+
Q.prototype.write = function(e) {
|
|
1178
|
+
for (let t = 0, i = this.data.length; t < i; t++)
|
|
1179
|
+
e.put(this.data[t], 8);
|
|
1180
|
+
};
|
|
1181
|
+
var Ce = Q;
|
|
1182
|
+
const Ee = z, be = x;
|
|
1183
|
+
function Y(e) {
|
|
1184
|
+
this.mode = Ee.KANJI, this.data = e;
|
|
1185
|
+
}
|
|
1186
|
+
Y.getBitsLength = function(t) {
|
|
1187
|
+
return t * 13;
|
|
1188
|
+
};
|
|
1189
|
+
Y.prototype.getLength = function() {
|
|
1190
|
+
return this.data.length;
|
|
1191
|
+
};
|
|
1192
|
+
Y.prototype.getBitsLength = function() {
|
|
1193
|
+
return Y.getBitsLength(this.data.length);
|
|
1194
|
+
};
|
|
1195
|
+
Y.prototype.write = function(e) {
|
|
1196
|
+
let t;
|
|
1197
|
+
for (t = 0; t < this.data.length; t++) {
|
|
1198
|
+
let i = be.toSJIS(this.data[t]);
|
|
1199
|
+
if (i >= 33088 && i <= 40956)
|
|
1200
|
+
i -= 33088;
|
|
1201
|
+
else if (i >= 57408 && i <= 60351)
|
|
1202
|
+
i -= 49472;
|
|
1203
|
+
else
|
|
1204
|
+
throw new Error(
|
|
1205
|
+
"Invalid SJIS character: " + this.data[t] + `
|
|
1206
|
+
Make sure your charset is UTF-8`
|
|
1207
|
+
);
|
|
1208
|
+
i = (i >>> 8 & 255) * 192 + (i & 255), e.put(i, 13);
|
|
1209
|
+
}
|
|
1210
|
+
};
|
|
1211
|
+
var Be = Y, Ht = { exports: {} };
|
|
1212
|
+
(function(e) {
|
|
1213
|
+
var t = {
|
|
1214
|
+
single_source_shortest_paths: function(i, o, n) {
|
|
1215
|
+
var r = {}, s = {};
|
|
1216
|
+
s[o] = 0;
|
|
1217
|
+
var a = t.PriorityQueue.make();
|
|
1218
|
+
a.push(o, 0);
|
|
1219
|
+
for (var c, u, l, E, p, d, m, g, b; !a.empty(); ) {
|
|
1220
|
+
c = a.pop(), u = c.value, E = c.cost, p = i[u] || {};
|
|
1221
|
+
for (l in p)
|
|
1222
|
+
p.hasOwnProperty(l) && (d = p[l], m = E + d, g = s[l], b = typeof s[l] > "u", (b || g > m) && (s[l] = m, a.push(l, m), r[l] = u));
|
|
1223
|
+
}
|
|
1224
|
+
if (typeof n < "u" && typeof s[n] > "u") {
|
|
1225
|
+
var y = ["Could not find a path from ", o, " to ", n, "."].join("");
|
|
1226
|
+
throw new Error(y);
|
|
1227
|
+
}
|
|
1228
|
+
return r;
|
|
1229
|
+
},
|
|
1230
|
+
extract_shortest_path_from_predecessor_list: function(i, o) {
|
|
1231
|
+
for (var n = [], r = o; r; )
|
|
1232
|
+
n.push(r), i[r], r = i[r];
|
|
1233
|
+
return n.reverse(), n;
|
|
1234
|
+
},
|
|
1235
|
+
find_path: function(i, o, n) {
|
|
1236
|
+
var r = t.single_source_shortest_paths(i, o, n);
|
|
1237
|
+
return t.extract_shortest_path_from_predecessor_list(
|
|
1238
|
+
r,
|
|
1239
|
+
n
|
|
1240
|
+
);
|
|
1241
|
+
},
|
|
1242
|
+
/**
|
|
1243
|
+
* A very naive priority queue implementation.
|
|
1244
|
+
*/
|
|
1245
|
+
PriorityQueue: {
|
|
1246
|
+
make: function(i) {
|
|
1247
|
+
var o = t.PriorityQueue, n = {}, r;
|
|
1248
|
+
i = i || {};
|
|
1249
|
+
for (r in o)
|
|
1250
|
+
o.hasOwnProperty(r) && (n[r] = o[r]);
|
|
1251
|
+
return n.queue = [], n.sorter = i.sorter || o.default_sorter, n;
|
|
1252
|
+
},
|
|
1253
|
+
default_sorter: function(i, o) {
|
|
1254
|
+
return i.cost - o.cost;
|
|
1255
|
+
},
|
|
1256
|
+
/**
|
|
1257
|
+
* Add a new item to the queue and ensure the highest priority element
|
|
1258
|
+
* is at the front of the queue.
|
|
1259
|
+
*/
|
|
1260
|
+
push: function(i, o) {
|
|
1261
|
+
var n = { value: i, cost: o };
|
|
1262
|
+
this.queue.push(n), this.queue.sort(this.sorter);
|
|
1263
|
+
},
|
|
1264
|
+
/**
|
|
1265
|
+
* Return the highest priority element in the queue.
|
|
1266
|
+
*/
|
|
1267
|
+
pop: function() {
|
|
1268
|
+
return this.queue.shift();
|
|
1269
|
+
},
|
|
1270
|
+
empty: function() {
|
|
1271
|
+
return this.queue.length === 0;
|
|
1272
|
+
}
|
|
1273
|
+
}
|
|
1274
|
+
};
|
|
1275
|
+
e.exports = t;
|
|
1276
|
+
})(Ht);
|
|
1277
|
+
var Se = Ht.exports;
|
|
1278
|
+
(function(e) {
|
|
1279
|
+
const t = z, i = pe, o = ye, n = Ce, r = Be, s = U, a = x, c = Se;
|
|
1280
|
+
function u(y) {
|
|
1281
|
+
return unescape(encodeURIComponent(y)).length;
|
|
1282
|
+
}
|
|
1283
|
+
function l(y, w, h) {
|
|
1284
|
+
const f = [];
|
|
1285
|
+
let C;
|
|
1286
|
+
for (; (C = y.exec(h)) !== null; )
|
|
1287
|
+
f.push({
|
|
1288
|
+
data: C[0],
|
|
1289
|
+
index: C.index,
|
|
1290
|
+
mode: w,
|
|
1291
|
+
length: C[0].length
|
|
1292
|
+
});
|
|
1293
|
+
return f;
|
|
1294
|
+
}
|
|
1295
|
+
function E(y) {
|
|
1296
|
+
const w = l(s.NUMERIC, t.NUMERIC, y), h = l(s.ALPHANUMERIC, t.ALPHANUMERIC, y);
|
|
1297
|
+
let f, C;
|
|
1298
|
+
return a.isKanjiModeEnabled() ? (f = l(s.BYTE, t.BYTE, y), C = l(s.KANJI, t.KANJI, y)) : (f = l(s.BYTE_KANJI, t.BYTE, y), C = []), w.concat(h, f, C).sort(function(S, R) {
|
|
1299
|
+
return S.index - R.index;
|
|
1300
|
+
}).map(function(S) {
|
|
1301
|
+
return {
|
|
1302
|
+
data: S.data,
|
|
1303
|
+
mode: S.mode,
|
|
1304
|
+
length: S.length
|
|
1305
|
+
};
|
|
1306
|
+
});
|
|
1307
|
+
}
|
|
1308
|
+
function p(y, w) {
|
|
1309
|
+
switch (w) {
|
|
1310
|
+
case t.NUMERIC:
|
|
1311
|
+
return i.getBitsLength(y);
|
|
1312
|
+
case t.ALPHANUMERIC:
|
|
1313
|
+
return o.getBitsLength(y);
|
|
1314
|
+
case t.KANJI:
|
|
1315
|
+
return r.getBitsLength(y);
|
|
1316
|
+
case t.BYTE:
|
|
1317
|
+
return n.getBitsLength(y);
|
|
1318
|
+
}
|
|
1319
|
+
}
|
|
1320
|
+
function d(y) {
|
|
1321
|
+
return y.reduce(function(w, h) {
|
|
1322
|
+
const f = w.length - 1 >= 0 ? w[w.length - 1] : null;
|
|
1323
|
+
return f && f.mode === h.mode ? (w[w.length - 1].data += h.data, w) : (w.push(h), w);
|
|
1324
|
+
}, []);
|
|
1325
|
+
}
|
|
1326
|
+
function m(y) {
|
|
1327
|
+
const w = [];
|
|
1328
|
+
for (let h = 0; h < y.length; h++) {
|
|
1329
|
+
const f = y[h];
|
|
1330
|
+
switch (f.mode) {
|
|
1331
|
+
case t.NUMERIC:
|
|
1332
|
+
w.push([
|
|
1333
|
+
f,
|
|
1334
|
+
{ data: f.data, mode: t.ALPHANUMERIC, length: f.length },
|
|
1335
|
+
{ data: f.data, mode: t.BYTE, length: f.length }
|
|
1336
|
+
]);
|
|
1337
|
+
break;
|
|
1338
|
+
case t.ALPHANUMERIC:
|
|
1339
|
+
w.push([
|
|
1340
|
+
f,
|
|
1341
|
+
{ data: f.data, mode: t.BYTE, length: f.length }
|
|
1342
|
+
]);
|
|
1343
|
+
break;
|
|
1344
|
+
case t.KANJI:
|
|
1345
|
+
w.push([
|
|
1346
|
+
f,
|
|
1347
|
+
{ data: f.data, mode: t.BYTE, length: u(f.data) }
|
|
1348
|
+
]);
|
|
1349
|
+
break;
|
|
1350
|
+
case t.BYTE:
|
|
1351
|
+
w.push([
|
|
1352
|
+
{ data: f.data, mode: t.BYTE, length: u(f.data) }
|
|
1353
|
+
]);
|
|
1354
|
+
}
|
|
1355
|
+
}
|
|
1356
|
+
return w;
|
|
1357
|
+
}
|
|
1358
|
+
function g(y, w) {
|
|
1359
|
+
const h = {}, f = { start: {} };
|
|
1360
|
+
let C = ["start"];
|
|
1361
|
+
for (let B = 0; B < y.length; B++) {
|
|
1362
|
+
const S = y[B], R = [];
|
|
1363
|
+
for (let M = 0; M < S.length; M++) {
|
|
1364
|
+
const P = S[M], _ = "" + B + M;
|
|
1365
|
+
R.push(_), h[_] = { node: P, lastCount: 0 }, f[_] = {};
|
|
1366
|
+
for (let D = 0; D < C.length; D++) {
|
|
1367
|
+
const k = C[D];
|
|
1368
|
+
h[k] && h[k].node.mode === P.mode ? (f[k][_] = p(h[k].lastCount + P.length, P.mode) - p(h[k].lastCount, P.mode), h[k].lastCount += P.length) : (h[k] && (h[k].lastCount = P.length), f[k][_] = p(P.length, P.mode) + 4 + t.getCharCountIndicator(P.mode, w));
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
C = R;
|
|
1372
|
+
}
|
|
1373
|
+
for (let B = 0; B < C.length; B++)
|
|
1374
|
+
f[C[B]].end = 0;
|
|
1375
|
+
return { map: f, table: h };
|
|
1376
|
+
}
|
|
1377
|
+
function b(y, w) {
|
|
1378
|
+
let h;
|
|
1379
|
+
const f = t.getBestModeForData(y);
|
|
1380
|
+
if (h = t.from(w, f), h !== t.BYTE && h.bit < f.bit)
|
|
1381
|
+
throw new Error('"' + y + '" cannot be encoded with mode ' + t.toString(h) + `.
|
|
1382
|
+
Suggested mode is: ` + t.toString(f));
|
|
1383
|
+
switch (h === t.KANJI && !a.isKanjiModeEnabled() && (h = t.BYTE), h) {
|
|
1384
|
+
case t.NUMERIC:
|
|
1385
|
+
return new i(y);
|
|
1386
|
+
case t.ALPHANUMERIC:
|
|
1387
|
+
return new o(y);
|
|
1388
|
+
case t.KANJI:
|
|
1389
|
+
return new r(y);
|
|
1390
|
+
case t.BYTE:
|
|
1391
|
+
return new n(y);
|
|
1392
|
+
}
|
|
1393
|
+
}
|
|
1394
|
+
e.fromArray = function(w) {
|
|
1395
|
+
return w.reduce(function(h, f) {
|
|
1396
|
+
return typeof f == "string" ? h.push(b(f, null)) : f.data && h.push(b(f.data, f.mode)), h;
|
|
1397
|
+
}, []);
|
|
1398
|
+
}, e.fromString = function(w, h) {
|
|
1399
|
+
const f = E(w, a.isKanjiModeEnabled()), C = m(f), B = g(C, h), S = c.find_path(B.map, "start", "end"), R = [];
|
|
1400
|
+
for (let M = 1; M < S.length - 1; M++)
|
|
1401
|
+
R.push(B.table[S[M]].node);
|
|
1402
|
+
return e.fromArray(d(R));
|
|
1403
|
+
}, e.rawSplit = function(w) {
|
|
1404
|
+
return e.fromArray(
|
|
1405
|
+
E(w, a.isKanjiModeEnabled())
|
|
1406
|
+
);
|
|
1407
|
+
};
|
|
1408
|
+
})(Vt);
|
|
1409
|
+
const dt = x, gt = ct, Te = re, Ie = ie, Ae = Lt, Pe = vt, wt = Ut, Ct = ut, Ne = ae, at = Ft, Re = Ot, xe = z, ht = Vt;
|
|
1410
|
+
function Me(e, t) {
|
|
1411
|
+
const i = e.size, o = Pe.getPositions(t);
|
|
1412
|
+
for (let n = 0; n < o.length; n++) {
|
|
1413
|
+
const r = o[n][0], s = o[n][1];
|
|
1414
|
+
for (let a = -1; a <= 7; a++)
|
|
1415
|
+
if (!(r + a <= -1 || i <= r + a))
|
|
1416
|
+
for (let c = -1; c <= 7; c++)
|
|
1417
|
+
s + c <= -1 || i <= s + c || (a >= 0 && a <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (a === 0 || a === 6) || a >= 2 && a <= 4 && c >= 2 && c <= 4 ? e.set(r + a, s + c, !0, !0) : e.set(r + a, s + c, !1, !0));
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
function ke(e) {
|
|
1421
|
+
const t = e.size;
|
|
1422
|
+
for (let i = 8; i < t - 8; i++) {
|
|
1423
|
+
const o = i % 2 === 0;
|
|
1424
|
+
e.set(i, 6, o, !0), e.set(6, i, o, !0);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1427
|
+
function Le(e, t) {
|
|
1428
|
+
const i = Ae.getPositions(t);
|
|
1429
|
+
for (let o = 0; o < i.length; o++) {
|
|
1430
|
+
const n = i[o][0], r = i[o][1];
|
|
1431
|
+
for (let s = -2; s <= 2; s++)
|
|
1432
|
+
for (let a = -2; a <= 2; a++)
|
|
1433
|
+
s === -2 || s === 2 || a === -2 || a === 2 || s === 0 && a === 0 ? e.set(n + s, r + a, !0, !0) : e.set(n + s, r + a, !1, !0);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
function ve(e, t) {
|
|
1437
|
+
const i = e.size, o = at.getEncodedBits(t);
|
|
1438
|
+
let n, r, s;
|
|
1439
|
+
for (let a = 0; a < 18; a++)
|
|
1440
|
+
n = Math.floor(a / 3), r = a % 3 + i - 8 - 3, s = (o >> a & 1) === 1, e.set(n, r, s, !0), e.set(r, n, s, !0);
|
|
1441
|
+
}
|
|
1442
|
+
function pt(e, t, i) {
|
|
1443
|
+
const o = e.size, n = Re.getEncodedBits(t, i);
|
|
1444
|
+
let r, s;
|
|
1445
|
+
for (r = 0; r < 15; r++)
|
|
1446
|
+
s = (n >> r & 1) === 1, r < 6 ? e.set(r, 8, s, !0) : r < 8 ? e.set(r + 1, 8, s, !0) : e.set(o - 15 + r, 8, s, !0), r < 8 ? e.set(8, o - r - 1, s, !0) : r < 9 ? e.set(8, 15 - r - 1 + 1, s, !0) : e.set(8, 15 - r - 1, s, !0);
|
|
1447
|
+
e.set(o - 8, 8, 1, !0);
|
|
1448
|
+
}
|
|
1449
|
+
function Ue(e, t) {
|
|
1450
|
+
const i = e.size;
|
|
1451
|
+
let o = -1, n = i - 1, r = 7, s = 0;
|
|
1452
|
+
for (let a = i - 1; a > 0; a -= 2)
|
|
1453
|
+
for (a === 6 && a--; ; ) {
|
|
1454
|
+
for (let c = 0; c < 2; c++)
|
|
1455
|
+
if (!e.isReserved(n, a - c)) {
|
|
1456
|
+
let u = !1;
|
|
1457
|
+
s < t.length && (u = (t[s] >>> r & 1) === 1), e.set(n, a - c, u), r--, r === -1 && (s++, r = 7);
|
|
1458
|
+
}
|
|
1459
|
+
if (n += o, n < 0 || i <= n) {
|
|
1460
|
+
n -= o, o = -o;
|
|
1461
|
+
break;
|
|
1462
|
+
}
|
|
1463
|
+
}
|
|
1464
|
+
}
|
|
1465
|
+
function _e(e, t, i) {
|
|
1466
|
+
const o = new Te();
|
|
1467
|
+
i.forEach(function(c) {
|
|
1468
|
+
o.put(c.mode.bit, 4), o.put(c.getLength(), xe.getCharCountIndicator(c.mode, e)), c.write(o);
|
|
1469
|
+
});
|
|
1470
|
+
const n = dt.getSymbolTotalCodewords(e), r = Ct.getTotalCodewordsCount(e, t), s = (n - r) * 8;
|
|
1471
|
+
for (o.getLengthInBits() + 4 <= s && o.put(0, 4); o.getLengthInBits() % 8 !== 0; )
|
|
1472
|
+
o.putBit(0);
|
|
1473
|
+
const a = (s - o.getLengthInBits()) / 8;
|
|
1474
|
+
for (let c = 0; c < a; c++)
|
|
1475
|
+
o.put(c % 2 ? 17 : 236, 8);
|
|
1476
|
+
return De(o, e, t);
|
|
1477
|
+
}
|
|
1478
|
+
function De(e, t, i) {
|
|
1479
|
+
const o = dt.getSymbolTotalCodewords(t), n = Ct.getTotalCodewordsCount(t, i), r = o - n, s = Ct.getBlocksCount(t, i), a = o % s, c = s - a, u = Math.floor(o / s), l = Math.floor(r / s), E = l + 1, p = u - l, d = new Ne(p);
|
|
1480
|
+
let m = 0;
|
|
1481
|
+
const g = new Array(s), b = new Array(s);
|
|
1482
|
+
let y = 0;
|
|
1483
|
+
const w = new Uint8Array(e.buffer);
|
|
1484
|
+
for (let S = 0; S < s; S++) {
|
|
1485
|
+
const R = S < c ? l : E;
|
|
1486
|
+
g[S] = w.slice(m, m + R), b[S] = d.encode(g[S]), m += R, y = Math.max(y, R);
|
|
1487
|
+
}
|
|
1488
|
+
const h = new Uint8Array(o);
|
|
1489
|
+
let f = 0, C, B;
|
|
1490
|
+
for (C = 0; C < y; C++)
|
|
1491
|
+
for (B = 0; B < s; B++)
|
|
1492
|
+
C < g[B].length && (h[f++] = g[B][C]);
|
|
1493
|
+
for (C = 0; C < p; C++)
|
|
1494
|
+
for (B = 0; B < s; B++)
|
|
1495
|
+
h[f++] = b[B][C];
|
|
1496
|
+
return h;
|
|
1497
|
+
}
|
|
1498
|
+
function Fe(e, t, i, o) {
|
|
1499
|
+
let n;
|
|
1500
|
+
if (Array.isArray(e))
|
|
1501
|
+
n = ht.fromArray(e);
|
|
1502
|
+
else if (typeof e == "string") {
|
|
1503
|
+
let u = t;
|
|
1504
|
+
if (!u) {
|
|
1505
|
+
const l = ht.rawSplit(e);
|
|
1506
|
+
u = at.getBestVersionForData(l, i);
|
|
1507
|
+
}
|
|
1508
|
+
n = ht.fromString(e, u || 40);
|
|
1509
|
+
} else
|
|
1510
|
+
throw new Error("Invalid data");
|
|
1511
|
+
const r = at.getBestVersionForData(n, i);
|
|
1512
|
+
if (!r)
|
|
1513
|
+
throw new Error("The amount of data is too big to be stored in a QR Code");
|
|
1514
|
+
if (!t)
|
|
1515
|
+
t = r;
|
|
1516
|
+
else if (t < r)
|
|
1517
|
+
throw new Error(
|
|
1518
|
+
`
|
|
1519
|
+
The chosen QR Code version cannot contain this amount of data.
|
|
1520
|
+
Minimum version required to store current data is: ` + r + `.
|
|
1521
|
+
`
|
|
1522
|
+
);
|
|
1523
|
+
const s = _e(t, i, n), a = dt.getSymbolSize(t), c = new Ie(a);
|
|
1524
|
+
return Me(c, t), ke(c), Le(c, t), pt(c, i, 0), t >= 7 && ve(c, t), Ue(c, s), isNaN(o) && (o = wt.getBestMask(
|
|
1525
|
+
c,
|
|
1526
|
+
pt.bind(null, c, i)
|
|
1527
|
+
)), wt.applyMask(o, c), pt(c, i, o), {
|
|
1528
|
+
modules: c,
|
|
1529
|
+
version: t,
|
|
1530
|
+
errorCorrectionLevel: i,
|
|
1531
|
+
maskPattern: o,
|
|
1532
|
+
segments: n
|
|
1533
|
+
};
|
|
1534
|
+
}
|
|
1535
|
+
Mt.create = function(t, i) {
|
|
1536
|
+
if (typeof t > "u" || t === "")
|
|
1537
|
+
throw new Error("No input text");
|
|
1538
|
+
let o = gt.M, n, r;
|
|
1539
|
+
return typeof i < "u" && (o = gt.from(i.errorCorrectionLevel, gt.M), n = at.from(i.version), r = wt.from(i.maskPattern), i.toSJISFunc && dt.setToSJISFunction(i.toSJISFunc)), Fe(t, n, o, r);
|
|
1540
|
+
};
|
|
1541
|
+
var Jt = {}, Tt = {};
|
|
1542
|
+
(function(e) {
|
|
1543
|
+
function t(i) {
|
|
1544
|
+
if (typeof i == "number" && (i = i.toString()), typeof i != "string")
|
|
1545
|
+
throw new Error("Color should be defined as hex string");
|
|
1546
|
+
let o = i.slice().replace("#", "").split("");
|
|
1547
|
+
if (o.length < 3 || o.length === 5 || o.length > 8)
|
|
1548
|
+
throw new Error("Invalid hex color: " + i);
|
|
1549
|
+
(o.length === 3 || o.length === 4) && (o = Array.prototype.concat.apply([], o.map(function(r) {
|
|
1550
|
+
return [r, r];
|
|
1551
|
+
}))), o.length === 6 && o.push("F", "F");
|
|
1552
|
+
const n = parseInt(o.join(""), 16);
|
|
1553
|
+
return {
|
|
1554
|
+
r: n >> 24 & 255,
|
|
1555
|
+
g: n >> 16 & 255,
|
|
1556
|
+
b: n >> 8 & 255,
|
|
1557
|
+
a: n & 255,
|
|
1558
|
+
hex: "#" + o.slice(0, 6).join("")
|
|
1559
|
+
};
|
|
1560
|
+
}
|
|
1561
|
+
e.getOptions = function(o) {
|
|
1562
|
+
o || (o = {}), o.color || (o.color = {});
|
|
1563
|
+
const n = typeof o.margin > "u" || o.margin === null || o.margin < 0 ? 4 : o.margin, r = o.width && o.width >= 21 ? o.width : void 0, s = o.scale || 4;
|
|
1564
|
+
return {
|
|
1565
|
+
width: r,
|
|
1566
|
+
scale: r ? 4 : s,
|
|
1567
|
+
margin: n,
|
|
1568
|
+
color: {
|
|
1569
|
+
dark: t(o.color.dark || "#000000ff"),
|
|
1570
|
+
light: t(o.color.light || "#ffffffff")
|
|
1571
|
+
},
|
|
1572
|
+
type: o.type,
|
|
1573
|
+
rendererOpts: o.rendererOpts || {}
|
|
1574
|
+
};
|
|
1575
|
+
}, e.getScale = function(o, n) {
|
|
1576
|
+
return n.width && n.width >= o + n.margin * 2 ? n.width / (o + n.margin * 2) : n.scale;
|
|
1577
|
+
}, e.getImageWidth = function(o, n) {
|
|
1578
|
+
const r = e.getScale(o, n);
|
|
1579
|
+
return Math.floor((o + n.margin * 2) * r);
|
|
1580
|
+
}, e.qrToImageData = function(o, n, r) {
|
|
1581
|
+
const s = n.modules.size, a = n.modules.data, c = e.getScale(s, r), u = Math.floor((s + r.margin * 2) * c), l = r.margin * c, E = [r.color.light, r.color.dark];
|
|
1582
|
+
for (let p = 0; p < u; p++)
|
|
1583
|
+
for (let d = 0; d < u; d++) {
|
|
1584
|
+
let m = (p * u + d) * 4, g = r.color.light;
|
|
1585
|
+
if (p >= l && d >= l && p < u - l && d < u - l) {
|
|
1586
|
+
const b = Math.floor((p - l) / c), y = Math.floor((d - l) / c);
|
|
1587
|
+
g = E[a[b * s + y] ? 1 : 0];
|
|
1588
|
+
}
|
|
1589
|
+
o[m++] = g.r, o[m++] = g.g, o[m++] = g.b, o[m] = g.a;
|
|
1590
|
+
}
|
|
1591
|
+
};
|
|
1592
|
+
})(Tt);
|
|
1593
|
+
(function(e) {
|
|
1594
|
+
const t = Tt;
|
|
1595
|
+
function i(n, r, s) {
|
|
1596
|
+
n.clearRect(0, 0, r.width, r.height), r.style || (r.style = {}), r.height = s, r.width = s, r.style.height = s + "px", r.style.width = s + "px";
|
|
1597
|
+
}
|
|
1598
|
+
function o() {
|
|
1599
|
+
try {
|
|
1600
|
+
return document.createElement("canvas");
|
|
1601
|
+
} catch {
|
|
1602
|
+
throw new Error("You need to specify a canvas element");
|
|
1603
|
+
}
|
|
1604
|
+
}
|
|
1605
|
+
e.render = function(r, s, a) {
|
|
1606
|
+
let c = a, u = s;
|
|
1607
|
+
typeof c > "u" && (!s || !s.getContext) && (c = s, s = void 0), s || (u = o()), c = t.getOptions(c);
|
|
1608
|
+
const l = t.getImageWidth(r.modules.size, c), E = u.getContext("2d"), p = E.createImageData(l, l);
|
|
1609
|
+
return t.qrToImageData(p.data, r, c), i(E, u, l), E.putImageData(p, 0, 0), u;
|
|
1610
|
+
}, e.renderToDataURL = function(r, s, a) {
|
|
1611
|
+
let c = a;
|
|
1612
|
+
typeof c > "u" && (!s || !s.getContext) && (c = s, s = void 0), c || (c = {});
|
|
1613
|
+
const u = e.render(r, s, c), l = c.type || "image/png", E = c.rendererOpts || {};
|
|
1614
|
+
return u.toDataURL(l, E.quality);
|
|
1615
|
+
};
|
|
1616
|
+
})(Jt);
|
|
1617
|
+
var jt = {};
|
|
1618
|
+
const ze = Tt;
|
|
1619
|
+
function xt(e, t) {
|
|
1620
|
+
const i = e.a / 255, o = t + '="' + e.hex + '"';
|
|
1621
|
+
return i < 1 ? o + " " + t + '-opacity="' + i.toFixed(2).slice(1) + '"' : o;
|
|
1622
|
+
}
|
|
1623
|
+
function mt(e, t, i) {
|
|
1624
|
+
let o = e + t;
|
|
1625
|
+
return typeof i < "u" && (o += " " + i), o;
|
|
1626
|
+
}
|
|
1627
|
+
function Oe(e, t, i) {
|
|
1628
|
+
let o = "", n = 0, r = !1, s = 0;
|
|
1629
|
+
for (let a = 0; a < e.length; a++) {
|
|
1630
|
+
const c = Math.floor(a % t), u = Math.floor(a / t);
|
|
1631
|
+
!c && !r && (r = !0), e[a] ? (s++, a > 0 && c > 0 && e[a - 1] || (o += r ? mt("M", c + i, 0.5 + u + i) : mt("m", n, 0), n = 0, r = !1), c + 1 < t && e[a + 1] || (o += mt("h", s), s = 0)) : n++;
|
|
1632
|
+
}
|
|
1633
|
+
return o;
|
|
1634
|
+
}
|
|
1635
|
+
jt.render = function(t, i, o) {
|
|
1636
|
+
const n = ze.getOptions(i), r = t.modules.size, s = t.modules.data, a = r + n.margin * 2, c = n.color.light.a ? "<path " + xt(n.color.light, "fill") + ' d="M0 0h' + a + "v" + a + 'H0z"/>' : "", u = "<path " + xt(n.color.dark, "stroke") + ' d="' + Oe(s, r, n.margin) + '"/>', l = 'viewBox="0 0 ' + a + " " + a + '"', p = '<svg xmlns="http://www.w3.org/2000/svg" ' + (n.width ? 'width="' + n.width + '" height="' + n.width + '" ' : "") + l + ' shape-rendering="crispEdges">' + c + u + `</svg>
|
|
1637
|
+
`;
|
|
1638
|
+
return typeof o == "function" && o(null, p), p;
|
|
1639
|
+
};
|
|
1640
|
+
const Ke = ne, Et = Mt, Qt = Jt, Ve = jt;
|
|
1641
|
+
function It(e, t, i, o, n) {
|
|
1642
|
+
const r = [].slice.call(arguments, 1), s = r.length, a = typeof r[s - 1] == "function";
|
|
1643
|
+
if (!a && !Ke())
|
|
1644
|
+
throw new Error("Callback required as last argument");
|
|
1645
|
+
if (a) {
|
|
1646
|
+
if (s < 2)
|
|
1647
|
+
throw new Error("Too few arguments provided");
|
|
1648
|
+
s === 2 ? (n = i, i = t, t = o = void 0) : s === 3 && (t.getContext && typeof n > "u" ? (n = o, o = void 0) : (n = o, o = i, i = t, t = void 0));
|
|
1649
|
+
} else {
|
|
1650
|
+
if (s < 1)
|
|
1651
|
+
throw new Error("Too few arguments provided");
|
|
1652
|
+
return s === 1 ? (i = t, t = o = void 0) : s === 2 && !t.getContext && (o = i, i = t, t = void 0), new Promise(function(c, u) {
|
|
1653
|
+
try {
|
|
1654
|
+
const l = Et.create(i, o);
|
|
1655
|
+
c(e(l, t, o));
|
|
1656
|
+
} catch (l) {
|
|
1657
|
+
u(l);
|
|
1658
|
+
}
|
|
1659
|
+
});
|
|
1660
|
+
}
|
|
1661
|
+
try {
|
|
1662
|
+
const c = Et.create(i, o);
|
|
1663
|
+
n(null, e(c, t, o));
|
|
1664
|
+
} catch (c) {
|
|
1665
|
+
n(c);
|
|
1666
|
+
}
|
|
1667
|
+
}
|
|
1668
|
+
tt.create = Et.create;
|
|
1669
|
+
tt.toCanvas = It.bind(null, Qt.render);
|
|
1670
|
+
tt.toDataURL = It.bind(null, Qt.renderToDataURL);
|
|
1671
|
+
tt.toString = It.bind(null, function(e, t, i) {
|
|
1672
|
+
return Ve.render(e, i);
|
|
1673
|
+
});
|
|
1674
|
+
function He({ emv: e, size: t = 256, className: i, style: o }) {
|
|
1675
|
+
const n = H(null);
|
|
1676
|
+
return it(() => {
|
|
1677
|
+
!n.current || !e || tt.toCanvas(n.current, e, {
|
|
1678
|
+
width: t,
|
|
1679
|
+
margin: 2,
|
|
1680
|
+
color: { dark: "#000000", light: "#FFFFFF" }
|
|
1681
|
+
});
|
|
1682
|
+
}, [e, t]), /* @__PURE__ */ I(
|
|
1683
|
+
"canvas",
|
|
1684
|
+
{
|
|
1685
|
+
ref: n,
|
|
1686
|
+
width: t,
|
|
1687
|
+
height: t,
|
|
1688
|
+
className: i,
|
|
1689
|
+
style: { display: "block", ...o },
|
|
1690
|
+
"aria-label": "QR Code PIX"
|
|
1691
|
+
}
|
|
1692
|
+
);
|
|
1693
|
+
}
|
|
1694
|
+
const T = {
|
|
1695
|
+
container: {
|
|
1696
|
+
fontFamily: "system-ui, -apple-system, sans-serif",
|
|
1697
|
+
maxWidth: 380,
|
|
1698
|
+
margin: "0 auto",
|
|
1699
|
+
padding: "24px",
|
|
1700
|
+
border: "1px solid #e5e7eb",
|
|
1701
|
+
borderRadius: "16px",
|
|
1702
|
+
background: "#fff",
|
|
1703
|
+
textAlign: "center",
|
|
1704
|
+
boxSizing: "border-box"
|
|
1705
|
+
},
|
|
1706
|
+
title: {
|
|
1707
|
+
fontSize: "18px",
|
|
1708
|
+
fontWeight: 600,
|
|
1709
|
+
color: "#111827",
|
|
1710
|
+
margin: "0 0 4px"
|
|
1711
|
+
},
|
|
1712
|
+
amount: {
|
|
1713
|
+
fontSize: "28px",
|
|
1714
|
+
fontWeight: 700,
|
|
1715
|
+
color: "#059669",
|
|
1716
|
+
margin: "0 0 20px"
|
|
1717
|
+
},
|
|
1718
|
+
qrWrapper: {
|
|
1719
|
+
position: "relative",
|
|
1720
|
+
display: "inline-block",
|
|
1721
|
+
marginBottom: "20px"
|
|
1722
|
+
},
|
|
1723
|
+
sandboxOverlay: {
|
|
1724
|
+
position: "absolute",
|
|
1725
|
+
top: "50%",
|
|
1726
|
+
left: "50%",
|
|
1727
|
+
transform: "translate(-50%, -50%) rotate(-30deg)",
|
|
1728
|
+
fontSize: "22px",
|
|
1729
|
+
fontWeight: 900,
|
|
1730
|
+
color: "rgba(251, 146, 60, 0.55)",
|
|
1731
|
+
letterSpacing: "6px",
|
|
1732
|
+
pointerEvents: "none",
|
|
1733
|
+
userSelect: "none",
|
|
1734
|
+
whiteSpace: "nowrap"
|
|
1735
|
+
},
|
|
1736
|
+
divider: {
|
|
1737
|
+
display: "flex",
|
|
1738
|
+
alignItems: "center",
|
|
1739
|
+
gap: "12px",
|
|
1740
|
+
margin: "0 0 16px",
|
|
1741
|
+
color: "#9ca3af",
|
|
1742
|
+
fontSize: "13px"
|
|
1743
|
+
},
|
|
1744
|
+
dividerLine: {
|
|
1745
|
+
flex: 1,
|
|
1746
|
+
height: "1px",
|
|
1747
|
+
background: "#e5e7eb"
|
|
1748
|
+
},
|
|
1749
|
+
codeBox: {
|
|
1750
|
+
display: "flex",
|
|
1751
|
+
gap: "8px",
|
|
1752
|
+
marginBottom: "20px"
|
|
1753
|
+
},
|
|
1754
|
+
codeInput: {
|
|
1755
|
+
flex: 1,
|
|
1756
|
+
padding: "10px 12px",
|
|
1757
|
+
border: "1px solid #d1d5db",
|
|
1758
|
+
borderRadius: "8px",
|
|
1759
|
+
fontSize: "12px",
|
|
1760
|
+
color: "#374151",
|
|
1761
|
+
background: "#f9fafb",
|
|
1762
|
+
overflow: "hidden",
|
|
1763
|
+
textOverflow: "ellipsis",
|
|
1764
|
+
whiteSpace: "nowrap",
|
|
1765
|
+
cursor: "default",
|
|
1766
|
+
outline: "none"
|
|
1767
|
+
},
|
|
1768
|
+
copyButton: {
|
|
1769
|
+
padding: "10px 16px",
|
|
1770
|
+
background: "#6366f1",
|
|
1771
|
+
color: "#fff",
|
|
1772
|
+
border: "none",
|
|
1773
|
+
borderRadius: "8px",
|
|
1774
|
+
fontSize: "13px",
|
|
1775
|
+
fontWeight: 600,
|
|
1776
|
+
cursor: "pointer",
|
|
1777
|
+
whiteSpace: "nowrap",
|
|
1778
|
+
transition: "background 0.15s"
|
|
1779
|
+
},
|
|
1780
|
+
copyButtonCopied: {
|
|
1781
|
+
background: "#059669"
|
|
1782
|
+
},
|
|
1783
|
+
waitingText: {
|
|
1784
|
+
fontSize: "14px",
|
|
1785
|
+
color: "#6b7280",
|
|
1786
|
+
margin: "0 0 16px"
|
|
1787
|
+
},
|
|
1788
|
+
sandboxBlock: {
|
|
1789
|
+
marginTop: "4px",
|
|
1790
|
+
border: "1px solid #fed7aa",
|
|
1791
|
+
borderRadius: "12px",
|
|
1792
|
+
background: "#fff7ed",
|
|
1793
|
+
padding: "16px",
|
|
1794
|
+
textAlign: "left"
|
|
1795
|
+
},
|
|
1796
|
+
sandboxBlockHeader: {
|
|
1797
|
+
display: "flex",
|
|
1798
|
+
alignItems: "center",
|
|
1799
|
+
gap: "8px",
|
|
1800
|
+
marginBottom: "6px"
|
|
1801
|
+
},
|
|
1802
|
+
sandboxBlockTitle: {
|
|
1803
|
+
fontSize: "13px",
|
|
1804
|
+
fontWeight: 700,
|
|
1805
|
+
color: "#9a3412",
|
|
1806
|
+
margin: 0
|
|
1807
|
+
},
|
|
1808
|
+
sandboxBlockText: {
|
|
1809
|
+
fontSize: "12px",
|
|
1810
|
+
color: "#c2410c",
|
|
1811
|
+
margin: "0 0 12px"
|
|
1812
|
+
},
|
|
1813
|
+
simulateButton: {
|
|
1814
|
+
width: "100%",
|
|
1815
|
+
padding: "12px",
|
|
1816
|
+
background: "#22c55e",
|
|
1817
|
+
color: "#fff",
|
|
1818
|
+
border: "none",
|
|
1819
|
+
borderRadius: "8px",
|
|
1820
|
+
fontSize: "14px",
|
|
1821
|
+
fontWeight: 600,
|
|
1822
|
+
cursor: "pointer",
|
|
1823
|
+
transition: "background 0.15s"
|
|
1824
|
+
},
|
|
1825
|
+
successBlock: {
|
|
1826
|
+
padding: "20px",
|
|
1827
|
+
border: "1px solid #bbf7d0",
|
|
1828
|
+
borderRadius: "12px",
|
|
1829
|
+
background: "#f0fdf4",
|
|
1830
|
+
marginTop: "8px"
|
|
1831
|
+
},
|
|
1832
|
+
successText: {
|
|
1833
|
+
fontSize: "18px",
|
|
1834
|
+
color: "#15803d",
|
|
1835
|
+
fontWeight: 700,
|
|
1836
|
+
margin: "0 0 4px"
|
|
1837
|
+
},
|
|
1838
|
+
successSubtext: {
|
|
1839
|
+
fontSize: "13px",
|
|
1840
|
+
color: "#16a34a",
|
|
1841
|
+
margin: 0
|
|
1842
|
+
},
|
|
1843
|
+
errorText: {
|
|
1844
|
+
fontSize: "13px",
|
|
1845
|
+
color: "#dc2626",
|
|
1846
|
+
background: "#fef2f2",
|
|
1847
|
+
border: "1px solid #fecaca",
|
|
1848
|
+
borderRadius: "8px",
|
|
1849
|
+
padding: "10px 12px",
|
|
1850
|
+
margin: "0 0 12px"
|
|
1851
|
+
},
|
|
1852
|
+
spinner: {
|
|
1853
|
+
display: "inline-block",
|
|
1854
|
+
width: "40px",
|
|
1855
|
+
height: "40px",
|
|
1856
|
+
border: "3px solid #e5e7eb",
|
|
1857
|
+
borderTopColor: "#6366f1",
|
|
1858
|
+
borderRadius: "50%",
|
|
1859
|
+
margin: "20px auto"
|
|
1860
|
+
}
|
|
1861
|
+
};
|
|
1862
|
+
function Je(e) {
|
|
1863
|
+
return new Intl.NumberFormat("pt-BR", {
|
|
1864
|
+
style: "currency",
|
|
1865
|
+
currency: "BRL"
|
|
1866
|
+
}).format(e / 100);
|
|
1867
|
+
}
|
|
1868
|
+
function qe({
|
|
1869
|
+
title: e = "Pagar com PIX",
|
|
1870
|
+
className: t,
|
|
1871
|
+
style: i,
|
|
1872
|
+
...o
|
|
1873
|
+
}) {
|
|
1874
|
+
const { qrCodeEmv: n, status: r, error: s, copyCode: a, copied: c, simulatePayment: u } = ee(o), { amount: l, sandbox: E = !1 } = o, p = r === "idle" || r === "loading", d = r === "active", m = r === "completed", g = r === "error";
|
|
1875
|
+
return /* @__PURE__ */ v(Pt, { children: [
|
|
1876
|
+
/* @__PURE__ */ I("style", { children: "@keyframes _vp_spin { to { transform: rotate(360deg) } }" }),
|
|
1877
|
+
/* @__PURE__ */ v("div", { className: t, style: { ...T.container, ...i }, children: [
|
|
1878
|
+
/* @__PURE__ */ I("p", { style: T.title, children: e }),
|
|
1879
|
+
/* @__PURE__ */ I("p", { style: T.amount, children: Je(l) }),
|
|
1880
|
+
p && /* @__PURE__ */ I("div", { style: { ...T.spinner, animation: "_vp_spin 0.8s linear infinite" } }),
|
|
1881
|
+
d && n && /* @__PURE__ */ v(Pt, { children: [
|
|
1882
|
+
/* @__PURE__ */ v("div", { style: T.qrWrapper, children: [
|
|
1883
|
+
/* @__PURE__ */ I(He, { emv: n, size: 220 }),
|
|
1884
|
+
E && /* @__PURE__ */ I("span", { style: T.sandboxOverlay, children: "SANDBOX" })
|
|
1885
|
+
] }),
|
|
1886
|
+
/* @__PURE__ */ v("div", { style: T.divider, children: [
|
|
1887
|
+
/* @__PURE__ */ I("div", { style: T.dividerLine }),
|
|
1888
|
+
/* @__PURE__ */ I("span", { children: "ou copie o código" }),
|
|
1889
|
+
/* @__PURE__ */ I("div", { style: T.dividerLine })
|
|
1890
|
+
] }),
|
|
1891
|
+
/* @__PURE__ */ v("div", { style: T.codeBox, children: [
|
|
1892
|
+
/* @__PURE__ */ I(
|
|
1893
|
+
"input",
|
|
1894
|
+
{
|
|
1895
|
+
readOnly: !0,
|
|
1896
|
+
value: n,
|
|
1897
|
+
style: T.codeInput,
|
|
1898
|
+
onClick: (b) => b.target.select()
|
|
1899
|
+
}
|
|
1900
|
+
),
|
|
1901
|
+
/* @__PURE__ */ I(
|
|
1902
|
+
"button",
|
|
1903
|
+
{
|
|
1904
|
+
onClick: a,
|
|
1905
|
+
style: { ...T.copyButton, ...c ? T.copyButtonCopied : {} },
|
|
1906
|
+
children: c ? "✓ Copiado" : "Copiar"
|
|
1907
|
+
}
|
|
1908
|
+
)
|
|
1909
|
+
] }),
|
|
1910
|
+
/* @__PURE__ */ I("p", { style: T.waitingText, children: "⏳ Aguardando pagamento…" }),
|
|
1911
|
+
E && /* @__PURE__ */ v("div", { style: T.sandboxBlock, children: [
|
|
1912
|
+
/* @__PURE__ */ v("div", { style: T.sandboxBlockHeader, children: [
|
|
1913
|
+
/* @__PURE__ */ I("span", { children: "🧪" }),
|
|
1914
|
+
/* @__PURE__ */ I("p", { style: T.sandboxBlockTitle, children: "MODO SANDBOX — Ambiente de testes" })
|
|
1915
|
+
] }),
|
|
1916
|
+
/* @__PURE__ */ I("p", { style: T.sandboxBlockText, children: "Nenhum pagamento real será processado. Use o botão abaixo para simular." }),
|
|
1917
|
+
/* @__PURE__ */ I("button", { onClick: u, style: T.simulateButton, children: "✅ Simular pagamento" })
|
|
1918
|
+
] })
|
|
1919
|
+
] }),
|
|
1920
|
+
m && /* @__PURE__ */ v("div", { style: T.successBlock, children: [
|
|
1921
|
+
/* @__PURE__ */ I("p", { style: T.successText, children: "✅ Pagamento confirmado!" }),
|
|
1922
|
+
/* @__PURE__ */ I("p", { style: T.successSubtext, children: "Obrigado. Sua transação foi processada com sucesso." })
|
|
1923
|
+
] }),
|
|
1924
|
+
g && s && /* @__PURE__ */ v("p", { style: T.errorText, children: [
|
|
1925
|
+
"⚠️ ",
|
|
1926
|
+
s
|
|
1927
|
+
] })
|
|
1928
|
+
] })
|
|
1929
|
+
] });
|
|
1930
|
+
}
|
|
1931
|
+
export {
|
|
1932
|
+
qe as PixCheckout,
|
|
1933
|
+
He as PixQrCode,
|
|
1934
|
+
$t as VerusPayClient,
|
|
1935
|
+
ee as usePixPayment
|
|
1936
|
+
};
|
|
1937
|
+
//# sourceMappingURL=index.js.map
|