@pollar/react 0.5.3 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,9 +1,1001 @@
1
1
  'use client';
2
2
  import { AUTH_ERROR_CODES, WalletType, PollarClient } from '@pollar/core';
3
- import { createContext, useState, useEffect, useMemo, useContext, useRef, Component } from 'react';
3
+ import { forwardRef, createContext, useState, useEffect, useRef, useCallback, useMemo, useContext, Component } from 'react';
4
4
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
5
5
 
6
- // src/context.tsx
6
+ var __create = Object.create;
7
+ var __defProp = Object.defineProperty;
8
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
9
+ var __getOwnPropNames = Object.getOwnPropertyNames;
10
+ var __getProtoOf = Object.getPrototypeOf;
11
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
12
+ var __commonJS = (cb, mod) => function __require() {
13
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
14
+ };
15
+ var __copyProps = (to, from, except, desc) => {
16
+ if (from && typeof from === "object" || typeof from === "function") {
17
+ for (let key of __getOwnPropNames(from))
18
+ if (!__hasOwnProp.call(to, key) && key !== except)
19
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
+ }
21
+ return to;
22
+ };
23
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
+ // If the importer is in node compatibility mode or this is not an ESM
25
+ // file that has been converted to a CommonJS file using a Babel-
26
+ // compatible transform (i.e. "__esModule" has not been set), then set
27
+ // "default" to the CommonJS "module.exports" for node compatibility.
28
+ !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
+ mod
30
+ ));
31
+
32
+ // ../../node_modules/qr.js/lib/ErrorCorrectLevel.js
33
+ var require_ErrorCorrectLevel = __commonJS({
34
+ "../../node_modules/qr.js/lib/ErrorCorrectLevel.js"(exports$1, module) {
35
+ module.exports = {
36
+ L: 1,
37
+ M: 0,
38
+ Q: 3,
39
+ H: 2
40
+ };
41
+ }
42
+ });
43
+
44
+ // ../../node_modules/qr.js/lib/mode.js
45
+ var require_mode = __commonJS({
46
+ "../../node_modules/qr.js/lib/mode.js"(exports$1, module) {
47
+ module.exports = {
48
+ MODE_NUMBER: 1 << 0,
49
+ MODE_ALPHA_NUM: 1 << 1,
50
+ MODE_8BIT_BYTE: 1 << 2,
51
+ MODE_KANJI: 1 << 3
52
+ };
53
+ }
54
+ });
55
+
56
+ // ../../node_modules/qr.js/lib/8BitByte.js
57
+ var require_BitByte = __commonJS({
58
+ "../../node_modules/qr.js/lib/8BitByte.js"(exports$1, module) {
59
+ var mode = require_mode();
60
+ function QR8bitByte(data) {
61
+ this.mode = mode.MODE_8BIT_BYTE;
62
+ this.data = data;
63
+ }
64
+ QR8bitByte.prototype = {
65
+ getLength: function(buffer) {
66
+ return this.data.length;
67
+ },
68
+ write: function(buffer) {
69
+ for (var i = 0; i < this.data.length; i++) {
70
+ buffer.put(this.data.charCodeAt(i), 8);
71
+ }
72
+ }
73
+ };
74
+ module.exports = QR8bitByte;
75
+ }
76
+ });
77
+
78
+ // ../../node_modules/qr.js/lib/RSBlock.js
79
+ var require_RSBlock = __commonJS({
80
+ "../../node_modules/qr.js/lib/RSBlock.js"(exports$1, module) {
81
+ var ECL = require_ErrorCorrectLevel();
82
+ function QRRSBlock(totalCount, dataCount) {
83
+ this.totalCount = totalCount;
84
+ this.dataCount = dataCount;
85
+ }
86
+ QRRSBlock.RS_BLOCK_TABLE = [
87
+ // L
88
+ // M
89
+ // Q
90
+ // H
91
+ // 1
92
+ [1, 26, 19],
93
+ [1, 26, 16],
94
+ [1, 26, 13],
95
+ [1, 26, 9],
96
+ // 2
97
+ [1, 44, 34],
98
+ [1, 44, 28],
99
+ [1, 44, 22],
100
+ [1, 44, 16],
101
+ // 3
102
+ [1, 70, 55],
103
+ [1, 70, 44],
104
+ [2, 35, 17],
105
+ [2, 35, 13],
106
+ // 4
107
+ [1, 100, 80],
108
+ [2, 50, 32],
109
+ [2, 50, 24],
110
+ [4, 25, 9],
111
+ // 5
112
+ [1, 134, 108],
113
+ [2, 67, 43],
114
+ [2, 33, 15, 2, 34, 16],
115
+ [2, 33, 11, 2, 34, 12],
116
+ // 6
117
+ [2, 86, 68],
118
+ [4, 43, 27],
119
+ [4, 43, 19],
120
+ [4, 43, 15],
121
+ // 7
122
+ [2, 98, 78],
123
+ [4, 49, 31],
124
+ [2, 32, 14, 4, 33, 15],
125
+ [4, 39, 13, 1, 40, 14],
126
+ // 8
127
+ [2, 121, 97],
128
+ [2, 60, 38, 2, 61, 39],
129
+ [4, 40, 18, 2, 41, 19],
130
+ [4, 40, 14, 2, 41, 15],
131
+ // 9
132
+ [2, 146, 116],
133
+ [3, 58, 36, 2, 59, 37],
134
+ [4, 36, 16, 4, 37, 17],
135
+ [4, 36, 12, 4, 37, 13],
136
+ // 10
137
+ [2, 86, 68, 2, 87, 69],
138
+ [4, 69, 43, 1, 70, 44],
139
+ [6, 43, 19, 2, 44, 20],
140
+ [6, 43, 15, 2, 44, 16],
141
+ // 11
142
+ [4, 101, 81],
143
+ [1, 80, 50, 4, 81, 51],
144
+ [4, 50, 22, 4, 51, 23],
145
+ [3, 36, 12, 8, 37, 13],
146
+ // 12
147
+ [2, 116, 92, 2, 117, 93],
148
+ [6, 58, 36, 2, 59, 37],
149
+ [4, 46, 20, 6, 47, 21],
150
+ [7, 42, 14, 4, 43, 15],
151
+ // 13
152
+ [4, 133, 107],
153
+ [8, 59, 37, 1, 60, 38],
154
+ [8, 44, 20, 4, 45, 21],
155
+ [12, 33, 11, 4, 34, 12],
156
+ // 14
157
+ [3, 145, 115, 1, 146, 116],
158
+ [4, 64, 40, 5, 65, 41],
159
+ [11, 36, 16, 5, 37, 17],
160
+ [11, 36, 12, 5, 37, 13],
161
+ // 15
162
+ [5, 109, 87, 1, 110, 88],
163
+ [5, 65, 41, 5, 66, 42],
164
+ [5, 54, 24, 7, 55, 25],
165
+ [11, 36, 12],
166
+ // 16
167
+ [5, 122, 98, 1, 123, 99],
168
+ [7, 73, 45, 3, 74, 46],
169
+ [15, 43, 19, 2, 44, 20],
170
+ [3, 45, 15, 13, 46, 16],
171
+ // 17
172
+ [1, 135, 107, 5, 136, 108],
173
+ [10, 74, 46, 1, 75, 47],
174
+ [1, 50, 22, 15, 51, 23],
175
+ [2, 42, 14, 17, 43, 15],
176
+ // 18
177
+ [5, 150, 120, 1, 151, 121],
178
+ [9, 69, 43, 4, 70, 44],
179
+ [17, 50, 22, 1, 51, 23],
180
+ [2, 42, 14, 19, 43, 15],
181
+ // 19
182
+ [3, 141, 113, 4, 142, 114],
183
+ [3, 70, 44, 11, 71, 45],
184
+ [17, 47, 21, 4, 48, 22],
185
+ [9, 39, 13, 16, 40, 14],
186
+ // 20
187
+ [3, 135, 107, 5, 136, 108],
188
+ [3, 67, 41, 13, 68, 42],
189
+ [15, 54, 24, 5, 55, 25],
190
+ [15, 43, 15, 10, 44, 16],
191
+ // 21
192
+ [4, 144, 116, 4, 145, 117],
193
+ [17, 68, 42],
194
+ [17, 50, 22, 6, 51, 23],
195
+ [19, 46, 16, 6, 47, 17],
196
+ // 22
197
+ [2, 139, 111, 7, 140, 112],
198
+ [17, 74, 46],
199
+ [7, 54, 24, 16, 55, 25],
200
+ [34, 37, 13],
201
+ // 23
202
+ [4, 151, 121, 5, 152, 122],
203
+ [4, 75, 47, 14, 76, 48],
204
+ [11, 54, 24, 14, 55, 25],
205
+ [16, 45, 15, 14, 46, 16],
206
+ // 24
207
+ [6, 147, 117, 4, 148, 118],
208
+ [6, 73, 45, 14, 74, 46],
209
+ [11, 54, 24, 16, 55, 25],
210
+ [30, 46, 16, 2, 47, 17],
211
+ // 25
212
+ [8, 132, 106, 4, 133, 107],
213
+ [8, 75, 47, 13, 76, 48],
214
+ [7, 54, 24, 22, 55, 25],
215
+ [22, 45, 15, 13, 46, 16],
216
+ // 26
217
+ [10, 142, 114, 2, 143, 115],
218
+ [19, 74, 46, 4, 75, 47],
219
+ [28, 50, 22, 6, 51, 23],
220
+ [33, 46, 16, 4, 47, 17],
221
+ // 27
222
+ [8, 152, 122, 4, 153, 123],
223
+ [22, 73, 45, 3, 74, 46],
224
+ [8, 53, 23, 26, 54, 24],
225
+ [12, 45, 15, 28, 46, 16],
226
+ // 28
227
+ [3, 147, 117, 10, 148, 118],
228
+ [3, 73, 45, 23, 74, 46],
229
+ [4, 54, 24, 31, 55, 25],
230
+ [11, 45, 15, 31, 46, 16],
231
+ // 29
232
+ [7, 146, 116, 7, 147, 117],
233
+ [21, 73, 45, 7, 74, 46],
234
+ [1, 53, 23, 37, 54, 24],
235
+ [19, 45, 15, 26, 46, 16],
236
+ // 30
237
+ [5, 145, 115, 10, 146, 116],
238
+ [19, 75, 47, 10, 76, 48],
239
+ [15, 54, 24, 25, 55, 25],
240
+ [23, 45, 15, 25, 46, 16],
241
+ // 31
242
+ [13, 145, 115, 3, 146, 116],
243
+ [2, 74, 46, 29, 75, 47],
244
+ [42, 54, 24, 1, 55, 25],
245
+ [23, 45, 15, 28, 46, 16],
246
+ // 32
247
+ [17, 145, 115],
248
+ [10, 74, 46, 23, 75, 47],
249
+ [10, 54, 24, 35, 55, 25],
250
+ [19, 45, 15, 35, 46, 16],
251
+ // 33
252
+ [17, 145, 115, 1, 146, 116],
253
+ [14, 74, 46, 21, 75, 47],
254
+ [29, 54, 24, 19, 55, 25],
255
+ [11, 45, 15, 46, 46, 16],
256
+ // 34
257
+ [13, 145, 115, 6, 146, 116],
258
+ [14, 74, 46, 23, 75, 47],
259
+ [44, 54, 24, 7, 55, 25],
260
+ [59, 46, 16, 1, 47, 17],
261
+ // 35
262
+ [12, 151, 121, 7, 152, 122],
263
+ [12, 75, 47, 26, 76, 48],
264
+ [39, 54, 24, 14, 55, 25],
265
+ [22, 45, 15, 41, 46, 16],
266
+ // 36
267
+ [6, 151, 121, 14, 152, 122],
268
+ [6, 75, 47, 34, 76, 48],
269
+ [46, 54, 24, 10, 55, 25],
270
+ [2, 45, 15, 64, 46, 16],
271
+ // 37
272
+ [17, 152, 122, 4, 153, 123],
273
+ [29, 74, 46, 14, 75, 47],
274
+ [49, 54, 24, 10, 55, 25],
275
+ [24, 45, 15, 46, 46, 16],
276
+ // 38
277
+ [4, 152, 122, 18, 153, 123],
278
+ [13, 74, 46, 32, 75, 47],
279
+ [48, 54, 24, 14, 55, 25],
280
+ [42, 45, 15, 32, 46, 16],
281
+ // 39
282
+ [20, 147, 117, 4, 148, 118],
283
+ [40, 75, 47, 7, 76, 48],
284
+ [43, 54, 24, 22, 55, 25],
285
+ [10, 45, 15, 67, 46, 16],
286
+ // 40
287
+ [19, 148, 118, 6, 149, 119],
288
+ [18, 75, 47, 31, 76, 48],
289
+ [34, 54, 24, 34, 55, 25],
290
+ [20, 45, 15, 61, 46, 16]
291
+ ];
292
+ QRRSBlock.getRSBlocks = function(typeNumber, errorCorrectLevel) {
293
+ var rsBlock = QRRSBlock.getRsBlockTable(typeNumber, errorCorrectLevel);
294
+ if (rsBlock == void 0) {
295
+ throw new Error("bad rs block @ typeNumber:" + typeNumber + "/errorCorrectLevel:" + errorCorrectLevel);
296
+ }
297
+ var length = rsBlock.length / 3;
298
+ var list = new Array();
299
+ for (var i = 0; i < length; i++) {
300
+ var count = rsBlock[i * 3 + 0];
301
+ var totalCount = rsBlock[i * 3 + 1];
302
+ var dataCount = rsBlock[i * 3 + 2];
303
+ for (var j = 0; j < count; j++) {
304
+ list.push(new QRRSBlock(totalCount, dataCount));
305
+ }
306
+ }
307
+ return list;
308
+ };
309
+ QRRSBlock.getRsBlockTable = function(typeNumber, errorCorrectLevel) {
310
+ switch (errorCorrectLevel) {
311
+ case ECL.L:
312
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 0];
313
+ case ECL.M:
314
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 1];
315
+ case ECL.Q:
316
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 2];
317
+ case ECL.H:
318
+ return QRRSBlock.RS_BLOCK_TABLE[(typeNumber - 1) * 4 + 3];
319
+ default:
320
+ return void 0;
321
+ }
322
+ };
323
+ module.exports = QRRSBlock;
324
+ }
325
+ });
326
+
327
+ // ../../node_modules/qr.js/lib/BitBuffer.js
328
+ var require_BitBuffer = __commonJS({
329
+ "../../node_modules/qr.js/lib/BitBuffer.js"(exports$1, module) {
330
+ function QRBitBuffer() {
331
+ this.buffer = new Array();
332
+ this.length = 0;
333
+ }
334
+ QRBitBuffer.prototype = {
335
+ get: function(index) {
336
+ var bufIndex = Math.floor(index / 8);
337
+ return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) == 1;
338
+ },
339
+ put: function(num, length) {
340
+ for (var i = 0; i < length; i++) {
341
+ this.putBit((num >>> length - i - 1 & 1) == 1);
342
+ }
343
+ },
344
+ getLengthInBits: function() {
345
+ return this.length;
346
+ },
347
+ putBit: function(bit) {
348
+ var bufIndex = Math.floor(this.length / 8);
349
+ if (this.buffer.length <= bufIndex) {
350
+ this.buffer.push(0);
351
+ }
352
+ if (bit) {
353
+ this.buffer[bufIndex] |= 128 >>> this.length % 8;
354
+ }
355
+ this.length++;
356
+ }
357
+ };
358
+ module.exports = QRBitBuffer;
359
+ }
360
+ });
361
+
362
+ // ../../node_modules/qr.js/lib/math.js
363
+ var require_math = __commonJS({
364
+ "../../node_modules/qr.js/lib/math.js"(exports$1, module) {
365
+ var QRMath = {
366
+ glog: function(n) {
367
+ if (n < 1) {
368
+ throw new Error("glog(" + n + ")");
369
+ }
370
+ return QRMath.LOG_TABLE[n];
371
+ },
372
+ gexp: function(n) {
373
+ while (n < 0) {
374
+ n += 255;
375
+ }
376
+ while (n >= 256) {
377
+ n -= 255;
378
+ }
379
+ return QRMath.EXP_TABLE[n];
380
+ },
381
+ EXP_TABLE: new Array(256),
382
+ LOG_TABLE: new Array(256)
383
+ };
384
+ for (i = 0; i < 8; i++) {
385
+ QRMath.EXP_TABLE[i] = 1 << i;
386
+ }
387
+ var i;
388
+ for (i = 8; i < 256; i++) {
389
+ QRMath.EXP_TABLE[i] = QRMath.EXP_TABLE[i - 4] ^ QRMath.EXP_TABLE[i - 5] ^ QRMath.EXP_TABLE[i - 6] ^ QRMath.EXP_TABLE[i - 8];
390
+ }
391
+ var i;
392
+ for (i = 0; i < 255; i++) {
393
+ QRMath.LOG_TABLE[QRMath.EXP_TABLE[i]] = i;
394
+ }
395
+ var i;
396
+ module.exports = QRMath;
397
+ }
398
+ });
399
+
400
+ // ../../node_modules/qr.js/lib/Polynomial.js
401
+ var require_Polynomial = __commonJS({
402
+ "../../node_modules/qr.js/lib/Polynomial.js"(exports$1, module) {
403
+ var math = require_math();
404
+ function QRPolynomial(num, shift) {
405
+ if (num.length == void 0) {
406
+ throw new Error(num.length + "/" + shift);
407
+ }
408
+ var offset = 0;
409
+ while (offset < num.length && num[offset] == 0) {
410
+ offset++;
411
+ }
412
+ this.num = new Array(num.length - offset + shift);
413
+ for (var i = 0; i < num.length - offset; i++) {
414
+ this.num[i] = num[i + offset];
415
+ }
416
+ }
417
+ QRPolynomial.prototype = {
418
+ get: function(index) {
419
+ return this.num[index];
420
+ },
421
+ getLength: function() {
422
+ return this.num.length;
423
+ },
424
+ multiply: function(e) {
425
+ var num = new Array(this.getLength() + e.getLength() - 1);
426
+ for (var i = 0; i < this.getLength(); i++) {
427
+ for (var j = 0; j < e.getLength(); j++) {
428
+ num[i + j] ^= math.gexp(math.glog(this.get(i)) + math.glog(e.get(j)));
429
+ }
430
+ }
431
+ return new QRPolynomial(num, 0);
432
+ },
433
+ mod: function(e) {
434
+ if (this.getLength() - e.getLength() < 0) {
435
+ return this;
436
+ }
437
+ var ratio = math.glog(this.get(0)) - math.glog(e.get(0));
438
+ var num = new Array(this.getLength());
439
+ for (var i = 0; i < this.getLength(); i++) {
440
+ num[i] = this.get(i);
441
+ }
442
+ for (var i = 0; i < e.getLength(); i++) {
443
+ num[i] ^= math.gexp(math.glog(e.get(i)) + ratio);
444
+ }
445
+ return new QRPolynomial(num, 0).mod(e);
446
+ }
447
+ };
448
+ module.exports = QRPolynomial;
449
+ }
450
+ });
451
+
452
+ // ../../node_modules/qr.js/lib/util.js
453
+ var require_util = __commonJS({
454
+ "../../node_modules/qr.js/lib/util.js"(exports$1, module) {
455
+ var Mode = require_mode();
456
+ var Polynomial = require_Polynomial();
457
+ var math = require_math();
458
+ var QRMaskPattern = {
459
+ PATTERN000: 0,
460
+ PATTERN001: 1,
461
+ PATTERN010: 2,
462
+ PATTERN011: 3,
463
+ PATTERN100: 4,
464
+ PATTERN101: 5,
465
+ PATTERN110: 6,
466
+ PATTERN111: 7
467
+ };
468
+ var QRUtil = {
469
+ PATTERN_POSITION_TABLE: [
470
+ [],
471
+ [6, 18],
472
+ [6, 22],
473
+ [6, 26],
474
+ [6, 30],
475
+ [6, 34],
476
+ [6, 22, 38],
477
+ [6, 24, 42],
478
+ [6, 26, 46],
479
+ [6, 28, 50],
480
+ [6, 30, 54],
481
+ [6, 32, 58],
482
+ [6, 34, 62],
483
+ [6, 26, 46, 66],
484
+ [6, 26, 48, 70],
485
+ [6, 26, 50, 74],
486
+ [6, 30, 54, 78],
487
+ [6, 30, 56, 82],
488
+ [6, 30, 58, 86],
489
+ [6, 34, 62, 90],
490
+ [6, 28, 50, 72, 94],
491
+ [6, 26, 50, 74, 98],
492
+ [6, 30, 54, 78, 102],
493
+ [6, 28, 54, 80, 106],
494
+ [6, 32, 58, 84, 110],
495
+ [6, 30, 58, 86, 114],
496
+ [6, 34, 62, 90, 118],
497
+ [6, 26, 50, 74, 98, 122],
498
+ [6, 30, 54, 78, 102, 126],
499
+ [6, 26, 52, 78, 104, 130],
500
+ [6, 30, 56, 82, 108, 134],
501
+ [6, 34, 60, 86, 112, 138],
502
+ [6, 30, 58, 86, 114, 142],
503
+ [6, 34, 62, 90, 118, 146],
504
+ [6, 30, 54, 78, 102, 126, 150],
505
+ [6, 24, 50, 76, 102, 128, 154],
506
+ [6, 28, 54, 80, 106, 132, 158],
507
+ [6, 32, 58, 84, 110, 136, 162],
508
+ [6, 26, 54, 82, 110, 138, 166],
509
+ [6, 30, 58, 86, 114, 142, 170]
510
+ ],
511
+ G15: 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0,
512
+ G18: 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0,
513
+ G15_MASK: 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1,
514
+ getBCHTypeInfo: function(data) {
515
+ var d = data << 10;
516
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15) >= 0) {
517
+ d ^= QRUtil.G15 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G15);
518
+ }
519
+ return (data << 10 | d) ^ QRUtil.G15_MASK;
520
+ },
521
+ getBCHTypeNumber: function(data) {
522
+ var d = data << 12;
523
+ while (QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18) >= 0) {
524
+ d ^= QRUtil.G18 << QRUtil.getBCHDigit(d) - QRUtil.getBCHDigit(QRUtil.G18);
525
+ }
526
+ return data << 12 | d;
527
+ },
528
+ getBCHDigit: function(data) {
529
+ var digit = 0;
530
+ while (data != 0) {
531
+ digit++;
532
+ data >>>= 1;
533
+ }
534
+ return digit;
535
+ },
536
+ getPatternPosition: function(typeNumber) {
537
+ return QRUtil.PATTERN_POSITION_TABLE[typeNumber - 1];
538
+ },
539
+ getMask: function(maskPattern, i, j) {
540
+ switch (maskPattern) {
541
+ case QRMaskPattern.PATTERN000:
542
+ return (i + j) % 2 == 0;
543
+ case QRMaskPattern.PATTERN001:
544
+ return i % 2 == 0;
545
+ case QRMaskPattern.PATTERN010:
546
+ return j % 3 == 0;
547
+ case QRMaskPattern.PATTERN011:
548
+ return (i + j) % 3 == 0;
549
+ case QRMaskPattern.PATTERN100:
550
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 == 0;
551
+ case QRMaskPattern.PATTERN101:
552
+ return i * j % 2 + i * j % 3 == 0;
553
+ case QRMaskPattern.PATTERN110:
554
+ return (i * j % 2 + i * j % 3) % 2 == 0;
555
+ case QRMaskPattern.PATTERN111:
556
+ return (i * j % 3 + (i + j) % 2) % 2 == 0;
557
+ default:
558
+ throw new Error("bad maskPattern:" + maskPattern);
559
+ }
560
+ },
561
+ getErrorCorrectPolynomial: function(errorCorrectLength) {
562
+ var a = new Polynomial([1], 0);
563
+ for (var i = 0; i < errorCorrectLength; i++) {
564
+ a = a.multiply(new Polynomial([1, math.gexp(i)], 0));
565
+ }
566
+ return a;
567
+ },
568
+ getLengthInBits: function(mode, type) {
569
+ if (1 <= type && type < 10) {
570
+ switch (mode) {
571
+ case Mode.MODE_NUMBER:
572
+ return 10;
573
+ case Mode.MODE_ALPHA_NUM:
574
+ return 9;
575
+ case Mode.MODE_8BIT_BYTE:
576
+ return 8;
577
+ case Mode.MODE_KANJI:
578
+ return 8;
579
+ default:
580
+ throw new Error("mode:" + mode);
581
+ }
582
+ } else if (type < 27) {
583
+ switch (mode) {
584
+ case Mode.MODE_NUMBER:
585
+ return 12;
586
+ case Mode.MODE_ALPHA_NUM:
587
+ return 11;
588
+ case Mode.MODE_8BIT_BYTE:
589
+ return 16;
590
+ case Mode.MODE_KANJI:
591
+ return 10;
592
+ default:
593
+ throw new Error("mode:" + mode);
594
+ }
595
+ } else if (type < 41) {
596
+ switch (mode) {
597
+ case Mode.MODE_NUMBER:
598
+ return 14;
599
+ case Mode.MODE_ALPHA_NUM:
600
+ return 13;
601
+ case Mode.MODE_8BIT_BYTE:
602
+ return 16;
603
+ case Mode.MODE_KANJI:
604
+ return 12;
605
+ default:
606
+ throw new Error("mode:" + mode);
607
+ }
608
+ } else {
609
+ throw new Error("type:" + type);
610
+ }
611
+ },
612
+ getLostPoint: function(qrCode) {
613
+ var moduleCount = qrCode.getModuleCount();
614
+ var lostPoint = 0;
615
+ for (var row = 0; row < moduleCount; row++) {
616
+ for (var col = 0; col < moduleCount; col++) {
617
+ var sameCount = 0;
618
+ var dark = qrCode.isDark(row, col);
619
+ for (var r = -1; r <= 1; r++) {
620
+ if (row + r < 0 || moduleCount <= row + r) {
621
+ continue;
622
+ }
623
+ for (var c = -1; c <= 1; c++) {
624
+ if (col + c < 0 || moduleCount <= col + c) {
625
+ continue;
626
+ }
627
+ if (r == 0 && c == 0) {
628
+ continue;
629
+ }
630
+ if (dark == qrCode.isDark(row + r, col + c)) {
631
+ sameCount++;
632
+ }
633
+ }
634
+ }
635
+ if (sameCount > 5) {
636
+ lostPoint += 3 + sameCount - 5;
637
+ }
638
+ }
639
+ }
640
+ for (var row = 0; row < moduleCount - 1; row++) {
641
+ for (var col = 0; col < moduleCount - 1; col++) {
642
+ var count = 0;
643
+ if (qrCode.isDark(row, col)) count++;
644
+ if (qrCode.isDark(row + 1, col)) count++;
645
+ if (qrCode.isDark(row, col + 1)) count++;
646
+ if (qrCode.isDark(row + 1, col + 1)) count++;
647
+ if (count == 0 || count == 4) {
648
+ lostPoint += 3;
649
+ }
650
+ }
651
+ }
652
+ for (var row = 0; row < moduleCount; row++) {
653
+ for (var col = 0; col < moduleCount - 6; col++) {
654
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row, col + 1) && qrCode.isDark(row, col + 2) && qrCode.isDark(row, col + 3) && qrCode.isDark(row, col + 4) && !qrCode.isDark(row, col + 5) && qrCode.isDark(row, col + 6)) {
655
+ lostPoint += 40;
656
+ }
657
+ }
658
+ }
659
+ for (var col = 0; col < moduleCount; col++) {
660
+ for (var row = 0; row < moduleCount - 6; row++) {
661
+ if (qrCode.isDark(row, col) && !qrCode.isDark(row + 1, col) && qrCode.isDark(row + 2, col) && qrCode.isDark(row + 3, col) && qrCode.isDark(row + 4, col) && !qrCode.isDark(row + 5, col) && qrCode.isDark(row + 6, col)) {
662
+ lostPoint += 40;
663
+ }
664
+ }
665
+ }
666
+ var darkCount = 0;
667
+ for (var col = 0; col < moduleCount; col++) {
668
+ for (var row = 0; row < moduleCount; row++) {
669
+ if (qrCode.isDark(row, col)) {
670
+ darkCount++;
671
+ }
672
+ }
673
+ }
674
+ var ratio = Math.abs(100 * darkCount / moduleCount / moduleCount - 50) / 5;
675
+ lostPoint += ratio * 10;
676
+ return lostPoint;
677
+ }
678
+ };
679
+ module.exports = QRUtil;
680
+ }
681
+ });
682
+
683
+ // ../../node_modules/qr.js/lib/QRCode.js
684
+ var require_QRCode = __commonJS({
685
+ "../../node_modules/qr.js/lib/QRCode.js"(exports$1, module) {
686
+ var BitByte = require_BitByte();
687
+ var RSBlock = require_RSBlock();
688
+ var BitBuffer = require_BitBuffer();
689
+ var util = require_util();
690
+ var Polynomial = require_Polynomial();
691
+ function QRCode3(typeNumber, errorCorrectLevel) {
692
+ this.typeNumber = typeNumber;
693
+ this.errorCorrectLevel = errorCorrectLevel;
694
+ this.modules = null;
695
+ this.moduleCount = 0;
696
+ this.dataCache = null;
697
+ this.dataList = [];
698
+ }
699
+ var proto = QRCode3.prototype;
700
+ proto.addData = function(data) {
701
+ var newData = new BitByte(data);
702
+ this.dataList.push(newData);
703
+ this.dataCache = null;
704
+ };
705
+ proto.isDark = function(row, col) {
706
+ if (row < 0 || this.moduleCount <= row || col < 0 || this.moduleCount <= col) {
707
+ throw new Error(row + "," + col);
708
+ }
709
+ return this.modules[row][col];
710
+ };
711
+ proto.getModuleCount = function() {
712
+ return this.moduleCount;
713
+ };
714
+ proto.make = function() {
715
+ if (this.typeNumber < 1) {
716
+ var typeNumber = 1;
717
+ for (typeNumber = 1; typeNumber < 40; typeNumber++) {
718
+ var rsBlocks = RSBlock.getRSBlocks(typeNumber, this.errorCorrectLevel);
719
+ var buffer = new BitBuffer();
720
+ var totalDataCount = 0;
721
+ for (var i = 0; i < rsBlocks.length; i++) {
722
+ totalDataCount += rsBlocks[i].dataCount;
723
+ }
724
+ for (var i = 0; i < this.dataList.length; i++) {
725
+ var data = this.dataList[i];
726
+ buffer.put(data.mode, 4);
727
+ buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber));
728
+ data.write(buffer);
729
+ }
730
+ if (buffer.getLengthInBits() <= totalDataCount * 8)
731
+ break;
732
+ }
733
+ this.typeNumber = typeNumber;
734
+ }
735
+ this.makeImpl(false, this.getBestMaskPattern());
736
+ };
737
+ proto.makeImpl = function(test, maskPattern) {
738
+ this.moduleCount = this.typeNumber * 4 + 17;
739
+ this.modules = new Array(this.moduleCount);
740
+ for (var row = 0; row < this.moduleCount; row++) {
741
+ this.modules[row] = new Array(this.moduleCount);
742
+ for (var col = 0; col < this.moduleCount; col++) {
743
+ this.modules[row][col] = null;
744
+ }
745
+ }
746
+ this.setupPositionProbePattern(0, 0);
747
+ this.setupPositionProbePattern(this.moduleCount - 7, 0);
748
+ this.setupPositionProbePattern(0, this.moduleCount - 7);
749
+ this.setupPositionAdjustPattern();
750
+ this.setupTimingPattern();
751
+ this.setupTypeInfo(test, maskPattern);
752
+ if (this.typeNumber >= 7) {
753
+ this.setupTypeNumber(test);
754
+ }
755
+ if (this.dataCache == null) {
756
+ this.dataCache = QRCode3.createData(this.typeNumber, this.errorCorrectLevel, this.dataList);
757
+ }
758
+ this.mapData(this.dataCache, maskPattern);
759
+ };
760
+ proto.setupPositionProbePattern = function(row, col) {
761
+ for (var r = -1; r <= 7; r++) {
762
+ if (row + r <= -1 || this.moduleCount <= row + r) continue;
763
+ for (var c = -1; c <= 7; c++) {
764
+ if (col + c <= -1 || this.moduleCount <= col + c) continue;
765
+ if (0 <= r && r <= 6 && (c == 0 || c == 6) || 0 <= c && c <= 6 && (r == 0 || r == 6) || 2 <= r && r <= 4 && 2 <= c && c <= 4) {
766
+ this.modules[row + r][col + c] = true;
767
+ } else {
768
+ this.modules[row + r][col + c] = false;
769
+ }
770
+ }
771
+ }
772
+ };
773
+ proto.getBestMaskPattern = function() {
774
+ var minLostPoint = 0;
775
+ var pattern = 0;
776
+ for (var i = 0; i < 8; i++) {
777
+ this.makeImpl(true, i);
778
+ var lostPoint = util.getLostPoint(this);
779
+ if (i == 0 || minLostPoint > lostPoint) {
780
+ minLostPoint = lostPoint;
781
+ pattern = i;
782
+ }
783
+ }
784
+ return pattern;
785
+ };
786
+ proto.createMovieClip = function(target_mc, instance_name, depth) {
787
+ var qr_mc = target_mc.createEmptyMovieClip(instance_name, depth);
788
+ var cs = 1;
789
+ this.make();
790
+ for (var row = 0; row < this.modules.length; row++) {
791
+ var y = row * cs;
792
+ for (var col = 0; col < this.modules[row].length; col++) {
793
+ var x = col * cs;
794
+ var dark = this.modules[row][col];
795
+ if (dark) {
796
+ qr_mc.beginFill(0, 100);
797
+ qr_mc.moveTo(x, y);
798
+ qr_mc.lineTo(x + cs, y);
799
+ qr_mc.lineTo(x + cs, y + cs);
800
+ qr_mc.lineTo(x, y + cs);
801
+ qr_mc.endFill();
802
+ }
803
+ }
804
+ }
805
+ return qr_mc;
806
+ };
807
+ proto.setupTimingPattern = function() {
808
+ for (var r = 8; r < this.moduleCount - 8; r++) {
809
+ if (this.modules[r][6] != null) {
810
+ continue;
811
+ }
812
+ this.modules[r][6] = r % 2 == 0;
813
+ }
814
+ for (var c = 8; c < this.moduleCount - 8; c++) {
815
+ if (this.modules[6][c] != null) {
816
+ continue;
817
+ }
818
+ this.modules[6][c] = c % 2 == 0;
819
+ }
820
+ };
821
+ proto.setupPositionAdjustPattern = function() {
822
+ var pos = util.getPatternPosition(this.typeNumber);
823
+ for (var i = 0; i < pos.length; i++) {
824
+ for (var j = 0; j < pos.length; j++) {
825
+ var row = pos[i];
826
+ var col = pos[j];
827
+ if (this.modules[row][col] != null) {
828
+ continue;
829
+ }
830
+ for (var r = -2; r <= 2; r++) {
831
+ for (var c = -2; c <= 2; c++) {
832
+ if (r == -2 || r == 2 || c == -2 || c == 2 || r == 0 && c == 0) {
833
+ this.modules[row + r][col + c] = true;
834
+ } else {
835
+ this.modules[row + r][col + c] = false;
836
+ }
837
+ }
838
+ }
839
+ }
840
+ }
841
+ };
842
+ proto.setupTypeNumber = function(test) {
843
+ var bits = util.getBCHTypeNumber(this.typeNumber);
844
+ for (var i = 0; i < 18; i++) {
845
+ var mod = !test && (bits >> i & 1) == 1;
846
+ this.modules[Math.floor(i / 3)][i % 3 + this.moduleCount - 8 - 3] = mod;
847
+ }
848
+ for (var i = 0; i < 18; i++) {
849
+ var mod = !test && (bits >> i & 1) == 1;
850
+ this.modules[i % 3 + this.moduleCount - 8 - 3][Math.floor(i / 3)] = mod;
851
+ }
852
+ };
853
+ proto.setupTypeInfo = function(test, maskPattern) {
854
+ var data = this.errorCorrectLevel << 3 | maskPattern;
855
+ var bits = util.getBCHTypeInfo(data);
856
+ for (var i = 0; i < 15; i++) {
857
+ var mod = !test && (bits >> i & 1) == 1;
858
+ if (i < 6) {
859
+ this.modules[i][8] = mod;
860
+ } else if (i < 8) {
861
+ this.modules[i + 1][8] = mod;
862
+ } else {
863
+ this.modules[this.moduleCount - 15 + i][8] = mod;
864
+ }
865
+ }
866
+ for (var i = 0; i < 15; i++) {
867
+ var mod = !test && (bits >> i & 1) == 1;
868
+ if (i < 8) {
869
+ this.modules[8][this.moduleCount - i - 1] = mod;
870
+ } else if (i < 9) {
871
+ this.modules[8][15 - i - 1 + 1] = mod;
872
+ } else {
873
+ this.modules[8][15 - i - 1] = mod;
874
+ }
875
+ }
876
+ this.modules[this.moduleCount - 8][8] = !test;
877
+ };
878
+ proto.mapData = function(data, maskPattern) {
879
+ var inc = -1;
880
+ var row = this.moduleCount - 1;
881
+ var bitIndex = 7;
882
+ var byteIndex = 0;
883
+ for (var col = this.moduleCount - 1; col > 0; col -= 2) {
884
+ if (col == 6) col--;
885
+ while (true) {
886
+ for (var c = 0; c < 2; c++) {
887
+ if (this.modules[row][col - c] == null) {
888
+ var dark = false;
889
+ if (byteIndex < data.length) {
890
+ dark = (data[byteIndex] >>> bitIndex & 1) == 1;
891
+ }
892
+ var mask = util.getMask(maskPattern, row, col - c);
893
+ if (mask) {
894
+ dark = !dark;
895
+ }
896
+ this.modules[row][col - c] = dark;
897
+ bitIndex--;
898
+ if (bitIndex == -1) {
899
+ byteIndex++;
900
+ bitIndex = 7;
901
+ }
902
+ }
903
+ }
904
+ row += inc;
905
+ if (row < 0 || this.moduleCount <= row) {
906
+ row -= inc;
907
+ inc = -inc;
908
+ break;
909
+ }
910
+ }
911
+ }
912
+ };
913
+ QRCode3.PAD0 = 236;
914
+ QRCode3.PAD1 = 17;
915
+ QRCode3.createData = function(typeNumber, errorCorrectLevel, dataList) {
916
+ var rsBlocks = RSBlock.getRSBlocks(typeNumber, errorCorrectLevel);
917
+ var buffer = new BitBuffer();
918
+ for (var i = 0; i < dataList.length; i++) {
919
+ var data = dataList[i];
920
+ buffer.put(data.mode, 4);
921
+ buffer.put(data.getLength(), util.getLengthInBits(data.mode, typeNumber));
922
+ data.write(buffer);
923
+ }
924
+ var totalDataCount = 0;
925
+ for (var i = 0; i < rsBlocks.length; i++) {
926
+ totalDataCount += rsBlocks[i].dataCount;
927
+ }
928
+ if (buffer.getLengthInBits() > totalDataCount * 8) {
929
+ throw new Error("code length overflow. (" + buffer.getLengthInBits() + ">" + totalDataCount * 8 + ")");
930
+ }
931
+ if (buffer.getLengthInBits() + 4 <= totalDataCount * 8) {
932
+ buffer.put(0, 4);
933
+ }
934
+ while (buffer.getLengthInBits() % 8 != 0) {
935
+ buffer.putBit(false);
936
+ }
937
+ while (true) {
938
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
939
+ break;
940
+ }
941
+ buffer.put(QRCode3.PAD0, 8);
942
+ if (buffer.getLengthInBits() >= totalDataCount * 8) {
943
+ break;
944
+ }
945
+ buffer.put(QRCode3.PAD1, 8);
946
+ }
947
+ return QRCode3.createBytes(buffer, rsBlocks);
948
+ };
949
+ QRCode3.createBytes = function(buffer, rsBlocks) {
950
+ var offset = 0;
951
+ var maxDcCount = 0;
952
+ var maxEcCount = 0;
953
+ var dcdata = new Array(rsBlocks.length);
954
+ var ecdata = new Array(rsBlocks.length);
955
+ for (var r = 0; r < rsBlocks.length; r++) {
956
+ var dcCount = rsBlocks[r].dataCount;
957
+ var ecCount = rsBlocks[r].totalCount - dcCount;
958
+ maxDcCount = Math.max(maxDcCount, dcCount);
959
+ maxEcCount = Math.max(maxEcCount, ecCount);
960
+ dcdata[r] = new Array(dcCount);
961
+ for (var i = 0; i < dcdata[r].length; i++) {
962
+ dcdata[r][i] = 255 & buffer.buffer[i + offset];
963
+ }
964
+ offset += dcCount;
965
+ var rsPoly = util.getErrorCorrectPolynomial(ecCount);
966
+ var rawPoly = new Polynomial(dcdata[r], rsPoly.getLength() - 1);
967
+ var modPoly = rawPoly.mod(rsPoly);
968
+ ecdata[r] = new Array(rsPoly.getLength() - 1);
969
+ for (var i = 0; i < ecdata[r].length; i++) {
970
+ var modIndex = i + modPoly.getLength() - ecdata[r].length;
971
+ ecdata[r][i] = modIndex >= 0 ? modPoly.get(modIndex) : 0;
972
+ }
973
+ }
974
+ var totalCodeCount = 0;
975
+ for (var i = 0; i < rsBlocks.length; i++) {
976
+ totalCodeCount += rsBlocks[i].totalCount;
977
+ }
978
+ var data = new Array(totalCodeCount);
979
+ var index = 0;
980
+ for (var i = 0; i < maxDcCount; i++) {
981
+ for (var r = 0; r < rsBlocks.length; r++) {
982
+ if (i < dcdata[r].length) {
983
+ data[index++] = dcdata[r][i];
984
+ }
985
+ }
986
+ }
987
+ for (var i = 0; i < maxEcCount; i++) {
988
+ for (var r = 0; r < rsBlocks.length; r++) {
989
+ if (i < ecdata[r].length) {
990
+ data[index++] = ecdata[r][i];
991
+ }
992
+ }
993
+ }
994
+ return data;
995
+ };
996
+ module.exports = QRCode3;
997
+ }
998
+ });
7
999
 
