@drop-africa/drop-js 0.1.1

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/drop.js ADDED
@@ -0,0 +1,1557 @@
1
+ const It = {
2
+ PaymentInitiated: "initiated",
3
+ PaymentPending: "pending",
4
+ PaymentSucceeded: "succeeded",
5
+ PaymentFailed: "failed",
6
+ PaymentCancelled: "cancelled",
7
+ PaymentExpired: "expired"
8
+ }, Et = /* @__PURE__ */ new Set([
9
+ "succeeded",
10
+ "failed",
11
+ "cancelled",
12
+ "expired"
13
+ ]);
14
+ function Bt(c) {
15
+ return It[c] ?? null;
16
+ }
17
+ function Dt(c) {
18
+ return Et.has(c);
19
+ }
20
+ function pt(c, A, z) {
21
+ return { code: c, message: A, retryable: z };
22
+ }
23
+ function bt(c, A) {
24
+ switch (c) {
25
+ case 401:
26
+ return pt("AUTH_ERROR", A ?? "Invalid client secret.", !1);
27
+ case 404:
28
+ return pt("NOT_FOUND", A ?? "Payment intent not found.", !1);
29
+ case 429:
30
+ return pt("RATE_LIMITED", A ?? "Rate limited. Retrying.", !0);
31
+ default:
32
+ return pt("UNKNOWN", A ?? `Unexpected status: ${c}`, !0);
33
+ }
34
+ }
35
+ function St(c) {
36
+ return pt("NETWORK_ERROR", c, !0);
37
+ }
38
+ const At = 3e3, Pt = 1.5, Rt = 3e4, Mt = 5, zt = 3e4;
39
+ class qt {
40
+ constructor(A) {
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
+ }
43
+ start() {
44
+ this.poll();
45
+ }
46
+ stop() {
47
+ this.destroyed = !0, this.timer !== null && (clearTimeout(this.timer), this.timer = null);
48
+ }
49
+ getStatus() {
50
+ return this.currentStatus;
51
+ }
52
+ async poll() {
53
+ var A, z;
54
+ if (!this.destroyed) {
55
+ if ((z = (A = this.config).onPoll) == null || z.call(A), this.isExpired()) {
56
+ this.emitStatus("expired");
57
+ return;
58
+ }
59
+ try {
60
+ const D = await this.fetchStatus();
61
+ if (D.ok) {
62
+ this.consecutiveFailures = 0, this.interval = At;
63
+ const E = await D.json();
64
+ this.expiresAt = new Date(E.expiresAt);
65
+ const Q = Bt(E.status);
66
+ if (Q && Q !== this.currentStatus && (this.emitStatus(Q), Dt(Q)))
67
+ return;
68
+ } else if (D.status === 429) {
69
+ const E = D.headers.get("Retry-After");
70
+ if (E) {
71
+ const Q = parseInt(E, 10);
72
+ isNaN(Q) || (this.interval = Q * 1e3);
73
+ } else
74
+ this.applyBackoff();
75
+ this.config.onError(bt(429));
76
+ } else if (D.status === 401 || D.status === 404) {
77
+ this.config.onError(bt(D.status));
78
+ return;
79
+ } else if (this.consecutiveFailures++, this.applyBackoff(), this.config.onError(bt(D.status)), this.consecutiveFailures >= Mt) {
80
+ this.config.onError(
81
+ bt(D.status, "Max consecutive failures reached. Stopping.")
82
+ );
83
+ return;
84
+ }
85
+ } catch {
86
+ if (this.consecutiveFailures++, this.applyBackoff(), this.config.onError(St("Network request failed.")), this.consecutiveFailures >= Mt) {
87
+ this.config.onError(
88
+ St("Max consecutive failures reached. Stopping.")
89
+ );
90
+ return;
91
+ }
92
+ }
93
+ this.scheduleNext();
94
+ }
95
+ }
96
+ async fetchStatus() {
97
+ const A = this.config.queryString || "", z = `${this.config.apiBaseUrl}/payment-accounts/${this.config.paymentAccountId}/payment-intents/${this.config.paymentIntentId}/status${A}`;
98
+ return fetch(z, {
99
+ method: "GET",
100
+ headers: {
101
+ "client-secret": this.config.clientSecret
102
+ }
103
+ });
104
+ }
105
+ emitStatus(A) {
106
+ this.currentStatus = A, this.config.onStatusChange(A);
107
+ }
108
+ applyBackoff() {
109
+ this.interval = Math.min(this.interval * Pt, Rt);
110
+ }
111
+ isExpired() {
112
+ return this.expiresAt ? Date.now() > this.expiresAt.getTime() + zt : !1;
113
+ }
114
+ scheduleNext() {
115
+ this.destroyed || (this.timer = setTimeout(() => this.poll(), this.interval));
116
+ }
117
+ }
118
+ function Lt(c) {
119
+ return c && c.__esModule && Object.prototype.hasOwnProperty.call(c, "default") ? c.default : c;
120
+ }
121
+ var xt = { exports: {} }, Nt = xt.exports, $t;
122
+ function Tt() {
123
+ return $t || ($t = 1, (function(c, A) {
124
+ (function(z, D) {
125
+ c.exports = D();
126
+ })(Nt, (() => (() => {
127
+ var z = { 873: (S, x) => {
128
+ var B, F, q = (function() {
129
+ var U = function(p, l) {
130
+ var d = p, e = st[l], t = null, n = 0, r = null, i = [], a = {}, w = function(o, h) {
131
+ t = (function(s) {
132
+ for (var u = new Array(s), g = 0; g < s; g += 1) {
133
+ u[g] = new Array(s);
134
+ for (var b = 0; b < s; b += 1) u[g][b] = null;
135
+ }
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 = P(d, e, i)), C(r, h);
138
+ }, f = function(o, h) {
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
+ }, _ = function() {
141
+ for (var o = 8; o < n - 8; o += 1) t[o][6] == null && (t[o][6] = o % 2 == 0);
142
+ for (var h = 8; h < n - 8; h += 1) t[6][h] == null && (t[6][h] = h % 2 == 0);
143
+ }, m = function() {
144
+ for (var o = V.getPatternPosition(d), h = 0; h < o.length; h += 1) for (var s = 0; s < o.length; s += 1) {
145
+ var u = o[h], g = o[s];
146
+ if (t[u][g] == null) for (var b = -2; b <= 2; b += 1) for (var O = -2; O <= 2; O += 1) t[u + b][g + O] = b == -2 || b == 2 || O == -2 || O == 2 || b == 0 && O == 0;
147
+ }
148
+ }, y = function(o) {
149
+ for (var h = V.getBCHTypeNumber(d), s = 0; s < 18; s += 1) {
150
+ var u = !o && (h >> s & 1) == 1;
151
+ t[Math.floor(s / 3)][s % 3 + n - 8 - 3] = u;
152
+ }
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
+ }, v = function(o, h) {
155
+ for (var s = e << 3 | h, u = V.getBCHTypeInfo(s), g = 0; g < 15; g += 1) {
156
+ var b = !o && (u >> g & 1) == 1;
157
+ g < 6 ? t[g][8] = b : g < 8 ? t[g + 1][8] = b : t[n - 15 + g][8] = b;
158
+ }
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
+ t[n - 8][8] = !o;
161
+ }, C = function(o, h) {
162
+ for (var s = -1, u = n - 1, g = 7, b = 0, O = V.getMaskFunction(h), I = n - 1; I > 0; I -= 2) for (I == 6 && (I -= 1); ; ) {
163
+ for (var N = 0; N < 2; N += 1) if (t[u][I - N] == null) {
164
+ var T = !1;
165
+ b < o.length && (T = (o[b] >>> g & 1) == 1), O(u, I - N) && (T = !T), t[u][I - N] = T, (g -= 1) == -1 && (b += 1, g = 7);
166
+ }
167
+ if ((u += s) < 0 || n <= u) {
168
+ u -= s, s = -s;
169
+ break;
170
+ }
171
+ }
172
+ }, P = function(o, h, s) {
173
+ for (var u = ft.getRSBlocks(o, h), g = ut(), b = 0; b < s.length; b += 1) {
174
+ var O = s[b];
175
+ g.put(O.getMode(), 4), g.put(O.getLength(), V.getLengthInBits(O.getMode(), o)), O.write(g);
176
+ }
177
+ var I = 0;
178
+ for (b = 0; b < u.length; b += 1) I += u[b].dataCount;
179
+ if (g.getLengthInBits() > 8 * I) throw "code length overflow. (" + g.getLengthInBits() + ">" + 8 * I + ")";
180
+ for (g.getLengthInBits() + 4 <= 8 * I && g.put(0, 4); g.getLengthInBits() % 8 != 0; ) g.putBit(!1);
181
+ for (; !(g.getLengthInBits() >= 8 * I || (g.put(236, 8), g.getLengthInBits() >= 8 * I)); ) g.put(17, 8);
182
+ return (function(N, T) {
183
+ for (var H = 0, tt = 0, W = 0, X = new Array(T.length), j = new Array(T.length), M = 0; M < T.length; M += 1) {
184
+ var Y = T[M].dataCount, Z = T[M].totalCount - Y;
185
+ tt = Math.max(tt, Y), W = Math.max(W, Z), X[M] = new Array(Y);
186
+ for (var k = 0; k < X[M].length; k += 1) X[M][k] = 255 & N.getBuffer()[k + H];
187
+ H += Y;
188
+ var ot = V.getErrorCorrectPolynomial(Z), rt = dt(X[M], ot.getLength() - 1).mod(ot);
189
+ for (j[M] = new Array(ot.getLength() - 1), k = 0; k < j[M].length; k += 1) {
190
+ var et = k + rt.getLength() - j[M].length;
191
+ j[M][k] = et >= 0 ? rt.getAt(et) : 0;
192
+ }
193
+ }
194
+ var yt = 0;
195
+ for (k = 0; k < T.length; k += 1) yt += T[k].totalCount;
196
+ var gt = new Array(yt), at = 0;
197
+ for (k = 0; k < tt; k += 1) for (M = 0; M < T.length; M += 1) k < X[M].length && (gt[at] = X[M][k], at += 1);
198
+ for (k = 0; k < W; k += 1) for (M = 0; M < T.length; M += 1) k < j[M].length && (gt[at] = j[M][k], at += 1);
199
+ return gt;
200
+ })(g, u);
201
+ };
202
+ a.addData = function(o, h) {
203
+ var s = null;
204
+ switch (h = h || "Byte") {
205
+ case "Numeric":
206
+ s = wt(o);
207
+ break;
208
+ case "Alphanumeric":
209
+ s = mt(o);
210
+ break;
211
+ case "Byte":
212
+ s = ct(o);
213
+ break;
214
+ case "Kanji":
215
+ s = vt(o);
216
+ break;
217
+ default:
218
+ throw "mode:" + h;
219
+ }
220
+ i.push(s), r = null;
221
+ }, a.isDark = function(o, h) {
222
+ if (o < 0 || n <= o || h < 0 || n <= h) throw o + "," + h;
223
+ return t[o][h];
224
+ }, a.getModuleCount = function() {
225
+ return n;
226
+ }, a.make = function() {
227
+ if (d < 1) {
228
+ for (var o = 1; o < 40; o++) {
229
+ for (var h = ft.getRSBlocks(o, e), s = ut(), u = 0; u < i.length; u++) {
230
+ var g = i[u];
231
+ s.put(g.getMode(), 4), s.put(g.getLength(), V.getLengthInBits(g.getMode(), o)), g.write(s);
232
+ }
233
+ var b = 0;
234
+ for (u = 0; u < h.length; u++) b += h[u].dataCount;
235
+ if (s.getLengthInBits() <= 8 * b) break;
236
+ }
237
+ d = o;
238
+ }
239
+ w(!1, (function() {
240
+ for (var O = 0, I = 0, N = 0; N < 8; N += 1) {
241
+ w(!0, N);
242
+ var T = V.getLostPoint(a);
243
+ (N == 0 || O > T) && (O = T, I = N);
244
+ }
245
+ return I;
246
+ })());
247
+ }, a.createTableTag = function(o, h) {
248
+ o = o || 2;
249
+ var s = "";
250
+ s += '<table style="', s += " border-width: 0px; border-style: none;", s += " border-collapse: collapse;", s += " padding: 0px; margin: " + (h = h === void 0 ? 4 * o : h) + "px;", s += '">', s += "<tbody>";
251
+ for (var u = 0; u < a.getModuleCount(); u += 1) {
252
+ s += "<tr>";
253
+ for (var g = 0; g < a.getModuleCount(); g += 1) s += '<td style="', s += " border-width: 0px; border-style: none;", s += " border-collapse: collapse;", s += " padding: 0px; margin: 0px;", s += " width: " + o + "px;", s += " height: " + o + "px;", s += " background-color: ", s += a.isDark(u, g) ? "#000000" : "#ffffff", s += ";", s += '"/>';
254
+ s += "</tr>";
255
+ }
256
+ return (s += "</tbody>") + "</table>";
257
+ }, a.createSvgTag = function(o, h, s, u) {
258
+ var g = {};
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, O, I, N, T = a.getModuleCount() * o + 2 * h, H = "";
261
+ for (N = "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="' + T + 'px" height="' + T + 'px"', H += ' viewBox="0 0 ' + T + " " + T + '" ', H += ' preserveAspectRatio="xMinYMin meet"', H += u.text || s.text ? ' role="img" aria-labelledby="' + $([u.id, s.id].join(" ").trim()) + '"' : "", H += ">", H += u.text ? '<title id="' + $(u.id) + '">' + $(u.text) + "</title>" : "", H += s.text ? '<description id="' + $(s.id) + '">' + $(s.text) + "</description>" : "", H += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>', H += '<path d="', O = 0; O < a.getModuleCount(); O += 1) for (I = O * o + h, b = 0; b < a.getModuleCount(); b += 1) a.isDark(O, b) && (H += "M" + (b * o + h) + "," + I + N);
262
+ return (H += '" stroke="transparent" fill="black"/>') + "</svg>";
263
+ }, a.createDataURL = function(o, h) {
264
+ o = o || 2, h = h === void 0 ? 4 * o : h;
265
+ var s = a.getModuleCount() * o + 2 * h, u = h, g = s - h;
266
+ return lt(s, s, (function(b, O) {
267
+ if (u <= b && b < g && u <= O && O < g) {
268
+ var I = Math.floor((b - u) / o), N = Math.floor((O - u) / o);
269
+ return a.isDark(N, I) ? 0 : 1;
270
+ }
271
+ return 1;
272
+ }));
273
+ }, a.createImgTag = function(o, h, s) {
274
+ o = o || 2, h = h === void 0 ? 4 * o : h;
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 += $(s), g += '"'), g + "/>";
277
+ };
278
+ var $ = function(o) {
279
+ for (var h = "", s = 0; s < o.length; s += 1) {
280
+ var u = o.charAt(s);
281
+ switch (u) {
282
+ case "<":
283
+ h += "&lt;";
284
+ break;
285
+ case ">":
286
+ h += "&gt;";
287
+ break;
288
+ case "&":
289
+ h += "&amp;";
290
+ break;
291
+ case '"':
292
+ h += "&quot;";
293
+ break;
294
+ default:
295
+ h += u;
296
+ }
297
+ }
298
+ return h;
299
+ };
300
+ return a.createASCII = function(o, h) {
301
+ if ((o = o || 1) < 2) return (function(X) {
302
+ X = X === void 0 ? 2 : X;
303
+ var j, M, Y, Z, k, ot = 1 * a.getModuleCount() + 2 * X, rt = X, et = ot - X, yt = { "██": "█", "█ ": "▀", " █": "▄", " ": " " }, gt = { "██": "▀", "█ ": "▀", " █": " ", " ": " " }, at = "";
304
+ for (j = 0; j < ot; j += 2) {
305
+ for (Y = Math.floor((j - rt) / 1), Z = Math.floor((j + 1 - rt) / 1), M = 0; M < ot; M += 1) k = "█", rt <= M && M < et && rt <= j && j < et && a.isDark(Y, Math.floor((M - rt) / 1)) && (k = " "), rt <= M && M < et && rt <= j + 1 && j + 1 < et && a.isDark(Z, Math.floor((M - rt) / 1)) ? k += " " : k += "█", at += X < 1 && j + 1 >= et ? gt[k] : yt[k];
306
+ at += `
307
+ `;
308
+ }
309
+ return ot % 2 && X > 0 ? at.substring(0, at.length - ot - 1) + Array(ot + 1).join("▀") : at.substring(0, at.length - 1);
310
+ })(h);
311
+ o -= 1, h = h === void 0 ? 2 * o : h;
312
+ var s, u, g, b, O = a.getModuleCount() * o + 2 * h, I = h, N = O - h, T = Array(o + 1).join("██"), H = Array(o + 1).join(" "), tt = "", W = "";
313
+ for (s = 0; s < O; s += 1) {
314
+ for (g = Math.floor((s - I) / o), W = "", u = 0; u < O; u += 1) b = 1, I <= u && u < N && I <= s && s < N && a.isDark(g, Math.floor((u - I) / o)) && (b = 0), W += b ? T : H;
315
+ for (g = 0; g < o; g += 1) tt += W + `
316
+ `;
317
+ }
318
+ return tt.substring(0, tt.length - 1);
319
+ }, a.renderTo2dContext = function(o, h) {
320
+ h = h || 2;
321
+ for (var s = a.getModuleCount(), u = 0; u < s; u++) for (var g = 0; g < s; g++) o.fillStyle = a.isDark(u, g) ? "black" : "white", o.fillRect(u * h, g * h, h, h);
322
+ }, a;
323
+ };
324
+ U.stringToBytes = (U.stringToBytesFuncs = { default: function(p) {
325
+ for (var l = [], d = 0; d < p.length; d += 1) {
326
+ var e = p.charCodeAt(d);
327
+ l.push(255 & e);
328
+ }
329
+ return l;
330
+ } }).default, U.createStringToBytes = function(p, l) {
331
+ var d = (function() {
332
+ for (var t = Ct(p), n = function() {
333
+ var _ = t.read();
334
+ if (_ == -1) throw "eof";
335
+ return _;
336
+ }, r = 0, i = {}; ; ) {
337
+ var a = t.read();
338
+ if (a == -1) break;
339
+ var w = n(), f = n() << 8 | n();
340
+ i[String.fromCharCode(a << 8 | w)] = f, r += 1;
341
+ }
342
+ if (r != l) throw r + " != " + l;
343
+ return i;
344
+ })(), e = 63;
345
+ return function(t) {
346
+ for (var n = [], r = 0; r < t.length; r += 1) {
347
+ var i = t.charCodeAt(r);
348
+ if (i < 128) n.push(i);
349
+ else {
350
+ var a = d[t.charAt(r)];
351
+ typeof a == "number" ? (255 & a) == a ? n.push(a) : (n.push(a >>> 8), n.push(255 & a)) : n.push(e);
352
+ }
353
+ }
354
+ return n;
355
+ };
356
+ };
357
+ var G, K, L, R, nt, st = { L: 1, M: 0, Q: 3, H: 2 }, V = (G = [[], [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]], K = 1335, L = 7973, nt = function(p) {
358
+ for (var l = 0; p != 0; ) l += 1, p >>>= 1;
359
+ return l;
360
+ }, (R = {}).getBCHTypeInfo = function(p) {
361
+ for (var l = p << 10; nt(l) - nt(K) >= 0; ) l ^= K << nt(l) - nt(K);
362
+ return 21522 ^ (p << 10 | l);
363
+ }, R.getBCHTypeNumber = function(p) {
364
+ for (var l = p << 12; nt(l) - nt(L) >= 0; ) l ^= L << nt(l) - nt(L);
365
+ return p << 12 | l;
366
+ }, R.getPatternPosition = function(p) {
367
+ return G[p - 1];
368
+ }, R.getMaskFunction = function(p) {
369
+ switch (p) {
370
+ case 0:
371
+ return function(l, d) {
372
+ return (l + d) % 2 == 0;
373
+ };
374
+ case 1:
375
+ return function(l, d) {
376
+ return l % 2 == 0;
377
+ };
378
+ case 2:
379
+ return function(l, d) {
380
+ return d % 3 == 0;
381
+ };
382
+ case 3:
383
+ return function(l, d) {
384
+ return (l + d) % 3 == 0;
385
+ };
386
+ case 4:
387
+ return function(l, d) {
388
+ return (Math.floor(l / 2) + Math.floor(d / 3)) % 2 == 0;
389
+ };
390
+ case 5:
391
+ return function(l, d) {
392
+ return l * d % 2 + l * d % 3 == 0;
393
+ };
394
+ case 6:
395
+ return function(l, d) {
396
+ return (l * d % 2 + l * d % 3) % 2 == 0;
397
+ };
398
+ case 7:
399
+ return function(l, d) {
400
+ return (l * d % 3 + (l + d) % 2) % 2 == 0;
401
+ };
402
+ default:
403
+ throw "bad maskPattern:" + p;
404
+ }
405
+ }, R.getErrorCorrectPolynomial = function(p) {
406
+ for (var l = dt([1], 0), d = 0; d < p; d += 1) l = l.multiply(dt([1, J.gexp(d)], 0));
407
+ return l;
408
+ }, R.getLengthInBits = function(p, l) {
409
+ if (1 <= l && l < 10) switch (p) {
410
+ case 1:
411
+ return 10;
412
+ case 2:
413
+ return 9;
414
+ case 4:
415
+ case 8:
416
+ return 8;
417
+ default:
418
+ throw "mode:" + p;
419
+ }
420
+ else if (l < 27) switch (p) {
421
+ case 1:
422
+ return 12;
423
+ case 2:
424
+ return 11;
425
+ case 4:
426
+ return 16;
427
+ case 8:
428
+ return 10;
429
+ default:
430
+ throw "mode:" + p;
431
+ }
432
+ else {
433
+ if (!(l < 41)) throw "type:" + l;
434
+ switch (p) {
435
+ case 1:
436
+ return 14;
437
+ case 2:
438
+ return 13;
439
+ case 4:
440
+ return 16;
441
+ case 8:
442
+ return 12;
443
+ default:
444
+ throw "mode:" + p;
445
+ }
446
+ }
447
+ }, R.getLostPoint = function(p) {
448
+ for (var l = p.getModuleCount(), d = 0, e = 0; e < l; e += 1) for (var t = 0; t < l; t += 1) {
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
+ n > 5 && (d += 3 + n - 5);
451
+ }
452
+ for (e = 0; e < l - 1; e += 1) for (t = 0; t < l - 1; t += 1) {
453
+ var w = 0;
454
+ p.isDark(e, t) && (w += 1), p.isDark(e + 1, t) && (w += 1), p.isDark(e, t + 1) && (w += 1), p.isDark(e + 1, t + 1) && (w += 1), w != 0 && w != 4 || (d += 3);
455
+ }
456
+ for (e = 0; e < l; e += 1) for (t = 0; t < l - 6; t += 1) p.isDark(e, t) && !p.isDark(e, t + 1) && p.isDark(e, t + 2) && p.isDark(e, t + 3) && p.isDark(e, t + 4) && !p.isDark(e, t + 5) && p.isDark(e, t + 6) && (d += 40);
457
+ for (t = 0; t < l; t += 1) for (e = 0; e < l - 6; e += 1) p.isDark(e, t) && !p.isDark(e + 1, t) && p.isDark(e + 2, t) && p.isDark(e + 3, t) && p.isDark(e + 4, t) && !p.isDark(e + 5, t) && p.isDark(e + 6, t) && (d += 40);
458
+ var f = 0;
459
+ for (t = 0; t < l; t += 1) for (e = 0; e < l; e += 1) p.isDark(e, t) && (f += 1);
460
+ return d + Math.abs(100 * f / l / l - 50) / 5 * 10;
461
+ }, R), J = (function() {
462
+ for (var p = new Array(256), l = new Array(256), d = 0; d < 8; d += 1) p[d] = 1 << d;
463
+ for (d = 8; d < 256; d += 1) p[d] = p[d - 4] ^ p[d - 5] ^ p[d - 6] ^ p[d - 8];
464
+ for (d = 0; d < 255; d += 1) l[p[d]] = d;
465
+ return { glog: function(e) {
466
+ if (e < 1) throw "glog(" + e + ")";
467
+ return l[e];
468
+ }, gexp: function(e) {
469
+ for (; e < 0; ) e += 255;
470
+ for (; e >= 256; ) e -= 255;
471
+ return p[e];
472
+ } };
473
+ })();
474
+ function dt(p, l) {
475
+ if (p.length === void 0) throw p.length + "/" + l;
476
+ var d = (function() {
477
+ for (var t = 0; t < p.length && p[t] == 0; ) t += 1;
478
+ for (var n = new Array(p.length - t + l), r = 0; r < p.length - t; r += 1) n[r] = p[r + t];
479
+ return n;
480
+ })(), e = { getAt: function(t) {
481
+ return d[t];
482
+ }, getLength: function() {
483
+ return d.length;
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] ^= J.gexp(J.glog(e.getAt(r)) + J.glog(t.getAt(i)));
486
+ return dt(n, 0);
487
+ }, mod: function(t) {
488
+ if (e.getLength() - t.getLength() < 0) return e;
489
+ for (var n = J.glog(e.getAt(0)) - J.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] ^= J.gexp(J.glog(t.getAt(i)) + n);
491
+ return dt(r, 0).mod(t);
492
+ } };
493
+ return e;
494
+ }
495
+ var ft = /* @__PURE__ */ (function() {
496
+ var p = [[1, 26, 19], [1, 26, 16], [1, 26, 13], [1, 26, 9], [1, 44, 34], [1, 44, 28], [1, 44, 22], [1, 44, 16], [1, 70, 55], [1, 70, 44], [2, 35, 17], [2, 35, 13], [1, 100, 80], [2, 50, 32], [2, 50, 24], [4, 25, 9], [1, 134, 108], [2, 67, 43], [2, 33, 15, 2, 34, 16], [2, 33, 11, 2, 34, 12], [2, 86, 68], [4, 43, 27], [4, 43, 19], [4, 43, 15], [2, 98, 78], [4, 49, 31], [2, 32, 14, 4, 33, 15], [4, 39, 13, 1, 40, 14], [2, 121, 97], [2, 60, 38, 2, 61, 39], [4, 40, 18, 2, 41, 19], [4, 40, 14, 2, 41, 15], [2, 146, 116], [3, 58, 36, 2, 59, 37], [4, 36, 16, 4, 37, 17], [4, 36, 12, 4, 37, 13], [2, 86, 68, 2, 87, 69], [4, 69, 43, 1, 70, 44], [6, 43, 19, 2, 44, 20], [6, 43, 15, 2, 44, 16], [4, 101, 81], [1, 80, 50, 4, 81, 51], [4, 50, 22, 4, 51, 23], [3, 36, 12, 8, 37, 13], [2, 116, 92, 2, 117, 93], [6, 58, 36, 2, 59, 37], [4, 46, 20, 6, 47, 21], [7, 42, 14, 4, 43, 15], [4, 133, 107], [8, 59, 37, 1, 60, 38], [8, 44, 20, 4, 45, 21], [12, 33, 11, 4, 34, 12], [3, 145, 115, 1, 146, 116], [4, 64, 40, 5, 65, 41], [11, 36, 16, 5, 37, 17], [11, 36, 12, 5, 37, 13], [5, 109, 87, 1, 110, 88], [5, 65, 41, 5, 66, 42], [5, 54, 24, 7, 55, 25], [11, 36, 12, 7, 37, 13], [5, 122, 98, 1, 123, 99], [7, 73, 45, 3, 74, 46], [15, 43, 19, 2, 44, 20], [3, 45, 15, 13, 46, 16], [1, 135, 107, 5, 136, 108], [10, 74, 46, 1, 75, 47], [1, 50, 22, 15, 51, 23], [2, 42, 14, 17, 43, 15], [5, 150, 120, 1, 151, 121], [9, 69, 43, 4, 70, 44], [17, 50, 22, 1, 51, 23], [2, 42, 14, 19, 43, 15], [3, 141, 113, 4, 142, 114], [3, 70, 44, 11, 71, 45], [17, 47, 21, 4, 48, 22], [9, 39, 13, 16, 40, 14], [3, 135, 107, 5, 136, 108], [3, 67, 41, 13, 68, 42], [15, 54, 24, 5, 55, 25], [15, 43, 15, 10, 44, 16], [4, 144, 116, 4, 145, 117], [17, 68, 42], [17, 50, 22, 6, 51, 23], [19, 46, 16, 6, 47, 17], [2, 139, 111, 7, 140, 112], [17, 74, 46], [7, 54, 24, 16, 55, 25], [34, 37, 13], [4, 151, 121, 5, 152, 122], [4, 75, 47, 14, 76, 48], [11, 54, 24, 14, 55, 25], [16, 45, 15, 14, 46, 16], [6, 147, 117, 4, 148, 118], [6, 73, 45, 14, 74, 46], [11, 54, 24, 16, 55, 25], [30, 46, 16, 2, 47, 17], [8, 132, 106, 4, 133, 107], [8, 75, 47, 13, 76, 48], [7, 54, 24, 22, 55, 25], [22, 45, 15, 13, 46, 16], [10, 142, 114, 2, 143, 115], [19, 74, 46, 4, 75, 47], [28, 50, 22, 6, 51, 23], [33, 46, 16, 4, 47, 17], [8, 152, 122, 4, 153, 123], [22, 73, 45, 3, 74, 46], [8, 53, 23, 26, 54, 24], [12, 45, 15, 28, 46, 16], [3, 147, 117, 10, 148, 118], [3, 73, 45, 23, 74, 46], [4, 54, 24, 31, 55, 25], [11, 45, 15, 31, 46, 16], [7, 146, 116, 7, 147, 117], [21, 73, 45, 7, 74, 46], [1, 53, 23, 37, 54, 24], [19, 45, 15, 26, 46, 16], [5, 145, 115, 10, 146, 116], [19, 75, 47, 10, 76, 48], [15, 54, 24, 25, 55, 25], [23, 45, 15, 25, 46, 16], [13, 145, 115, 3, 146, 116], [2, 74, 46, 29, 75, 47], [42, 54, 24, 1, 55, 25], [23, 45, 15, 28, 46, 16], [17, 145, 115], [10, 74, 46, 23, 75, 47], [10, 54, 24, 35, 55, 25], [19, 45, 15, 35, 46, 16], [17, 145, 115, 1, 146, 116], [14, 74, 46, 21, 75, 47], [29, 54, 24, 19, 55, 25], [11, 45, 15, 46, 46, 16], [13, 145, 115, 6, 146, 116], [14, 74, 46, 23, 75, 47], [44, 54, 24, 7, 55, 25], [59, 46, 16, 1, 47, 17], [12, 151, 121, 7, 152, 122], [12, 75, 47, 26, 76, 48], [39, 54, 24, 14, 55, 25], [22, 45, 15, 41, 46, 16], [6, 151, 121, 14, 152, 122], [6, 75, 47, 34, 76, 48], [46, 54, 24, 10, 55, 25], [2, 45, 15, 64, 46, 16], [17, 152, 122, 4, 153, 123], [29, 74, 46, 14, 75, 47], [49, 54, 24, 10, 55, 25], [24, 45, 15, 46, 46, 16], [4, 152, 122, 18, 153, 123], [13, 74, 46, 32, 75, 47], [48, 54, 24, 14, 55, 25], [42, 45, 15, 32, 46, 16], [20, 147, 117, 4, 148, 118], [40, 75, 47, 7, 76, 48], [43, 54, 24, 22, 55, 25], [10, 45, 15, 67, 46, 16], [19, 148, 118, 6, 149, 119], [18, 75, 47, 31, 76, 48], [34, 54, 24, 34, 55, 25], [20, 45, 15, 61, 46, 16]], l = function(e, t) {
497
+ var n = {};
498
+ return n.totalCount = e, n.dataCount = t, n;
499
+ }, d = { getRSBlocks: function(e, t) {
500
+ var n = (function(y, v) {
501
+ switch (v) {
502
+ case st.L:
503
+ return p[4 * (y - 1) + 0];
504
+ case st.M:
505
+ return p[4 * (y - 1) + 1];
506
+ case st.Q:
507
+ return p[4 * (y - 1) + 2];
508
+ case st.H:
509
+ return p[4 * (y - 1) + 3];
510
+ default:
511
+ return;
512
+ }
513
+ })(e, t);
514
+ if (n === void 0) throw "bad rs block @ typeNumber:" + e + "/errorCorrectionLevel:" + t;
515
+ for (var r = n.length / 3, i = [], a = 0; a < r; a += 1) for (var w = n[3 * a + 0], f = n[3 * a + 1], _ = n[3 * a + 2], m = 0; m < w; m += 1) i.push(l(f, _));
516
+ return i;
517
+ } };
518
+ return d;
519
+ })(), ut = function() {
520
+ var p = [], l = 0, d = { getBuffer: function() {
521
+ return p;
522
+ }, getAt: function(e) {
523
+ var t = Math.floor(e / 8);
524
+ return (p[t] >>> 7 - e % 8 & 1) == 1;
525
+ }, put: function(e, t) {
526
+ for (var n = 0; n < t; n += 1) d.putBit((e >>> t - n - 1 & 1) == 1);
527
+ }, getLengthInBits: function() {
528
+ return l;
529
+ }, putBit: function(e) {
530
+ var t = Math.floor(l / 8);
531
+ p.length <= t && p.push(0), e && (p[t] |= 128 >>> l % 8), l += 1;
532
+ } };
533
+ return d;
534
+ }, wt = function(p) {
535
+ var l = p, d = { getMode: function() {
536
+ return 1;
537
+ }, getLength: function(n) {
538
+ return l.length;
539
+ }, write: function(n) {
540
+ for (var r = l, i = 0; i + 2 < r.length; ) n.put(e(r.substring(i, i + 3)), 10), i += 3;
541
+ i < r.length && (r.length - i == 1 ? n.put(e(r.substring(i, i + 1)), 4) : r.length - i == 2 && n.put(e(r.substring(i, i + 2)), 7));
542
+ } }, e = function(n) {
543
+ for (var r = 0, i = 0; i < n.length; i += 1) r = 10 * r + t(n.charAt(i));
544
+ return r;
545
+ }, t = function(n) {
546
+ if ("0" <= n && n <= "9") return n.charCodeAt(0) - 48;
547
+ throw "illegal char :" + n;
548
+ };
549
+ return d;
550
+ }, mt = function(p) {
551
+ var l = p, d = { getMode: function() {
552
+ return 2;
553
+ }, getLength: function(t) {
554
+ return l.length;
555
+ }, write: function(t) {
556
+ for (var n = l, r = 0; r + 1 < n.length; ) t.put(45 * e(n.charAt(r)) + e(n.charAt(r + 1)), 11), r += 2;
557
+ r < n.length && t.put(e(n.charAt(r)), 6);
558
+ } }, e = function(t) {
559
+ if ("0" <= t && t <= "9") return t.charCodeAt(0) - 48;
560
+ if ("A" <= t && t <= "Z") return t.charCodeAt(0) - 65 + 10;
561
+ switch (t) {
562
+ case " ":
563
+ return 36;
564
+ case "$":
565
+ return 37;
566
+ case "%":
567
+ return 38;
568
+ case "*":
569
+ return 39;
570
+ case "+":
571
+ return 40;
572
+ case "-":
573
+ return 41;
574
+ case ".":
575
+ return 42;
576
+ case "/":
577
+ return 43;
578
+ case ":":
579
+ return 44;
580
+ default:
581
+ throw "illegal char :" + t;
582
+ }
583
+ };
584
+ return d;
585
+ }, ct = function(p) {
586
+ var l = U.stringToBytes(p);
587
+ return { getMode: function() {
588
+ return 4;
589
+ }, getLength: function(d) {
590
+ return l.length;
591
+ }, write: function(d) {
592
+ for (var e = 0; e < l.length; e += 1) d.put(l[e], 8);
593
+ } };
594
+ }, vt = function(p) {
595
+ var l = U.stringToBytesFuncs.SJIS;
596
+ if (!l) throw "sjis not supported.";
597
+ (function() {
598
+ var t = l("友");
599
+ if (t.length != 2 || (t[0] << 8 | t[1]) != 38726) throw "sjis not supported.";
600
+ })();
601
+ var d = l(p), e = { getMode: function() {
602
+ return 8;
603
+ }, getLength: function(t) {
604
+ return ~~(d.length / 2);
605
+ }, write: function(t) {
606
+ for (var n = d, r = 0; r + 1 < n.length; ) {
607
+ var i = (255 & n[r]) << 8 | 255 & n[r + 1];
608
+ if (33088 <= i && i <= 40956) i -= 33088;
609
+ else {
610
+ if (!(57408 <= i && i <= 60351)) throw "illegal char at " + (r + 1) + "/" + i;
611
+ i -= 49472;
612
+ }
613
+ i = 192 * (i >>> 8 & 255) + (255 & i), t.put(i, 13), r += 2;
614
+ }
615
+ if (r < n.length) throw "illegal char at " + (r + 1);
616
+ } };
617
+ return e;
618
+ }, _t = function() {
619
+ var p = [], l = { writeByte: function(d) {
620
+ p.push(255 & d);
621
+ }, writeShort: function(d) {
622
+ l.writeByte(d), l.writeByte(d >>> 8);
623
+ }, writeBytes: function(d, e, t) {
624
+ e = e || 0, t = t || d.length;
625
+ for (var n = 0; n < t; n += 1) l.writeByte(d[n + e]);
626
+ }, writeString: function(d) {
627
+ for (var e = 0; e < d.length; e += 1) l.writeByte(d.charCodeAt(e));
628
+ }, toByteArray: function() {
629
+ return p;
630
+ }, toString: function() {
631
+ var d = "";
632
+ d += "[";
633
+ for (var e = 0; e < p.length; e += 1) e > 0 && (d += ","), d += p[e];
634
+ return d + "]";
635
+ } };
636
+ return l;
637
+ }, Ct = function(p) {
638
+ var l = p, d = 0, e = 0, t = 0, n = { read: function() {
639
+ for (; t < 8; ) {
640
+ if (d >= l.length) {
641
+ if (t == 0) return -1;
642
+ throw "unexpected end of file./" + t;
643
+ }
644
+ var i = l.charAt(d);
645
+ if (d += 1, i == "=") return t = 0, -1;
646
+ i.match(/^\s$/) || (e = e << 6 | r(i.charCodeAt(0)), t += 6);
647
+ }
648
+ var a = e >>> t - 8 & 255;
649
+ return t -= 8, a;
650
+ } }, r = function(i) {
651
+ if (65 <= i && i <= 90) return i - 65;
652
+ if (97 <= i && i <= 122) return i - 97 + 26;
653
+ if (48 <= i && i <= 57) return i - 48 + 52;
654
+ if (i == 43) return 62;
655
+ if (i == 47) return 63;
656
+ throw "c:" + i;
657
+ };
658
+ return n;
659
+ }, lt = function(p, l, d) {
660
+ for (var e = (function(f, _) {
661
+ var m = f, y = _, v = new Array(f * _), C = { setPixel: function(o, h, s) {
662
+ v[h * m + o] = s;
663
+ }, write: function(o) {
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 = P(2);
666
+ o.writeByte(2);
667
+ for (var s = 0; h.length - s > 255; ) o.writeByte(255), o.writeBytes(h, s, 255), s += 255;
668
+ o.writeByte(h.length - s), o.writeBytes(h, s, h.length - s), o.writeByte(0), o.writeString(";");
669
+ } }, P = function(o) {
670
+ for (var h = 1 << o, s = 1 + (1 << o), u = o + 1, g = $(), b = 0; b < h; b += 1) g.add(String.fromCharCode(b));
671
+ g.add(String.fromCharCode(h)), g.add(String.fromCharCode(s));
672
+ var O, I, N, T = _t(), H = (O = T, I = 0, N = 0, { write: function(j, M) {
673
+ if (j >>> M) throw "length over";
674
+ for (; I + M >= 8; ) O.writeByte(255 & (j << I | N)), M -= 8 - I, j >>>= 8 - I, N = 0, I = 0;
675
+ N |= j << I, I += M;
676
+ }, flush: function() {
677
+ I > 0 && O.writeByte(N);
678
+ } });
679
+ H.write(h, u);
680
+ var tt = 0, W = String.fromCharCode(v[tt]);
681
+ for (tt += 1; tt < v.length; ) {
682
+ var X = String.fromCharCode(v[tt]);
683
+ tt += 1, g.contains(W + X) ? W += X : (H.write(g.indexOf(W), u), g.size() < 4095 && (g.size() == 1 << u && (u += 1), g.add(W + X)), W = X);
684
+ }
685
+ return H.write(g.indexOf(W), u), H.write(s, u), H.flush(), T.toByteArray();
686
+ }, $ = function() {
687
+ var o = {}, h = 0, s = { add: function(u) {
688
+ if (s.contains(u)) throw "dup key:" + u;
689
+ o[u] = h, h += 1;
690
+ }, size: function() {
691
+ return h;
692
+ }, indexOf: function(u) {
693
+ return o[u];
694
+ }, contains: function(u) {
695
+ return o[u] !== void 0;
696
+ } };
697
+ return s;
698
+ };
699
+ return C;
700
+ })(p, l), t = 0; t < l; t += 1) for (var n = 0; n < p; n += 1) e.setPixel(n, t, d(n, t));
701
+ var r = _t();
702
+ e.write(r);
703
+ for (var i = (function() {
704
+ var f = 0, _ = 0, m = 0, y = "", v = {}, C = function($) {
705
+ y += String.fromCharCode(P(63 & $));
706
+ }, P = function($) {
707
+ if (!($ < 0)) {
708
+ if ($ < 26) return 65 + $;
709
+ if ($ < 52) return $ - 26 + 97;
710
+ if ($ < 62) return $ - 52 + 48;
711
+ if ($ == 62) return 43;
712
+ if ($ == 63) return 47;
713
+ }
714
+ throw "n:" + $;
715
+ };
716
+ return v.writeByte = function($) {
717
+ for (f = f << 8 | 255 & $, _ += 8, m += 1; _ >= 6; ) C(f >>> _ - 6), _ -= 6;
718
+ }, v.flush = function() {
719
+ if (_ > 0 && (C(f << 6 - _), f = 0, _ = 0), m % 3 != 0) for (var $ = 3 - m % 3, o = 0; o < $; o += 1) y += "=";
720
+ }, v.toString = function() {
721
+ return y;
722
+ }, v;
723
+ })(), a = r.toByteArray(), w = 0; w < a.length; w += 1) i.writeByte(a[w]);
724
+ return i.flush(), "data:image/gif;base64," + i;
725
+ };
726
+ return U;
727
+ })();
728
+ q.stringToBytesFuncs["UTF-8"] = function(U) {
729
+ return (function(G) {
730
+ for (var K = [], L = 0; L < G.length; L++) {
731
+ var R = G.charCodeAt(L);
732
+ R < 128 ? K.push(R) : R < 2048 ? K.push(192 | R >> 6, 128 | 63 & R) : R < 55296 || R >= 57344 ? K.push(224 | R >> 12, 128 | R >> 6 & 63, 128 | 63 & R) : (L++, R = 65536 + ((1023 & R) << 10 | 1023 & G.charCodeAt(L)), K.push(240 | R >> 18, 128 | R >> 12 & 63, 128 | R >> 6 & 63, 128 | 63 & R));
733
+ }
734
+ return K;
735
+ })(U);
736
+ }, (F = typeof (B = function() {
737
+ return q;
738
+ }) == "function" ? B.apply(x, []) : B) === void 0 || (S.exports = F);
739
+ } }, D = {};
740
+ function E(S) {
741
+ var x = D[S];
742
+ if (x !== void 0) return x.exports;
743
+ var B = D[S] = { exports: {} };
744
+ return z[S](B, B.exports, E), B.exports;
745
+ }
746
+ E.n = (S) => {
747
+ var x = S && S.__esModule ? () => S.default : () => S;
748
+ return E.d(x, { a: x }), x;
749
+ }, E.d = (S, x) => {
750
+ for (var B in x) E.o(x, B) && !E.o(S, B) && Object.defineProperty(S, B, { enumerable: !0, get: x[B] });
751
+ }, E.o = (S, x) => Object.prototype.hasOwnProperty.call(S, x);
752
+ var Q = {};
753
+ return (() => {
754
+ E.d(Q, { default: () => l });
755
+ const S = (d) => !!d && typeof d == "object" && !Array.isArray(d);
756
+ function x(d, ...e) {
757
+ if (!e.length) return d;
758
+ const t = e.shift();
759
+ return t !== void 0 && S(d) && S(t) ? (d = Object.assign({}, d), Object.keys(t).forEach(((n) => {
760
+ const r = d[n], i = t[n];
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
+ })), x(d, ...e)) : d;
763
+ }
764
+ function B(d, e) {
765
+ const t = document.createElement("a");
766
+ t.download = e, t.href = d, document.body.appendChild(t), t.click(), document.body.removeChild(t);
767
+ }
768
+ const F = { L: 0.07, M: 0.15, Q: 0.25, H: 0.3 };
769
+ class q {
770
+ constructor({ svg: e, type: t, window: n }) {
771
+ this._svg = e, this._type = t, this._window = n;
772
+ }
773
+ draw(e, t, n, r) {
774
+ let i;
775
+ switch (this._type) {
776
+ case "dots":
777
+ i = this._drawDot;
778
+ break;
779
+ case "classy":
780
+ i = this._drawClassy;
781
+ break;
782
+ case "classy-rounded":
783
+ i = this._drawClassyRounded;
784
+ break;
785
+ case "rounded":
786
+ i = this._drawRounded;
787
+ break;
788
+ case "extra-rounded":
789
+ i = this._drawExtraRounded;
790
+ break;
791
+ default:
792
+ i = this._drawSquare;
793
+ }
794
+ i.call(this, { x: e, y: t, size: n, getNeighbor: r });
795
+ }
796
+ _rotateFigure({ x: e, y: t, size: n, rotation: r = 0, draw: i }) {
797
+ var a;
798
+ const w = e + n / 2, f = t + n / 2;
799
+ i(), (a = this._element) === null || a === void 0 || a.setAttribute("transform", `rotate(${180 * r / Math.PI},${w},${f})`);
800
+ }
801
+ _basicDot(e) {
802
+ const { size: t, x: n, y: r } = e;
803
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
804
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(n + t / 2)), this._element.setAttribute("cy", String(r + t / 2)), this._element.setAttribute("r", String(t / 2));
805
+ } }));
806
+ }
807
+ _basicSquare(e) {
808
+ const { size: t, x: n, y: r } = e;
809
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
810
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(n)), this._element.setAttribute("y", String(r)), this._element.setAttribute("width", String(t)), this._element.setAttribute("height", String(t));
811
+ } }));
812
+ }
813
+ _basicSideRounded(e) {
814
+ const { size: t, x: n, y: r } = e;
815
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
816
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${n} ${r}v ${t}h ` + t / 2 + `a ${t / 2} ${t / 2}, 0, 0, 0, 0 ${-t}`);
817
+ } }));
818
+ }
819
+ _basicCornerRounded(e) {
820
+ const { size: t, x: n, y: r } = e;
821
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
822
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${n} ${r}v ${t}h ${t}v ` + -t / 2 + `a ${t / 2} ${t / 2}, 0, 0, 0, ${-t / 2} ${-t / 2}`);
823
+ } }));
824
+ }
825
+ _basicCornerExtraRounded(e) {
826
+ const { size: t, x: n, y: r } = e;
827
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
828
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${n} ${r}v ${t}h ${t}a ${t} ${t}, 0, 0, 0, ${-t} ${-t}`);
829
+ } }));
830
+ }
831
+ _basicCornersRounded(e) {
832
+ const { size: t, x: n, y: r } = e;
833
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
834
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${n} ${r}v ` + t / 2 + `a ${t / 2} ${t / 2}, 0, 0, 0, ${t / 2} ${t / 2}h ` + t / 2 + "v " + -t / 2 + `a ${t / 2} ${t / 2}, 0, 0, 0, ${-t / 2} ${-t / 2}`);
835
+ } }));
836
+ }
837
+ _drawDot({ x: e, y: t, size: n }) {
838
+ this._basicDot({ x: e, y: t, size: n, rotation: 0 });
839
+ }
840
+ _drawSquare({ x: e, y: t, size: n }) {
841
+ this._basicSquare({ x: e, y: t, size: n, rotation: 0 });
842
+ }
843
+ _drawRounded({ x: e, y: t, size: n, getNeighbor: r }) {
844
+ const i = r ? +r(-1, 0) : 0, a = r ? +r(1, 0) : 0, w = r ? +r(0, -1) : 0, f = r ? +r(0, 1) : 0, _ = i + a + w + f;
845
+ if (_ !== 0) if (_ > 2 || i && a || w && f) this._basicSquare({ x: e, y: t, size: n, rotation: 0 });
846
+ else {
847
+ if (_ === 2) {
848
+ let m = 0;
849
+ return i && w ? m = Math.PI / 2 : w && a ? m = Math.PI : a && f && (m = -Math.PI / 2), void this._basicCornerRounded({ x: e, y: t, size: n, rotation: m });
850
+ }
851
+ if (_ === 1) {
852
+ let m = 0;
853
+ return w ? m = Math.PI / 2 : a ? m = Math.PI : f && (m = -Math.PI / 2), void this._basicSideRounded({ x: e, y: t, size: n, rotation: m });
854
+ }
855
+ }
856
+ else this._basicDot({ x: e, y: t, size: n, rotation: 0 });
857
+ }
858
+ _drawExtraRounded({ x: e, y: t, size: n, getNeighbor: r }) {
859
+ const i = r ? +r(-1, 0) : 0, a = r ? +r(1, 0) : 0, w = r ? +r(0, -1) : 0, f = r ? +r(0, 1) : 0, _ = i + a + w + f;
860
+ if (_ !== 0) if (_ > 2 || i && a || w && f) this._basicSquare({ x: e, y: t, size: n, rotation: 0 });
861
+ else {
862
+ if (_ === 2) {
863
+ let m = 0;
864
+ return i && w ? m = Math.PI / 2 : w && a ? m = Math.PI : a && f && (m = -Math.PI / 2), void this._basicCornerExtraRounded({ x: e, y: t, size: n, rotation: m });
865
+ }
866
+ if (_ === 1) {
867
+ let m = 0;
868
+ return w ? m = Math.PI / 2 : a ? m = Math.PI : f && (m = -Math.PI / 2), void this._basicSideRounded({ x: e, y: t, size: n, rotation: m });
869
+ }
870
+ }
871
+ else this._basicDot({ x: e, y: t, size: n, rotation: 0 });
872
+ }
873
+ _drawClassy({ x: e, y: t, size: n, getNeighbor: r }) {
874
+ const i = r ? +r(-1, 0) : 0, a = r ? +r(1, 0) : 0, w = r ? +r(0, -1) : 0, f = r ? +r(0, 1) : 0;
875
+ i + a + w + f !== 0 ? i || w ? a || f ? this._basicSquare({ x: e, y: t, size: n, rotation: 0 }) : this._basicCornerRounded({ x: e, y: t, size: n, rotation: Math.PI / 2 }) : this._basicCornerRounded({ x: e, y: t, size: n, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: e, y: t, size: n, rotation: Math.PI / 2 });
876
+ }
877
+ _drawClassyRounded({ x: e, y: t, size: n, getNeighbor: r }) {
878
+ const i = r ? +r(-1, 0) : 0, a = r ? +r(1, 0) : 0, w = r ? +r(0, -1) : 0, f = r ? +r(0, 1) : 0;
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
+ }
881
+ }
882
+ const U = { dot: "dot", square: "square", extraRounded: "extra-rounded" }, G = Object.values(U);
883
+ class K {
884
+ constructor({ svg: e, type: t, window: n }) {
885
+ this._svg = e, this._type = t, this._window = n;
886
+ }
887
+ draw(e, t, n, r) {
888
+ let i;
889
+ switch (this._type) {
890
+ case U.square:
891
+ i = this._drawSquare;
892
+ break;
893
+ case U.extraRounded:
894
+ i = this._drawExtraRounded;
895
+ break;
896
+ default:
897
+ i = this._drawDot;
898
+ }
899
+ i.call(this, { x: e, y: t, size: n, rotation: r });
900
+ }
901
+ _rotateFigure({ x: e, y: t, size: n, rotation: r = 0, draw: i }) {
902
+ var a;
903
+ const w = e + n / 2, f = t + n / 2;
904
+ i(), (a = this._element) === null || a === void 0 || a.setAttribute("transform", `rotate(${180 * r / Math.PI},${w},${f})`);
905
+ }
906
+ _basicDot(e) {
907
+ const { size: t, x: n, y: r } = e, i = t / 7;
908
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
909
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${n + t / 2} ${r}a ${t / 2} ${t / 2} 0 1 0 0.1 0zm 0 ${i}a ${t / 2 - i} ${t / 2 - i} 0 1 1 -0.1 0Z`);
910
+ } }));
911
+ }
912
+ _basicSquare(e) {
913
+ const { size: t, x: n, y: r } = e, i = t / 7;
914
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
915
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${n} ${r}v ${t}h ${t}v ` + -t + `zM ${n + i} ${r + i}h ` + (t - 2 * i) + "v " + (t - 2 * i) + "h " + (2 * i - t) + "z");
916
+ } }));
917
+ }
918
+ _basicExtraRounded(e) {
919
+ const { size: t, x: n, y: r } = e, i = t / 7;
920
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
921
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${n} ${r + 2.5 * i}v ` + 2 * i + `a ${2.5 * i} ${2.5 * i}, 0, 0, 0, ${2.5 * i} ${2.5 * i}h ` + 2 * i + `a ${2.5 * i} ${2.5 * i}, 0, 0, 0, ${2.5 * i} ${2.5 * -i}v ` + -2 * i + `a ${2.5 * i} ${2.5 * i}, 0, 0, 0, ${2.5 * -i} ${2.5 * -i}h ` + -2 * i + `a ${2.5 * i} ${2.5 * i}, 0, 0, 0, ${2.5 * -i} ${2.5 * i}M ${n + 2.5 * i} ${r + i}h ` + 2 * i + `a ${1.5 * i} ${1.5 * i}, 0, 0, 1, ${1.5 * i} ${1.5 * i}v ` + 2 * i + `a ${1.5 * i} ${1.5 * i}, 0, 0, 1, ${1.5 * -i} ${1.5 * i}h ` + -2 * i + `a ${1.5 * i} ${1.5 * i}, 0, 0, 1, ${1.5 * -i} ${1.5 * -i}v ` + -2 * i + `a ${1.5 * i} ${1.5 * i}, 0, 0, 1, ${1.5 * i} ${1.5 * -i}`);
922
+ } }));
923
+ }
924
+ _drawDot({ x: e, y: t, size: n, rotation: r }) {
925
+ this._basicDot({ x: e, y: t, size: n, rotation: r });
926
+ }
927
+ _drawSquare({ x: e, y: t, size: n, rotation: r }) {
928
+ this._basicSquare({ x: e, y: t, size: n, rotation: r });
929
+ }
930
+ _drawExtraRounded({ x: e, y: t, size: n, rotation: r }) {
931
+ this._basicExtraRounded({ x: e, y: t, size: n, rotation: r });
932
+ }
933
+ }
934
+ const L = { dot: "dot", square: "square" }, R = Object.values(L);
935
+ class nt {
936
+ constructor({ svg: e, type: t, window: n }) {
937
+ this._svg = e, this._type = t, this._window = n;
938
+ }
939
+ draw(e, t, n, r) {
940
+ let i;
941
+ i = this._type === L.square ? this._drawSquare : this._drawDot, i.call(this, { x: e, y: t, size: n, rotation: r });
942
+ }
943
+ _rotateFigure({ x: e, y: t, size: n, rotation: r = 0, draw: i }) {
944
+ var a;
945
+ const w = e + n / 2, f = t + n / 2;
946
+ i(), (a = this._element) === null || a === void 0 || a.setAttribute("transform", `rotate(${180 * r / Math.PI},${w},${f})`);
947
+ }
948
+ _basicDot(e) {
949
+ const { size: t, x: n, y: r } = e;
950
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
951
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(n + t / 2)), this._element.setAttribute("cy", String(r + t / 2)), this._element.setAttribute("r", String(t / 2));
952
+ } }));
953
+ }
954
+ _basicSquare(e) {
955
+ const { size: t, x: n, y: r } = e;
956
+ this._rotateFigure(Object.assign(Object.assign({}, e), { draw: () => {
957
+ this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(n)), this._element.setAttribute("y", String(r)), this._element.setAttribute("width", String(t)), this._element.setAttribute("height", String(t));
958
+ } }));
959
+ }
960
+ _drawDot({ x: e, y: t, size: n, rotation: r }) {
961
+ this._basicDot({ x: e, y: t, size: n, rotation: r });
962
+ }
963
+ _drawSquare({ x: e, y: t, size: n, rotation: r }) {
964
+ this._basicSquare({ x: e, y: t, size: n, rotation: r });
965
+ }
966
+ }
967
+ const st = "circle", V = [[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]], J = [[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
+ class dt {
969
+ constructor(e, t) {
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;
971
+ }
972
+ get width() {
973
+ return this._options.width;
974
+ }
975
+ get height() {
976
+ return this._options.height;
977
+ }
978
+ getElement() {
979
+ return this._element;
980
+ }
981
+ async drawQR(e) {
982
+ const t = e.getModuleCount(), n = Math.min(this._options.width, this._options.height) - 2 * this._options.margin, r = this._options.shape === st ? n / Math.sqrt(2) : n, i = this._roundSize(r / t);
983
+ let a = { hideXDots: 0, hideYDots: 0, width: 0, height: 0 };
984
+ if (this._qr = e, this._options.image) {
985
+ if (await this.loadImage(), !this._image) return;
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: P, dotSize: $ }) {
988
+ const o = { x: 0, y: 0 }, h = { x: 0, y: 0 };
989
+ if (y <= 0 || v <= 0 || C <= 0 || $ <= 0) return { height: 0, width: 0, hideYDots: 0, hideXDots: 0 };
990
+ const s = y / v;
991
+ return o.x = Math.floor(Math.sqrt(C / s)), o.x <= 0 && (o.x = 1), P && P < o.x && (o.x = P), o.x % 2 == 0 && o.x--, h.x = o.x * $, o.y = 1 + 2 * Math.ceil((o.x * s - 1) / 2), h.y = Math.round(h.x * s), (o.y * o.x > C || P && P < o.y) && (P && P < o.y ? (o.y = P, o.y % 2 == 0 && o.x--) : o.y -= 2, h.y = o.y * $, 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
+ })({ originalWidth: this._image.width, originalHeight: this._image.height, maxHiddenDots: m, maxHiddenAxisDots: t - 14, dotSize: i });
993
+ }
994
+ this.drawBackground(), this.drawDots(((w, f) => {
995
+ var _, m, y, v, C, P;
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 || !((_ = V[w]) === null || _ === void 0) && _[f] || !((m = V[w - t + 7]) === null || m === void 0) && m[f] || !((y = V[w]) === null || y === void 0) && y[f - t + 7] || !((v = J[w]) === null || v === void 0) && v[f] || !((C = J[w - t + 7]) === null || C === void 0) && C[f] || !((P = J[w]) === null || P === void 0) && P[f - t + 7]);
997
+ })), this.drawCorners(), this._options.image && await this.drawImage({ width: a.width, height: a.height, count: t, dotSize: i });
998
+ }
999
+ drawBackground() {
1000
+ var e, t, n;
1001
+ const r = this._element, i = this._options;
1002
+ if (r) {
1003
+ const a = (e = i.backgroundOptions) === null || e === void 0 ? void 0 : e.gradient, w = (t = i.backgroundOptions) === null || t === void 0 ? void 0 : t.color;
1004
+ let f = i.height, _ = i.width;
1005
+ if (a || w) {
1006
+ const m = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect");
1007
+ this._backgroundClipPath = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), this._backgroundClipPath.setAttribute("id", `clip-path-background-color-${this._instanceId}`), this._defs.appendChild(this._backgroundClipPath), !((n = i.backgroundOptions) === null || n === void 0) && n.round && (f = _ = Math.min(i.width, i.height), m.setAttribute("rx", String(f / 2 * i.backgroundOptions.round))), m.setAttribute("x", String(this._roundSize((i.width - _) / 2))), m.setAttribute("y", String(this._roundSize((i.height - f) / 2))), m.setAttribute("width", String(_)), m.setAttribute("height", String(f)), this._backgroundClipPath.appendChild(m), this._createColor({ options: a, color: w, additionalRotation: 0, x: 0, y: 0, height: i.height, width: i.width, name: `background-color-${this._instanceId}` });
1008
+ }
1009
+ }
1010
+ }
1011
+ drawDots(e) {
1012
+ var t, n;
1013
+ if (!this._qr) throw "QR code is not defined";
1014
+ const r = this._options, i = this._qr.getModuleCount();
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 q({ svg: this._element, type: r.dotsOptions.type, window: this._window });
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, ((P, $) => !(C + P < 0 || v + $ < 0 || C + P >= i || v + $ >= i) && !(e && !e(v + $, C + P)) && !!this._qr && this._qr.isDark(v + $, C + P))), y._element && this._dotsClipPath && this._dotsClipPath.appendChild(y._element));
1019
+ if (r.shape === st) {
1020
+ const v = this._roundSize((a / f - i) / 2), C = i + 2 * v, P = _ - v * f, $ = m - v * f, o = [], h = this._roundSize(C / 2);
1021
+ for (let s = 0; s < C; s++) {
1022
+ o[s] = [];
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
+ }
1025
+ for (let s = 0; s < C; s++) for (let u = 0; u < C; u++) o[s][u] && (y.draw(P + u * f, $ + s * f, f, ((g, b) => {
1026
+ var O;
1027
+ return !!(!((O = o[s + b]) === null || O === void 0) && O[u + g]);
1028
+ })), y._element && this._dotsClipPath && this._dotsClipPath.appendChild(y._element));
1029
+ }
1030
+ }
1031
+ drawCorners() {
1032
+ if (!this._qr) throw "QR code is not defined";
1033
+ const e = this._element, t = this._options;
1034
+ if (!e) throw "Element code is not defined";
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
+ [[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach((([y, v, C]) => {
1037
+ var P, $, o, h, s, u, g, b, O, I, N, T, H, tt;
1038
+ const W = _ + y * a * (n - 7), X = m + v * a * (n - 7);
1039
+ let j = this._dotsClipPath, M = this._dotsClipPath;
1040
+ if ((!((P = t.cornersSquareOptions) === null || P === void 0) && P.gradient || !(($ = t.cornersSquareOptions) === null || $ === void 0) && $.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: W, y: X, height: w, width: w, name: `corners-square-color-${y}-${v}-${this._instanceId}` })), ((s = t.cornersSquareOptions) === null || s === void 0 ? void 0 : s.type) && G.includes(t.cornersSquareOptions.type)) {
1041
+ const Y = new K({ svg: this._element, type: t.cornersSquareOptions.type, window: this._window });
1042
+ Y.draw(W, X, w, C), Y._element && j && j.appendChild(Y._element);
1043
+ } else {
1044
+ const Y = new q({ svg: this._element, type: ((u = t.cornersSquareOptions) === null || u === void 0 ? void 0 : u.type) || t.dotsOptions.type, window: this._window });
1045
+ for (let Z = 0; Z < V.length; Z++) for (let k = 0; k < V[Z].length; k++) !((g = V[Z]) === null || g === void 0) && g[k] && (Y.draw(W + k * a, X + Z * a, a, ((ot, rt) => {
1046
+ var et;
1047
+ return !!(!((et = V[Z + rt]) === null || et === void 0) && et[k + ot]);
1048
+ })), Y._element && j && j.appendChild(Y._element));
1049
+ }
1050
+ if ((!((b = t.cornersDotOptions) === null || b === void 0) && b.gradient || !((O = t.cornersDotOptions) === null || O === void 0) && O.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: (N = t.cornersDotOptions) === null || N === void 0 ? void 0 : N.color, additionalRotation: C, x: W + 2 * a, y: X + 2 * a, height: f, width: f, name: `corners-dot-color-${y}-${v}-${this._instanceId}` })), ((T = t.cornersDotOptions) === null || T === void 0 ? void 0 : T.type) && R.includes(t.cornersDotOptions.type)) {
1051
+ const Y = new nt({ svg: this._element, type: t.cornersDotOptions.type, window: this._window });
1052
+ Y.draw(W + 2 * a, X + 2 * a, f, C), Y._element && M && M.appendChild(Y._element);
1053
+ } else {
1054
+ const Y = new q({ svg: this._element, type: ((H = t.cornersDotOptions) === null || H === void 0 ? void 0 : H.type) || t.dotsOptions.type, window: this._window });
1055
+ for (let Z = 0; Z < J.length; Z++) for (let k = 0; k < J[Z].length; k++) !((tt = J[Z]) === null || tt === void 0) && tt[k] && (Y.draw(W + k * a, X + Z * a, a, ((ot, rt) => {
1056
+ var et;
1057
+ return !!(!((et = J[Z + rt]) === null || et === void 0) && et[k + ot]);
1058
+ })), Y._element && M && M.appendChild(Y._element));
1059
+ }
1060
+ }));
1061
+ }
1062
+ loadImage() {
1063
+ return new Promise(((e, t) => {
1064
+ var n;
1065
+ const r = this._options;
1066
+ if (!r.image) return t("Image is not defined");
1067
+ if (!((n = r.nodeCanvas) === null || n === void 0) && n.loadImage) r.nodeCanvas.loadImage(r.image).then(((i) => {
1068
+ var a, w;
1069
+ if (this._image = i, this._options.imageOptions.saveAsBlob) {
1070
+ const f = (a = r.nodeCanvas) === null || a === void 0 ? void 0 : a.createCanvas(this._image.width, this._image.height);
1071
+ (w = f == null ? void 0 : f.getContext("2d")) === null || w === void 0 || w.drawImage(i, 0, 0), this._imageUri = f == null ? void 0 : f.toDataURL();
1072
+ }
1073
+ e();
1074
+ })).catch(t);
1075
+ else {
1076
+ const i = new this._window.Image();
1077
+ typeof r.imageOptions.crossOrigin == "string" && (i.crossOrigin = r.imageOptions.crossOrigin), this._image = i, i.onload = async () => {
1078
+ this._options.imageOptions.saveAsBlob && (this._imageUri = await (async function(a, w) {
1079
+ return new Promise(((f) => {
1080
+ const _ = new w.XMLHttpRequest();
1081
+ _.onload = function() {
1082
+ const m = new w.FileReader();
1083
+ m.onloadend = function() {
1084
+ f(m.result);
1085
+ }, m.readAsDataURL(_.response);
1086
+ }, _.open("GET", a), _.responseType = "blob", _.send();
1087
+ }));
1088
+ })(r.image || "", this._window)), e();
1089
+ }, i.src = r.image;
1090
+ }
1091
+ }));
1092
+ }
1093
+ async drawImage({ width: e, height: t, count: n, dotSize: r }) {
1094
+ const i = this._options, a = this._roundSize((i.width - n * r) / 2), w = this._roundSize((i.height - n * r) / 2), f = a + this._roundSize(i.imageOptions.margin + (n * r - e) / 2), _ = w + this._roundSize(i.imageOptions.margin + (n * r - t) / 2), m = e - 2 * i.imageOptions.margin, y = t - 2 * i.imageOptions.margin, v = this._window.document.createElementNS("http://www.w3.org/2000/svg", "image");
1095
+ v.setAttribute("href", this._imageUri || ""), v.setAttribute("xlink:href", this._imageUri || ""), v.setAttribute("x", String(f)), v.setAttribute("y", String(_)), v.setAttribute("width", `${m}px`), v.setAttribute("height", `${y}px`), this._element.appendChild(v);
1096
+ }
1097
+ _createColor({ options: e, color: t, additionalRotation: n, x: r, y: i, height: a, width: w, name: f }) {
1098
+ const _ = w > a ? w : a, m = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect");
1099
+ if (m.setAttribute("x", String(r)), m.setAttribute("y", String(i)), m.setAttribute("height", String(a)), m.setAttribute("width", String(w)), m.setAttribute("clip-path", `url('#clip-path-${f}')`), e) {
1100
+ let y;
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
+ else {
1103
+ const v = ((e.rotation || 0) + n) % (2 * Math.PI), C = (v + 2 * Math.PI) % (2 * Math.PI);
1104
+ let P = r + w / 2, $ = 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 ? (P -= w / 2, $ -= a / 2 * Math.tan(v), o += w / 2, h += a / 2 * Math.tan(v)) : C > 0.25 * Math.PI && C <= 0.75 * Math.PI ? ($ -= a / 2, P -= w / 2 / Math.tan(v), h += a / 2, o += w / 2 / Math.tan(v)) : C > 0.75 * Math.PI && C <= 1.25 * Math.PI ? (P += w / 2, $ += a / 2 * Math.tan(v), o -= w / 2, h -= a / 2 * Math.tan(v)) : C > 1.25 * Math.PI && C <= 1.75 * Math.PI && ($ += a / 2, P += 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(P))), y.setAttribute("y1", String(Math.round($))), y.setAttribute("x2", String(Math.round(o))), y.setAttribute("y2", String(Math.round(h)));
1106
+ }
1107
+ e.colorStops.forEach((({ offset: v, color: C }) => {
1108
+ const P = this._window.document.createElementNS("http://www.w3.org/2000/svg", "stop");
1109
+ P.setAttribute("offset", 100 * v + "%"), P.setAttribute("stop-color", C), y.appendChild(P);
1110
+ })), m.setAttribute("fill", `url('#${f}')`), this._defs.appendChild(y);
1111
+ } else t && m.setAttribute("fill", t);
1112
+ this._element.appendChild(m);
1113
+ }
1114
+ }
1115
+ dt.instanceCount = 0;
1116
+ const ft = dt, ut = "canvas", wt = {};
1117
+ for (let d = 0; d <= 40; d++) wt[d] = d;
1118
+ const mt = { type: ut, shape: "square", width: 300, height: 300, data: "", margin: 0, qrOptions: { typeNumber: wt[0], mode: void 0, errorCorrectionLevel: "Q" }, imageOptions: { saveAsBlob: !0, hideBackgroundDots: !0, imageSize: 0.4, crossOrigin: void 0, margin: 0 }, dotsOptions: { type: "square", color: "#000", roundSize: !0 }, backgroundOptions: { round: 0, color: "#fff" } };
1119
+ function ct(d) {
1120
+ const e = Object.assign({}, d);
1121
+ if (!e.colorStops || !e.colorStops.length) throw "Field 'colorStops' is required in gradient";
1122
+ return e.rotation ? e.rotation = Number(e.rotation) : e.rotation = 0, e.colorStops = e.colorStops.map(((t) => Object.assign(Object.assign({}, t), { offset: Number(t.offset) }))), e;
1123
+ }
1124
+ function vt(d) {
1125
+ const e = Object.assign({}, d);
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
+ }
1128
+ var _t = E(873), Ct = E.n(_t);
1129
+ function lt(d) {
1130
+ if (!d) throw new Error("Extension must be defined");
1131
+ d[0] === "." && (d = d.substring(1));
1132
+ const e = { bmp: "image/bmp", gif: "image/gif", ico: "image/vnd.microsoft.icon", jpeg: "image/jpeg", jpg: "image/jpeg", png: "image/png", svg: "image/svg+xml", tif: "image/tiff", tiff: "image/tiff", webp: "image/webp", pdf: "application/pdf" }[d.toLowerCase()];
1133
+ if (!e) throw new Error(`Extension "${d}" is not supported`);
1134
+ return e;
1135
+ }
1136
+ class p {
1137
+ constructor(e) {
1138
+ e != null && e.jsdom ? this._window = new e.jsdom("", { resources: "usable" }).window : this._window = window, this._options = e ? vt(x(mt, e)) : mt, this.update();
1139
+ }
1140
+ static _clearContainer(e) {
1141
+ e && (e.innerHTML = "");
1142
+ }
1143
+ _setupSvg() {
1144
+ if (!this._qr) return;
1145
+ const e = new ft(this._options, this._window);
1146
+ this._svg = e.getElement(), this._svgDrawingPromise = e.drawQR(this._qr).then((() => {
1147
+ var t;
1148
+ this._svg && ((t = this._extension) === null || t === void 0 || t.call(this, e.getElement(), this._options));
1149
+ }));
1150
+ }
1151
+ _setupCanvas() {
1152
+ var e, t;
1153
+ this._qr && (!((e = this._options.nodeCanvas) === null || e === void 0) && e.createCanvas ? (this._nodeCanvas = this._options.nodeCanvas.createCanvas(this._options.width, this._options.height), this._nodeCanvas.width = this._options.width, this._nodeCanvas.height = this._options.height) : (this._domCanvas = document.createElement("canvas"), this._domCanvas.width = this._options.width, this._domCanvas.height = this._options.height), this._setupSvg(), this._canvasDrawingPromise = (t = this._svgDrawingPromise) === null || t === void 0 ? void 0 : t.then((() => {
1154
+ var n;
1155
+ if (!this._svg) return;
1156
+ const r = this._svg, i = new this._window.XMLSerializer().serializeToString(r), a = btoa(i), w = `data:${lt("svg")};base64,${a}`;
1157
+ if (!((n = this._options.nodeCanvas) === null || n === void 0) && n.loadImage) return this._options.nodeCanvas.loadImage(w).then(((f) => {
1158
+ var _, m;
1159
+ f.width = this._options.width, f.height = this._options.height, (m = (_ = this._nodeCanvas) === null || _ === void 0 ? void 0 : _.getContext("2d")) === null || m === void 0 || m.drawImage(f, 0, 0);
1160
+ }));
1161
+ {
1162
+ const f = new this._window.Image();
1163
+ return new Promise(((_) => {
1164
+ f.onload = () => {
1165
+ var m, y;
1166
+ (y = (m = this._domCanvas) === null || m === void 0 ? void 0 : m.getContext("2d")) === null || y === void 0 || y.drawImage(f, 0, 0), _();
1167
+ }, f.src = w;
1168
+ }));
1169
+ }
1170
+ })));
1171
+ }
1172
+ async _getElement(e = "png") {
1173
+ if (!this._qr) throw "QR code is empty";
1174
+ return e.toLowerCase() === "svg" ? (this._svg && this._svgDrawingPromise || this._setupSvg(), await this._svgDrawingPromise, this._svg) : ((this._domCanvas || this._nodeCanvas) && this._canvasDrawingPromise || this._setupCanvas(), await this._canvasDrawingPromise, this._domCanvas || this._nodeCanvas);
1175
+ }
1176
+ update(e) {
1177
+ p._clearContainer(this._container), this._options = e ? vt(x(this._options, e)) : this._options, this._options.data && (this._qr = Ct()(this._options.qrOptions.typeNumber, this._options.qrOptions.errorCorrectionLevel), this._qr.addData(this._options.data, this._options.qrOptions.mode || (function(t) {
1178
+ switch (!0) {
1179
+ case /^[0-9]*$/.test(t):
1180
+ return "Numeric";
1181
+ case /^[0-9A-Z $%*+\-./:]*$/.test(t):
1182
+ return "Alphanumeric";
1183
+ default:
1184
+ return "Byte";
1185
+ }
1186
+ })(this._options.data)), this._qr.make(), this._options.type === ut ? this._setupCanvas() : this._setupSvg(), this.append(this._container));
1187
+ }
1188
+ append(e) {
1189
+ if (e) {
1190
+ if (typeof e.appendChild != "function") throw "Container should be a single DOM node";
1191
+ this._options.type === ut ? this._domCanvas && e.appendChild(this._domCanvas) : this._svg && e.appendChild(this._svg), this._container = e;
1192
+ }
1193
+ }
1194
+ applyExtension(e) {
1195
+ if (!e) throw "Extension function should be defined.";
1196
+ this._extension = e, this.update();
1197
+ }
1198
+ deleteExtension() {
1199
+ this._extension = void 0, this.update();
1200
+ }
1201
+ async getRawData(e = "png") {
1202
+ if (!this._qr) throw "QR code is empty";
1203
+ const t = await this._getElement(e), n = lt(e);
1204
+ if (!t) return null;
1205
+ if (e.toLowerCase() === "svg") {
1206
+ const r = `<?xml version="1.0" standalone="no"?>\r
1207
+ ${new this._window.XMLSerializer().serializeToString(t)}`;
1208
+ return typeof Blob > "u" || this._options.jsdom ? Buffer.from(r) : new Blob([r], { type: n });
1209
+ }
1210
+ return new Promise(((r) => {
1211
+ const i = t;
1212
+ if ("toBuffer" in i) if (n === "image/png") r(i.toBuffer(n));
1213
+ else if (n === "image/jpeg") r(i.toBuffer(n));
1214
+ else {
1215
+ if (n !== "application/pdf") throw Error("Unsupported extension");
1216
+ r(i.toBuffer(n));
1217
+ }
1218
+ else "toBlob" in i && i.toBlob(r, n, 1);
1219
+ }));
1220
+ }
1221
+ async download(e) {
1222
+ if (!this._qr) throw "QR code is empty";
1223
+ if (typeof Blob > "u") throw "Cannot download in Node.js, call getRawData instead.";
1224
+ let t = "png", n = "qr";
1225
+ typeof e == "string" ? (t = e, console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")) : typeof e == "object" && e !== null && (e.name && (n = e.name), e.extension && (t = e.extension));
1226
+ const r = await this._getElement(t);
1227
+ if (r) if (t.toLowerCase() === "svg") {
1228
+ let i = new XMLSerializer().serializeToString(r);
1229
+ i = `<?xml version="1.0" standalone="no"?>\r
1230
+ ` + i, B(`data:${lt(t)};charset=utf-8,${encodeURIComponent(i)}`, `${n}.svg`);
1231
+ } else B(r.toDataURL(lt(t)), `${n}.${t}`);
1232
+ }
1233
+ }
1234
+ const l = p;
1235
+ })(), Q.default;
1236
+ })()));
1237
+ })(xt)), xt.exports;
1238
+ }
1239
+ var jt = Tt();
1240
+ const Ft = /* @__PURE__ */ Lt(jt), Ut = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADgAAAA4BAMAAABaqCYtAAAAMFBMVEUKfmT+//8Bd1tSpJAginI7l4OgzcNxl0BjrZyQxbl6uas6ilTr9fOz18/R5+KbojH3wCiYAAAACXBIWXMAAAsTAAALEwEAmpwYAAABYklEQVR42mNgGKZACY+UggsTTqmIaWkZOGQjpmWZMHilKjCwBmHIuWWZKCkwKIVNUVJdhC7HNAMoBTLcdmnnBQydE0AyQAUKna2TFdB1TlVQUnBdZQQ0WSkSQzI2JGJazuJpDkA2pwO6sapps0yslJRTgEwtIwwXKSgpdSiAvak6CZtX3SBBoDQFm6TyVQVQSAU/VsAiyQQMAmAgZnVik+QusF0xbVaIkhY2Y+u3K3SFKClgDXrucu4CHFJAye8bCnBGNnt1QTVOye3/8Uiy19fjMXb79g04Jbm/45ZkUir/jlPONTTYBEg7YJNkEwSCJgaWd9g0JoIkLzHoCmKmTAYtkJxgEtNCLJIuNkCpM2eMlAVlMeRUzwDl5FwclHwEj2AEvTLITKAelouCRgxYJQXPvXsjKKmAQxIELjDglpRxwiMprIBHchEDbklZrMFubGxs0dHRYYC9RIAABYZRQAoAAMPFUF7XIspMAAAAAElFTkSuQmCC";
1241
+ function ht(c, A) {
1242
+ Object.entries(A).forEach(([z, D]) => {
1243
+ c.style[z] = D;
1244
+ });
1245
+ }
1246
+ function Ot(c) {
1247
+ if (c.startsWith("#"))
1248
+ return c;
1249
+ if (c.startsWith("rgb")) {
1250
+ const A = c.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)/);
1251
+ if (A) {
1252
+ const z = parseInt(A[1]).toString(16).padStart(2, "0"), D = parseInt(A[2]).toString(16).padStart(2, "0"), E = parseInt(A[3]).toString(16).padStart(2, "0");
1253
+ return `#${z}${D}${E}`;
1254
+ }
1255
+ }
1256
+ if (c.startsWith("hsl")) {
1257
+ const A = c.match(/hsla?\((\d+),\s*(\d+)%,\s*(\d+)%/);
1258
+ if (A) {
1259
+ const z = parseInt(A[1]) / 360, D = parseInt(A[2]) / 100, E = parseInt(A[3]) / 100;
1260
+ let Q, S, x;
1261
+ if (D === 0)
1262
+ Q = S = x = E;
1263
+ else {
1264
+ const F = (G, K, L) => (L < 0 && (L += 1), L > 1 && (L -= 1), L < 0.16666666666666666 ? G + (K - G) * 6 * L : L < 0.5 ? K : L < 0.6666666666666666 ? G + (K - G) * (0.6666666666666666 - L) * 6 : G), q = E < 0.5 ? E * (1 + D) : E + D - E * D, U = 2 * E - q;
1265
+ Q = F(U, q, z + 1 / 3), S = F(U, q, z), x = F(U, q, z - 1 / 3);
1266
+ }
1267
+ const B = (F) => Math.round(F * 255).toString(16).padStart(2, "0");
1268
+ return `#${B(Q)}${B(S)}${B(x)}`;
1269
+ }
1270
+ }
1271
+ return c;
1272
+ }
1273
+ function Qt(c, A, z) {
1274
+ const D = document.createElement("div");
1275
+ D.className = "drop-payment-link", ht(D, {
1276
+ marginTop: "16px",
1277
+ width: `${A}px`
1278
+ });
1279
+ const E = document.createElement("label");
1280
+ E.className = "drop-link-label", E.textContent = z, ht(E, {
1281
+ display: "block",
1282
+ fontSize: "14px",
1283
+ fontWeight: "500",
1284
+ color: "hsl(160, 65%, 25%)",
1285
+ marginBottom: "8px",
1286
+ fontFamily: "system-ui, -apple-system, sans-serif"
1287
+ });
1288
+ const Q = document.createElement("div");
1289
+ Q.className = "drop-link-input-wrapper", ht(Q, {
1290
+ position: "relative"
1291
+ });
1292
+ const S = document.createElement("input");
1293
+ S.type = "text", S.readOnly = !0, S.value = c, S.className = "drop-link-input", S.setAttribute("aria-label", "Payment link");
1294
+ const x = document.createElement("p");
1295
+ x.className = "drop-link-hint", x.textContent = "Tap to copy", ht(x, {
1296
+ fontSize: "12px",
1297
+ color: "hsl(160, 30%, 40%)",
1298
+ marginTop: "6px",
1299
+ marginBottom: "0",
1300
+ fontFamily: "system-ui, -apple-system, sans-serif"
1301
+ });
1302
+ const B = async () => {
1303
+ S.select();
1304
+ try {
1305
+ navigator.clipboard && navigator.clipboard.writeText ? (await navigator.clipboard.writeText(c), F()) : document.execCommand("copy") && F();
1306
+ } catch {
1307
+ document.execCommand("copy"), F();
1308
+ }
1309
+ }, F = () => {
1310
+ const q = x.textContent;
1311
+ x.textContent = "✓ Copied to clipboard!", ht(x, {
1312
+ color: "hsl(160, 65%, 35%)",
1313
+ fontWeight: "500"
1314
+ }), setTimeout(() => {
1315
+ x.textContent = q, ht(x, {
1316
+ color: "hsl(160, 30%, 40%)",
1317
+ fontWeight: "normal"
1318
+ });
1319
+ }, 2e3);
1320
+ };
1321
+ return S.addEventListener("click", B), S.addEventListener("keydown", (q) => {
1322
+ (q.key === "Enter" || q.key === " ") && (q.preventDefault(), B());
1323
+ }), ht(S, {
1324
+ width: "100%",
1325
+ padding: "12px",
1326
+ fontSize: "14px",
1327
+ fontFamily: "monospace",
1328
+ border: "2px solid hsl(160, 65%, 25%)",
1329
+ borderRadius: "8px",
1330
+ backgroundColor: "hsl(0, 0%, 98%)",
1331
+ color: "hsl(160, 65%, 25%)",
1332
+ boxSizing: "border-box",
1333
+ cursor: "pointer",
1334
+ outline: "none"
1335
+ }), S.addEventListener("focus", () => {
1336
+ ht(S, {
1337
+ borderColor: "hsl(160, 65%, 35%)",
1338
+ backgroundColor: "hsl(160, 80%, 98%)"
1339
+ });
1340
+ }), S.addEventListener("blur", () => {
1341
+ ht(S, {
1342
+ borderColor: "hsl(160, 65%, 25%)",
1343
+ backgroundColor: "hsl(0, 0%, 98%)"
1344
+ });
1345
+ }), Q.appendChild(S), D.appendChild(E), D.appendChild(Q), D.appendChild(x), D;
1346
+ }
1347
+ async function Ht(c, A, z, D = {}) {
1348
+ const {
1349
+ moduleColor: E = "hsl(160, 65%, 25%)",
1350
+ backgroundColor: Q = "hsl(0, 0%, 98%)",
1351
+ cornerRadius: S = 0,
1352
+ showCopyableLink: x = !0,
1353
+ linkText: B = "Or paste this link:"
1354
+ } = D, F = Ot(E), q = Ot(Q), U = Math.sqrt(0.18), G = Math.round(z * 0.03), K = new Ft({
1355
+ width: z,
1356
+ height: z,
1357
+ type: "svg",
1358
+ data: A,
1359
+ image: Ut,
1360
+ qrOptions: {
1361
+ errorCorrectionLevel: "H"
1362
+ },
1363
+ dotsOptions: {
1364
+ color: F,
1365
+ type: S > 0 ? "rounded" : "square"
1366
+ },
1367
+ backgroundOptions: {
1368
+ color: q
1369
+ },
1370
+ imageOptions: {
1371
+ hideBackgroundDots: !0,
1372
+ imageSize: U,
1373
+ margin: G
1374
+ }
1375
+ }), L = document.createElement("div");
1376
+ L.className = "drop-payment-widget", K.append(L);
1377
+ const R = L.querySelector("svg");
1378
+ if (R && (R.setAttribute("role", "img"), R.setAttribute("aria-label", "Payment QR Code")), x) {
1379
+ const nt = Qt(A, z, B);
1380
+ L.appendChild(nt);
1381
+ }
1382
+ c.innerHTML = "", c.appendChild(L);
1383
+ }
1384
+ class it extends Error {
1385
+ constructor(A) {
1386
+ super(A), this.name = "ValidationError";
1387
+ }
1388
+ }
1389
+ function Xt(c) {
1390
+ Yt(c.clientSecret), c.qrSize !== void 0 && Wt(c.qrSize), c.pollingInterval !== void 0 && Kt(c.pollingInterval), c.qrOptions && Vt(c.qrOptions), c.linkText !== void 0 && Zt(c.linkText), Gt(c);
1391
+ }
1392
+ function Yt(c) {
1393
+ if (!c || c.trim() === "")
1394
+ throw new it("clientSecret is required and cannot be empty");
1395
+ if (c.length < 10)
1396
+ throw new it(
1397
+ `clientSecret must be at least 10 characters long. Received length: ${c.length}`
1398
+ );
1399
+ if (!c.startsWith("pi_secret_"))
1400
+ throw new it(
1401
+ "clientSecret must start with 'pi_secret_'. Received: " + c.substring(0, 10) + "..."
1402
+ );
1403
+ }
1404
+ function Wt(c) {
1405
+ if (typeof c != "number" || isNaN(c) || !isFinite(c))
1406
+ throw new it(`qrSize must be a valid number. Received: ${c}`);
1407
+ if (c < 128 || c > 1024)
1408
+ throw new it(
1409
+ `QR size must be between 128 and 1024 pixels. Received: ${c}`
1410
+ );
1411
+ }
1412
+ function Kt(c) {
1413
+ if (typeof c != "number" || isNaN(c) || !isFinite(c))
1414
+ throw new it(`pollingInterval must be a valid number. Received: ${c}`);
1415
+ if (c < 1e3 || c > 6e4)
1416
+ throw new it(
1417
+ `pollingInterval must be between 1000 and 60000 milliseconds. Received: ${c}`
1418
+ );
1419
+ }
1420
+ function Vt(c) {
1421
+ c && (c.cornerRadius !== void 0 && Jt(c.cornerRadius), c.moduleColor !== void 0 && kt(c.moduleColor, "moduleColor"), c.backgroundColor !== void 0 && kt(c.backgroundColor, "backgroundColor"));
1422
+ }
1423
+ function Jt(c) {
1424
+ if (typeof c != "number" || isNaN(c) || !isFinite(c))
1425
+ throw new it(`cornerRadius must be a valid number. Received: ${c}`);
1426
+ if (c < 0 || c > 1)
1427
+ throw new it(
1428
+ `cornerRadius must be between 0 and 1. Received: ${c}`
1429
+ );
1430
+ }
1431
+ function kt(c, A) {
1432
+ if (typeof c != "string")
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})$/, D = /^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/, E = /^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
+ let x = z.test(c);
1436
+ if (!x) {
1437
+ const B = c.match(D);
1438
+ if (B) {
1439
+ const [, F, q, U] = B;
1440
+ x = parseInt(F) <= 255 && parseInt(q) <= 255 && parseInt(U) <= 255;
1441
+ }
1442
+ }
1443
+ if (!x) {
1444
+ const B = c.match(E);
1445
+ if (B) {
1446
+ const [, F, q, U] = B;
1447
+ x = parseInt(F) <= 255 && parseInt(q) <= 255 && parseInt(U) <= 255;
1448
+ }
1449
+ }
1450
+ if (!x) {
1451
+ const B = c.match(Q);
1452
+ if (B) {
1453
+ const [, F, q, U] = B;
1454
+ x = parseInt(F) <= 360 && parseInt(q) <= 100 && parseInt(U) <= 100;
1455
+ }
1456
+ }
1457
+ if (!x) {
1458
+ const B = c.match(S);
1459
+ if (B) {
1460
+ const [, F, q, U] = B;
1461
+ x = parseInt(F) <= 360 && parseInt(q) <= 100 && parseInt(U) <= 100;
1462
+ }
1463
+ }
1464
+ if (!x)
1465
+ throw new it(
1466
+ `${A} must be a valid color format (hex, rgb, rgba, hsl, or hsla). Received: ${c}`
1467
+ );
1468
+ }
1469
+ function Zt(c) {
1470
+ if (typeof c != "string")
1471
+ throw new it(`linkText must be a string. Received: ${typeof c}`);
1472
+ if (c.length > 100)
1473
+ throw new it(
1474
+ `linkText must be 100 characters or less. Received length: ${c.length}`
1475
+ );
1476
+ }
1477
+ function Gt(c) {
1478
+ if (c.onStatusChange !== void 0 && typeof c.onStatusChange != "function")
1479
+ throw new it(
1480
+ `onStatusChange must be a function if provided. Received: ${typeof c.onStatusChange}`
1481
+ );
1482
+ if (c.onError !== void 0 && typeof c.onError != "function")
1483
+ throw new it(
1484
+ `onError must be a function if provided. Received: ${typeof c.onError}`
1485
+ );
1486
+ if (c.onPoll !== void 0 && typeof c.onPoll != "function")
1487
+ throw new it(
1488
+ `onPoll must be a function if provided. Received: ${typeof c.onPoll}`
1489
+ );
1490
+ }
1491
+ const te = 256;
1492
+ function ee(c) {
1493
+ const A = c.split("?")[0].split("#")[0], z = c.includes("?") ? c.substring(c.indexOf("?")) : "", D = /\/payment-accounts\/([^/]+)\/payment-intents\/([^/]+)/, E = A.match(D);
1494
+ if (!E)
1495
+ throw new Error(
1496
+ "Invalid instanceUrl format. Expected: .../payment-accounts/{id}/payment-intents/{id}"
1497
+ );
1498
+ const Q = E[1], S = E[2], x = A.substring(
1499
+ 0,
1500
+ A.indexOf("/payment-accounts/")
1501
+ );
1502
+ return { paymentAccountId: Q, paymentIntentId: S, apiBaseUrl: x, queryString: z };
1503
+ }
1504
+ const ie = {
1505
+ async create(c) {
1506
+ Xt(c);
1507
+ const {
1508
+ clientSecret: A,
1509
+ instanceUrl: z,
1510
+ containerId: D,
1511
+ qrSize: E = te,
1512
+ pollingInterval: Q,
1513
+ onStatusChange: S,
1514
+ onError: x,
1515
+ onPoll: B
1516
+ } = c, F = document.getElementById(D);
1517
+ if (!F)
1518
+ throw new Error(`Element with id "${D}" not found.`);
1519
+ const { paymentAccountId: q, paymentIntentId: U, apiBaseUrl: G, queryString: K } = ee(z), L = c.apiBaseUrl || G, { qrOptions: R, showCopyableLink: nt, linkText: st } = c;
1520
+ await Ht(F, z, E, {
1521
+ ...R,
1522
+ showCopyableLink: nt,
1523
+ linkText: st
1524
+ });
1525
+ const V = new qt({
1526
+ apiBaseUrl: L,
1527
+ paymentAccountId: q,
1528
+ paymentIntentId: U,
1529
+ clientSecret: A,
1530
+ queryString: K,
1531
+ pollingInterval: Q,
1532
+ onStatusChange: (J) => {
1533
+ S == null || S(J);
1534
+ },
1535
+ onError: (J) => {
1536
+ x == null || x(J);
1537
+ },
1538
+ onPoll: () => {
1539
+ B == null || B();
1540
+ }
1541
+ });
1542
+ return V.start(), {
1543
+ destroy() {
1544
+ V.stop(), F.innerHTML = "";
1545
+ },
1546
+ getStatus() {
1547
+ return V.getStatus();
1548
+ }
1549
+ };
1550
+ }
1551
+ };
1552
+ export {
1553
+ ie as Drop,
1554
+ it as ValidationError,
1555
+ Ht as renderQR
1556
+ };
1557
+ //# sourceMappingURL=drop.js.map