@unifold/connect-react 0.1.40 → 0.1.42
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/README.md +4 -0
- package/dist/index.d.mts +63 -4
- package/dist/index.d.ts +63 -4
- package/dist/index.js +2713 -725
- package/dist/index.mjs +2721 -730
- package/dist/styles-base.css +1 -1
- package/dist/styles.css +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -34,69 +34,69 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
var require_qr_code_styling = __commonJS({
|
|
35
35
|
"../../node_modules/.pnpm/qr-code-styling@1.9.2/node_modules/qr-code-styling/lib/qr-code-styling.js"(exports2, module2) {
|
|
36
36
|
"use strict";
|
|
37
|
-
!(function(
|
|
38
|
-
"object" == typeof exports2 && "object" == typeof module2 ? module2.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports2 ? exports2.QRCodeStyling = e() :
|
|
37
|
+
!(function(t11, e) {
|
|
38
|
+
"object" == typeof exports2 && "object" == typeof module2 ? module2.exports = e() : "function" == typeof define && define.amd ? define([], e) : "object" == typeof exports2 ? exports2.QRCodeStyling = e() : t11.QRCodeStyling = e();
|
|
39
39
|
})(exports2, (() => (() => {
|
|
40
|
-
var
|
|
40
|
+
var t11 = { 873: (t12, e2) => {
|
|
41
41
|
var i2, r3, n = (function() {
|
|
42
|
-
var
|
|
43
|
-
var i4 =
|
|
44
|
-
n3 = (function(
|
|
45
|
-
for (var e6 = new Array(
|
|
46
|
-
e6[i5] = new Array(
|
|
47
|
-
for (var r6 = 0; r6 <
|
|
42
|
+
var t13 = function(t14, e4) {
|
|
43
|
+
var i4 = t14, r5 = s[e4], n3 = null, o2 = 0, h2 = null, p2 = [], v2 = {}, m = function(t15, e5) {
|
|
44
|
+
n3 = (function(t16) {
|
|
45
|
+
for (var e6 = new Array(t16), i5 = 0; i5 < t16; i5 += 1) {
|
|
46
|
+
e6[i5] = new Array(t16);
|
|
47
|
+
for (var r6 = 0; r6 < t16; r6 += 1) e6[i5][r6] = null;
|
|
48
48
|
}
|
|
49
49
|
return e6;
|
|
50
|
-
})(o2 = 4 * i4 + 17), b(0, 0), b(o2 - 7, 0), b(0, o2 - 7), x(), y(), C(
|
|
51
|
-
}, b = function(
|
|
52
|
-
for (var i5 = -1; i5 <= 7; i5 += 1) if (!(
|
|
50
|
+
})(o2 = 4 * i4 + 17), b(0, 0), b(o2 - 7, 0), b(0, o2 - 7), x(), y(), C(t15, e5), i4 >= 7 && S(t15), null == h2 && (h2 = M(i4, r5, p2)), A(h2, e5);
|
|
51
|
+
}, b = function(t15, e5) {
|
|
52
|
+
for (var i5 = -1; i5 <= 7; i5 += 1) if (!(t15 + i5 <= -1 || o2 <= t15 + i5)) for (var r6 = -1; r6 <= 7; r6 += 1) e5 + r6 <= -1 || o2 <= e5 + r6 || (n3[t15 + i5][e5 + r6] = 0 <= i5 && i5 <= 6 && (0 == r6 || 6 == r6) || 0 <= r6 && r6 <= 6 && (0 == i5 || 6 == i5) || 2 <= i5 && i5 <= 4 && 2 <= r6 && r6 <= 4);
|
|
53
53
|
}, y = function() {
|
|
54
|
-
for (var
|
|
54
|
+
for (var t15 = 8; t15 < o2 - 8; t15 += 1) null == n3[t15][6] && (n3[t15][6] = t15 % 2 == 0);
|
|
55
55
|
for (var e5 = 8; e5 < o2 - 8; e5 += 1) null == n3[6][e5] && (n3[6][e5] = e5 % 2 == 0);
|
|
56
56
|
}, x = function() {
|
|
57
|
-
for (var
|
|
58
|
-
var o3 =
|
|
57
|
+
for (var t15 = a.getPatternPosition(i4), e5 = 0; e5 < t15.length; e5 += 1) for (var r6 = 0; r6 < t15.length; r6 += 1) {
|
|
58
|
+
var o3 = t15[e5], s2 = t15[r6];
|
|
59
59
|
if (null == n3[o3][s2]) for (var h3 = -2; h3 <= 2; h3 += 1) for (var d2 = -2; d2 <= 2; d2 += 1) n3[o3 + h3][s2 + d2] = -2 == h3 || 2 == h3 || -2 == d2 || 2 == d2 || 0 == h3 && 0 == d2;
|
|
60
60
|
}
|
|
61
|
-
}, S = function(
|
|
61
|
+
}, S = function(t15) {
|
|
62
62
|
for (var e5 = a.getBCHTypeNumber(i4), r6 = 0; r6 < 18; r6 += 1) {
|
|
63
|
-
var s2 = !
|
|
63
|
+
var s2 = !t15 && 1 == (e5 >> r6 & 1);
|
|
64
64
|
n3[Math.floor(r6 / 3)][r6 % 3 + o2 - 8 - 3] = s2;
|
|
65
65
|
}
|
|
66
|
-
for (r6 = 0; r6 < 18; r6 += 1) s2 = !
|
|
67
|
-
}, C = function(
|
|
66
|
+
for (r6 = 0; r6 < 18; r6 += 1) s2 = !t15 && 1 == (e5 >> r6 & 1), n3[r6 % 3 + o2 - 8 - 3][Math.floor(r6 / 3)] = s2;
|
|
67
|
+
}, C = function(t15, e5) {
|
|
68
68
|
for (var i5 = r5 << 3 | e5, s2 = a.getBCHTypeInfo(i5), h3 = 0; h3 < 15; h3 += 1) {
|
|
69
|
-
var d2 = !
|
|
69
|
+
var d2 = !t15 && 1 == (s2 >> h3 & 1);
|
|
70
70
|
h3 < 6 ? n3[h3][8] = d2 : h3 < 8 ? n3[h3 + 1][8] = d2 : n3[o2 - 15 + h3][8] = d2;
|
|
71
71
|
}
|
|
72
|
-
for (h3 = 0; h3 < 15; h3 += 1) d2 = !
|
|
73
|
-
n3[o2 - 8][8] = !
|
|
74
|
-
}, A = function(
|
|
72
|
+
for (h3 = 0; h3 < 15; h3 += 1) d2 = !t15 && 1 == (s2 >> h3 & 1), h3 < 8 ? n3[8][o2 - h3 - 1] = d2 : h3 < 9 ? n3[8][15 - h3 - 1 + 1] = d2 : n3[8][15 - h3 - 1] = d2;
|
|
73
|
+
n3[o2 - 8][8] = !t15;
|
|
74
|
+
}, A = function(t15, e5) {
|
|
75
75
|
for (var i5 = -1, r6 = o2 - 1, s2 = 7, h3 = 0, d2 = a.getMaskFunction(e5), u2 = o2 - 1; u2 > 0; u2 -= 2) for (6 == u2 && (u2 -= 1); ; ) {
|
|
76
76
|
for (var c2 = 0; c2 < 2; c2 += 1) if (null == n3[r6][u2 - c2]) {
|
|
77
77
|
var l2 = false;
|
|
78
|
-
h3 <
|
|
78
|
+
h3 < t15.length && (l2 = 1 == (t15[h3] >>> s2 & 1)), d2(r6, u2 - c2) && (l2 = !l2), n3[r6][u2 - c2] = l2, -1 == (s2 -= 1) && (h3 += 1, s2 = 7);
|
|
79
79
|
}
|
|
80
80
|
if ((r6 += i5) < 0 || o2 <= r6) {
|
|
81
81
|
r6 -= i5, i5 = -i5;
|
|
82
82
|
break;
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
}, M = function(
|
|
86
|
-
for (var r6 = u.getRSBlocks(
|
|
85
|
+
}, M = function(t15, e5, i5) {
|
|
86
|
+
for (var r6 = u.getRSBlocks(t15, e5), n4 = c(), o3 = 0; o3 < i5.length; o3 += 1) {
|
|
87
87
|
var s2 = i5[o3];
|
|
88
|
-
n4.put(s2.getMode(), 4), n4.put(s2.getLength(), a.getLengthInBits(s2.getMode(),
|
|
88
|
+
n4.put(s2.getMode(), 4), n4.put(s2.getLength(), a.getLengthInBits(s2.getMode(), t15)), s2.write(n4);
|
|
89
89
|
}
|
|
90
90
|
var h3 = 0;
|
|
91
91
|
for (o3 = 0; o3 < r6.length; o3 += 1) h3 += r6[o3].dataCount;
|
|
92
92
|
if (n4.getLengthInBits() > 8 * h3) throw "code length overflow. (" + n4.getLengthInBits() + ">" + 8 * h3 + ")";
|
|
93
93
|
for (n4.getLengthInBits() + 4 <= 8 * h3 && n4.put(0, 4); n4.getLengthInBits() % 8 != 0; ) n4.putBit(false);
|
|
94
94
|
for (; !(n4.getLengthInBits() >= 8 * h3 || (n4.put(236, 8), n4.getLengthInBits() >= 8 * h3)); ) n4.put(17, 8);
|
|
95
|
-
return (function(
|
|
95
|
+
return (function(t16, e6) {
|
|
96
96
|
for (var i6 = 0, r7 = 0, n5 = 0, o4 = new Array(e6.length), s3 = new Array(e6.length), h4 = 0; h4 < e6.length; h4 += 1) {
|
|
97
97
|
var u2 = e6[h4].dataCount, c2 = e6[h4].totalCount - u2;
|
|
98
98
|
r7 = Math.max(r7, u2), n5 = Math.max(n5, c2), o4[h4] = new Array(u2);
|
|
99
|
-
for (var l2 = 0; l2 < o4[h4].length; l2 += 1) o4[h4][l2] = 255 &
|
|
99
|
+
for (var l2 = 0; l2 < o4[h4].length; l2 += 1) o4[h4][l2] = 255 & t16.getBuffer()[l2 + i6];
|
|
100
100
|
i6 += u2;
|
|
101
101
|
var g2 = a.getErrorCorrectPolynomial(c2), f2 = d(o4[h4], g2.getLength() - 1).mod(g2);
|
|
102
102
|
for (s3[h4] = new Array(g2.getLength() - 1), l2 = 0; l2 < s3[h4].length; l2 += 1) {
|
|
@@ -112,85 +112,85 @@ var require_qr_code_styling = __commonJS({
|
|
|
112
112
|
return v3;
|
|
113
113
|
})(n4, r6);
|
|
114
114
|
};
|
|
115
|
-
v2.addData = function(
|
|
115
|
+
v2.addData = function(t15, e5) {
|
|
116
116
|
var i5 = null;
|
|
117
117
|
switch (e5 = e5 || "Byte") {
|
|
118
118
|
case "Numeric":
|
|
119
|
-
i5 = l(
|
|
119
|
+
i5 = l(t15);
|
|
120
120
|
break;
|
|
121
121
|
case "Alphanumeric":
|
|
122
|
-
i5 = g(
|
|
122
|
+
i5 = g(t15);
|
|
123
123
|
break;
|
|
124
124
|
case "Byte":
|
|
125
|
-
i5 = f(
|
|
125
|
+
i5 = f(t15);
|
|
126
126
|
break;
|
|
127
127
|
case "Kanji":
|
|
128
|
-
i5 = w(
|
|
128
|
+
i5 = w(t15);
|
|
129
129
|
break;
|
|
130
130
|
default:
|
|
131
131
|
throw "mode:" + e5;
|
|
132
132
|
}
|
|
133
133
|
p2.push(i5), h2 = null;
|
|
134
|
-
}, v2.isDark = function(
|
|
135
|
-
if (
|
|
136
|
-
return n3[
|
|
134
|
+
}, v2.isDark = function(t15, e5) {
|
|
135
|
+
if (t15 < 0 || o2 <= t15 || e5 < 0 || o2 <= e5) throw t15 + "," + e5;
|
|
136
|
+
return n3[t15][e5];
|
|
137
137
|
}, v2.getModuleCount = function() {
|
|
138
138
|
return o2;
|
|
139
139
|
}, v2.make = function() {
|
|
140
140
|
if (i4 < 1) {
|
|
141
|
-
for (var
|
|
142
|
-
for (var e5 = u.getRSBlocks(
|
|
141
|
+
for (var t15 = 1; t15 < 40; t15++) {
|
|
142
|
+
for (var e5 = u.getRSBlocks(t15, r5), n4 = c(), o3 = 0; o3 < p2.length; o3++) {
|
|
143
143
|
var s2 = p2[o3];
|
|
144
|
-
n4.put(s2.getMode(), 4), n4.put(s2.getLength(), a.getLengthInBits(s2.getMode(),
|
|
144
|
+
n4.put(s2.getMode(), 4), n4.put(s2.getLength(), a.getLengthInBits(s2.getMode(), t15)), s2.write(n4);
|
|
145
145
|
}
|
|
146
146
|
var h3 = 0;
|
|
147
147
|
for (o3 = 0; o3 < e5.length; o3++) h3 += e5[o3].dataCount;
|
|
148
148
|
if (n4.getLengthInBits() <= 8 * h3) break;
|
|
149
149
|
}
|
|
150
|
-
i4 =
|
|
150
|
+
i4 = t15;
|
|
151
151
|
}
|
|
152
152
|
m(false, (function() {
|
|
153
|
-
for (var
|
|
153
|
+
for (var t16 = 0, e6 = 0, i5 = 0; i5 < 8; i5 += 1) {
|
|
154
154
|
m(true, i5);
|
|
155
155
|
var r6 = a.getLostPoint(v2);
|
|
156
|
-
(0 == i5 ||
|
|
156
|
+
(0 == i5 || t16 > r6) && (t16 = r6, e6 = i5);
|
|
157
157
|
}
|
|
158
158
|
return e6;
|
|
159
159
|
})());
|
|
160
|
-
}, v2.createTableTag = function(
|
|
161
|
-
|
|
160
|
+
}, v2.createTableTag = function(t15, e5) {
|
|
161
|
+
t15 = t15 || 2;
|
|
162
162
|
var i5 = "";
|
|
163
|
-
i5 += '<table style="', i5 += " border-width: 0px; border-style: none;", i5 += " border-collapse: collapse;", i5 += " padding: 0px; margin: " + (e5 = void 0 === e5 ? 4 *
|
|
163
|
+
i5 += '<table style="', i5 += " border-width: 0px; border-style: none;", i5 += " border-collapse: collapse;", i5 += " padding: 0px; margin: " + (e5 = void 0 === e5 ? 4 * t15 : e5) + "px;", i5 += '">', i5 += "<tbody>";
|
|
164
164
|
for (var r6 = 0; r6 < v2.getModuleCount(); r6 += 1) {
|
|
165
165
|
i5 += "<tr>";
|
|
166
|
-
for (var n4 = 0; n4 < v2.getModuleCount(); n4 += 1) i5 += '<td style="', i5 += " border-width: 0px; border-style: none;", i5 += " border-collapse: collapse;", i5 += " padding: 0px; margin: 0px;", i5 += " width: " +
|
|
166
|
+
for (var n4 = 0; n4 < v2.getModuleCount(); n4 += 1) i5 += '<td style="', i5 += " border-width: 0px; border-style: none;", i5 += " border-collapse: collapse;", i5 += " padding: 0px; margin: 0px;", i5 += " width: " + t15 + "px;", i5 += " height: " + t15 + "px;", i5 += " background-color: ", i5 += v2.isDark(r6, n4) ? "#000000" : "#ffffff", i5 += ";", i5 += '"/>';
|
|
167
167
|
i5 += "</tr>";
|
|
168
168
|
}
|
|
169
169
|
return (i5 += "</tbody>") + "</table>";
|
|
170
|
-
}, v2.createSvgTag = function(
|
|
170
|
+
}, v2.createSvgTag = function(t15, e5, i5, r6) {
|
|
171
171
|
var n4 = {};
|
|
172
|
-
"object" == typeof arguments[0] && (
|
|
173
|
-
var o3, s2, a2, h3, d2 = v2.getModuleCount() *
|
|
174
|
-
for (h3 = "l" +
|
|
172
|
+
"object" == typeof arguments[0] && (t15 = (n4 = arguments[0]).cellSize, e5 = n4.margin, i5 = n4.alt, r6 = n4.title), t15 = t15 || 2, e5 = void 0 === e5 ? 4 * t15 : e5, (i5 = "string" == typeof i5 ? { text: i5 } : i5 || {}).text = i5.text || null, i5.id = i5.text ? i5.id || "qrcode-description" : null, (r6 = "string" == typeof r6 ? { text: r6 } : r6 || {}).text = r6.text || null, r6.id = r6.text ? r6.id || "qrcode-title" : null;
|
|
173
|
+
var o3, s2, a2, h3, d2 = v2.getModuleCount() * t15 + 2 * e5, u2 = "";
|
|
174
|
+
for (h3 = "l" + t15 + ",0 0," + t15 + " -" + t15 + ",0 0,-" + t15 + "z ", u2 += '<svg version="1.1" xmlns="http://www.w3.org/2000/svg"', u2 += n4.scalable ? "" : ' width="' + d2 + 'px" height="' + d2 + 'px"', u2 += ' viewBox="0 0 ' + d2 + " " + d2 + '" ', u2 += ' preserveAspectRatio="xMinYMin meet"', u2 += r6.text || i5.text ? ' role="img" aria-labelledby="' + $([r6.id, i5.id].join(" ").trim()) + '"' : "", u2 += ">", u2 += r6.text ? '<title id="' + $(r6.id) + '">' + $(r6.text) + "</title>" : "", u2 += i5.text ? '<description id="' + $(i5.id) + '">' + $(i5.text) + "</description>" : "", u2 += '<rect width="100%" height="100%" fill="white" cx="0" cy="0"/>', u2 += '<path d="', s2 = 0; s2 < v2.getModuleCount(); s2 += 1) for (a2 = s2 * t15 + e5, o3 = 0; o3 < v2.getModuleCount(); o3 += 1) v2.isDark(s2, o3) && (u2 += "M" + (o3 * t15 + e5) + "," + a2 + h3);
|
|
175
175
|
return (u2 += '" stroke="transparent" fill="black"/>') + "</svg>";
|
|
176
|
-
}, v2.createDataURL = function(
|
|
177
|
-
|
|
178
|
-
var i5 = v2.getModuleCount() *
|
|
176
|
+
}, v2.createDataURL = function(t15, e5) {
|
|
177
|
+
t15 = t15 || 2, e5 = void 0 === e5 ? 4 * t15 : e5;
|
|
178
|
+
var i5 = v2.getModuleCount() * t15 + 2 * e5, r6 = e5, n4 = i5 - e5;
|
|
179
179
|
return _(i5, i5, (function(e6, i6) {
|
|
180
180
|
if (r6 <= e6 && e6 < n4 && r6 <= i6 && i6 < n4) {
|
|
181
|
-
var o3 = Math.floor((e6 - r6) /
|
|
181
|
+
var o3 = Math.floor((e6 - r6) / t15), s2 = Math.floor((i6 - r6) / t15);
|
|
182
182
|
return v2.isDark(s2, o3) ? 0 : 1;
|
|
183
183
|
}
|
|
184
184
|
return 1;
|
|
185
185
|
}));
|
|
186
|
-
}, v2.createImgTag = function(
|
|
187
|
-
|
|
188
|
-
var r6 = v2.getModuleCount() *
|
|
189
|
-
return n4 += "<img", n4 += ' src="', n4 += v2.createDataURL(
|
|
186
|
+
}, v2.createImgTag = function(t15, e5, i5) {
|
|
187
|
+
t15 = t15 || 2, e5 = void 0 === e5 ? 4 * t15 : e5;
|
|
188
|
+
var r6 = v2.getModuleCount() * t15 + 2 * e5, n4 = "";
|
|
189
|
+
return n4 += "<img", n4 += ' src="', n4 += v2.createDataURL(t15, e5), n4 += '"', n4 += ' width="', n4 += r6, n4 += '"', n4 += ' height="', n4 += r6, n4 += '"', i5 && (n4 += ' alt="', n4 += $(i5), n4 += '"'), n4 + "/>";
|
|
190
190
|
};
|
|
191
|
-
var $ = function(
|
|
192
|
-
for (var e5 = "", i5 = 0; i5 <
|
|
193
|
-
var r6 =
|
|
191
|
+
var $ = function(t15) {
|
|
192
|
+
for (var e5 = "", i5 = 0; i5 < t15.length; i5 += 1) {
|
|
193
|
+
var r6 = t15.charAt(i5);
|
|
194
194
|
switch (r6) {
|
|
195
195
|
case "<":
|
|
196
196
|
e5 += "<";
|
|
@@ -210,40 +210,40 @@ var require_qr_code_styling = __commonJS({
|
|
|
210
210
|
}
|
|
211
211
|
return e5;
|
|
212
212
|
};
|
|
213
|
-
return v2.createASCII = function(
|
|
214
|
-
if ((
|
|
215
|
-
|
|
216
|
-
var e6, i6, r7, n5, o4, s3 = 1 * v2.getModuleCount() + 2 *
|
|
213
|
+
return v2.createASCII = function(t15, e5) {
|
|
214
|
+
if ((t15 = t15 || 1) < 2) return (function(t16) {
|
|
215
|
+
t16 = void 0 === t16 ? 2 : t16;
|
|
216
|
+
var e6, i6, r7, n5, o4, s3 = 1 * v2.getModuleCount() + 2 * t16, a3 = t16, h4 = s3 - t16, d3 = { "\u2588\u2588": "\u2588", "\u2588 ": "\u2580", " \u2588": "\u2584", " ": " " }, u3 = { "\u2588\u2588": "\u2580", "\u2588 ": "\u2580", " \u2588": " ", " ": " " }, c3 = "";
|
|
217
217
|
for (e6 = 0; e6 < s3; e6 += 2) {
|
|
218
|
-
for (r7 = Math.floor((e6 - a3) / 1), n5 = Math.floor((e6 + 1 - a3) / 1), i6 = 0; i6 < s3; i6 += 1) o4 = "\u2588", a3 <= i6 && i6 < h4 && a3 <= e6 && e6 < h4 && v2.isDark(r7, Math.floor((i6 - a3) / 1)) && (o4 = " "), a3 <= i6 && i6 < h4 && a3 <= e6 + 1 && e6 + 1 < h4 && v2.isDark(n5, Math.floor((i6 - a3) / 1)) ? o4 += " " : o4 += "\u2588", c3 +=
|
|
218
|
+
for (r7 = Math.floor((e6 - a3) / 1), n5 = Math.floor((e6 + 1 - a3) / 1), i6 = 0; i6 < s3; i6 += 1) o4 = "\u2588", a3 <= i6 && i6 < h4 && a3 <= e6 && e6 < h4 && v2.isDark(r7, Math.floor((i6 - a3) / 1)) && (o4 = " "), a3 <= i6 && i6 < h4 && a3 <= e6 + 1 && e6 + 1 < h4 && v2.isDark(n5, Math.floor((i6 - a3) / 1)) ? o4 += " " : o4 += "\u2588", c3 += t16 < 1 && e6 + 1 >= h4 ? u3[o4] : d3[o4];
|
|
219
219
|
c3 += "\n";
|
|
220
220
|
}
|
|
221
|
-
return s3 % 2 &&
|
|
221
|
+
return s3 % 2 && t16 > 0 ? c3.substring(0, c3.length - s3 - 1) + Array(s3 + 1).join("\u2580") : c3.substring(0, c3.length - 1);
|
|
222
222
|
})(e5);
|
|
223
|
-
|
|
224
|
-
var i5, r6, n4, o3, s2 = v2.getModuleCount() *
|
|
223
|
+
t15 -= 1, e5 = void 0 === e5 ? 2 * t15 : e5;
|
|
224
|
+
var i5, r6, n4, o3, s2 = v2.getModuleCount() * t15 + 2 * e5, a2 = e5, h3 = s2 - e5, d2 = Array(t15 + 1).join("\u2588\u2588"), u2 = Array(t15 + 1).join(" "), c2 = "", l2 = "";
|
|
225
225
|
for (i5 = 0; i5 < s2; i5 += 1) {
|
|
226
|
-
for (n4 = Math.floor((i5 - a2) /
|
|
227
|
-
for (n4 = 0; n4 <
|
|
226
|
+
for (n4 = Math.floor((i5 - a2) / t15), l2 = "", r6 = 0; r6 < s2; r6 += 1) o3 = 1, a2 <= r6 && r6 < h3 && a2 <= i5 && i5 < h3 && v2.isDark(n4, Math.floor((r6 - a2) / t15)) && (o3 = 0), l2 += o3 ? d2 : u2;
|
|
227
|
+
for (n4 = 0; n4 < t15; n4 += 1) c2 += l2 + "\n";
|
|
228
228
|
}
|
|
229
229
|
return c2.substring(0, c2.length - 1);
|
|
230
|
-
}, v2.renderTo2dContext = function(
|
|
230
|
+
}, v2.renderTo2dContext = function(t15, e5) {
|
|
231
231
|
e5 = e5 || 2;
|
|
232
|
-
for (var i5 = v2.getModuleCount(), r6 = 0; r6 < i5; r6++) for (var n4 = 0; n4 < i5; n4++)
|
|
232
|
+
for (var i5 = v2.getModuleCount(), r6 = 0; r6 < i5; r6++) for (var n4 = 0; n4 < i5; n4++) t15.fillStyle = v2.isDark(r6, n4) ? "black" : "white", t15.fillRect(r6 * e5, n4 * e5, e5, e5);
|
|
233
233
|
}, v2;
|
|
234
234
|
};
|
|
235
|
-
|
|
236
|
-
for (var e4 = [], i4 = 0; i4 <
|
|
237
|
-
var r5 =
|
|
235
|
+
t13.stringToBytes = (t13.stringToBytesFuncs = { default: function(t14) {
|
|
236
|
+
for (var e4 = [], i4 = 0; i4 < t14.length; i4 += 1) {
|
|
237
|
+
var r5 = t14.charCodeAt(i4);
|
|
238
238
|
e4.push(255 & r5);
|
|
239
239
|
}
|
|
240
240
|
return e4;
|
|
241
|
-
} }).default,
|
|
241
|
+
} }).default, t13.createStringToBytes = function(t14, e4) {
|
|
242
242
|
var i4 = (function() {
|
|
243
|
-
for (var i5 = v(
|
|
244
|
-
var
|
|
245
|
-
if (-1 ==
|
|
246
|
-
return
|
|
243
|
+
for (var i5 = v(t14), r6 = function() {
|
|
244
|
+
var t15 = i5.read();
|
|
245
|
+
if (-1 == t15) throw "eof";
|
|
246
|
+
return t15;
|
|
247
247
|
}, n3 = 0, o2 = {}; ; ) {
|
|
248
248
|
var s2 = i5.read();
|
|
249
249
|
if (-1 == s2) break;
|
|
@@ -253,71 +253,71 @@ var require_qr_code_styling = __commonJS({
|
|
|
253
253
|
if (n3 != e4) throw n3 + " != " + e4;
|
|
254
254
|
return o2;
|
|
255
255
|
})(), r5 = "?".charCodeAt(0);
|
|
256
|
-
return function(
|
|
257
|
-
for (var e5 = [], n3 = 0; n3 <
|
|
258
|
-
var o2 =
|
|
256
|
+
return function(t15) {
|
|
257
|
+
for (var e5 = [], n3 = 0; n3 < t15.length; n3 += 1) {
|
|
258
|
+
var o2 = t15.charCodeAt(n3);
|
|
259
259
|
if (o2 < 128) e5.push(o2);
|
|
260
260
|
else {
|
|
261
|
-
var s2 = i4[
|
|
261
|
+
var s2 = i4[t15.charAt(n3)];
|
|
262
262
|
"number" == typeof s2 ? (255 & s2) == s2 ? e5.push(s2) : (e5.push(s2 >>> 8), e5.push(255 & s2)) : e5.push(r5);
|
|
263
263
|
}
|
|
264
264
|
}
|
|
265
265
|
return e5;
|
|
266
266
|
};
|
|
267
267
|
};
|
|
268
|
-
var e3, i3, r4, n2, o, s = { L: 1, M: 0, Q: 3, H: 2 }, a = (e3 = [[], [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]], i3 = 1335, r4 = 7973, o = function(
|
|
269
|
-
for (var e4 = 0; 0 !=
|
|
268
|
+
var e3, i3, r4, n2, o, s = { L: 1, M: 0, Q: 3, H: 2 }, a = (e3 = [[], [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]], i3 = 1335, r4 = 7973, o = function(t14) {
|
|
269
|
+
for (var e4 = 0; 0 != t14; ) e4 += 1, t14 >>>= 1;
|
|
270
270
|
return e4;
|
|
271
|
-
}, (n2 = {}).getBCHTypeInfo = function(
|
|
272
|
-
for (var e4 =
|
|
273
|
-
return 21522 ^ (
|
|
274
|
-
}, n2.getBCHTypeNumber = function(
|
|
275
|
-
for (var e4 =
|
|
276
|
-
return
|
|
277
|
-
}, n2.getPatternPosition = function(
|
|
278
|
-
return e3[
|
|
279
|
-
}, n2.getMaskFunction = function(
|
|
280
|
-
switch (
|
|
271
|
+
}, (n2 = {}).getBCHTypeInfo = function(t14) {
|
|
272
|
+
for (var e4 = t14 << 10; o(e4) - o(i3) >= 0; ) e4 ^= i3 << o(e4) - o(i3);
|
|
273
|
+
return 21522 ^ (t14 << 10 | e4);
|
|
274
|
+
}, n2.getBCHTypeNumber = function(t14) {
|
|
275
|
+
for (var e4 = t14 << 12; o(e4) - o(r4) >= 0; ) e4 ^= r4 << o(e4) - o(r4);
|
|
276
|
+
return t14 << 12 | e4;
|
|
277
|
+
}, n2.getPatternPosition = function(t14) {
|
|
278
|
+
return e3[t14 - 1];
|
|
279
|
+
}, n2.getMaskFunction = function(t14) {
|
|
280
|
+
switch (t14) {
|
|
281
281
|
case 0:
|
|
282
|
-
return function(
|
|
283
|
-
return (
|
|
282
|
+
return function(t15, e4) {
|
|
283
|
+
return (t15 + e4) % 2 == 0;
|
|
284
284
|
};
|
|
285
285
|
case 1:
|
|
286
|
-
return function(
|
|
287
|
-
return
|
|
286
|
+
return function(t15, e4) {
|
|
287
|
+
return t15 % 2 == 0;
|
|
288
288
|
};
|
|
289
289
|
case 2:
|
|
290
|
-
return function(
|
|
290
|
+
return function(t15, e4) {
|
|
291
291
|
return e4 % 3 == 0;
|
|
292
292
|
};
|
|
293
293
|
case 3:
|
|
294
|
-
return function(
|
|
295
|
-
return (
|
|
294
|
+
return function(t15, e4) {
|
|
295
|
+
return (t15 + e4) % 3 == 0;
|
|
296
296
|
};
|
|
297
297
|
case 4:
|
|
298
|
-
return function(
|
|
299
|
-
return (Math.floor(
|
|
298
|
+
return function(t15, e4) {
|
|
299
|
+
return (Math.floor(t15 / 2) + Math.floor(e4 / 3)) % 2 == 0;
|
|
300
300
|
};
|
|
301
301
|
case 5:
|
|
302
|
-
return function(
|
|
303
|
-
return
|
|
302
|
+
return function(t15, e4) {
|
|
303
|
+
return t15 * e4 % 2 + t15 * e4 % 3 == 0;
|
|
304
304
|
};
|
|
305
305
|
case 6:
|
|
306
|
-
return function(
|
|
307
|
-
return (
|
|
306
|
+
return function(t15, e4) {
|
|
307
|
+
return (t15 * e4 % 2 + t15 * e4 % 3) % 2 == 0;
|
|
308
308
|
};
|
|
309
309
|
case 7:
|
|
310
|
-
return function(
|
|
311
|
-
return (
|
|
310
|
+
return function(t15, e4) {
|
|
311
|
+
return (t15 * e4 % 3 + (t15 + e4) % 2) % 2 == 0;
|
|
312
312
|
};
|
|
313
313
|
default:
|
|
314
|
-
throw "bad maskPattern:" +
|
|
314
|
+
throw "bad maskPattern:" + t14;
|
|
315
315
|
}
|
|
316
|
-
}, n2.getErrorCorrectPolynomial = function(
|
|
317
|
-
for (var e4 = d([1], 0), i4 = 0; i4 <
|
|
316
|
+
}, n2.getErrorCorrectPolynomial = function(t14) {
|
|
317
|
+
for (var e4 = d([1], 0), i4 = 0; i4 < t14; i4 += 1) e4 = e4.multiply(d([1, h.gexp(i4)], 0));
|
|
318
318
|
return e4;
|
|
319
|
-
}, n2.getLengthInBits = function(
|
|
320
|
-
if (1 <= e4 && e4 < 10) switch (
|
|
319
|
+
}, n2.getLengthInBits = function(t14, e4) {
|
|
320
|
+
if (1 <= e4 && e4 < 10) switch (t14) {
|
|
321
321
|
case 1:
|
|
322
322
|
return 10;
|
|
323
323
|
case 2:
|
|
@@ -326,9 +326,9 @@ var require_qr_code_styling = __commonJS({
|
|
|
326
326
|
case 8:
|
|
327
327
|
return 8;
|
|
328
328
|
default:
|
|
329
|
-
throw "mode:" +
|
|
329
|
+
throw "mode:" + t14;
|
|
330
330
|
}
|
|
331
|
-
else if (e4 < 27) switch (
|
|
331
|
+
else if (e4 < 27) switch (t14) {
|
|
332
332
|
case 1:
|
|
333
333
|
return 12;
|
|
334
334
|
case 2:
|
|
@@ -338,11 +338,11 @@ var require_qr_code_styling = __commonJS({
|
|
|
338
338
|
case 8:
|
|
339
339
|
return 10;
|
|
340
340
|
default:
|
|
341
|
-
throw "mode:" +
|
|
341
|
+
throw "mode:" + t14;
|
|
342
342
|
}
|
|
343
343
|
else {
|
|
344
344
|
if (!(e4 < 41)) throw "type:" + e4;
|
|
345
|
-
switch (
|
|
345
|
+
switch (t14) {
|
|
346
346
|
case 1:
|
|
347
347
|
return 14;
|
|
348
348
|
case 2:
|
|
@@ -352,72 +352,72 @@ var require_qr_code_styling = __commonJS({
|
|
|
352
352
|
case 8:
|
|
353
353
|
return 12;
|
|
354
354
|
default:
|
|
355
|
-
throw "mode:" +
|
|
355
|
+
throw "mode:" + t14;
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
|
-
}, n2.getLostPoint = function(
|
|
359
|
-
for (var e4 =
|
|
360
|
-
for (var o2 = 0, s2 =
|
|
358
|
+
}, n2.getLostPoint = function(t14) {
|
|
359
|
+
for (var e4 = t14.getModuleCount(), i4 = 0, r5 = 0; r5 < e4; r5 += 1) for (var n3 = 0; n3 < e4; n3 += 1) {
|
|
360
|
+
for (var o2 = 0, s2 = t14.isDark(r5, n3), a2 = -1; a2 <= 1; a2 += 1) if (!(r5 + a2 < 0 || e4 <= r5 + a2)) for (var h2 = -1; h2 <= 1; h2 += 1) n3 + h2 < 0 || e4 <= n3 + h2 || 0 == a2 && 0 == h2 || s2 == t14.isDark(r5 + a2, n3 + h2) && (o2 += 1);
|
|
361
361
|
o2 > 5 && (i4 += 3 + o2 - 5);
|
|
362
362
|
}
|
|
363
363
|
for (r5 = 0; r5 < e4 - 1; r5 += 1) for (n3 = 0; n3 < e4 - 1; n3 += 1) {
|
|
364
364
|
var d2 = 0;
|
|
365
|
-
|
|
365
|
+
t14.isDark(r5, n3) && (d2 += 1), t14.isDark(r5 + 1, n3) && (d2 += 1), t14.isDark(r5, n3 + 1) && (d2 += 1), t14.isDark(r5 + 1, n3 + 1) && (d2 += 1), 0 != d2 && 4 != d2 || (i4 += 3);
|
|
366
366
|
}
|
|
367
|
-
for (r5 = 0; r5 < e4; r5 += 1) for (n3 = 0; n3 < e4 - 6; n3 += 1)
|
|
368
|
-
for (n3 = 0; n3 < e4; n3 += 1) for (r5 = 0; r5 < e4 - 6; r5 += 1)
|
|
367
|
+
for (r5 = 0; r5 < e4; r5 += 1) for (n3 = 0; n3 < e4 - 6; n3 += 1) t14.isDark(r5, n3) && !t14.isDark(r5, n3 + 1) && t14.isDark(r5, n3 + 2) && t14.isDark(r5, n3 + 3) && t14.isDark(r5, n3 + 4) && !t14.isDark(r5, n3 + 5) && t14.isDark(r5, n3 + 6) && (i4 += 40);
|
|
368
|
+
for (n3 = 0; n3 < e4; n3 += 1) for (r5 = 0; r5 < e4 - 6; r5 += 1) t14.isDark(r5, n3) && !t14.isDark(r5 + 1, n3) && t14.isDark(r5 + 2, n3) && t14.isDark(r5 + 3, n3) && t14.isDark(r5 + 4, n3) && !t14.isDark(r5 + 5, n3) && t14.isDark(r5 + 6, n3) && (i4 += 40);
|
|
369
369
|
var u2 = 0;
|
|
370
|
-
for (n3 = 0; n3 < e4; n3 += 1) for (r5 = 0; r5 < e4; r5 += 1)
|
|
370
|
+
for (n3 = 0; n3 < e4; n3 += 1) for (r5 = 0; r5 < e4; r5 += 1) t14.isDark(r5, n3) && (u2 += 1);
|
|
371
371
|
return i4 + Math.abs(100 * u2 / e4 / e4 - 50) / 5 * 10;
|
|
372
372
|
}, n2), h = (function() {
|
|
373
|
-
for (var
|
|
374
|
-
for (i4 = 8; i4 < 256; i4 += 1)
|
|
375
|
-
for (i4 = 0; i4 < 255; i4 += 1) e4[
|
|
376
|
-
return { glog: function(
|
|
377
|
-
if (
|
|
378
|
-
return e4[
|
|
373
|
+
for (var t14 = new Array(256), e4 = new Array(256), i4 = 0; i4 < 8; i4 += 1) t14[i4] = 1 << i4;
|
|
374
|
+
for (i4 = 8; i4 < 256; i4 += 1) t14[i4] = t14[i4 - 4] ^ t14[i4 - 5] ^ t14[i4 - 6] ^ t14[i4 - 8];
|
|
375
|
+
for (i4 = 0; i4 < 255; i4 += 1) e4[t14[i4]] = i4;
|
|
376
|
+
return { glog: function(t15) {
|
|
377
|
+
if (t15 < 1) throw "glog(" + t15 + ")";
|
|
378
|
+
return e4[t15];
|
|
379
379
|
}, gexp: function(e5) {
|
|
380
380
|
for (; e5 < 0; ) e5 += 255;
|
|
381
381
|
for (; e5 >= 256; ) e5 -= 255;
|
|
382
|
-
return
|
|
382
|
+
return t14[e5];
|
|
383
383
|
} };
|
|
384
384
|
})();
|
|
385
|
-
function d(
|
|
386
|
-
if (void 0 ===
|
|
385
|
+
function d(t14, e4) {
|
|
386
|
+
if (void 0 === t14.length) throw t14.length + "/" + e4;
|
|
387
387
|
var i4 = (function() {
|
|
388
|
-
for (var i5 = 0; i5 <
|
|
389
|
-
for (var r6 = new Array(
|
|
388
|
+
for (var i5 = 0; i5 < t14.length && 0 == t14[i5]; ) i5 += 1;
|
|
389
|
+
for (var r6 = new Array(t14.length - i5 + e4), n3 = 0; n3 < t14.length - i5; n3 += 1) r6[n3] = t14[n3 + i5];
|
|
390
390
|
return r6;
|
|
391
|
-
})(), r5 = { getAt: function(
|
|
392
|
-
return i4[
|
|
391
|
+
})(), r5 = { getAt: function(t15) {
|
|
392
|
+
return i4[t15];
|
|
393
393
|
}, getLength: function() {
|
|
394
394
|
return i4.length;
|
|
395
|
-
}, multiply: function(
|
|
396
|
-
for (var e5 = new Array(r5.getLength() +
|
|
395
|
+
}, multiply: function(t15) {
|
|
396
|
+
for (var e5 = new Array(r5.getLength() + t15.getLength() - 1), i5 = 0; i5 < r5.getLength(); i5 += 1) for (var n3 = 0; n3 < t15.getLength(); n3 += 1) e5[i5 + n3] ^= h.gexp(h.glog(r5.getAt(i5)) + h.glog(t15.getAt(n3)));
|
|
397
397
|
return d(e5, 0);
|
|
398
|
-
}, mod: function(
|
|
399
|
-
if (r5.getLength() -
|
|
400
|
-
for (var e5 = h.glog(r5.getAt(0)) - h.glog(
|
|
401
|
-
for (n3 = 0; n3 <
|
|
402
|
-
return d(i5, 0).mod(
|
|
398
|
+
}, mod: function(t15) {
|
|
399
|
+
if (r5.getLength() - t15.getLength() < 0) return r5;
|
|
400
|
+
for (var e5 = h.glog(r5.getAt(0)) - h.glog(t15.getAt(0)), i5 = new Array(r5.getLength()), n3 = 0; n3 < r5.getLength(); n3 += 1) i5[n3] = r5.getAt(n3);
|
|
401
|
+
for (n3 = 0; n3 < t15.getLength(); n3 += 1) i5[n3] ^= h.gexp(h.glog(t15.getAt(n3)) + e5);
|
|
402
|
+
return d(i5, 0).mod(t15);
|
|
403
403
|
} };
|
|
404
404
|
return r5;
|
|
405
405
|
}
|
|
406
406
|
var u = /* @__PURE__ */ (function() {
|
|
407
|
-
var
|
|
407
|
+
var t14 = [[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]], e4 = function(t15, e5) {
|
|
408
408
|
var i5 = {};
|
|
409
|
-
return i5.totalCount =
|
|
409
|
+
return i5.totalCount = t15, i5.dataCount = e5, i5;
|
|
410
410
|
}, i4 = { getRSBlocks: function(i5, r5) {
|
|
411
411
|
var n3 = (function(e5, i6) {
|
|
412
412
|
switch (i6) {
|
|
413
413
|
case s.L:
|
|
414
|
-
return
|
|
414
|
+
return t14[4 * (e5 - 1) + 0];
|
|
415
415
|
case s.M:
|
|
416
|
-
return
|
|
416
|
+
return t14[4 * (e5 - 1) + 1];
|
|
417
417
|
case s.Q:
|
|
418
|
-
return
|
|
418
|
+
return t14[4 * (e5 - 1) + 2];
|
|
419
419
|
case s.H:
|
|
420
|
-
return
|
|
420
|
+
return t14[4 * (e5 - 1) + 3];
|
|
421
421
|
default:
|
|
422
422
|
return;
|
|
423
423
|
}
|
|
@@ -428,48 +428,48 @@ var require_qr_code_styling = __commonJS({
|
|
|
428
428
|
} };
|
|
429
429
|
return i4;
|
|
430
430
|
})(), c = function() {
|
|
431
|
-
var
|
|
432
|
-
return
|
|
431
|
+
var t14 = [], e4 = 0, i4 = { getBuffer: function() {
|
|
432
|
+
return t14;
|
|
433
433
|
}, getAt: function(e5) {
|
|
434
434
|
var i5 = Math.floor(e5 / 8);
|
|
435
|
-
return 1 == (
|
|
436
|
-
}, put: function(
|
|
437
|
-
for (var r5 = 0; r5 < e5; r5 += 1) i4.putBit(1 == (
|
|
435
|
+
return 1 == (t14[i5] >>> 7 - e5 % 8 & 1);
|
|
436
|
+
}, put: function(t15, e5) {
|
|
437
|
+
for (var r5 = 0; r5 < e5; r5 += 1) i4.putBit(1 == (t15 >>> e5 - r5 - 1 & 1));
|
|
438
438
|
}, getLengthInBits: function() {
|
|
439
439
|
return e4;
|
|
440
440
|
}, putBit: function(i5) {
|
|
441
441
|
var r5 = Math.floor(e4 / 8);
|
|
442
|
-
|
|
442
|
+
t14.length <= r5 && t14.push(0), i5 && (t14[r5] |= 128 >>> e4 % 8), e4 += 1;
|
|
443
443
|
} };
|
|
444
444
|
return i4;
|
|
445
|
-
}, l = function(
|
|
446
|
-
var e4 =
|
|
445
|
+
}, l = function(t14) {
|
|
446
|
+
var e4 = t14, i4 = { getMode: function() {
|
|
447
447
|
return 1;
|
|
448
|
-
}, getLength: function(
|
|
448
|
+
}, getLength: function(t15) {
|
|
449
449
|
return e4.length;
|
|
450
|
-
}, write: function(
|
|
451
|
-
for (var i5 = e4, n4 = 0; n4 + 2 < i5.length; )
|
|
452
|
-
n4 < i5.length && (i5.length - n4 == 1 ?
|
|
453
|
-
} }, r5 = function(
|
|
454
|
-
for (var e5 = 0, i5 = 0; i5 <
|
|
450
|
+
}, write: function(t15) {
|
|
451
|
+
for (var i5 = e4, n4 = 0; n4 + 2 < i5.length; ) t15.put(r5(i5.substring(n4, n4 + 3)), 10), n4 += 3;
|
|
452
|
+
n4 < i5.length && (i5.length - n4 == 1 ? t15.put(r5(i5.substring(n4, n4 + 1)), 4) : i5.length - n4 == 2 && t15.put(r5(i5.substring(n4, n4 + 2)), 7));
|
|
453
|
+
} }, r5 = function(t15) {
|
|
454
|
+
for (var e5 = 0, i5 = 0; i5 < t15.length; i5 += 1) e5 = 10 * e5 + n3(t15.charAt(i5));
|
|
455
455
|
return e5;
|
|
456
|
-
}, n3 = function(
|
|
457
|
-
if ("0" <=
|
|
458
|
-
throw "illegal char :" +
|
|
456
|
+
}, n3 = function(t15) {
|
|
457
|
+
if ("0" <= t15 && t15 <= "9") return t15.charCodeAt(0) - "0".charCodeAt(0);
|
|
458
|
+
throw "illegal char :" + t15;
|
|
459
459
|
};
|
|
460
460
|
return i4;
|
|
461
|
-
}, g = function(
|
|
462
|
-
var e4 =
|
|
461
|
+
}, g = function(t14) {
|
|
462
|
+
var e4 = t14, i4 = { getMode: function() {
|
|
463
463
|
return 2;
|
|
464
|
-
}, getLength: function(
|
|
464
|
+
}, getLength: function(t15) {
|
|
465
465
|
return e4.length;
|
|
466
|
-
}, write: function(
|
|
467
|
-
for (var i5 = e4, n3 = 0; n3 + 1 < i5.length; )
|
|
468
|
-
n3 < i5.length &&
|
|
469
|
-
} }, r5 = function(
|
|
470
|
-
if ("0" <=
|
|
471
|
-
if ("A" <=
|
|
472
|
-
switch (
|
|
466
|
+
}, write: function(t15) {
|
|
467
|
+
for (var i5 = e4, n3 = 0; n3 + 1 < i5.length; ) t15.put(45 * r5(i5.charAt(n3)) + r5(i5.charAt(n3 + 1)), 11), n3 += 2;
|
|
468
|
+
n3 < i5.length && t15.put(r5(i5.charAt(n3)), 6);
|
|
469
|
+
} }, r5 = function(t15) {
|
|
470
|
+
if ("0" <= t15 && t15 <= "9") return t15.charCodeAt(0) - "0".charCodeAt(0);
|
|
471
|
+
if ("A" <= t15 && t15 <= "Z") return t15.charCodeAt(0) - "A".charCodeAt(0) + 10;
|
|
472
|
+
switch (t15) {
|
|
473
473
|
case " ":
|
|
474
474
|
return 36;
|
|
475
475
|
case "$":
|
|
@@ -489,31 +489,31 @@ var require_qr_code_styling = __commonJS({
|
|
|
489
489
|
case ":":
|
|
490
490
|
return 44;
|
|
491
491
|
default:
|
|
492
|
-
throw "illegal char :" +
|
|
492
|
+
throw "illegal char :" + t15;
|
|
493
493
|
}
|
|
494
494
|
};
|
|
495
495
|
return i4;
|
|
496
496
|
}, f = function(e4) {
|
|
497
|
-
var i4 =
|
|
497
|
+
var i4 = t13.stringToBytes(e4);
|
|
498
498
|
return { getMode: function() {
|
|
499
499
|
return 4;
|
|
500
|
-
}, getLength: function(
|
|
500
|
+
}, getLength: function(t14) {
|
|
501
501
|
return i4.length;
|
|
502
|
-
}, write: function(
|
|
503
|
-
for (var e5 = 0; e5 < i4.length; e5 += 1)
|
|
502
|
+
}, write: function(t14) {
|
|
503
|
+
for (var e5 = 0; e5 < i4.length; e5 += 1) t14.put(i4[e5], 8);
|
|
504
504
|
} };
|
|
505
505
|
}, w = function(e4) {
|
|
506
|
-
var i4 =
|
|
506
|
+
var i4 = t13.stringToBytesFuncs.SJIS;
|
|
507
507
|
if (!i4) throw "sjis not supported.";
|
|
508
508
|
!(function() {
|
|
509
|
-
var
|
|
510
|
-
if (2 !=
|
|
509
|
+
var t14 = i4("\u53CB");
|
|
510
|
+
if (2 != t14.length || 38726 != (t14[0] << 8 | t14[1])) throw "sjis not supported.";
|
|
511
511
|
})();
|
|
512
512
|
var r5 = i4(e4), n3 = { getMode: function() {
|
|
513
513
|
return 8;
|
|
514
|
-
}, getLength: function(
|
|
514
|
+
}, getLength: function(t14) {
|
|
515
515
|
return ~~(r5.length / 2);
|
|
516
|
-
}, write: function(
|
|
516
|
+
}, write: function(t14) {
|
|
517
517
|
for (var e5 = r5, i5 = 0; i5 + 1 < e5.length; ) {
|
|
518
518
|
var n4 = (255 & e5[i5]) << 8 | 255 & e5[i5 + 1];
|
|
519
519
|
if (33088 <= n4 && n4 <= 40956) n4 -= 33088;
|
|
@@ -521,69 +521,69 @@ var require_qr_code_styling = __commonJS({
|
|
|
521
521
|
if (!(57408 <= n4 && n4 <= 60351)) throw "illegal char at " + (i5 + 1) + "/" + n4;
|
|
522
522
|
n4 -= 49472;
|
|
523
523
|
}
|
|
524
|
-
n4 = 192 * (n4 >>> 8 & 255) + (255 & n4),
|
|
524
|
+
n4 = 192 * (n4 >>> 8 & 255) + (255 & n4), t14.put(n4, 13), i5 += 2;
|
|
525
525
|
}
|
|
526
526
|
if (i5 < e5.length) throw "illegal char at " + (i5 + 1);
|
|
527
527
|
} };
|
|
528
528
|
return n3;
|
|
529
529
|
}, p = function() {
|
|
530
|
-
var
|
|
531
|
-
|
|
532
|
-
}, writeShort: function(
|
|
533
|
-
e4.writeByte(
|
|
534
|
-
}, writeBytes: function(
|
|
535
|
-
i4 = i4 || 0, r5 = r5 ||
|
|
536
|
-
for (var n3 = 0; n3 < r5; n3 += 1) e4.writeByte(
|
|
537
|
-
}, writeString: function(
|
|
538
|
-
for (var i4 = 0; i4 <
|
|
530
|
+
var t14 = [], e4 = { writeByte: function(e5) {
|
|
531
|
+
t14.push(255 & e5);
|
|
532
|
+
}, writeShort: function(t15) {
|
|
533
|
+
e4.writeByte(t15), e4.writeByte(t15 >>> 8);
|
|
534
|
+
}, writeBytes: function(t15, i4, r5) {
|
|
535
|
+
i4 = i4 || 0, r5 = r5 || t15.length;
|
|
536
|
+
for (var n3 = 0; n3 < r5; n3 += 1) e4.writeByte(t15[n3 + i4]);
|
|
537
|
+
}, writeString: function(t15) {
|
|
538
|
+
for (var i4 = 0; i4 < t15.length; i4 += 1) e4.writeByte(t15.charCodeAt(i4));
|
|
539
539
|
}, toByteArray: function() {
|
|
540
|
-
return
|
|
540
|
+
return t14;
|
|
541
541
|
}, toString: function() {
|
|
542
542
|
var e5 = "";
|
|
543
543
|
e5 += "[";
|
|
544
|
-
for (var i4 = 0; i4 <
|
|
544
|
+
for (var i4 = 0; i4 < t14.length; i4 += 1) i4 > 0 && (e5 += ","), e5 += t14[i4];
|
|
545
545
|
return e5 + "]";
|
|
546
546
|
} };
|
|
547
547
|
return e4;
|
|
548
|
-
}, v = function(
|
|
549
|
-
var e4 =
|
|
548
|
+
}, v = function(t14) {
|
|
549
|
+
var e4 = t14, i4 = 0, r5 = 0, n3 = 0, o2 = { read: function() {
|
|
550
550
|
for (; n3 < 8; ) {
|
|
551
551
|
if (i4 >= e4.length) {
|
|
552
552
|
if (0 == n3) return -1;
|
|
553
553
|
throw "unexpected end of file./" + n3;
|
|
554
554
|
}
|
|
555
|
-
var
|
|
556
|
-
if (i4 += 1, "=" ==
|
|
557
|
-
|
|
555
|
+
var t15 = e4.charAt(i4);
|
|
556
|
+
if (i4 += 1, "=" == t15) return n3 = 0, -1;
|
|
557
|
+
t15.match(/^\s$/) || (r5 = r5 << 6 | s2(t15.charCodeAt(0)), n3 += 6);
|
|
558
558
|
}
|
|
559
559
|
var o3 = r5 >>> n3 - 8 & 255;
|
|
560
560
|
return n3 -= 8, o3;
|
|
561
|
-
} }, s2 = function(
|
|
562
|
-
if (65 <=
|
|
563
|
-
if (97 <=
|
|
564
|
-
if (48 <=
|
|
565
|
-
if (43 ==
|
|
566
|
-
if (47 ==
|
|
567
|
-
throw "c:" +
|
|
561
|
+
} }, s2 = function(t15) {
|
|
562
|
+
if (65 <= t15 && t15 <= 90) return t15 - 65;
|
|
563
|
+
if (97 <= t15 && t15 <= 122) return t15 - 97 + 26;
|
|
564
|
+
if (48 <= t15 && t15 <= 57) return t15 - 48 + 52;
|
|
565
|
+
if (43 == t15) return 62;
|
|
566
|
+
if (47 == t15) return 63;
|
|
567
|
+
throw "c:" + t15;
|
|
568
568
|
};
|
|
569
569
|
return o2;
|
|
570
|
-
}, _ = function(
|
|
571
|
-
for (var r5 = (function(
|
|
572
|
-
var i5 =
|
|
573
|
-
n4[e6 * i5 +
|
|
574
|
-
}, write: function(
|
|
575
|
-
|
|
570
|
+
}, _ = function(t14, e4, i4) {
|
|
571
|
+
for (var r5 = (function(t15, e5) {
|
|
572
|
+
var i5 = t15, r6 = e5, n4 = new Array(t15 * e5), o3 = { setPixel: function(t16, e6, r7) {
|
|
573
|
+
n4[e6 * i5 + t16] = r7;
|
|
574
|
+
}, write: function(t16) {
|
|
575
|
+
t16.writeString("GIF87a"), t16.writeShort(i5), t16.writeShort(r6), t16.writeByte(128), t16.writeByte(0), t16.writeByte(0), t16.writeByte(0), t16.writeByte(0), t16.writeByte(0), t16.writeByte(255), t16.writeByte(255), t16.writeByte(255), t16.writeString(","), t16.writeShort(0), t16.writeShort(0), t16.writeShort(i5), t16.writeShort(r6), t16.writeByte(0);
|
|
576
576
|
var e6 = s3(2);
|
|
577
|
-
|
|
578
|
-
for (var n5 = 0; e6.length - n5 > 255; )
|
|
579
|
-
|
|
580
|
-
} }, s3 = function(
|
|
581
|
-
for (var e6 = 1 <<
|
|
577
|
+
t16.writeByte(2);
|
|
578
|
+
for (var n5 = 0; e6.length - n5 > 255; ) t16.writeByte(255), t16.writeBytes(e6, n5, 255), n5 += 255;
|
|
579
|
+
t16.writeByte(e6.length - n5), t16.writeBytes(e6, n5, e6.length - n5), t16.writeByte(0), t16.writeString(";");
|
|
580
|
+
} }, s3 = function(t16) {
|
|
581
|
+
for (var e6 = 1 << t16, i6 = 1 + (1 << t16), r7 = t16 + 1, o4 = a3(), s4 = 0; s4 < e6; s4 += 1) o4.add(String.fromCharCode(s4));
|
|
582
582
|
o4.add(String.fromCharCode(e6)), o4.add(String.fromCharCode(i6));
|
|
583
|
-
var h3, d3, u2, c2 = p(), l2 = (h3 = c2, d3 = 0, u2 = 0, { write: function(
|
|
584
|
-
if (
|
|
585
|
-
for (; d3 + e7 >= 8; ) h3.writeByte(255 & (
|
|
586
|
-
u2 |=
|
|
583
|
+
var h3, d3, u2, c2 = p(), l2 = (h3 = c2, d3 = 0, u2 = 0, { write: function(t17, e7) {
|
|
584
|
+
if (t17 >>> e7 != 0) throw "length over";
|
|
585
|
+
for (; d3 + e7 >= 8; ) h3.writeByte(255 & (t17 << d3 | u2)), e7 -= 8 - d3, t17 >>>= 8 - d3, u2 = 0, d3 = 0;
|
|
586
|
+
u2 |= t17 << d3, d3 += e7;
|
|
587
587
|
}, flush: function() {
|
|
588
588
|
d3 > 0 && h3.writeByte(u2);
|
|
589
589
|
} });
|
|
@@ -595,95 +595,95 @@ var require_qr_code_styling = __commonJS({
|
|
|
595
595
|
}
|
|
596
596
|
return l2.write(o4.indexOf(f2), r7), l2.write(i6, r7), l2.flush(), c2.toByteArray();
|
|
597
597
|
}, a3 = function() {
|
|
598
|
-
var
|
|
598
|
+
var t16 = {}, e6 = 0, i6 = { add: function(r7) {
|
|
599
599
|
if (i6.contains(r7)) throw "dup key:" + r7;
|
|
600
|
-
|
|
600
|
+
t16[r7] = e6, e6 += 1;
|
|
601
601
|
}, size: function() {
|
|
602
602
|
return e6;
|
|
603
603
|
}, indexOf: function(e7) {
|
|
604
|
-
return
|
|
604
|
+
return t16[e7];
|
|
605
605
|
}, contains: function(e7) {
|
|
606
|
-
return void 0 !==
|
|
606
|
+
return void 0 !== t16[e7];
|
|
607
607
|
} };
|
|
608
608
|
return i6;
|
|
609
609
|
};
|
|
610
610
|
return o3;
|
|
611
|
-
})(
|
|
611
|
+
})(t14, e4), n3 = 0; n3 < e4; n3 += 1) for (var o2 = 0; o2 < t14; o2 += 1) r5.setPixel(o2, n3, i4(o2, n3));
|
|
612
612
|
var s2 = p();
|
|
613
613
|
r5.write(s2);
|
|
614
614
|
for (var a2 = (function() {
|
|
615
|
-
var
|
|
616
|
-
r6 += String.fromCharCode(s3(63 &
|
|
617
|
-
}, s3 = function(
|
|
618
|
-
if (
|
|
615
|
+
var t15 = 0, e5 = 0, i5 = 0, r6 = "", n4 = {}, o3 = function(t16) {
|
|
616
|
+
r6 += String.fromCharCode(s3(63 & t16));
|
|
617
|
+
}, s3 = function(t16) {
|
|
618
|
+
if (t16 < 0) ;
|
|
619
619
|
else {
|
|
620
|
-
if (
|
|
621
|
-
if (
|
|
622
|
-
if (
|
|
623
|
-
if (62 ==
|
|
624
|
-
if (63 ==
|
|
620
|
+
if (t16 < 26) return 65 + t16;
|
|
621
|
+
if (t16 < 52) return t16 - 26 + 97;
|
|
622
|
+
if (t16 < 62) return t16 - 52 + 48;
|
|
623
|
+
if (62 == t16) return 43;
|
|
624
|
+
if (63 == t16) return 47;
|
|
625
625
|
}
|
|
626
|
-
throw "n:" +
|
|
626
|
+
throw "n:" + t16;
|
|
627
627
|
};
|
|
628
628
|
return n4.writeByte = function(r7) {
|
|
629
|
-
for (
|
|
629
|
+
for (t15 = t15 << 8 | 255 & r7, e5 += 8, i5 += 1; e5 >= 6; ) o3(t15 >>> e5 - 6), e5 -= 6;
|
|
630
630
|
}, n4.flush = function() {
|
|
631
|
-
if (e5 > 0 && (o3(
|
|
631
|
+
if (e5 > 0 && (o3(t15 << 6 - e5), t15 = 0, e5 = 0), i5 % 3 != 0) for (var n5 = 3 - i5 % 3, s4 = 0; s4 < n5; s4 += 1) r6 += "=";
|
|
632
632
|
}, n4.toString = function() {
|
|
633
633
|
return r6;
|
|
634
634
|
}, n4;
|
|
635
635
|
})(), h2 = s2.toByteArray(), d2 = 0; d2 < h2.length; d2 += 1) a2.writeByte(h2[d2]);
|
|
636
636
|
return a2.flush(), "data:image/gif;base64," + a2;
|
|
637
637
|
};
|
|
638
|
-
return
|
|
638
|
+
return t13;
|
|
639
639
|
})();
|
|
640
|
-
n.stringToBytesFuncs["UTF-8"] = function(
|
|
641
|
-
return (function(
|
|
642
|
-
for (var e3 = [], i3 = 0; i3 <
|
|
643
|
-
var r4 =
|
|
644
|
-
r4 < 128 ? e3.push(r4) : r4 < 2048 ? e3.push(192 | r4 >> 6, 128 | 63 & r4) : r4 < 55296 || r4 >= 57344 ? e3.push(224 | r4 >> 12, 128 | r4 >> 6 & 63, 128 | 63 & r4) : (i3++, r4 = 65536 + ((1023 & r4) << 10 | 1023 &
|
|
640
|
+
n.stringToBytesFuncs["UTF-8"] = function(t13) {
|
|
641
|
+
return (function(t14) {
|
|
642
|
+
for (var e3 = [], i3 = 0; i3 < t14.length; i3++) {
|
|
643
|
+
var r4 = t14.charCodeAt(i3);
|
|
644
|
+
r4 < 128 ? e3.push(r4) : r4 < 2048 ? e3.push(192 | r4 >> 6, 128 | 63 & r4) : r4 < 55296 || r4 >= 57344 ? e3.push(224 | r4 >> 12, 128 | r4 >> 6 & 63, 128 | 63 & r4) : (i3++, r4 = 65536 + ((1023 & r4) << 10 | 1023 & t14.charCodeAt(i3)), e3.push(240 | r4 >> 18, 128 | r4 >> 12 & 63, 128 | r4 >> 6 & 63, 128 | 63 & r4));
|
|
645
645
|
}
|
|
646
646
|
return e3;
|
|
647
|
-
})(
|
|
647
|
+
})(t13);
|
|
648
648
|
}, void 0 === (r3 = "function" == typeof (i2 = function() {
|
|
649
649
|
return n;
|
|
650
|
-
}) ? i2.apply(e2, []) : i2) || (
|
|
650
|
+
}) ? i2.apply(e2, []) : i2) || (t12.exports = r3);
|
|
651
651
|
} }, e = {};
|
|
652
652
|
function i(r3) {
|
|
653
653
|
var n = e[r3];
|
|
654
654
|
if (void 0 !== n) return n.exports;
|
|
655
655
|
var o = e[r3] = { exports: {} };
|
|
656
|
-
return
|
|
656
|
+
return t11[r3](o, o.exports, i), o.exports;
|
|
657
657
|
}
|
|
658
|
-
i.n = (
|
|
659
|
-
var e2 =
|
|
658
|
+
i.n = (t12) => {
|
|
659
|
+
var e2 = t12 && t12.__esModule ? () => t12.default : () => t12;
|
|
660
660
|
return i.d(e2, { a: e2 }), e2;
|
|
661
|
-
}, i.d = (
|
|
662
|
-
for (var r3 in e2) i.o(e2, r3) && !i.o(
|
|
663
|
-
}, i.o = (
|
|
661
|
+
}, i.d = (t12, e2) => {
|
|
662
|
+
for (var r3 in e2) i.o(e2, r3) && !i.o(t12, r3) && Object.defineProperty(t12, r3, { enumerable: true, get: e2[r3] });
|
|
663
|
+
}, i.o = (t12, e2) => Object.prototype.hasOwnProperty.call(t12, e2);
|
|
664
664
|
var r2 = {};
|
|
665
665
|
return (() => {
|
|
666
666
|
"use strict";
|
|
667
667
|
i.d(r2, { default: () => $ });
|
|
668
|
-
const
|
|
668
|
+
const t12 = (t13) => !!t13 && "object" == typeof t13 && !Array.isArray(t13);
|
|
669
669
|
function e2(i2, ...r3) {
|
|
670
670
|
if (!r3.length) return i2;
|
|
671
671
|
const n2 = r3.shift();
|
|
672
|
-
return void 0 !== n2 &&
|
|
672
|
+
return void 0 !== n2 && t12(i2) && t12(n2) ? (i2 = Object.assign({}, i2), Object.keys(n2).forEach(((r4) => {
|
|
673
673
|
const o2 = i2[r4], s2 = n2[r4];
|
|
674
|
-
Array.isArray(o2) && Array.isArray(s2) ? i2[r4] = s2 :
|
|
674
|
+
Array.isArray(o2) && Array.isArray(s2) ? i2[r4] = s2 : t12(o2) && t12(s2) ? i2[r4] = e2(Object.assign({}, o2), s2) : i2[r4] = s2;
|
|
675
675
|
})), e2(i2, ...r3)) : i2;
|
|
676
676
|
}
|
|
677
|
-
function n(
|
|
677
|
+
function n(t13, e3) {
|
|
678
678
|
const i2 = document.createElement("a");
|
|
679
|
-
i2.download = e3, i2.href =
|
|
679
|
+
i2.download = e3, i2.href = t13, document.body.appendChild(i2), i2.click(), document.body.removeChild(i2);
|
|
680
680
|
}
|
|
681
681
|
const o = { L: 0.07, M: 0.15, Q: 0.25, H: 0.3 };
|
|
682
682
|
class s {
|
|
683
|
-
constructor({ svg:
|
|
684
|
-
this._svg =
|
|
683
|
+
constructor({ svg: t13, type: e3, window: i2 }) {
|
|
684
|
+
this._svg = t13, this._type = e3, this._window = i2;
|
|
685
685
|
}
|
|
686
|
-
draw(
|
|
686
|
+
draw(t13, e3, i2, r3) {
|
|
687
687
|
let n2;
|
|
688
688
|
switch (this._type) {
|
|
689
689
|
case "dots":
|
|
@@ -704,100 +704,100 @@ var require_qr_code_styling = __commonJS({
|
|
|
704
704
|
default:
|
|
705
705
|
n2 = this._drawSquare;
|
|
706
706
|
}
|
|
707
|
-
n2.call(this, { x:
|
|
707
|
+
n2.call(this, { x: t13, y: e3, size: i2, getNeighbor: r3 });
|
|
708
708
|
}
|
|
709
|
-
_rotateFigure({ x:
|
|
709
|
+
_rotateFigure({ x: t13, y: e3, size: i2, rotation: r3 = 0, draw: n2 }) {
|
|
710
710
|
var o2;
|
|
711
|
-
const s2 =
|
|
711
|
+
const s2 = t13 + i2 / 2, a2 = e3 + i2 / 2;
|
|
712
712
|
n2(), null === (o2 = this._element) || void 0 === o2 || o2.setAttribute("transform", `rotate(${180 * r3 / Math.PI},${s2},${a2})`);
|
|
713
713
|
}
|
|
714
|
-
_basicDot(
|
|
715
|
-
const { size: e3, x: i2, y: r3 } =
|
|
716
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
714
|
+
_basicDot(t13) {
|
|
715
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
716
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
717
717
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(i2 + e3 / 2)), this._element.setAttribute("cy", String(r3 + e3 / 2)), this._element.setAttribute("r", String(e3 / 2));
|
|
718
718
|
} }));
|
|
719
719
|
}
|
|
720
|
-
_basicSquare(
|
|
721
|
-
const { size: e3, x: i2, y: r3 } =
|
|
722
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
720
|
+
_basicSquare(t13) {
|
|
721
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
722
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
723
723
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(i2)), this._element.setAttribute("y", String(r3)), this._element.setAttribute("width", String(e3)), this._element.setAttribute("height", String(e3));
|
|
724
724
|
} }));
|
|
725
725
|
}
|
|
726
|
-
_basicSideRounded(
|
|
727
|
-
const { size: e3, x: i2, y: r3 } =
|
|
728
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
726
|
+
_basicSideRounded(t13) {
|
|
727
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
728
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
729
729
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${i2} ${r3}v ${e3}h ` + e3 / 2 + `a ${e3 / 2} ${e3 / 2}, 0, 0, 0, 0 ${-e3}`);
|
|
730
730
|
} }));
|
|
731
731
|
}
|
|
732
|
-
_basicCornerRounded(
|
|
733
|
-
const { size: e3, x: i2, y: r3 } =
|
|
734
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
732
|
+
_basicCornerRounded(t13) {
|
|
733
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
734
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
735
735
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${i2} ${r3}v ${e3}h ${e3}v ` + -e3 / 2 + `a ${e3 / 2} ${e3 / 2}, 0, 0, 0, ${-e3 / 2} ${-e3 / 2}`);
|
|
736
736
|
} }));
|
|
737
737
|
}
|
|
738
|
-
_basicCornerExtraRounded(
|
|
739
|
-
const { size: e3, x: i2, y: r3 } =
|
|
740
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
738
|
+
_basicCornerExtraRounded(t13) {
|
|
739
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
740
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
741
741
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${i2} ${r3}v ${e3}h ${e3}a ${e3} ${e3}, 0, 0, 0, ${-e3} ${-e3}`);
|
|
742
742
|
} }));
|
|
743
743
|
}
|
|
744
|
-
_basicCornersRounded(
|
|
745
|
-
const { size: e3, x: i2, y: r3 } =
|
|
746
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
744
|
+
_basicCornersRounded(t13) {
|
|
745
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
746
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
747
747
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("d", `M ${i2} ${r3}v ` + e3 / 2 + `a ${e3 / 2} ${e3 / 2}, 0, 0, 0, ${e3 / 2} ${e3 / 2}h ` + e3 / 2 + "v " + -e3 / 2 + `a ${e3 / 2} ${e3 / 2}, 0, 0, 0, ${-e3 / 2} ${-e3 / 2}`);
|
|
748
748
|
} }));
|
|
749
749
|
}
|
|
750
|
-
_drawDot({ x:
|
|
751
|
-
this._basicDot({ x:
|
|
750
|
+
_drawDot({ x: t13, y: e3, size: i2 }) {
|
|
751
|
+
this._basicDot({ x: t13, y: e3, size: i2, rotation: 0 });
|
|
752
752
|
}
|
|
753
|
-
_drawSquare({ x:
|
|
754
|
-
this._basicSquare({ x:
|
|
753
|
+
_drawSquare({ x: t13, y: e3, size: i2 }) {
|
|
754
|
+
this._basicSquare({ x: t13, y: e3, size: i2, rotation: 0 });
|
|
755
755
|
}
|
|
756
|
-
_drawRounded({ x:
|
|
756
|
+
_drawRounded({ x: t13, y: e3, size: i2, getNeighbor: r3 }) {
|
|
757
757
|
const n2 = r3 ? +r3(-1, 0) : 0, o2 = r3 ? +r3(1, 0) : 0, s2 = r3 ? +r3(0, -1) : 0, a2 = r3 ? +r3(0, 1) : 0, h2 = n2 + o2 + s2 + a2;
|
|
758
|
-
if (0 !== h2) if (h2 > 2 || n2 && o2 || s2 && a2) this._basicSquare({ x:
|
|
758
|
+
if (0 !== h2) if (h2 > 2 || n2 && o2 || s2 && a2) this._basicSquare({ x: t13, y: e3, size: i2, rotation: 0 });
|
|
759
759
|
else {
|
|
760
760
|
if (2 === h2) {
|
|
761
761
|
let r4 = 0;
|
|
762
|
-
return n2 && s2 ? r4 = Math.PI / 2 : s2 && o2 ? r4 = Math.PI : o2 && a2 && (r4 = -Math.PI / 2), void this._basicCornerRounded({ x:
|
|
762
|
+
return n2 && s2 ? r4 = Math.PI / 2 : s2 && o2 ? r4 = Math.PI : o2 && a2 && (r4 = -Math.PI / 2), void this._basicCornerRounded({ x: t13, y: e3, size: i2, rotation: r4 });
|
|
763
763
|
}
|
|
764
764
|
if (1 === h2) {
|
|
765
765
|
let r4 = 0;
|
|
766
|
-
return s2 ? r4 = Math.PI / 2 : o2 ? r4 = Math.PI : a2 && (r4 = -Math.PI / 2), void this._basicSideRounded({ x:
|
|
766
|
+
return s2 ? r4 = Math.PI / 2 : o2 ? r4 = Math.PI : a2 && (r4 = -Math.PI / 2), void this._basicSideRounded({ x: t13, y: e3, size: i2, rotation: r4 });
|
|
767
767
|
}
|
|
768
768
|
}
|
|
769
|
-
else this._basicDot({ x:
|
|
769
|
+
else this._basicDot({ x: t13, y: e3, size: i2, rotation: 0 });
|
|
770
770
|
}
|
|
771
|
-
_drawExtraRounded({ x:
|
|
771
|
+
_drawExtraRounded({ x: t13, y: e3, size: i2, getNeighbor: r3 }) {
|
|
772
772
|
const n2 = r3 ? +r3(-1, 0) : 0, o2 = r3 ? +r3(1, 0) : 0, s2 = r3 ? +r3(0, -1) : 0, a2 = r3 ? +r3(0, 1) : 0, h2 = n2 + o2 + s2 + a2;
|
|
773
|
-
if (0 !== h2) if (h2 > 2 || n2 && o2 || s2 && a2) this._basicSquare({ x:
|
|
773
|
+
if (0 !== h2) if (h2 > 2 || n2 && o2 || s2 && a2) this._basicSquare({ x: t13, y: e3, size: i2, rotation: 0 });
|
|
774
774
|
else {
|
|
775
775
|
if (2 === h2) {
|
|
776
776
|
let r4 = 0;
|
|
777
|
-
return n2 && s2 ? r4 = Math.PI / 2 : s2 && o2 ? r4 = Math.PI : o2 && a2 && (r4 = -Math.PI / 2), void this._basicCornerExtraRounded({ x:
|
|
777
|
+
return n2 && s2 ? r4 = Math.PI / 2 : s2 && o2 ? r4 = Math.PI : o2 && a2 && (r4 = -Math.PI / 2), void this._basicCornerExtraRounded({ x: t13, y: e3, size: i2, rotation: r4 });
|
|
778
778
|
}
|
|
779
779
|
if (1 === h2) {
|
|
780
780
|
let r4 = 0;
|
|
781
|
-
return s2 ? r4 = Math.PI / 2 : o2 ? r4 = Math.PI : a2 && (r4 = -Math.PI / 2), void this._basicSideRounded({ x:
|
|
781
|
+
return s2 ? r4 = Math.PI / 2 : o2 ? r4 = Math.PI : a2 && (r4 = -Math.PI / 2), void this._basicSideRounded({ x: t13, y: e3, size: i2, rotation: r4 });
|
|
782
782
|
}
|
|
783
783
|
}
|
|
784
|
-
else this._basicDot({ x:
|
|
784
|
+
else this._basicDot({ x: t13, y: e3, size: i2, rotation: 0 });
|
|
785
785
|
}
|
|
786
|
-
_drawClassy({ x:
|
|
786
|
+
_drawClassy({ x: t13, y: e3, size: i2, getNeighbor: r3 }) {
|
|
787
787
|
const n2 = r3 ? +r3(-1, 0) : 0, o2 = r3 ? +r3(1, 0) : 0, s2 = r3 ? +r3(0, -1) : 0, a2 = r3 ? +r3(0, 1) : 0;
|
|
788
|
-
0 !== n2 + o2 + s2 + a2 ? n2 || s2 ? o2 || a2 ? this._basicSquare({ x:
|
|
788
|
+
0 !== n2 + o2 + s2 + a2 ? n2 || s2 ? o2 || a2 ? this._basicSquare({ x: t13, y: e3, size: i2, rotation: 0 }) : this._basicCornerRounded({ x: t13, y: e3, size: i2, rotation: Math.PI / 2 }) : this._basicCornerRounded({ x: t13, y: e3, size: i2, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: t13, y: e3, size: i2, rotation: Math.PI / 2 });
|
|
789
789
|
}
|
|
790
|
-
_drawClassyRounded({ x:
|
|
790
|
+
_drawClassyRounded({ x: t13, y: e3, size: i2, getNeighbor: r3 }) {
|
|
791
791
|
const n2 = r3 ? +r3(-1, 0) : 0, o2 = r3 ? +r3(1, 0) : 0, s2 = r3 ? +r3(0, -1) : 0, a2 = r3 ? +r3(0, 1) : 0;
|
|
792
|
-
0 !== n2 + o2 + s2 + a2 ? n2 || s2 ? o2 || a2 ? this._basicSquare({ x:
|
|
792
|
+
0 !== n2 + o2 + s2 + a2 ? n2 || s2 ? o2 || a2 ? this._basicSquare({ x: t13, y: e3, size: i2, rotation: 0 }) : this._basicCornerExtraRounded({ x: t13, y: e3, size: i2, rotation: Math.PI / 2 }) : this._basicCornerExtraRounded({ x: t13, y: e3, size: i2, rotation: -Math.PI / 2 }) : this._basicCornersRounded({ x: t13, y: e3, size: i2, rotation: Math.PI / 2 });
|
|
793
793
|
}
|
|
794
794
|
}
|
|
795
795
|
const a = { dot: "dot", square: "square", extraRounded: "extra-rounded" }, h = Object.values(a);
|
|
796
796
|
class d {
|
|
797
|
-
constructor({ svg:
|
|
798
|
-
this._svg =
|
|
797
|
+
constructor({ svg: t13, type: e3, window: i2 }) {
|
|
798
|
+
this._svg = t13, this._type = e3, this._window = i2;
|
|
799
799
|
}
|
|
800
|
-
draw(
|
|
800
|
+
draw(t13, e3, i2, r3) {
|
|
801
801
|
let n2;
|
|
802
802
|
switch (this._type) {
|
|
803
803
|
case a.square:
|
|
@@ -809,78 +809,78 @@ var require_qr_code_styling = __commonJS({
|
|
|
809
809
|
default:
|
|
810
810
|
n2 = this._drawDot;
|
|
811
811
|
}
|
|
812
|
-
n2.call(this, { x:
|
|
812
|
+
n2.call(this, { x: t13, y: e3, size: i2, rotation: r3 });
|
|
813
813
|
}
|
|
814
|
-
_rotateFigure({ x:
|
|
814
|
+
_rotateFigure({ x: t13, y: e3, size: i2, rotation: r3 = 0, draw: n2 }) {
|
|
815
815
|
var o2;
|
|
816
|
-
const s2 =
|
|
816
|
+
const s2 = t13 + i2 / 2, a2 = e3 + i2 / 2;
|
|
817
817
|
n2(), null === (o2 = this._element) || void 0 === o2 || o2.setAttribute("transform", `rotate(${180 * r3 / Math.PI},${s2},${a2})`);
|
|
818
818
|
}
|
|
819
|
-
_basicDot(
|
|
820
|
-
const { size: e3, x: i2, y: r3 } =
|
|
821
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
819
|
+
_basicDot(t13) {
|
|
820
|
+
const { size: e3, x: i2, y: r3 } = t13, n2 = e3 / 7;
|
|
821
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
822
822
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${i2 + e3 / 2} ${r3}a ${e3 / 2} ${e3 / 2} 0 1 0 0.1 0zm 0 ${n2}a ${e3 / 2 - n2} ${e3 / 2 - n2} 0 1 1 -0.1 0Z`);
|
|
823
823
|
} }));
|
|
824
824
|
}
|
|
825
|
-
_basicSquare(
|
|
826
|
-
const { size: e3, x: i2, y: r3 } =
|
|
827
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
825
|
+
_basicSquare(t13) {
|
|
826
|
+
const { size: e3, x: i2, y: r3 } = t13, n2 = e3 / 7;
|
|
827
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
828
828
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${i2} ${r3}v ${e3}h ${e3}v ` + -e3 + `zM ${i2 + n2} ${r3 + n2}h ` + (e3 - 2 * n2) + "v " + (e3 - 2 * n2) + "h " + (2 * n2 - e3) + "z");
|
|
829
829
|
} }));
|
|
830
830
|
}
|
|
831
|
-
_basicExtraRounded(
|
|
832
|
-
const { size: e3, x: i2, y: r3 } =
|
|
833
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
831
|
+
_basicExtraRounded(t13) {
|
|
832
|
+
const { size: e3, x: i2, y: r3 } = t13, n2 = e3 / 7;
|
|
833
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
834
834
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "path"), this._element.setAttribute("clip-rule", "evenodd"), this._element.setAttribute("d", `M ${i2} ${r3 + 2.5 * n2}v ` + 2 * n2 + `a ${2.5 * n2} ${2.5 * n2}, 0, 0, 0, ${2.5 * n2} ${2.5 * n2}h ` + 2 * n2 + `a ${2.5 * n2} ${2.5 * n2}, 0, 0, 0, ${2.5 * n2} ${2.5 * -n2}v ` + -2 * n2 + `a ${2.5 * n2} ${2.5 * n2}, 0, 0, 0, ${2.5 * -n2} ${2.5 * -n2}h ` + -2 * n2 + `a ${2.5 * n2} ${2.5 * n2}, 0, 0, 0, ${2.5 * -n2} ${2.5 * n2}M ${i2 + 2.5 * n2} ${r3 + n2}h ` + 2 * n2 + `a ${1.5 * n2} ${1.5 * n2}, 0, 0, 1, ${1.5 * n2} ${1.5 * n2}v ` + 2 * n2 + `a ${1.5 * n2} ${1.5 * n2}, 0, 0, 1, ${1.5 * -n2} ${1.5 * n2}h ` + -2 * n2 + `a ${1.5 * n2} ${1.5 * n2}, 0, 0, 1, ${1.5 * -n2} ${1.5 * -n2}v ` + -2 * n2 + `a ${1.5 * n2} ${1.5 * n2}, 0, 0, 1, ${1.5 * n2} ${1.5 * -n2}`);
|
|
835
835
|
} }));
|
|
836
836
|
}
|
|
837
|
-
_drawDot({ x:
|
|
838
|
-
this._basicDot({ x:
|
|
837
|
+
_drawDot({ x: t13, y: e3, size: i2, rotation: r3 }) {
|
|
838
|
+
this._basicDot({ x: t13, y: e3, size: i2, rotation: r3 });
|
|
839
839
|
}
|
|
840
|
-
_drawSquare({ x:
|
|
841
|
-
this._basicSquare({ x:
|
|
840
|
+
_drawSquare({ x: t13, y: e3, size: i2, rotation: r3 }) {
|
|
841
|
+
this._basicSquare({ x: t13, y: e3, size: i2, rotation: r3 });
|
|
842
842
|
}
|
|
843
|
-
_drawExtraRounded({ x:
|
|
844
|
-
this._basicExtraRounded({ x:
|
|
843
|
+
_drawExtraRounded({ x: t13, y: e3, size: i2, rotation: r3 }) {
|
|
844
|
+
this._basicExtraRounded({ x: t13, y: e3, size: i2, rotation: r3 });
|
|
845
845
|
}
|
|
846
846
|
}
|
|
847
847
|
const u = { dot: "dot", square: "square" }, c = Object.values(u);
|
|
848
848
|
class l {
|
|
849
|
-
constructor({ svg:
|
|
850
|
-
this._svg =
|
|
849
|
+
constructor({ svg: t13, type: e3, window: i2 }) {
|
|
850
|
+
this._svg = t13, this._type = e3, this._window = i2;
|
|
851
851
|
}
|
|
852
|
-
draw(
|
|
852
|
+
draw(t13, e3, i2, r3) {
|
|
853
853
|
let n2;
|
|
854
|
-
n2 = this._type === u.square ? this._drawSquare : this._drawDot, n2.call(this, { x:
|
|
854
|
+
n2 = this._type === u.square ? this._drawSquare : this._drawDot, n2.call(this, { x: t13, y: e3, size: i2, rotation: r3 });
|
|
855
855
|
}
|
|
856
|
-
_rotateFigure({ x:
|
|
856
|
+
_rotateFigure({ x: t13, y: e3, size: i2, rotation: r3 = 0, draw: n2 }) {
|
|
857
857
|
var o2;
|
|
858
|
-
const s2 =
|
|
858
|
+
const s2 = t13 + i2 / 2, a2 = e3 + i2 / 2;
|
|
859
859
|
n2(), null === (o2 = this._element) || void 0 === o2 || o2.setAttribute("transform", `rotate(${180 * r3 / Math.PI},${s2},${a2})`);
|
|
860
860
|
}
|
|
861
|
-
_basicDot(
|
|
862
|
-
const { size: e3, x: i2, y: r3 } =
|
|
863
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
861
|
+
_basicDot(t13) {
|
|
862
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
863
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
864
864
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "circle"), this._element.setAttribute("cx", String(i2 + e3 / 2)), this._element.setAttribute("cy", String(r3 + e3 / 2)), this._element.setAttribute("r", String(e3 / 2));
|
|
865
865
|
} }));
|
|
866
866
|
}
|
|
867
|
-
_basicSquare(
|
|
868
|
-
const { size: e3, x: i2, y: r3 } =
|
|
869
|
-
this._rotateFigure(Object.assign(Object.assign({},
|
|
867
|
+
_basicSquare(t13) {
|
|
868
|
+
const { size: e3, x: i2, y: r3 } = t13;
|
|
869
|
+
this._rotateFigure(Object.assign(Object.assign({}, t13), { draw: () => {
|
|
870
870
|
this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect"), this._element.setAttribute("x", String(i2)), this._element.setAttribute("y", String(r3)), this._element.setAttribute("width", String(e3)), this._element.setAttribute("height", String(e3));
|
|
871
871
|
} }));
|
|
872
872
|
}
|
|
873
|
-
_drawDot({ x:
|
|
874
|
-
this._basicDot({ x:
|
|
873
|
+
_drawDot({ x: t13, y: e3, size: i2, rotation: r3 }) {
|
|
874
|
+
this._basicDot({ x: t13, y: e3, size: i2, rotation: r3 });
|
|
875
875
|
}
|
|
876
|
-
_drawSquare({ x:
|
|
877
|
-
this._basicSquare({ x:
|
|
876
|
+
_drawSquare({ x: t13, y: e3, size: i2, rotation: r3 }) {
|
|
877
|
+
this._basicSquare({ x: t13, y: e3, size: i2, rotation: r3 });
|
|
878
878
|
}
|
|
879
879
|
}
|
|
880
880
|
const g = "circle", f = [[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]], w = [[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]];
|
|
881
881
|
class p {
|
|
882
|
-
constructor(
|
|
883
|
-
this._roundSize = (
|
|
882
|
+
constructor(t13, e3) {
|
|
883
|
+
this._roundSize = (t14) => this._options.dotsOptions.roundSize ? Math.floor(t14) : t14, this._window = e3, this._element = this._window.document.createElementNS("http://www.w3.org/2000/svg", "svg"), this._element.setAttribute("width", String(t13.width)), this._element.setAttribute("height", String(t13.height)), this._element.setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink"), t13.dotsOptions.roundSize || this._element.setAttribute("shape-rendering", "crispEdges"), this._element.setAttribute("viewBox", `0 0 ${t13.width} ${t13.height}`), this._defs = this._window.document.createElementNS("http://www.w3.org/2000/svg", "defs"), this._element.appendChild(this._defs), this._imageUri = t13.image, this._instanceId = p.instanceCount++, this._options = t13;
|
|
884
884
|
}
|
|
885
885
|
get width() {
|
|
886
886
|
return this._options.width;
|
|
@@ -891,135 +891,135 @@ var require_qr_code_styling = __commonJS({
|
|
|
891
891
|
getElement() {
|
|
892
892
|
return this._element;
|
|
893
893
|
}
|
|
894
|
-
async drawQR(
|
|
895
|
-
const e3 =
|
|
894
|
+
async drawQR(t13) {
|
|
895
|
+
const e3 = t13.getModuleCount(), i2 = Math.min(this._options.width, this._options.height) - 2 * this._options.margin, r3 = this._options.shape === g ? i2 / Math.sqrt(2) : i2, n2 = this._roundSize(r3 / e3);
|
|
896
896
|
let s2 = { hideXDots: 0, hideYDots: 0, width: 0, height: 0 };
|
|
897
|
-
if (this._qr =
|
|
897
|
+
if (this._qr = t13, this._options.image) {
|
|
898
898
|
if (await this.loadImage(), !this._image) return;
|
|
899
|
-
const { imageOptions:
|
|
900
|
-
s2 = (function({ originalHeight:
|
|
899
|
+
const { imageOptions: t14, qrOptions: i3 } = this._options, r4 = t14.imageSize * o[i3.errorCorrectionLevel], a2 = Math.floor(r4 * e3 * e3);
|
|
900
|
+
s2 = (function({ originalHeight: t15, originalWidth: e4, maxHiddenDots: i4, maxHiddenAxisDots: r5, dotSize: n3 }) {
|
|
901
901
|
const o2 = { x: 0, y: 0 }, s3 = { x: 0, y: 0 };
|
|
902
|
-
if (
|
|
903
|
-
const a3 =
|
|
902
|
+
if (t15 <= 0 || e4 <= 0 || i4 <= 0 || n3 <= 0) return { height: 0, width: 0, hideYDots: 0, hideXDots: 0 };
|
|
903
|
+
const a3 = t15 / e4;
|
|
904
904
|
return o2.x = Math.floor(Math.sqrt(i4 / a3)), o2.x <= 0 && (o2.x = 1), r5 && r5 < o2.x && (o2.x = r5), o2.x % 2 == 0 && o2.x--, s3.x = o2.x * n3, o2.y = 1 + 2 * Math.ceil((o2.x * a3 - 1) / 2), s3.y = Math.round(s3.x * a3), (o2.y * o2.x > i4 || r5 && r5 < o2.y) && (r5 && r5 < o2.y ? (o2.y = r5, o2.y % 2 == 0 && o2.x--) : o2.y -= 2, s3.y = o2.y * n3, o2.x = 1 + 2 * Math.ceil((o2.y / a3 - 1) / 2), s3.x = Math.round(s3.y / a3)), { height: s3.y, width: s3.x, hideYDots: o2.y, hideXDots: o2.x };
|
|
905
905
|
})({ originalWidth: this._image.width, originalHeight: this._image.height, maxHiddenDots: a2, maxHiddenAxisDots: e3 - 14, dotSize: n2 });
|
|
906
906
|
}
|
|
907
|
-
this.drawBackground(), this.drawDots(((
|
|
907
|
+
this.drawBackground(), this.drawDots(((t14, i3) => {
|
|
908
908
|
var r4, n3, o2, a2, h2, d2;
|
|
909
|
-
return !(this._options.imageOptions.hideBackgroundDots &&
|
|
909
|
+
return !(this._options.imageOptions.hideBackgroundDots && t14 >= (e3 - s2.hideYDots) / 2 && t14 < (e3 + s2.hideYDots) / 2 && i3 >= (e3 - s2.hideXDots) / 2 && i3 < (e3 + s2.hideXDots) / 2 || (null === (r4 = f[t14]) || void 0 === r4 ? void 0 : r4[i3]) || (null === (n3 = f[t14 - e3 + 7]) || void 0 === n3 ? void 0 : n3[i3]) || (null === (o2 = f[t14]) || void 0 === o2 ? void 0 : o2[i3 - e3 + 7]) || (null === (a2 = w[t14]) || void 0 === a2 ? void 0 : a2[i3]) || (null === (h2 = w[t14 - e3 + 7]) || void 0 === h2 ? void 0 : h2[i3]) || (null === (d2 = w[t14]) || void 0 === d2 ? void 0 : d2[i3 - e3 + 7]));
|
|
910
910
|
})), this.drawCorners(), this._options.image && await this.drawImage({ width: s2.width, height: s2.height, count: e3, dotSize: n2 });
|
|
911
911
|
}
|
|
912
912
|
drawBackground() {
|
|
913
|
-
var
|
|
913
|
+
var t13, e3, i2;
|
|
914
914
|
const r3 = this._element, n2 = this._options;
|
|
915
915
|
if (r3) {
|
|
916
|
-
const r4 = null === (
|
|
916
|
+
const r4 = null === (t13 = n2.backgroundOptions) || void 0 === t13 ? void 0 : t13.gradient, o2 = null === (e3 = n2.backgroundOptions) || void 0 === e3 ? void 0 : e3.color;
|
|
917
917
|
let s2 = n2.height, a2 = n2.width;
|
|
918
918
|
if (r4 || o2) {
|
|
919
|
-
const
|
|
920
|
-
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), (null === (i2 = n2.backgroundOptions) || void 0 === i2 ? void 0 : i2.round) && (s2 = a2 = Math.min(n2.width, n2.height),
|
|
919
|
+
const t14 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
920
|
+
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), (null === (i2 = n2.backgroundOptions) || void 0 === i2 ? void 0 : i2.round) && (s2 = a2 = Math.min(n2.width, n2.height), t14.setAttribute("rx", String(s2 / 2 * n2.backgroundOptions.round))), t14.setAttribute("x", String(this._roundSize((n2.width - a2) / 2))), t14.setAttribute("y", String(this._roundSize((n2.height - s2) / 2))), t14.setAttribute("width", String(a2)), t14.setAttribute("height", String(s2)), this._backgroundClipPath.appendChild(t14), this._createColor({ options: r4, color: o2, additionalRotation: 0, x: 0, y: 0, height: n2.height, width: n2.width, name: `background-color-${this._instanceId}` });
|
|
921
921
|
}
|
|
922
922
|
}
|
|
923
923
|
}
|
|
924
|
-
drawDots(
|
|
924
|
+
drawDots(t13) {
|
|
925
925
|
var e3, i2;
|
|
926
926
|
if (!this._qr) throw "QR code is not defined";
|
|
927
927
|
const r3 = this._options, n2 = this._qr.getModuleCount();
|
|
928
928
|
if (n2 > r3.width || n2 > r3.height) throw "The canvas is too small.";
|
|
929
929
|
const o2 = Math.min(r3.width, r3.height) - 2 * r3.margin, a2 = r3.shape === g ? o2 / Math.sqrt(2) : o2, h2 = this._roundSize(a2 / n2), d2 = this._roundSize((r3.width - n2 * h2) / 2), u2 = this._roundSize((r3.height - n2 * h2) / 2), c2 = new s({ svg: this._element, type: r3.dotsOptions.type, window: this._window });
|
|
930
930
|
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: null === (e3 = r3.dotsOptions) || void 0 === e3 ? void 0 : e3.gradient, color: r3.dotsOptions.color, additionalRotation: 0, x: 0, y: 0, height: r3.height, width: r3.width, name: `dot-color-${this._instanceId}` });
|
|
931
|
-
for (let e4 = 0; e4 < n2; e4++) for (let r4 = 0; r4 < n2; r4++)
|
|
931
|
+
for (let e4 = 0; e4 < n2; e4++) for (let r4 = 0; r4 < n2; r4++) t13 && !t13(e4, r4) || (null === (i2 = this._qr) || void 0 === i2 ? void 0 : i2.isDark(e4, r4)) && (c2.draw(d2 + r4 * h2, u2 + e4 * h2, h2, ((i3, o3) => !(r4 + i3 < 0 || e4 + o3 < 0 || r4 + i3 >= n2 || e4 + o3 >= n2) && !(t13 && !t13(e4 + o3, r4 + i3)) && !!this._qr && this._qr.isDark(e4 + o3, r4 + i3))), c2._element && this._dotsClipPath && this._dotsClipPath.appendChild(c2._element));
|
|
932
932
|
if (r3.shape === g) {
|
|
933
|
-
const
|
|
933
|
+
const t14 = this._roundSize((o2 / h2 - n2) / 2), e4 = n2 + 2 * t14, i3 = d2 - t14 * h2, r4 = u2 - t14 * h2, s2 = [], a3 = this._roundSize(e4 / 2);
|
|
934
934
|
for (let i4 = 0; i4 < e4; i4++) {
|
|
935
935
|
s2[i4] = [];
|
|
936
|
-
for (let r5 = 0; r5 < e4; r5++) i4 >=
|
|
936
|
+
for (let r5 = 0; r5 < e4; r5++) i4 >= t14 - 1 && i4 <= e4 - t14 && r5 >= t14 - 1 && r5 <= e4 - t14 || Math.sqrt((i4 - a3) * (i4 - a3) + (r5 - a3) * (r5 - a3)) > a3 ? s2[i4][r5] = 0 : s2[i4][r5] = this._qr.isDark(r5 - 2 * t14 < 0 ? r5 : r5 >= n2 ? r5 - 2 * t14 : r5 - t14, i4 - 2 * t14 < 0 ? i4 : i4 >= n2 ? i4 - 2 * t14 : i4 - t14) ? 1 : 0;
|
|
937
937
|
}
|
|
938
|
-
for (let
|
|
938
|
+
for (let t15 = 0; t15 < e4; t15++) for (let n3 = 0; n3 < e4; n3++) s2[t15][n3] && (c2.draw(i3 + n3 * h2, r4 + t15 * h2, h2, ((e5, i4) => {
|
|
939
939
|
var r5;
|
|
940
|
-
return !!(null === (r5 = s2[
|
|
940
|
+
return !!(null === (r5 = s2[t15 + i4]) || void 0 === r5 ? void 0 : r5[n3 + e5]);
|
|
941
941
|
})), c2._element && this._dotsClipPath && this._dotsClipPath.appendChild(c2._element));
|
|
942
942
|
}
|
|
943
943
|
}
|
|
944
944
|
drawCorners() {
|
|
945
945
|
if (!this._qr) throw "QR code is not defined";
|
|
946
|
-
const
|
|
947
|
-
if (!
|
|
946
|
+
const t13 = this._element, e3 = this._options;
|
|
947
|
+
if (!t13) throw "Element code is not defined";
|
|
948
948
|
const i2 = this._qr.getModuleCount(), r3 = Math.min(e3.width, e3.height) - 2 * e3.margin, n2 = e3.shape === g ? r3 / Math.sqrt(2) : r3, o2 = this._roundSize(n2 / i2), a2 = 7 * o2, u2 = 3 * o2, p2 = this._roundSize((e3.width - i2 * o2) / 2), v2 = this._roundSize((e3.height - i2 * o2) / 2);
|
|
949
|
-
[[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach((([
|
|
949
|
+
[[0, 0, 0], [1, 0, Math.PI / 2], [0, 1, -Math.PI / 2]].forEach((([t14, r4, n3]) => {
|
|
950
950
|
var g2, _2, m2, b2, y2, x2, S2, C2, A2, M2, $2, O, D, k;
|
|
951
|
-
const z = p2 +
|
|
951
|
+
const z = p2 + t14 * o2 * (i2 - 7), B = v2 + r4 * o2 * (i2 - 7);
|
|
952
952
|
let P = this._dotsClipPath, I = this._dotsClipPath;
|
|
953
|
-
if (((null === (g2 = e3.cornersSquareOptions) || void 0 === g2 ? void 0 : g2.gradient) || (null === (_2 = e3.cornersSquareOptions) || void 0 === _2 ? void 0 : _2.color)) && (P = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), P.setAttribute("id", `clip-path-corners-square-color-${
|
|
954
|
-
const
|
|
955
|
-
|
|
953
|
+
if (((null === (g2 = e3.cornersSquareOptions) || void 0 === g2 ? void 0 : g2.gradient) || (null === (_2 = e3.cornersSquareOptions) || void 0 === _2 ? void 0 : _2.color)) && (P = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), P.setAttribute("id", `clip-path-corners-square-color-${t14}-${r4}-${this._instanceId}`), this._defs.appendChild(P), this._cornersSquareClipPath = this._cornersDotClipPath = I = P, this._createColor({ options: null === (m2 = e3.cornersSquareOptions) || void 0 === m2 ? void 0 : m2.gradient, color: null === (b2 = e3.cornersSquareOptions) || void 0 === b2 ? void 0 : b2.color, additionalRotation: n3, x: z, y: B, height: a2, width: a2, name: `corners-square-color-${t14}-${r4}-${this._instanceId}` })), (null === (y2 = e3.cornersSquareOptions) || void 0 === y2 ? void 0 : y2.type) && h.includes(e3.cornersSquareOptions.type)) {
|
|
954
|
+
const t15 = new d({ svg: this._element, type: e3.cornersSquareOptions.type, window: this._window });
|
|
955
|
+
t15.draw(z, B, a2, n3), t15._element && P && P.appendChild(t15._element);
|
|
956
956
|
} else {
|
|
957
|
-
const
|
|
958
|
-
for (let e4 = 0; e4 < f.length; e4++) for (let i3 = 0; i3 < f[e4].length; i3++) (null === (S2 = f[e4]) || void 0 === S2 ? void 0 : S2[i3]) && (
|
|
957
|
+
const t15 = new s({ svg: this._element, type: (null === (x2 = e3.cornersSquareOptions) || void 0 === x2 ? void 0 : x2.type) || e3.dotsOptions.type, window: this._window });
|
|
958
|
+
for (let e4 = 0; e4 < f.length; e4++) for (let i3 = 0; i3 < f[e4].length; i3++) (null === (S2 = f[e4]) || void 0 === S2 ? void 0 : S2[i3]) && (t15.draw(z + i3 * o2, B + e4 * o2, o2, ((t16, r5) => {
|
|
959
959
|
var n4;
|
|
960
|
-
return !!(null === (n4 = f[e4 + r5]) || void 0 === n4 ? void 0 : n4[i3 +
|
|
961
|
-
})),
|
|
960
|
+
return !!(null === (n4 = f[e4 + r5]) || void 0 === n4 ? void 0 : n4[i3 + t16]);
|
|
961
|
+
})), t15._element && P && P.appendChild(t15._element));
|
|
962
962
|
}
|
|
963
|
-
if (((null === (C2 = e3.cornersDotOptions) || void 0 === C2 ? void 0 : C2.gradient) || (null === (A2 = e3.cornersDotOptions) || void 0 === A2 ? void 0 : A2.color)) && (I = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), I.setAttribute("id", `clip-path-corners-dot-color-${
|
|
964
|
-
const
|
|
965
|
-
|
|
963
|
+
if (((null === (C2 = e3.cornersDotOptions) || void 0 === C2 ? void 0 : C2.gradient) || (null === (A2 = e3.cornersDotOptions) || void 0 === A2 ? void 0 : A2.color)) && (I = this._window.document.createElementNS("http://www.w3.org/2000/svg", "clipPath"), I.setAttribute("id", `clip-path-corners-dot-color-${t14}-${r4}-${this._instanceId}`), this._defs.appendChild(I), this._cornersDotClipPath = I, this._createColor({ options: null === (M2 = e3.cornersDotOptions) || void 0 === M2 ? void 0 : M2.gradient, color: null === ($2 = e3.cornersDotOptions) || void 0 === $2 ? void 0 : $2.color, additionalRotation: n3, x: z + 2 * o2, y: B + 2 * o2, height: u2, width: u2, name: `corners-dot-color-${t14}-${r4}-${this._instanceId}` })), (null === (O = e3.cornersDotOptions) || void 0 === O ? void 0 : O.type) && c.includes(e3.cornersDotOptions.type)) {
|
|
964
|
+
const t15 = new l({ svg: this._element, type: e3.cornersDotOptions.type, window: this._window });
|
|
965
|
+
t15.draw(z + 2 * o2, B + 2 * o2, u2, n3), t15._element && I && I.appendChild(t15._element);
|
|
966
966
|
} else {
|
|
967
|
-
const
|
|
968
|
-
for (let e4 = 0; e4 < w.length; e4++) for (let i3 = 0; i3 < w[e4].length; i3++) (null === (k = w[e4]) || void 0 === k ? void 0 : k[i3]) && (
|
|
967
|
+
const t15 = new s({ svg: this._element, type: (null === (D = e3.cornersDotOptions) || void 0 === D ? void 0 : D.type) || e3.dotsOptions.type, window: this._window });
|
|
968
|
+
for (let e4 = 0; e4 < w.length; e4++) for (let i3 = 0; i3 < w[e4].length; i3++) (null === (k = w[e4]) || void 0 === k ? void 0 : k[i3]) && (t15.draw(z + i3 * o2, B + e4 * o2, o2, ((t16, r5) => {
|
|
969
969
|
var n4;
|
|
970
|
-
return !!(null === (n4 = w[e4 + r5]) || void 0 === n4 ? void 0 : n4[i3 +
|
|
971
|
-
})),
|
|
970
|
+
return !!(null === (n4 = w[e4 + r5]) || void 0 === n4 ? void 0 : n4[i3 + t16]);
|
|
971
|
+
})), t15._element && I && I.appendChild(t15._element));
|
|
972
972
|
}
|
|
973
973
|
}));
|
|
974
974
|
}
|
|
975
975
|
loadImage() {
|
|
976
|
-
return new Promise(((
|
|
976
|
+
return new Promise(((t13, e3) => {
|
|
977
977
|
var i2;
|
|
978
978
|
const r3 = this._options;
|
|
979
979
|
if (!r3.image) return e3("Image is not defined");
|
|
980
980
|
if (null === (i2 = r3.nodeCanvas) || void 0 === i2 ? void 0 : i2.loadImage) r3.nodeCanvas.loadImage(r3.image).then(((e4) => {
|
|
981
981
|
var i3, n2;
|
|
982
982
|
if (this._image = e4, this._options.imageOptions.saveAsBlob) {
|
|
983
|
-
const
|
|
984
|
-
null === (n2 = null ==
|
|
983
|
+
const t14 = null === (i3 = r3.nodeCanvas) || void 0 === i3 ? void 0 : i3.createCanvas(this._image.width, this._image.height);
|
|
984
|
+
null === (n2 = null == t14 ? void 0 : t14.getContext("2d")) || void 0 === n2 || n2.drawImage(e4, 0, 0), this._imageUri = null == t14 ? void 0 : t14.toDataURL();
|
|
985
985
|
}
|
|
986
|
-
|
|
986
|
+
t13();
|
|
987
987
|
})).catch(e3);
|
|
988
988
|
else {
|
|
989
989
|
const e4 = new this._window.Image();
|
|
990
990
|
"string" == typeof r3.imageOptions.crossOrigin && (e4.crossOrigin = r3.imageOptions.crossOrigin), this._image = e4, e4.onload = async () => {
|
|
991
|
-
this._options.imageOptions.saveAsBlob && (this._imageUri = await (async function(
|
|
991
|
+
this._options.imageOptions.saveAsBlob && (this._imageUri = await (async function(t14, e5) {
|
|
992
992
|
return new Promise(((i3) => {
|
|
993
993
|
const r4 = new e5.XMLHttpRequest();
|
|
994
994
|
r4.onload = function() {
|
|
995
|
-
const
|
|
996
|
-
|
|
997
|
-
i3(
|
|
998
|
-
},
|
|
999
|
-
}, r4.open("GET",
|
|
995
|
+
const t15 = new e5.FileReader();
|
|
996
|
+
t15.onloadend = function() {
|
|
997
|
+
i3(t15.result);
|
|
998
|
+
}, t15.readAsDataURL(r4.response);
|
|
999
|
+
}, r4.open("GET", t14), r4.responseType = "blob", r4.send();
|
|
1000
1000
|
}));
|
|
1001
|
-
})(r3.image || "", this._window)),
|
|
1001
|
+
})(r3.image || "", this._window)), t13();
|
|
1002
1002
|
}, e4.src = r3.image;
|
|
1003
1003
|
}
|
|
1004
1004
|
}));
|
|
1005
1005
|
}
|
|
1006
|
-
async drawImage({ width:
|
|
1007
|
-
const n2 = this._options, o2 = this._roundSize((n2.width - i2 * r3) / 2), s2 = this._roundSize((n2.height - i2 * r3) / 2), a2 = o2 + this._roundSize(n2.imageOptions.margin + (i2 * r3 -
|
|
1006
|
+
async drawImage({ width: t13, height: e3, count: i2, dotSize: r3 }) {
|
|
1007
|
+
const n2 = this._options, o2 = this._roundSize((n2.width - i2 * r3) / 2), s2 = this._roundSize((n2.height - i2 * r3) / 2), a2 = o2 + this._roundSize(n2.imageOptions.margin + (i2 * r3 - t13) / 2), h2 = s2 + this._roundSize(n2.imageOptions.margin + (i2 * r3 - e3) / 2), d2 = t13 - 2 * n2.imageOptions.margin, u2 = e3 - 2 * n2.imageOptions.margin, c2 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "image");
|
|
1008
1008
|
c2.setAttribute("href", this._imageUri || ""), c2.setAttribute("xlink:href", this._imageUri || ""), c2.setAttribute("x", String(a2)), c2.setAttribute("y", String(h2)), c2.setAttribute("width", `${d2}px`), c2.setAttribute("height", `${u2}px`), this._element.appendChild(c2);
|
|
1009
1009
|
}
|
|
1010
|
-
_createColor({ options:
|
|
1010
|
+
_createColor({ options: t13, color: e3, additionalRotation: i2, x: r3, y: n2, height: o2, width: s2, name: a2 }) {
|
|
1011
1011
|
const h2 = s2 > o2 ? s2 : o2, d2 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
1012
|
-
if (d2.setAttribute("x", String(r3)), d2.setAttribute("y", String(n2)), d2.setAttribute("height", String(o2)), d2.setAttribute("width", String(s2)), d2.setAttribute("clip-path", `url('#clip-path-${a2}')`),
|
|
1012
|
+
if (d2.setAttribute("x", String(r3)), d2.setAttribute("y", String(n2)), d2.setAttribute("height", String(o2)), d2.setAttribute("width", String(s2)), d2.setAttribute("clip-path", `url('#clip-path-${a2}')`), t13) {
|
|
1013
1013
|
let e4;
|
|
1014
|
-
if ("radial" ===
|
|
1014
|
+
if ("radial" === t13.type) e4 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "radialGradient"), e4.setAttribute("id", a2), e4.setAttribute("gradientUnits", "userSpaceOnUse"), e4.setAttribute("fx", String(r3 + s2 / 2)), e4.setAttribute("fy", String(n2 + o2 / 2)), e4.setAttribute("cx", String(r3 + s2 / 2)), e4.setAttribute("cy", String(n2 + o2 / 2)), e4.setAttribute("r", String(h2 / 2));
|
|
1015
1015
|
else {
|
|
1016
|
-
const h3 = ((
|
|
1016
|
+
const h3 = ((t13.rotation || 0) + i2) % (2 * Math.PI), d3 = (h3 + 2 * Math.PI) % (2 * Math.PI);
|
|
1017
1017
|
let u2 = r3 + s2 / 2, c2 = n2 + o2 / 2, l2 = r3 + s2 / 2, g2 = n2 + o2 / 2;
|
|
1018
1018
|
d3 >= 0 && d3 <= 0.25 * Math.PI || d3 > 1.75 * Math.PI && d3 <= 2 * Math.PI ? (u2 -= s2 / 2, c2 -= o2 / 2 * Math.tan(h3), l2 += s2 / 2, g2 += o2 / 2 * Math.tan(h3)) : d3 > 0.25 * Math.PI && d3 <= 0.75 * Math.PI ? (c2 -= o2 / 2, u2 -= s2 / 2 / Math.tan(h3), g2 += o2 / 2, l2 += s2 / 2 / Math.tan(h3)) : d3 > 0.75 * Math.PI && d3 <= 1.25 * Math.PI ? (u2 += s2 / 2, c2 += o2 / 2 * Math.tan(h3), l2 -= s2 / 2, g2 -= o2 / 2 * Math.tan(h3)) : d3 > 1.25 * Math.PI && d3 <= 1.75 * Math.PI && (c2 += o2 / 2, u2 += s2 / 2 / Math.tan(h3), g2 -= o2 / 2, l2 -= s2 / 2 / Math.tan(h3)), e4 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "linearGradient"), e4.setAttribute("id", a2), e4.setAttribute("gradientUnits", "userSpaceOnUse"), e4.setAttribute("x1", String(Math.round(u2))), e4.setAttribute("y1", String(Math.round(c2))), e4.setAttribute("x2", String(Math.round(l2))), e4.setAttribute("y2", String(Math.round(g2)));
|
|
1019
1019
|
}
|
|
1020
|
-
|
|
1020
|
+
t13.colorStops.forEach((({ offset: t14, color: i3 }) => {
|
|
1021
1021
|
const r4 = this._window.document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
1022
|
-
r4.setAttribute("offset", 100 *
|
|
1022
|
+
r4.setAttribute("offset", 100 * t14 + "%"), r4.setAttribute("stop-color", i3), e4.appendChild(r4);
|
|
1023
1023
|
})), d2.setAttribute("fill", `url('#${a2}')`), this._defs.appendChild(e4);
|
|
1024
1024
|
} else e3 && d2.setAttribute("fill", e3);
|
|
1025
1025
|
this._element.appendChild(d2);
|
|
@@ -1027,119 +1027,119 @@ var require_qr_code_styling = __commonJS({
|
|
|
1027
1027
|
}
|
|
1028
1028
|
p.instanceCount = 0;
|
|
1029
1029
|
const v = p, _ = "canvas", m = {};
|
|
1030
|
-
for (let
|
|
1030
|
+
for (let t13 = 0; t13 <= 40; t13++) m[t13] = t13;
|
|
1031
1031
|
const b = { type: _, shape: "square", width: 300, height: 300, data: "", margin: 0, qrOptions: { typeNumber: m[0], mode: void 0, errorCorrectionLevel: "Q" }, imageOptions: { saveAsBlob: true, hideBackgroundDots: true, imageSize: 0.4, crossOrigin: void 0, margin: 0 }, dotsOptions: { type: "square", color: "#000", roundSize: true }, backgroundOptions: { round: 0, color: "#fff" } };
|
|
1032
|
-
function y(
|
|
1033
|
-
const e3 = Object.assign({},
|
|
1032
|
+
function y(t13) {
|
|
1033
|
+
const e3 = Object.assign({}, t13);
|
|
1034
1034
|
if (!e3.colorStops || !e3.colorStops.length) throw "Field 'colorStops' is required in gradient";
|
|
1035
|
-
return e3.rotation ? e3.rotation = Number(e3.rotation) : e3.rotation = 0, e3.colorStops = e3.colorStops.map(((
|
|
1035
|
+
return e3.rotation ? e3.rotation = Number(e3.rotation) : e3.rotation = 0, e3.colorStops = e3.colorStops.map(((t14) => Object.assign(Object.assign({}, t14), { offset: Number(t14.offset) }))), e3;
|
|
1036
1036
|
}
|
|
1037
|
-
function x(
|
|
1038
|
-
const e3 = Object.assign({},
|
|
1037
|
+
function x(t13) {
|
|
1038
|
+
const e3 = Object.assign({}, t13);
|
|
1039
1039
|
return e3.width = Number(e3.width), e3.height = Number(e3.height), e3.margin = Number(e3.margin), e3.imageOptions = Object.assign(Object.assign({}, e3.imageOptions), { hideBackgroundDots: Boolean(e3.imageOptions.hideBackgroundDots), imageSize: Number(e3.imageOptions.imageSize), margin: Number(e3.imageOptions.margin) }), e3.margin > Math.min(e3.width, e3.height) && (e3.margin = Math.min(e3.width, e3.height)), e3.dotsOptions = Object.assign({}, e3.dotsOptions), e3.dotsOptions.gradient && (e3.dotsOptions.gradient = y(e3.dotsOptions.gradient)), e3.cornersSquareOptions && (e3.cornersSquareOptions = Object.assign({}, e3.cornersSquareOptions), e3.cornersSquareOptions.gradient && (e3.cornersSquareOptions.gradient = y(e3.cornersSquareOptions.gradient))), e3.cornersDotOptions && (e3.cornersDotOptions = Object.assign({}, e3.cornersDotOptions), e3.cornersDotOptions.gradient && (e3.cornersDotOptions.gradient = y(e3.cornersDotOptions.gradient))), e3.backgroundOptions && (e3.backgroundOptions = Object.assign({}, e3.backgroundOptions), e3.backgroundOptions.gradient && (e3.backgroundOptions.gradient = y(e3.backgroundOptions.gradient))), e3;
|
|
1040
1040
|
}
|
|
1041
1041
|
var S = i(873), C = i.n(S);
|
|
1042
|
-
function A(
|
|
1043
|
-
if (!
|
|
1044
|
-
"." ===
|
|
1045
|
-
const e3 = { 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" }[
|
|
1046
|
-
if (!e3) throw new Error(`Extension "${
|
|
1042
|
+
function A(t13) {
|
|
1043
|
+
if (!t13) throw new Error("Extension must be defined");
|
|
1044
|
+
"." === t13[0] && (t13 = t13.substring(1));
|
|
1045
|
+
const e3 = { 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" }[t13.toLowerCase()];
|
|
1046
|
+
if (!e3) throw new Error(`Extension "${t13}" is not supported`);
|
|
1047
1047
|
return e3;
|
|
1048
1048
|
}
|
|
1049
1049
|
class M {
|
|
1050
|
-
constructor(
|
|
1051
|
-
(null ==
|
|
1050
|
+
constructor(t13) {
|
|
1051
|
+
(null == t13 ? void 0 : t13.jsdom) ? this._window = new t13.jsdom("", { resources: "usable" }).window : this._window = window, this._options = t13 ? x(e2(b, t13)) : b, this.update();
|
|
1052
1052
|
}
|
|
1053
|
-
static _clearContainer(
|
|
1054
|
-
|
|
1053
|
+
static _clearContainer(t13) {
|
|
1054
|
+
t13 && (t13.innerHTML = "");
|
|
1055
1055
|
}
|
|
1056
1056
|
_setupSvg() {
|
|
1057
1057
|
if (!this._qr) return;
|
|
1058
|
-
const
|
|
1059
|
-
this._svg =
|
|
1058
|
+
const t13 = new v(this._options, this._window);
|
|
1059
|
+
this._svg = t13.getElement(), this._svgDrawingPromise = t13.drawQR(this._qr).then((() => {
|
|
1060
1060
|
var e3;
|
|
1061
|
-
this._svg && (null === (e3 = this._extension) || void 0 === e3 || e3.call(this,
|
|
1061
|
+
this._svg && (null === (e3 = this._extension) || void 0 === e3 || e3.call(this, t13.getElement(), this._options));
|
|
1062
1062
|
}));
|
|
1063
1063
|
}
|
|
1064
1064
|
_setupCanvas() {
|
|
1065
|
-
var
|
|
1066
|
-
this._qr && ((null === (
|
|
1067
|
-
var
|
|
1065
|
+
var t13, e3;
|
|
1066
|
+
this._qr && ((null === (t13 = this._options.nodeCanvas) || void 0 === t13 ? void 0 : t13.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 = null === (e3 = this._svgDrawingPromise) || void 0 === e3 ? void 0 : e3.then((() => {
|
|
1067
|
+
var t14;
|
|
1068
1068
|
if (!this._svg) return;
|
|
1069
1069
|
const e4 = this._svg, i2 = new this._window.XMLSerializer().serializeToString(e4), r3 = btoa(i2), n2 = `data:${A("svg")};base64,${r3}`;
|
|
1070
|
-
if (null === (
|
|
1070
|
+
if (null === (t14 = this._options.nodeCanvas) || void 0 === t14 ? void 0 : t14.loadImage) return this._options.nodeCanvas.loadImage(n2).then(((t15) => {
|
|
1071
1071
|
var e5, i3;
|
|
1072
|
-
|
|
1072
|
+
t15.width = this._options.width, t15.height = this._options.height, null === (i3 = null === (e5 = this._nodeCanvas) || void 0 === e5 ? void 0 : e5.getContext("2d")) || void 0 === i3 || i3.drawImage(t15, 0, 0);
|
|
1073
1073
|
}));
|
|
1074
1074
|
{
|
|
1075
|
-
const
|
|
1075
|
+
const t15 = new this._window.Image();
|
|
1076
1076
|
return new Promise(((e5) => {
|
|
1077
|
-
|
|
1077
|
+
t15.onload = () => {
|
|
1078
1078
|
var i3, r4;
|
|
1079
|
-
null === (r4 = null === (i3 = this._domCanvas) || void 0 === i3 ? void 0 : i3.getContext("2d")) || void 0 === r4 || r4.drawImage(
|
|
1080
|
-
},
|
|
1079
|
+
null === (r4 = null === (i3 = this._domCanvas) || void 0 === i3 ? void 0 : i3.getContext("2d")) || void 0 === r4 || r4.drawImage(t15, 0, 0), e5();
|
|
1080
|
+
}, t15.src = n2;
|
|
1081
1081
|
}));
|
|
1082
1082
|
}
|
|
1083
1083
|
})));
|
|
1084
1084
|
}
|
|
1085
|
-
async _getElement(
|
|
1085
|
+
async _getElement(t13 = "png") {
|
|
1086
1086
|
if (!this._qr) throw "QR code is empty";
|
|
1087
|
-
return "svg" ===
|
|
1087
|
+
return "svg" === t13.toLowerCase() ? (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);
|
|
1088
1088
|
}
|
|
1089
|
-
update(
|
|
1090
|
-
M._clearContainer(this._container), this._options =
|
|
1089
|
+
update(t13) {
|
|
1090
|
+
M._clearContainer(this._container), this._options = t13 ? x(e2(this._options, t13)) : this._options, this._options.data && (this._qr = C()(this._options.qrOptions.typeNumber, this._options.qrOptions.errorCorrectionLevel), this._qr.addData(this._options.data, this._options.qrOptions.mode || (function(t14) {
|
|
1091
1091
|
switch (true) {
|
|
1092
|
-
case /^[0-9]*$/.test(
|
|
1092
|
+
case /^[0-9]*$/.test(t14):
|
|
1093
1093
|
return "Numeric";
|
|
1094
|
-
case /^[0-9A-Z $%*+\-./:]*$/.test(
|
|
1094
|
+
case /^[0-9A-Z $%*+\-./:]*$/.test(t14):
|
|
1095
1095
|
return "Alphanumeric";
|
|
1096
1096
|
default:
|
|
1097
1097
|
return "Byte";
|
|
1098
1098
|
}
|
|
1099
1099
|
})(this._options.data)), this._qr.make(), this._options.type === _ ? this._setupCanvas() : this._setupSvg(), this.append(this._container));
|
|
1100
1100
|
}
|
|
1101
|
-
append(
|
|
1102
|
-
if (
|
|
1103
|
-
if ("function" != typeof
|
|
1104
|
-
this._options.type === _ ? this._domCanvas &&
|
|
1101
|
+
append(t13) {
|
|
1102
|
+
if (t13) {
|
|
1103
|
+
if ("function" != typeof t13.appendChild) throw "Container should be a single DOM node";
|
|
1104
|
+
this._options.type === _ ? this._domCanvas && t13.appendChild(this._domCanvas) : this._svg && t13.appendChild(this._svg), this._container = t13;
|
|
1105
1105
|
}
|
|
1106
1106
|
}
|
|
1107
|
-
applyExtension(
|
|
1108
|
-
if (!
|
|
1109
|
-
this._extension =
|
|
1107
|
+
applyExtension(t13) {
|
|
1108
|
+
if (!t13) throw "Extension function should be defined.";
|
|
1109
|
+
this._extension = t13, this.update();
|
|
1110
1110
|
}
|
|
1111
1111
|
deleteExtension() {
|
|
1112
1112
|
this._extension = void 0, this.update();
|
|
1113
1113
|
}
|
|
1114
|
-
async getRawData(
|
|
1114
|
+
async getRawData(t13 = "png") {
|
|
1115
1115
|
if (!this._qr) throw "QR code is empty";
|
|
1116
|
-
const e3 = await this._getElement(
|
|
1116
|
+
const e3 = await this._getElement(t13), i2 = A(t13);
|
|
1117
1117
|
if (!e3) return null;
|
|
1118
|
-
if ("svg" ===
|
|
1119
|
-
const
|
|
1118
|
+
if ("svg" === t13.toLowerCase()) {
|
|
1119
|
+
const t14 = `<?xml version="1.0" standalone="no"?>\r
|
|
1120
1120
|
${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
1121
|
-
return "undefined" == typeof Blob || this._options.jsdom ? Buffer.from(
|
|
1121
|
+
return "undefined" == typeof Blob || this._options.jsdom ? Buffer.from(t14) : new Blob([t14], { type: i2 });
|
|
1122
1122
|
}
|
|
1123
|
-
return new Promise(((
|
|
1123
|
+
return new Promise(((t14) => {
|
|
1124
1124
|
const r3 = e3;
|
|
1125
|
-
if ("toBuffer" in r3) if ("image/png" === i2)
|
|
1126
|
-
else if ("image/jpeg" === i2)
|
|
1125
|
+
if ("toBuffer" in r3) if ("image/png" === i2) t14(r3.toBuffer(i2));
|
|
1126
|
+
else if ("image/jpeg" === i2) t14(r3.toBuffer(i2));
|
|
1127
1127
|
else {
|
|
1128
1128
|
if ("application/pdf" !== i2) throw Error("Unsupported extension");
|
|
1129
|
-
|
|
1129
|
+
t14(r3.toBuffer(i2));
|
|
1130
1130
|
}
|
|
1131
|
-
else "toBlob" in r3 && r3.toBlob(
|
|
1131
|
+
else "toBlob" in r3 && r3.toBlob(t14, i2, 1);
|
|
1132
1132
|
}));
|
|
1133
1133
|
}
|
|
1134
|
-
async download(
|
|
1134
|
+
async download(t13) {
|
|
1135
1135
|
if (!this._qr) throw "QR code is empty";
|
|
1136
1136
|
if ("undefined" == typeof Blob) throw "Cannot download in Node.js, call getRawData instead.";
|
|
1137
1137
|
let e3 = "png", i2 = "qr";
|
|
1138
|
-
"string" == typeof
|
|
1138
|
+
"string" == typeof t13 ? (e3 = t13, console.warn("Extension is deprecated as argument for 'download' method, please pass object { name: '...', extension: '...' } as argument")) : "object" == typeof t13 && null !== t13 && (t13.name && (i2 = t13.name), t13.extension && (e3 = t13.extension));
|
|
1139
1139
|
const r3 = await this._getElement(e3);
|
|
1140
1140
|
if (r3) if ("svg" === e3.toLowerCase()) {
|
|
1141
|
-
let
|
|
1142
|
-
|
|
1141
|
+
let t14 = new XMLSerializer().serializeToString(r3);
|
|
1142
|
+
t14 = '<?xml version="1.0" standalone="no"?>\r\n' + t14, n(`data:${A(e3)};charset=utf-8,${encodeURIComponent(t14)}`, `${i2}.svg`);
|
|
1143
1143
|
} else n(r3.toDataURL(A(e3)), `${i2}.${e3}`);
|
|
1144
1144
|
}
|
|
1145
1145
|
}
|
|
@@ -1152,6 +1152,7 @@ ${new this._window.XMLSerializer().serializeToString(e3)}`;
|
|
|
1152
1152
|
// src/index.ts
|
|
1153
1153
|
var index_exports = {};
|
|
1154
1154
|
__export(index_exports, {
|
|
1155
|
+
ActionType: () => ActionType,
|
|
1155
1156
|
Button: () => Button,
|
|
1156
1157
|
ConfirmingView: () => ConfirmingView,
|
|
1157
1158
|
ExecutionStatus: () => ExecutionStatus,
|
|
@@ -1170,10 +1171,12 @@ __export(index_exports, {
|
|
|
1170
1171
|
getPreferredIconUrl: () => getPreferredIconUrl,
|
|
1171
1172
|
getProjectConfig: () => getProjectConfig,
|
|
1172
1173
|
getSupportedDepositTokens: () => getSupportedDepositTokens,
|
|
1174
|
+
getSupportedDestinationTokens: () => getSupportedDestinationTokens,
|
|
1173
1175
|
getTokenChains: () => getTokenChains,
|
|
1174
1176
|
getWalletByChainType: () => getWalletByChainType,
|
|
1175
1177
|
i18n: () => i18n,
|
|
1176
1178
|
queryExecutions: () => queryExecutions,
|
|
1179
|
+
sendSolanaTransaction: () => sendSolanaTransaction,
|
|
1177
1180
|
setApiConfig: () => setApiConfig,
|
|
1178
1181
|
useAllowedCountry: () => useAllowedCountry2,
|
|
1179
1182
|
useUnifold: () => useUnifold2,
|
|
@@ -1182,7 +1185,7 @@ __export(index_exports, {
|
|
|
1182
1185
|
module.exports = __toCommonJS(index_exports);
|
|
1183
1186
|
|
|
1184
1187
|
// src/provider.tsx
|
|
1185
|
-
var
|
|
1188
|
+
var import_react31 = __toESM(require("react"));
|
|
1186
1189
|
|
|
1187
1190
|
// ../react-provider/dist/index.mjs
|
|
1188
1191
|
var import_react = require("react");
|
|
@@ -1331,6 +1334,14 @@ var ArrowLeft = createLucideIcon("ArrowLeft", [
|
|
|
1331
1334
|
["path", { d: "M19 12H5", key: "x3x0zl" }]
|
|
1332
1335
|
]);
|
|
1333
1336
|
|
|
1337
|
+
// ../../node_modules/.pnpm/lucide-react@0.454.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/arrow-up-down.js
|
|
1338
|
+
var ArrowUpDown = createLucideIcon("ArrowUpDown", [
|
|
1339
|
+
["path", { d: "m21 16-4 4-4-4", key: "f6ql7i" }],
|
|
1340
|
+
["path", { d: "M17 20V4", key: "1ejh1v" }],
|
|
1341
|
+
["path", { d: "m3 8 4-4 4 4", key: "11wl7u" }],
|
|
1342
|
+
["path", { d: "M7 4v16", key: "1glfcx" }]
|
|
1343
|
+
]);
|
|
1344
|
+
|
|
1334
1345
|
// ../../node_modules/.pnpm/lucide-react@0.454.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/check.js
|
|
1335
1346
|
var Check = createLucideIcon("Check", [["path", { d: "M20 6 9 17l-5-5", key: "1gmf2c" }]]);
|
|
1336
1347
|
|
|
@@ -1353,6 +1364,22 @@ var CircleCheck = createLucideIcon("CircleCheck", [
|
|
|
1353
1364
|
["path", { d: "m9 12 2 2 4-4", key: "dzmm74" }]
|
|
1354
1365
|
]);
|
|
1355
1366
|
|
|
1367
|
+
// ../../node_modules/.pnpm/lucide-react@0.454.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/clipboard-paste.js
|
|
1368
|
+
var ClipboardPaste = createLucideIcon("ClipboardPaste", [
|
|
1369
|
+
[
|
|
1370
|
+
"path",
|
|
1371
|
+
{ d: "M15 2H9a1 1 0 0 0-1 1v2c0 .6.4 1 1 1h6c.6 0 1-.4 1-1V3c0-.6-.4-1-1-1Z", key: "1pp7kr" }
|
|
1372
|
+
],
|
|
1373
|
+
[
|
|
1374
|
+
"path",
|
|
1375
|
+
{
|
|
1376
|
+
d: "M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2M16 4h2a2 2 0 0 1 2 2v2M11 14h10",
|
|
1377
|
+
key: "2ik1ml"
|
|
1378
|
+
}
|
|
1379
|
+
],
|
|
1380
|
+
["path", { d: "m17 10 4 4-4 4", key: "vp2hj1" }]
|
|
1381
|
+
]);
|
|
1382
|
+
|
|
1356
1383
|
// ../../node_modules/.pnpm/lucide-react@0.454.0_react@18.3.1/node_modules/lucide-react/dist/esm/icons/clock.js
|
|
1357
1384
|
var Clock = createLucideIcon("Clock", [
|
|
1358
1385
|
["circle", { cx: "12", cy: "12", r: "10", key: "1mglay" }],
|
|
@@ -2439,25 +2466,25 @@ function createFocusGuard() {
|
|
|
2439
2466
|
|
|
2440
2467
|
// ../../node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs
|
|
2441
2468
|
var __assign = function() {
|
|
2442
|
-
__assign = Object.assign || function __assign2(
|
|
2469
|
+
__assign = Object.assign || function __assign2(t11) {
|
|
2443
2470
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
2444
2471
|
s = arguments[i];
|
|
2445
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
2472
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t11[p] = s[p];
|
|
2446
2473
|
}
|
|
2447
|
-
return
|
|
2474
|
+
return t11;
|
|
2448
2475
|
};
|
|
2449
2476
|
return __assign.apply(this, arguments);
|
|
2450
2477
|
};
|
|
2451
2478
|
function __rest(s, e) {
|
|
2452
|
-
var
|
|
2479
|
+
var t11 = {};
|
|
2453
2480
|
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
2454
|
-
|
|
2481
|
+
t11[p] = s[p];
|
|
2455
2482
|
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
2456
2483
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
2457
2484
|
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
2458
|
-
|
|
2485
|
+
t11[p[i]] = s[p[i]];
|
|
2459
2486
|
}
|
|
2460
|
-
return
|
|
2487
|
+
return t11;
|
|
2461
2488
|
}
|
|
2462
2489
|
function __spreadArray(to, from, pack) {
|
|
2463
2490
|
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
@@ -3584,16 +3611,16 @@ var Close = DialogClose;
|
|
|
3584
3611
|
|
|
3585
3612
|
// ../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs
|
|
3586
3613
|
function r(e) {
|
|
3587
|
-
var
|
|
3614
|
+
var t11, f, n = "";
|
|
3588
3615
|
if ("string" == typeof e || "number" == typeof e) n += e;
|
|
3589
3616
|
else if ("object" == typeof e) if (Array.isArray(e)) {
|
|
3590
3617
|
var o = e.length;
|
|
3591
|
-
for (
|
|
3618
|
+
for (t11 = 0; t11 < o; t11++) e[t11] && (f = r(e[t11])) && (n && (n += " "), n += f);
|
|
3592
3619
|
} else for (f in e) e[f] && (n && (n += " "), n += f);
|
|
3593
3620
|
return n;
|
|
3594
3621
|
}
|
|
3595
3622
|
function clsx() {
|
|
3596
|
-
for (var e,
|
|
3623
|
+
for (var e, t11, f = 0, n = "", o = arguments.length; f < o; f++) (e = arguments[f]) && (t11 = r(e)) && (n && (n += " "), n += t11);
|
|
3597
3624
|
return n;
|
|
3598
3625
|
}
|
|
3599
3626
|
|
|
@@ -6118,6 +6145,11 @@ function getIconUrlWithCdn(iconPath, assetCdnUrl) {
|
|
|
6118
6145
|
const baseUrl = assetCdnUrl.endsWith("/") ? assetCdnUrl.slice(0, -1) : assetCdnUrl;
|
|
6119
6146
|
return `${baseUrl}/api/public${normalizedPath}`;
|
|
6120
6147
|
}
|
|
6148
|
+
var ActionType = /* @__PURE__ */ ((ActionType2) => {
|
|
6149
|
+
ActionType2["Deposit"] = "deposit";
|
|
6150
|
+
ActionType2["Withdraw"] = "withdraw";
|
|
6151
|
+
return ActionType2;
|
|
6152
|
+
})(ActionType || {});
|
|
6121
6153
|
async function createDepositAddress(overrides, publishableKey) {
|
|
6122
6154
|
if (!overrides?.external_user_id) {
|
|
6123
6155
|
throw new Error("external_user_id is required");
|
|
@@ -6128,6 +6160,7 @@ async function createDepositAddress(overrides, publishableKey) {
|
|
|
6128
6160
|
destination_chain_id: overrides?.destination_chain_id || DEFAULT_CONFIG.destinationChainId || "8453",
|
|
6129
6161
|
destination_token_address: overrides?.destination_token_address || DEFAULT_CONFIG.destinationTokenAddress || "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
|
|
6130
6162
|
recipient_address: overrides?.recipient_address || DEFAULT_CONFIG.recipientAddress || "0x309a4154a2CD4153Da886E780890C9cb5161553C",
|
|
6163
|
+
...overrides?.action_type ? { action_type: overrides.action_type } : {},
|
|
6131
6164
|
client_metadata: overrides?.client_metadata || {}
|
|
6132
6165
|
};
|
|
6133
6166
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
@@ -6159,9 +6192,13 @@ var ExecutionStatus = /* @__PURE__ */ ((ExecutionStatus2) => {
|
|
|
6159
6192
|
return ExecutionStatus2;
|
|
6160
6193
|
})(ExecutionStatus || {});
|
|
6161
6194
|
var SOLANA_USDC_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
|
|
6162
|
-
async function queryExecutions(externalUserId, publishableKey) {
|
|
6195
|
+
async function queryExecutions(externalUserId, publishableKey, actionType) {
|
|
6163
6196
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6164
6197
|
validatePublishableKey(pk);
|
|
6198
|
+
const body = {
|
|
6199
|
+
external_user_id: externalUserId,
|
|
6200
|
+
...actionType ? { action_type: actionType } : {}
|
|
6201
|
+
};
|
|
6165
6202
|
const response = await fetch(
|
|
6166
6203
|
`${API_BASE_URL}/v1/public/direct_executions/query`,
|
|
6167
6204
|
{
|
|
@@ -6171,9 +6208,7 @@ async function queryExecutions(externalUserId, publishableKey) {
|
|
|
6171
6208
|
"x-publishable-key": pk,
|
|
6172
6209
|
"Content-Type": "application/json"
|
|
6173
6210
|
},
|
|
6174
|
-
body: JSON.stringify(
|
|
6175
|
-
external_user_id: externalUserId
|
|
6176
|
-
})
|
|
6211
|
+
body: JSON.stringify(body)
|
|
6177
6212
|
}
|
|
6178
6213
|
);
|
|
6179
6214
|
if (!response.ok) {
|
|
@@ -6201,6 +6236,26 @@ async function pollDirectExecutions(request, publishableKey) {
|
|
|
6201
6236
|
}
|
|
6202
6237
|
return response.json();
|
|
6203
6238
|
}
|
|
6239
|
+
async function getSupportedDestinationTokens(publishableKey) {
|
|
6240
|
+
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6241
|
+
validatePublishableKey(pk);
|
|
6242
|
+
const response = await fetch(
|
|
6243
|
+
`${API_BASE_URL}/v1/public/tokens/supported_destination_tokens`,
|
|
6244
|
+
{
|
|
6245
|
+
method: "GET",
|
|
6246
|
+
headers: {
|
|
6247
|
+
accept: "application/json",
|
|
6248
|
+
"x-publishable-key": pk
|
|
6249
|
+
}
|
|
6250
|
+
}
|
|
6251
|
+
);
|
|
6252
|
+
if (!response.ok) {
|
|
6253
|
+
throw new Error(
|
|
6254
|
+
`Failed to fetch supported destination tokens: ${response.statusText}`
|
|
6255
|
+
);
|
|
6256
|
+
}
|
|
6257
|
+
return response.json();
|
|
6258
|
+
}
|
|
6204
6259
|
async function getSupportedDepositTokens(publishableKey, options) {
|
|
6205
6260
|
const pk = publishableKey || DEFAULT_PUBLISHABLE_KEY;
|
|
6206
6261
|
validatePublishableKey(pk);
|
|
@@ -6659,6 +6714,32 @@ var en_default = {
|
|
|
6659
6714
|
youReceive: "You receive",
|
|
6660
6715
|
intentAddressNote: "The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."
|
|
6661
6716
|
}
|
|
6717
|
+
},
|
|
6718
|
+
withdrawModal: {
|
|
6719
|
+
title: "Withdraw",
|
|
6720
|
+
withdrawCrypto: {
|
|
6721
|
+
title: "Withdraw with Crypto",
|
|
6722
|
+
subtitle: "Send to any wallet address"
|
|
6723
|
+
},
|
|
6724
|
+
selectToken: "Select withdrawal token",
|
|
6725
|
+
receiveToken: "Receive token",
|
|
6726
|
+
receiveChain: "Receive chain",
|
|
6727
|
+
recipientAddress: "Recipient address",
|
|
6728
|
+
recipientAddressPlaceholder: "Enter wallet address",
|
|
6729
|
+
amount: "Amount",
|
|
6730
|
+
amountPlaceholder: "0.00",
|
|
6731
|
+
balance: "Balance",
|
|
6732
|
+
minimum: "min",
|
|
6733
|
+
withdraw: "Withdraw",
|
|
6734
|
+
invalidAddress: "Please enter a valid address",
|
|
6735
|
+
invalidAmount: "Please enter a valid amount",
|
|
6736
|
+
verifyingAddress: "Verifying address...",
|
|
6737
|
+
loading: "Loading...",
|
|
6738
|
+
noTokensAvailable: "No tokens available",
|
|
6739
|
+
sourceToken: "Source token",
|
|
6740
|
+
review: "Review",
|
|
6741
|
+
confirm: "Confirm Withdrawal",
|
|
6742
|
+
back: "Back"
|
|
6662
6743
|
}
|
|
6663
6744
|
};
|
|
6664
6745
|
var i18n = en_default;
|
|
@@ -6885,9 +6966,10 @@ var import_jsx_runtime52 = require("react/jsx-runtime");
|
|
|
6885
6966
|
var import_react21 = require("react");
|
|
6886
6967
|
var import_jsx_runtime53 = require("react/jsx-runtime");
|
|
6887
6968
|
var import_jsx_runtime54 = require("react/jsx-runtime");
|
|
6969
|
+
var import_react22 = require("react");
|
|
6888
6970
|
var import_jsx_runtime55 = require("react/jsx-runtime");
|
|
6889
6971
|
var import_jsx_runtime56 = require("react/jsx-runtime");
|
|
6890
|
-
var
|
|
6972
|
+
var import_react23 = require("react");
|
|
6891
6973
|
var React242 = __toESM(require("react"), 1);
|
|
6892
6974
|
|
|
6893
6975
|
// ../../node_modules/.pnpm/@radix-ui+react-tooltip@1.2.8_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2._aqltx4jspgwttwvtzmq3z5uagy/node_modules/@radix-ui/react-tooltip/dist/index.mjs
|
|
@@ -9627,7 +9709,7 @@ var Content22 = TooltipContent;
|
|
|
9627
9709
|
// ../ui-react/dist/index.mjs
|
|
9628
9710
|
var import_jsx_runtime57 = require("react/jsx-runtime");
|
|
9629
9711
|
var import_jsx_runtime58 = require("react/jsx-runtime");
|
|
9630
|
-
var
|
|
9712
|
+
var import_react24 = require("react");
|
|
9631
9713
|
var React252 = __toESM(require("react"), 1);
|
|
9632
9714
|
|
|
9633
9715
|
// ../../node_modules/.pnpm/@radix-ui+react-select@2.2.6_@types+react-dom@19.2.3_@types+react@19.2.9__@types+react@19.2.9_5n4syhs66qrtkkphe44qzgdimq/node_modules/@radix-ui/react-select/dist/index.mjs
|
|
@@ -10870,12 +10952,28 @@ var import_jsx_runtime61 = require("react/jsx-runtime");
|
|
|
10870
10952
|
var import_jsx_runtime62 = require("react/jsx-runtime");
|
|
10871
10953
|
var import_jsx_runtime63 = require("react/jsx-runtime");
|
|
10872
10954
|
var import_jsx_runtime64 = require("react/jsx-runtime");
|
|
10873
|
-
var
|
|
10955
|
+
var import_react25 = require("react");
|
|
10874
10956
|
var import_jsx_runtime65 = require("react/jsx-runtime");
|
|
10875
10957
|
var import_jsx_runtime66 = require("react/jsx-runtime");
|
|
10876
10958
|
var React272 = __toESM(require("react"), 1);
|
|
10877
10959
|
var import_jsx_runtime67 = require("react/jsx-runtime");
|
|
10878
10960
|
var import_jsx_runtime68 = require("react/jsx-runtime");
|
|
10961
|
+
var import_react26 = require("react");
|
|
10962
|
+
var import_react_query11 = require("@tanstack/react-query");
|
|
10963
|
+
var import_react_query12 = require("@tanstack/react-query");
|
|
10964
|
+
var import_react_query13 = require("@tanstack/react-query");
|
|
10965
|
+
var import_react_query14 = require("@tanstack/react-query");
|
|
10966
|
+
var import_react27 = require("react");
|
|
10967
|
+
var import_jsx_runtime69 = require("react/jsx-runtime");
|
|
10968
|
+
var import_react28 = require("react");
|
|
10969
|
+
var import_react_query15 = require("@tanstack/react-query");
|
|
10970
|
+
var import_jsx_runtime70 = require("react/jsx-runtime");
|
|
10971
|
+
var import_jsx_runtime71 = require("react/jsx-runtime");
|
|
10972
|
+
var import_react29 = require("react");
|
|
10973
|
+
var import_jsx_runtime72 = require("react/jsx-runtime");
|
|
10974
|
+
var import_jsx_runtime73 = require("react/jsx-runtime");
|
|
10975
|
+
var import_react30 = require("react");
|
|
10976
|
+
var import_jsx_runtime74 = require("react/jsx-runtime");
|
|
10879
10977
|
function cn(...inputs) {
|
|
10880
10978
|
return twMerge(clsx(inputs));
|
|
10881
10979
|
}
|
|
@@ -11441,6 +11539,7 @@ function useDepositAddress(params) {
|
|
|
11441
11539
|
destinationChainType,
|
|
11442
11540
|
destinationChainId,
|
|
11443
11541
|
destinationTokenAddress,
|
|
11542
|
+
actionType,
|
|
11444
11543
|
enabled = true
|
|
11445
11544
|
} = params;
|
|
11446
11545
|
return (0, import_react_query3.useQuery)({
|
|
@@ -11452,6 +11551,7 @@ function useDepositAddress(params) {
|
|
|
11452
11551
|
destinationChainType ?? null,
|
|
11453
11552
|
destinationChainId ?? null,
|
|
11454
11553
|
destinationTokenAddress ?? null,
|
|
11554
|
+
actionType ?? null,
|
|
11455
11555
|
publishableKey
|
|
11456
11556
|
],
|
|
11457
11557
|
queryFn: () => createDepositAddress(
|
|
@@ -11460,7 +11560,8 @@ function useDepositAddress(params) {
|
|
|
11460
11560
|
recipient_address: recipientAddress,
|
|
11461
11561
|
destination_chain_type: destinationChainType,
|
|
11462
11562
|
destination_chain_id: destinationChainId,
|
|
11463
|
-
destination_token_address: destinationTokenAddress
|
|
11563
|
+
destination_token_address: destinationTokenAddress,
|
|
11564
|
+
action_type: actionType
|
|
11464
11565
|
},
|
|
11465
11566
|
publishableKey
|
|
11466
11567
|
),
|
|
@@ -12142,6 +12243,30 @@ var en_default2 = {
|
|
|
12142
12243
|
youReceive: "You receive",
|
|
12143
12244
|
intentAddressNote: "The wallet address displayed in the payment provider is a temporary deposit address. Your funds will be automatically converted and deposited into your account."
|
|
12144
12245
|
}
|
|
12246
|
+
},
|
|
12247
|
+
withdrawModal: {
|
|
12248
|
+
title: "Withdraw",
|
|
12249
|
+
withdrawCrypto: {
|
|
12250
|
+
title: "Withdraw with Crypto",
|
|
12251
|
+
subtitle: "Send to any wallet address"
|
|
12252
|
+
},
|
|
12253
|
+
selectToken: "Select withdrawal token",
|
|
12254
|
+
receiveToken: "Receive token",
|
|
12255
|
+
receiveChain: "Receive chain",
|
|
12256
|
+
recipientAddress: "Recipient address",
|
|
12257
|
+
recipientAddressPlaceholder: "Enter wallet address",
|
|
12258
|
+
amount: "Amount",
|
|
12259
|
+
amountPlaceholder: "0.00",
|
|
12260
|
+
balance: "Balance",
|
|
12261
|
+
minimum: "min",
|
|
12262
|
+
withdraw: "Withdraw",
|
|
12263
|
+
invalidAddress: "Please enter a valid address",
|
|
12264
|
+
invalidAmount: "Please enter a valid amount",
|
|
12265
|
+
verifyingAddress: "Verifying address...",
|
|
12266
|
+
loading: "Loading...",
|
|
12267
|
+
noTokensAvailable: "No tokens available",
|
|
12268
|
+
review: "Review Withdrawal",
|
|
12269
|
+
back: "Back"
|
|
12145
12270
|
}
|
|
12146
12271
|
};
|
|
12147
12272
|
var i18n2 = en_default2;
|
|
@@ -12220,7 +12345,7 @@ function useDepositPolling({
|
|
|
12220
12345
|
const modalOpenedAt = modalOpenedAtRef.current;
|
|
12221
12346
|
const poll = async () => {
|
|
12222
12347
|
try {
|
|
12223
|
-
const response = await queryExecutions(userId, publishableKey);
|
|
12348
|
+
const response = await queryExecutions(userId, publishableKey, ActionType.Deposit);
|
|
12224
12349
|
const cutoff = new Date(modalOpenedAt.getTime() - CUTOFF_BUFFER_MS);
|
|
12225
12350
|
const sortedExecutions = [...response.data].sort((a, b) => {
|
|
12226
12351
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
@@ -12342,7 +12467,8 @@ function formatCurrency(currency) {
|
|
|
12342
12467
|
}
|
|
12343
12468
|
function DepositDetailContent({
|
|
12344
12469
|
execution,
|
|
12345
|
-
className
|
|
12470
|
+
className,
|
|
12471
|
+
variant = "deposit"
|
|
12346
12472
|
}) {
|
|
12347
12473
|
const { colors: colors2, fonts, components } = useTheme();
|
|
12348
12474
|
const [chains, setChains] = (0, import_react15.useState)([]);
|
|
@@ -12748,7 +12874,7 @@ function DepositDetailContent({
|
|
|
12748
12874
|
color: components.card.rowLeftLabel,
|
|
12749
12875
|
fontFamily: fonts.regular
|
|
12750
12876
|
},
|
|
12751
|
-
children: "Deposit Tx"
|
|
12877
|
+
children: variant === "withdraw" ? "Withdrawal Tx" : "Deposit Tx"
|
|
12752
12878
|
}
|
|
12753
12879
|
),
|
|
12754
12880
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
@@ -17874,7 +18000,7 @@ function DepositsModal({
|
|
|
17874
18000
|
if (!open || !userId) return;
|
|
17875
18001
|
const fetchExecutions = async () => {
|
|
17876
18002
|
try {
|
|
17877
|
-
const response = await queryExecutions(userId, publishableKey);
|
|
18003
|
+
const response = await queryExecutions(userId, publishableKey, ActionType.Deposit);
|
|
17878
18004
|
const sorted = [...response.data].sort((a, b) => {
|
|
17879
18005
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
17880
18006
|
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
@@ -17991,7 +18117,7 @@ function saveRecentToken(token) {
|
|
|
17991
18117
|
try {
|
|
17992
18118
|
const recent = getRecentTokens();
|
|
17993
18119
|
const filtered = recent.filter(
|
|
17994
|
-
(
|
|
18120
|
+
(t11) => !(t11.symbol === token.symbol && t11.chainType === token.chainType && t11.chainId === token.chainId)
|
|
17995
18121
|
);
|
|
17996
18122
|
filtered.unshift(token);
|
|
17997
18123
|
const trimmed = filtered.slice(0, MAX_RECENT_TOKENS);
|
|
@@ -18004,7 +18130,7 @@ function removeRecentToken(token) {
|
|
|
18004
18130
|
try {
|
|
18005
18131
|
const recent = getRecentTokens();
|
|
18006
18132
|
const filtered = recent.filter(
|
|
18007
|
-
(
|
|
18133
|
+
(t11) => !(t11.symbol === token.symbol && t11.chainType === token.chainType && t11.chainId === token.chainId)
|
|
18008
18134
|
);
|
|
18009
18135
|
localStorage.setItem(STORAGE_KEY, JSON.stringify(filtered));
|
|
18010
18136
|
return filtered;
|
|
@@ -18043,7 +18169,7 @@ function TokenSelectorSheet({
|
|
|
18043
18169
|
const addOption = (symbol, chainType, chainId, isRecent) => {
|
|
18044
18170
|
const key = `${symbol}-${chainType}:${chainId}`;
|
|
18045
18171
|
if (seen.has(key)) return;
|
|
18046
|
-
const tokenData = tokens.find((
|
|
18172
|
+
const tokenData = tokens.find((t11) => t11.symbol === symbol);
|
|
18047
18173
|
if (!tokenData) return;
|
|
18048
18174
|
const chainData = tokenData.chains.find(
|
|
18049
18175
|
(c) => c.chain_type === chainType && c.chain_id === chainId
|
|
@@ -18499,6 +18625,104 @@ function DepositPollingUi({
|
|
|
18499
18625
|
}
|
|
18500
18626
|
return null;
|
|
18501
18627
|
}
|
|
18628
|
+
var getChainKey = (chainId, chainType) => {
|
|
18629
|
+
return `${chainType}:${chainId}`;
|
|
18630
|
+
};
|
|
18631
|
+
function resolveSourceToken(supportedTokens, defaultSourceChainType, defaultSourceChainId, defaultSourceTokenAddress, defaultSourceSymbol) {
|
|
18632
|
+
if (!supportedTokens.length) return null;
|
|
18633
|
+
let selectedTokenData;
|
|
18634
|
+
let selectedChainData;
|
|
18635
|
+
const hasChainDefaults = defaultSourceChainType && defaultSourceChainId;
|
|
18636
|
+
if (defaultSourceTokenAddress && hasChainDefaults) {
|
|
18637
|
+
for (const t11 of supportedTokens) {
|
|
18638
|
+
const matchingChain = t11.chains.find(
|
|
18639
|
+
(c) => c.token_address.toLowerCase() === defaultSourceTokenAddress.toLowerCase() && c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
|
|
18640
|
+
);
|
|
18641
|
+
if (matchingChain) {
|
|
18642
|
+
selectedTokenData = t11;
|
|
18643
|
+
selectedChainData = matchingChain;
|
|
18644
|
+
break;
|
|
18645
|
+
}
|
|
18646
|
+
}
|
|
18647
|
+
}
|
|
18648
|
+
if (!selectedTokenData && defaultSourceSymbol && hasChainDefaults) {
|
|
18649
|
+
for (const t11 of supportedTokens) {
|
|
18650
|
+
if (t11.symbol !== defaultSourceSymbol) continue;
|
|
18651
|
+
const matchedChain = t11.chains.find(
|
|
18652
|
+
(c) => c.chain_type === defaultSourceChainType && c.chain_id === defaultSourceChainId
|
|
18653
|
+
);
|
|
18654
|
+
if (matchedChain) {
|
|
18655
|
+
selectedTokenData = t11;
|
|
18656
|
+
selectedChainData = matchedChain;
|
|
18657
|
+
break;
|
|
18658
|
+
}
|
|
18659
|
+
}
|
|
18660
|
+
}
|
|
18661
|
+
if (!selectedTokenData) {
|
|
18662
|
+
for (const t11 of supportedTokens) {
|
|
18663
|
+
if (t11.chains.length > 0) {
|
|
18664
|
+
selectedTokenData = t11;
|
|
18665
|
+
selectedChainData = t11.chains[0];
|
|
18666
|
+
break;
|
|
18667
|
+
}
|
|
18668
|
+
}
|
|
18669
|
+
}
|
|
18670
|
+
if (selectedTokenData && selectedChainData) {
|
|
18671
|
+
return { token: selectedTokenData, chain: selectedChainData };
|
|
18672
|
+
}
|
|
18673
|
+
return null;
|
|
18674
|
+
}
|
|
18675
|
+
function useDefaultSourceToken({
|
|
18676
|
+
supportedTokens,
|
|
18677
|
+
defaultSourceChainType,
|
|
18678
|
+
defaultSourceChainId,
|
|
18679
|
+
defaultSourceTokenAddress,
|
|
18680
|
+
defaultSourceSymbol
|
|
18681
|
+
}) {
|
|
18682
|
+
const [token, setToken] = (0, import_react22.useState)(null);
|
|
18683
|
+
const [chain, setChain] = (0, import_react22.useState)(null);
|
|
18684
|
+
const [initialSelectionDone, setInitialSelectionDone] = (0, import_react22.useState)(false);
|
|
18685
|
+
const appliedDefaultsRef = (0, import_react22.useRef)("");
|
|
18686
|
+
(0, import_react22.useEffect)(() => {
|
|
18687
|
+
if (!supportedTokens.length) return;
|
|
18688
|
+
const defaultsKey = `${defaultSourceTokenAddress ?? ""}|${defaultSourceSymbol ?? ""}|${defaultSourceChainType ?? ""}|${defaultSourceChainId ?? ""}`;
|
|
18689
|
+
const defaultsChanged = appliedDefaultsRef.current !== defaultsKey;
|
|
18690
|
+
if (initialSelectionDone && !defaultsChanged) return;
|
|
18691
|
+
const result = resolveSourceToken(
|
|
18692
|
+
supportedTokens,
|
|
18693
|
+
defaultSourceChainType,
|
|
18694
|
+
defaultSourceChainId,
|
|
18695
|
+
defaultSourceTokenAddress,
|
|
18696
|
+
defaultSourceSymbol
|
|
18697
|
+
);
|
|
18698
|
+
if (result) {
|
|
18699
|
+
setToken(result.token.symbol);
|
|
18700
|
+
setChain(getChainKey(result.chain.chain_id, result.chain.chain_type));
|
|
18701
|
+
appliedDefaultsRef.current = defaultsKey;
|
|
18702
|
+
setInitialSelectionDone(true);
|
|
18703
|
+
}
|
|
18704
|
+
}, [
|
|
18705
|
+
supportedTokens,
|
|
18706
|
+
defaultSourceTokenAddress,
|
|
18707
|
+
defaultSourceSymbol,
|
|
18708
|
+
defaultSourceChainType,
|
|
18709
|
+
defaultSourceChainId,
|
|
18710
|
+
initialSelectionDone
|
|
18711
|
+
]);
|
|
18712
|
+
(0, import_react22.useEffect)(() => {
|
|
18713
|
+
if (!supportedTokens.length || !token) return;
|
|
18714
|
+
const currentToken = supportedTokens.find((t11) => t11.symbol === token);
|
|
18715
|
+
if (!currentToken || currentToken.chains.length === 0) return;
|
|
18716
|
+
const isChainAvailable = chain && currentToken.chains.some((c) => {
|
|
18717
|
+
return getChainKey(c.chain_id, c.chain_type) === chain;
|
|
18718
|
+
});
|
|
18719
|
+
if (!isChainAvailable) {
|
|
18720
|
+
const firstChain = currentToken.chains[0];
|
|
18721
|
+
setChain(getChainKey(firstChain.chain_id, firstChain.chain_type));
|
|
18722
|
+
}
|
|
18723
|
+
}, [token, supportedTokens, chain]);
|
|
18724
|
+
return { token, chain, setToken, setChain, initialSelectionDone };
|
|
18725
|
+
}
|
|
18502
18726
|
function DepositFooterLinks({
|
|
18503
18727
|
onGlossaryClick
|
|
18504
18728
|
}) {
|
|
@@ -18658,7 +18882,7 @@ function GlossaryModal({
|
|
|
18658
18882
|
) });
|
|
18659
18883
|
}
|
|
18660
18884
|
function useCopyAddress() {
|
|
18661
|
-
const [copied, setCopied] = (0,
|
|
18885
|
+
const [copied, setCopied] = (0, import_react23.useState)(false);
|
|
18662
18886
|
const handleCopy = (address) => {
|
|
18663
18887
|
if (!address) return;
|
|
18664
18888
|
navigator.clipboard.writeText(address);
|
|
@@ -18704,7 +18928,7 @@ var TooltipContent2 = React242.forwardRef(({ className, sideOffset = 4, ...props
|
|
|
18704
18928
|
});
|
|
18705
18929
|
TooltipContent2.displayName = Content22.displayName;
|
|
18706
18930
|
var t4 = i18n2.transferCrypto;
|
|
18707
|
-
var
|
|
18931
|
+
var getChainKey2 = (chainId, chainType) => {
|
|
18708
18932
|
return `${chainType}:${chainId}`;
|
|
18709
18933
|
};
|
|
18710
18934
|
var parseChainKey = (chainKey) => {
|
|
@@ -18718,6 +18942,10 @@ function TransferCryptoSingleInput({
|
|
|
18718
18942
|
destinationChainType,
|
|
18719
18943
|
destinationChainId,
|
|
18720
18944
|
destinationTokenAddress,
|
|
18945
|
+
defaultSourceChainType,
|
|
18946
|
+
defaultSourceChainId,
|
|
18947
|
+
defaultSourceTokenAddress,
|
|
18948
|
+
defaultSourceSymbol,
|
|
18721
18949
|
depositConfirmationMode = "auto_ui",
|
|
18722
18950
|
onExecutionsChange,
|
|
18723
18951
|
onDepositSuccess,
|
|
@@ -18726,21 +18954,25 @@ function TransferCryptoSingleInput({
|
|
|
18726
18954
|
}) {
|
|
18727
18955
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
18728
18956
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
18729
|
-
const [token, setToken] = (0, import_react18.useState)("USDC");
|
|
18730
|
-
const [chain, setChain] = (0, import_react18.useState)("solana:mainnet");
|
|
18731
18957
|
const [copied, setCopied] = (0, import_react18.useState)(false);
|
|
18732
18958
|
const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
|
|
18733
18959
|
const [glossaryOpen, setGlossaryOpen] = (0, import_react18.useState)(false);
|
|
18734
18960
|
const [detailsExpanded, setDetailsExpanded] = (0, import_react18.useState)(false);
|
|
18735
18961
|
const [depositsModalOpen, setDepositsModalOpen] = (0, import_react18.useState)(false);
|
|
18736
18962
|
const [tokenSelectorOpen, setTokenSelectorOpen] = (0, import_react18.useState)(false);
|
|
18737
|
-
const [initialSelectionDone, setInitialSelectionDone] = (0, import_react18.useState)(false);
|
|
18738
18963
|
const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
|
|
18739
18964
|
destination_token_address: destinationTokenAddress,
|
|
18740
18965
|
destination_chain_id: destinationChainId,
|
|
18741
18966
|
destination_chain_type: destinationChainType
|
|
18742
18967
|
});
|
|
18743
18968
|
const supportedTokens = tokensResponse?.data ?? [];
|
|
18969
|
+
const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
|
|
18970
|
+
supportedTokens,
|
|
18971
|
+
defaultSourceChainType,
|
|
18972
|
+
defaultSourceChainId,
|
|
18973
|
+
defaultSourceTokenAddress,
|
|
18974
|
+
defaultSourceSymbol
|
|
18975
|
+
});
|
|
18744
18976
|
const {
|
|
18745
18977
|
data: depositAddressResponse,
|
|
18746
18978
|
isLoading: walletsLoading,
|
|
@@ -18760,8 +18992,8 @@ function TransferCryptoSingleInput({
|
|
|
18760
18992
|
const error = walletsError?.message ?? null;
|
|
18761
18993
|
const allAvailableChains = (0, import_react18.useMemo)(() => {
|
|
18762
18994
|
const chainsMap = /* @__PURE__ */ new Map();
|
|
18763
|
-
supportedTokens.forEach((
|
|
18764
|
-
|
|
18995
|
+
supportedTokens.forEach((t11) => {
|
|
18996
|
+
t11.chains.forEach((c) => {
|
|
18765
18997
|
const comboKey = `${c.chain_type}:${c.chain_id}`;
|
|
18766
18998
|
if (!chainsMap.has(comboKey)) {
|
|
18767
18999
|
chainsMap.set(comboKey, c);
|
|
@@ -18770,10 +19002,10 @@ function TransferCryptoSingleInput({
|
|
|
18770
19002
|
});
|
|
18771
19003
|
return Array.from(chainsMap.values());
|
|
18772
19004
|
}, [supportedTokens]);
|
|
18773
|
-
const currentChainCombo = parseChainKey(chain);
|
|
18774
|
-
const currentChainData = allAvailableChains.find(
|
|
19005
|
+
const currentChainCombo = chain ? parseChainKey(chain) : null;
|
|
19006
|
+
const currentChainData = currentChainCombo ? allAvailableChains.find(
|
|
18775
19007
|
(c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
|
|
18776
|
-
);
|
|
19008
|
+
) : void 0;
|
|
18777
19009
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
18778
19010
|
const currentWallet = getWalletByChainType(wallets, currentChainType);
|
|
18779
19011
|
const depositAddress = currentWallet?.address || "";
|
|
@@ -18791,84 +19023,26 @@ function TransferCryptoSingleInput({
|
|
|
18791
19023
|
onDepositSuccess,
|
|
18792
19024
|
onDepositError
|
|
18793
19025
|
});
|
|
18794
|
-
(0, import_react18.useEffect)(() => {
|
|
18795
|
-
if (!supportedTokens.length || initialSelectionDone) return;
|
|
18796
|
-
let selectedTokenData;
|
|
18797
|
-
let selectedChainData;
|
|
18798
|
-
if (destinationTokenAddress) {
|
|
18799
|
-
for (const t7 of supportedTokens) {
|
|
18800
|
-
const matchingChain = t7.chains.find(
|
|
18801
|
-
(c) => c.token_address.toLowerCase() === destinationTokenAddress.toLowerCase()
|
|
18802
|
-
);
|
|
18803
|
-
if (matchingChain) {
|
|
18804
|
-
selectedTokenData = t7;
|
|
18805
|
-
selectedChainData = matchingChain;
|
|
18806
|
-
break;
|
|
18807
|
-
}
|
|
18808
|
-
}
|
|
18809
|
-
}
|
|
18810
|
-
if (!selectedTokenData) {
|
|
18811
|
-
selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDC");
|
|
18812
|
-
if (selectedTokenData && selectedTokenData.chains.length > 0) {
|
|
18813
|
-
selectedChainData = selectedTokenData.chains[0];
|
|
18814
|
-
}
|
|
18815
|
-
}
|
|
18816
|
-
if (!selectedTokenData) {
|
|
18817
|
-
selectedTokenData = supportedTokens.find((t7) => t7.symbol === "USDT");
|
|
18818
|
-
if (selectedTokenData && selectedTokenData.chains.length > 0) {
|
|
18819
|
-
selectedChainData = selectedTokenData.chains[0];
|
|
18820
|
-
}
|
|
18821
|
-
}
|
|
18822
|
-
if (!selectedTokenData) {
|
|
18823
|
-
selectedTokenData = supportedTokens[0];
|
|
18824
|
-
if (selectedTokenData.chains.length > 0) {
|
|
18825
|
-
selectedChainData = selectedTokenData.chains[0];
|
|
18826
|
-
}
|
|
18827
|
-
}
|
|
18828
|
-
if (selectedTokenData) {
|
|
18829
|
-
setToken(selectedTokenData.symbol);
|
|
18830
|
-
}
|
|
18831
|
-
if (selectedChainData) {
|
|
18832
|
-
setChain(
|
|
18833
|
-
getChainKey(selectedChainData.chain_id, selectedChainData.chain_type)
|
|
18834
|
-
);
|
|
18835
|
-
}
|
|
18836
|
-
setInitialSelectionDone(true);
|
|
18837
|
-
}, [supportedTokens, destinationTokenAddress, initialSelectionDone]);
|
|
18838
19026
|
(0, import_react18.useEffect)(() => {
|
|
18839
19027
|
if (onExecutionsChange) {
|
|
18840
19028
|
onExecutionsChange(depositExecutions);
|
|
18841
19029
|
}
|
|
18842
19030
|
}, [depositExecutions, onExecutionsChange]);
|
|
18843
|
-
|
|
18844
|
-
if (!supportedTokens.length) return;
|
|
18845
|
-
const currentToken = supportedTokens.find((t7) => t7.symbol === token);
|
|
18846
|
-
if (!currentToken || currentToken.chains.length === 0) return;
|
|
18847
|
-
const isChainAvailable = currentToken.chains.some((c) => {
|
|
18848
|
-
const key = getChainKey(c.chain_id, c.chain_type);
|
|
18849
|
-
return key === chain;
|
|
18850
|
-
});
|
|
18851
|
-
if (!isChainAvailable) {
|
|
18852
|
-
const firstChain = currentToken.chains[0];
|
|
18853
|
-
const newChain = getChainKey(firstChain.chain_id, firstChain.chain_type);
|
|
18854
|
-
setChain(newChain);
|
|
18855
|
-
}
|
|
18856
|
-
}, [token, supportedTokens, chain]);
|
|
18857
|
-
const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
|
|
19031
|
+
const selectedToken = token ? supportedTokens.find((t11) => t11.symbol === token) : void 0;
|
|
18858
19032
|
const availableChainsForToken = selectedToken?.chains || [];
|
|
18859
|
-
const currentChainFromBackend = availableChainsForToken.find((c) => {
|
|
18860
|
-
const key =
|
|
19033
|
+
const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
|
|
19034
|
+
const key = getChainKey2(c.chain_id, c.chain_type);
|
|
18861
19035
|
return key === chain;
|
|
18862
19036
|
}) || allAvailableChains.find((c) => {
|
|
18863
|
-
const key =
|
|
19037
|
+
const key = getChainKey2(c.chain_id, c.chain_type);
|
|
18864
19038
|
return key === chain;
|
|
18865
|
-
});
|
|
19039
|
+
}) : void 0;
|
|
18866
19040
|
const handleCopyAddress = () => {
|
|
18867
19041
|
navigator.clipboard.writeText(depositAddress);
|
|
18868
19042
|
setCopied(true);
|
|
18869
19043
|
setTimeout(() => setCopied(false), 2e3);
|
|
18870
19044
|
};
|
|
18871
|
-
const
|
|
19045
|
+
const formatProcessingTime3 = (seconds) => {
|
|
18872
19046
|
if (seconds === null) {
|
|
18873
19047
|
return t4.processingTime.lessThanMinutes.replace("{{minutes}}", "1");
|
|
18874
19048
|
}
|
|
@@ -18897,10 +19071,10 @@ function TransferCryptoSingleInput({
|
|
|
18897
19071
|
"button",
|
|
18898
19072
|
{
|
|
18899
19073
|
onClick: () => setTokenSelectorOpen(true),
|
|
18900
|
-
disabled: tokensLoading || supportedTokens.length === 0,
|
|
19074
|
+
disabled: tokensLoading || !token || supportedTokens.length === 0,
|
|
18901
19075
|
className: "uf-w-full hover:uf-bg-accent uf-p-3 uf-flex uf-items-center uf-gap-3 uf-transition-colors disabled:uf-opacity-50 disabled:uf-cursor-not-allowed",
|
|
18902
19076
|
style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` },
|
|
18903
|
-
children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
|
|
19077
|
+
children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-3 uf-animate-pulse", children: [
|
|
18904
19078
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-w-10 uf-h-10 uf-rounded-full uf-bg-muted" }),
|
|
18905
19079
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsxs)("div", { className: "uf-flex-1", children: [
|
|
18906
19080
|
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("div", { className: "uf-h-4 uf-w-16 uf-bg-muted uf-rounded uf-mb-1" }),
|
|
@@ -18974,8 +19148,8 @@ function TransferCryptoSingleInput({
|
|
|
18974
19148
|
open: tokenSelectorOpen,
|
|
18975
19149
|
onOpenChange: setTokenSelectorOpen,
|
|
18976
19150
|
tokens: supportedTokens,
|
|
18977
|
-
selectedToken: token,
|
|
18978
|
-
selectedChainKey: chain,
|
|
19151
|
+
selectedToken: token ?? "",
|
|
19152
|
+
selectedChainKey: chain ?? "",
|
|
18979
19153
|
onSelect: (newToken, newChain) => {
|
|
18980
19154
|
setToken(newToken);
|
|
18981
19155
|
setChain(newChain);
|
|
@@ -19077,7 +19251,7 @@ function TransferCryptoSingleInput({
|
|
|
19077
19251
|
t4.processingTime.label,
|
|
19078
19252
|
":",
|
|
19079
19253
|
" ",
|
|
19080
|
-
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children:
|
|
19254
|
+
/* @__PURE__ */ (0, import_jsx_runtime58.jsx)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: formatProcessingTime3(processingTime) })
|
|
19081
19255
|
] })
|
|
19082
19256
|
] }),
|
|
19083
19257
|
detailsExpanded ? /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ChevronUp, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } }) : /* @__PURE__ */ (0, import_jsx_runtime58.jsx)(ChevronDown, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } })
|
|
@@ -19313,7 +19487,7 @@ var SelectSeparator2 = React252.forwardRef(({ className, ...props }, ref) => /*
|
|
|
19313
19487
|
));
|
|
19314
19488
|
SelectSeparator2.displayName = Separator.displayName;
|
|
19315
19489
|
var t5 = i18n2.transferCrypto;
|
|
19316
|
-
var
|
|
19490
|
+
var getChainKey3 = (chainId, chainType) => {
|
|
19317
19491
|
return `${chainType}:${chainId}`;
|
|
19318
19492
|
};
|
|
19319
19493
|
var parseChainKey2 = (chainKey) => {
|
|
@@ -19327,6 +19501,10 @@ function TransferCryptoDoubleInput({
|
|
|
19327
19501
|
destinationChainType,
|
|
19328
19502
|
destinationChainId,
|
|
19329
19503
|
destinationTokenAddress,
|
|
19504
|
+
defaultSourceChainType,
|
|
19505
|
+
defaultSourceChainId,
|
|
19506
|
+
defaultSourceTokenAddress,
|
|
19507
|
+
defaultSourceSymbol,
|
|
19330
19508
|
depositConfirmationMode = "auto_ui",
|
|
19331
19509
|
onExecutionsChange,
|
|
19332
19510
|
onDepositSuccess,
|
|
@@ -19335,20 +19513,24 @@ function TransferCryptoDoubleInput({
|
|
|
19335
19513
|
}) {
|
|
19336
19514
|
const { themeClass, colors: colors2, fonts, components } = useTheme();
|
|
19337
19515
|
const isDarkMode = themeClass.includes("uf-dark");
|
|
19338
|
-
const [
|
|
19339
|
-
const [chain, setChain] = (0, import_react23.useState)("solana:mainnet");
|
|
19340
|
-
const [copied, setCopied] = (0, import_react23.useState)(false);
|
|
19516
|
+
const [copied, setCopied] = (0, import_react24.useState)(false);
|
|
19341
19517
|
const { copied: copiedRecipient, handleCopy: handleCopyRecipientAddress } = useCopyAddress();
|
|
19342
|
-
const [glossaryOpen, setGlossaryOpen] = (0,
|
|
19343
|
-
const [detailsExpanded, setDetailsExpanded] = (0,
|
|
19344
|
-
const [depositsModalOpen, setDepositsModalOpen] = (0,
|
|
19345
|
-
const [initialSelectionDone, setInitialSelectionDone] = (0, import_react23.useState)(false);
|
|
19518
|
+
const [glossaryOpen, setGlossaryOpen] = (0, import_react24.useState)(false);
|
|
19519
|
+
const [detailsExpanded, setDetailsExpanded] = (0, import_react24.useState)(false);
|
|
19520
|
+
const [depositsModalOpen, setDepositsModalOpen] = (0, import_react24.useState)(false);
|
|
19346
19521
|
const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDepositTokens(publishableKey, {
|
|
19347
19522
|
destination_token_address: destinationTokenAddress,
|
|
19348
19523
|
destination_chain_id: destinationChainId,
|
|
19349
19524
|
destination_chain_type: destinationChainType
|
|
19350
19525
|
});
|
|
19351
19526
|
const supportedTokens = tokensResponse?.data ?? [];
|
|
19527
|
+
const { token, chain, setToken, setChain, initialSelectionDone } = useDefaultSourceToken({
|
|
19528
|
+
supportedTokens,
|
|
19529
|
+
defaultSourceChainType,
|
|
19530
|
+
defaultSourceChainId,
|
|
19531
|
+
defaultSourceTokenAddress,
|
|
19532
|
+
defaultSourceSymbol
|
|
19533
|
+
});
|
|
19352
19534
|
const {
|
|
19353
19535
|
data: depositAddressResponse,
|
|
19354
19536
|
isLoading: walletsLoading,
|
|
@@ -19366,10 +19548,10 @@ function TransferCryptoDoubleInput({
|
|
|
19366
19548
|
const wallets = externalWallets?.length ? externalWallets : depositAddressResponse?.data ?? [];
|
|
19367
19549
|
const loading = externalWallets?.length ? false : walletsLoading;
|
|
19368
19550
|
const error = walletsError?.message ?? null;
|
|
19369
|
-
const allAvailableChains = (0,
|
|
19551
|
+
const allAvailableChains = (0, import_react24.useMemo)(() => {
|
|
19370
19552
|
const chainsMap = /* @__PURE__ */ new Map();
|
|
19371
|
-
supportedTokens.forEach((
|
|
19372
|
-
|
|
19553
|
+
supportedTokens.forEach((t11) => {
|
|
19554
|
+
t11.chains.forEach((c) => {
|
|
19373
19555
|
const comboKey = `${c.chain_type}:${c.chain_id}`;
|
|
19374
19556
|
if (!chainsMap.has(comboKey)) {
|
|
19375
19557
|
chainsMap.set(comboKey, c);
|
|
@@ -19378,10 +19560,10 @@ function TransferCryptoDoubleInput({
|
|
|
19378
19560
|
});
|
|
19379
19561
|
return Array.from(chainsMap.values());
|
|
19380
19562
|
}, [supportedTokens]);
|
|
19381
|
-
const currentChainCombo = parseChainKey2(chain);
|
|
19382
|
-
const currentChainData = allAvailableChains.find(
|
|
19563
|
+
const currentChainCombo = chain ? parseChainKey2(chain) : null;
|
|
19564
|
+
const currentChainData = currentChainCombo ? allAvailableChains.find(
|
|
19383
19565
|
(c) => c.chain_type === currentChainCombo.chainType && c.chain_id === currentChainCombo.chainId
|
|
19384
|
-
);
|
|
19566
|
+
) : void 0;
|
|
19385
19567
|
const currentChainType = currentChainData?.chain_type || "ethereum";
|
|
19386
19568
|
const currentWallet = getWalletByChainType(wallets, currentChainType);
|
|
19387
19569
|
const depositAddress = currentWallet?.address || "";
|
|
@@ -19399,57 +19581,26 @@ function TransferCryptoDoubleInput({
|
|
|
19399
19581
|
onDepositSuccess,
|
|
19400
19582
|
onDepositError
|
|
19401
19583
|
});
|
|
19402
|
-
(0,
|
|
19403
|
-
if (!supportedTokens.length || initialSelectionDone) return;
|
|
19404
|
-
const allChains = /* @__PURE__ */ new Set();
|
|
19405
|
-
supportedTokens.forEach((t7) => {
|
|
19406
|
-
t7.chains.forEach((c) => {
|
|
19407
|
-
allChains.add(getChainKey2(c.chain_id, c.chain_type));
|
|
19408
|
-
});
|
|
19409
|
-
});
|
|
19410
|
-
if (!allChains.has(chain)) {
|
|
19411
|
-
const firstToken = supportedTokens[0];
|
|
19412
|
-
if (firstToken.chains.length > 0) {
|
|
19413
|
-
const firstChain = firstToken.chains[0];
|
|
19414
|
-
setChain(getChainKey2(firstChain.chain_id, firstChain.chain_type));
|
|
19415
|
-
}
|
|
19416
|
-
}
|
|
19417
|
-
setInitialSelectionDone(true);
|
|
19418
|
-
}, [supportedTokens, chain, initialSelectionDone]);
|
|
19419
|
-
(0, import_react23.useEffect)(() => {
|
|
19584
|
+
(0, import_react24.useEffect)(() => {
|
|
19420
19585
|
if (onExecutionsChange) {
|
|
19421
19586
|
onExecutionsChange(depositExecutions);
|
|
19422
19587
|
}
|
|
19423
19588
|
}, [depositExecutions, onExecutionsChange]);
|
|
19424
|
-
|
|
19425
|
-
if (!supportedTokens.length) return;
|
|
19426
|
-
const currentToken = supportedTokens.find((t7) => t7.symbol === token);
|
|
19427
|
-
if (!currentToken || currentToken.chains.length === 0) return;
|
|
19428
|
-
const isChainAvailable = currentToken.chains.some((c) => {
|
|
19429
|
-
const key = getChainKey2(c.chain_id, c.chain_type);
|
|
19430
|
-
return key === chain;
|
|
19431
|
-
});
|
|
19432
|
-
if (!isChainAvailable) {
|
|
19433
|
-
const firstChain = currentToken.chains[0];
|
|
19434
|
-
const newChain = getChainKey2(firstChain.chain_id, firstChain.chain_type);
|
|
19435
|
-
setChain(newChain);
|
|
19436
|
-
}
|
|
19437
|
-
}, [token, supportedTokens, chain]);
|
|
19438
|
-
const selectedToken = supportedTokens.find((t7) => t7.symbol === token);
|
|
19589
|
+
const selectedToken = token ? supportedTokens.find((t11) => t11.symbol === token) : void 0;
|
|
19439
19590
|
const availableChainsForToken = selectedToken?.chains || [];
|
|
19440
|
-
const currentChainFromBackend = availableChainsForToken.find((c) => {
|
|
19441
|
-
const key =
|
|
19591
|
+
const currentChainFromBackend = chain ? availableChainsForToken.find((c) => {
|
|
19592
|
+
const key = getChainKey3(c.chain_id, c.chain_type);
|
|
19442
19593
|
return key === chain;
|
|
19443
19594
|
}) || allAvailableChains.find((c) => {
|
|
19444
|
-
const key =
|
|
19595
|
+
const key = getChainKey3(c.chain_id, c.chain_type);
|
|
19445
19596
|
return key === chain;
|
|
19446
|
-
});
|
|
19597
|
+
}) : void 0;
|
|
19447
19598
|
const handleCopyAddress = () => {
|
|
19448
19599
|
navigator.clipboard.writeText(depositAddress);
|
|
19449
19600
|
setCopied(true);
|
|
19450
19601
|
setTimeout(() => setCopied(false), 2e3);
|
|
19451
19602
|
};
|
|
19452
|
-
const
|
|
19603
|
+
const formatProcessingTime3 = (seconds) => {
|
|
19453
19604
|
if (seconds === null) {
|
|
19454
19605
|
return t5.processingTime.lessThanMinutes.replace("{{minutes}}", "1");
|
|
19455
19606
|
}
|
|
@@ -19517,11 +19668,11 @@ function TransferCryptoDoubleInput({
|
|
|
19517
19668
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
19518
19669
|
Select2,
|
|
19519
19670
|
{
|
|
19520
|
-
value: token,
|
|
19671
|
+
value: token ?? "",
|
|
19521
19672
|
onValueChange: setToken,
|
|
19522
|
-
disabled: tokensLoading || supportedTokens.length === 0,
|
|
19673
|
+
disabled: tokensLoading || !token || supportedTokens.length === 0,
|
|
19523
19674
|
children: [
|
|
19524
|
-
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
|
|
19675
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading || !token ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: token }) }) }) }),
|
|
19525
19676
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectContent2, { className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px]", style: { border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`, ...fonts.regular ? { "--uf-font-family": fonts.regular } : {} }, children: supportedTokens.map((tokenData) => /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
19526
19677
|
SelectItem2,
|
|
19527
19678
|
{
|
|
@@ -19548,11 +19699,11 @@ function TransferCryptoDoubleInput({
|
|
|
19548
19699
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsxs)(
|
|
19549
19700
|
Select2,
|
|
19550
19701
|
{
|
|
19551
|
-
value: chain,
|
|
19702
|
+
value: chain ?? "",
|
|
19552
19703
|
onValueChange: setChain,
|
|
19553
|
-
disabled: tokensLoading || availableChainsForToken.length === 0,
|
|
19704
|
+
disabled: tokensLoading || !chain || availableChainsForToken.length === 0,
|
|
19554
19705
|
children: [
|
|
19555
|
-
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : currentChainFromBackend ? renderChainItem(currentChainFromBackend) : currentChainData ? renderChainItem(currentChainData) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
|
|
19706
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectTrigger2, { className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50", style: { backgroundColor: components.card.backgroundColor, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(SelectValue2, { children: tokensLoading || !chain ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t5.loading }) }) : currentChainFromBackend ? renderChainItem(currentChainFromBackend) : currentChainData ? renderChainItem(currentChainData) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-flex uf-items-center uf-gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chain }) }) }) }),
|
|
19556
19707
|
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)(
|
|
19557
19708
|
SelectContent2,
|
|
19558
19709
|
{
|
|
@@ -19560,7 +19711,7 @@ function TransferCryptoDoubleInput({
|
|
|
19560
19711
|
className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px] uf-min-w-[200px]",
|
|
19561
19712
|
style: { border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`, ...fonts.regular ? { "--uf-font-family": fonts.regular } : {} },
|
|
19562
19713
|
children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)("div", { className: "uf-px-2 uf-py-3 uf-text-xs uf-text-muted-foreground uf-text-center", children: t5.noChainsAvailable }) : availableChainsForToken.map((chainData) => {
|
|
19563
|
-
const chainKey =
|
|
19714
|
+
const chainKey = getChainKey3(
|
|
19564
19715
|
chainData.chain_id,
|
|
19565
19716
|
chainData.chain_type
|
|
19566
19717
|
);
|
|
@@ -19676,7 +19827,7 @@ function TransferCryptoDoubleInput({
|
|
|
19676
19827
|
t5.processingTime.label,
|
|
19677
19828
|
":",
|
|
19678
19829
|
" ",
|
|
19679
|
-
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children:
|
|
19830
|
+
/* @__PURE__ */ (0, import_jsx_runtime60.jsx)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: formatProcessingTime3(processingTime) })
|
|
19680
19831
|
] })
|
|
19681
19832
|
] }),
|
|
19682
19833
|
detailsExpanded ? /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChevronUp, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } }) : /* @__PURE__ */ (0, import_jsx_runtime60.jsx)(ChevronDown, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } })
|
|
@@ -20555,8 +20706,8 @@ function ConfirmingView({
|
|
|
20555
20706
|
isPolling = false
|
|
20556
20707
|
}) {
|
|
20557
20708
|
const { colors: colors2, fonts } = useTheme();
|
|
20558
|
-
const [containerEl, setContainerEl] = (0,
|
|
20559
|
-
const containerCallbackRef = (0,
|
|
20709
|
+
const [containerEl, setContainerEl] = (0, import_react25.useState)(null);
|
|
20710
|
+
const containerCallbackRef = (0, import_react25.useCallback)((el) => {
|
|
20560
20711
|
setContainerEl(el);
|
|
20561
20712
|
}, []);
|
|
20562
20713
|
return /* @__PURE__ */ (0, import_jsx_runtime65.jsx)(PortalContainerProvider, { value: containerEl, children: /* @__PURE__ */ (0, import_jsx_runtime65.jsxs)(
|
|
@@ -20720,7 +20871,7 @@ function BrowserWalletModal({
|
|
|
20720
20871
|
);
|
|
20721
20872
|
if (cancelled) return;
|
|
20722
20873
|
const supportedToken = response.data.find(
|
|
20723
|
-
(
|
|
20874
|
+
(t11) => t11.symbol.toLowerCase() === token.symbol.toLowerCase()
|
|
20724
20875
|
);
|
|
20725
20876
|
if (supportedToken) {
|
|
20726
20877
|
const chainDetail = supportedToken.chains.find(
|
|
@@ -21928,6 +22079,10 @@ function DepositModal({
|
|
|
21928
22079
|
destinationChainType,
|
|
21929
22080
|
destinationChainId,
|
|
21930
22081
|
destinationTokenAddress,
|
|
22082
|
+
defaultSourceChainType,
|
|
22083
|
+
defaultSourceChainId,
|
|
22084
|
+
defaultSourceTokenAddress,
|
|
22085
|
+
defaultSourceSymbol,
|
|
21931
22086
|
hideDepositTracker = false,
|
|
21932
22087
|
showBalanceHeader = false,
|
|
21933
22088
|
transferInputVariant = "double_input",
|
|
@@ -22024,7 +22179,7 @@ function DepositModal({
|
|
|
22024
22179
|
if (view !== "tracker" || !userId) return;
|
|
22025
22180
|
const fetchExecutions = async () => {
|
|
22026
22181
|
try {
|
|
22027
|
-
const response = await queryExecutions(userId, publishableKey);
|
|
22182
|
+
const response = await queryExecutions(userId, publishableKey, ActionType.Deposit);
|
|
22028
22183
|
const sorted = [...response.data].sort((a, b) => {
|
|
22029
22184
|
const timeA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
22030
22185
|
const timeB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
@@ -22360,6 +22515,10 @@ function DepositModal({
|
|
|
22360
22515
|
destinationChainType,
|
|
22361
22516
|
destinationChainId,
|
|
22362
22517
|
destinationTokenAddress,
|
|
22518
|
+
defaultSourceChainType,
|
|
22519
|
+
defaultSourceChainId,
|
|
22520
|
+
defaultSourceTokenAddress,
|
|
22521
|
+
defaultSourceSymbol,
|
|
22363
22522
|
depositConfirmationMode,
|
|
22364
22523
|
onExecutionsChange: setDepositExecutions,
|
|
22365
22524
|
onDepositSuccess,
|
|
@@ -22375,6 +22534,10 @@ function DepositModal({
|
|
|
22375
22534
|
destinationChainType,
|
|
22376
22535
|
destinationChainId,
|
|
22377
22536
|
destinationTokenAddress,
|
|
22537
|
+
defaultSourceChainType,
|
|
22538
|
+
defaultSourceChainId,
|
|
22539
|
+
defaultSourceTokenAddress,
|
|
22540
|
+
defaultSourceSymbol,
|
|
22378
22541
|
depositConfirmationMode,
|
|
22379
22542
|
onExecutionsChange: setDepositExecutions,
|
|
22380
22543
|
onDepositSuccess,
|
|
@@ -22535,99 +22698,1822 @@ function DepositModal({
|
|
|
22535
22698
|
}
|
|
22536
22699
|
) });
|
|
22537
22700
|
}
|
|
22538
|
-
|
|
22539
|
-
|
|
22540
|
-
|
|
22541
|
-
|
|
22542
|
-
|
|
22701
|
+
function useSupportedDestinationTokens(publishableKey, enabled = true) {
|
|
22702
|
+
return (0, import_react_query11.useQuery)({
|
|
22703
|
+
queryKey: ["unifold", "supportedDestinationTokens", publishableKey],
|
|
22704
|
+
queryFn: () => getSupportedDestinationTokens(publishableKey),
|
|
22705
|
+
staleTime: 1e3 * 60 * 5,
|
|
22706
|
+
gcTime: 1e3 * 60 * 30,
|
|
22707
|
+
refetchOnMount: false,
|
|
22708
|
+
refetchOnWindowFocus: false,
|
|
22709
|
+
enabled
|
|
22710
|
+
});
|
|
22711
|
+
}
|
|
22712
|
+
function useSourceTokenValidation(params) {
|
|
22713
|
+
const {
|
|
22714
|
+
sourceChainType,
|
|
22715
|
+
sourceChainId,
|
|
22716
|
+
sourceTokenAddress,
|
|
22717
|
+
sourceTokenSymbol,
|
|
22718
|
+
publishableKey,
|
|
22719
|
+
enabled = true
|
|
22720
|
+
} = params;
|
|
22721
|
+
const hasParams = !!sourceChainType && !!sourceChainId && !!sourceTokenAddress;
|
|
22722
|
+
return (0, import_react_query12.useQuery)({
|
|
22723
|
+
queryKey: [
|
|
22724
|
+
"unifold",
|
|
22725
|
+
"sourceTokenValidation",
|
|
22726
|
+
sourceChainType ?? null,
|
|
22727
|
+
sourceChainId ?? null,
|
|
22728
|
+
sourceTokenAddress ?? null,
|
|
22729
|
+
publishableKey
|
|
22730
|
+
],
|
|
22731
|
+
queryFn: async () => {
|
|
22732
|
+
const res = await getSupportedDepositTokens(publishableKey);
|
|
22733
|
+
let matchedMinUsd = null;
|
|
22734
|
+
let matchedProcessingTime = null;
|
|
22735
|
+
let matchedSlippage = null;
|
|
22736
|
+
let matchedPriceImpact = null;
|
|
22737
|
+
const found = res.data.some(
|
|
22738
|
+
(token) => token.chains.some((chain) => {
|
|
22739
|
+
const match = chain.chain_type === sourceChainType && chain.chain_id === sourceChainId && chain.token_address.toLowerCase() === sourceTokenAddress.toLowerCase();
|
|
22740
|
+
if (match) {
|
|
22741
|
+
matchedMinUsd = chain.minimum_deposit_amount_usd;
|
|
22742
|
+
matchedProcessingTime = chain.estimated_processing_time;
|
|
22743
|
+
matchedSlippage = chain.max_slippage_percent;
|
|
22744
|
+
matchedPriceImpact = chain.estimated_price_impact_percent;
|
|
22745
|
+
}
|
|
22746
|
+
return match;
|
|
22747
|
+
})
|
|
22748
|
+
);
|
|
22749
|
+
return {
|
|
22750
|
+
isSupported: found,
|
|
22751
|
+
minimumAmountUsd: matchedMinUsd,
|
|
22752
|
+
estimatedProcessingTime: matchedProcessingTime,
|
|
22753
|
+
maxSlippagePercent: matchedSlippage,
|
|
22754
|
+
priceImpactPercent: matchedPriceImpact,
|
|
22755
|
+
errorMessage: found ? null : `${sourceTokenSymbol || "Source token"} is not a supported withdrawal token. Supported tokens include USDC, USDT, and other stablecoins.`
|
|
22756
|
+
};
|
|
22757
|
+
},
|
|
22758
|
+
enabled: enabled && hasParams,
|
|
22759
|
+
staleTime: 1e3 * 60 * 5,
|
|
22760
|
+
gcTime: 1e3 * 60 * 30,
|
|
22761
|
+
refetchOnMount: false,
|
|
22762
|
+
refetchOnWindowFocus: false
|
|
22763
|
+
});
|
|
22764
|
+
}
|
|
22765
|
+
function useAddressBalance(params) {
|
|
22766
|
+
const {
|
|
22767
|
+
address,
|
|
22768
|
+
chainType,
|
|
22769
|
+
chainId,
|
|
22770
|
+
tokenAddress,
|
|
22771
|
+
publishableKey,
|
|
22772
|
+
enabled = true
|
|
22773
|
+
} = params;
|
|
22774
|
+
const hasParams = !!address && !!chainType && !!chainId && !!tokenAddress;
|
|
22775
|
+
return (0, import_react_query13.useQuery)({
|
|
22776
|
+
queryKey: [
|
|
22777
|
+
"unifold",
|
|
22778
|
+
"addressBalance",
|
|
22779
|
+
address ?? null,
|
|
22780
|
+
chainType ?? null,
|
|
22781
|
+
chainId ?? null,
|
|
22782
|
+
tokenAddress ?? null,
|
|
22783
|
+
publishableKey
|
|
22784
|
+
],
|
|
22785
|
+
queryFn: async () => {
|
|
22786
|
+
const res = await getAddressBalance(
|
|
22787
|
+
address,
|
|
22788
|
+
chainType,
|
|
22789
|
+
chainId,
|
|
22790
|
+
tokenAddress,
|
|
22791
|
+
publishableKey
|
|
22792
|
+
);
|
|
22793
|
+
if (res.balance) {
|
|
22794
|
+
const decimals = res.balance.token?.decimals ?? 6;
|
|
22795
|
+
const symbol = res.balance.token?.symbol ?? "";
|
|
22796
|
+
const baseUnit = res.balance.amount;
|
|
22797
|
+
const raw = BigInt(baseUnit);
|
|
22798
|
+
const divisor = BigInt(10 ** decimals);
|
|
22799
|
+
const whole = raw / divisor;
|
|
22800
|
+
const frac = raw % divisor;
|
|
22801
|
+
const fracStr = frac.toString().padStart(decimals, "0").replace(/0+$/, "");
|
|
22802
|
+
const balanceHuman = fracStr ? `${whole}.${fracStr}` : whole.toString();
|
|
22803
|
+
return {
|
|
22804
|
+
balanceBaseUnit: baseUnit,
|
|
22805
|
+
balanceHuman,
|
|
22806
|
+
balanceUsd: res.balance.amount_usd,
|
|
22807
|
+
exchangeRate: res.balance.exchange_rate,
|
|
22808
|
+
decimals,
|
|
22809
|
+
symbol
|
|
22810
|
+
};
|
|
22811
|
+
}
|
|
22812
|
+
return { balanceBaseUnit: "0", balanceHuman: "0", balanceUsd: "0", exchangeRate: null, decimals: 6, symbol: "" };
|
|
22813
|
+
},
|
|
22814
|
+
enabled: enabled && hasParams,
|
|
22815
|
+
staleTime: 1e3 * 30,
|
|
22816
|
+
gcTime: 1e3 * 60 * 5,
|
|
22817
|
+
refetchInterval: 1e3 * 30,
|
|
22818
|
+
refetchOnMount: "always",
|
|
22819
|
+
refetchOnWindowFocus: false
|
|
22820
|
+
});
|
|
22821
|
+
}
|
|
22822
|
+
function useExecutions(userId, publishableKey, options) {
|
|
22823
|
+
const actionType = options?.actionType ?? ActionType.Deposit;
|
|
22824
|
+
return (0, import_react_query14.useQuery)({
|
|
22825
|
+
queryKey: ["unifold", "executions", actionType, userId, publishableKey],
|
|
22826
|
+
queryFn: () => queryExecutions(userId, publishableKey, actionType),
|
|
22827
|
+
enabled: (options?.enabled ?? true) && !!userId,
|
|
22828
|
+
refetchInterval: options?.refetchInterval ?? 3e3,
|
|
22829
|
+
staleTime: 0,
|
|
22830
|
+
gcTime: 1e3 * 60 * 5,
|
|
22831
|
+
refetchOnWindowFocus: false
|
|
22832
|
+
});
|
|
22833
|
+
}
|
|
22834
|
+
var POLL_INTERVAL_MS2 = 2500;
|
|
22835
|
+
var POLL_ENDPOINT_INTERVAL_MS2 = 3e3;
|
|
22836
|
+
var CUTOFF_BUFFER_MS2 = 6e4;
|
|
22837
|
+
function useWithdrawPolling({
|
|
22838
|
+
userId,
|
|
22543
22839
|
publishableKey,
|
|
22544
|
-
|
|
22840
|
+
depositWalletId,
|
|
22841
|
+
enabled = false,
|
|
22842
|
+
onWithdrawSuccess,
|
|
22843
|
+
onWithdrawError
|
|
22545
22844
|
}) {
|
|
22546
|
-
const [
|
|
22547
|
-
const [
|
|
22548
|
-
|
|
22549
|
-
);
|
|
22550
|
-
const
|
|
22551
|
-
(0,
|
|
22552
|
-
|
|
22553
|
-
|
|
22554
|
-
|
|
22555
|
-
}, [
|
|
22556
|
-
|
|
22557
|
-
|
|
22558
|
-
|
|
22559
|
-
|
|
22560
|
-
|
|
22561
|
-
|
|
22562
|
-
|
|
22563
|
-
setResolvedTheme(e.matches ? "dark" : "light");
|
|
22564
|
-
};
|
|
22565
|
-
mediaQuery.addEventListener("change", handler);
|
|
22566
|
-
return () => mediaQuery.removeEventListener("change", handler);
|
|
22567
|
-
} else {
|
|
22568
|
-
setResolvedTheme(appearance);
|
|
22569
|
-
}
|
|
22570
|
-
}, [config?.appearance]);
|
|
22571
|
-
const depositPromiseRef = import_react25.default.useRef(null);
|
|
22572
|
-
const depositConfigRef = import_react25.default.useRef(null);
|
|
22573
|
-
depositConfigRef.current = depositConfig;
|
|
22574
|
-
const closeTimeoutRef = import_react25.default.useRef(null);
|
|
22575
|
-
const closeGuardRef = import_react25.default.useRef(false);
|
|
22576
|
-
const beginDeposit = (0, import_react25.useCallback)((config2) => {
|
|
22577
|
-
if (closeTimeoutRef.current) {
|
|
22578
|
-
clearTimeout(closeTimeoutRef.current);
|
|
22579
|
-
closeTimeoutRef.current = null;
|
|
22580
|
-
}
|
|
22581
|
-
closeGuardRef.current = false;
|
|
22582
|
-
if (depositPromiseRef.current) {
|
|
22583
|
-
console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit.");
|
|
22584
|
-
depositPromiseRef.current.reject({
|
|
22585
|
-
message: "Deposit cancelled - new deposit started",
|
|
22586
|
-
code: "DEPOSIT_SUPERSEDED"
|
|
22587
|
-
});
|
|
22588
|
-
depositPromiseRef.current = null;
|
|
22589
|
-
}
|
|
22590
|
-
const promise = new Promise((resolve, reject) => {
|
|
22591
|
-
depositPromiseRef.current = { resolve, reject };
|
|
22592
|
-
});
|
|
22593
|
-
promise.catch(() => {
|
|
22594
|
-
});
|
|
22595
|
-
setDepositConfig(config2);
|
|
22596
|
-
setIsOpen(true);
|
|
22597
|
-
return promise;
|
|
22598
|
-
}, []);
|
|
22599
|
-
const closeDeposit = (0, import_react25.useCallback)(() => {
|
|
22600
|
-
if (closeGuardRef.current) {
|
|
22601
|
-
return;
|
|
22602
|
-
}
|
|
22603
|
-
closeGuardRef.current = true;
|
|
22604
|
-
const promiseToReject = depositPromiseRef.current;
|
|
22605
|
-
depositPromiseRef.current = null;
|
|
22606
|
-
if (depositConfigRef.current?.onClose) {
|
|
22607
|
-
depositConfigRef.current.onClose();
|
|
22608
|
-
}
|
|
22609
|
-
if (promiseToReject) {
|
|
22610
|
-
promiseToReject.reject({
|
|
22611
|
-
message: "Deposit cancelled by user",
|
|
22612
|
-
code: "DEPOSIT_CANCELLED"
|
|
22613
|
-
});
|
|
22614
|
-
}
|
|
22615
|
-
setIsOpen(false);
|
|
22616
|
-
closeTimeoutRef.current = setTimeout(() => {
|
|
22617
|
-
setDepositConfig(null);
|
|
22618
|
-
closeTimeoutRef.current = null;
|
|
22619
|
-
}, 200);
|
|
22620
|
-
}, []);
|
|
22621
|
-
const handleDepositSuccess = (0, import_react25.useCallback)((data) => {
|
|
22622
|
-
if (depositConfig?.onSuccess) {
|
|
22623
|
-
depositConfig.onSuccess(data);
|
|
22845
|
+
const [executions, setExecutions] = (0, import_react27.useState)([]);
|
|
22846
|
+
const [isPolling, setIsPolling] = (0, import_react27.useState)(false);
|
|
22847
|
+
const enabledAtRef = (0, import_react27.useRef)(/* @__PURE__ */ new Date());
|
|
22848
|
+
const trackedRef = (0, import_react27.useRef)(/* @__PURE__ */ new Map());
|
|
22849
|
+
const prevEnabledRef = (0, import_react27.useRef)(false);
|
|
22850
|
+
const onSuccessRef = (0, import_react27.useRef)(onWithdrawSuccess);
|
|
22851
|
+
const onErrorRef = (0, import_react27.useRef)(onWithdrawError);
|
|
22852
|
+
(0, import_react27.useEffect)(() => {
|
|
22853
|
+
onSuccessRef.current = onWithdrawSuccess;
|
|
22854
|
+
}, [onWithdrawSuccess]);
|
|
22855
|
+
(0, import_react27.useEffect)(() => {
|
|
22856
|
+
onErrorRef.current = onWithdrawError;
|
|
22857
|
+
}, [onWithdrawError]);
|
|
22858
|
+
(0, import_react27.useEffect)(() => {
|
|
22859
|
+
if (enabled && !prevEnabledRef.current) {
|
|
22860
|
+
enabledAtRef.current = /* @__PURE__ */ new Date();
|
|
22861
|
+
trackedRef.current.clear();
|
|
22624
22862
|
}
|
|
22625
|
-
if (
|
|
22626
|
-
|
|
22627
|
-
depositPromiseRef.current = null;
|
|
22863
|
+
if (!enabled) {
|
|
22864
|
+
trackedRef.current.clear();
|
|
22628
22865
|
}
|
|
22629
|
-
|
|
22630
|
-
|
|
22866
|
+
prevEnabledRef.current = enabled;
|
|
22867
|
+
}, [enabled]);
|
|
22868
|
+
(0, import_react27.useEffect)(() => {
|
|
22869
|
+
if (!userId || !enabled) return;
|
|
22870
|
+
const enabledAt = enabledAtRef.current;
|
|
22871
|
+
const poll = async () => {
|
|
22872
|
+
try {
|
|
22873
|
+
const response = await queryExecutions(userId, publishableKey, ActionType.Withdraw);
|
|
22874
|
+
const cutoff = new Date(enabledAt.getTime() - CUTOFF_BUFFER_MS2);
|
|
22875
|
+
const sorted = [...response.data].sort((a, b) => {
|
|
22876
|
+
const tA = a.created_at ? new Date(a.created_at).getTime() : 0;
|
|
22877
|
+
const tB = b.created_at ? new Date(b.created_at).getTime() : 0;
|
|
22878
|
+
return tB - tA;
|
|
22879
|
+
});
|
|
22880
|
+
const inProgress = [ExecutionStatus.PENDING, ExecutionStatus.WAITING, ExecutionStatus.DELAYED];
|
|
22881
|
+
const terminal = [ExecutionStatus.SUCCEEDED, ExecutionStatus.FAILED];
|
|
22882
|
+
let target = null;
|
|
22883
|
+
for (const ex of sorted) {
|
|
22884
|
+
const t11 = ex.created_at ? new Date(ex.created_at) : null;
|
|
22885
|
+
if (!t11 || t11 < cutoff) continue;
|
|
22886
|
+
const prev = trackedRef.current.get(ex.id);
|
|
22887
|
+
if (!prev) {
|
|
22888
|
+
target = ex;
|
|
22889
|
+
break;
|
|
22890
|
+
}
|
|
22891
|
+
if (inProgress.includes(prev) && terminal.includes(ex.status)) {
|
|
22892
|
+
target = ex;
|
|
22893
|
+
break;
|
|
22894
|
+
}
|
|
22895
|
+
}
|
|
22896
|
+
if (target) {
|
|
22897
|
+
const ex = target;
|
|
22898
|
+
const exTime = ex.created_at ? new Date(ex.created_at) : null;
|
|
22899
|
+
if (!exTime || exTime < enabledAtRef.current) return;
|
|
22900
|
+
const prev = trackedRef.current.get(ex.id);
|
|
22901
|
+
trackedRef.current.set(ex.id, ex.status);
|
|
22902
|
+
setExecutions((list) => {
|
|
22903
|
+
const idx = list.findIndex((e) => e.id === ex.id);
|
|
22904
|
+
if (idx >= 0) {
|
|
22905
|
+
const u = [...list];
|
|
22906
|
+
u[idx] = ex;
|
|
22907
|
+
return u;
|
|
22908
|
+
}
|
|
22909
|
+
return [...list, ex];
|
|
22910
|
+
});
|
|
22911
|
+
if (ex.status === ExecutionStatus.SUCCEEDED && (!prev || inProgress.includes(prev))) {
|
|
22912
|
+
onSuccessRef.current?.({ message: "Withdrawal completed successfully", executionId: ex.id, transaction: ex });
|
|
22913
|
+
} else if (ex.status === ExecutionStatus.FAILED && prev !== ExecutionStatus.FAILED) {
|
|
22914
|
+
onErrorRef.current?.({ message: "Withdrawal failed", code: "WITHDRAW_FAILED", error: ex });
|
|
22915
|
+
}
|
|
22916
|
+
}
|
|
22917
|
+
} catch (error) {
|
|
22918
|
+
console.error("Failed to fetch withdraw executions:", error);
|
|
22919
|
+
onErrorRef.current?.({ message: "Failed to fetch withdrawal status", code: "POLLING_ERROR", error });
|
|
22920
|
+
}
|
|
22921
|
+
};
|
|
22922
|
+
void poll();
|
|
22923
|
+
const interval = setInterval(poll, POLL_INTERVAL_MS2);
|
|
22924
|
+
setIsPolling(true);
|
|
22925
|
+
return () => {
|
|
22926
|
+
clearInterval(interval);
|
|
22927
|
+
setIsPolling(false);
|
|
22928
|
+
};
|
|
22929
|
+
}, [userId, publishableKey, enabled]);
|
|
22930
|
+
(0, import_react27.useEffect)(() => {
|
|
22931
|
+
if (!enabled || !depositWalletId) return;
|
|
22932
|
+
const trigger = async () => {
|
|
22933
|
+
try {
|
|
22934
|
+
await pollDirectExecutions({ deposit_wallet_id: depositWalletId }, publishableKey);
|
|
22935
|
+
} catch {
|
|
22936
|
+
}
|
|
22937
|
+
};
|
|
22938
|
+
trigger();
|
|
22939
|
+
const interval = setInterval(trigger, POLL_ENDPOINT_INTERVAL_MS2);
|
|
22940
|
+
return () => clearInterval(interval);
|
|
22941
|
+
}, [enabled, depositWalletId, publishableKey]);
|
|
22942
|
+
return { executions, isPolling };
|
|
22943
|
+
}
|
|
22944
|
+
var t7 = i18n2.withdrawModal;
|
|
22945
|
+
var getChainKey4 = (chainId, chainType) => `${chainType}:${chainId}`;
|
|
22946
|
+
function WithdrawDoubleInput({
|
|
22947
|
+
tokens,
|
|
22948
|
+
selectedTokenSymbol,
|
|
22949
|
+
selectedChainKey,
|
|
22950
|
+
onTokenChange,
|
|
22951
|
+
onChainChange,
|
|
22952
|
+
isLoading = false
|
|
22953
|
+
}) {
|
|
22954
|
+
const { fonts, components } = useTheme();
|
|
22955
|
+
const isDarkMode = useTheme().themeClass.includes("uf-dark");
|
|
22956
|
+
const selectedToken = selectedTokenSymbol ? tokens.find((t11) => t11.symbol === selectedTokenSymbol) : void 0;
|
|
22957
|
+
const availableChainsForToken = selectedToken?.chains || [];
|
|
22958
|
+
const renderTokenItem = (tokenData) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
22959
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
22960
|
+
"img",
|
|
22961
|
+
{
|
|
22962
|
+
src: tokenData.icon_url,
|
|
22963
|
+
alt: tokenData.symbol,
|
|
22964
|
+
width: 20,
|
|
22965
|
+
height: 20,
|
|
22966
|
+
loading: "lazy",
|
|
22967
|
+
className: "uf-rounded-full uf-flex-shrink-0"
|
|
22968
|
+
}
|
|
22969
|
+
),
|
|
22970
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "uf-text-xs uf-font-normal", children: tokenData.symbol })
|
|
22971
|
+
] });
|
|
22972
|
+
const renderChainItem = (chainData) => /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
22973
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
22974
|
+
"img",
|
|
22975
|
+
{
|
|
22976
|
+
src: chainData.icon_url,
|
|
22977
|
+
alt: chainData.chain_name,
|
|
22978
|
+
width: 20,
|
|
22979
|
+
height: 20,
|
|
22980
|
+
loading: "lazy",
|
|
22981
|
+
className: "uf-rounded-full uf-flex-shrink-0"
|
|
22982
|
+
}
|
|
22983
|
+
),
|
|
22984
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "uf-text-xs uf-font-normal", children: chainData.chain_name })
|
|
22985
|
+
] });
|
|
22986
|
+
const currentChainData = selectedChainKey ? availableChainsForToken.find(
|
|
22987
|
+
(c) => getChainKey4(c.chain_id, c.chain_type) === selectedChainKey
|
|
22988
|
+
) : void 0;
|
|
22989
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { className: "uf-grid uf-grid-cols-2 uf-gap-2.5", children: [
|
|
22990
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { children: [
|
|
22991
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
22992
|
+
"div",
|
|
22993
|
+
{
|
|
22994
|
+
className: "uf-text-xs uf-mb-2 uf-flex uf-items-center uf-gap-1",
|
|
22995
|
+
style: { color: components.card.labelColor },
|
|
22996
|
+
children: t7.receiveToken
|
|
22997
|
+
}
|
|
22998
|
+
),
|
|
22999
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
23000
|
+
Select2,
|
|
23001
|
+
{
|
|
23002
|
+
value: selectedTokenSymbol ?? "",
|
|
23003
|
+
onValueChange: onTokenChange,
|
|
23004
|
+
disabled: isLoading || tokens.length === 0,
|
|
23005
|
+
children: [
|
|
23006
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23007
|
+
SelectTrigger2,
|
|
23008
|
+
{
|
|
23009
|
+
className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50",
|
|
23010
|
+
style: {
|
|
23011
|
+
backgroundColor: components.card.backgroundColor,
|
|
23012
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
23013
|
+
},
|
|
23014
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(SelectValue2, { children: isLoading || !selectedTokenSymbol ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t7.loading }) : selectedToken ? renderTokenItem(selectedToken) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "uf-text-xs uf-font-normal", children: selectedTokenSymbol }) })
|
|
23015
|
+
}
|
|
23016
|
+
),
|
|
23017
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23018
|
+
SelectContent2,
|
|
23019
|
+
{
|
|
23020
|
+
className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px]",
|
|
23021
|
+
style: {
|
|
23022
|
+
border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`,
|
|
23023
|
+
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
23024
|
+
},
|
|
23025
|
+
children: tokens.map((tokenData) => /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23026
|
+
SelectItem2,
|
|
23027
|
+
{
|
|
23028
|
+
value: tokenData.symbol,
|
|
23029
|
+
className: "focus:uf-bg-accent focus:uf-text-foreground",
|
|
23030
|
+
children: renderTokenItem(tokenData)
|
|
23031
|
+
},
|
|
23032
|
+
tokenData.symbol
|
|
23033
|
+
))
|
|
23034
|
+
}
|
|
23035
|
+
)
|
|
23036
|
+
]
|
|
23037
|
+
}
|
|
23038
|
+
)
|
|
23039
|
+
] }),
|
|
23040
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)("div", { children: [
|
|
23041
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23042
|
+
"div",
|
|
23043
|
+
{
|
|
23044
|
+
className: "uf-text-xs uf-mb-2 uf-flex uf-items-center uf-gap-1",
|
|
23045
|
+
style: { color: components.card.labelColor },
|
|
23046
|
+
children: t7.receiveChain
|
|
23047
|
+
}
|
|
23048
|
+
),
|
|
23049
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsxs)(
|
|
23050
|
+
Select2,
|
|
23051
|
+
{
|
|
23052
|
+
value: selectedChainKey ?? "",
|
|
23053
|
+
onValueChange: onChainChange,
|
|
23054
|
+
disabled: isLoading || availableChainsForToken.length === 0,
|
|
23055
|
+
children: [
|
|
23056
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23057
|
+
SelectTrigger2,
|
|
23058
|
+
{
|
|
23059
|
+
className: "uf-h-10 hover:uf-opacity-90 uf-text-foreground disabled:uf-opacity-50",
|
|
23060
|
+
style: {
|
|
23061
|
+
backgroundColor: components.card.backgroundColor,
|
|
23062
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
23063
|
+
},
|
|
23064
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(SelectValue2, { children: isLoading || !selectedChainKey ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "uf-text-xs uf-font-light uf-text-muted-foreground", children: t7.loading }) : currentChainData ? renderChainItem(currentChainData) : /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("span", { className: "uf-text-xs uf-font-normal", children: selectedChainKey }) })
|
|
23065
|
+
}
|
|
23066
|
+
),
|
|
23067
|
+
/* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23068
|
+
SelectContent2,
|
|
23069
|
+
{
|
|
23070
|
+
align: "end",
|
|
23071
|
+
className: "uf-bg-secondary uf-border uf-text-foreground uf-max-h-[300px] uf-min-w-[200px]",
|
|
23072
|
+
style: {
|
|
23073
|
+
border: `1px solid ${isDarkMode ? "rgba(255,255,255,0.15)" : "rgba(0,0,0,0.15)"}`,
|
|
23074
|
+
...fonts.regular ? { "--uf-font-family": fonts.regular } : {}
|
|
23075
|
+
},
|
|
23076
|
+
children: availableChainsForToken.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime69.jsx)("div", { className: "uf-px-2 uf-py-3 uf-text-xs uf-text-muted-foreground uf-text-center", children: "No chains available" }) : availableChainsForToken.map((chainData) => {
|
|
23077
|
+
const chainKey = getChainKey4(chainData.chain_id, chainData.chain_type);
|
|
23078
|
+
return /* @__PURE__ */ (0, import_jsx_runtime69.jsx)(
|
|
23079
|
+
SelectItem2,
|
|
23080
|
+
{
|
|
23081
|
+
value: chainKey,
|
|
23082
|
+
className: "focus:uf-bg-accent focus:uf-text-foreground",
|
|
23083
|
+
children: renderChainItem(chainData)
|
|
23084
|
+
},
|
|
23085
|
+
chainKey
|
|
23086
|
+
);
|
|
23087
|
+
})
|
|
23088
|
+
}
|
|
23089
|
+
)
|
|
23090
|
+
]
|
|
23091
|
+
}
|
|
23092
|
+
)
|
|
23093
|
+
] })
|
|
23094
|
+
] });
|
|
23095
|
+
}
|
|
23096
|
+
function useVerifyRecipientAddress(params) {
|
|
23097
|
+
const {
|
|
23098
|
+
chainType,
|
|
23099
|
+
chainId,
|
|
23100
|
+
tokenAddress,
|
|
23101
|
+
recipientAddress,
|
|
23102
|
+
publishableKey,
|
|
23103
|
+
enabled = true
|
|
23104
|
+
} = params;
|
|
23105
|
+
const trimmedAddress = recipientAddress?.trim() || "";
|
|
23106
|
+
const hasAllParams = !!chainType && !!chainId && !!tokenAddress && trimmedAddress.length > 0;
|
|
23107
|
+
return (0, import_react_query15.useQuery)({
|
|
23108
|
+
queryKey: [
|
|
23109
|
+
"unifold",
|
|
23110
|
+
"verifyRecipientAddress",
|
|
23111
|
+
chainType ?? null,
|
|
23112
|
+
chainId ?? null,
|
|
23113
|
+
tokenAddress ?? null,
|
|
23114
|
+
trimmedAddress,
|
|
23115
|
+
publishableKey
|
|
23116
|
+
],
|
|
23117
|
+
queryFn: () => verifyRecipientAddress(
|
|
23118
|
+
{
|
|
23119
|
+
chain_type: chainType,
|
|
23120
|
+
chain_id: chainId,
|
|
23121
|
+
token_address: tokenAddress,
|
|
23122
|
+
recipient_address: trimmedAddress
|
|
23123
|
+
},
|
|
23124
|
+
publishableKey
|
|
23125
|
+
),
|
|
23126
|
+
enabled: enabled && hasAllParams,
|
|
23127
|
+
staleTime: 1e3 * 60 * 5,
|
|
23128
|
+
gcTime: 1e3 * 60 * 30,
|
|
23129
|
+
retry: 1,
|
|
23130
|
+
refetchOnMount: false,
|
|
23131
|
+
refetchOnWindowFocus: false
|
|
23132
|
+
});
|
|
23133
|
+
}
|
|
23134
|
+
async function sendEvmWithdraw(params) {
|
|
23135
|
+
const {
|
|
23136
|
+
provider,
|
|
23137
|
+
fromAddress,
|
|
23138
|
+
depositWalletAddress,
|
|
23139
|
+
sourceTokenAddress,
|
|
23140
|
+
sourceChainId,
|
|
23141
|
+
amountBaseUnit
|
|
23142
|
+
} = params;
|
|
23143
|
+
const currentChainIdHex = await provider.request({
|
|
23144
|
+
method: "eth_chainId",
|
|
23145
|
+
params: []
|
|
23146
|
+
});
|
|
23147
|
+
const currentChainId = parseInt(currentChainIdHex, 16).toString();
|
|
23148
|
+
if (currentChainId !== sourceChainId) {
|
|
23149
|
+
const requiredHex = "0x" + parseInt(sourceChainId).toString(16);
|
|
23150
|
+
try {
|
|
23151
|
+
await provider.request({
|
|
23152
|
+
method: "wallet_switchEthereumChain",
|
|
23153
|
+
params: [{ chainId: requiredHex }]
|
|
23154
|
+
});
|
|
23155
|
+
const newHex = await provider.request({ method: "eth_chainId", params: [] });
|
|
23156
|
+
if (parseInt(newHex, 16).toString() !== sourceChainId) {
|
|
23157
|
+
throw new Error(`Failed to switch to chain ${sourceChainId}. Please switch manually.`);
|
|
23158
|
+
}
|
|
23159
|
+
} catch (err) {
|
|
23160
|
+
if (err && typeof err === "object" && "code" in err) {
|
|
23161
|
+
const e = err;
|
|
23162
|
+
if (e.code === 4902) throw new Error(`Chain ${sourceChainId} is not configured in your wallet.`);
|
|
23163
|
+
if (e.code === 4001) throw new Error("You must approve the network switch to withdraw.");
|
|
23164
|
+
}
|
|
23165
|
+
throw err;
|
|
23166
|
+
}
|
|
23167
|
+
}
|
|
23168
|
+
const isNative = sourceTokenAddress === "native" || sourceTokenAddress === "0x0000000000000000000000000000000000000000" || sourceTokenAddress === "";
|
|
23169
|
+
const amountBig = BigInt(amountBaseUnit);
|
|
23170
|
+
const txParams = isNative ? { from: fromAddress, to: depositWalletAddress, value: "0x" + amountBig.toString(16) } : {
|
|
23171
|
+
from: fromAddress,
|
|
23172
|
+
to: sourceTokenAddress,
|
|
23173
|
+
data: "0xa9059cbb" + depositWalletAddress.slice(2).padStart(64, "0") + amountBig.toString(16).padStart(64, "0")
|
|
23174
|
+
};
|
|
23175
|
+
let gasEstimate;
|
|
23176
|
+
try {
|
|
23177
|
+
const hex = await provider.request({ method: "eth_estimateGas", params: [txParams] });
|
|
23178
|
+
gasEstimate = BigInt(hex);
|
|
23179
|
+
} catch {
|
|
23180
|
+
gasEstimate = isNative ? BigInt(21e3) : BigInt(65e3);
|
|
23181
|
+
}
|
|
23182
|
+
const gasPrice = BigInt(await provider.request({ method: "eth_gasPrice", params: [] }));
|
|
23183
|
+
const gasWithBuffer = gasEstimate * BigInt(120) / BigInt(100);
|
|
23184
|
+
const gasCost = gasWithBuffer * gasPrice;
|
|
23185
|
+
const ethBalance = BigInt(
|
|
23186
|
+
await provider.request({ method: "eth_getBalance", params: [fromAddress, "latest"] })
|
|
23187
|
+
);
|
|
23188
|
+
const totalRequired = isNative ? gasCost + amountBig : gasCost;
|
|
23189
|
+
if (ethBalance < totalRequired) {
|
|
23190
|
+
const gasFmt = (Number(gasCost) / 1e18).toFixed(6);
|
|
23191
|
+
if (isNative) {
|
|
23192
|
+
throw new Error(`Insufficient balance. Need ${(Number(totalRequired) / 1e18).toFixed(6)} ETH (amount + ~${gasFmt} gas).`);
|
|
23193
|
+
}
|
|
23194
|
+
throw new Error(`Insufficient ETH for gas. Need ~${gasFmt} ETH for fees.`);
|
|
23195
|
+
}
|
|
23196
|
+
const txHash = await provider.request({ method: "eth_sendTransaction", params: [txParams] });
|
|
23197
|
+
return txHash;
|
|
23198
|
+
}
|
|
23199
|
+
async function sendSolanaWithdraw(params) {
|
|
23200
|
+
const {
|
|
23201
|
+
provider,
|
|
23202
|
+
fromAddress,
|
|
23203
|
+
depositWalletAddress,
|
|
23204
|
+
sourceTokenAddress,
|
|
23205
|
+
amountBaseUnit,
|
|
23206
|
+
publishableKey
|
|
23207
|
+
} = params;
|
|
23208
|
+
if (!provider.publicKey) {
|
|
23209
|
+
await provider.connect();
|
|
23210
|
+
}
|
|
23211
|
+
const buildResponse = await buildSolanaTransaction(
|
|
23212
|
+
{
|
|
23213
|
+
chain_id: "mainnet",
|
|
23214
|
+
token_address: sourceTokenAddress === "" ? "native" : sourceTokenAddress,
|
|
23215
|
+
source_address: fromAddress,
|
|
23216
|
+
destination_address: depositWalletAddress,
|
|
23217
|
+
amount: amountBaseUnit
|
|
23218
|
+
},
|
|
23219
|
+
publishableKey
|
|
23220
|
+
);
|
|
23221
|
+
const { VersionedTransaction } = await import(
|
|
23222
|
+
/* @vite-ignore */
|
|
23223
|
+
"@solana/web3.js"
|
|
23224
|
+
);
|
|
23225
|
+
const binaryString = atob(buildResponse.transaction);
|
|
23226
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
23227
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
23228
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
23229
|
+
}
|
|
23230
|
+
const transaction = VersionedTransaction.deserialize(bytes);
|
|
23231
|
+
const signedTransaction = await provider.signTransaction(transaction);
|
|
23232
|
+
const serialized = signedTransaction.serialize();
|
|
23233
|
+
let binaryStr = "";
|
|
23234
|
+
for (let i = 0; i < serialized.length; i++) {
|
|
23235
|
+
binaryStr += String.fromCharCode(serialized[i]);
|
|
23236
|
+
}
|
|
23237
|
+
const sendResponse = await sendSolanaTransaction(
|
|
23238
|
+
{ chain_id: "mainnet", signed_transaction: btoa(binaryStr) },
|
|
23239
|
+
publishableKey
|
|
23240
|
+
);
|
|
23241
|
+
return sendResponse.signature;
|
|
23242
|
+
}
|
|
23243
|
+
async function detectBrowserWallet(chainType, senderAddress) {
|
|
23244
|
+
const win = typeof window !== "undefined" ? window : null;
|
|
23245
|
+
if (!win || !senderAddress) return null;
|
|
23246
|
+
const anyWin = win;
|
|
23247
|
+
if (chainType === "solana") {
|
|
23248
|
+
const solProviders = [];
|
|
23249
|
+
if (win.phantom?.solana) solProviders.push({ provider: win.phantom.solana, name: "Phantom" });
|
|
23250
|
+
if (anyWin.solflare) solProviders.push({ provider: anyWin.solflare, name: "Solflare" });
|
|
23251
|
+
if (anyWin.backpack) solProviders.push({ provider: anyWin.backpack, name: "Backpack" });
|
|
23252
|
+
if (anyWin.trustwallet?.solana) solProviders.push({ provider: anyWin.trustwallet.solana, name: "Trust Wallet" });
|
|
23253
|
+
for (const { provider, name } of solProviders) {
|
|
23254
|
+
if (!provider) continue;
|
|
23255
|
+
try {
|
|
23256
|
+
let addr;
|
|
23257
|
+
if (provider.isConnected && provider.publicKey) {
|
|
23258
|
+
addr = provider.publicKey.toString();
|
|
23259
|
+
} else {
|
|
23260
|
+
const resp = await provider.connect({ onlyIfTrusted: true });
|
|
23261
|
+
if (resp?.publicKey) addr = resp.publicKey.toString();
|
|
23262
|
+
}
|
|
23263
|
+
if (addr && addr === senderAddress) {
|
|
23264
|
+
return { chainFamily: "solana", provider, name, address: addr };
|
|
23265
|
+
}
|
|
23266
|
+
} catch {
|
|
23267
|
+
}
|
|
23268
|
+
}
|
|
23269
|
+
}
|
|
23270
|
+
if (chainType === "ethereum") {
|
|
23271
|
+
const evmProviders = [];
|
|
23272
|
+
const seen = /* @__PURE__ */ new Set();
|
|
23273
|
+
const add = (p, name) => {
|
|
23274
|
+
if (p && typeof p.request === "function" && !seen.has(p)) {
|
|
23275
|
+
seen.add(p);
|
|
23276
|
+
evmProviders.push({ provider: p, name });
|
|
23277
|
+
}
|
|
23278
|
+
};
|
|
23279
|
+
add(anyWin.phantom?.ethereum, "Phantom");
|
|
23280
|
+
add(anyWin.coinbaseWalletExtension, "Coinbase");
|
|
23281
|
+
add(anyWin.trustwallet?.ethereum, "Trust Wallet");
|
|
23282
|
+
add(anyWin.okxwallet, "OKX Wallet");
|
|
23283
|
+
if (anyWin.__eip6963Providers) {
|
|
23284
|
+
for (const detail of anyWin.__eip6963Providers) {
|
|
23285
|
+
const rdns = detail.info?.rdns || "";
|
|
23286
|
+
let name = detail.info?.name || "Wallet";
|
|
23287
|
+
if (rdns.includes("metamask")) name = "MetaMask";
|
|
23288
|
+
else if (rdns.includes("rabby")) name = "Rabby";
|
|
23289
|
+
else if (rdns.includes("rainbow")) name = "Rainbow";
|
|
23290
|
+
add(detail.provider, name);
|
|
23291
|
+
}
|
|
23292
|
+
}
|
|
23293
|
+
if (win.ethereum) {
|
|
23294
|
+
const eth = win.ethereum;
|
|
23295
|
+
let name = "Wallet";
|
|
23296
|
+
if (eth.isMetaMask && !eth.isPhantom && !eth.isRabby) name = "MetaMask";
|
|
23297
|
+
else if (eth.isRabby) name = "Rabby";
|
|
23298
|
+
else if (eth.isRainbow) name = "Rainbow";
|
|
23299
|
+
else if (eth.isCoinbaseWallet) name = "Coinbase";
|
|
23300
|
+
add(eth, name);
|
|
23301
|
+
}
|
|
23302
|
+
for (const { provider, name } of evmProviders) {
|
|
23303
|
+
try {
|
|
23304
|
+
const accounts = await provider.request({ method: "eth_accounts" });
|
|
23305
|
+
if (accounts?.length > 0 && accounts[0].toLowerCase() === senderAddress.toLowerCase()) {
|
|
23306
|
+
return { chainFamily: "evm", provider, name, address: accounts[0] };
|
|
23307
|
+
}
|
|
23308
|
+
} catch {
|
|
23309
|
+
}
|
|
23310
|
+
}
|
|
23311
|
+
}
|
|
23312
|
+
return null;
|
|
23313
|
+
}
|
|
23314
|
+
var t8 = i18n2.withdrawModal;
|
|
23315
|
+
var tCrypto = i18n2.transferCrypto;
|
|
23316
|
+
function formatProcessingTime2(seconds) {
|
|
23317
|
+
if (seconds === null) {
|
|
23318
|
+
return tCrypto.processingTime.lessThanMinutes.replace("{{minutes}}", "1");
|
|
23319
|
+
}
|
|
23320
|
+
const minutes = Math.ceil(seconds / 60);
|
|
23321
|
+
if (minutes < 60) {
|
|
23322
|
+
return tCrypto.processingTime.lessThanMinutes.replace("{{minutes}}", String(minutes));
|
|
23323
|
+
}
|
|
23324
|
+
const hours = Math.ceil(minutes / 60);
|
|
23325
|
+
return tCrypto.processingTime.lessThanHours.replace("{{hours}}", String(hours));
|
|
23326
|
+
}
|
|
23327
|
+
function computeBaseUnit(balanceBaseUnit, inputAmount, balanceAmount) {
|
|
23328
|
+
if (balanceAmount <= 0 || inputAmount <= 0) return "0";
|
|
23329
|
+
if (inputAmount >= balanceAmount) return balanceBaseUnit;
|
|
23330
|
+
const PRECISION = 10n ** 18n;
|
|
23331
|
+
const ratioScaled = BigInt(Math.round(inputAmount / balanceAmount * Number(PRECISION)));
|
|
23332
|
+
const result = BigInt(balanceBaseUnit) * ratioScaled / PRECISION;
|
|
23333
|
+
return result.toString();
|
|
23334
|
+
}
|
|
23335
|
+
function toSafeDecimalString(n, maxDecimals) {
|
|
23336
|
+
if (n === 0) return "0";
|
|
23337
|
+
return n.toFixed(maxDecimals).replace(/\.?0+$/, "");
|
|
23338
|
+
}
|
|
23339
|
+
function WithdrawForm({
|
|
23340
|
+
publishableKey,
|
|
23341
|
+
externalUserId,
|
|
23342
|
+
sourceChainType,
|
|
23343
|
+
selectedToken,
|
|
23344
|
+
selectedChain,
|
|
23345
|
+
sourceTokenSymbol,
|
|
23346
|
+
recipientAddressProp,
|
|
23347
|
+
balanceData,
|
|
23348
|
+
isLoadingBalance,
|
|
23349
|
+
minimumWithdrawAmountUsd,
|
|
23350
|
+
estimatedProcessingTime,
|
|
23351
|
+
maxSlippagePercent,
|
|
23352
|
+
priceImpactPercent,
|
|
23353
|
+
detectedWallet,
|
|
23354
|
+
sourceChainId,
|
|
23355
|
+
sourceTokenAddress,
|
|
23356
|
+
isWalletMatch,
|
|
23357
|
+
connectedWalletName,
|
|
23358
|
+
canWithdraw,
|
|
23359
|
+
onWithdraw,
|
|
23360
|
+
onWithdrawError,
|
|
23361
|
+
onDepositWalletCreation,
|
|
23362
|
+
onWithdrawSubmitted,
|
|
23363
|
+
footerLeft
|
|
23364
|
+
}) {
|
|
23365
|
+
const { colors: colors2, fonts, components } = useTheme();
|
|
23366
|
+
const [recipientAddress, setRecipientAddress] = (0, import_react28.useState)(recipientAddressProp || "");
|
|
23367
|
+
const [amount, setAmount] = (0, import_react28.useState)("");
|
|
23368
|
+
const [inputUnit, setInputUnit] = (0, import_react28.useState)("crypto");
|
|
23369
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react28.useState)(false);
|
|
23370
|
+
const [submitError, setSubmitError] = (0, import_react28.useState)(null);
|
|
23371
|
+
const [detailsExpanded, setDetailsExpanded] = (0, import_react28.useState)(false);
|
|
23372
|
+
const [glossaryOpen, setGlossaryOpen] = (0, import_react28.useState)(false);
|
|
23373
|
+
(0, import_react28.useEffect)(() => {
|
|
23374
|
+
setRecipientAddress(recipientAddressProp || "");
|
|
23375
|
+
setAmount("");
|
|
23376
|
+
setInputUnit("crypto");
|
|
23377
|
+
setSubmitError(null);
|
|
23378
|
+
}, [recipientAddressProp]);
|
|
23379
|
+
const trimmedAddress = recipientAddress.trim();
|
|
23380
|
+
const [debouncedAddress, setDebouncedAddress] = (0, import_react28.useState)(trimmedAddress);
|
|
23381
|
+
(0, import_react28.useEffect)(() => {
|
|
23382
|
+
const id = setTimeout(() => setDebouncedAddress(trimmedAddress), 500);
|
|
23383
|
+
return () => clearTimeout(id);
|
|
23384
|
+
}, [trimmedAddress]);
|
|
23385
|
+
const {
|
|
23386
|
+
data: addressVerification,
|
|
23387
|
+
isLoading: isVerifyingAddress,
|
|
23388
|
+
error: verifyError
|
|
23389
|
+
} = useVerifyRecipientAddress({
|
|
23390
|
+
chainType: selectedChain?.chain_type,
|
|
23391
|
+
chainId: selectedChain?.chain_id,
|
|
23392
|
+
tokenAddress: selectedChain?.token_address,
|
|
23393
|
+
recipientAddress: debouncedAddress,
|
|
23394
|
+
publishableKey,
|
|
23395
|
+
enabled: debouncedAddress.length > 5 && !!selectedChain
|
|
23396
|
+
});
|
|
23397
|
+
const isDebouncing = trimmedAddress !== debouncedAddress;
|
|
23398
|
+
const addressError = (0, import_react28.useMemo)(() => {
|
|
23399
|
+
if (!trimmedAddress || trimmedAddress.length <= 5) return null;
|
|
23400
|
+
if (isDebouncing || isVerifyingAddress) return null;
|
|
23401
|
+
if (verifyError) return t8.invalidAddress;
|
|
23402
|
+
if (addressVerification && !addressVerification.valid) {
|
|
23403
|
+
if (addressVerification.failure_code === "account_not_found")
|
|
23404
|
+
return `Account not found on ${selectedChain?.chain_name}`;
|
|
23405
|
+
if (addressVerification.failure_code === "not_opted_in")
|
|
23406
|
+
return `Recipient has not opted in to ${selectedToken?.symbol} on ${selectedChain?.chain_name}`;
|
|
23407
|
+
return t8.invalidAddress;
|
|
23408
|
+
}
|
|
23409
|
+
return null;
|
|
23410
|
+
}, [trimmedAddress, isDebouncing, isVerifyingAddress, verifyError, addressVerification, selectedChain, selectedToken]);
|
|
23411
|
+
const isAddressValid = !isDebouncing && !!addressVerification?.valid && !addressError;
|
|
23412
|
+
const exchangeRate = (0, import_react28.useMemo)(() => {
|
|
23413
|
+
if (!balanceData?.exchangeRate) return 0;
|
|
23414
|
+
return parseFloat(balanceData.exchangeRate);
|
|
23415
|
+
}, [balanceData]);
|
|
23416
|
+
const balanceCrypto = (0, import_react28.useMemo)(() => {
|
|
23417
|
+
if (!balanceData?.balanceHuman) return 0;
|
|
23418
|
+
return parseFloat(balanceData.balanceHuman);
|
|
23419
|
+
}, [balanceData]);
|
|
23420
|
+
const balanceUsdNum = (0, import_react28.useMemo)(() => {
|
|
23421
|
+
if (!balanceData?.balanceUsd) return 0;
|
|
23422
|
+
return parseFloat(balanceData.balanceUsd);
|
|
23423
|
+
}, [balanceData]);
|
|
23424
|
+
const tokenSymbol = sourceTokenSymbol || balanceData?.symbol || "TOKEN";
|
|
23425
|
+
const sourceDecimals = balanceData?.decimals ?? 6;
|
|
23426
|
+
const cryptoAmountFromInput = (0, import_react28.useMemo)(() => {
|
|
23427
|
+
const val = parseFloat(amount);
|
|
23428
|
+
if (!val || val <= 0) return 0;
|
|
23429
|
+
if (inputUnit === "crypto") return val;
|
|
23430
|
+
return exchangeRate > 0 ? val / exchangeRate : 0;
|
|
23431
|
+
}, [amount, inputUnit, exchangeRate]);
|
|
23432
|
+
const fiatAmountFromInput = (0, import_react28.useMemo)(() => {
|
|
23433
|
+
const val = parseFloat(amount);
|
|
23434
|
+
if (!val || val <= 0) return 0;
|
|
23435
|
+
if (inputUnit === "fiat") return val;
|
|
23436
|
+
return val * exchangeRate;
|
|
23437
|
+
}, [amount, inputUnit, exchangeRate]);
|
|
23438
|
+
const convertedDisplay = (0, import_react28.useMemo)(() => {
|
|
23439
|
+
if (!amount || parseFloat(amount) <= 0) return null;
|
|
23440
|
+
if (inputUnit === "crypto") {
|
|
23441
|
+
return `$${fiatAmountFromInput.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
23442
|
+
}
|
|
23443
|
+
return `${cryptoAmountFromInput.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 6 })} ${tokenSymbol}`;
|
|
23444
|
+
}, [amount, inputUnit, fiatAmountFromInput, cryptoAmountFromInput, tokenSymbol]);
|
|
23445
|
+
const balanceDisplay = (0, import_react28.useMemo)(() => {
|
|
23446
|
+
if (isLoadingBalance || !balanceData) return null;
|
|
23447
|
+
if (inputUnit === "crypto") {
|
|
23448
|
+
return `${balanceCrypto.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })} ${tokenSymbol}`;
|
|
23449
|
+
}
|
|
23450
|
+
return `$${balanceUsdNum.toLocaleString(void 0, { minimumFractionDigits: 2, maximumFractionDigits: 2 })}`;
|
|
23451
|
+
}, [isLoadingBalance, balanceData, inputUnit, balanceCrypto, balanceUsdNum, tokenSymbol]);
|
|
23452
|
+
const handleSwitchUnit = (0, import_react28.useCallback)(() => {
|
|
23453
|
+
const val = parseFloat(amount);
|
|
23454
|
+
if (!val || val <= 0 || exchangeRate <= 0) {
|
|
23455
|
+
setInputUnit((u) => u === "crypto" ? "fiat" : "crypto");
|
|
23456
|
+
setAmount("");
|
|
23457
|
+
return;
|
|
23458
|
+
}
|
|
23459
|
+
if (inputUnit === "crypto") {
|
|
23460
|
+
const fiat = val * exchangeRate;
|
|
23461
|
+
setAmount(fiat.toFixed(2));
|
|
23462
|
+
setInputUnit("fiat");
|
|
23463
|
+
} else {
|
|
23464
|
+
const crypto = val / exchangeRate;
|
|
23465
|
+
setAmount(crypto.toFixed(sourceDecimals > 6 ? 6 : sourceDecimals));
|
|
23466
|
+
setInputUnit("crypto");
|
|
23467
|
+
}
|
|
23468
|
+
}, [amount, inputUnit, exchangeRate, sourceDecimals]);
|
|
23469
|
+
const handleMaxClick = (0, import_react28.useCallback)(() => {
|
|
23470
|
+
if (inputUnit === "crypto") {
|
|
23471
|
+
if (balanceCrypto <= 0) return;
|
|
23472
|
+
setAmount(balanceData?.balanceHuman ?? "0");
|
|
23473
|
+
} else {
|
|
23474
|
+
if (balanceUsdNum <= 0) return;
|
|
23475
|
+
setAmount((Math.floor(balanceUsdNum * 100) / 100).toFixed(2));
|
|
23476
|
+
}
|
|
23477
|
+
}, [inputUnit, balanceCrypto, balanceUsdNum, balanceData]);
|
|
23478
|
+
const isBelowMinimum = minimumWithdrawAmountUsd !== null && fiatAmountFromInput > 0 && fiatAmountFromInput < minimumWithdrawAmountUsd;
|
|
23479
|
+
const isOverBalance = inputUnit === "crypto" ? cryptoAmountFromInput > 0 && balanceCrypto > 0 && cryptoAmountFromInput > balanceCrypto : fiatAmountFromInput > 0 && balanceUsdNum > 0 && fiatAmountFromInput > balanceUsdNum;
|
|
23480
|
+
const isFormValid = trimmedAddress.length > 0 && amount.trim().length > 0 && cryptoAmountFromInput > 0 && isAddressValid && !isBelowMinimum && !isOverBalance && !!balanceData;
|
|
23481
|
+
const handleWithdraw = (0, import_react28.useCallback)(async () => {
|
|
23482
|
+
if (!selectedToken || !selectedChain) return;
|
|
23483
|
+
if (!isFormValid) return;
|
|
23484
|
+
setIsSubmitting(true);
|
|
23485
|
+
setSubmitError(null);
|
|
23486
|
+
try {
|
|
23487
|
+
const depositWallet = await onDepositWalletCreation({
|
|
23488
|
+
destinationChainType: selectedChain.chain_type,
|
|
23489
|
+
destinationChainId: selectedChain.chain_id,
|
|
23490
|
+
destinationTokenAddress: selectedChain.token_address,
|
|
23491
|
+
recipientAddress: trimmedAddress
|
|
23492
|
+
});
|
|
23493
|
+
const amountBaseUnit = computeBaseUnit(
|
|
23494
|
+
balanceData.balanceBaseUnit,
|
|
23495
|
+
parseFloat(amount),
|
|
23496
|
+
inputUnit === "crypto" ? balanceCrypto : balanceUsdNum
|
|
23497
|
+
);
|
|
23498
|
+
const humanAmount = toSafeDecimalString(cryptoAmountFromInput, sourceDecimals);
|
|
23499
|
+
const txInfo = {
|
|
23500
|
+
sourceChainType,
|
|
23501
|
+
sourceChainId,
|
|
23502
|
+
sourceTokenAddress,
|
|
23503
|
+
sourceTokenSymbol: tokenSymbol,
|
|
23504
|
+
destinationChainType: selectedChain.chain_type,
|
|
23505
|
+
destinationChainId: selectedChain.chain_id,
|
|
23506
|
+
destinationTokenAddress: selectedChain.token_address,
|
|
23507
|
+
destinationTokenSymbol: selectedToken.symbol,
|
|
23508
|
+
amount: humanAmount,
|
|
23509
|
+
amountBaseUnit,
|
|
23510
|
+
withdrawIntentAddress: depositWallet.address,
|
|
23511
|
+
recipientAddress: trimmedAddress
|
|
23512
|
+
};
|
|
23513
|
+
if (detectedWallet) {
|
|
23514
|
+
if (detectedWallet.chainFamily === "evm") {
|
|
23515
|
+
await sendEvmWithdraw({
|
|
23516
|
+
provider: detectedWallet.provider,
|
|
23517
|
+
fromAddress: detectedWallet.address,
|
|
23518
|
+
depositWalletAddress: depositWallet.address,
|
|
23519
|
+
sourceTokenAddress,
|
|
23520
|
+
sourceChainId,
|
|
23521
|
+
amountBaseUnit
|
|
23522
|
+
});
|
|
23523
|
+
} else if (detectedWallet.chainFamily === "solana") {
|
|
23524
|
+
await sendSolanaWithdraw({
|
|
23525
|
+
provider: detectedWallet.provider,
|
|
23526
|
+
fromAddress: detectedWallet.address,
|
|
23527
|
+
depositWalletAddress: depositWallet.address,
|
|
23528
|
+
sourceTokenAddress,
|
|
23529
|
+
amountBaseUnit,
|
|
23530
|
+
publishableKey
|
|
23531
|
+
});
|
|
23532
|
+
}
|
|
23533
|
+
} else if (onWithdraw) {
|
|
23534
|
+
await onWithdraw(txInfo);
|
|
23535
|
+
} else {
|
|
23536
|
+
throw new Error("No withdrawal method available. Please connect a wallet.");
|
|
23537
|
+
}
|
|
23538
|
+
onWithdrawSubmitted?.(txInfo);
|
|
23539
|
+
} catch (err) {
|
|
23540
|
+
const raw = err instanceof Error ? err.message : "Withdrawal failed. Please try again.";
|
|
23541
|
+
setSubmitError(raw.length > 120 ? "Withdrawal failed. Please try again." : raw);
|
|
23542
|
+
onWithdrawError?.({
|
|
23543
|
+
message: raw,
|
|
23544
|
+
error: err,
|
|
23545
|
+
code: "WITHDRAW_FAILED"
|
|
23546
|
+
});
|
|
23547
|
+
} finally {
|
|
23548
|
+
setIsSubmitting(false);
|
|
23549
|
+
}
|
|
23550
|
+
}, [selectedToken, selectedChain, isFormValid, cryptoAmountFromInput, sourceDecimals, trimmedAddress, publishableKey, onWithdraw, detectedWallet, sourceTokenAddress, sourceChainId, onWithdrawError, onDepositWalletCreation, onWithdrawSubmitted, amount, inputUnit, balanceCrypto, balanceUsdNum, balanceData]);
|
|
23551
|
+
return /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
23552
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { children: [
|
|
23553
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23554
|
+
"div",
|
|
23555
|
+
{
|
|
23556
|
+
className: "uf-text-xs uf-mb-1.5",
|
|
23557
|
+
style: { color: components.card.labelColor, fontFamily: fonts.medium },
|
|
23558
|
+
children: t8.recipientAddress
|
|
23559
|
+
}
|
|
23560
|
+
),
|
|
23561
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23562
|
+
"style",
|
|
23563
|
+
{
|
|
23564
|
+
dangerouslySetInnerHTML: {
|
|
23565
|
+
__html: `.uf-withdraw-addr::placeholder { color: ${components.search.placeholderColor}; }`
|
|
23566
|
+
}
|
|
23567
|
+
}
|
|
23568
|
+
),
|
|
23569
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
23570
|
+
"div",
|
|
23571
|
+
{
|
|
23572
|
+
className: "uf-flex uf-items-center uf-gap-1 uf-pr-2",
|
|
23573
|
+
style: {
|
|
23574
|
+
backgroundColor: components.search.backgroundColor,
|
|
23575
|
+
borderRadius: components.input.borderRadius,
|
|
23576
|
+
border: `${components.input.borderWidth}px solid ${addressError ? colors2.error : components.input.borderColor}`
|
|
23577
|
+
},
|
|
23578
|
+
children: [
|
|
23579
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23580
|
+
"input",
|
|
23581
|
+
{
|
|
23582
|
+
type: "text",
|
|
23583
|
+
placeholder: t8.recipientAddressPlaceholder,
|
|
23584
|
+
value: recipientAddress,
|
|
23585
|
+
onChange: (e) => {
|
|
23586
|
+
setRecipientAddress(e.target.value);
|
|
23587
|
+
setSubmitError(null);
|
|
23588
|
+
},
|
|
23589
|
+
className: "uf-withdraw-addr uf-flex-1 uf-min-w-0 uf-px-3 uf-py-2.5 uf-text-sm uf-bg-transparent uf-outline-none",
|
|
23590
|
+
style: {
|
|
23591
|
+
color: components.search.inputColor,
|
|
23592
|
+
fontFamily: fonts.regular
|
|
23593
|
+
}
|
|
23594
|
+
}
|
|
23595
|
+
),
|
|
23596
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23597
|
+
"button",
|
|
23598
|
+
{
|
|
23599
|
+
type: "button",
|
|
23600
|
+
onClick: async () => {
|
|
23601
|
+
try {
|
|
23602
|
+
const text = await navigator.clipboard.readText();
|
|
23603
|
+
if (text) {
|
|
23604
|
+
setRecipientAddress(text.trim());
|
|
23605
|
+
setSubmitError(null);
|
|
23606
|
+
}
|
|
23607
|
+
} catch {
|
|
23608
|
+
}
|
|
23609
|
+
},
|
|
23610
|
+
className: "uf-flex-shrink-0 uf-p-1 uf-rounded uf-transition-colors hover:uf-opacity-70",
|
|
23611
|
+
style: { color: colors2.foregroundMuted },
|
|
23612
|
+
title: "Paste from clipboard",
|
|
23613
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ClipboardPaste, { className: "uf-w-4 uf-h-4" })
|
|
23614
|
+
}
|
|
23615
|
+
)
|
|
23616
|
+
]
|
|
23617
|
+
}
|
|
23618
|
+
),
|
|
23619
|
+
(isDebouncing || isVerifyingAddress) && trimmedAddress.length > 5 && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-1.5", children: [
|
|
23620
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(LoaderCircle, { className: "uf-w-3 uf-h-3 uf-animate-spin", style: { color: colors2.foregroundMuted } }),
|
|
23621
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: t8.verifyingAddress })
|
|
23622
|
+
] }),
|
|
23623
|
+
addressError && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1.5 uf-mt-1.5", children: [
|
|
23624
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(TriangleAlert, { className: "uf-w-3 uf-h-3", style: { color: colors2.error } }),
|
|
23625
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "uf-text-xs", style: { color: colors2.error, fontFamily: fonts.regular }, children: addressError })
|
|
23626
|
+
] })
|
|
23627
|
+
] }),
|
|
23628
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { children: [
|
|
23629
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-text-xs uf-mb-1.5", style: { color: components.card.labelColor, fontFamily: fonts.medium }, children: [
|
|
23630
|
+
t8.amount,
|
|
23631
|
+
minimumWithdrawAmountUsd != null && minimumWithdrawAmountUsd > 0 && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { style: { color: colors2.warning, fontFamily: fonts.regular }, children: ` ($${minimumWithdrawAmountUsd.toFixed(2)} min)` })
|
|
23632
|
+
] }),
|
|
23633
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23634
|
+
"style",
|
|
23635
|
+
{
|
|
23636
|
+
dangerouslySetInnerHTML: {
|
|
23637
|
+
__html: `.uf-withdraw-amt::placeholder { color: ${components.search.placeholderColor}; }`
|
|
23638
|
+
}
|
|
23639
|
+
}
|
|
23640
|
+
),
|
|
23641
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
23642
|
+
"div",
|
|
23643
|
+
{
|
|
23644
|
+
className: "uf-flex uf-items-center uf-gap-2 uf-px-3 uf-py-2.5",
|
|
23645
|
+
style: {
|
|
23646
|
+
backgroundColor: components.search.backgroundColor,
|
|
23647
|
+
borderRadius: components.input.borderRadius,
|
|
23648
|
+
border: `${components.input.borderWidth}px solid ${components.input.borderColor}`
|
|
23649
|
+
},
|
|
23650
|
+
children: [
|
|
23651
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23652
|
+
"input",
|
|
23653
|
+
{
|
|
23654
|
+
type: "text",
|
|
23655
|
+
inputMode: "decimal",
|
|
23656
|
+
placeholder: "0.00",
|
|
23657
|
+
value: amount,
|
|
23658
|
+
onChange: (e) => {
|
|
23659
|
+
const val = e.target.value;
|
|
23660
|
+
if (val === "" || /^\d*\.?\d*$/.test(val)) {
|
|
23661
|
+
setAmount(val);
|
|
23662
|
+
setSubmitError(null);
|
|
23663
|
+
}
|
|
23664
|
+
},
|
|
23665
|
+
className: "uf-withdraw-amt uf-flex-1 uf-min-w-0 uf-bg-transparent uf-text-sm uf-outline-none",
|
|
23666
|
+
style: {
|
|
23667
|
+
color: components.search.inputColor,
|
|
23668
|
+
fontFamily: fonts.regular
|
|
23669
|
+
}
|
|
23670
|
+
}
|
|
23671
|
+
),
|
|
23672
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "uf-text-sm uf-shrink-0", style: { color: colors2.foregroundMuted, fontFamily: fonts.medium }, children: inputUnit === "crypto" ? tokenSymbol : "USD" }),
|
|
23673
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23674
|
+
"button",
|
|
23675
|
+
{
|
|
23676
|
+
type: "button",
|
|
23677
|
+
onClick: handleMaxClick,
|
|
23678
|
+
className: "uf-shrink-0 uf-px-2 uf-py-0.5 uf-rounded-md uf-text-xs uf-font-medium uf-transition-colors hover:uf-opacity-80",
|
|
23679
|
+
style: { backgroundColor: colors2.primary + "20", color: colors2.primary, fontFamily: fonts.medium },
|
|
23680
|
+
children: "Max"
|
|
23681
|
+
}
|
|
23682
|
+
)
|
|
23683
|
+
]
|
|
23684
|
+
}
|
|
23685
|
+
),
|
|
23686
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-mt-1.5 uf-px-3", children: [
|
|
23687
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-1", children: [
|
|
23688
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: convertedDisplay || (inputUnit === "crypto" ? "$0.00" : `0.00 ${tokenSymbol}`) }),
|
|
23689
|
+
exchangeRate > 0 && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23690
|
+
"button",
|
|
23691
|
+
{
|
|
23692
|
+
type: "button",
|
|
23693
|
+
onClick: handleSwitchUnit,
|
|
23694
|
+
className: "uf-p-0.5 uf-rounded uf-transition-colors hover:uf-opacity-70",
|
|
23695
|
+
style: { color: colors2.foregroundMuted },
|
|
23696
|
+
title: "Switch unit",
|
|
23697
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ArrowUpDown, { className: "uf-w-3 uf-h-3" })
|
|
23698
|
+
}
|
|
23699
|
+
)
|
|
23700
|
+
] }),
|
|
23701
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { children: [
|
|
23702
|
+
balanceDisplay && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: [
|
|
23703
|
+
t8.balance,
|
|
23704
|
+
": ",
|
|
23705
|
+
balanceDisplay
|
|
23706
|
+
] }),
|
|
23707
|
+
isLoadingBalance && /* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "uf-h-3 uf-w-16 uf-bg-muted uf-rounded uf-animate-pulse" })
|
|
23708
|
+
] })
|
|
23709
|
+
] })
|
|
23710
|
+
] }),
|
|
23711
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-px-2.5", style: { backgroundColor: components.card.backgroundColor, borderRadius: components.card.borderRadius, border: `${components.card.borderWidth}px solid ${components.card.borderColor}` }, children: [
|
|
23712
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
23713
|
+
"button",
|
|
23714
|
+
{
|
|
23715
|
+
type: "button",
|
|
23716
|
+
onClick: () => setDetailsExpanded(!detailsExpanded),
|
|
23717
|
+
className: "uf-w-full uf-flex uf-items-center uf-justify-between uf-py-2.5",
|
|
23718
|
+
children: [
|
|
23719
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
23720
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "uf-rounded-full uf-p-1", style: { backgroundColor: components.card.iconBackgroundColor }, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Clock, { className: "uf-w-3 uf-h-3", style: { color: components.card.iconColor } }) }),
|
|
23721
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "uf-text-xs", style: { color: components.card.labelColor, fontFamily: fonts.regular }, children: [
|
|
23722
|
+
tCrypto.processingTime.label,
|
|
23723
|
+
":",
|
|
23724
|
+
" ",
|
|
23725
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: formatProcessingTime2(estimatedProcessingTime) })
|
|
23726
|
+
] })
|
|
23727
|
+
] }),
|
|
23728
|
+
detailsExpanded ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChevronUp, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } }) : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ChevronDown, { className: "uf-w-4 uf-h-4", style: { color: components.card.actionColor } })
|
|
23729
|
+
]
|
|
23730
|
+
}
|
|
23731
|
+
),
|
|
23732
|
+
detailsExpanded && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-pb-3 uf-space-y-2.5", children: [
|
|
23733
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
23734
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "uf-rounded-full uf-p-1", style: { backgroundColor: components.card.iconBackgroundColor }, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(ShieldCheck, { className: "uf-w-3 uf-h-3", style: { color: components.card.iconColor } }) }),
|
|
23735
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "uf-text-xs", style: { color: components.card.labelColor, fontFamily: fonts.regular }, children: [
|
|
23736
|
+
tCrypto.slippage.label,
|
|
23737
|
+
":",
|
|
23738
|
+
" ",
|
|
23739
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: [
|
|
23740
|
+
tCrypto.slippage.auto,
|
|
23741
|
+
" \u2022 ",
|
|
23742
|
+
(maxSlippagePercent ?? 0.25).toFixed(2),
|
|
23743
|
+
"%"
|
|
23744
|
+
] })
|
|
23745
|
+
] })
|
|
23746
|
+
] }),
|
|
23747
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-gap-2", children: [
|
|
23748
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "uf-rounded-full uf-p-1", style: { backgroundColor: components.card.iconBackgroundColor }, children: /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DollarSign, { className: "uf-w-3 uf-h-3", style: { color: components.card.iconColor } }) }),
|
|
23749
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "uf-text-xs", style: { color: components.card.labelColor, fontFamily: fonts.regular }, children: [
|
|
23750
|
+
tCrypto.priceImpact.label,
|
|
23751
|
+
":",
|
|
23752
|
+
" ",
|
|
23753
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { style: { color: components.card.titleColor, fontFamily: fonts.medium }, children: [
|
|
23754
|
+
(priceImpactPercent ?? 0).toFixed(2),
|
|
23755
|
+
"%"
|
|
23756
|
+
] })
|
|
23757
|
+
] })
|
|
23758
|
+
] })
|
|
23759
|
+
] })
|
|
23760
|
+
] }),
|
|
23761
|
+
!canWithdraw && !submitError && /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(
|
|
23762
|
+
"div",
|
|
23763
|
+
{
|
|
23764
|
+
className: "uf-flex uf-items-start uf-gap-2.5 uf-p-3 uf-rounded-xl",
|
|
23765
|
+
style: { backgroundColor: colors2.card, border: `1px solid ${colors2.border}` },
|
|
23766
|
+
children: [
|
|
23767
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Wallet, { className: "uf-w-4 uf-h-4 uf-flex-shrink-0 uf-mt-0.5", style: { color: colors2.warning } }),
|
|
23768
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { className: "uf-text-xs", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "No connected wallet detected. Please connect a wallet that matches your account to withdraw." })
|
|
23769
|
+
]
|
|
23770
|
+
}
|
|
23771
|
+
),
|
|
23772
|
+
isWalletMatch && connectedWalletName ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23773
|
+
"button",
|
|
23774
|
+
{
|
|
23775
|
+
type: "button",
|
|
23776
|
+
onClick: handleWithdraw,
|
|
23777
|
+
disabled: !isFormValid || !canWithdraw || isSubmitting || !selectedToken || !selectedChain,
|
|
23778
|
+
className: "uf-w-full uf-py-3 uf-text-sm uf-font-medium uf-transition-colors disabled:uf-opacity-50 disabled:uf-cursor-not-allowed uf-flex uf-items-center uf-justify-center uf-gap-2",
|
|
23779
|
+
style: {
|
|
23780
|
+
backgroundColor: colors2.primary,
|
|
23781
|
+
color: colors2.primaryForeground,
|
|
23782
|
+
fontFamily: fonts.medium,
|
|
23783
|
+
borderRadius: components.button.borderRadius,
|
|
23784
|
+
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
23785
|
+
},
|
|
23786
|
+
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
23787
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }),
|
|
23788
|
+
"Processing..."
|
|
23789
|
+
] }) : isOverBalance ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_jsx_runtime70.Fragment, { children: "Insufficient balance" }) : isBelowMinimum ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_jsx_runtime70.Fragment, { children: "Minimum amount not met" }) : submitError ? /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(import_jsx_runtime70.Fragment, { children: "Withdrawal failed. Try again" }) : /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)(import_jsx_runtime70.Fragment, { children: [
|
|
23790
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(Wallet, { className: "uf-w-4 uf-h-4" }),
|
|
23791
|
+
"Withdraw from ",
|
|
23792
|
+
connectedWalletName
|
|
23793
|
+
] })
|
|
23794
|
+
}
|
|
23795
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23796
|
+
"button",
|
|
23797
|
+
{
|
|
23798
|
+
type: "button",
|
|
23799
|
+
onClick: handleWithdraw,
|
|
23800
|
+
disabled: !isFormValid || !canWithdraw || isSubmitting || !selectedToken || !selectedChain,
|
|
23801
|
+
className: "uf-w-full uf-py-3 uf-text-sm uf-font-medium uf-transition-colors disabled:uf-opacity-50 disabled:uf-cursor-not-allowed",
|
|
23802
|
+
style: {
|
|
23803
|
+
backgroundColor: colors2.primary,
|
|
23804
|
+
color: colors2.primaryForeground,
|
|
23805
|
+
fontFamily: fonts.medium,
|
|
23806
|
+
borderRadius: components.button.borderRadius,
|
|
23807
|
+
border: `${components.button.borderWidth}px solid ${components.button.borderColor}`
|
|
23808
|
+
},
|
|
23809
|
+
children: isSubmitting ? /* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("span", { className: "uf-flex uf-items-center uf-justify-center uf-gap-2", children: [
|
|
23810
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(LoaderCircle, { className: "uf-w-4 uf-h-4 uf-animate-spin" }),
|
|
23811
|
+
"Processing..."
|
|
23812
|
+
] }) : isOverBalance ? "Insufficient balance" : isBelowMinimum ? "Minimum amount not met" : submitError ? "Withdrawal failed. Try again" : t8.withdraw
|
|
23813
|
+
}
|
|
23814
|
+
),
|
|
23815
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsxs)("div", { className: "uf-flex uf-items-center uf-justify-between uf-text-xs uf-pt-1", children: [
|
|
23816
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)("div", { children: footerLeft }),
|
|
23817
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(DepositFooterLinks, { onGlossaryClick: () => setGlossaryOpen(true) })
|
|
23818
|
+
] }),
|
|
23819
|
+
/* @__PURE__ */ (0, import_jsx_runtime70.jsx)(
|
|
23820
|
+
GlossaryModal,
|
|
23821
|
+
{
|
|
23822
|
+
open: glossaryOpen,
|
|
23823
|
+
onOpenChange: setGlossaryOpen
|
|
23824
|
+
}
|
|
23825
|
+
)
|
|
23826
|
+
] });
|
|
23827
|
+
}
|
|
23828
|
+
function WithdrawExecutionItem({
|
|
23829
|
+
execution,
|
|
23830
|
+
onClick
|
|
23831
|
+
}) {
|
|
23832
|
+
const { colors: colors2, fonts, components } = useTheme();
|
|
23833
|
+
const isPending = execution.status === ExecutionStatus.PENDING || execution.status === ExecutionStatus.WAITING || execution.status === ExecutionStatus.DELAYED;
|
|
23834
|
+
const formatDateTime = (timestamp) => {
|
|
23835
|
+
try {
|
|
23836
|
+
const date = new Date(timestamp);
|
|
23837
|
+
const monthDay = date.toLocaleDateString("en-US", {
|
|
23838
|
+
month: "short",
|
|
23839
|
+
day: "numeric",
|
|
23840
|
+
year: "numeric"
|
|
23841
|
+
});
|
|
23842
|
+
const time = date.toLocaleTimeString("en-US", {
|
|
23843
|
+
hour: "numeric",
|
|
23844
|
+
minute: "2-digit",
|
|
23845
|
+
hour12: true
|
|
23846
|
+
}).toLowerCase();
|
|
23847
|
+
return `${monthDay} at ${time}`;
|
|
23848
|
+
} catch {
|
|
23849
|
+
return timestamp;
|
|
23850
|
+
}
|
|
23851
|
+
};
|
|
23852
|
+
const formatUsdAmount2 = (sourceAmountUsd) => {
|
|
23853
|
+
try {
|
|
23854
|
+
const amount = Number(sourceAmountUsd);
|
|
23855
|
+
return new Intl.NumberFormat("en-US", {
|
|
23856
|
+
style: "currency",
|
|
23857
|
+
currency: "USD",
|
|
23858
|
+
minimumFractionDigits: 2,
|
|
23859
|
+
maximumFractionDigits: 2
|
|
23860
|
+
}).format(amount);
|
|
23861
|
+
} catch {
|
|
23862
|
+
return "$0.00";
|
|
23863
|
+
}
|
|
23864
|
+
};
|
|
23865
|
+
return /* @__PURE__ */ (0, import_jsx_runtime71.jsxs)(
|
|
23866
|
+
"button",
|
|
23867
|
+
{
|
|
23868
|
+
onClick,
|
|
23869
|
+
className: "uf-w-full uf-p-3 uf-flex uf-items-center uf-gap-3 hover:uf-bg-secondary/80 uf-transition-colors uf-text-left",
|
|
23870
|
+
style: {
|
|
23871
|
+
backgroundColor: components.card.backgroundColor,
|
|
23872
|
+
borderRadius: components.list.rowBorderRadius,
|
|
23873
|
+
border: `${components.card.borderWidth}px solid ${components.card.borderColor}`
|
|
23874
|
+
},
|
|
23875
|
+
children: [
|
|
23876
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-relative uf-flex-shrink-0 uf-w-9 uf-h-9", children: [
|
|
23877
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23878
|
+
"img",
|
|
23879
|
+
{
|
|
23880
|
+
src: execution.destination_token_metadata?.icon_url || getIconUrl("/icons/tokens/svg/usdc.svg"),
|
|
23881
|
+
alt: "Token",
|
|
23882
|
+
width: 36,
|
|
23883
|
+
height: 36,
|
|
23884
|
+
loading: "lazy",
|
|
23885
|
+
className: "uf-rounded-full uf-w-9 uf-h-9"
|
|
23886
|
+
}
|
|
23887
|
+
),
|
|
23888
|
+
isPending ? /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23889
|
+
"div",
|
|
23890
|
+
{
|
|
23891
|
+
className: "uf-absolute -uf-bottom-0.5 -uf-right-0.5 uf-rounded-full uf-p-0.5",
|
|
23892
|
+
style: { backgroundColor: colors2.warning },
|
|
23893
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23894
|
+
"svg",
|
|
23895
|
+
{
|
|
23896
|
+
width: "10",
|
|
23897
|
+
height: "10",
|
|
23898
|
+
viewBox: "0 0 12 12",
|
|
23899
|
+
fill: "none",
|
|
23900
|
+
className: "uf-animate-spin uf-block",
|
|
23901
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23902
|
+
"path",
|
|
23903
|
+
{
|
|
23904
|
+
d: "M6 1V3M6 9V11M1 6H3M9 6H11M2.5 2.5L4 4M8 8L9.5 9.5M2.5 9.5L4 8M8 4L9.5 2.5",
|
|
23905
|
+
stroke: "white",
|
|
23906
|
+
strokeWidth: "2",
|
|
23907
|
+
strokeLinecap: "round"
|
|
23908
|
+
}
|
|
23909
|
+
)
|
|
23910
|
+
}
|
|
23911
|
+
)
|
|
23912
|
+
}
|
|
23913
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23914
|
+
"div",
|
|
23915
|
+
{
|
|
23916
|
+
className: "uf-absolute -uf-bottom-0.5 -uf-right-0.5 uf-rounded-full uf-p-0.5",
|
|
23917
|
+
style: { backgroundColor: colors2.success },
|
|
23918
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23919
|
+
"svg",
|
|
23920
|
+
{
|
|
23921
|
+
width: "10",
|
|
23922
|
+
height: "10",
|
|
23923
|
+
viewBox: "0 0 12 12",
|
|
23924
|
+
fill: "none",
|
|
23925
|
+
className: "uf-block",
|
|
23926
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23927
|
+
"path",
|
|
23928
|
+
{
|
|
23929
|
+
d: "M10 3L4.5 8.5L2 6",
|
|
23930
|
+
stroke: "white",
|
|
23931
|
+
strokeWidth: "2",
|
|
23932
|
+
strokeLinecap: "round",
|
|
23933
|
+
strokeLinejoin: "round"
|
|
23934
|
+
}
|
|
23935
|
+
)
|
|
23936
|
+
}
|
|
23937
|
+
)
|
|
23938
|
+
}
|
|
23939
|
+
)
|
|
23940
|
+
] }),
|
|
23941
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsxs)("div", { className: "uf-flex-1 uf-min-w-0", children: [
|
|
23942
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23943
|
+
"h3",
|
|
23944
|
+
{
|
|
23945
|
+
className: "uf-font-medium uf-text-sm uf-leading-tight",
|
|
23946
|
+
style: {
|
|
23947
|
+
color: components.card.titleColor,
|
|
23948
|
+
fontFamily: fonts.medium
|
|
23949
|
+
},
|
|
23950
|
+
children: isPending ? "Withdrawal processing" : "Withdrawal completed"
|
|
23951
|
+
}
|
|
23952
|
+
),
|
|
23953
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23954
|
+
"p",
|
|
23955
|
+
{
|
|
23956
|
+
className: "uf-text-xs uf-leading-tight",
|
|
23957
|
+
style: {
|
|
23958
|
+
color: components.card.subtitleColor,
|
|
23959
|
+
fontFamily: fonts.regular
|
|
23960
|
+
},
|
|
23961
|
+
children: formatDateTime(execution.created_at || (/* @__PURE__ */ new Date()).toISOString())
|
|
23962
|
+
}
|
|
23963
|
+
)
|
|
23964
|
+
] }),
|
|
23965
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23966
|
+
"span",
|
|
23967
|
+
{
|
|
23968
|
+
className: "uf-font-medium uf-text-sm uf-flex-shrink-0",
|
|
23969
|
+
style: {
|
|
23970
|
+
color: components.card.textRightColor,
|
|
23971
|
+
fontFamily: fonts.medium
|
|
23972
|
+
},
|
|
23973
|
+
children: formatUsdAmount2(execution.source_amount_usd || "0")
|
|
23974
|
+
}
|
|
23975
|
+
),
|
|
23976
|
+
/* @__PURE__ */ (0, import_jsx_runtime71.jsx)(
|
|
23977
|
+
ChevronRight,
|
|
23978
|
+
{
|
|
23979
|
+
className: "uf-w-4 uf-h-4 uf-flex-shrink-0",
|
|
23980
|
+
style: { color: components.card.actionColor }
|
|
23981
|
+
}
|
|
23982
|
+
)
|
|
23983
|
+
]
|
|
23984
|
+
}
|
|
23985
|
+
);
|
|
23986
|
+
}
|
|
23987
|
+
function truncateAddress4(addr) {
|
|
23988
|
+
if (addr.length <= 12) return addr;
|
|
23989
|
+
return `${addr.slice(0, 6)}...${addr.slice(-4)}`;
|
|
23990
|
+
}
|
|
23991
|
+
var SHOW_BUTTON_DELAY_MS = 5e3;
|
|
23992
|
+
function WithdrawConfirmingView({
|
|
23993
|
+
txInfo,
|
|
23994
|
+
executions,
|
|
23995
|
+
onClose,
|
|
23996
|
+
onViewTracker
|
|
23997
|
+
}) {
|
|
23998
|
+
const { colors: colors2, fonts, components } = useTheme();
|
|
23999
|
+
const [showButton, setShowButton] = (0, import_react29.useState)(false);
|
|
24000
|
+
const latestExecution = executions.length > 0 ? executions[executions.length - 1] : null;
|
|
24001
|
+
(0, import_react29.useEffect)(() => {
|
|
24002
|
+
if (latestExecution) return;
|
|
24003
|
+
const timer = setTimeout(() => setShowButton(true), SHOW_BUTTON_DELAY_MS);
|
|
24004
|
+
return () => clearTimeout(timer);
|
|
24005
|
+
}, [latestExecution]);
|
|
24006
|
+
const btnRadius = components.button.borderRadius;
|
|
24007
|
+
const btnBorder = `${components.button.borderWidth}px solid ${components.button.borderColor}`;
|
|
24008
|
+
if (latestExecution) {
|
|
24009
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
24010
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DepositHeader, { title: "Withdrawal Details", showClose: true, onClose }),
|
|
24011
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DepositDetailContent, { execution: latestExecution, variant: "withdraw" }),
|
|
24012
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-gap-2 uf-px-2 uf-pt-2", children: [
|
|
24013
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24014
|
+
"button",
|
|
24015
|
+
{
|
|
24016
|
+
type: "button",
|
|
24017
|
+
onClick: onViewTracker,
|
|
24018
|
+
className: "uf-flex-1 uf-py-2.5 uf-text-sm uf-transition-colors hover:uf-opacity-90",
|
|
24019
|
+
style: {
|
|
24020
|
+
backgroundColor: components.button.secondaryBackground,
|
|
24021
|
+
color: components.button.secondaryText,
|
|
24022
|
+
fontFamily: fonts.medium,
|
|
24023
|
+
borderRadius: btnRadius,
|
|
24024
|
+
border: btnBorder
|
|
24025
|
+
},
|
|
24026
|
+
children: "Withdrawal History"
|
|
24027
|
+
}
|
|
24028
|
+
),
|
|
24029
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24030
|
+
"button",
|
|
24031
|
+
{
|
|
24032
|
+
type: "button",
|
|
24033
|
+
onClick: onClose,
|
|
24034
|
+
className: "uf-flex-1 uf-py-2.5 uf-text-sm uf-transition-colors hover:uf-opacity-90",
|
|
24035
|
+
style: {
|
|
24036
|
+
backgroundColor: components.button.primaryBackground,
|
|
24037
|
+
color: components.button.primaryText,
|
|
24038
|
+
fontFamily: fonts.medium,
|
|
24039
|
+
borderRadius: btnRadius,
|
|
24040
|
+
border: btnBorder
|
|
24041
|
+
},
|
|
24042
|
+
children: "Close"
|
|
24043
|
+
}
|
|
24044
|
+
)
|
|
24045
|
+
] }),
|
|
24046
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24047
|
+
PoweredByUnifold,
|
|
24048
|
+
{
|
|
24049
|
+
color: colors2.foregroundMuted,
|
|
24050
|
+
className: "uf-flex uf-justify-center uf-shrink-0"
|
|
24051
|
+
}
|
|
24052
|
+
) })
|
|
24053
|
+
] });
|
|
24054
|
+
}
|
|
24055
|
+
return /* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(import_jsx_runtime72.Fragment, { children: [
|
|
24056
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(DepositHeader, { title: "Withdrawal Status", showClose: true, onClose }),
|
|
24057
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-16 uf-px-4", children: [
|
|
24058
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24059
|
+
"div",
|
|
24060
|
+
{
|
|
24061
|
+
className: "uf-w-20 uf-h-20 uf-rounded-full uf-flex uf-items-center uf-justify-center uf-mb-6",
|
|
24062
|
+
style: { backgroundColor: `${colors2.primary}20` },
|
|
24063
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24064
|
+
"svg",
|
|
24065
|
+
{
|
|
24066
|
+
width: "40",
|
|
24067
|
+
height: "40",
|
|
24068
|
+
viewBox: "0 0 24 24",
|
|
24069
|
+
fill: "none",
|
|
24070
|
+
className: "uf-animate-spin",
|
|
24071
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24072
|
+
"path",
|
|
24073
|
+
{
|
|
24074
|
+
d: "M21 12a9 9 0 1 1-6.22-8.56",
|
|
24075
|
+
stroke: colors2.primary,
|
|
24076
|
+
strokeWidth: "2.5",
|
|
24077
|
+
strokeLinecap: "round"
|
|
24078
|
+
}
|
|
24079
|
+
)
|
|
24080
|
+
}
|
|
24081
|
+
)
|
|
24082
|
+
}
|
|
24083
|
+
),
|
|
24084
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24085
|
+
"h3",
|
|
24086
|
+
{
|
|
24087
|
+
className: "uf-text-xl uf-mb-2",
|
|
24088
|
+
style: { color: colors2.foreground, fontFamily: fonts.medium },
|
|
24089
|
+
children: "Checking Withdrawal"
|
|
24090
|
+
}
|
|
24091
|
+
),
|
|
24092
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsxs)(
|
|
24093
|
+
"p",
|
|
24094
|
+
{
|
|
24095
|
+
className: "uf-text-sm uf-text-center",
|
|
24096
|
+
style: { color: colors2.foregroundMuted, fontFamily: fonts.regular },
|
|
24097
|
+
children: [
|
|
24098
|
+
txInfo.amount,
|
|
24099
|
+
" ",
|
|
24100
|
+
txInfo.sourceTokenSymbol,
|
|
24101
|
+
" to",
|
|
24102
|
+
" ",
|
|
24103
|
+
truncateAddress4(txInfo.recipientAddress)
|
|
24104
|
+
]
|
|
24105
|
+
}
|
|
24106
|
+
)
|
|
24107
|
+
] }),
|
|
24108
|
+
showButton && /* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "uf-px-1 uf-pb-1", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24109
|
+
"button",
|
|
24110
|
+
{
|
|
24111
|
+
type: "button",
|
|
24112
|
+
onClick: onViewTracker,
|
|
24113
|
+
className: "uf-w-full uf-py-2.5 uf-text-sm uf-transition-colors hover:uf-opacity-90",
|
|
24114
|
+
style: {
|
|
24115
|
+
backgroundColor: components.button.secondaryBackground,
|
|
24116
|
+
color: components.button.secondaryText,
|
|
24117
|
+
fontFamily: fonts.medium,
|
|
24118
|
+
borderRadius: btnRadius,
|
|
24119
|
+
border: btnBorder
|
|
24120
|
+
},
|
|
24121
|
+
children: "Withdrawal History"
|
|
24122
|
+
}
|
|
24123
|
+
) }),
|
|
24124
|
+
/* @__PURE__ */ (0, import_jsx_runtime72.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime72.jsx)(
|
|
24125
|
+
PoweredByUnifold,
|
|
24126
|
+
{
|
|
24127
|
+
color: colors2.foregroundMuted,
|
|
24128
|
+
className: "uf-flex uf-justify-center uf-shrink-0"
|
|
24129
|
+
}
|
|
24130
|
+
) })
|
|
24131
|
+
] });
|
|
24132
|
+
}
|
|
24133
|
+
var t9 = i18n2.withdrawModal;
|
|
24134
|
+
var getChainKey5 = (chainId, chainType) => `${chainType}:${chainId}`;
|
|
24135
|
+
function WithdrawModal({
|
|
24136
|
+
open,
|
|
24137
|
+
onOpenChange,
|
|
24138
|
+
publishableKey,
|
|
24139
|
+
modalTitle,
|
|
24140
|
+
externalUserId,
|
|
24141
|
+
sourceChainType,
|
|
24142
|
+
sourceChainId,
|
|
24143
|
+
sourceTokenAddress,
|
|
24144
|
+
sourceTokenSymbol,
|
|
24145
|
+
recipientAddress: recipientAddressProp,
|
|
24146
|
+
senderAddress,
|
|
24147
|
+
onWithdraw,
|
|
24148
|
+
onWithdrawSuccess,
|
|
24149
|
+
onWithdrawError,
|
|
24150
|
+
theme = "dark",
|
|
24151
|
+
hideOverlay = false
|
|
24152
|
+
}) {
|
|
24153
|
+
const { colors: colors2, fonts, components } = useTheme();
|
|
24154
|
+
const [containerEl, setContainerEl] = (0, import_react26.useState)(null);
|
|
24155
|
+
const containerCallbackRef = (0, import_react26.useCallback)((el) => {
|
|
24156
|
+
setContainerEl(el);
|
|
24157
|
+
}, []);
|
|
24158
|
+
const [resolvedTheme, setResolvedTheme] = (0, import_react26.useState)(
|
|
24159
|
+
theme === "auto" ? "dark" : theme
|
|
24160
|
+
);
|
|
24161
|
+
(0, import_react26.useEffect)(() => {
|
|
24162
|
+
if (theme === "auto") {
|
|
24163
|
+
const mq = window.matchMedia("(prefers-color-scheme: dark)");
|
|
24164
|
+
setResolvedTheme(mq.matches ? "dark" : "light");
|
|
24165
|
+
const h = (e) => setResolvedTheme(e.matches ? "dark" : "light");
|
|
24166
|
+
mq.addEventListener("change", h);
|
|
24167
|
+
return () => mq.removeEventListener("change", h);
|
|
24168
|
+
}
|
|
24169
|
+
setResolvedTheme(theme);
|
|
24170
|
+
}, [theme]);
|
|
24171
|
+
const themeClass = resolvedTheme === "dark" ? "uf-dark" : "";
|
|
24172
|
+
const { data: tokensResponse, isLoading: tokensLoading } = useSupportedDestinationTokens(publishableKey, open);
|
|
24173
|
+
const destinationTokens = tokensResponse?.data ?? [];
|
|
24174
|
+
const { data: sourceValidation, isLoading: isCheckingSourceToken } = useSourceTokenValidation({
|
|
24175
|
+
sourceChainType,
|
|
24176
|
+
sourceChainId,
|
|
24177
|
+
sourceTokenAddress,
|
|
24178
|
+
sourceTokenSymbol,
|
|
24179
|
+
publishableKey,
|
|
24180
|
+
enabled: open
|
|
24181
|
+
});
|
|
24182
|
+
const { data: balanceData, isLoading: isLoadingBalance } = useAddressBalance({
|
|
24183
|
+
address: senderAddress,
|
|
24184
|
+
chainType: sourceChainType,
|
|
24185
|
+
chainId: sourceChainId,
|
|
24186
|
+
tokenAddress: sourceTokenAddress,
|
|
24187
|
+
publishableKey,
|
|
24188
|
+
enabled: open
|
|
24189
|
+
});
|
|
24190
|
+
const [selectedToken, setSelectedToken] = (0, import_react26.useState)(null);
|
|
24191
|
+
const [selectedChain, setSelectedChain] = (0, import_react26.useState)(null);
|
|
24192
|
+
const [detectedWallet, setDetectedWallet] = (0, import_react26.useState)(null);
|
|
24193
|
+
const connectedWalletName = detectedWallet?.name ?? null;
|
|
24194
|
+
const isWalletMatch = !!detectedWallet;
|
|
24195
|
+
(0, import_react26.useEffect)(() => {
|
|
24196
|
+
if (!senderAddress || !open) {
|
|
24197
|
+
setDetectedWallet(null);
|
|
24198
|
+
return;
|
|
24199
|
+
}
|
|
24200
|
+
let cancelled = false;
|
|
24201
|
+
detectBrowserWallet(sourceChainType, senderAddress).then((wallet) => {
|
|
24202
|
+
if (!cancelled) setDetectedWallet(wallet);
|
|
24203
|
+
});
|
|
24204
|
+
return () => {
|
|
24205
|
+
cancelled = true;
|
|
24206
|
+
};
|
|
24207
|
+
}, [senderAddress, sourceChainType, open]);
|
|
24208
|
+
const [view, setView] = (0, import_react26.useState)("form");
|
|
24209
|
+
const [withdrawDepositWalletId, setWithdrawDepositWalletId] = (0, import_react26.useState)();
|
|
24210
|
+
const [selectedExecution, setSelectedExecution] = (0, import_react26.useState)(null);
|
|
24211
|
+
const [submittedTxInfo, setSubmittedTxInfo] = (0, import_react26.useState)(null);
|
|
24212
|
+
const { executions: realtimeExecutions } = useWithdrawPolling({
|
|
24213
|
+
userId: externalUserId,
|
|
24214
|
+
publishableKey,
|
|
24215
|
+
depositWalletId: withdrawDepositWalletId,
|
|
24216
|
+
enabled: !!withdrawDepositWalletId && open,
|
|
24217
|
+
onWithdrawSuccess: onWithdrawSuccess ? (d) => onWithdrawSuccess({ message: d.message, transaction: d.transaction }) : void 0,
|
|
24218
|
+
onWithdrawError
|
|
24219
|
+
});
|
|
24220
|
+
const { data: allWithdrawalsData } = useExecutions(externalUserId, publishableKey, {
|
|
24221
|
+
actionType: ActionType.Withdraw,
|
|
24222
|
+
enabled: open,
|
|
24223
|
+
refetchInterval: view === "tracker" || view === "detail" ? 5e3 : 15e3
|
|
24224
|
+
});
|
|
24225
|
+
const allWithdrawals = allWithdrawalsData?.data ?? [];
|
|
24226
|
+
const handleDepositWalletCreation = (0, import_react26.useCallback)(async (params) => {
|
|
24227
|
+
const { data: wallets } = await createDepositAddress(
|
|
24228
|
+
{
|
|
24229
|
+
external_user_id: externalUserId,
|
|
24230
|
+
destination_chain_type: params.destinationChainType,
|
|
24231
|
+
destination_chain_id: params.destinationChainId,
|
|
24232
|
+
destination_token_address: params.destinationTokenAddress,
|
|
24233
|
+
recipient_address: params.recipientAddress,
|
|
24234
|
+
action_type: ActionType.Withdraw
|
|
24235
|
+
},
|
|
24236
|
+
publishableKey
|
|
24237
|
+
);
|
|
24238
|
+
const depositWallet = getWalletByChainType(wallets, sourceChainType);
|
|
24239
|
+
if (!depositWallet) {
|
|
24240
|
+
throw new Error(`No deposit wallet available for ${sourceChainType}`);
|
|
24241
|
+
}
|
|
24242
|
+
setWithdrawDepositWalletId(depositWallet.id);
|
|
24243
|
+
return depositWallet;
|
|
24244
|
+
}, [externalUserId, publishableKey, sourceChainType]);
|
|
24245
|
+
const handleWithdrawSubmitted = (0, import_react26.useCallback)((txInfo) => {
|
|
24246
|
+
setSubmittedTxInfo(txInfo);
|
|
24247
|
+
setView("confirming");
|
|
24248
|
+
}, []);
|
|
24249
|
+
(0, import_react26.useEffect)(() => {
|
|
24250
|
+
if (!destinationTokens.length || selectedToken) return;
|
|
24251
|
+
const first = destinationTokens[0];
|
|
24252
|
+
if (first?.chains.length > 0) {
|
|
24253
|
+
setSelectedToken(first);
|
|
24254
|
+
setSelectedChain(first.chains[0]);
|
|
24255
|
+
}
|
|
24256
|
+
}, [destinationTokens, selectedToken]);
|
|
24257
|
+
const resetViewTimeoutRef = (0, import_react26.useRef)(null);
|
|
24258
|
+
const handleClose = (0, import_react26.useCallback)(() => {
|
|
24259
|
+
onOpenChange(false);
|
|
24260
|
+
if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
|
|
24261
|
+
resetViewTimeoutRef.current = setTimeout(() => {
|
|
24262
|
+
setSelectedToken(null);
|
|
24263
|
+
setSelectedChain(null);
|
|
24264
|
+
setView("form");
|
|
24265
|
+
setSelectedExecution(null);
|
|
24266
|
+
setSubmittedTxInfo(null);
|
|
24267
|
+
setWithdrawDepositWalletId(void 0);
|
|
24268
|
+
resetViewTimeoutRef.current = null;
|
|
24269
|
+
}, 200);
|
|
24270
|
+
}, [onOpenChange]);
|
|
24271
|
+
(0, import_react26.useLayoutEffect)(() => {
|
|
24272
|
+
if (!open) return;
|
|
24273
|
+
if (resetViewTimeoutRef.current) {
|
|
24274
|
+
clearTimeout(resetViewTimeoutRef.current);
|
|
24275
|
+
resetViewTimeoutRef.current = null;
|
|
24276
|
+
}
|
|
24277
|
+
setSelectedToken(null);
|
|
24278
|
+
setSelectedChain(null);
|
|
24279
|
+
setView("form");
|
|
24280
|
+
setSelectedExecution(null);
|
|
24281
|
+
setSubmittedTxInfo(null);
|
|
24282
|
+
setWithdrawDepositWalletId(void 0);
|
|
24283
|
+
}, [open]);
|
|
24284
|
+
(0, import_react26.useEffect)(() => () => {
|
|
24285
|
+
if (resetViewTimeoutRef.current) clearTimeout(resetViewTimeoutRef.current);
|
|
24286
|
+
}, []);
|
|
24287
|
+
const handleTokenSymbolChange = (0, import_react26.useCallback)((symbol) => {
|
|
24288
|
+
const tok = destinationTokens.find((t11) => t11.symbol === symbol);
|
|
24289
|
+
if (tok) {
|
|
24290
|
+
setSelectedToken(tok);
|
|
24291
|
+
if (tok.chains.length > 0) setSelectedChain(tok.chains[0]);
|
|
24292
|
+
}
|
|
24293
|
+
}, [destinationTokens]);
|
|
24294
|
+
const handleChainKeyChange = (0, import_react26.useCallback)((chainKey) => {
|
|
24295
|
+
if (!selectedToken) return;
|
|
24296
|
+
const chain = selectedToken.chains.find((c) => getChainKey5(c.chain_id, c.chain_type) === chainKey);
|
|
24297
|
+
if (chain) setSelectedChain(chain);
|
|
24298
|
+
}, [selectedToken]);
|
|
24299
|
+
const isSourceSupported = sourceValidation?.isSupported ?? null;
|
|
24300
|
+
const canWithdraw = !!onWithdraw || isWalletMatch;
|
|
24301
|
+
const isAnyLoading = tokensLoading || isCheckingSourceToken;
|
|
24302
|
+
const withdrawPoweredByFooter = /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-pt-3", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(PoweredByUnifold, { color: colors2.foregroundMuted, className: "uf-flex uf-justify-center uf-shrink-0" }) });
|
|
24303
|
+
return /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(PortalContainerProvider, { value: hideOverlay ? containerEl : null, children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Dialog2, { open: hideOverlay || open, onOpenChange: hideOverlay ? void 0 : handleClose, modal: !hideOverlay, children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
24304
|
+
DialogContent2,
|
|
24305
|
+
{
|
|
24306
|
+
ref: hideOverlay ? containerCallbackRef : void 0,
|
|
24307
|
+
hideOverlay,
|
|
24308
|
+
className: `sm:uf-max-w-[400px] uf-border-secondary uf-text-foreground uf-gap-0 [&>button]:uf-hidden ${hideOverlay ? `uf-p-6 uf-overflow-hidden ${themeClass}` : `uf-p-0 uf-overflow-visible !uf-top-auto !uf-h-auto !uf-max-h-[90vh] sm:!uf-max-h-none sm:!uf-top-[50%] ${themeClass}`}`,
|
|
24309
|
+
style: { backgroundColor: colors2.background },
|
|
24310
|
+
onPointerDownOutside: (e) => e.preventDefault(),
|
|
24311
|
+
onInteractOutside: (e) => e.preventDefault(),
|
|
24312
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ThemeStyleInjector, { children: view === "confirming" && submittedTxInfo ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
24313
|
+
WithdrawConfirmingView,
|
|
24314
|
+
{
|
|
24315
|
+
txInfo: submittedTxInfo,
|
|
24316
|
+
executions: realtimeExecutions,
|
|
24317
|
+
onClose: handleClose,
|
|
24318
|
+
onViewTracker: () => setView("tracker")
|
|
24319
|
+
}
|
|
24320
|
+
) : view === "detail" && selectedExecution ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
24321
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Withdrawal Details", showBack: true, showClose: !hideOverlay, onBack: () => {
|
|
24322
|
+
setSelectedExecution(null);
|
|
24323
|
+
setView("tracker");
|
|
24324
|
+
}, onClose: handleClose }),
|
|
24325
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositDetailContent, { execution: selectedExecution, variant: "withdraw" }),
|
|
24326
|
+
withdrawPoweredByFooter
|
|
24327
|
+
] }) : view === "tracker" ? (
|
|
24328
|
+
/* ---------- Tracker view: execution list ---------- */
|
|
24329
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
24330
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: "Withdrawal History", showBack: true, showClose: !hideOverlay, onBack: () => setView("form"), onClose: handleClose }),
|
|
24331
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-flex uf-flex-col uf-gap-2", style: { minHeight: 200 }, children: allWithdrawals.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-flex uf-items-center uf-justify-center uf-py-8", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "uf-text-sm", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: "No withdrawals to track yet" }) }) : allWithdrawals.map((ex) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
24332
|
+
WithdrawExecutionItem,
|
|
24333
|
+
{
|
|
24334
|
+
execution: ex,
|
|
24335
|
+
onClick: () => {
|
|
24336
|
+
setSelectedExecution(ex);
|
|
24337
|
+
setView("detail");
|
|
24338
|
+
}
|
|
24339
|
+
},
|
|
24340
|
+
ex.id
|
|
24341
|
+
)) }),
|
|
24342
|
+
withdrawPoweredByFooter
|
|
24343
|
+
] })
|
|
24344
|
+
) : (
|
|
24345
|
+
/* ---------- Form view (default) ---------- */
|
|
24346
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
24347
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(DepositHeader, { title: modalTitle || t9.title, showClose: !hideOverlay, onClose: handleClose }),
|
|
24348
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-flex-col uf-gap-3", children: [
|
|
24349
|
+
isAnyLoading ? /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-space-y-3", children: [1, 2, 3].map((i) => /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-w-full uf-bg-secondary uf-rounded-xl uf-p-3 uf-flex uf-items-center uf-animate-pulse", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-bg-muted uf-rounded-lg uf-w-full uf-h-10" }) }, i)) }) : isSourceSupported === false ? /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)("div", { className: "uf-flex uf-flex-col uf-items-center uf-justify-center uf-py-8 uf-px-4 uf-text-center", children: [
|
|
24350
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("div", { className: "uf-w-16 uf-h-16 uf-rounded-full uf-bg-muted uf-flex uf-items-center uf-justify-center uf-mb-4", children: /* @__PURE__ */ (0, import_jsx_runtime73.jsx)(TriangleAlert, { className: "uf-w-8 uf-h-8 uf-text-muted-foreground" }) }),
|
|
24351
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("h3", { className: "uf-text-lg uf-font-semibold uf-mb-2", style: { color: colors2.foreground, fontFamily: fonts.medium }, children: "Unsupported Source Token" }),
|
|
24352
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)("p", { className: "uf-text-sm uf-max-w-[280px]", style: { color: colors2.foregroundMuted, fontFamily: fonts.regular }, children: sourceValidation?.errorMessage })
|
|
24353
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(import_jsx_runtime73.Fragment, { children: [
|
|
24354
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
24355
|
+
WithdrawDoubleInput,
|
|
24356
|
+
{
|
|
24357
|
+
tokens: destinationTokens,
|
|
24358
|
+
selectedTokenSymbol: selectedToken?.symbol ?? null,
|
|
24359
|
+
selectedChainKey: selectedChain ? getChainKey5(selectedChain.chain_id, selectedChain.chain_type) : null,
|
|
24360
|
+
onTokenChange: handleTokenSymbolChange,
|
|
24361
|
+
onChainChange: handleChainKeyChange,
|
|
24362
|
+
isLoading: tokensLoading
|
|
24363
|
+
}
|
|
24364
|
+
),
|
|
24365
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(
|
|
24366
|
+
WithdrawForm,
|
|
24367
|
+
{
|
|
24368
|
+
publishableKey,
|
|
24369
|
+
externalUserId,
|
|
24370
|
+
sourceChainType,
|
|
24371
|
+
selectedToken,
|
|
24372
|
+
selectedChain,
|
|
24373
|
+
sourceTokenSymbol,
|
|
24374
|
+
recipientAddressProp,
|
|
24375
|
+
balanceData: balanceData ?? null,
|
|
24376
|
+
isLoadingBalance,
|
|
24377
|
+
minimumWithdrawAmountUsd: sourceValidation?.minimumAmountUsd ?? null,
|
|
24378
|
+
estimatedProcessingTime: sourceValidation?.estimatedProcessingTime ?? null,
|
|
24379
|
+
maxSlippagePercent: sourceValidation?.maxSlippagePercent ?? null,
|
|
24380
|
+
priceImpactPercent: sourceValidation?.priceImpactPercent ?? null,
|
|
24381
|
+
detectedWallet,
|
|
24382
|
+
sourceChainId,
|
|
24383
|
+
sourceTokenAddress,
|
|
24384
|
+
isWalletMatch,
|
|
24385
|
+
connectedWalletName,
|
|
24386
|
+
canWithdraw,
|
|
24387
|
+
onWithdraw,
|
|
24388
|
+
onWithdrawError,
|
|
24389
|
+
onDepositWalletCreation: handleDepositWalletCreation,
|
|
24390
|
+
onWithdrawSubmitted: handleWithdrawSubmitted,
|
|
24391
|
+
footerLeft: /* @__PURE__ */ (0, import_jsx_runtime73.jsxs)(
|
|
24392
|
+
"button",
|
|
24393
|
+
{
|
|
24394
|
+
onClick: () => setView("tracker"),
|
|
24395
|
+
className: "uf-flex uf-items-center uf-gap-1 uf-transition-colors hover:uf-opacity-70",
|
|
24396
|
+
style: { color: colors2.foregroundMuted },
|
|
24397
|
+
children: [
|
|
24398
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(Clock, { className: "uf-w-3.5 uf-h-3.5" }),
|
|
24399
|
+
"Withdrawal History",
|
|
24400
|
+
/* @__PURE__ */ (0, import_jsx_runtime73.jsx)(ChevronRight, { className: "uf-w-3 uf-h-3" })
|
|
24401
|
+
]
|
|
24402
|
+
}
|
|
24403
|
+
)
|
|
24404
|
+
}
|
|
24405
|
+
)
|
|
24406
|
+
] }),
|
|
24407
|
+
withdrawPoweredByFooter
|
|
24408
|
+
] })
|
|
24409
|
+
] })
|
|
24410
|
+
) })
|
|
24411
|
+
}
|
|
24412
|
+
) }) });
|
|
24413
|
+
}
|
|
24414
|
+
var t10 = i18n2.withdrawModal;
|
|
24415
|
+
|
|
24416
|
+
// src/provider.tsx
|
|
24417
|
+
var import_jsx_runtime75 = require("react/jsx-runtime");
|
|
24418
|
+
function UnifoldProvider2({
|
|
24419
|
+
children,
|
|
24420
|
+
publishableKey,
|
|
24421
|
+
config
|
|
24422
|
+
}) {
|
|
24423
|
+
const [isOpen, setIsOpen] = (0, import_react31.useState)(false);
|
|
24424
|
+
const [depositConfig, setDepositConfig] = (0, import_react31.useState)(
|
|
24425
|
+
null
|
|
24426
|
+
);
|
|
24427
|
+
const [isWithdrawOpen, setIsWithdrawOpen] = (0, import_react31.useState)(false);
|
|
24428
|
+
const [withdrawConfig, setWithdrawConfig] = (0, import_react31.useState)(
|
|
24429
|
+
null
|
|
24430
|
+
);
|
|
24431
|
+
const [resolvedTheme, setResolvedTheme] = import_react31.default.useState("dark");
|
|
24432
|
+
(0, import_react31.useEffect)(() => {
|
|
24433
|
+
if (publishableKey) {
|
|
24434
|
+
setApiConfig({ publishableKey });
|
|
24435
|
+
}
|
|
24436
|
+
}, [publishableKey]);
|
|
24437
|
+
import_react31.default.useEffect(() => {
|
|
24438
|
+
const appearance = config?.appearance || "dark";
|
|
24439
|
+
if (appearance === "auto") {
|
|
24440
|
+
const prefersDark = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
24441
|
+
setResolvedTheme(prefersDark ? "dark" : "light");
|
|
24442
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
24443
|
+
const handler = (e) => {
|
|
24444
|
+
setResolvedTheme(e.matches ? "dark" : "light");
|
|
24445
|
+
};
|
|
24446
|
+
mediaQuery.addEventListener("change", handler);
|
|
24447
|
+
return () => mediaQuery.removeEventListener("change", handler);
|
|
24448
|
+
} else {
|
|
24449
|
+
setResolvedTheme(appearance);
|
|
24450
|
+
}
|
|
24451
|
+
}, [config?.appearance]);
|
|
24452
|
+
const depositPromiseRef = import_react31.default.useRef(null);
|
|
24453
|
+
const depositConfigRef = import_react31.default.useRef(null);
|
|
24454
|
+
depositConfigRef.current = depositConfig;
|
|
24455
|
+
const closeTimeoutRef = import_react31.default.useRef(null);
|
|
24456
|
+
const closeGuardRef = import_react31.default.useRef(false);
|
|
24457
|
+
const withdrawPromiseRef = import_react31.default.useRef(null);
|
|
24458
|
+
const withdrawConfigRef = import_react31.default.useRef(null);
|
|
24459
|
+
withdrawConfigRef.current = withdrawConfig;
|
|
24460
|
+
const withdrawCloseTimeoutRef = import_react31.default.useRef(null);
|
|
24461
|
+
const withdrawCloseGuardRef = import_react31.default.useRef(false);
|
|
24462
|
+
const beginDeposit = (0, import_react31.useCallback)((config2) => {
|
|
24463
|
+
if (closeTimeoutRef.current) {
|
|
24464
|
+
clearTimeout(closeTimeoutRef.current);
|
|
24465
|
+
closeTimeoutRef.current = null;
|
|
24466
|
+
}
|
|
24467
|
+
closeGuardRef.current = false;
|
|
24468
|
+
if (depositPromiseRef.current) {
|
|
24469
|
+
console.warn("[UnifoldProvider] A deposit is already in progress. Cancelling previous deposit.");
|
|
24470
|
+
depositPromiseRef.current.reject({
|
|
24471
|
+
message: "Deposit cancelled - new deposit started",
|
|
24472
|
+
code: "DEPOSIT_SUPERSEDED"
|
|
24473
|
+
});
|
|
24474
|
+
depositPromiseRef.current = null;
|
|
24475
|
+
}
|
|
24476
|
+
const promise = new Promise((resolve, reject) => {
|
|
24477
|
+
depositPromiseRef.current = { resolve, reject };
|
|
24478
|
+
});
|
|
24479
|
+
promise.catch(() => {
|
|
24480
|
+
});
|
|
24481
|
+
setDepositConfig(config2);
|
|
24482
|
+
setIsOpen(true);
|
|
24483
|
+
return promise;
|
|
24484
|
+
}, []);
|
|
24485
|
+
const closeDeposit = (0, import_react31.useCallback)(() => {
|
|
24486
|
+
if (closeGuardRef.current) {
|
|
24487
|
+
return;
|
|
24488
|
+
}
|
|
24489
|
+
closeGuardRef.current = true;
|
|
24490
|
+
const promiseToReject = depositPromiseRef.current;
|
|
24491
|
+
depositPromiseRef.current = null;
|
|
24492
|
+
if (depositConfigRef.current?.onClose) {
|
|
24493
|
+
depositConfigRef.current.onClose();
|
|
24494
|
+
}
|
|
24495
|
+
if (promiseToReject) {
|
|
24496
|
+
promiseToReject.reject({
|
|
24497
|
+
message: "Deposit cancelled by user",
|
|
24498
|
+
code: "DEPOSIT_CANCELLED"
|
|
24499
|
+
});
|
|
24500
|
+
}
|
|
24501
|
+
setIsOpen(false);
|
|
24502
|
+
closeTimeoutRef.current = setTimeout(() => {
|
|
24503
|
+
setDepositConfig(null);
|
|
24504
|
+
closeTimeoutRef.current = null;
|
|
24505
|
+
}, 200);
|
|
24506
|
+
}, []);
|
|
24507
|
+
const handleDepositSuccess = (0, import_react31.useCallback)((data) => {
|
|
24508
|
+
if (depositConfig?.onSuccess) {
|
|
24509
|
+
depositConfig.onSuccess(data);
|
|
24510
|
+
}
|
|
24511
|
+
if (depositPromiseRef.current) {
|
|
24512
|
+
depositPromiseRef.current.resolve(data);
|
|
24513
|
+
depositPromiseRef.current = null;
|
|
24514
|
+
}
|
|
24515
|
+
}, [depositConfig]);
|
|
24516
|
+
const handleDepositError = (0, import_react31.useCallback)((error) => {
|
|
22631
24517
|
console.error("[UnifoldProvider] Deposit error:", error);
|
|
22632
24518
|
if (depositConfig?.onError) {
|
|
22633
24519
|
depositConfig.onError(error);
|
|
@@ -22637,16 +24523,84 @@ function UnifoldProvider2({
|
|
|
22637
24523
|
depositPromiseRef.current = null;
|
|
22638
24524
|
}
|
|
22639
24525
|
}, [depositConfig]);
|
|
22640
|
-
const
|
|
24526
|
+
const beginWithdraw = (0, import_react31.useCallback)((config2) => {
|
|
24527
|
+
if (withdrawCloseTimeoutRef.current) {
|
|
24528
|
+
clearTimeout(withdrawCloseTimeoutRef.current);
|
|
24529
|
+
withdrawCloseTimeoutRef.current = null;
|
|
24530
|
+
}
|
|
24531
|
+
withdrawCloseGuardRef.current = false;
|
|
24532
|
+
if (withdrawPromiseRef.current) {
|
|
24533
|
+
console.warn("[UnifoldProvider] A withdraw is already in progress. Cancelling previous withdraw.");
|
|
24534
|
+
withdrawPromiseRef.current.reject({
|
|
24535
|
+
message: "Withdraw cancelled - new withdraw started",
|
|
24536
|
+
code: "WITHDRAW_SUPERSEDED"
|
|
24537
|
+
});
|
|
24538
|
+
withdrawPromiseRef.current = null;
|
|
24539
|
+
}
|
|
24540
|
+
const promise = new Promise((resolve, reject) => {
|
|
24541
|
+
withdrawPromiseRef.current = { resolve, reject };
|
|
24542
|
+
});
|
|
24543
|
+
promise.catch(() => {
|
|
24544
|
+
});
|
|
24545
|
+
setWithdrawConfig(config2);
|
|
24546
|
+
setIsWithdrawOpen(true);
|
|
24547
|
+
return promise;
|
|
24548
|
+
}, []);
|
|
24549
|
+
const closeWithdraw = (0, import_react31.useCallback)(() => {
|
|
24550
|
+
if (withdrawCloseGuardRef.current) {
|
|
24551
|
+
return;
|
|
24552
|
+
}
|
|
24553
|
+
withdrawCloseGuardRef.current = true;
|
|
24554
|
+
const promiseToReject = withdrawPromiseRef.current;
|
|
24555
|
+
withdrawPromiseRef.current = null;
|
|
24556
|
+
if (withdrawConfigRef.current?.onClose) {
|
|
24557
|
+
withdrawConfigRef.current.onClose();
|
|
24558
|
+
}
|
|
24559
|
+
if (promiseToReject) {
|
|
24560
|
+
promiseToReject.reject({
|
|
24561
|
+
message: "Withdraw cancelled by user",
|
|
24562
|
+
code: "WITHDRAW_CANCELLED"
|
|
24563
|
+
});
|
|
24564
|
+
}
|
|
24565
|
+
setIsWithdrawOpen(false);
|
|
24566
|
+
withdrawCloseTimeoutRef.current = setTimeout(() => {
|
|
24567
|
+
setWithdrawConfig(null);
|
|
24568
|
+
withdrawCloseTimeoutRef.current = null;
|
|
24569
|
+
}, 200);
|
|
24570
|
+
}, []);
|
|
24571
|
+
const handleWithdrawSuccess = (0, import_react31.useCallback)((data) => {
|
|
24572
|
+
if (withdrawConfigRef.current?.onSuccess) {
|
|
24573
|
+
withdrawConfigRef.current.onSuccess(data);
|
|
24574
|
+
}
|
|
24575
|
+
if (withdrawPromiseRef.current) {
|
|
24576
|
+
withdrawPromiseRef.current.resolve(data);
|
|
24577
|
+
withdrawPromiseRef.current = null;
|
|
24578
|
+
}
|
|
24579
|
+
}, []);
|
|
24580
|
+
const handleWithdrawError = (0, import_react31.useCallback)((error) => {
|
|
24581
|
+
console.error("[UnifoldProvider] Withdraw error:", error);
|
|
24582
|
+
if (withdrawConfigRef.current?.onError) {
|
|
24583
|
+
withdrawConfigRef.current.onError(error);
|
|
24584
|
+
}
|
|
24585
|
+
if (withdrawPromiseRef.current) {
|
|
24586
|
+
withdrawPromiseRef.current.reject(error);
|
|
24587
|
+
withdrawPromiseRef.current = null;
|
|
24588
|
+
}
|
|
24589
|
+
}, []);
|
|
24590
|
+
const contextValue = (0, import_react31.useMemo)(
|
|
22641
24591
|
() => ({
|
|
22642
24592
|
beginDeposit,
|
|
22643
24593
|
closeDeposit,
|
|
22644
24594
|
handleDepositSuccess,
|
|
22645
|
-
handleDepositError
|
|
24595
|
+
handleDepositError,
|
|
24596
|
+
beginWithdraw,
|
|
24597
|
+
closeWithdraw,
|
|
24598
|
+
handleWithdrawSuccess,
|
|
24599
|
+
handleWithdrawError
|
|
22646
24600
|
}),
|
|
22647
|
-
[beginDeposit, closeDeposit, handleDepositSuccess, handleDepositError]
|
|
24601
|
+
[beginDeposit, closeDeposit, handleDepositSuccess, handleDepositError, beginWithdraw, closeWithdraw, handleWithdrawSuccess, handleWithdrawError]
|
|
22648
24602
|
);
|
|
22649
|
-
return /* @__PURE__ */ (0,
|
|
24603
|
+
return /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(UnifoldProvider, { publishableKey, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(ConnectContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime75.jsxs)(
|
|
22650
24604
|
ThemeProvider,
|
|
22651
24605
|
{
|
|
22652
24606
|
mode: resolvedTheme,
|
|
@@ -22657,7 +24611,27 @@ function UnifoldProvider2({
|
|
|
22657
24611
|
components: config?.components,
|
|
22658
24612
|
children: [
|
|
22659
24613
|
children,
|
|
22660
|
-
|
|
24614
|
+
withdrawConfig && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
24615
|
+
WithdrawModal,
|
|
24616
|
+
{
|
|
24617
|
+
open: isWithdrawOpen,
|
|
24618
|
+
onOpenChange: closeWithdraw,
|
|
24619
|
+
publishableKey,
|
|
24620
|
+
modalTitle: config?.withdrawModalTitle,
|
|
24621
|
+
externalUserId: withdrawConfig.externalUserId,
|
|
24622
|
+
sourceChainType: withdrawConfig.sourceChainType,
|
|
24623
|
+
sourceChainId: withdrawConfig.sourceChainId,
|
|
24624
|
+
sourceTokenAddress: withdrawConfig.sourceTokenAddress,
|
|
24625
|
+
sourceTokenSymbol: withdrawConfig.sourceTokenSymbol,
|
|
24626
|
+
recipientAddress: withdrawConfig.recipientAddress,
|
|
24627
|
+
senderAddress: withdrawConfig.senderAddress,
|
|
24628
|
+
onWithdraw: withdrawConfig.withdraw,
|
|
24629
|
+
onWithdrawSuccess: handleWithdrawSuccess,
|
|
24630
|
+
onWithdrawError: handleWithdrawError,
|
|
24631
|
+
theme: resolvedTheme
|
|
24632
|
+
}
|
|
24633
|
+
),
|
|
24634
|
+
depositConfig && /* @__PURE__ */ (0, import_jsx_runtime75.jsx)(
|
|
22661
24635
|
DepositModal,
|
|
22662
24636
|
{
|
|
22663
24637
|
open: isOpen,
|
|
@@ -22670,6 +24644,10 @@ function UnifoldProvider2({
|
|
|
22670
24644
|
destinationChainType: depositConfig.destinationChainType,
|
|
22671
24645
|
destinationChainId: depositConfig.destinationChainId,
|
|
22672
24646
|
destinationTokenAddress: depositConfig.destinationTokenAddress,
|
|
24647
|
+
defaultSourceChainType: depositConfig.defaultSourceChainType,
|
|
24648
|
+
defaultSourceChainId: depositConfig.defaultSourceChainId,
|
|
24649
|
+
defaultSourceTokenAddress: depositConfig.defaultSourceTokenAddress,
|
|
24650
|
+
defaultSourceSymbol: depositConfig.defaultSourceSymbol,
|
|
22673
24651
|
depositConfirmationMode: depositConfig.depositConfirmationMode ?? "auto_ui",
|
|
22674
24652
|
hideDepositTracker: config?.hideDepositTracker,
|
|
22675
24653
|
showBalanceHeader: config?.showBalanceHeader,
|
|
@@ -22694,15 +24672,18 @@ function UnifoldProvider2({
|
|
|
22694
24672
|
}
|
|
22695
24673
|
) }) });
|
|
22696
24674
|
}
|
|
22697
|
-
var ConnectContext =
|
|
24675
|
+
var ConnectContext = import_react31.default.createContext(null);
|
|
22698
24676
|
function useUnifold2() {
|
|
22699
24677
|
const baseContext = useUnifold();
|
|
22700
|
-
const connectContext =
|
|
24678
|
+
const connectContext = import_react31.default.useContext(ConnectContext);
|
|
22701
24679
|
if (typeof window === "undefined") {
|
|
22702
24680
|
return {
|
|
22703
24681
|
publishableKey: "",
|
|
22704
24682
|
beginDeposit: () => Promise.reject(new Error("SSR not supported")),
|
|
22705
24683
|
closeDeposit: () => {
|
|
24684
|
+
},
|
|
24685
|
+
beginWithdraw: () => Promise.reject(new Error("SSR not supported")),
|
|
24686
|
+
closeWithdraw: () => {
|
|
22706
24687
|
}
|
|
22707
24688
|
};
|
|
22708
24689
|
}
|
|
@@ -22712,7 +24693,9 @@ function useUnifold2() {
|
|
|
22712
24693
|
return {
|
|
22713
24694
|
publishableKey: baseContext.publishableKey,
|
|
22714
24695
|
beginDeposit: connectContext.beginDeposit,
|
|
22715
|
-
closeDeposit: connectContext.closeDeposit
|
|
24696
|
+
closeDeposit: connectContext.closeDeposit,
|
|
24697
|
+
beginWithdraw: connectContext.beginWithdraw,
|
|
24698
|
+
closeWithdraw: connectContext.closeWithdraw
|
|
22716
24699
|
};
|
|
22717
24700
|
}
|
|
22718
24701
|
function useAllowedCountry2() {
|
|
@@ -22721,6 +24704,7 @@ function useAllowedCountry2() {
|
|
|
22721
24704
|
}
|
|
22722
24705
|
// Annotate the CommonJS export names for ESM import in node:
|
|
22723
24706
|
0 && (module.exports = {
|
|
24707
|
+
ActionType,
|
|
22724
24708
|
Button,
|
|
22725
24709
|
ConfirmingView,
|
|
22726
24710
|
ExecutionStatus,
|
|
@@ -22739,10 +24723,12 @@ function useAllowedCountry2() {
|
|
|
22739
24723
|
getPreferredIconUrl,
|
|
22740
24724
|
getProjectConfig,
|
|
22741
24725
|
getSupportedDepositTokens,
|
|
24726
|
+
getSupportedDestinationTokens,
|
|
22742
24727
|
getTokenChains,
|
|
22743
24728
|
getWalletByChainType,
|
|
22744
24729
|
i18n,
|
|
22745
24730
|
queryExecutions,
|
|
24731
|
+
sendSolanaTransaction,
|
|
22746
24732
|
setApiConfig,
|
|
22747
24733
|
useAllowedCountry,
|
|
22748
24734
|
useUnifold,
|
|
@@ -22756,11 +24742,13 @@ lucide-react/dist/esm/Icon.js:
|
|
|
22756
24742
|
lucide-react/dist/esm/createLucideIcon.js:
|
|
22757
24743
|
lucide-react/dist/esm/icons/arrow-left-right.js:
|
|
22758
24744
|
lucide-react/dist/esm/icons/arrow-left.js:
|
|
24745
|
+
lucide-react/dist/esm/icons/arrow-up-down.js:
|
|
22759
24746
|
lucide-react/dist/esm/icons/check.js:
|
|
22760
24747
|
lucide-react/dist/esm/icons/chevron-down.js:
|
|
22761
24748
|
lucide-react/dist/esm/icons/chevron-right.js:
|
|
22762
24749
|
lucide-react/dist/esm/icons/chevron-up.js:
|
|
22763
24750
|
lucide-react/dist/esm/icons/circle-check.js:
|
|
24751
|
+
lucide-react/dist/esm/icons/clipboard-paste.js:
|
|
22764
24752
|
lucide-react/dist/esm/icons/clock.js:
|
|
22765
24753
|
lucide-react/dist/esm/icons/copy.js:
|
|
22766
24754
|
lucide-react/dist/esm/icons/credit-card.js:
|