@drop-africa/drop-js 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +44 -18
- package/dist/drop.js +286 -270
- package/dist/drop.js.map +1 -1
- package/dist/drop.umd.cjs +4 -4
- package/dist/drop.umd.cjs.map +1 -1
- package/dist/index.d.ts +20 -2
- package/package.json +6 -9
package/dist/drop.js
CHANGED
|
@@ -5,17 +5,17 @@ const It = {
|
|
|
5
5
|
PaymentFailed: "failed",
|
|
6
6
|
PaymentCancelled: "cancelled",
|
|
7
7
|
PaymentExpired: "expired"
|
|
8
|
-
},
|
|
8
|
+
}, kt = /* @__PURE__ */ new Set([
|
|
9
9
|
"succeeded",
|
|
10
10
|
"failed",
|
|
11
11
|
"cancelled",
|
|
12
12
|
"expired"
|
|
13
13
|
]);
|
|
14
|
-
function
|
|
14
|
+
function Dt(c) {
|
|
15
15
|
return It[c] ?? null;
|
|
16
16
|
}
|
|
17
|
-
function
|
|
18
|
-
return
|
|
17
|
+
function Rt(c) {
|
|
18
|
+
return kt.has(c);
|
|
19
19
|
}
|
|
20
20
|
function pt(c, A, z) {
|
|
21
21
|
return { code: c, message: A, retryable: z };
|
|
@@ -35,8 +35,8 @@ function bt(c, A) {
|
|
|
35
35
|
function St(c) {
|
|
36
36
|
return pt("NETWORK_ERROR", c, !0);
|
|
37
37
|
}
|
|
38
|
-
const At = 3e3,
|
|
39
|
-
class
|
|
38
|
+
const At = 3e3, Bt = 1.5, Pt = 3e4, Mt = 5, zt = 3e4;
|
|
39
|
+
class Nt {
|
|
40
40
|
constructor(A) {
|
|
41
41
|
this.interval = At, this.timer = null, this.destroyed = !1, this.consecutiveFailures = 0, this.currentStatus = "initiated", this.expiresAt = null, this.config = A, A.pollingInterval && (this.interval = A.pollingInterval);
|
|
42
42
|
}
|
|
@@ -57,28 +57,28 @@ class qt {
|
|
|
57
57
|
return;
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
60
|
-
const
|
|
61
|
-
if (
|
|
60
|
+
const R = await this.fetchStatus();
|
|
61
|
+
if (R.ok) {
|
|
62
62
|
this.consecutiveFailures = 0, this.interval = At;
|
|
63
|
-
const
|
|
64
|
-
this.expiresAt = new Date(
|
|
65
|
-
const Q =
|
|
66
|
-
if (Q && Q !== this.currentStatus && (this.emitStatus(Q),
|
|
63
|
+
const k = await R.json();
|
|
64
|
+
this.expiresAt = new Date(k.expiresAt);
|
|
65
|
+
const Q = Dt(k.status);
|
|
66
|
+
if (Q && Q !== this.currentStatus && (this.emitStatus(Q), Rt(Q)))
|
|
67
67
|
return;
|
|
68
|
-
} else if (
|
|
69
|
-
const
|
|
70
|
-
if (
|
|
71
|
-
const Q = parseInt(
|
|
68
|
+
} else if (R.status === 429) {
|
|
69
|
+
const k = R.headers.get("Retry-After");
|
|
70
|
+
if (k) {
|
|
71
|
+
const Q = parseInt(k, 10);
|
|
72
72
|
isNaN(Q) || (this.interval = Q * 1e3);
|
|
73
73
|
} else
|
|
74
74
|
this.applyBackoff();
|
|
75
75
|
this.config.onError(bt(429));
|
|
76
|
-
} else if (
|
|
77
|
-
this.config.onError(bt(
|
|
76
|
+
} else if (R.status === 401 || R.status === 404) {
|
|
77
|
+
this.config.onError(bt(R.status));
|
|
78
78
|
return;
|
|
79
|
-
} else if (this.consecutiveFailures++, this.applyBackoff(), this.config.onError(bt(
|
|
79
|
+
} else if (this.consecutiveFailures++, this.applyBackoff(), this.config.onError(bt(R.status)), this.consecutiveFailures >= Mt) {
|
|
80
80
|
this.config.onError(
|
|
81
|
-
bt(
|
|
81
|
+
bt(R.status, "Max consecutive failures reached. Stopping.")
|
|
82
82
|
);
|
|
83
83
|
return;
|
|
84
84
|
}
|
|
@@ -106,7 +106,7 @@ class qt {
|
|
|
106
106
|
this.currentStatus = A, this.config.onStatusChange(A);
|
|
107
107
|
}
|
|
108
108
|
applyBackoff() {
|
|
109
|
-
this.interval = Math.min(this.interval *
|
|
109
|
+
this.interval = Math.min(this.interval * Bt, Pt);
|
|
110
110
|
}
|
|
111
111
|
isExpired() {
|
|
112
112
|
return this.expiresAt ? Date.now() > this.expiresAt.getTime() + zt : !1;
|
|
@@ -115,17 +115,17 @@ class qt {
|
|
|
115
115
|
this.destroyed || (this.timer = setTimeout(() => this.poll(), this.interval));
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function Tt(c) {
|
|
119
119
|
return c && c.__esModule && Object.prototype.hasOwnProperty.call(c, "default") ? c.default : c;
|
|
120
120
|
}
|
|
121
|
-
var xt = { exports: {} },
|
|
122
|
-
function
|
|
123
|
-
return
|
|
124
|
-
(function(z,
|
|
125
|
-
c.exports =
|
|
126
|
-
})(
|
|
121
|
+
var xt = { exports: {} }, qt = xt.exports, Ot;
|
|
122
|
+
function Lt() {
|
|
123
|
+
return Ot || (Ot = 1, (function(c, A) {
|
|
124
|
+
(function(z, R) {
|
|
125
|
+
c.exports = R();
|
|
126
|
+
})(qt, (() => (() => {
|
|
127
127
|
var z = { 873: (S, x) => {
|
|
128
|
-
var
|
|
128
|
+
var D, F, N = (function() {
|
|
129
129
|
var U = function(p, l) {
|
|
130
130
|
var d = p, e = st[l], t = null, n = 0, r = null, i = [], a = {}, w = function(o, h) {
|
|
131
131
|
t = (function(s) {
|
|
@@ -134,68 +134,68 @@ function Tt() {
|
|
|
134
134
|
for (var b = 0; b < s; b += 1) u[g][b] = null;
|
|
135
135
|
}
|
|
136
136
|
return u;
|
|
137
|
-
})(n = 4 * d + 17), f(0, 0), f(n - 7, 0), f(0, n - 7), m(), _(), v(o, h), d >= 7 && y(o), r == null && (r =
|
|
137
|
+
})(n = 4 * d + 17), f(0, 0), f(n - 7, 0), f(0, n - 7), m(), _(), v(o, h), d >= 7 && y(o), r == null && (r = B(d, e, i)), C(r, h);
|
|
138
138
|
}, f = function(o, h) {
|
|
139
139
|
for (var s = -1; s <= 7; s += 1) if (!(o + s <= -1 || n <= o + s)) for (var u = -1; u <= 7; u += 1) h + u <= -1 || n <= h + u || (t[o + s][h + u] = 0 <= s && s <= 6 && (u == 0 || u == 6) || 0 <= u && u <= 6 && (s == 0 || s == 6) || 2 <= s && s <= 4 && 2 <= u && u <= 4);
|
|
140
140
|
}, _ = function() {
|
|
141
141
|
for (var o = 8; o < n - 8; o += 1) t[o][6] == null && (t[o][6] = o % 2 == 0);
|
|
142
142
|
for (var h = 8; h < n - 8; h += 1) t[6][h] == null && (t[6][h] = h % 2 == 0);
|
|
143
143
|
}, m = function() {
|
|
144
|
-
for (var o =
|
|
144
|
+
for (var o = Y.getPatternPosition(d), h = 0; h < o.length; h += 1) for (var s = 0; s < o.length; s += 1) {
|
|
145
145
|
var u = o[h], g = o[s];
|
|
146
|
-
if (t[u][g] == null) for (var b = -2; b <= 2; b += 1) for (var
|
|
146
|
+
if (t[u][g] == null) for (var b = -2; b <= 2; b += 1) for (var $ = -2; $ <= 2; $ += 1) t[u + b][g + $] = b == -2 || b == 2 || $ == -2 || $ == 2 || b == 0 && $ == 0;
|
|
147
147
|
}
|
|
148
148
|
}, y = function(o) {
|
|
149
|
-
for (var h =
|
|
149
|
+
for (var h = Y.getBCHTypeNumber(d), s = 0; s < 18; s += 1) {
|
|
150
150
|
var u = !o && (h >> s & 1) == 1;
|
|
151
151
|
t[Math.floor(s / 3)][s % 3 + n - 8 - 3] = u;
|
|
152
152
|
}
|
|
153
153
|
for (s = 0; s < 18; s += 1) u = !o && (h >> s & 1) == 1, t[s % 3 + n - 8 - 3][Math.floor(s / 3)] = u;
|
|
154
154
|
}, v = function(o, h) {
|
|
155
|
-
for (var s = e << 3 | h, u =
|
|
155
|
+
for (var s = e << 3 | h, u = Y.getBCHTypeInfo(s), g = 0; g < 15; g += 1) {
|
|
156
156
|
var b = !o && (u >> g & 1) == 1;
|
|
157
157
|
g < 6 ? t[g][8] = b : g < 8 ? t[g + 1][8] = b : t[n - 15 + g][8] = b;
|
|
158
158
|
}
|
|
159
159
|
for (g = 0; g < 15; g += 1) b = !o && (u >> g & 1) == 1, g < 8 ? t[8][n - g - 1] = b : g < 9 ? t[8][15 - g - 1 + 1] = b : t[8][15 - g - 1] = b;
|
|
160
160
|
t[n - 8][8] = !o;
|
|
161
161
|
}, C = function(o, h) {
|
|
162
|
-
for (var s = -1, u = n - 1, g = 7, b = 0,
|
|
163
|
-
for (var
|
|
164
|
-
var
|
|
165
|
-
b < o.length && (
|
|
162
|
+
for (var s = -1, u = n - 1, g = 7, b = 0, $ = Y.getMaskFunction(h), I = n - 1; I > 0; I -= 2) for (I == 6 && (I -= 1); ; ) {
|
|
163
|
+
for (var q = 0; q < 2; q += 1) if (t[u][I - q] == null) {
|
|
164
|
+
var L = !1;
|
|
165
|
+
b < o.length && (L = (o[b] >>> g & 1) == 1), $(u, I - q) && (L = !L), t[u][I - q] = L, (g -= 1) == -1 && (b += 1, g = 7);
|
|
166
166
|
}
|
|
167
167
|
if ((u += s) < 0 || n <= u) {
|
|
168
168
|
u -= s, s = -s;
|
|
169
169
|
break;
|
|
170
170
|
}
|
|
171
171
|
}
|
|
172
|
-
},
|
|
172
|
+
}, B = function(o, h, s) {
|
|
173
173
|
for (var u = ft.getRSBlocks(o, h), g = ut(), b = 0; b < s.length; b += 1) {
|
|
174
|
-
var
|
|
175
|
-
g.put(
|
|
174
|
+
var $ = s[b];
|
|
175
|
+
g.put($.getMode(), 4), g.put($.getLength(), Y.getLengthInBits($.getMode(), o)), $.write(g);
|
|
176
176
|
}
|
|
177
177
|
var I = 0;
|
|
178
178
|
for (b = 0; b < u.length; b += 1) I += u[b].dataCount;
|
|
179
179
|
if (g.getLengthInBits() > 8 * I) throw "code length overflow. (" + g.getLengthInBits() + ">" + 8 * I + ")";
|
|
180
180
|
for (g.getLengthInBits() + 4 <= 8 * I && g.put(0, 4); g.getLengthInBits() % 8 != 0; ) g.putBit(!1);
|
|
181
181
|
for (; !(g.getLengthInBits() >= 8 * I || (g.put(236, 8), g.getLengthInBits() >= 8 * I)); ) g.put(17, 8);
|
|
182
|
-
return (function(
|
|
183
|
-
for (var H = 0, tt = 0,
|
|
184
|
-
var
|
|
185
|
-
tt = Math.max(tt,
|
|
186
|
-
for (var
|
|
187
|
-
H +=
|
|
188
|
-
var ot =
|
|
189
|
-
for (j[M] = new Array(ot.getLength() - 1),
|
|
190
|
-
var et =
|
|
191
|
-
j[M][
|
|
182
|
+
return (function(q, L) {
|
|
183
|
+
for (var H = 0, tt = 0, X = 0, W = new Array(L.length), j = new Array(L.length), M = 0; M < L.length; M += 1) {
|
|
184
|
+
var K = L[M].dataCount, J = L[M].totalCount - K;
|
|
185
|
+
tt = Math.max(tt, K), X = Math.max(X, J), W[M] = new Array(K);
|
|
186
|
+
for (var E = 0; E < W[M].length; E += 1) W[M][E] = 255 & q.getBuffer()[E + H];
|
|
187
|
+
H += K;
|
|
188
|
+
var ot = Y.getErrorCorrectPolynomial(J), rt = dt(W[M], ot.getLength() - 1).mod(ot);
|
|
189
|
+
for (j[M] = new Array(ot.getLength() - 1), E = 0; E < j[M].length; E += 1) {
|
|
190
|
+
var et = E + rt.getLength() - j[M].length;
|
|
191
|
+
j[M][E] = et >= 0 ? rt.getAt(et) : 0;
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
var yt = 0;
|
|
195
|
-
for (
|
|
195
|
+
for (E = 0; E < L.length; E += 1) yt += L[E].totalCount;
|
|
196
196
|
var gt = new Array(yt), at = 0;
|
|
197
|
-
for (
|
|
198
|
-
for (
|
|
197
|
+
for (E = 0; E < tt; E += 1) for (M = 0; M < L.length; M += 1) E < W[M].length && (gt[at] = W[M][E], at += 1);
|
|
198
|
+
for (E = 0; E < X; E += 1) for (M = 0; M < L.length; M += 1) E < j[M].length && (gt[at] = j[M][E], at += 1);
|
|
199
199
|
return gt;
|
|
200
200
|
})(g, u);
|
|
201
201
|
};
|
|
@@ -228,7 +228,7 @@ function Tt() {
|
|
|
228
228
|
for (var o = 1; o < 40; o++) {
|
|
229
229
|
for (var h = ft.getRSBlocks(o, e), s = ut(), u = 0; u < i.length; u++) {
|
|
230
230
|
var g = i[u];
|
|
231
|
-
s.put(g.getMode(), 4), s.put(g.getLength(),
|
|
231
|
+
s.put(g.getMode(), 4), s.put(g.getLength(), Y.getLengthInBits(g.getMode(), o)), g.write(s);
|
|
232
232
|
}
|
|
233
233
|
var b = 0;
|
|
234
234
|
for (u = 0; u < h.length; u++) b += h[u].dataCount;
|
|
@@ -237,10 +237,10 @@ function Tt() {
|
|
|
237
237
|
d = o;
|
|
238
238
|
}
|
|
239
239
|
w(!1, (function() {
|
|
240
|
-
for (var
|
|
241
|
-
w(!0,
|
|
242
|
-
var
|
|
243
|
-
(
|
|
240
|
+
for (var $ = 0, I = 0, q = 0; q < 8; q += 1) {
|
|
241
|
+
w(!0, q);
|
|
242
|
+
var L = Y.getLostPoint(a);
|
|
243
|
+
(q == 0 || $ > L) && ($ = L, I = q);
|
|
244
244
|
}
|
|
245
245
|
return I;
|
|
246
246
|
})());
|
|
@@ -257,25 +257,25 @@ function Tt() {
|
|
|
257
257
|
}, a.createSvgTag = function(o, h, s, u) {
|
|
258
258
|
var g = {};
|
|
259
259
|
typeof arguments[0] == "object" && (o = (g = arguments[0]).cellSize, h = g.margin, s = g.alt, u = g.title), o = o || 2, h = h === void 0 ? 4 * o : h, (s = typeof s == "string" ? { text: s } : s || {}).text = s.text || null, s.id = s.text ? s.id || "qrcode-description" : null, (u = typeof u == "string" ? { text: u } : u || {}).text = u.text || null, u.id = u.text ? u.id || "qrcode-title" : null;
|
|
260
|
-
var b,
|
|
261
|
-
for (
|
|
260
|
+
var b, $, I, q, L = a.getModuleCount() * o + 2 * h, H = "";
|
|
261
|
+
for (q = "l" + o + ",0 0," + o + " -" + o + ",0 0,-" + o + "z ", H += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"', H += g.scalable ? "" : ' width="' + L + 'px" height="' + L + 'px"', H += ' viewBox="0 0 ' + L + " " + L + '" ', H += ' preserveAspectRatio="xMinYMin meet"', H += u.text || s.text ? ' role="img" aria-labelledby="' + O([u.id, s.id].join(" ").trim()) + '"' : "", H += ">", H += u.text ? '<title id="' + O(u.id) + '">' + O(u.text) + "</title>" : "", H += s.text ? '<description id="' + O(s.id) + '">' + O(s.text) + "</description>" : "", H += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>', H += '<path d="', $ = 0; $ < a.getModuleCount(); $ += 1) for (I = $ * o + h, b = 0; b < a.getModuleCount(); b += 1) a.isDark($, b) && (H += "M" + (b * o + h) + "," + I + q);
|
|
262
262
|
return (H += '" stroke="transparent" fill="black"/>') + "</svg>";
|
|
263
263
|
}, a.createDataURL = function(o, h) {
|
|
264
264
|
o = o || 2, h = h === void 0 ? 4 * o : h;
|
|
265
265
|
var s = a.getModuleCount() * o + 2 * h, u = h, g = s - h;
|
|
266
|
-
return lt(s, s, (function(b,
|
|
267
|
-
if (u <= b && b < g && u <=
|
|
268
|
-
var I = Math.floor((b - u) / o),
|
|
269
|
-
return a.isDark(
|
|
266
|
+
return lt(s, s, (function(b, $) {
|
|
267
|
+
if (u <= b && b < g && u <= $ && $ < g) {
|
|
268
|
+
var I = Math.floor((b - u) / o), q = Math.floor(($ - u) / o);
|
|
269
|
+
return a.isDark(q, I) ? 0 : 1;
|
|
270
270
|
}
|
|
271
271
|
return 1;
|
|
272
272
|
}));
|
|
273
273
|
}, a.createImgTag = function(o, h, s) {
|
|
274
274
|
o = o || 2, h = h === void 0 ? 4 * o : h;
|
|
275
275
|
var u = a.getModuleCount() * o + 2 * h, g = "";
|
|
276
|
-
return g += "<img", g += ' src="', g += a.createDataURL(o, h), g += '"', g += ' width="', g += u, g += '"', g += ' height="', g += u, g += '"', s && (g += ' alt="', g +=
|
|
276
|
+
return g += "<img", g += ' src="', g += a.createDataURL(o, h), g += '"', g += ' width="', g += u, g += '"', g += ' height="', g += u, g += '"', s && (g += ' alt="', g += O(s), g += '"'), g + "/>";
|
|
277
277
|
};
|
|
278
|
-
var
|
|
278
|
+
var O = function(o) {
|
|
279
279
|
for (var h = "", s = 0; s < o.length; s += 1) {
|
|
280
280
|
var u = o.charAt(s);
|
|
281
281
|
switch (u) {
|
|
@@ -298,21 +298,21 @@ function Tt() {
|
|
|
298
298
|
return h;
|
|
299
299
|
};
|
|
300
300
|
return a.createASCII = function(o, h) {
|
|
301
|
-
if ((o = o || 1) < 2) return (function(
|
|
302
|
-
|
|
303
|
-
var j, M,
|
|
301
|
+
if ((o = o || 1) < 2) return (function(W) {
|
|
302
|
+
W = W === void 0 ? 2 : W;
|
|
303
|
+
var j, M, K, J, E, ot = 1 * a.getModuleCount() + 2 * W, rt = W, et = ot - W, yt = { "██": "█", "█ ": "▀", " █": "▄", " ": " " }, gt = { "██": "▀", "█ ": "▀", " █": " ", " ": " " }, at = "";
|
|
304
304
|
for (j = 0; j < ot; j += 2) {
|
|
305
|
-
for (
|
|
305
|
+
for (K = Math.floor((j - rt) / 1), J = Math.floor((j + 1 - rt) / 1), M = 0; M < ot; M += 1) E = "█", rt <= M && M < et && rt <= j && j < et && a.isDark(K, Math.floor((M - rt) / 1)) && (E = " "), rt <= M && M < et && rt <= j + 1 && j + 1 < et && a.isDark(J, Math.floor((M - rt) / 1)) ? E += " " : E += "█", at += W < 1 && j + 1 >= et ? gt[E] : yt[E];
|
|
306
306
|
at += `
|
|
307
307
|
`;
|
|
308
308
|
}
|
|
309
|
-
return ot % 2 &&
|
|
309
|
+
return ot % 2 && W > 0 ? at.substring(0, at.length - ot - 1) + Array(ot + 1).join("▀") : at.substring(0, at.length - 1);
|
|
310
310
|
})(h);
|
|
311
311
|
o -= 1, h = h === void 0 ? 2 * o : h;
|
|
312
|
-
var s, u, g, b,
|
|
313
|
-
for (s = 0; s <
|
|
314
|
-
for (g = Math.floor((s - I) / o),
|
|
315
|
-
for (g = 0; g < o; g += 1) tt +=
|
|
312
|
+
var s, u, g, b, $ = a.getModuleCount() * o + 2 * h, I = h, q = $ - h, L = Array(o + 1).join("██"), H = Array(o + 1).join(" "), tt = "", X = "";
|
|
313
|
+
for (s = 0; s < $; s += 1) {
|
|
314
|
+
for (g = Math.floor((s - I) / o), X = "", u = 0; u < $; u += 1) b = 1, I <= u && u < q && I <= s && s < q && a.isDark(g, Math.floor((u - I) / o)) && (b = 0), X += b ? L : H;
|
|
315
|
+
for (g = 0; g < o; g += 1) tt += X + `
|
|
316
316
|
`;
|
|
317
317
|
}
|
|
318
318
|
return tt.substring(0, tt.length - 1);
|
|
@@ -354,18 +354,18 @@ function Tt() {
|
|
|
354
354
|
return n;
|
|
355
355
|
};
|
|
356
356
|
};
|
|
357
|
-
var
|
|
357
|
+
var Z, V, T, P, nt, st = { L: 1, M: 0, Q: 3, H: 2 }, Y = (Z = [[], [6, 18], [6, 22], [6, 26], [6, 30], [6, 34], [6, 22, 38], [6, 24, 42], [6, 26, 46], [6, 28, 50], [6, 30, 54], [6, 32, 58], [6, 34, 62], [6, 26, 46, 66], [6, 26, 48, 70], [6, 26, 50, 74], [6, 30, 54, 78], [6, 30, 56, 82], [6, 30, 58, 86], [6, 34, 62, 90], [6, 28, 50, 72, 94], [6, 26, 50, 74, 98], [6, 30, 54, 78, 102], [6, 28, 54, 80, 106], [6, 32, 58, 84, 110], [6, 30, 58, 86, 114], [6, 34, 62, 90, 118], [6, 26, 50, 74, 98, 122], [6, 30, 54, 78, 102, 126], [6, 26, 52, 78, 104, 130], [6, 30, 56, 82, 108, 134], [6, 34, 60, 86, 112, 138], [6, 30, 58, 86, 114, 142], [6, 34, 62, 90, 118, 146], [6, 30, 54, 78, 102, 126, 150], [6, 24, 50, 76, 102, 128, 154], [6, 28, 54, 80, 106, 132, 158], [6, 32, 58, 84, 110, 136, 162], [6, 26, 54, 82, 110, 138, 166], [6, 30, 58, 86, 114, 142, 170]], V = 1335, T = 7973, nt = function(p) {
|
|
358
358
|
for (var l = 0; p != 0; ) l += 1, p >>>= 1;
|
|
359
359
|
return l;
|
|
360
|
-
}, (
|
|
361
|
-
for (var l = p << 10; nt(l) - nt(
|
|
360
|
+
}, (P = {}).getBCHTypeInfo = function(p) {
|
|
361
|
+
for (var l = p << 10; nt(l) - nt(V) >= 0; ) l ^= V << nt(l) - nt(V);
|
|
362
362
|
return 21522 ^ (p << 10 | l);
|
|
363
|
-
},
|
|
364
|
-
for (var l = p << 12; nt(l) - nt(
|
|
363
|
+
}, P.getBCHTypeNumber = function(p) {
|
|
364
|
+
for (var l = p << 12; nt(l) - nt(T) >= 0; ) l ^= T << nt(l) - nt(T);
|
|
365
365
|
return p << 12 | l;
|
|
366
|
-
},
|
|
367
|
-
return
|
|
368
|
-
},
|
|
366
|
+
}, P.getPatternPosition = function(p) {
|
|
367
|
+
return Z[p - 1];
|
|
368
|
+
}, P.getMaskFunction = function(p) {
|
|
369
369
|
switch (p) {
|
|
370
370
|
case 0:
|
|
371
371
|
return function(l, d) {
|
|
@@ -402,10 +402,10 @@ function Tt() {
|
|
|
402
402
|
default:
|
|
403
403
|
throw "bad maskPattern:" + p;
|
|
404
404
|
}
|
|
405
|
-
},
|
|
406
|
-
for (var l = dt([1], 0), d = 0; d < p; d += 1) l = l.multiply(dt([1,
|
|
405
|
+
}, P.getErrorCorrectPolynomial = function(p) {
|
|
406
|
+
for (var l = dt([1], 0), d = 0; d < p; d += 1) l = l.multiply(dt([1, G.gexp(d)], 0));
|
|
407
407
|
return l;
|
|
408
|
-
},
|
|
408
|
+
}, P.getLengthInBits = function(p, l) {
|
|
409
409
|
if (1 <= l && l < 10) switch (p) {
|
|
410
410
|
case 1:
|
|
411
411
|
return 10;
|
|
@@ -444,7 +444,7 @@ function Tt() {
|
|
|
444
444
|
throw "mode:" + p;
|
|
445
445
|
}
|
|
446
446
|
}
|
|
447
|
-
},
|
|
447
|
+
}, P.getLostPoint = function(p) {
|
|
448
448
|
for (var l = p.getModuleCount(), d = 0, e = 0; e < l; e += 1) for (var t = 0; t < l; t += 1) {
|
|
449
449
|
for (var n = 0, r = p.isDark(e, t), i = -1; i <= 1; i += 1) if (!(e + i < 0 || l <= e + i)) for (var a = -1; a <= 1; a += 1) t + a < 0 || l <= t + a || i == 0 && a == 0 || r == p.isDark(e + i, t + a) && (n += 1);
|
|
450
450
|
n > 5 && (d += 3 + n - 5);
|
|
@@ -458,7 +458,7 @@ function Tt() {
|
|
|
458
458
|
var f = 0;
|
|
459
459
|
for (t = 0; t < l; t += 1) for (e = 0; e < l; e += 1) p.isDark(e, t) && (f += 1);
|
|
460
460
|
return d + Math.abs(100 * f / l / l - 50) / 5 * 10;
|
|
461
|
-
},
|
|
461
|
+
}, P), G = (function() {
|
|
462
462
|
for (var p = new Array(256), l = new Array(256), d = 0; d < 8; d += 1) p[d] = 1 << d;
|
|
463
463
|
for (d = 8; d < 256; d += 1) p[d] = p[d - 4] ^ p[d - 5] ^ p[d - 6] ^ p[d - 8];
|
|
464
464
|
for (d = 0; d < 255; d += 1) l[p[d]] = d;
|
|
@@ -482,12 +482,12 @@ function Tt() {
|
|
|
482
482
|
}, getLength: function() {
|
|
483
483
|
return d.length;
|
|
484
484
|
}, multiply: function(t) {
|
|
485
|
-
for (var n = new Array(e.getLength() + t.getLength() - 1), r = 0; r < e.getLength(); r += 1) for (var i = 0; i < t.getLength(); i += 1) n[r + i] ^=
|
|
485
|
+
for (var n = new Array(e.getLength() + t.getLength() - 1), r = 0; r < e.getLength(); r += 1) for (var i = 0; i < t.getLength(); i += 1) n[r + i] ^= G.gexp(G.glog(e.getAt(r)) + G.glog(t.getAt(i)));
|
|
486
486
|
return dt(n, 0);
|
|
487
487
|
}, mod: function(t) {
|
|
488
488
|
if (e.getLength() - t.getLength() < 0) return e;
|
|
489
|
-
for (var n =
|
|
490
|
-
for (i = 0; i < t.getLength(); i += 1) r[i] ^=
|
|
489
|
+
for (var n = G.glog(e.getAt(0)) - G.glog(t.getAt(0)), r = new Array(e.getLength()), i = 0; i < e.getLength(); i += 1) r[i] = e.getAt(i);
|
|
490
|
+
for (i = 0; i < t.getLength(); i += 1) r[i] ^= G.gexp(G.glog(t.getAt(i)) + n);
|
|
491
491
|
return dt(r, 0).mod(t);
|
|
492
492
|
} };
|
|
493
493
|
return e;
|
|
@@ -662,28 +662,28 @@ function Tt() {
|
|
|
662
662
|
v[h * m + o] = s;
|
|
663
663
|
}, write: function(o) {
|
|
664
664
|
o.writeString("GIF87a"), o.writeShort(m), o.writeShort(y), o.writeByte(128), o.writeByte(0), o.writeByte(0), o.writeByte(0), o.writeByte(0), o.writeByte(0), o.writeByte(255), o.writeByte(255), o.writeByte(255), o.writeString(","), o.writeShort(0), o.writeShort(0), o.writeShort(m), o.writeShort(y), o.writeByte(0);
|
|
665
|
-
var h =
|
|
665
|
+
var h = B(2);
|
|
666
666
|
o.writeByte(2);
|
|
667
667
|
for (var s = 0; h.length - s > 255; ) o.writeByte(255), o.writeBytes(h, s, 255), s += 255;
|
|
668
668
|
o.writeByte(h.length - s), o.writeBytes(h, s, h.length - s), o.writeByte(0), o.writeString(";");
|
|
669
|
-
} },
|
|
670
|
-
for (var h = 1 << o, s = 1 + (1 << o), u = o + 1, g =
|
|
669
|
+
} }, B = function(o) {
|
|
670
|
+
for (var h = 1 << o, s = 1 + (1 << o), u = o + 1, g = O(), b = 0; b < h; b += 1) g.add(String.fromCharCode(b));
|
|
671
671
|
g.add(String.fromCharCode(h)), g.add(String.fromCharCode(s));
|
|
672
|
-
var
|
|
672
|
+
var $, I, q, L = _t(), H = ($ = L, I = 0, q = 0, { write: function(j, M) {
|
|
673
673
|
if (j >>> M) throw "length over";
|
|
674
|
-
for (; I + M >= 8; )
|
|
675
|
-
|
|
674
|
+
for (; I + M >= 8; ) $.writeByte(255 & (j << I | q)), M -= 8 - I, j >>>= 8 - I, q = 0, I = 0;
|
|
675
|
+
q |= j << I, I += M;
|
|
676
676
|
}, flush: function() {
|
|
677
|
-
I > 0 &&
|
|
677
|
+
I > 0 && $.writeByte(q);
|
|
678
678
|
} });
|
|
679
679
|
H.write(h, u);
|
|
680
|
-
var tt = 0,
|
|
680
|
+
var tt = 0, X = String.fromCharCode(v[tt]);
|
|
681
681
|
for (tt += 1; tt < v.length; ) {
|
|
682
|
-
var
|
|
683
|
-
tt += 1, g.contains(
|
|
682
|
+
var W = String.fromCharCode(v[tt]);
|
|
683
|
+
tt += 1, g.contains(X + W) ? X += W : (H.write(g.indexOf(X), u), g.size() < 4095 && (g.size() == 1 << u && (u += 1), g.add(X + W)), X = W);
|
|
684
684
|
}
|
|
685
|
-
return H.write(g.indexOf(
|
|
686
|
-
},
|
|
685
|
+
return H.write(g.indexOf(X), u), H.write(s, u), H.flush(), L.toByteArray();
|
|
686
|
+
}, O = function() {
|
|
687
687
|
var o = {}, h = 0, s = { add: function(u) {
|
|
688
688
|
if (s.contains(u)) throw "dup key:" + u;
|
|
689
689
|
o[u] = h, h += 1;
|
|
@@ -701,22 +701,22 @@ function Tt() {
|
|
|
701
701
|
var r = _t();
|
|
702
702
|
e.write(r);
|
|
703
703
|
for (var i = (function() {
|
|
704
|
-
var f = 0, _ = 0, m = 0, y = "", v = {}, C = function(
|
|
705
|
-
y += String.fromCharCode(
|
|
706
|
-
},
|
|
707
|
-
if (!(
|
|
708
|
-
if (
|
|
709
|
-
if (
|
|
710
|
-
if (
|
|
711
|
-
if (
|
|
712
|
-
if (
|
|
704
|
+
var f = 0, _ = 0, m = 0, y = "", v = {}, C = function(O) {
|
|
705
|
+
y += String.fromCharCode(B(63 & O));
|
|
706
|
+
}, B = function(O) {
|
|
707
|
+
if (!(O < 0)) {
|
|
708
|
+
if (O < 26) return 65 + O;
|
|
709
|
+
if (O < 52) return O - 26 + 97;
|
|
710
|
+
if (O < 62) return O - 52 + 48;
|
|
711
|
+
if (O == 62) return 43;
|
|
712
|
+
if (O == 63) return 47;
|
|
713
713
|
}
|
|
714
|
-
throw "n:" +
|
|
714
|
+
throw "n:" + O;
|
|
715
715
|
};
|
|
716
|
-
return v.writeByte = function(
|
|
717
|
-
for (f = f << 8 | 255 &
|
|
716
|
+
return v.writeByte = function(O) {
|
|
717
|
+
for (f = f << 8 | 255 & O, _ += 8, m += 1; _ >= 6; ) C(f >>> _ - 6), _ -= 6;
|
|
718
718
|
}, v.flush = function() {
|
|
719
|
-
if (_ > 0 && (C(f << 6 - _), f = 0, _ = 0), m % 3 != 0) for (var
|
|
719
|
+
if (_ > 0 && (C(f << 6 - _), f = 0, _ = 0), m % 3 != 0) for (var O = 3 - m % 3, o = 0; o < O; o += 1) y += "=";
|
|
720
720
|
}, v.toString = function() {
|
|
721
721
|
return y;
|
|
722
722
|
}, v;
|
|
@@ -725,33 +725,33 @@ function Tt() {
|
|
|
725
725
|
};
|
|
726
726
|
return U;
|
|
727
727
|
})();
|
|
728
|
-
|
|
729
|
-
return (function(
|
|
730
|
-
for (var
|
|
731
|
-
var
|
|
732
|
-
|
|
728
|
+
N.stringToBytesFuncs["UTF-8"] = function(U) {
|
|
729
|
+
return (function(Z) {
|
|
730
|
+
for (var V = [], T = 0; T < Z.length; T++) {
|
|
731
|
+
var P = Z.charCodeAt(T);
|
|
732
|
+
P < 128 ? V.push(P) : P < 2048 ? V.push(192 | P >> 6, 128 | 63 & P) : P < 55296 || P >= 57344 ? V.push(224 | P >> 12, 128 | P >> 6 & 63, 128 | 63 & P) : (T++, P = 65536 + ((1023 & P) << 10 | 1023 & Z.charCodeAt(T)), V.push(240 | P >> 18, 128 | P >> 12 & 63, 128 | P >> 6 & 63, 128 | 63 & P));
|
|
733
733
|
}
|
|
734
|
-
return
|
|
734
|
+
return V;
|
|
735
735
|
})(U);
|
|
736
|
-
}, (F = typeof (
|
|
737
|
-
return
|
|
738
|
-
}) == "function" ?
|
|
739
|
-
} },
|
|
740
|
-
function
|
|
741
|
-
var x =
|
|
736
|
+
}, (F = typeof (D = function() {
|
|
737
|
+
return N;
|
|
738
|
+
}) == "function" ? D.apply(x, []) : D) === void 0 || (S.exports = F);
|
|
739
|
+
} }, R = {};
|
|
740
|
+
function k(S) {
|
|
741
|
+
var x = R[S];
|
|
742
742
|
if (x !== void 0) return x.exports;
|
|
743
|
-
var
|
|
744
|
-
return z[S](
|
|
743
|
+
var D = R[S] = { exports: {} };
|
|
744
|
+
return z[S](D, D.exports, k), D.exports;
|
|
745
745
|
}
|
|
746
|
-
|
|
746
|
+
k.n = (S) => {
|
|
747
747
|
var x = S && S.__esModule ? () => S.default : () => S;
|
|
748
|
-
return
|
|
749
|
-
},
|
|
750
|
-
for (var
|
|
751
|
-
},
|
|
748
|
+
return k.d(x, { a: x }), x;
|
|
749
|
+
}, k.d = (S, x) => {
|
|
750
|
+
for (var D in x) k.o(x, D) && !k.o(S, D) && Object.defineProperty(S, D, { enumerable: !0, get: x[D] });
|
|
751
|
+
}, k.o = (S, x) => Object.prototype.hasOwnProperty.call(S, x);
|
|
752
752
|
var Q = {};
|
|
753
753
|
return (() => {
|
|
754
|
-
|
|
754
|
+
k.d(Q, { default: () => l });
|
|
755
755
|
const S = (d) => !!d && typeof d == "object" && !Array.isArray(d);
|
|
756
756
|
function x(d, ...e) {
|
|
757
757
|
if (!e.length) return d;
|
|
@@ -761,12 +761,12 @@ function Tt() {
|
|
|
761
761
|
Array.isArray(r) && Array.isArray(i) ? d[n] = i : S(r) && S(i) ? d[n] = x(Object.assign({}, r), i) : d[n] = i;
|
|
762
762
|
})), x(d, ...e)) : d;
|
|
763
763
|
}
|
|
764
|
-
function
|
|
764
|
+
function D(d, e) {
|
|
765
765
|
const t = document.createElement("a");
|
|
766
766
|
t.download = e, t.href = d, document.body.appendChild(t), t.click(), document.body.removeChild(t);
|
|
767
767
|
}
|
|
768
768
|
const F = { L: 0.07, M: 0.15, Q: 0.25, H: 0.3 };
|
|
769
|
-
class
|
|
769
|
+
class N {
|
|
770
770
|
constructor({ svg: e, type: t, window: n }) {
|
|
771
771
|
this._svg = e, this._type = t, this._window = n;
|
|
772
772
|
}
|
|
@@ -879,8 +879,8 @@ function Tt() {
|
|
|
879
879
|
i + a + w + f !== 0 ? i || w ? a || f ? this._basicSquare({ x: e, y: t, size: n, rotation: 0 }) : this._basicCornerExtraRounded({ x: e, y: t, size: n, rotation: Math.PI / 2 }) : this._basicCornerExtraRounded({ x: e, y: t, size: n, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: e, y: t, size: n, rotation: Math.PI / 2 });
|
|
880
880
|
}
|
|
881
881
|
}
|
|
882
|
-
const U = { dot: "dot", square: "square", extraRounded: "extra-rounded" },
|
|
883
|
-
class
|
|
882
|
+
const U = { dot: "dot", square: "square", extraRounded: "extra-rounded" }, Z = Object.values(U);
|
|
883
|
+
class V {
|
|
884
884
|
constructor({ svg: e, type: t, window: n }) {
|
|
885
885
|
this._svg = e, this._type = t, this._window = n;
|
|
886
886
|
}
|
|
@@ -931,14 +931,14 @@ function Tt() {
|
|
|
931
931
|
this._basicExtraRounded({ x: e, y: t, size: n, rotation: r });
|
|
932
932
|
}
|
|
933
933
|
}
|
|
934
|
-
const
|
|
934
|
+
const T = { dot: "dot", square: "square" }, P = Object.values(T);
|
|
935
935
|
class nt {
|
|
936
936
|
constructor({ svg: e, type: t, window: n }) {
|
|
937
937
|
this._svg = e, this._type = t, this._window = n;
|
|
938
938
|
}
|
|
939
939
|
draw(e, t, n, r) {
|
|
940
940
|
let i;
|
|
941
|
-
i = this._type ===
|
|
941
|
+
i = this._type === T.square ? this._drawSquare : this._drawDot, i.call(this, { x: e, y: t, size: n, rotation: r });
|
|
942
942
|
}
|
|
943
943
|
_rotateFigure({ x: e, y: t, size: n, rotation: r = 0, draw: i }) {
|
|
944
944
|
var a;
|
|
@@ -964,7 +964,7 @@ function Tt() {
|
|
|
964
964
|
this._basicSquare({ x: e, y: t, size: n, rotation: r });
|
|
965
965
|
}
|
|
966
966
|
}
|
|
967
|
-
const st = "circle",
|
|
967
|
+
const st = "circle", Y = [[1, 1, 1, 1, 1, 1, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 0, 0, 0, 0, 0, 1], [1, 1, 1, 1, 1, 1, 1]], G = [[0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 1, 1, 1, 0, 0], [0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0]];
|
|
968
968
|
class dt {
|
|
969
969
|
constructor(e, t) {
|
|
970
970
|
this._roundSize = (n) => this._options.dotsOptions.roundSize ? Math.floor(n) : n, this._window = t, this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._element.setAttribute("width", String(e.width)), this._element.setAttribute("height", String(e.height)), this._element.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), e.dotsOptions.roundSize || this._element.setAttribute("shape-rendering", "crispEdges"), this._element.setAttribute("viewBox", `0 0 ${e.width} ${e.height}`), this._defs = this._window.document.createElementNS("http://www.w3.org/2000/svg", "defs"), this._element.appendChild(this._defs), this._imageUri = e.image, this._instanceId = dt.instanceCount++, this._options = e;
|
|
@@ -984,16 +984,16 @@ function Tt() {
|
|
|
984
984
|
if (this._qr = e, this._options.image) {
|
|
985
985
|
if (await this.loadImage(), !this._image) return;
|
|
986
986
|
const { imageOptions: w, qrOptions: f } = this._options, _ = w.imageSize * F[f.errorCorrectionLevel], m = Math.floor(_ * t * t);
|
|
987
|
-
a = (function({ originalHeight: y, originalWidth: v, maxHiddenDots: C, maxHiddenAxisDots:
|
|
987
|
+
a = (function({ originalHeight: y, originalWidth: v, maxHiddenDots: C, maxHiddenAxisDots: B, dotSize: O }) {
|
|
988
988
|
const o = { x: 0, y: 0 }, h = { x: 0, y: 0 };
|
|
989
|
-
if (y <= 0 || v <= 0 || C <= 0 ||
|
|
989
|
+
if (y <= 0 || v <= 0 || C <= 0 || O <= 0) return { height: 0, width: 0, hideYDots: 0, hideXDots: 0 };
|
|
990
990
|
const s = y / v;
|
|
991
|
-
return o.x = Math.floor(Math.sqrt(C / s)), o.x <= 0 && (o.x = 1),
|
|
991
|
+
return o.x = Math.floor(Math.sqrt(C / s)), o.x <= 0 && (o.x = 1), B && B < o.x && (o.x = B), o.x % 2 == 0 && o.x--, h.x = o.x * O, o.y = 1 + 2 * Math.ceil((o.x * s - 1) / 2), h.y = Math.round(h.x * s), (o.y * o.x > C || B && B < o.y) && (B && B < o.y ? (o.y = B, o.y % 2 == 0 && o.x--) : o.y -= 2, h.y = o.y * O, o.x = 1 + 2 * Math.ceil((o.y / s - 1) / 2), h.x = Math.round(h.y / s)), { height: h.y, width: h.x, hideYDots: o.y, hideXDots: o.x };
|
|
992
992
|
})({ originalWidth: this._image.width, originalHeight: this._image.height, maxHiddenDots: m, maxHiddenAxisDots: t - 14, dotSize: i });
|
|
993
993
|
}
|
|
994
994
|
this.drawBackground(), this.drawDots(((w, f) => {
|
|
995
|
-
var _, m, y, v, C,
|
|
996
|
-
return !(this._options.imageOptions.hideBackgroundDots && w >= (t - a.hideYDots) / 2 && w < (t + a.hideYDots) / 2 && f >= (t - a.hideXDots) / 2 && f < (t + a.hideXDots) / 2 || !((_ =
|
|
995
|
+
var _, m, y, v, C, B;
|
|
996
|
+
return !(this._options.imageOptions.hideBackgroundDots && w >= (t - a.hideYDots) / 2 && w < (t + a.hideYDots) / 2 && f >= (t - a.hideXDots) / 2 && f < (t + a.hideXDots) / 2 || !((_ = Y[w]) === null || _ === void 0) && _[f] || !((m = Y[w - t + 7]) === null || m === void 0) && m[f] || !((y = Y[w]) === null || y === void 0) && y[f - t + 7] || !((v = G[w]) === null || v === void 0) && v[f] || !((C = G[w - t + 7]) === null || C === void 0) && C[f] || !((B = G[w]) === null || B === void 0) && B[f - t + 7]);
|
|
997
997
|
})), this.drawCorners(), this._options.image && await this.drawImage({ width: a.width, height: a.height, count: t, dotSize: i });
|
|
998
998
|
}
|
|
999
999
|
drawBackground() {
|
|
@@ -1013,18 +1013,18 @@ function Tt() {
|
|
|
1013
1013
|
if (!this._qr) throw "QR code is not defined";
|
|
1014
1014
|
const r = this._options, i = this._qr.getModuleCount();
|
|
1015
1015
|
if (i > r.width || i > r.height) throw "The canvas is too small.";
|
|
1016
|
-
const a = Math.min(r.width, r.height) - 2 * r.margin, w = r.shape === st ? a / Math.sqrt(2) : a, f = this._roundSize(w / i), _ = this._roundSize((r.width - i * f) / 2), m = this._roundSize((r.height - i * f) / 2), y = new
|
|
1016
|
+
const a = Math.min(r.width, r.height) - 2 * r.margin, w = r.shape === st ? a / Math.sqrt(2) : a, f = this._roundSize(w / i), _ = this._roundSize((r.width - i * f) / 2), m = this._roundSize((r.height - i * f) / 2), y = new N({ svg: this._element, type: r.dotsOptions.type, window: this._window });
|
|
1017
1017
|
this._dotsClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._dotsClipPath.setAttribute("id", `clip-path-dot-color-${this._instanceId}`), this._defs.appendChild(this._dotsClipPath), this._createColor({ options: (t = r.dotsOptions) === null || t === void 0 ? void 0 : t.gradient, color: r.dotsOptions.color, additionalRotation: 0, x: 0, y: 0, height: r.height, width: r.width, name: `dot-color-${this._instanceId}` });
|
|
1018
|
-
for (let v = 0; v < i; v++) for (let C = 0; C < i; C++) e && !e(v, C) || !((n = this._qr) === null || n === void 0) && n.isDark(v, C) && (y.draw(_ + C * f, m + v * f, f, ((
|
|
1018
|
+
for (let v = 0; v < i; v++) for (let C = 0; C < i; C++) e && !e(v, C) || !((n = this._qr) === null || n === void 0) && n.isDark(v, C) && (y.draw(_ + C * f, m + v * f, f, ((B, O) => !(C + B < 0 || v + O < 0 || C + B >= i || v + O >= i) && !(e && !e(v + O, C + B)) && !!this._qr && this._qr.isDark(v + O, C + B))), y._element && this._dotsClipPath && this._dotsClipPath.appendChild(y._element));
|
|
1019
1019
|
if (r.shape === st) {
|
|
1020
|
-
const v = this._roundSize((a / f - i) / 2), C = i + 2 * v,
|
|
1020
|
+
const v = this._roundSize((a / f - i) / 2), C = i + 2 * v, B = _ - v * f, O = m - v * f, o = [], h = this._roundSize(C / 2);
|
|
1021
1021
|
for (let s = 0; s < C; s++) {
|
|
1022
1022
|
o[s] = [];
|
|
1023
1023
|
for (let u = 0; u < C; u++) s >= v - 1 && s <= C - v && u >= v - 1 && u <= C - v || Math.sqrt((s - h) * (s - h) + (u - h) * (u - h)) > h ? o[s][u] = 0 : o[s][u] = this._qr.isDark(u - 2 * v < 0 ? u : u >= i ? u - 2 * v : u - v, s - 2 * v < 0 ? s : s >= i ? s - 2 * v : s - v) ? 1 : 0;
|
|
1024
1024
|
}
|
|
1025
|
-
for (let s = 0; s < C; s++) for (let u = 0; u < C; u++) o[s][u] && (y.draw(
|
|
1026
|
-
var
|
|
1027
|
-
return !!(!((
|
|
1025
|
+
for (let s = 0; s < C; s++) for (let u = 0; u < C; u++) o[s][u] && (y.draw(B + u * f, O + s * f, f, ((g, b) => {
|
|
1026
|
+
var $;
|
|
1027
|
+
return !!(!(($ = o[s + b]) === null || $ === void 0) && $[u + g]);
|
|
1028
1028
|
})), y._element && this._dotsClipPath && this._dotsClipPath.appendChild(y._element));
|
|
1029
1029
|
}
|
|
1030
1030
|
}
|
|
@@ -1034,28 +1034,28 @@ function Tt() {
|
|
|
1034
1034
|
if (!e) throw "Element code is not defined";
|
|
1035
1035
|
const n = this._qr.getModuleCount(), r = Math.min(t.width, t.height) - 2 * t.margin, i = t.shape === st ? r / Math.sqrt(2) : r, a = this._roundSize(i / n), w = 7 * a, f = 3 * a, _ = this._roundSize((t.width - n * a) / 2), m = this._roundSize((t.height - n * a) / 2);
|
|
1036
1036
|
[[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach((([y, v, C]) => {
|
|
1037
|
-
var
|
|
1038
|
-
const
|
|
1037
|
+
var B, O, o, h, s, u, g, b, $, I, q, L, H, tt;
|
|
1038
|
+
const X = _ + y * a * (n - 7), W = m + v * a * (n - 7);
|
|
1039
1039
|
let j = this._dotsClipPath, M = this._dotsClipPath;
|
|
1040
|
-
if ((!((
|
|
1041
|
-
const
|
|
1042
|
-
|
|
1040
|
+
if ((!((B = t.cornersSquareOptions) === null || B === void 0) && B.gradient || !((O = t.cornersSquareOptions) === null || O === void 0) && O.color) && (j = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), j.setAttribute("id", `clip-path-corners-square-color-${y}-${v}-${this._instanceId}`), this._defs.appendChild(j), this._cornersSquareClipPath = this._cornersDotClipPath = M = j, this._createColor({ options: (o = t.cornersSquareOptions) === null || o === void 0 ? void 0 : o.gradient, color: (h = t.cornersSquareOptions) === null || h === void 0 ? void 0 : h.color, additionalRotation: C, x: X, y: W, height: w, width: w, name: `corners-square-color-${y}-${v}-${this._instanceId}` })), ((s = t.cornersSquareOptions) === null || s === void 0 ? void 0 : s.type) && Z.includes(t.cornersSquareOptions.type)) {
|
|
1041
|
+
const K = new V({ svg: this._element, type: t.cornersSquareOptions.type, window: this._window });
|
|
1042
|
+
K.draw(X, W, w, C), K._element && j && j.appendChild(K._element);
|
|
1043
1043
|
} else {
|
|
1044
|
-
const
|
|
1045
|
-
for (let
|
|
1044
|
+
const K = new N({ svg: this._element, type: ((u = t.cornersSquareOptions) === null || u === void 0 ? void 0 : u.type) || t.dotsOptions.type, window: this._window });
|
|
1045
|
+
for (let J = 0; J < Y.length; J++) for (let E = 0; E < Y[J].length; E++) !((g = Y[J]) === null || g === void 0) && g[E] && (K.draw(X + E * a, W + J * a, a, ((ot, rt) => {
|
|
1046
1046
|
var et;
|
|
1047
|
-
return !!(!((et =
|
|
1048
|
-
})),
|
|
1047
|
+
return !!(!((et = Y[J + rt]) === null || et === void 0) && et[E + ot]);
|
|
1048
|
+
})), K._element && j && j.appendChild(K._element));
|
|
1049
1049
|
}
|
|
1050
|
-
if ((!((b = t.cornersDotOptions) === null || b === void 0) && b.gradient || !((
|
|
1051
|
-
const
|
|
1052
|
-
|
|
1050
|
+
if ((!((b = t.cornersDotOptions) === null || b === void 0) && b.gradient || !(($ = t.cornersDotOptions) === null || $ === void 0) && $.color) && (M = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), M.setAttribute("id", `clip-path-corners-dot-color-${y}-${v}-${this._instanceId}`), this._defs.appendChild(M), this._cornersDotClipPath = M, this._createColor({ options: (I = t.cornersDotOptions) === null || I === void 0 ? void 0 : I.gradient, color: (q = t.cornersDotOptions) === null || q === void 0 ? void 0 : q.color, additionalRotation: C, x: X + 2 * a, y: W + 2 * a, height: f, width: f, name: `corners-dot-color-${y}-${v}-${this._instanceId}` })), ((L = t.cornersDotOptions) === null || L === void 0 ? void 0 : L.type) && P.includes(t.cornersDotOptions.type)) {
|
|
1051
|
+
const K = new nt({ svg: this._element, type: t.cornersDotOptions.type, window: this._window });
|
|
1052
|
+
K.draw(X + 2 * a, W + 2 * a, f, C), K._element && M && M.appendChild(K._element);
|
|
1053
1053
|
} else {
|
|
1054
|
-
const
|
|
1055
|
-
for (let
|
|
1054
|
+
const K = new N({ svg: this._element, type: ((H = t.cornersDotOptions) === null || H === void 0 ? void 0 : H.type) || t.dotsOptions.type, window: this._window });
|
|
1055
|
+
for (let J = 0; J < G.length; J++) for (let E = 0; E < G[J].length; E++) !((tt = G[J]) === null || tt === void 0) && tt[E] && (K.draw(X + E * a, W + J * a, a, ((ot, rt) => {
|
|
1056
1056
|
var et;
|
|
1057
|
-
return !!(!((et = J
|
|
1058
|
-
})),
|
|
1057
|
+
return !!(!((et = G[J + rt]) === null || et === void 0) && et[E + ot]);
|
|
1058
|
+
})), K._element && M && M.appendChild(K._element));
|
|
1059
1059
|
}
|
|
1060
1060
|
}));
|
|
1061
1061
|
}
|
|
@@ -1101,12 +1101,12 @@ function Tt() {
|
|
|
1101
1101
|
if (e.type === "radial") y = this._window.document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"), y.setAttribute("id", f), y.setAttribute("gradientUnits", "userSpaceOnUse"), y.setAttribute("fx", String(r + w / 2)), y.setAttribute("fy", String(i + a / 2)), y.setAttribute("cx", String(r + w / 2)), y.setAttribute("cy", String(i + a / 2)), y.setAttribute("r", String(_ / 2));
|
|
1102
1102
|
else {
|
|
1103
1103
|
const v = ((e.rotation || 0) + n) % (2 * Math.PI), C = (v + 2 * Math.PI) % (2 * Math.PI);
|
|
1104
|
-
let
|
|
1105
|
-
C >= 0 && C <= 0.25 * Math.PI || C > 1.75 * Math.PI && C <= 2 * Math.PI ? (
|
|
1104
|
+
let B = r + w / 2, O = i + a / 2, o = r + w / 2, h = i + a / 2;
|
|
1105
|
+
C >= 0 && C <= 0.25 * Math.PI || C > 1.75 * Math.PI && C <= 2 * Math.PI ? (B -= w / 2, O -= a / 2 * Math.tan(v), o += w / 2, h += a / 2 * Math.tan(v)) : C > 0.25 * Math.PI && C <= 0.75 * Math.PI ? (O -= a / 2, B -= w / 2 / Math.tan(v), h += a / 2, o += w / 2 / Math.tan(v)) : C > 0.75 * Math.PI && C <= 1.25 * Math.PI ? (B += w / 2, O += a / 2 * Math.tan(v), o -= w / 2, h -= a / 2 * Math.tan(v)) : C > 1.25 * Math.PI && C <= 1.75 * Math.PI && (O += a / 2, B += w / 2 / Math.tan(v), h -= a / 2, o -= w / 2 / Math.tan(v)), y = this._window.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"), y.setAttribute("id", f), y.setAttribute("gradientUnits", "userSpaceOnUse"), y.setAttribute("x1", String(Math.round(B))), y.setAttribute("y1", String(Math.round(O))), y.setAttribute("x2", String(Math.round(o))), y.setAttribute("y2", String(Math.round(h)));
|
|
1106
1106
|
}
|
|
1107
1107
|
e.colorStops.forEach((({ offset: v, color: C }) => {
|
|
1108
|
-
const
|
|
1109
|
-
|
|
1108
|
+
const B = this._window.document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
1109
|
+
B.setAttribute("offset", 100 * v + "%"), B.setAttribute("stop-color", C), y.appendChild(B);
|
|
1110
1110
|
})), m.setAttribute("fill", `url('#${f}')`), this._defs.appendChild(y);
|
|
1111
1111
|
} else t && m.setAttribute("fill", t);
|
|
1112
1112
|
this._element.appendChild(m);
|
|
@@ -1125,7 +1125,7 @@ function Tt() {
|
|
|
1125
1125
|
const e = Object.assign({}, d);
|
|
1126
1126
|
return e.width = Number(e.width), e.height = Number(e.height), e.margin = Number(e.margin), e.imageOptions = Object.assign(Object.assign({}, e.imageOptions), { hideBackgroundDots: !!e.imageOptions.hideBackgroundDots, imageSize: Number(e.imageOptions.imageSize), margin: Number(e.imageOptions.margin) }), e.margin > Math.min(e.width, e.height) && (e.margin = Math.min(e.width, e.height)), e.dotsOptions = Object.assign({}, e.dotsOptions), e.dotsOptions.gradient && (e.dotsOptions.gradient = ct(e.dotsOptions.gradient)), e.cornersSquareOptions && (e.cornersSquareOptions = Object.assign({}, e.cornersSquareOptions), e.cornersSquareOptions.gradient && (e.cornersSquareOptions.gradient = ct(e.cornersSquareOptions.gradient))), e.cornersDotOptions && (e.cornersDotOptions = Object.assign({}, e.cornersDotOptions), e.cornersDotOptions.gradient && (e.cornersDotOptions.gradient = ct(e.cornersDotOptions.gradient))), e.backgroundOptions && (e.backgroundOptions = Object.assign({}, e.backgroundOptions), e.backgroundOptions.gradient && (e.backgroundOptions.gradient = ct(e.backgroundOptions.gradient))), e;
|
|
1127
1127
|
}
|
|
1128
|
-
var _t =
|
|
1128
|
+
var _t = k(873), Ct = k.n(_t);
|
|
1129
1129
|
function lt(d) {
|
|
1130
1130
|
if (!d) throw new Error("Extension must be defined");
|
|
1131
1131
|
d[0] === "." && (d = d.substring(1));
|
|
@@ -1227,8 +1227,8 @@ ${new this._window.XMLSerializer().serializeToString(t)}`;
|
|
|
1227
1227
|
if (r) if (t.toLowerCase() === "svg") {
|
|
1228
1228
|
let i = new XMLSerializer().serializeToString(r);
|
|
1229
1229
|
i = `<?xml version="1.0" standalone="no"?>\r
|
|
1230
|
-
` + i,
|
|
1231
|
-
} else
|
|
1230
|
+
` + i, D(`data:${lt(t)};charset=utf-8,${encodeURIComponent(i)}`, `${n}.svg`);
|
|
1231
|
+
} else D(r.toDataURL(lt(t)), `${n}.${t}`);
|
|
1232
1232
|
}
|
|
1233
1233
|
}
|
|
1234
1234
|
const l = p;
|
|
@@ -1236,48 +1236,48 @@ ${new this._window.XMLSerializer().serializeToString(t)}`;
|
|
|
1236
1236
|
})()));
|
|
1237
1237
|
})(xt)), xt.exports;
|
|
1238
1238
|
}
|
|
1239
|
-
var jt =
|
|
1240
|
-
const Ft = /* @__PURE__ */
|
|
1239
|
+
var jt = Lt();
|
|
1240
|
+
const Ft = /* @__PURE__ */ Tt(jt), Ut = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4BAMAAABaqCYtAAAAMFBMVEUKfmT+//8Bd1tSpJAginI7l4OgzcNxl0BjrZyQxbl6uas6ilTr9fOz18/R5+KbojH3wCiYAAAACXBIWXMAAAsTAAALEwEAmpwYAAABYklEQVR42mNgGKZACY+UggsTTqmIaWkZOGQjpmWZMHilKjCwBmHIuWWZKCkwKIVNUVJdhC7HNAMoBTLcdmnnBQydE0AyQAUKna2TFdB1TlVQUnBdZQQ0WSkSQzI2JGJazuJpDkA2pwO6sapps0yslJRTgEwtIwwXKSgpdSiAvak6CZtX3SBBoDQFm6TyVQVQSAU/VsAiyQQMAmAgZnVik+QusF0xbVaIkhY2Y+u3K3SFKClgDXrucu4CHFJAye8bCnBGNnt1QTVOye3/8Uiy19fjMXb79g04Jbm/45ZkUir/jlPONTTYBEg7YJNkEwSCJgaWd9g0JoIkLzHoCmKmTAYtkJxgEtNCLJIuNkCpM2eMlAVlMeRUzwDl5FwclHwEj2AEvTLITKAelouCRgxYJQXPvXsjKKmAQxIELjDglpRxwiMprIBHchEDbklZrMFubGxs0dHRYYC9RIAABYZRQAoAAMPFUF7XIspMAAAAAElFTkSuQmCC";
|
|
1241
1241
|
function ht(c, A) {
|
|
1242
|
-
Object.entries(A).forEach(([z,
|
|
1243
|
-
c.style[z] =
|
|
1242
|
+
Object.entries(A).forEach(([z, R]) => {
|
|
1243
|
+
c.style[z] = R;
|
|
1244
1244
|
});
|
|
1245
1245
|
}
|
|
1246
|
-
function
|
|
1246
|
+
function $t(c) {
|
|
1247
1247
|
if (c.startsWith("#"))
|
|
1248
1248
|
return c;
|
|
1249
1249
|
if (c.startsWith("rgb")) {
|
|
1250
1250
|
const A = c.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
|
|
1251
1251
|
if (A) {
|
|
1252
|
-
const z = parseInt(A[1]).toString(16).padStart(2, "0"),
|
|
1253
|
-
return `#${z}${
|
|
1252
|
+
const z = parseInt(A[1]).toString(16).padStart(2, "0"), R = parseInt(A[2]).toString(16).padStart(2, "0"), k = parseInt(A[3]).toString(16).padStart(2, "0");
|
|
1253
|
+
return `#${z}${R}${k}`;
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
1256
|
if (c.startsWith("hsl")) {
|
|
1257
1257
|
const A = c.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%/);
|
|
1258
1258
|
if (A) {
|
|
1259
|
-
const z = parseInt(A[1]) / 360,
|
|
1259
|
+
const z = parseInt(A[1]) / 360, R = parseInt(A[2]) / 100, k = parseInt(A[3]) / 100;
|
|
1260
1260
|
let Q, S, x;
|
|
1261
|
-
if (
|
|
1262
|
-
Q = S = x =
|
|
1261
|
+
if (R === 0)
|
|
1262
|
+
Q = S = x = k;
|
|
1263
1263
|
else {
|
|
1264
|
-
const F = (
|
|
1265
|
-
Q = F(U,
|
|
1264
|
+
const F = (Z, V, T) => (T < 0 && (T += 1), T > 1 && (T -= 1), T < 0.16666666666666666 ? Z + (V - Z) * 6 * T : T < 0.5 ? V : T < 0.6666666666666666 ? Z + (V - Z) * (0.6666666666666666 - T) * 6 : Z), N = k < 0.5 ? k * (1 + R) : k + R - k * R, U = 2 * k - N;
|
|
1265
|
+
Q = F(U, N, z + 1 / 3), S = F(U, N, z), x = F(U, N, z - 1 / 3);
|
|
1266
1266
|
}
|
|
1267
|
-
const
|
|
1268
|
-
return `#${
|
|
1267
|
+
const D = (F) => Math.round(F * 255).toString(16).padStart(2, "0");
|
|
1268
|
+
return `#${D(Q)}${D(S)}${D(x)}`;
|
|
1269
1269
|
}
|
|
1270
1270
|
}
|
|
1271
1271
|
return c;
|
|
1272
1272
|
}
|
|
1273
1273
|
function Qt(c, A, z) {
|
|
1274
|
-
const
|
|
1275
|
-
|
|
1274
|
+
const R = document.createElement("div");
|
|
1275
|
+
R.className = "drop-payment-link", ht(R, {
|
|
1276
1276
|
marginTop: "16px",
|
|
1277
1277
|
width: `${A}px`
|
|
1278
1278
|
});
|
|
1279
|
-
const
|
|
1280
|
-
|
|
1279
|
+
const k = document.createElement("label");
|
|
1280
|
+
k.className = "drop-link-label", k.textContent = z, ht(k, {
|
|
1281
1281
|
display: "block",
|
|
1282
1282
|
fontSize: "14px",
|
|
1283
1283
|
fontWeight: "500",
|
|
@@ -1299,7 +1299,7 @@ function Qt(c, A, z) {
|
|
|
1299
1299
|
marginBottom: "0",
|
|
1300
1300
|
fontFamily: "system-ui, -apple-system, sans-serif"
|
|
1301
1301
|
});
|
|
1302
|
-
const
|
|
1302
|
+
const D = async () => {
|
|
1303
1303
|
S.select();
|
|
1304
1304
|
try {
|
|
1305
1305
|
navigator.clipboard && navigator.clipboard.writeText ? (await navigator.clipboard.writeText(c), F()) : document.execCommand("copy") && F();
|
|
@@ -1307,19 +1307,19 @@ function Qt(c, A, z) {
|
|
|
1307
1307
|
document.execCommand("copy"), F();
|
|
1308
1308
|
}
|
|
1309
1309
|
}, F = () => {
|
|
1310
|
-
const
|
|
1310
|
+
const N = x.textContent;
|
|
1311
1311
|
x.textContent = "✓ Copied to clipboard!", ht(x, {
|
|
1312
1312
|
color: "hsl(160, 65%, 35%)",
|
|
1313
1313
|
fontWeight: "500"
|
|
1314
1314
|
}), setTimeout(() => {
|
|
1315
|
-
x.textContent =
|
|
1315
|
+
x.textContent = N, ht(x, {
|
|
1316
1316
|
color: "hsl(160, 30%, 40%)",
|
|
1317
1317
|
fontWeight: "normal"
|
|
1318
1318
|
});
|
|
1319
1319
|
}, 2e3);
|
|
1320
1320
|
};
|
|
1321
|
-
return S.addEventListener("click",
|
|
1322
|
-
(
|
|
1321
|
+
return S.addEventListener("click", D), S.addEventListener("keydown", (N) => {
|
|
1322
|
+
(N.key === "Enter" || N.key === " ") && (N.preventDefault(), D());
|
|
1323
1323
|
}), ht(S, {
|
|
1324
1324
|
width: "100%",
|
|
1325
1325
|
padding: "12px",
|
|
@@ -1342,16 +1342,16 @@ function Qt(c, A, z) {
|
|
|
1342
1342
|
borderColor: "hsl(160, 65%, 25%)",
|
|
1343
1343
|
backgroundColor: "hsl(0, 0%, 98%)"
|
|
1344
1344
|
});
|
|
1345
|
-
}), Q.appendChild(S),
|
|
1345
|
+
}), Q.appendChild(S), R.appendChild(k), R.appendChild(Q), R.appendChild(x), R;
|
|
1346
1346
|
}
|
|
1347
|
-
async function Ht(c, A, z,
|
|
1347
|
+
async function Ht(c, A, z, R = {}) {
|
|
1348
1348
|
const {
|
|
1349
|
-
moduleColor:
|
|
1349
|
+
moduleColor: k = "hsl(160, 65%, 25%)",
|
|
1350
1350
|
backgroundColor: Q = "hsl(0, 0%, 98%)",
|
|
1351
1351
|
cornerRadius: S = 0,
|
|
1352
1352
|
showCopyableLink: x = !0,
|
|
1353
|
-
linkText:
|
|
1354
|
-
} =
|
|
1353
|
+
linkText: D = "Or paste this link:"
|
|
1354
|
+
} = R, F = $t(k), N = $t(Q), U = Math.sqrt(0.18), Z = Math.round(z * 0.03), V = new Ft({
|
|
1355
1355
|
width: z,
|
|
1356
1356
|
height: z,
|
|
1357
1357
|
type: "svg",
|
|
@@ -1365,31 +1365,31 @@ async function Ht(c, A, z, D = {}) {
|
|
|
1365
1365
|
type: S > 0 ? "rounded" : "square"
|
|
1366
1366
|
},
|
|
1367
1367
|
backgroundOptions: {
|
|
1368
|
-
color:
|
|
1368
|
+
color: N
|
|
1369
1369
|
},
|
|
1370
1370
|
imageOptions: {
|
|
1371
1371
|
hideBackgroundDots: !0,
|
|
1372
1372
|
imageSize: U,
|
|
1373
|
-
margin:
|
|
1373
|
+
margin: Z
|
|
1374
1374
|
}
|
|
1375
|
-
}),
|
|
1376
|
-
|
|
1377
|
-
const
|
|
1378
|
-
if (
|
|
1379
|
-
const nt = Qt(A, z,
|
|
1380
|
-
|
|
1375
|
+
}), T = document.createElement("div");
|
|
1376
|
+
T.className = "drop-payment-widget", V.append(T);
|
|
1377
|
+
const P = T.querySelector("svg");
|
|
1378
|
+
if (P && (P.setAttribute("role", "img"), P.setAttribute("aria-label", "Payment QR Code")), x) {
|
|
1379
|
+
const nt = Qt(A, z, D);
|
|
1380
|
+
T.appendChild(nt);
|
|
1381
1381
|
}
|
|
1382
|
-
c.innerHTML = "", c.appendChild(
|
|
1382
|
+
c.innerHTML = "", c.appendChild(T);
|
|
1383
1383
|
}
|
|
1384
1384
|
class it extends Error {
|
|
1385
1385
|
constructor(A) {
|
|
1386
1386
|
super(A), this.name = "ValidationError";
|
|
1387
1387
|
}
|
|
1388
1388
|
}
|
|
1389
|
-
function
|
|
1390
|
-
|
|
1389
|
+
function Wt(c) {
|
|
1390
|
+
Kt(c.clientSecret), c.qrSize !== void 0 && Xt(c.qrSize), c.pollingInterval !== void 0 && Vt(c.pollingInterval), c.qrOptions && Yt(c.qrOptions), c.linkText !== void 0 && Jt(c.linkText), Zt(c);
|
|
1391
1391
|
}
|
|
1392
|
-
function
|
|
1392
|
+
function Kt(c) {
|
|
1393
1393
|
if (!c || c.trim() === "")
|
|
1394
1394
|
throw new it("clientSecret is required and cannot be empty");
|
|
1395
1395
|
if (c.length < 10)
|
|
@@ -1401,7 +1401,7 @@ function Yt(c) {
|
|
|
1401
1401
|
"clientSecret must start with 'pi_secret_'. Received: " + c.substring(0, 10) + "..."
|
|
1402
1402
|
);
|
|
1403
1403
|
}
|
|
1404
|
-
function
|
|
1404
|
+
function Xt(c) {
|
|
1405
1405
|
if (typeof c != "number" || isNaN(c) || !isFinite(c))
|
|
1406
1406
|
throw new it(`qrSize must be a valid number. Received: ${c}`);
|
|
1407
1407
|
if (c < 128 || c > 1024)
|
|
@@ -1409,7 +1409,7 @@ function Wt(c) {
|
|
|
1409
1409
|
`QR size must be between 128 and 1024 pixels. Received: ${c}`
|
|
1410
1410
|
);
|
|
1411
1411
|
}
|
|
1412
|
-
function
|
|
1412
|
+
function Vt(c) {
|
|
1413
1413
|
if (typeof c != "number" || isNaN(c) || !isFinite(c))
|
|
1414
1414
|
throw new it(`pollingInterval must be a valid number. Received: ${c}`);
|
|
1415
1415
|
if (c < 1e3 || c > 6e4)
|
|
@@ -1417,10 +1417,10 @@ function Kt(c) {
|
|
|
1417
1417
|
`pollingInterval must be between 1000 and 60000 milliseconds. Received: ${c}`
|
|
1418
1418
|
);
|
|
1419
1419
|
}
|
|
1420
|
-
function
|
|
1421
|
-
c && (c.cornerRadius !== void 0 &&
|
|
1420
|
+
function Yt(c) {
|
|
1421
|
+
c && (c.cornerRadius !== void 0 && Gt(c.cornerRadius), c.moduleColor !== void 0 && Et(c.moduleColor, "moduleColor"), c.backgroundColor !== void 0 && Et(c.backgroundColor, "backgroundColor"));
|
|
1422
1422
|
}
|
|
1423
|
-
function
|
|
1423
|
+
function Gt(c) {
|
|
1424
1424
|
if (typeof c != "number" || isNaN(c) || !isFinite(c))
|
|
1425
1425
|
throw new it(`cornerRadius must be a valid number. Received: ${c}`);
|
|
1426
1426
|
if (c < 0 || c > 1)
|
|
@@ -1428,37 +1428,37 @@ function Jt(c) {
|
|
|
1428
1428
|
`cornerRadius must be between 0 and 1. Received: ${c}`
|
|
1429
1429
|
);
|
|
1430
1430
|
}
|
|
1431
|
-
function
|
|
1431
|
+
function Et(c, A) {
|
|
1432
1432
|
if (typeof c != "string")
|
|
1433
1433
|
throw new it(`${A} must be a string. Received: ${typeof c}`);
|
|
1434
|
-
const z = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/,
|
|
1434
|
+
const z = /^#([0-9A-Fa-f]{3}|[0-9A-Fa-f]{6})$/, R = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/, k = /^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0|1|0?\.\d+)\s*\)$/, Q = /^hsl\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*\)$/, S = /^hsla\(\s*(\d{1,3})\s*,\s*(\d{1,3})%\s*,\s*(\d{1,3})%\s*,\s*(0|1|0?\.\d+)\s*\)$/;
|
|
1435
1435
|
let x = z.test(c);
|
|
1436
1436
|
if (!x) {
|
|
1437
|
-
const
|
|
1438
|
-
if (
|
|
1439
|
-
const [, F,
|
|
1440
|
-
x = parseInt(F) <= 255 && parseInt(
|
|
1437
|
+
const D = c.match(R);
|
|
1438
|
+
if (D) {
|
|
1439
|
+
const [, F, N, U] = D;
|
|
1440
|
+
x = parseInt(F) <= 255 && parseInt(N) <= 255 && parseInt(U) <= 255;
|
|
1441
1441
|
}
|
|
1442
1442
|
}
|
|
1443
1443
|
if (!x) {
|
|
1444
|
-
const
|
|
1445
|
-
if (
|
|
1446
|
-
const [, F,
|
|
1447
|
-
x = parseInt(F) <= 255 && parseInt(
|
|
1444
|
+
const D = c.match(k);
|
|
1445
|
+
if (D) {
|
|
1446
|
+
const [, F, N, U] = D;
|
|
1447
|
+
x = parseInt(F) <= 255 && parseInt(N) <= 255 && parseInt(U) <= 255;
|
|
1448
1448
|
}
|
|
1449
1449
|
}
|
|
1450
1450
|
if (!x) {
|
|
1451
|
-
const
|
|
1452
|
-
if (
|
|
1453
|
-
const [, F,
|
|
1454
|
-
x = parseInt(F) <= 360 && parseInt(
|
|
1451
|
+
const D = c.match(Q);
|
|
1452
|
+
if (D) {
|
|
1453
|
+
const [, F, N, U] = D;
|
|
1454
|
+
x = parseInt(F) <= 360 && parseInt(N) <= 100 && parseInt(U) <= 100;
|
|
1455
1455
|
}
|
|
1456
1456
|
}
|
|
1457
1457
|
if (!x) {
|
|
1458
|
-
const
|
|
1459
|
-
if (
|
|
1460
|
-
const [, F,
|
|
1461
|
-
x = parseInt(F) <= 360 && parseInt(
|
|
1458
|
+
const D = c.match(S);
|
|
1459
|
+
if (D) {
|
|
1460
|
+
const [, F, N, U] = D;
|
|
1461
|
+
x = parseInt(F) <= 360 && parseInt(N) <= 100 && parseInt(U) <= 100;
|
|
1462
1462
|
}
|
|
1463
1463
|
}
|
|
1464
1464
|
if (!x)
|
|
@@ -1466,7 +1466,7 @@ function kt(c, A) {
|
|
|
1466
1466
|
`${A} must be a valid color format (hex, rgb, rgba, hsl, or hsla). Received: ${c}`
|
|
1467
1467
|
);
|
|
1468
1468
|
}
|
|
1469
|
-
function
|
|
1469
|
+
function Jt(c) {
|
|
1470
1470
|
if (typeof c != "string")
|
|
1471
1471
|
throw new it(`linkText must be a string. Received: ${typeof c}`);
|
|
1472
1472
|
if (c.length > 100)
|
|
@@ -1474,7 +1474,7 @@ function Zt(c) {
|
|
|
1474
1474
|
`linkText must be 100 characters or less. Received length: ${c.length}`
|
|
1475
1475
|
);
|
|
1476
1476
|
}
|
|
1477
|
-
function
|
|
1477
|
+
function Zt(c) {
|
|
1478
1478
|
if (c.onStatusChange !== void 0 && typeof c.onStatusChange != "function")
|
|
1479
1479
|
throw new it(
|
|
1480
1480
|
`onStatusChange must be a function if provided. Received: ${typeof c.onStatusChange}`
|
|
@@ -1488,69 +1488,85 @@ function Gt(c) {
|
|
|
1488
1488
|
`onPoll must be a function if provided. Received: ${typeof c.onPoll}`
|
|
1489
1489
|
);
|
|
1490
1490
|
}
|
|
1491
|
-
const
|
|
1491
|
+
const ie = {
|
|
1492
|
+
INITIATED: "initiated",
|
|
1493
|
+
PENDING: "pending",
|
|
1494
|
+
SUCCEEDED: "succeeded",
|
|
1495
|
+
FAILED: "failed",
|
|
1496
|
+
CANCELLED: "cancelled",
|
|
1497
|
+
EXPIRED: "expired"
|
|
1498
|
+
}, ne = {
|
|
1499
|
+
NETWORK_ERROR: "NETWORK_ERROR",
|
|
1500
|
+
AUTH_ERROR: "AUTH_ERROR",
|
|
1501
|
+
RATE_LIMITED: "RATE_LIMITED",
|
|
1502
|
+
NOT_FOUND: "NOT_FOUND",
|
|
1503
|
+
VALIDATION_ERROR: "VALIDATION_ERROR",
|
|
1504
|
+
UNKNOWN: "UNKNOWN"
|
|
1505
|
+
}, te = 256;
|
|
1492
1506
|
function ee(c) {
|
|
1493
|
-
const A = c.split("?")[0].split("#")[0], z = c.includes("?") ? c.substring(c.indexOf("?")) : "",
|
|
1494
|
-
if (!
|
|
1507
|
+
const A = c.split("?")[0].split("#")[0], z = c.includes("?") ? c.substring(c.indexOf("?")) : "", R = /\/payment-accounts\/([^/]+)\/payment-intents\/([^/]+)/, k = A.match(R);
|
|
1508
|
+
if (!k)
|
|
1495
1509
|
throw new Error(
|
|
1496
1510
|
"Invalid instanceUrl format. Expected: .../payment-accounts/{id}/payment-intents/{id}"
|
|
1497
1511
|
);
|
|
1498
|
-
const Q =
|
|
1512
|
+
const Q = k[1], S = k[2], x = A.substring(
|
|
1499
1513
|
0,
|
|
1500
1514
|
A.indexOf("/payment-accounts/")
|
|
1501
1515
|
);
|
|
1502
1516
|
return { paymentAccountId: Q, paymentIntentId: S, apiBaseUrl: x, queryString: z };
|
|
1503
1517
|
}
|
|
1504
|
-
const
|
|
1518
|
+
const re = {
|
|
1505
1519
|
async create(c) {
|
|
1506
|
-
|
|
1520
|
+
Wt(c);
|
|
1507
1521
|
const {
|
|
1508
1522
|
clientSecret: A,
|
|
1509
1523
|
instanceUrl: z,
|
|
1510
|
-
containerId:
|
|
1511
|
-
qrSize:
|
|
1524
|
+
containerId: R,
|
|
1525
|
+
qrSize: k = te,
|
|
1512
1526
|
pollingInterval: Q,
|
|
1513
1527
|
onStatusChange: S,
|
|
1514
1528
|
onError: x,
|
|
1515
|
-
onPoll:
|
|
1516
|
-
} = c, F = document.getElementById(
|
|
1529
|
+
onPoll: D
|
|
1530
|
+
} = c, F = document.getElementById(R);
|
|
1517
1531
|
if (!F)
|
|
1518
|
-
throw new Error(`Element with id "${
|
|
1519
|
-
const { paymentAccountId:
|
|
1520
|
-
await Ht(F, z,
|
|
1521
|
-
...
|
|
1532
|
+
throw new Error(`Element with id "${R}" not found.`);
|
|
1533
|
+
const { paymentAccountId: N, paymentIntentId: U, apiBaseUrl: Z, queryString: V } = ee(z), T = c.apiBaseUrl || Z, { qrOptions: P, showCopyableLink: nt, linkText: st } = c;
|
|
1534
|
+
await Ht(F, z, k, {
|
|
1535
|
+
...P,
|
|
1522
1536
|
showCopyableLink: nt,
|
|
1523
1537
|
linkText: st
|
|
1524
1538
|
});
|
|
1525
|
-
const
|
|
1526
|
-
apiBaseUrl:
|
|
1527
|
-
paymentAccountId:
|
|
1539
|
+
const Y = new Nt({
|
|
1540
|
+
apiBaseUrl: T,
|
|
1541
|
+
paymentAccountId: N,
|
|
1528
1542
|
paymentIntentId: U,
|
|
1529
1543
|
clientSecret: A,
|
|
1530
|
-
queryString:
|
|
1544
|
+
queryString: V,
|
|
1531
1545
|
pollingInterval: Q,
|
|
1532
|
-
onStatusChange: (
|
|
1533
|
-
S == null || S(
|
|
1546
|
+
onStatusChange: (G) => {
|
|
1547
|
+
S == null || S(G);
|
|
1534
1548
|
},
|
|
1535
|
-
onError: (
|
|
1536
|
-
x == null || x(
|
|
1549
|
+
onError: (G) => {
|
|
1550
|
+
x == null || x(G);
|
|
1537
1551
|
},
|
|
1538
1552
|
onPoll: () => {
|
|
1539
|
-
|
|
1553
|
+
D == null || D();
|
|
1540
1554
|
}
|
|
1541
1555
|
});
|
|
1542
|
-
return
|
|
1556
|
+
return Y.start(), {
|
|
1543
1557
|
destroy() {
|
|
1544
|
-
|
|
1558
|
+
Y.stop(), F.innerHTML = "";
|
|
1545
1559
|
},
|
|
1546
1560
|
getStatus() {
|
|
1547
|
-
return
|
|
1561
|
+
return Y.getStatus();
|
|
1548
1562
|
}
|
|
1549
1563
|
};
|
|
1550
1564
|
}
|
|
1551
1565
|
};
|
|
1552
1566
|
export {
|
|
1553
|
-
|
|
1567
|
+
re as Drop,
|
|
1568
|
+
ne as ErrorCodes,
|
|
1569
|
+
ie as PaymentStatuses,
|
|
1554
1570
|
it as ValidationError,
|
|
1555
1571
|
Ht as renderQR
|
|
1556
1572
|
};
|