8
1000
  // src/constants.ts
9
1001
  var LOGO_POLLAR = "https://pollar.xyz/assets/logo_pollar.png";
@@ -36,7 +1028,7 @@ var PollarModalFooter = () => {
36
1028
  /* @__PURE__ */ jsx("span", { className: "pollar-footer-name", children: "Pollar" }),
37
1029
  /* @__PURE__ */ jsxs("span", { className: "pollar-footer-version", children: [
38
1030
  "v",
39
- "0.5.3"
1031
+ "0.7.0"
40
1032
  ] })
41
1033
  ] })
42
1034
  ] });
@@ -169,8 +1161,8 @@ function KycModal({ onClose, country = "MX", level = "basic", onApproved }) {
169
1161
  const { theme = "light", accentColor = "#005DB4" } = styles;
170
1162
  useEffect(() => {
171
1163
  setIsLoading(true);
172
- client.getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
173
- }, [country]);
1164
+ getClient().getKycProviders(country).then((result) => setProviders(result.providers)).catch(() => setProviders([])).finally(() => setIsLoading(false));
1165
+ }, [getClient, country]);
174
1166
  async function handleSelectProvider(provider) {
175
1167
  setSelectedProvider(provider);
176
1168
  setIsLoading(true);
@@ -501,10 +1493,12 @@ function LoginModalTemplate({
501
1493
  }
502
1494
  function LoginModal({ onClose }) {
503
1495
  const [email, setEmail] = useState("");
504
- const { getClient, styles, config } = usePollar();
1496
+ const { getClient, styles, appConfig: config } = usePollar();
505
1497
  const [authState, setAuthState] = useState(() => getClient().getAuthState());
506
1498
  const [codeInputKey, setCodeInputKey] = useState(0);
507
1499
  const pendingEmail = useRef(null);
1500
+ const onCloseRef = useRef(onClose);
1501
+ onCloseRef.current = onClose;
508
1502
  useEffect(() => {
509
1503
  return getClient().onAuthStateChange((next) => {
510
1504
  setAuthState(next);
@@ -516,10 +1510,10 @@ function LoginModal({ onClose }) {
516
1510
  setCodeInputKey((k) => k + 1);
517
1511
  }
518
1512
  if (next.step === "authenticated") {
519
- setTimeout(onClose, 1e3);
1513
+ setTimeout(onCloseRef.current, 1e3);
520
1514
  }
521
1515
  });
522
- }, []);
1516
+ }, [getClient]);
523
1517
  const { theme = "light", accentColor = "#005DB4", logoUrl, emailEnabled, embeddedWallets, providers } = styles;
524
1518
  function handleClose() {
525
1519
  setEmail("");
@@ -581,70 +1575,60 @@ function LoginModal({ onClose }) {
581
1575
  }
582
1576
  ) });
583
1577
  }
584
- var RAIL_LABELS = {
585
- SPEI: "SPEI (Mexico)",
586
- PIX: "PIX (Brazil)",
587
- PSE: "PSE (Colombia)",
588
- ACH: "ACH (US)"
589
- };
590
- function RouteDisplay({ quote, onSelect }) {
591
- return /* @__PURE__ */ jsxs(
592
- "div",
1578
+
1579
+ // src/lib/qr-code/index.tsx
1580
+ var import_ErrorCorrectLevel = __toESM(require_ErrorCorrectLevel());
1581
+ var import_QRCode = __toESM(require_QRCode());
1582
+ var QRCodeSvg = forwardRef(function QRCodeSvg2({
1583
+ bgColor,
1584
+ bgD,
1585
+ fgD,
1586
+ fgColor,
1587
+ size,
1588
+ title,
1589
+ viewBoxSize,
1590
+ xmlns = "http://www.w3.org/2000/svg",
1591
+ ...props
1592
+ }, ref) {
1593
+ return /* @__PURE__ */ jsxs("svg", { ...props, height: size, ref, viewBox: `0 0 ${viewBoxSize} ${viewBoxSize}`, width: size, xmlns, children: [
1594
+ title ? /* @__PURE__ */ jsx("title", { children: title }) : null,
1595
+ /* @__PURE__ */ jsx("path", { d: bgD, fill: bgColor }),
1596
+ /* @__PURE__ */ jsx("path", { d: fgD, fill: fgColor })
1597
+ ] });
1598
+ });
1599
+ QRCodeSvg.displayName = "QRCodeSvg";
1600
+ function bytesToBinaryString(bytes) {
1601
+ return bytes.map((b) => String.fromCharCode(b & 255)).join("");
1602
+ }
1603
+ function encodeStringToUtf8Bytes(input) {
1604
+ return Array.from(new TextEncoder().encode(input));
1605
+ }
1606
+ var QRCode = forwardRef(function QRCode2({ bgColor = "#FFFFFF", fgColor = "#000000", level = "L", size = 256, value, ...props }, ref) {
1607
+ const qrcode = new import_QRCode.default(-1, import_ErrorCorrectLevel.default[level]);
1608
+ const utf8Bytes = encodeStringToUtf8Bytes(value);
1609
+ const binaryString = bytesToBinaryString(utf8Bytes);
1610
+ qrcode.addData(binaryString, "Byte");
1611
+ qrcode.make();
1612
+ const cells = qrcode.modules;
1613
+ return /* @__PURE__ */ jsx(
1614
+ QRCodeSvg,
593
1615
  {
594
- className: "pollar-ramp-route-card",
595
- "data-recommended": quote.recommended,
596
- role: "button",
597
- tabIndex: 0,
598
- onClick: () => onSelect(quote),
599
- onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
600
- children: [
601
- /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-left", children: [
602
- /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
603
- /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-meta", children: [
604
- RAIL_LABELS[quote.rail] ?? quote.rail,
605
- " \xB7 ",
606
- quote.protocol,
607
- " \xB7 ",
608
- quote.estimatedTime
609
- ] })
610
- ] }),
611
- /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-right", children: [
612
- /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-fee", children: [
613
- quote.fee,
614
- "% fee"
615
- ] }),
616
- quote.recommended && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
617
- ] })
618
- ]
1616
+ ...props,
1617
+ bgColor,
1618
+ bgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => !cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
1619
+ fgColor,
1620
+ fgD: cells.map((row, rowIndex) => row.map((cell, cellIndex) => cell ? `M ${cellIndex} ${rowIndex} l 1 0 0 1 -1 0 Z` : "").join(" ")).join(" "),
1621
+ ref,
1622
+ size,
1623
+ viewBoxSize: cells.length
619
1624
  }
620
1625
  );
621
- }
622
- var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
623
- var COUNTRY_CURRENCIES = {
624
- MX: "MXN",
625
- BR: "BRL",
626
- CO: "COP",
627
- CL: "CLP",
628
- PE: "PEN",
629
- AR: "ARS"
630
- };
631
- function RampWidgetTemplate({
1626
+ });
1627
+ function ReceiveModalTemplate({
632
1628
  theme,
633
1629
  accentColor,
634
- step,
635
- direction,
636
- amount,
637
- currency,
638
- country,
639
- quotes,
640
- paymentInstructions,
641
- isLoading,
642
- onDirectionChange,
643
- onAmountChange,
644
- onCurrencyChange,
645
- onCountryChange,
646
- onFindRoute,
647
- onSelectQuote,
1630
+ walletAddress,
1631
+ copied,
648
1632
  onCopy,
649
1633
  onClose
650
1634
  }) {
@@ -664,13 +1648,183 @@ function RampWidgetTemplate({
664
1648
  "--pollar-buttons-height": "44px",
665
1649
  "--pollar-input-height": "44px",
666
1650
  "--pollar-input-border-radius": "0.5rem",
667
- "--pollar-card-border-radius": "10px",
668
- "--pollar-modal-padding": "2rem",
669
- "--pollar-modal-heading-size": "1.375rem",
670
- "--pollar-modal-subtitle-size": "0.9rem"
1651
+ "--pollar-card-border-radius": "10px"
671
1652
  };
672
- const stepTitle = {
673
- input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
1653
+ return /* @__PURE__ */ jsxs(
1654
+ "div",
1655
+ {
1656
+ className: "pollar-modal-card pollar-receive-modal",
1657
+ "data-theme": theme,
1658
+ style: cssVars,
1659
+ onClick: (e) => e.stopPropagation(),
1660
+ children: [
1661
+ /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
1662
+ /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Receive" }),
1663
+ /* @__PURE__ */ jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
1664
+ ] }),
1665
+ walletAddress ? /* @__PURE__ */ jsxs(Fragment, { children: [
1666
+ /* @__PURE__ */ jsx("div", { className: "pollar-receive-qr", children: /* @__PURE__ */ jsx(
1667
+ QRCode,
1668
+ {
1669
+ value: walletAddress,
1670
+ size: 180,
1671
+ fgColor: isDark ? "#ffffff" : "#111827",
1672
+ bgColor: "transparent"
1673
+ }
1674
+ ) }),
1675
+ /* @__PURE__ */ jsx("p", { className: "pollar-receive-instructions", children: "Share your Stellar address to receive any asset. Only send Stellar assets to this address." }),
1676
+ /* @__PURE__ */ jsxs("div", { className: "pollar-receive-address-row", children: [
1677
+ /* @__PURE__ */ jsx("span", { className: "pollar-receive-address", children: walletAddress }),
1678
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-receive-copy-btn", onClick: onCopy, "aria-label": "Copy address", children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
1679
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
1680
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
1681
+ /* @__PURE__ */ jsx(
1682
+ "path",
1683
+ {
1684
+ d: "M3.5 7l2.5 2.5 4.5-5",
1685
+ stroke: "white",
1686
+ strokeWidth: "1.5",
1687
+ strokeLinecap: "round",
1688
+ strokeLinejoin: "round"
1689
+ }
1690
+ )
1691
+ ] }),
1692
+ "Copied!"
1693
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1694
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1695
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
1696
+ /* @__PURE__ */ jsx(
1697
+ "path",
1698
+ {
1699
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1700
+ stroke: "currentColor",
1701
+ strokeWidth: "1.5",
1702
+ strokeLinecap: "round"
1703
+ }
1704
+ )
1705
+ ] }),
1706
+ "Copy address"
1707
+ ] }) })
1708
+ ] })
1709
+ ] }) : /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No wallet connected." }),
1710
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
1711
+ ]
1712
+ }
1713
+ );
1714
+ }
1715
+ function ReceiveModal({ onClose }) {
1716
+ const { walletAddress, styles } = usePollar();
1717
+ const { theme = "light", accentColor = "#005DB4" } = styles;
1718
+ const [copied, setCopied] = useState(false);
1719
+ function handleCopy() {
1720
+ if (!walletAddress) return;
1721
+ navigator.clipboard.writeText(walletAddress).then(() => {
1722
+ setCopied(true);
1723
+ setTimeout(() => setCopied(false), 2e3);
1724
+ });
1725
+ }
1726
+ return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
1727
+ ReceiveModalTemplate,
1728
+ {
1729
+ theme,
1730
+ accentColor,
1731
+ walletAddress,
1732
+ copied,
1733
+ onCopy: handleCopy,
1734
+ onClose
1735
+ }
1736
+ ) });
1737
+ }
1738
+ var RAIL_LABELS = {
1739
+ SPEI: "SPEI (Mexico)",
1740
+ PIX: "PIX (Brazil)",
1741
+ PSE: "PSE (Colombia)",
1742
+ ACH: "ACH (US)"
1743
+ };
1744
+ function RouteDisplay({ quote, onSelect }) {
1745
+ return /* @__PURE__ */ jsxs(
1746
+ "div",
1747
+ {
1748
+ className: "pollar-ramp-route-card",
1749
+ "data-recommended": quote.recommended,
1750
+ role: "button",
1751
+ tabIndex: 0,
1752
+ onClick: () => onSelect(quote),
1753
+ onKeyDown: (e) => e.key === "Enter" && onSelect(quote),
1754
+ children: [
1755
+ /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-left", children: [
1756
+ /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-provider", children: quote.provider }),
1757
+ /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-meta", children: [
1758
+ RAIL_LABELS[quote.rail] ?? quote.rail,
1759
+ " \xB7 ",
1760
+ quote.protocol,
1761
+ " \xB7 ",
1762
+ quote.estimatedTime
1763
+ ] })
1764
+ ] }),
1765
+ /* @__PURE__ */ jsxs("div", { className: "pollar-ramp-route-right", children: [
1766
+ /* @__PURE__ */ jsxs("span", { className: "pollar-ramp-route-fee", children: [
1767
+ quote.fee,
1768
+ "% fee"
1769
+ ] }),
1770
+ quote.recommended && /* @__PURE__ */ jsx("span", { className: "pollar-ramp-route-badge", children: "Best rate" })
1771
+ ] })
1772
+ ]
1773
+ }
1774
+ );
1775
+ }
1776
+ var LOADING_STEPS = ["Detecting your country\u2026", "Consulting providers\u2026", "Route found!"];
1777
+ var COUNTRY_CURRENCIES = {
1778
+ MX: "MXN",
1779
+ BR: "BRL",
1780
+ CO: "COP",
1781
+ CL: "CLP",
1782
+ PE: "PEN",
1783
+ AR: "ARS"
1784
+ };
1785
+ function RampWidgetTemplate({
1786
+ theme,
1787
+ accentColor,
1788
+ step,
1789
+ direction,
1790
+ amount,
1791
+ currency,
1792
+ country,
1793
+ quotes,
1794
+ paymentInstructions,
1795
+ isLoading,
1796
+ onDirectionChange,
1797
+ onAmountChange,
1798
+ onCurrencyChange,
1799
+ onCountryChange,
1800
+ onFindRoute,
1801
+ onSelectQuote,
1802
+ onCopy,
1803
+ onClose
1804
+ }) {
1805
+ const isDark = theme === "dark";
1806
+ const cssVars = {
1807
+ "--pollar-accent": accentColor,
1808
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
1809
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
1810
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
1811
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
1812
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
1813
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
1814
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
1815
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
1816
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
1817
+ "--pollar-buttons-border-radius": "6px",
1818
+ "--pollar-buttons-height": "44px",
1819
+ "--pollar-input-height": "44px",
1820
+ "--pollar-input-border-radius": "0.5rem",
1821
+ "--pollar-card-border-radius": "10px",
1822
+ "--pollar-modal-padding": "2rem",
1823
+ "--pollar-modal-heading-size": "1.375rem",
1824
+ "--pollar-modal-subtitle-size": "0.9rem"
1825
+ };
1826
+ const stepTitle = {
1827
+ input: direction === "onramp" ? "Buy crypto" : "Sell crypto",
674
1828
  loading_quote: "Finding best route",
675
1829
  select_route: "Select provider",
676
1830
  payment_instructions: "Payment instructions"
@@ -903,38 +2057,18 @@ var STATUS_MESSAGES = {
903
2057
  success: "Transaction sent successfully",
904
2058
  error: "Transaction failed"
905
2059
  };
906
- function TransactionModalTemplate({
907
- theme,
908
- accentColor,
2060
+ function TxStatusView({
909
2061
  transaction,
910
2062
  showXdr,
911
2063
  copied,
912
2064
  explorerUrl,
913
2065
  walletType,
914
- onClose,
915
2066
  onSignAndSend,
916
2067
  onToggleXdr,
917
2068
  onCopyHash,
918
- onRetry
2069
+ onRetry,
2070
+ onDone
919
2071
  }) {
920
- const isDark = theme === "dark";
921
- const cssVars = {
922
- "--pollar-accent": accentColor,
923
- "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
924
- "--pollar-border": isDark ? "#374151" : "#e5e7eb",
925
- "--pollar-text": isDark ? "#ffffff" : "#111827",
926
- "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
927
- "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
928
- "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
929
- "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
930
- "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
931
- "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
932
- "--pollar-buttons-border-radius": "6px",
933
- "--pollar-buttons-height": "44px",
934
- "--pollar-input-height": "44px",
935
- "--pollar-input-border-radius": "0.5rem",
936
- "--pollar-card-border-radius": "10px"
937
- };
938
2072
  const buildData = "buildData" in transaction ? transaction.buildData : null;
939
2073
  const hash = transaction.step === "success" ? transaction.hash : null;
940
2074
  const errorDetails = transaction.step === "error" ? transaction.details ?? null : null;
@@ -943,23 +2077,9 @@ function TransactionModalTemplate({
943
2077
  const isSuccess = transaction.step === "success";
944
2078
  const isError = transaction.step === "error";
945
2079
  const showDetails = buildData !== null && (isBuilt || isSigning || isSuccess);
946
- return /* @__PURE__ */ jsxs("div", { className: "pollar-modal-card pollar-tx-modal", "data-theme": theme, style: cssVars, onClick: (e) => e.stopPropagation(), children: [
947
- /* @__PURE__ */ jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
948
- /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(
949
- "svg",
950
- {
951
- width: "18",
952
- height: "18",
953
- viewBox: "0 0 24 24",
954
- fill: "none",
955
- stroke: "currentColor",
956
- strokeWidth: "2.5",
957
- strokeLinecap: "round",
958
- strokeLinejoin: "round",
959
- "aria-hidden": true,
960
- children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
961
- }
962
- ) }),
2080
+ const walletImg = walletType === WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR;
2081
+ const walletAlt = walletType === WalletType.FREIGHTER ? "Freighter" : walletType === WalletType.ALBEDO ? "Albedo" : "Pollar";
2082
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
963
2083
  showDetails && buildData && /* @__PURE__ */ jsxs(Fragment, { children: [
964
2084
  /* @__PURE__ */ jsxs("div", { className: "pollar-tx-summary", children: [
965
2085
  /* @__PURE__ */ jsx("p", { className: "pollar-tx-summary-title", children: "Details" }),
@@ -1004,116 +2124,707 @@ function TransactionModalTemplate({
1004
2124
  /* @__PURE__ */ jsxs(
1005
2125
  "svg",
1006
2126
  {
1007
- viewBox: "0 0 88 88",
1008
- width: "88",
1009
- height: "88",
1010
- className: `pollar-tx-spinner-svg${isSigning ? " pollar-tx-spinner-rotating" : ""}`,
2127
+ viewBox: "0 0 88 88",
2128
+ width: "88",
2129
+ height: "88",
2130
+ className: `pollar-tx-spinner-svg${isSigning ? " pollar-tx-spinner-rotating" : ""}`,
2131
+ "aria-hidden": true,
2132
+ children: [
2133
+ /* @__PURE__ */ jsx("circle", { cx: "44", cy: "44", r: "36", fill: "none", stroke: "var(--pollar-border)", strokeWidth: "3" }),
2134
+ /* @__PURE__ */ jsx(
2135
+ "circle",
2136
+ {
2137
+ cx: "44",
2138
+ cy: "44",
2139
+ r: "36",
2140
+ fill: "none",
2141
+ stroke: isSuccess ? "var(--pollar-success-text)" : isError ? "var(--pollar-error-text)" : "var(--pollar-accent)",
2142
+ strokeWidth: "3",
2143
+ strokeLinecap: "round",
2144
+ strokeDasharray: isSigning ? "169.6 56.6" : "999 0",
2145
+ transform: "rotate(-90 44 44)",
2146
+ style: { transition: isSigning ? "none" : "stroke 400ms, stroke-dasharray 400ms" }
2147
+ }
2148
+ )
2149
+ ]
2150
+ }
2151
+ ),
2152
+ /* @__PURE__ */ jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsx("img", { src: walletImg, alt: walletAlt, className: "pollar-tx-wallet-img" }) })
2153
+ ] }),
2154
+ isSigning && /* @__PURE__ */ jsx("p", { className: "pollar-tx-spinner-label", children: walletType === WalletType.FREIGHTER ? "Waiting for Freighter\u2026" : walletType === WalletType.ALBEDO ? "Waiting for Albedo\u2026" : "Signing and sending\u2026" }),
2155
+ isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
2156
+ ] }),
2157
+ isSuccess && hash && /* @__PURE__ */ jsxs("div", { className: "pollar-tx-result", children: [
2158
+ /* @__PURE__ */ jsx("span", { className: "pollar-tx-result-label", children: "Transaction hash" }),
2159
+ /* @__PURE__ */ jsx("span", { className: "pollar-tx-result-hash", children: hash }),
2160
+ /* @__PURE__ */ jsxs("div", { className: "pollar-tx-result-actions", children: [
2161
+ /* @__PURE__ */ jsx("button", { className: "pollar-tx-result-btn", onClick: onCopyHash, children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
2162
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
2163
+ /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
2164
+ /* @__PURE__ */ jsx(
2165
+ "path",
2166
+ {
2167
+ d: "M3.5 7l2.5 2.5 4.5-5",
2168
+ stroke: "white",
2169
+ strokeWidth: "1.5",
2170
+ strokeLinecap: "round",
2171
+ strokeLinejoin: "round"
2172
+ }
2173
+ )
2174
+ ] }),
2175
+ "Copied!"
2176
+ ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
2177
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
2178
+ /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
2179
+ /* @__PURE__ */ jsx(
2180
+ "path",
2181
+ {
2182
+ d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
2183
+ stroke: "currentColor",
2184
+ strokeWidth: "1.5",
2185
+ strokeLinecap: "round"
2186
+ }
2187
+ )
2188
+ ] }),
2189
+ "Copy hash"
2190
+ ] }) }),
2191
+ explorerUrl && /* @__PURE__ */ jsxs("a", { className: "pollar-tx-result-btn", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", children: [
2192
+ /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
2193
+ /* @__PURE__ */ jsx(
2194
+ "path",
2195
+ {
2196
+ d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8",
2197
+ stroke: "currentColor",
2198
+ strokeWidth: "1.5",
2199
+ strokeLinecap: "round"
2200
+ }
2201
+ ),
2202
+ /* @__PURE__ */ jsx(
2203
+ "path",
2204
+ {
2205
+ d: "M8 1h4m0 0v4m0-4L6 7",
2206
+ stroke: "currentColor",
2207
+ strokeWidth: "1.5",
2208
+ strokeLinecap: "round",
2209
+ strokeLinejoin: "round"
2210
+ }
2211
+ )
2212
+ ] }),
2213
+ "View on Explorer"
2214
+ ] })
2215
+ ] })
2216
+ ] }),
2217
+ isSuccess && /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onDone, children: "Done" }),
2218
+ /* @__PURE__ */ jsx(
2219
+ ModalStatusBanner,
2220
+ {
2221
+ message: STATUS_MESSAGES[transaction.step],
2222
+ status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
2223
+ }
2224
+ )
2225
+ ] });
2226
+ }
2227
+ function formatBalance(balance) {
2228
+ const n = parseFloat(balance);
2229
+ return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
2230
+ }
2231
+ function assetKey(record) {
2232
+ return `${record.code}:${record.issuer ?? "native"}`;
2233
+ }
2234
+ function SendModalTemplate({
2235
+ theme,
2236
+ accentColor,
2237
+ step,
2238
+ txTitle,
2239
+ assets,
2240
+ selectedAsset,
2241
+ amount,
2242
+ destination,
2243
+ formError,
2244
+ isLoadingBalance,
2245
+ transaction,
2246
+ showXdr,
2247
+ copied,
2248
+ explorerUrl,
2249
+ walletType,
2250
+ showBack,
2251
+ isInProgress,
2252
+ onClose,
2253
+ onBack,
2254
+ onSelectAsset,
2255
+ onAmountChange,
2256
+ onDestinationChange,
2257
+ onSubmit,
2258
+ onSignAndSend,
2259
+ onToggleXdr,
2260
+ onCopyHash,
2261
+ onRetry,
2262
+ onDone
2263
+ }) {
2264
+ const isDark = theme === "dark";
2265
+ const cssVars = {
2266
+ "--pollar-accent": accentColor,
2267
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2268
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2269
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2270
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2271
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2272
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2273
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2274
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2275
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2276
+ "--pollar-buttons-border-radius": "6px",
2277
+ "--pollar-buttons-height": "44px",
2278
+ "--pollar-input-height": "44px",
2279
+ "--pollar-input-border-radius": "0.5rem",
2280
+ "--pollar-card-border-radius": "10px"
2281
+ };
2282
+ const enabledAssets = assets.filter((a) => a.enabledInApp);
2283
+ const otherAssets = assets.filter((a) => !a.enabledInApp);
2284
+ const selectedKey = selectedAsset ? assetKey(selectedAsset) : "";
2285
+ const canSubmit = !!selectedAsset && !!amount && !!destination.trim() && !isLoadingBalance;
2286
+ const title = step === "form" ? "Send" : txTitle;
2287
+ return /* @__PURE__ */ jsxs(
2288
+ "div",
2289
+ {
2290
+ className: "pollar-modal-card pollar-send-modal",
2291
+ "data-theme": theme,
2292
+ style: cssVars,
2293
+ onClick: (e) => e.stopPropagation(),
2294
+ children: [
2295
+ /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
2296
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-header-left", children: [
2297
+ showBack && /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onBack, "aria-label": "Back", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M10 3L5 8l5 5", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }) }),
2298
+ /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: title })
2299
+ ] }),
2300
+ !isInProgress && /* @__PURE__ */ jsx("div", { className: "pollar-modal-header-actions", children: /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) }) })
2301
+ ] }),
2302
+ step === "form" && /* @__PURE__ */ jsxs(Fragment, { children: [
2303
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
2304
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Asset" }),
2305
+ isLoadingBalance ? /* @__PURE__ */ jsx("div", { className: "pollar-send-skeleton" }) : /* @__PURE__ */ jsxs(
2306
+ "select",
2307
+ {
2308
+ className: "pollar-input pollar-send-select",
2309
+ value: selectedKey,
2310
+ onChange: (e) => {
2311
+ const all = [...enabledAssets, ...otherAssets];
2312
+ const found = all.find((a) => assetKey(a) === e.target.value);
2313
+ if (found) onSelectAsset(found);
2314
+ },
2315
+ children: [
2316
+ /* @__PURE__ */ jsx("option", { value: "", disabled: true, children: "Select asset" }),
2317
+ enabledAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: "App assets", children: enabledAssets.map((a) => /* @__PURE__ */ jsxs("option", { value: assetKey(a), children: [
2318
+ a.code,
2319
+ " \u2014 ",
2320
+ formatBalance(a.available),
2321
+ " available"
2322
+ ] }, assetKey(a))) }),
2323
+ otherAssets.length > 0 && /* @__PURE__ */ jsx("optgroup", { label: "Other assets", children: otherAssets.map((a) => /* @__PURE__ */ jsxs("option", { value: assetKey(a), children: [
2324
+ a.code,
2325
+ " \u2014 ",
2326
+ formatBalance(a.available),
2327
+ " available"
2328
+ ] }, assetKey(a))) })
2329
+ ]
2330
+ }
2331
+ )
2332
+ ] }),
2333
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
2334
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-label-row", children: [
2335
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Amount" }),
2336
+ selectedAsset && /* @__PURE__ */ jsxs("span", { className: "pollar-send-hint", children: [
2337
+ "Available: ",
2338
+ formatBalance(selectedAsset.available),
2339
+ " ",
2340
+ selectedAsset.code
2341
+ ] })
2342
+ ] }),
2343
+ /* @__PURE__ */ jsx(
2344
+ "input",
2345
+ {
2346
+ className: "pollar-input",
2347
+ type: "text",
2348
+ inputMode: "decimal",
2349
+ placeholder: "0.00",
2350
+ value: amount,
2351
+ onChange: (e) => onAmountChange(e.target.value)
2352
+ }
2353
+ )
2354
+ ] }),
2355
+ /* @__PURE__ */ jsxs("div", { className: "pollar-send-field", children: [
2356
+ /* @__PURE__ */ jsx("label", { className: "pollar-send-label", children: "Destination wallet" }),
2357
+ /* @__PURE__ */ jsx(
2358
+ "input",
2359
+ {
2360
+ className: "pollar-input",
2361
+ type: "text",
2362
+ placeholder: "G\u2026",
2363
+ value: destination,
2364
+ onChange: (e) => onDestinationChange(e.target.value)
2365
+ }
2366
+ )
2367
+ ] }),
2368
+ formError && /* @__PURE__ */ jsx("div", { className: "pollar-modal-error", children: formError }),
2369
+ /* @__PURE__ */ jsx("div", { className: "pollar-modal-actions", children: /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary", onClick: onSubmit, disabled: !canSubmit, children: "Continue" }) })
2370
+ ] }),
2371
+ step === "tx" && /* @__PURE__ */ jsx(
2372
+ TxStatusView,
2373
+ {
2374
+ transaction,
2375
+ showXdr,
2376
+ copied,
2377
+ explorerUrl,
2378
+ walletType,
2379
+ onSignAndSend,
2380
+ onToggleXdr,
2381
+ onCopyHash,
2382
+ onRetry,
2383
+ onDone
2384
+ }
2385
+ ),
2386
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
2387
+ ]
2388
+ }
2389
+ );
2390
+ }
2391
+ function assetParam(record) {
2392
+ if (record.type === "native") return { type: "native" };
2393
+ if (record.type === "credit_alphanum4") {
2394
+ return { type: "credit_alphanum4", code: record.code, issuer: record.issuer };
2395
+ }
2396
+ return { type: "credit_alphanum12", code: record.code, issuer: record.issuer };
2397
+ }
2398
+ function SendModal({ onClose }) {
2399
+ const { walletBalance, refreshWalletBalance, buildTx, signAndSubmitTx, tx: transaction, walletType, network, styles } = usePollar();
2400
+ const { theme = "light", accentColor = "#005DB4" } = styles;
2401
+ const [step, setStep] = useState("form");
2402
+ const [amount, setAmount] = useState("");
2403
+ const [destination, setDestination] = useState("");
2404
+ const [selectedAsset, setSelectedAsset] = useState(null);
2405
+ const [showXdr, setShowXdr] = useState(false);
2406
+ const [copied, setCopied] = useState(false);
2407
+ const [formError, setFormError] = useState("");
2408
+ useEffect(() => {
2409
+ void refreshWalletBalance();
2410
+ }, [refreshWalletBalance]);
2411
+ const balanceData = walletBalance.step === "loaded" ? walletBalance.data : null;
2412
+ const allAssets = balanceData?.balances ?? [];
2413
+ const sortedAssets = [
2414
+ ...allAssets.filter((b) => b.enabledInApp),
2415
+ ...allAssets.filter((b) => !b.enabledInApp && parseFloat(b.balance) > 0)
2416
+ ];
2417
+ const hash = transaction.step === "success" ? transaction.hash : null;
2418
+ const buildData = "buildData" in transaction ? transaction.buildData : null;
2419
+ const explorerNetwork = buildData?.summary.network?.toLowerCase().includes("testnet") ? "testnet" : buildData ? "public" : network === "testnet" ? "testnet" : "public";
2420
+ const explorerUrl = hash ? `https://stellar.expert/explorer/${explorerNetwork}/tx/${hash}` : null;
2421
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
2422
+ const showBack = step === "tx" && (transaction.step === "error" || transaction.step === "success") && !isInProgress;
2423
+ const txTitle = transaction.step === "signing" ? "Sending\u2026" : transaction.step === "success" ? "Sent!" : transaction.step === "error" ? "Send failed" : "Confirm Send";
2424
+ async function handleSubmit() {
2425
+ setFormError("");
2426
+ if (!selectedAsset) {
2427
+ setFormError("Select an asset");
2428
+ return;
2429
+ }
2430
+ const parsed = parseFloat(amount);
2431
+ if (!amount || isNaN(parsed) || parsed <= 0) {
2432
+ setFormError("Enter a valid amount");
2433
+ return;
2434
+ }
2435
+ if (parsed > parseFloat(selectedAsset.available)) {
2436
+ setFormError("Insufficient balance");
2437
+ return;
2438
+ }
2439
+ if (!destination.trim()) {
2440
+ setFormError("Enter a destination address");
2441
+ return;
2442
+ }
2443
+ setStep("tx");
2444
+ await buildTx("payment", { destination: destination.trim(), amount, asset: assetParam(selectedAsset) });
2445
+ }
2446
+ function handleSignAndSend() {
2447
+ if (transaction.step === "built") {
2448
+ void signAndSubmitTx(transaction.buildData.unsignedXdr);
2449
+ }
2450
+ }
2451
+ function handleCopyHash() {
2452
+ if (!hash) return;
2453
+ navigator.clipboard.writeText(hash).then(() => {
2454
+ setCopied(true);
2455
+ setTimeout(() => setCopied(false), 2e3);
2456
+ });
2457
+ }
2458
+ async function handleRetry() {
2459
+ if (transaction.step === "error" && transaction.buildData) {
2460
+ await signAndSubmitTx(transaction.buildData.unsignedXdr);
2461
+ }
2462
+ }
2463
+ function handleBack() {
2464
+ setStep("form");
2465
+ setShowXdr(false);
2466
+ setCopied(false);
2467
+ }
2468
+ return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: !isInProgress ? onClose : void 0, children: /* @__PURE__ */ jsx(
2469
+ SendModalTemplate,
2470
+ {
2471
+ theme,
2472
+ accentColor,
2473
+ step,
2474
+ txTitle,
2475
+ assets: sortedAssets,
2476
+ selectedAsset,
2477
+ amount,
2478
+ destination,
2479
+ formError,
2480
+ isLoadingBalance: walletBalance.step === "loading",
2481
+ transaction,
2482
+ showXdr,
2483
+ copied,
2484
+ explorerUrl,
2485
+ walletType,
2486
+ showBack,
2487
+ isInProgress,
2488
+ onClose,
2489
+ onBack: handleBack,
2490
+ onSelectAsset: setSelectedAsset,
2491
+ onAmountChange: setAmount,
2492
+ onDestinationChange: setDestination,
2493
+ onSubmit: () => void handleSubmit(),
2494
+ onSignAndSend: handleSignAndSend,
2495
+ onToggleXdr: () => setShowXdr((v) => !v),
2496
+ onCopyHash: handleCopyHash,
2497
+ onRetry: () => void handleRetry(),
2498
+ onDone: onClose
2499
+ }
2500
+ ) });
2501
+ }
2502
+ function describeDevice(s) {
2503
+ if (s.deviceLabel) return s.deviceLabel;
2504
+ if (!s.userAgent) return "Unknown device";
2505
+ return parseUserAgent(s.userAgent);
2506
+ }
2507
+ function detectBrowser(ua) {
2508
+ if (/Edg\//.test(ua)) return "Edge";
2509
+ if (/OPR\//.test(ua)) return "Opera";
2510
+ if (/(Chrome|CriOS)\//.test(ua)) return "Chrome";
2511
+ if (/(Firefox|FxiOS)\//.test(ua)) return "Firefox";
2512
+ if (/Safari\//.test(ua)) return "Safari";
2513
+ return null;
2514
+ }
2515
+ function detectOS(ua) {
2516
+ if (/iPhone|iPad|iPod/.test(ua)) return "iOS";
2517
+ if (/Android/.test(ua)) return "Android";
2518
+ if (/Mac OS X/.test(ua)) return "macOS";
2519
+ if (/Windows NT/.test(ua)) return "Windows";
2520
+ if (/Linux/.test(ua)) return "Linux";
2521
+ return null;
2522
+ }
2523
+ function parseUserAgent(ua) {
2524
+ const browser = detectBrowser(ua);
2525
+ const os = detectOS(ua);
2526
+ if (browser && os) return `${os} \u2014 ${browser}`;
2527
+ if (os) return os;
2528
+ if (browser) return browser;
2529
+ return ua.slice(0, 48);
2530
+ }
2531
+ function formatRelative(iso) {
2532
+ if (!iso) return "\u2014";
2533
+ const ts = new Date(iso).getTime();
2534
+ if (!Number.isFinite(ts)) return "\u2014";
2535
+ const diffSec = Math.round((Date.now() - ts) / 1e3);
2536
+ if (diffSec < 0) return "just now";
2537
+ if (diffSec < 60) return `${diffSec}s ago`;
2538
+ const diffMin = Math.round(diffSec / 60);
2539
+ if (diffMin < 60) return `${diffMin}m ago`;
2540
+ const diffHr = Math.round(diffMin / 60);
2541
+ if (diffHr < 24) return `${diffHr}h ago`;
2542
+ const diffDay = Math.round(diffHr / 24);
2543
+ if (diffDay < 30) return `${diffDay}d ago`;
2544
+ return new Date(iso).toLocaleDateString(void 0, { month: "short", day: "numeric", year: "numeric" });
2545
+ }
2546
+ function shortIp(hash) {
2547
+ if (!hash) return "";
2548
+ return hash.slice(0, 8);
2549
+ }
2550
+ function SessionsModalTemplate({
2551
+ theme,
2552
+ accentColor,
2553
+ state,
2554
+ revokingFamilyId,
2555
+ signingOutEverywhere,
2556
+ onRefresh,
2557
+ onRevoke,
2558
+ onLogoutEverywhere,
2559
+ onClose
2560
+ }) {
2561
+ const isDark = theme === "dark";
2562
+ const cssVars = {
2563
+ "--pollar-accent": accentColor,
2564
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2565
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2566
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2567
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2568
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2569
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2570
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2571
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2572
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2573
+ "--pollar-buttons-border-radius": "6px",
2574
+ "--pollar-buttons-height": "44px",
2575
+ "--pollar-input-height": "44px",
2576
+ "--pollar-input-border-radius": "0.5rem",
2577
+ "--pollar-card-border-radius": "10px"
2578
+ };
2579
+ const isLoading = state.step === "loading";
2580
+ const sessions = state.step === "loaded" ? state.sessions : [];
2581
+ const otherCount = sessions.filter((s) => !s.current).length;
2582
+ return /* @__PURE__ */ jsxs(
2583
+ "div",
2584
+ {
2585
+ className: "pollar-modal-card pollar-sessions-modal",
2586
+ "data-theme": theme,
2587
+ style: cssVars,
2588
+ onClick: (e) => e.stopPropagation(),
2589
+ children: [
2590
+ /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header", children: [
2591
+ /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Active sessions" }),
2592
+ /* @__PURE__ */ jsxs("div", { className: "pollar-modal-header-actions", children: [
2593
+ /* @__PURE__ */ jsxs("button", { className: "pollar-modal-refresh-btn", onClick: onRefresh, disabled: isLoading, children: [
2594
+ /* @__PURE__ */ jsxs(
2595
+ "svg",
2596
+ {
2597
+ className: `pollar-modal-refresh-icon${isLoading ? " spinning" : ""}`,
2598
+ width: "13",
2599
+ height: "13",
2600
+ viewBox: "0 0 13 13",
2601
+ fill: "none",
2602
+ "aria-hidden": true,
2603
+ children: [
2604
+ /* @__PURE__ */ jsx("path", { d: "M11.5 6.5a5 5 0 11-1.5-3.536", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round" }),
2605
+ /* @__PURE__ */ jsx(
2606
+ "path",
2607
+ {
2608
+ d: "M10 1v3h-3",
2609
+ stroke: "currentColor",
2610
+ strokeWidth: "1.5",
2611
+ strokeLinecap: "round",
2612
+ strokeLinejoin: "round"
2613
+ }
2614
+ )
2615
+ ]
2616
+ }
2617
+ ),
2618
+ "Refresh"
2619
+ ] }),
2620
+ /* @__PURE__ */ jsx("button", { className: "pollar-modal-close", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", "aria-hidden": true, children: /* @__PURE__ */ jsx("path", { d: "M2 2l12 12M14 2L2 14", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round" }) }) })
2621
+ ] })
2622
+ ] }),
2623
+ /* @__PURE__ */ jsxs("div", { className: "pollar-sessions-list", children: [
2624
+ state.step === "idle" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
2625
+ isLoading && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "Loading\u2026" }),
2626
+ state.step === "error" && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: state.message }),
2627
+ state.step === "loaded" && sessions.length === 0 && /* @__PURE__ */ jsx("div", { className: "pollar-modal-empty", children: "No active sessions." }),
2628
+ sessions.map((s) => {
2629
+ const isRevoking = revokingFamilyId === s.familyId;
2630
+ return /* @__PURE__ */ jsxs("div", { className: "pollar-sessions-item", "data-current": s.current || void 0, children: [
2631
+ /* @__PURE__ */ jsxs("div", { className: "pollar-sessions-item-main", children: [
2632
+ /* @__PURE__ */ jsx("span", { className: "pollar-sessions-item-device", children: describeDevice(s) }),
2633
+ s.current && /* @__PURE__ */ jsx("span", { className: "pollar-sessions-item-badge", children: "This device" })
2634
+ ] }),
2635
+ /* @__PURE__ */ jsxs("div", { className: "pollar-sessions-item-meta", children: [
2636
+ /* @__PURE__ */ jsxs("span", { children: [
2637
+ "Last used ",
2638
+ formatRelative(s.lastUsedAt ?? s.createdAt)
2639
+ ] }),
2640
+ s.ipHash && /* @__PURE__ */ jsxs(Fragment, { children: [
2641
+ /* @__PURE__ */ jsx("span", { children: "\xB7" }),
2642
+ /* @__PURE__ */ jsxs("span", { title: `ip-hash ${s.ipHash}`, children: [
2643
+ "ip ",
2644
+ shortIp(s.ipHash)
2645
+ ] })
2646
+ ] })
2647
+ ] }),
2648
+ !s.current && /* @__PURE__ */ jsx(
2649
+ "button",
2650
+ {
2651
+ className: "pollar-sessions-item-revoke",
2652
+ onClick: () => onRevoke(s.familyId),
2653
+ disabled: isRevoking || signingOutEverywhere,
2654
+ children: isRevoking ? "Revoking\u2026" : "Revoke"
2655
+ }
2656
+ )
2657
+ ] }, s.familyId);
2658
+ })
2659
+ ] }),
2660
+ state.step === "loaded" && sessions.length > 0 && /* @__PURE__ */ jsx("div", { className: "pollar-sessions-actions", children: /* @__PURE__ */ jsx(
2661
+ "button",
2662
+ {
2663
+ className: "pollar-sessions-logout-all",
2664
+ onClick: onLogoutEverywhere,
2665
+ disabled: signingOutEverywhere || otherCount === 0,
2666
+ title: otherCount === 0 ? "No other devices to sign out" : void 0,
2667
+ children: signingOutEverywhere ? "Signing out\u2026" : "Sign out everywhere"
2668
+ }
2669
+ ) }),
2670
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
2671
+ ]
2672
+ }
2673
+ );
2674
+ }
2675
+ function SessionsModal({ onClose }) {
2676
+ const { getClient, styles } = usePollar();
2677
+ const { theme = "light", accentColor = "#005DB4" } = styles;
2678
+ const [state, setState] = useState({ step: "idle" });
2679
+ const [revokingFamilyId, setRevokingFamilyId] = useState(null);
2680
+ const [signingOutEverywhere, setSigningOutEverywhere] = useState(false);
2681
+ const mountedRef = useRef(true);
2682
+ useEffect(() => () => {
2683
+ mountedRef.current = false;
2684
+ }, []);
2685
+ const onCloseRef = useRef(onClose);
2686
+ onCloseRef.current = onClose;
2687
+ useEffect(() => {
2688
+ return getClient().onAuthStateChange((authState) => {
2689
+ if (authState.step === "idle") onCloseRef.current();
2690
+ });
2691
+ }, [getClient]);
2692
+ const load = useCallback(async () => {
2693
+ setState({ step: "loading" });
2694
+ try {
2695
+ const sessions = await getClient().listSessions();
2696
+ if (!mountedRef.current) return;
2697
+ setState({ step: "loaded", sessions });
2698
+ } catch (err) {
2699
+ if (!mountedRef.current) return;
2700
+ const message = err instanceof Error ? err.message : "Failed to load sessions";
2701
+ setState({ step: "error", message });
2702
+ }
2703
+ }, [getClient]);
2704
+ useEffect(() => {
2705
+ void load();
2706
+ }, [load]);
2707
+ const handleRevoke = useCallback(
2708
+ async (familyId) => {
2709
+ setRevokingFamilyId(familyId);
2710
+ try {
2711
+ await getClient().revokeSession(familyId);
2712
+ if (!mountedRef.current) return;
2713
+ await load();
2714
+ } catch {
2715
+ if (!mountedRef.current) return;
2716
+ setState(
2717
+ (prev) => prev.step === "loaded" ? { step: "error", message: "Failed to revoke session" } : prev
2718
+ );
2719
+ } finally {
2720
+ if (mountedRef.current) setRevokingFamilyId(null);
2721
+ }
2722
+ },
2723
+ [getClient, load]
2724
+ );
2725
+ const handleLogoutEverywhere = useCallback(async () => {
2726
+ setSigningOutEverywhere(true);
2727
+ try {
2728
+ await getClient().logoutEverywhere();
2729
+ onClose();
2730
+ } catch {
2731
+ if (!mountedRef.current) return;
2732
+ setSigningOutEverywhere(false);
2733
+ }
2734
+ }, [getClient, onClose]);
2735
+ return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
2736
+ SessionsModalTemplate,
2737
+ {
2738
+ theme,
2739
+ accentColor,
2740
+ state,
2741
+ revokingFamilyId,
2742
+ signingOutEverywhere,
2743
+ onRefresh: () => void load(),
2744
+ onRevoke: (familyId) => void handleRevoke(familyId),
2745
+ onLogoutEverywhere: () => void handleLogoutEverywhere(),
2746
+ onClose
2747
+ }
2748
+ ) });
2749
+ }
2750
+ function TransactionModalTemplate({
2751
+ theme,
2752
+ accentColor,
2753
+ transaction,
2754
+ showXdr,
2755
+ copied,
2756
+ explorerUrl,
2757
+ walletType,
2758
+ onClose,
2759
+ onSignAndSend,
2760
+ onToggleXdr,
2761
+ onCopyHash,
2762
+ onRetry
2763
+ }) {
2764
+ const isDark = theme === "dark";
2765
+ const cssVars = {
2766
+ "--pollar-accent": accentColor,
2767
+ "--pollar-bg": isDark ? "#1a1a1a" : "#ffffff",
2768
+ "--pollar-border": isDark ? "#374151" : "#e5e7eb",
2769
+ "--pollar-text": isDark ? "#ffffff" : "#111827",
2770
+ "--pollar-muted": isDark ? "#9ca3af" : "#6b7280",
2771
+ "--pollar-input-bg": isDark ? "#374151" : "#f9fafb",
2772
+ "--pollar-error-bg": isDark ? "#2a1515" : "#fef2f2",
2773
+ "--pollar-error-border": isDark ? "#7f1d1d" : "#fecaca",
2774
+ "--pollar-error-text": isDark ? "#f87171" : "#dc2626",
2775
+ "--pollar-success-text": isDark ? "#4ade80" : "#16a34a",
2776
+ "--pollar-buttons-border-radius": "6px",
2777
+ "--pollar-buttons-height": "44px",
2778
+ "--pollar-input-height": "44px",
2779
+ "--pollar-input-border-radius": "0.5rem",
2780
+ "--pollar-card-border-radius": "10px"
2781
+ };
2782
+ return /* @__PURE__ */ jsxs(
2783
+ "div",
2784
+ {
2785
+ className: "pollar-modal-card pollar-tx-modal",
2786
+ "data-theme": theme,
2787
+ style: cssVars,
2788
+ onClick: (e) => e.stopPropagation(),
2789
+ children: [
2790
+ /* @__PURE__ */ jsx("div", { className: "pollar-modal-header", children: /* @__PURE__ */ jsx("h2", { className: "pollar-modal-title", children: "Transaction" }) }),
2791
+ /* @__PURE__ */ jsx("button", { type: "button", className: "pollar-close-btn", onClick: onClose, "aria-label": "Close", children: /* @__PURE__ */ jsx(
2792
+ "svg",
2793
+ {
2794
+ width: "18",
2795
+ height: "18",
2796
+ viewBox: "0 0 24 24",
2797
+ fill: "none",
2798
+ stroke: "currentColor",
2799
+ strokeWidth: "2.5",
2800
+ strokeLinecap: "round",
2801
+ strokeLinejoin: "round",
1011
2802
  "aria-hidden": true,
1012
- children: [
1013
- /* @__PURE__ */ jsx("circle", { cx: "44", cy: "44", r: "36", fill: "none", stroke: "var(--pollar-border)", strokeWidth: "3" }),
1014
- /* @__PURE__ */ jsx(
1015
- "circle",
1016
- {
1017
- cx: "44",
1018
- cy: "44",
1019
- r: "36",
1020
- fill: "none",
1021
- stroke: isSuccess ? "var(--pollar-success-text)" : isError ? "var(--pollar-error-text)" : "var(--pollar-accent)",
1022
- strokeWidth: "3",
1023
- strokeLinecap: "round",
1024
- strokeDasharray: isSigning ? "169.6 56.6" : "999 0",
1025
- transform: "rotate(-90 44 44)",
1026
- style: { transition: isSigning ? "none" : "stroke 400ms, stroke-dasharray 400ms" }
1027
- }
1028
- )
1029
- ]
2803
+ children: /* @__PURE__ */ jsx("path", { d: "M18 6L6 18M6 6l12 12" })
1030
2804
  }
1031
- ),
1032
- /* @__PURE__ */ jsx("div", { className: "pollar-tx-wallet-icon", children: /* @__PURE__ */ jsx(
1033
- "img",
2805
+ ) }),
2806
+ /* @__PURE__ */ jsx(
2807
+ TxStatusView,
1034
2808
  {
1035
- src: walletType === WalletType.FREIGHTER ? LOGO_FREIGHTER : walletType === WalletType.ALBEDO ? LOGO_ALBEDO : LOGO_POLLAR,
1036
- alt: walletType === WalletType.FREIGHTER ? "Freighter" : walletType === WalletType.ALBEDO ? "Albedo" : "Pollar",
1037
- className: "pollar-tx-wallet-img"
2809
+ transaction,
2810
+ showXdr,
2811
+ copied,
2812
+ explorerUrl,
2813
+ walletType,
2814
+ onSignAndSend,
2815
+ onToggleXdr,
2816
+ onCopyHash,
2817
+ onRetry,
2818
+ onDone: onClose
1038
2819
  }
1039
- ) })
1040
- ] }),
1041
- isSigning && /* @__PURE__ */ jsx("p", { className: "pollar-tx-spinner-label", children: walletType === WalletType.FREIGHTER ? "Waiting for Freighter\u2026" : walletType === WalletType.ALBEDO ? "Waiting for Albedo\u2026" : "Signing and sending\u2026" }),
1042
- isError && onRetry && "buildData" in transaction && transaction.buildData && /* @__PURE__ */ jsx("button", { className: "pollar-btn-secondary pollar-tx-retry-btn", onClick: onRetry, children: "Try again" })
1043
- ] }),
1044
- isSuccess && hash && /* @__PURE__ */ jsxs("div", { className: "pollar-tx-result", children: [
1045
- /* @__PURE__ */ jsx("span", { className: "pollar-tx-result-label", children: "Transaction hash" }),
1046
- /* @__PURE__ */ jsx("span", { className: "pollar-tx-result-hash", children: hash }),
1047
- /* @__PURE__ */ jsxs("div", { className: "pollar-tx-result-actions", children: [
1048
- /* @__PURE__ */ jsx("button", { className: "pollar-tx-result-btn", onClick: onCopyHash, children: copied ? /* @__PURE__ */ jsxs(Fragment, { children: [
1049
- /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 14 14", fill: "none", "aria-hidden": true, children: [
1050
- /* @__PURE__ */ jsx("circle", { cx: "7", cy: "7", r: "7", fill: "currentColor" }),
1051
- /* @__PURE__ */ jsx(
1052
- "path",
1053
- {
1054
- d: "M3.5 7l2.5 2.5 4.5-5",
1055
- stroke: "white",
1056
- strokeWidth: "1.5",
1057
- strokeLinecap: "round",
1058
- strokeLinejoin: "round"
1059
- }
1060
- )
1061
- ] }),
1062
- "Copied!"
1063
- ] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
1064
- /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1065
- /* @__PURE__ */ jsx("rect", { x: "4", y: "4", width: "8", height: "8", rx: "1.5", stroke: "currentColor", strokeWidth: "1.5" }),
1066
- /* @__PURE__ */ jsx(
1067
- "path",
1068
- {
1069
- d: "M3 9H2a1 1 0 01-1-1V2a1 1 0 011-1h6a1 1 0 011 1v1",
1070
- stroke: "currentColor",
1071
- strokeWidth: "1.5",
1072
- strokeLinecap: "round"
1073
- }
1074
- )
1075
- ] }),
1076
- "Copy hash"
1077
- ] }) }),
1078
- explorerUrl && /* @__PURE__ */ jsxs("a", { className: "pollar-tx-result-btn", href: explorerUrl, target: "_blank", rel: "noopener noreferrer", children: [
1079
- /* @__PURE__ */ jsxs("svg", { width: "13", height: "13", viewBox: "0 0 13 13", fill: "none", "aria-hidden": true, children: [
1080
- /* @__PURE__ */ jsx(
1081
- "path",
1082
- {
1083
- d: "M5 2H2a1 1 0 00-1 1v8a1 1 0 001 1h8a1 1 0 001-1V8",
1084
- stroke: "currentColor",
1085
- strokeWidth: "1.5",
1086
- strokeLinecap: "round"
1087
- }
1088
- ),
1089
- /* @__PURE__ */ jsx(
1090
- "path",
1091
- {
1092
- d: "M8 1h4m0 0v4m0-4L6 7",
1093
- stroke: "currentColor",
1094
- strokeWidth: "1.5",
1095
- strokeLinecap: "round",
1096
- strokeLinejoin: "round"
1097
- }
1098
- )
1099
- ] }),
1100
- "View on Explorer"
1101
- ] })
1102
- ] })
1103
- ] }),
1104
- isSuccess && /* @__PURE__ */ jsx("button", { className: "pollar-btn-primary pollar-tx-sign-btn", onClick: onClose, children: "Done" }),
1105
- /* @__PURE__ */ jsx(
1106
- ModalStatusBanner,
1107
- {
1108
- message: STATUS_MESSAGES[transaction.step],
1109
- status: isError ? "ERROR" : isSigning || transaction.step === "building" ? "LOADING" : isSuccess ? "SUCCESS" : "NONE"
1110
- }
1111
- ),
1112
- /* @__PURE__ */ jsx(PollarModalFooter, {})
1113
- ] });
2820
+ ),
2821
+ /* @__PURE__ */ jsx(PollarModalFooter, {})
2822
+ ]
2823
+ }
2824
+ );
1114
2825
  }
1115
2826
  function TransactionModal({ onClose }) {
1116
- const { getClient, styles, transaction, network, walletType } = usePollar();
2827
+ const { getClient, styles, tx: transaction, network, walletType } = usePollar();
1117
2828
  const { theme = "light", accentColor = "#005DB4" } = styles;
1118
2829
  const [showXdr, setShowXdr] = useState(false);
1119
2830
  const [copied, setCopied] = useState(false);
@@ -1284,10 +2995,13 @@ function TxHistoryModal({ onClose }) {
1284
2995
  const { getClient, styles, txHistory } = usePollar();
1285
2996
  const { theme = "light", accentColor = "#005DB4" } = styles;
1286
2997
  const [offset, setOffset] = useState(0);
1287
- function load(nextOffset) {
2998
+ const load = useCallback((nextOffset) => {
1288
2999
  setOffset(nextOffset);
1289
3000
  void getClient().fetchTxHistory({ limit: PAGE_SIZE2, offset: nextOffset });
1290
- }
3001
+ }, [getClient]);
3002
+ useEffect(() => {
3003
+ load(0);
3004
+ }, [load]);
1291
3005
  return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
1292
3006
  TxHistoryModalTemplate,
1293
3007
  {
@@ -1302,7 +3016,7 @@ function TxHistoryModal({ onClose }) {
1302
3016
  }
1303
3017
  ) });
1304
3018
  }
1305
- function formatBalance(balance) {
3019
+ function formatBalance2(balance) {
1306
3020
  const n = parseFloat(balance);
1307
3021
  return isNaN(n) ? balance : n.toLocaleString(void 0, { maximumFractionDigits: 7 });
1308
3022
  }
@@ -1315,9 +3029,9 @@ function BalanceItem({ record }) {
1315
3029
  return /* @__PURE__ */ jsxs("div", { className: "pollar-bal-item", children: [
1316
3030
  /* @__PURE__ */ jsx("span", { className: "pollar-bal-asset", children: record.code }),
1317
3031
  /* @__PURE__ */ jsxs("div", { className: "pollar-bal-amounts", children: [
1318
- /* @__PURE__ */ jsx("span", { className: "pollar-bal-amount", children: formatBalance(record.balance) }),
3032
+ /* @__PURE__ */ jsx("span", { className: "pollar-bal-amount", children: formatBalance2(record.balance) }),
1319
3033
  balanceDiffers && /* @__PURE__ */ jsxs("span", { className: "pollar-bal-available", children: [
1320
- formatBalance(record.available),
3034
+ formatBalance2(record.available),
1321
3035
  " available"
1322
3036
  ] })
1323
3037
  ] })
@@ -1390,11 +3104,11 @@ function WalletBalanceModalTemplate({
1390
3104
  ] });
1391
3105
  }
1392
3106
  function WalletBalanceModal({ onClose }) {
1393
- const { walletBalance, refreshBalance, walletAddress, styles } = usePollar();
3107
+ const { walletBalance, refreshWalletBalance, walletAddress, styles } = usePollar();
1394
3108
  const { theme = "light", accentColor = "#005DB4" } = styles;
1395
3109
  useEffect(() => {
1396
- void refreshBalance();
1397
- }, []);
3110
+ void refreshWalletBalance();
3111
+ }, [refreshWalletBalance]);
1398
3112
  return /* @__PURE__ */ jsx("div", { className: "pollar-overlay", onClick: onClose, children: /* @__PURE__ */ jsx(
1399
3113
  WalletBalanceModalTemplate,
1400
3114
  {
@@ -1402,7 +3116,7 @@ function WalletBalanceModal({ onClose }) {
1402
3116
  accentColor,
1403
3117
  walletBalance,
1404
3118
  walletAddress,
1405
- onRefresh: () => refreshBalance(),
3119
+ onRefresh: () => refreshWalletBalance(),
1406
3120
  onClose
1407
3121
  }
1408
3122
  ) });
@@ -1427,6 +3141,8 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1427
3141
  const [walletBalance, setWalletBalance] = useState({ step: "idle" });
1428
3142
  const [remoteConfig, setRemoteConfig] = useState(emptyResponse);
1429
3143
  const [styles, setStyles] = useState(propStyles ?? {});
3144
+ const propStylesRef = useRef(propStyles);
3145
+ propStylesRef.current = propStyles;
1430
3146
  useEffect(() => {
1431
3147
  return pollarClient.onTransactionStateChange(setTransaction);
1432
3148
  }, [pollarClient]);
@@ -1451,59 +3167,78 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1451
3167
  });
1452
3168
  }, [pollarClient]);
1453
3169
  useEffect(() => {
3170
+ const propStyles2 = propStylesRef.current;
1454
3171
  fetchRemoteConfig(pollarClient).then((fetched) => {
1455
3172
  setRemoteConfig(fetched);
1456
3173
  setStyles({
1457
3174
  ...fetched.styles,
1458
- ...propStyles,
1459
- providers: { ...fetched.styles?.providers, ...propStyles?.providers }
3175
+ ...propStyles2,
3176
+ providers: { ...fetched.styles?.providers, ...propStyles2?.providers }
1460
3177
  });
1461
3178
  }).catch(() => {
1462
- setStyles(propStyles ?? {});
3179
+ setStyles(propStyles2 ?? {});
1463
3180
  });
1464
3181
  }, [pollarClient]);
1465
- useEffect(() => {
1466
- if (transaction.step !== "idle") {
1467
- setTransactionModalOpen(true);
1468
- }
1469
- }, [transaction.step]);
1470
3182
  const [loginModalOpen, setLoginModalOpen] = useState(false);
1471
3183
  const [transactionModalOpen, setTransactionModalOpen] = useState(false);
1472
3184
  const [kycModalOpen, setKycModalOpen] = useState(false);
1473
3185
  const [kycModalOptions, setKycModalOptions] = useState({});
1474
- const [rampWidgetOpen, setRampWidgetOpen] = useState(false);
3186
+ const [rampModalOpen, setRampModalOpen] = useState(false);
1475
3187
  const [txHistoryModalOpen, setTxHistoryModalOpen] = useState(false);
1476
3188
  const [walletBalanceModalOpen, setWalletBalanceModalOpen] = useState(false);
3189
+ const [sendModalOpen, setSendModalOpen] = useState(false);
3190
+ const [receiveModalOpen, setReceiveModalOpen] = useState(false);
3191
+ const [sessionsModalOpen, setSessionsModalOpen] = useState(false);
3192
+ const adaptersRef = useRef(adapters);
3193
+ adaptersRef.current = adapters;
3194
+ const walletAddress = sessionState?.wallet?.publicKey || "";
3195
+ const getClient = useCallback(() => pollarClient, [pollarClient]);
3196
+ const refreshWalletBalance = useCallback(() => pollarClient.refreshBalance(walletAddress), [pollarClient, walletAddress]);
1477
3197
  const contextValue = useMemo(
1478
3198
  () => ({
1479
- walletAddress: sessionState?.data?.providers?.wallet?.address || sessionState?.wallet?.publicKey || "",
1480
- getClient: () => pollarClient,
1481
- transaction,
3199
+ // session
3200
+ walletAddress,
3201
+ isAuthenticated: !!walletAddress,
3202
+ walletType: pollarClient.getWalletType(),
3203
+ // client
3204
+ getClient,
3205
+ // auth
1482
3206
  login: (options) => pollarClient.login(options),
1483
3207
  logout: () => pollarClient.logout(),
1484
- isAuthenticated: !!sessionState?.wallet?.publicKey,
3208
+ openLoginModal: () => setLoginModalOpen(true),
3209
+ // transactions
3210
+ tx: transaction,
1485
3211
  buildTx: (operation, params, options) => pollarClient.buildTx(operation, params, options),
1486
3212
  signAndSubmitTx: (unsignedXdr) => pollarClient.signAndSubmitTx(unsignedXdr),
1487
- walletType: pollarClient.getWalletType(),
1488
- openTransactionModal: () => setTransactionModalOpen(true),
1489
- openLoginModal: () => setLoginModalOpen(true),
1490
- openKycModal: (options = {}) => {
1491
- setKycModalOptions(options);
1492
- setKycModalOpen(true);
1493
- },
1494
- openRampWidget: () => setRampWidgetOpen(true),
3213
+ openTxModal: () => setTransactionModalOpen(true),
3214
+ // tx history
1495
3215
  txHistory,
1496
3216
  openTxHistoryModal: () => setTxHistoryModalOpen(true),
1497
- openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
3217
+ // wallet balance
1498
3218
  walletBalance,
1499
- refreshBalance: (publicKey) => pollarClient.refreshBalance(publicKey),
3219
+ refreshWalletBalance,
3220
+ openWalletBalanceModal: () => setWalletBalanceModalOpen(true),
3221
+ // send / receive
3222
+ openSendModal: () => setSendModalOpen(true),
3223
+ openReceiveModal: () => setReceiveModalOpen(true),
3224
+ // sessions
3225
+ openSessionsModal: () => setSessionsModalOpen(true),
3226
+ // network
1500
3227
  network: networkState.step === "connected" ? networkState.network : "testnet",
1501
3228
  setNetwork: (network) => pollarClient.setNetwork(network),
1502
- config: remoteConfig,
3229
+ // kyc
3230
+ openKycModal: (options = {}) => {
3231
+ setKycModalOptions(options);
3232
+ setKycModalOpen(true);
3233
+ },
3234
+ // ramp
3235
+ openRampModal: () => setRampModalOpen(true),
3236
+ // config
3237
+ appConfig: remoteConfig,
1503
3238
  styles,
1504
- adapters
3239
+ adapters: adaptersRef.current
1505
3240
  }),
1506
- [sessionState, remoteConfig, styles, pollarClient, transaction, txHistory, networkState, walletBalance]
3241
+ [walletAddress, pollarClient, getClient, transaction, txHistory, walletBalance, refreshWalletBalance, networkState, remoteConfig, styles]
1507
3242
  );
1508
3243
  return /* @__PURE__ */ jsxs(PollarContext.Provider, { value: contextValue, children: [
1509
3244
  children,
@@ -1518,9 +3253,12 @@ function PollarProvider({ config, styles: propStyles, adapters, children }) {
1518
3253
  ...kycModalOptions.onApproved !== void 0 && { onApproved: kycModalOptions.onApproved }
1519
3254
  }
1520
3255
  ) }),
1521
- rampWidgetOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setRampWidgetOpen(false), children: /* @__PURE__ */ jsx(RampWidget, { onClose: () => setRampWidgetOpen(false) }) }),
3256
+ rampModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setRampModalOpen(false), children: /* @__PURE__ */ jsx(RampWidget, { onClose: () => setRampModalOpen(false) }) }),
1522
3257
  txHistoryModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setTxHistoryModalOpen(false), children: /* @__PURE__ */ jsx(TxHistoryModal, { onClose: () => setTxHistoryModalOpen(false) }) }),
1523
- walletBalanceModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) })
3258
+ walletBalanceModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setWalletBalanceModalOpen(false), children: /* @__PURE__ */ jsx(WalletBalanceModal, { onClose: () => setWalletBalanceModalOpen(false) }) }),
3259
+ sendModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSendModalOpen(false), children: /* @__PURE__ */ jsx(SendModal, { onClose: () => setSendModalOpen(false) }) }),
3260
+ receiveModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setReceiveModalOpen(false), children: /* @__PURE__ */ jsx(ReceiveModal, { onClose: () => setReceiveModalOpen(false) }) }),
3261
+ sessionsModalOpen && /* @__PURE__ */ jsx(ModalErrorBoundary, { onClose: () => setSessionsModalOpen(false), children: /* @__PURE__ */ jsx(SessionsModal, { onClose: () => setSessionsModalOpen(false) }) })
1524
3262
  ] });
1525
3263
  }
1526
3264
  function usePollar() {
@@ -1566,10 +3304,13 @@ function WalletButtonTemplate({
1566
3304
  dropdownBorder,
1567
3305
  itemColor,
1568
3306
  wrapperRef,
3307
+ isInProgress,
1569
3308
  onToggleOpen,
1570
3309
  onCopy,
1571
3310
  onWalletBalance,
1572
3311
  onTxHistory,
3312
+ onSend,
3313
+ onReceive,
1573
3314
  onLogout,
1574
3315
  onLogin
1575
3316
  }) {
@@ -1580,132 +3321,129 @@ function WalletButtonTemplate({
1580
3321
  ] });
1581
3322
  }
1582
3323
  return /* @__PURE__ */ jsxs("div", { className: "wallet-wrapper", ref: wrapperRef, children: [
1583
- /* @__PURE__ */ jsxs("button", { className: "wallet-btn", style: { backgroundColor: accentColor }, onClick: onToggleOpen, children: [
1584
- cropWallet(walletAddress),
1585
- /* @__PURE__ */ jsx(
1586
- "svg",
1587
- {
1588
- className: `wallet-chevron${open ? " open" : ""}`,
1589
- viewBox: "0 0 12 12",
1590
- fill: "none",
1591
- stroke: "currentColor",
1592
- strokeWidth: "2",
1593
- strokeLinecap: "round",
1594
- strokeLinejoin: "round",
1595
- children: /* @__PURE__ */ jsx("polyline", { points: "2,4 6,8 10,4" })
1596
- }
1597
- )
1598
- ] }),
3324
+ /* @__PURE__ */ jsxs(
3325
+ "button",
3326
+ {
3327
+ className: "wallet-btn",
3328
+ style: { backgroundColor: accentColor },
3329
+ onClick: isInProgress ? void 0 : onToggleOpen,
3330
+ disabled: isInProgress,
3331
+ "aria-busy": isInProgress,
3332
+ children: [
3333
+ /* @__PURE__ */ jsx("span", { className: "wallet-btn-label", children: cropWallet(walletAddress) }),
3334
+ isInProgress ? /* @__PURE__ */ jsxs(
3335
+ "svg",
3336
+ {
3337
+ className: "wallet-btn-spinner",
3338
+ viewBox: "0 0 12 12",
3339
+ width: "12",
3340
+ height: "12",
3341
+ fill: "none",
3342
+ "aria-hidden": true,
3343
+ children: [
3344
+ /* @__PURE__ */ jsx("circle", { cx: "6", cy: "6", r: "4.5", stroke: "rgba(255,255,255,0.35)", strokeWidth: "1.5" }),
3345
+ /* @__PURE__ */ jsx(
3346
+ "circle",
3347
+ {
3348
+ cx: "6",
3349
+ cy: "6",
3350
+ r: "4.5",
3351
+ stroke: "white",
3352
+ strokeWidth: "1.5",
3353
+ strokeLinecap: "round",
3354
+ strokeDasharray: "14 9",
3355
+ transform: "rotate(-90 6 6)"
3356
+ }
3357
+ )
3358
+ ]
3359
+ }
3360
+ ) : /* @__PURE__ */ jsx(
3361
+ "svg",
3362
+ {
3363
+ className: `wallet-chevron${open ? " open" : ""}`,
3364
+ viewBox: "0 0 12 12",
3365
+ fill: "none",
3366
+ stroke: "currentColor",
3367
+ strokeWidth: "2",
3368
+ strokeLinecap: "round",
3369
+ strokeLinejoin: "round",
3370
+ children: /* @__PURE__ */ jsx("polyline", { points: "2,4 6,8 10,4" })
3371
+ }
3372
+ )
3373
+ ]
3374
+ }
3375
+ ),
1599
3376
  open && /* @__PURE__ */ jsxs("div", { className: "wallet-dropdown", style: { backgroundColor: dropdownBg, borderColor: dropdownBorder }, children: [
3377
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onSend, children: [
3378
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3379
+ /* @__PURE__ */ jsx("line", { x1: "22", y1: "2", x2: "11", y2: "13" }),
3380
+ /* @__PURE__ */ jsx("polygon", { points: "22 2 15 22 11 13 2 9 22 2" })
3381
+ ] }),
3382
+ "Send"
3383
+ ] }),
3384
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onReceive, children: [
3385
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3386
+ /* @__PURE__ */ jsx("polyline", { points: "8 17 12 21 16 17" }),
3387
+ /* @__PURE__ */ jsx("line", { x1: "12", y1: "12", x2: "12", y2: "21" }),
3388
+ /* @__PURE__ */ jsx("path", { d: "M20.88 18.09A5 5 0 0 0 18 9h-1.26A8 8 0 1 0 3 16.29" })
3389
+ ] }),
3390
+ "Receive"
3391
+ ] }),
3392
+ /* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
1600
3393
  /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onCopy, children: [
1601
- /* @__PURE__ */ jsxs(
1602
- "svg",
1603
- {
1604
- width: "14",
1605
- height: "14",
1606
- viewBox: "0 0 24 24",
1607
- fill: "none",
1608
- stroke: "currentColor",
1609
- strokeWidth: "2",
1610
- strokeLinecap: "round",
1611
- strokeLinejoin: "round",
1612
- children: [
1613
- /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
1614
- /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
1615
- ]
1616
- }
1617
- ),
3394
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3395
+ /* @__PURE__ */ jsx("rect", { x: "9", y: "9", width: "13", height: "13", rx: "2" }),
3396
+ /* @__PURE__ */ jsx("path", { d: "M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" })
3397
+ ] }),
1618
3398
  copied ? "Copied!" : "Copy address"
1619
3399
  ] }),
1620
- /* @__PURE__ */ jsxs(
1621
- "button",
1622
- {
1623
- className: "wallet-dropdown-item",
1624
- style: { color: itemColor },
1625
- onClick: onWalletBalance,
1626
- children: [
1627
- /* @__PURE__ */ jsxs(
1628
- "svg",
1629
- {
1630
- width: "14",
1631
- height: "14",
1632
- viewBox: "0 0 24 24",
1633
- fill: "none",
1634
- stroke: "currentColor",
1635
- strokeWidth: "2",
1636
- strokeLinecap: "round",
1637
- strokeLinejoin: "round",
1638
- children: [
1639
- /* @__PURE__ */ jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
1640
- /* @__PURE__ */ jsx("circle", { cx: "16", cy: "12", r: "2" }),
1641
- /* @__PURE__ */ jsx("path", { d: "M22 8H12" })
1642
- ]
1643
- }
1644
- ),
1645
- "Wallet balance"
1646
- ]
1647
- }
1648
- ),
1649
- /* @__PURE__ */ jsxs(
1650
- "button",
1651
- {
1652
- className: "wallet-dropdown-item",
1653
- style: { color: itemColor },
1654
- onClick: onTxHistory,
1655
- children: [
1656
- /* @__PURE__ */ jsxs(
1657
- "svg",
1658
- {
1659
- width: "14",
1660
- height: "14",
1661
- viewBox: "0 0 24 24",
1662
- fill: "none",
1663
- stroke: "currentColor",
1664
- strokeWidth: "2",
1665
- strokeLinecap: "round",
1666
- strokeLinejoin: "round",
1667
- children: [
1668
- /* @__PURE__ */ jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
1669
- /* @__PURE__ */ jsx("polyline", { points: "14,2 14,8 20,8" }),
1670
- /* @__PURE__ */ jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
1671
- /* @__PURE__ */ jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
1672
- /* @__PURE__ */ jsx("polyline", { points: "10,9 9,9 8,9" })
1673
- ]
1674
- }
1675
- ),
1676
- "Transaction history"
1677
- ]
1678
- }
1679
- ),
3400
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onWalletBalance, children: [
3401
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3402
+ /* @__PURE__ */ jsx("rect", { x: "1", y: "4", width: "22", height: "16", rx: "2", ry: "2" }),
3403
+ /* @__PURE__ */ jsx("circle", { cx: "16", cy: "12", r: "2" }),
3404
+ /* @__PURE__ */ jsx("path", { d: "M22 8H12" })
3405
+ ] }),
3406
+ "Wallet balance"
3407
+ ] }),
3408
+ /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item", style: { color: itemColor }, onClick: onTxHistory, children: [
3409
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3410
+ /* @__PURE__ */ jsx("path", { d: "M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" }),
3411
+ /* @__PURE__ */ jsx("polyline", { points: "14,2 14,8 20,8" }),
3412
+ /* @__PURE__ */ jsx("line", { x1: "16", y1: "13", x2: "8", y2: "13" }),
3413
+ /* @__PURE__ */ jsx("line", { x1: "16", y1: "17", x2: "8", y2: "17" }),
3414
+ /* @__PURE__ */ jsx("polyline", { points: "10,9 9,9 8,9" })
3415
+ ] }),
3416
+ "Transaction history"
3417
+ ] }),
3418
+ /* @__PURE__ */ jsx("div", { className: "wallet-dropdown-divider" }),
1680
3419
  /* @__PURE__ */ jsxs("button", { className: "wallet-dropdown-item danger", onClick: onLogout, children: [
1681
- /* @__PURE__ */ jsxs(
1682
- "svg",
1683
- {
1684
- width: "14",
1685
- height: "14",
1686
- viewBox: "0 0 24 24",
1687
- fill: "none",
1688
- stroke: "currentColor",
1689
- strokeWidth: "2",
1690
- strokeLinecap: "round",
1691
- strokeLinejoin: "round",
1692
- children: [
1693
- /* @__PURE__ */ jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
1694
- /* @__PURE__ */ jsx("polyline", { points: "16,17 21,12 16,7" }),
1695
- /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
1696
- ]
1697
- }
1698
- ),
3420
+ /* @__PURE__ */ jsxs("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
3421
+ /* @__PURE__ */ jsx("path", { d: "M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" }),
3422
+ /* @__PURE__ */ jsx("polyline", { points: "16,17 21,12 16,7" }),
3423
+ /* @__PURE__ */ jsx("line", { x1: "21", y1: "12", x2: "9", y2: "12" })
3424
+ ] }),
1699
3425
  "Log out"
1700
3426
  ] })
1701
3427
  ] })
1702
3428
  ] });
1703
3429
  }
1704
3430
  function WalletButton() {
1705
- const { getClient, walletAddress, styles, openLoginModal, openTxHistoryModal, openWalletBalanceModal } = usePollar();
3431
+ const {
3432
+ getClient,
3433
+ walletAddress,
3434
+ styles,
3435
+ openLoginModal,
3436
+ openTxHistoryModal,
3437
+ openWalletBalanceModal,
3438
+ openSendModal,
3439
+ openReceiveModal,
3440
+ tx: transaction,
3441
+ walletType
3442
+ } = usePollar();
1706
3443
  const [open, setOpen] = useState(false);
1707
3444
  const [copied, setCopied] = useState(false);
1708
3445
  const wrapperRef = useRef(null);
3446
+ const isInProgress = transaction.step === "building" || transaction.step === "signing";
1709
3447
  const { theme = "light", accentColor = "#005DB4" } = styles;
1710
3448
  const isDark = theme === "dark";
1711
3449
  const dropdownBg = isDark ? "#18181b" : "#fff";
@@ -1738,6 +3476,14 @@ function WalletButton() {
1738
3476
  setOpen(false);
1739
3477
  openTxHistoryModal();
1740
3478
  }
3479
+ function handleSend() {
3480
+ setOpen(false);
3481
+ openSendModal();
3482
+ }
3483
+ function handleReceive() {
3484
+ setOpen(false);
3485
+ openReceiveModal();
3486
+ }
1741
3487
  return /* @__PURE__ */ jsx(
1742
3488
  WalletButtonTemplate,
1743
3489
  {
@@ -1749,16 +3495,20 @@ function WalletButton() {
1749
3495
  dropdownBorder,
1750
3496
  itemColor,
1751
3497
  wrapperRef,
3498
+ isInProgress,
3499
+ walletType,
1752
3500
  onToggleOpen: () => setOpen((v) => !v),
1753
3501
  onCopy: handleCopy,
1754
3502
  onWalletBalance: handleWalletBalance,
1755
3503
  onTxHistory: handleTxHistory,
3504
+ onSend: handleSend,
3505
+ onReceive: handleReceive,
1756
3506
  onLogout: handleLogout,
1757
3507
  onLogin: openLoginModal
1758
3508
  }
1759
3509
  );
1760
3510
  }
1761
3511
 
1762
- export { KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, RouteDisplay, TransactionModalTemplate, TxHistoryModalTemplate, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
3512
+ export { KycModal, KycModalTemplate, KycStatus, LoginModalTemplate, PollarProvider, RampWidget, RampWidgetTemplate, ReceiveModal, ReceiveModalTemplate, RouteDisplay, SendModal, SendModalTemplate, SessionsModal, SessionsModalTemplate, TransactionModalTemplate, TxHistoryModalTemplate, TxStatusView, WalletBalanceModal, WalletBalanceModalTemplate, WalletButton, createPollarAdapterHook, usePollar };
1763
3513
  //# sourceMappingURL=index.mjs.map
1764
3514
  //# sourceMappingURL=index.mjs.map