@prson/login-sdk-ui 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,2863 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
19
+ // If the importer is in node compatibility mode or this is not an ESM
20
+ // file that has been converted to a CommonJS file using a Babel-
21
+ // compatible transform (i.e. "__esModule" has not been set), then set
22
+ // "default" to the CommonJS "module.exports" for node compatibility.
23
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
24
+ mod
25
+ ));
26
+
27
+ // node_modules/qrcode/lib/can-promise.js
28
+ var require_can_promise = __commonJS({
29
+ "node_modules/qrcode/lib/can-promise.js"(exports, module) {
30
+ module.exports = function() {
31
+ return typeof Promise === "function" && Promise.prototype && Promise.prototype.then;
32
+ };
33
+ }
34
+ });
35
+
36
+ // node_modules/qrcode/lib/core/utils.js
37
+ var require_utils = __commonJS({
38
+ "node_modules/qrcode/lib/core/utils.js"(exports) {
39
+ var toSJISFunction;
40
+ var CODEWORDS_COUNT = [
41
+ 0,
42
+ // Not used
43
+ 26,
44
+ 44,
45
+ 70,
46
+ 100,
47
+ 134,
48
+ 172,
49
+ 196,
50
+ 242,
51
+ 292,
52
+ 346,
53
+ 404,
54
+ 466,
55
+ 532,
56
+ 581,
57
+ 655,
58
+ 733,
59
+ 815,
60
+ 901,
61
+ 991,
62
+ 1085,
63
+ 1156,
64
+ 1258,
65
+ 1364,
66
+ 1474,
67
+ 1588,
68
+ 1706,
69
+ 1828,
70
+ 1921,
71
+ 2051,
72
+ 2185,
73
+ 2323,
74
+ 2465,
75
+ 2611,
76
+ 2761,
77
+ 2876,
78
+ 3034,
79
+ 3196,
80
+ 3362,
81
+ 3532,
82
+ 3706
83
+ ];
84
+ exports.getSymbolSize = function getSymbolSize(version) {
85
+ if (!version) throw new Error('"version" cannot be null or undefined');
86
+ if (version < 1 || version > 40) throw new Error('"version" should be in range from 1 to 40');
87
+ return version * 4 + 17;
88
+ };
89
+ exports.getSymbolTotalCodewords = function getSymbolTotalCodewords(version) {
90
+ return CODEWORDS_COUNT[version];
91
+ };
92
+ exports.getBCHDigit = function(data) {
93
+ let digit = 0;
94
+ while (data !== 0) {
95
+ digit++;
96
+ data >>>= 1;
97
+ }
98
+ return digit;
99
+ };
100
+ exports.setToSJISFunction = function setToSJISFunction(f) {
101
+ if (typeof f !== "function") {
102
+ throw new Error('"toSJISFunc" is not a valid function.');
103
+ }
104
+ toSJISFunction = f;
105
+ };
106
+ exports.isKanjiModeEnabled = function() {
107
+ return typeof toSJISFunction !== "undefined";
108
+ };
109
+ exports.toSJIS = function toSJIS(kanji) {
110
+ return toSJISFunction(kanji);
111
+ };
112
+ }
113
+ });
114
+
115
+ // node_modules/qrcode/lib/core/error-correction-level.js
116
+ var require_error_correction_level = __commonJS({
117
+ "node_modules/qrcode/lib/core/error-correction-level.js"(exports) {
118
+ exports.L = { bit: 1 };
119
+ exports.M = { bit: 0 };
120
+ exports.Q = { bit: 3 };
121
+ exports.H = { bit: 2 };
122
+ function fromString(string) {
123
+ if (typeof string !== "string") {
124
+ throw new Error("Param is not a string");
125
+ }
126
+ const lcStr = string.toLowerCase();
127
+ switch (lcStr) {
128
+ case "l":
129
+ case "low":
130
+ return exports.L;
131
+ case "m":
132
+ case "medium":
133
+ return exports.M;
134
+ case "q":
135
+ case "quartile":
136
+ return exports.Q;
137
+ case "h":
138
+ case "high":
139
+ return exports.H;
140
+ default:
141
+ throw new Error("Unknown EC Level: " + string);
142
+ }
143
+ }
144
+ exports.isValid = function isValid(level) {
145
+ return level && typeof level.bit !== "undefined" && level.bit >= 0 && level.bit < 4;
146
+ };
147
+ exports.from = function from(value, defaultValue) {
148
+ if (exports.isValid(value)) {
149
+ return value;
150
+ }
151
+ try {
152
+ return fromString(value);
153
+ } catch (e) {
154
+ return defaultValue;
155
+ }
156
+ };
157
+ }
158
+ });
159
+
160
+ // node_modules/qrcode/lib/core/bit-buffer.js
161
+ var require_bit_buffer = __commonJS({
162
+ "node_modules/qrcode/lib/core/bit-buffer.js"(exports, module) {
163
+ function BitBuffer() {
164
+ this.buffer = [];
165
+ this.length = 0;
166
+ }
167
+ BitBuffer.prototype = {
168
+ get: function(index) {
169
+ const bufIndex = Math.floor(index / 8);
170
+ return (this.buffer[bufIndex] >>> 7 - index % 8 & 1) === 1;
171
+ },
172
+ put: function(num, length) {
173
+ for (let i = 0; i < length; i++) {
174
+ this.putBit((num >>> length - i - 1 & 1) === 1);
175
+ }
176
+ },
177
+ getLengthInBits: function() {
178
+ return this.length;
179
+ },
180
+ putBit: function(bit) {
181
+ const bufIndex = Math.floor(this.length / 8);
182
+ if (this.buffer.length <= bufIndex) {
183
+ this.buffer.push(0);
184
+ }
185
+ if (bit) {
186
+ this.buffer[bufIndex] |= 128 >>> this.length % 8;
187
+ }
188
+ this.length++;
189
+ }
190
+ };
191
+ module.exports = BitBuffer;
192
+ }
193
+ });
194
+
195
+ // node_modules/qrcode/lib/core/bit-matrix.js
196
+ var require_bit_matrix = __commonJS({
197
+ "node_modules/qrcode/lib/core/bit-matrix.js"(exports, module) {
198
+ function BitMatrix(size) {
199
+ if (!size || size < 1) {
200
+ throw new Error("BitMatrix size must be defined and greater than 0");
201
+ }
202
+ this.size = size;
203
+ this.data = new Uint8Array(size * size);
204
+ this.reservedBit = new Uint8Array(size * size);
205
+ }
206
+ BitMatrix.prototype.set = function(row, col, value, reserved) {
207
+ const index = row * this.size + col;
208
+ this.data[index] = value;
209
+ if (reserved) this.reservedBit[index] = true;
210
+ };
211
+ BitMatrix.prototype.get = function(row, col) {
212
+ return this.data[row * this.size + col];
213
+ };
214
+ BitMatrix.prototype.xor = function(row, col, value) {
215
+ this.data[row * this.size + col] ^= value;
216
+ };
217
+ BitMatrix.prototype.isReserved = function(row, col) {
218
+ return this.reservedBit[row * this.size + col];
219
+ };
220
+ module.exports = BitMatrix;
221
+ }
222
+ });
223
+
224
+ // node_modules/qrcode/lib/core/alignment-pattern.js
225
+ var require_alignment_pattern = __commonJS({
226
+ "node_modules/qrcode/lib/core/alignment-pattern.js"(exports) {
227
+ var getSymbolSize = require_utils().getSymbolSize;
228
+ exports.getRowColCoords = function getRowColCoords(version) {
229
+ if (version === 1) return [];
230
+ const posCount = Math.floor(version / 7) + 2;
231
+ const size = getSymbolSize(version);
232
+ const intervals = size === 145 ? 26 : Math.ceil((size - 13) / (2 * posCount - 2)) * 2;
233
+ const positions = [size - 7];
234
+ for (let i = 1; i < posCount - 1; i++) {
235
+ positions[i] = positions[i - 1] - intervals;
236
+ }
237
+ positions.push(6);
238
+ return positions.reverse();
239
+ };
240
+ exports.getPositions = function getPositions(version) {
241
+ const coords = [];
242
+ const pos = exports.getRowColCoords(version);
243
+ const posLength = pos.length;
244
+ for (let i = 0; i < posLength; i++) {
245
+ for (let j = 0; j < posLength; j++) {
246
+ if (i === 0 && j === 0 || // top-left
247
+ i === 0 && j === posLength - 1 || // bottom-left
248
+ i === posLength - 1 && j === 0) {
249
+ continue;
250
+ }
251
+ coords.push([pos[i], pos[j]]);
252
+ }
253
+ }
254
+ return coords;
255
+ };
256
+ }
257
+ });
258
+
259
+ // node_modules/qrcode/lib/core/finder-pattern.js
260
+ var require_finder_pattern = __commonJS({
261
+ "node_modules/qrcode/lib/core/finder-pattern.js"(exports) {
262
+ var getSymbolSize = require_utils().getSymbolSize;
263
+ var FINDER_PATTERN_SIZE = 7;
264
+ exports.getPositions = function getPositions(version) {
265
+ const size = getSymbolSize(version);
266
+ return [
267
+ // top-left
268
+ [0, 0],
269
+ // top-right
270
+ [size - FINDER_PATTERN_SIZE, 0],
271
+ // bottom-left
272
+ [0, size - FINDER_PATTERN_SIZE]
273
+ ];
274
+ };
275
+ }
276
+ });
277
+
278
+ // node_modules/qrcode/lib/core/mask-pattern.js
279
+ var require_mask_pattern = __commonJS({
280
+ "node_modules/qrcode/lib/core/mask-pattern.js"(exports) {
281
+ exports.Patterns = {
282
+ PATTERN000: 0,
283
+ PATTERN001: 1,
284
+ PATTERN010: 2,
285
+ PATTERN011: 3,
286
+ PATTERN100: 4,
287
+ PATTERN101: 5,
288
+ PATTERN110: 6,
289
+ PATTERN111: 7
290
+ };
291
+ var PenaltyScores = {
292
+ N1: 3,
293
+ N2: 3,
294
+ N3: 40,
295
+ N4: 10
296
+ };
297
+ exports.isValid = function isValid(mask) {
298
+ return mask != null && mask !== "" && !isNaN(mask) && mask >= 0 && mask <= 7;
299
+ };
300
+ exports.from = function from(value) {
301
+ return exports.isValid(value) ? parseInt(value, 10) : void 0;
302
+ };
303
+ exports.getPenaltyN1 = function getPenaltyN1(data) {
304
+ const size = data.size;
305
+ let points = 0;
306
+ let sameCountCol = 0;
307
+ let sameCountRow = 0;
308
+ let lastCol = null;
309
+ let lastRow = null;
310
+ for (let row = 0; row < size; row++) {
311
+ sameCountCol = sameCountRow = 0;
312
+ lastCol = lastRow = null;
313
+ for (let col = 0; col < size; col++) {
314
+ let module2 = data.get(row, col);
315
+ if (module2 === lastCol) {
316
+ sameCountCol++;
317
+ } else {
318
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
319
+ lastCol = module2;
320
+ sameCountCol = 1;
321
+ }
322
+ module2 = data.get(col, row);
323
+ if (module2 === lastRow) {
324
+ sameCountRow++;
325
+ } else {
326
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
327
+ lastRow = module2;
328
+ sameCountRow = 1;
329
+ }
330
+ }
331
+ if (sameCountCol >= 5) points += PenaltyScores.N1 + (sameCountCol - 5);
332
+ if (sameCountRow >= 5) points += PenaltyScores.N1 + (sameCountRow - 5);
333
+ }
334
+ return points;
335
+ };
336
+ exports.getPenaltyN2 = function getPenaltyN2(data) {
337
+ const size = data.size;
338
+ let points = 0;
339
+ for (let row = 0; row < size - 1; row++) {
340
+ for (let col = 0; col < size - 1; col++) {
341
+ const last = data.get(row, col) + data.get(row, col + 1) + data.get(row + 1, col) + data.get(row + 1, col + 1);
342
+ if (last === 4 || last === 0) points++;
343
+ }
344
+ }
345
+ return points * PenaltyScores.N2;
346
+ };
347
+ exports.getPenaltyN3 = function getPenaltyN3(data) {
348
+ const size = data.size;
349
+ let points = 0;
350
+ let bitsCol = 0;
351
+ let bitsRow = 0;
352
+ for (let row = 0; row < size; row++) {
353
+ bitsCol = bitsRow = 0;
354
+ for (let col = 0; col < size; col++) {
355
+ bitsCol = bitsCol << 1 & 2047 | data.get(row, col);
356
+ if (col >= 10 && (bitsCol === 1488 || bitsCol === 93)) points++;
357
+ bitsRow = bitsRow << 1 & 2047 | data.get(col, row);
358
+ if (col >= 10 && (bitsRow === 1488 || bitsRow === 93)) points++;
359
+ }
360
+ }
361
+ return points * PenaltyScores.N3;
362
+ };
363
+ exports.getPenaltyN4 = function getPenaltyN4(data) {
364
+ let darkCount = 0;
365
+ const modulesCount = data.data.length;
366
+ for (let i = 0; i < modulesCount; i++) darkCount += data.data[i];
367
+ const k = Math.abs(Math.ceil(darkCount * 100 / modulesCount / 5) - 10);
368
+ return k * PenaltyScores.N4;
369
+ };
370
+ function getMaskAt(maskPattern, i, j) {
371
+ switch (maskPattern) {
372
+ case exports.Patterns.PATTERN000:
373
+ return (i + j) % 2 === 0;
374
+ case exports.Patterns.PATTERN001:
375
+ return i % 2 === 0;
376
+ case exports.Patterns.PATTERN010:
377
+ return j % 3 === 0;
378
+ case exports.Patterns.PATTERN011:
379
+ return (i + j) % 3 === 0;
380
+ case exports.Patterns.PATTERN100:
381
+ return (Math.floor(i / 2) + Math.floor(j / 3)) % 2 === 0;
382
+ case exports.Patterns.PATTERN101:
383
+ return i * j % 2 + i * j % 3 === 0;
384
+ case exports.Patterns.PATTERN110:
385
+ return (i * j % 2 + i * j % 3) % 2 === 0;
386
+ case exports.Patterns.PATTERN111:
387
+ return (i * j % 3 + (i + j) % 2) % 2 === 0;
388
+ default:
389
+ throw new Error("bad maskPattern:" + maskPattern);
390
+ }
391
+ }
392
+ exports.applyMask = function applyMask(pattern, data) {
393
+ const size = data.size;
394
+ for (let col = 0; col < size; col++) {
395
+ for (let row = 0; row < size; row++) {
396
+ if (data.isReserved(row, col)) continue;
397
+ data.xor(row, col, getMaskAt(pattern, row, col));
398
+ }
399
+ }
400
+ };
401
+ exports.getBestMask = function getBestMask(data, setupFormatFunc) {
402
+ const numPatterns = Object.keys(exports.Patterns).length;
403
+ let bestPattern = 0;
404
+ let lowerPenalty = Infinity;
405
+ for (let p = 0; p < numPatterns; p++) {
406
+ setupFormatFunc(p);
407
+ exports.applyMask(p, data);
408
+ const penalty = exports.getPenaltyN1(data) + exports.getPenaltyN2(data) + exports.getPenaltyN3(data) + exports.getPenaltyN4(data);
409
+ exports.applyMask(p, data);
410
+ if (penalty < lowerPenalty) {
411
+ lowerPenalty = penalty;
412
+ bestPattern = p;
413
+ }
414
+ }
415
+ return bestPattern;
416
+ };
417
+ }
418
+ });
419
+
420
+ // node_modules/qrcode/lib/core/error-correction-code.js
421
+ var require_error_correction_code = __commonJS({
422
+ "node_modules/qrcode/lib/core/error-correction-code.js"(exports) {
423
+ var ECLevel = require_error_correction_level();
424
+ var EC_BLOCKS_TABLE = [
425
+ // L M Q H
426
+ 1,
427
+ 1,
428
+ 1,
429
+ 1,
430
+ 1,
431
+ 1,
432
+ 1,
433
+ 1,
434
+ 1,
435
+ 1,
436
+ 2,
437
+ 2,
438
+ 1,
439
+ 2,
440
+ 2,
441
+ 4,
442
+ 1,
443
+ 2,
444
+ 4,
445
+ 4,
446
+ 2,
447
+ 4,
448
+ 4,
449
+ 4,
450
+ 2,
451
+ 4,
452
+ 6,
453
+ 5,
454
+ 2,
455
+ 4,
456
+ 6,
457
+ 6,
458
+ 2,
459
+ 5,
460
+ 8,
461
+ 8,
462
+ 4,
463
+ 5,
464
+ 8,
465
+ 8,
466
+ 4,
467
+ 5,
468
+ 8,
469
+ 11,
470
+ 4,
471
+ 8,
472
+ 10,
473
+ 11,
474
+ 4,
475
+ 9,
476
+ 12,
477
+ 16,
478
+ 4,
479
+ 9,
480
+ 16,
481
+ 16,
482
+ 6,
483
+ 10,
484
+ 12,
485
+ 18,
486
+ 6,
487
+ 10,
488
+ 17,
489
+ 16,
490
+ 6,
491
+ 11,
492
+ 16,
493
+ 19,
494
+ 6,
495
+ 13,
496
+ 18,
497
+ 21,
498
+ 7,
499
+ 14,
500
+ 21,
501
+ 25,
502
+ 8,
503
+ 16,
504
+ 20,
505
+ 25,
506
+ 8,
507
+ 17,
508
+ 23,
509
+ 25,
510
+ 9,
511
+ 17,
512
+ 23,
513
+ 34,
514
+ 9,
515
+ 18,
516
+ 25,
517
+ 30,
518
+ 10,
519
+ 20,
520
+ 27,
521
+ 32,
522
+ 12,
523
+ 21,
524
+ 29,
525
+ 35,
526
+ 12,
527
+ 23,
528
+ 34,
529
+ 37,
530
+ 12,
531
+ 25,
532
+ 34,
533
+ 40,
534
+ 13,
535
+ 26,
536
+ 35,
537
+ 42,
538
+ 14,
539
+ 28,
540
+ 38,
541
+ 45,
542
+ 15,
543
+ 29,
544
+ 40,
545
+ 48,
546
+ 16,
547
+ 31,
548
+ 43,
549
+ 51,
550
+ 17,
551
+ 33,
552
+ 45,
553
+ 54,
554
+ 18,
555
+ 35,
556
+ 48,
557
+ 57,
558
+ 19,
559
+ 37,
560
+ 51,
561
+ 60,
562
+ 19,
563
+ 38,
564
+ 53,
565
+ 63,
566
+ 20,
567
+ 40,
568
+ 56,
569
+ 66,
570
+ 21,
571
+ 43,
572
+ 59,
573
+ 70,
574
+ 22,
575
+ 45,
576
+ 62,
577
+ 74,
578
+ 24,
579
+ 47,
580
+ 65,
581
+ 77,
582
+ 25,
583
+ 49,
584
+ 68,
585
+ 81
586
+ ];
587
+ var EC_CODEWORDS_TABLE = [
588
+ // L M Q H
589
+ 7,
590
+ 10,
591
+ 13,
592
+ 17,
593
+ 10,
594
+ 16,
595
+ 22,
596
+ 28,
597
+ 15,
598
+ 26,
599
+ 36,
600
+ 44,
601
+ 20,
602
+ 36,
603
+ 52,
604
+ 64,
605
+ 26,
606
+ 48,
607
+ 72,
608
+ 88,
609
+ 36,
610
+ 64,
611
+ 96,
612
+ 112,
613
+ 40,
614
+ 72,
615
+ 108,
616
+ 130,
617
+ 48,
618
+ 88,
619
+ 132,
620
+ 156,
621
+ 60,
622
+ 110,
623
+ 160,
624
+ 192,
625
+ 72,
626
+ 130,
627
+ 192,
628
+ 224,
629
+ 80,
630
+ 150,
631
+ 224,
632
+ 264,
633
+ 96,
634
+ 176,
635
+ 260,
636
+ 308,
637
+ 104,
638
+ 198,
639
+ 288,
640
+ 352,
641
+ 120,
642
+ 216,
643
+ 320,
644
+ 384,
645
+ 132,
646
+ 240,
647
+ 360,
648
+ 432,
649
+ 144,
650
+ 280,
651
+ 408,
652
+ 480,
653
+ 168,
654
+ 308,
655
+ 448,
656
+ 532,
657
+ 180,
658
+ 338,
659
+ 504,
660
+ 588,
661
+ 196,
662
+ 364,
663
+ 546,
664
+ 650,
665
+ 224,
666
+ 416,
667
+ 600,
668
+ 700,
669
+ 224,
670
+ 442,
671
+ 644,
672
+ 750,
673
+ 252,
674
+ 476,
675
+ 690,
676
+ 816,
677
+ 270,
678
+ 504,
679
+ 750,
680
+ 900,
681
+ 300,
682
+ 560,
683
+ 810,
684
+ 960,
685
+ 312,
686
+ 588,
687
+ 870,
688
+ 1050,
689
+ 336,
690
+ 644,
691
+ 952,
692
+ 1110,
693
+ 360,
694
+ 700,
695
+ 1020,
696
+ 1200,
697
+ 390,
698
+ 728,
699
+ 1050,
700
+ 1260,
701
+ 420,
702
+ 784,
703
+ 1140,
704
+ 1350,
705
+ 450,
706
+ 812,
707
+ 1200,
708
+ 1440,
709
+ 480,
710
+ 868,
711
+ 1290,
712
+ 1530,
713
+ 510,
714
+ 924,
715
+ 1350,
716
+ 1620,
717
+ 540,
718
+ 980,
719
+ 1440,
720
+ 1710,
721
+ 570,
722
+ 1036,
723
+ 1530,
724
+ 1800,
725
+ 570,
726
+ 1064,
727
+ 1590,
728
+ 1890,
729
+ 600,
730
+ 1120,
731
+ 1680,
732
+ 1980,
733
+ 630,
734
+ 1204,
735
+ 1770,
736
+ 2100,
737
+ 660,
738
+ 1260,
739
+ 1860,
740
+ 2220,
741
+ 720,
742
+ 1316,
743
+ 1950,
744
+ 2310,
745
+ 750,
746
+ 1372,
747
+ 2040,
748
+ 2430
749
+ ];
750
+ exports.getBlocksCount = function getBlocksCount(version, errorCorrectionLevel) {
751
+ switch (errorCorrectionLevel) {
752
+ case ECLevel.L:
753
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 0];
754
+ case ECLevel.M:
755
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 1];
756
+ case ECLevel.Q:
757
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 2];
758
+ case ECLevel.H:
759
+ return EC_BLOCKS_TABLE[(version - 1) * 4 + 3];
760
+ default:
761
+ return void 0;
762
+ }
763
+ };
764
+ exports.getTotalCodewordsCount = function getTotalCodewordsCount(version, errorCorrectionLevel) {
765
+ switch (errorCorrectionLevel) {
766
+ case ECLevel.L:
767
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 0];
768
+ case ECLevel.M:
769
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 1];
770
+ case ECLevel.Q:
771
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 2];
772
+ case ECLevel.H:
773
+ return EC_CODEWORDS_TABLE[(version - 1) * 4 + 3];
774
+ default:
775
+ return void 0;
776
+ }
777
+ };
778
+ }
779
+ });
780
+
781
+ // node_modules/qrcode/lib/core/galois-field.js
782
+ var require_galois_field = __commonJS({
783
+ "node_modules/qrcode/lib/core/galois-field.js"(exports) {
784
+ var EXP_TABLE = new Uint8Array(512);
785
+ var LOG_TABLE = new Uint8Array(256);
786
+ (function initTables() {
787
+ let x = 1;
788
+ for (let i = 0; i < 255; i++) {
789
+ EXP_TABLE[i] = x;
790
+ LOG_TABLE[x] = i;
791
+ x <<= 1;
792
+ if (x & 256) {
793
+ x ^= 285;
794
+ }
795
+ }
796
+ for (let i = 255; i < 512; i++) {
797
+ EXP_TABLE[i] = EXP_TABLE[i - 255];
798
+ }
799
+ })();
800
+ exports.log = function log(n) {
801
+ if (n < 1) throw new Error("log(" + n + ")");
802
+ return LOG_TABLE[n];
803
+ };
804
+ exports.exp = function exp(n) {
805
+ return EXP_TABLE[n];
806
+ };
807
+ exports.mul = function mul(x, y) {
808
+ if (x === 0 || y === 0) return 0;
809
+ return EXP_TABLE[LOG_TABLE[x] + LOG_TABLE[y]];
810
+ };
811
+ }
812
+ });
813
+
814
+ // node_modules/qrcode/lib/core/polynomial.js
815
+ var require_polynomial = __commonJS({
816
+ "node_modules/qrcode/lib/core/polynomial.js"(exports) {
817
+ var GF = require_galois_field();
818
+ exports.mul = function mul(p1, p2) {
819
+ const coeff = new Uint8Array(p1.length + p2.length - 1);
820
+ for (let i = 0; i < p1.length; i++) {
821
+ for (let j = 0; j < p2.length; j++) {
822
+ coeff[i + j] ^= GF.mul(p1[i], p2[j]);
823
+ }
824
+ }
825
+ return coeff;
826
+ };
827
+ exports.mod = function mod(divident, divisor) {
828
+ let result = new Uint8Array(divident);
829
+ while (result.length - divisor.length >= 0) {
830
+ const coeff = result[0];
831
+ for (let i = 0; i < divisor.length; i++) {
832
+ result[i] ^= GF.mul(divisor[i], coeff);
833
+ }
834
+ let offset = 0;
835
+ while (offset < result.length && result[offset] === 0) offset++;
836
+ result = result.slice(offset);
837
+ }
838
+ return result;
839
+ };
840
+ exports.generateECPolynomial = function generateECPolynomial(degree) {
841
+ let poly = new Uint8Array([1]);
842
+ for (let i = 0; i < degree; i++) {
843
+ poly = exports.mul(poly, new Uint8Array([1, GF.exp(i)]));
844
+ }
845
+ return poly;
846
+ };
847
+ }
848
+ });
849
+
850
+ // node_modules/qrcode/lib/core/reed-solomon-encoder.js
851
+ var require_reed_solomon_encoder = __commonJS({
852
+ "node_modules/qrcode/lib/core/reed-solomon-encoder.js"(exports, module) {
853
+ var Polynomial = require_polynomial();
854
+ function ReedSolomonEncoder(degree) {
855
+ this.genPoly = void 0;
856
+ this.degree = degree;
857
+ if (this.degree) this.initialize(this.degree);
858
+ }
859
+ ReedSolomonEncoder.prototype.initialize = function initialize(degree) {
860
+ this.degree = degree;
861
+ this.genPoly = Polynomial.generateECPolynomial(this.degree);
862
+ };
863
+ ReedSolomonEncoder.prototype.encode = function encode(data) {
864
+ if (!this.genPoly) {
865
+ throw new Error("Encoder not initialized");
866
+ }
867
+ const paddedData = new Uint8Array(data.length + this.degree);
868
+ paddedData.set(data);
869
+ const remainder = Polynomial.mod(paddedData, this.genPoly);
870
+ const start = this.degree - remainder.length;
871
+ if (start > 0) {
872
+ const buff = new Uint8Array(this.degree);
873
+ buff.set(remainder, start);
874
+ return buff;
875
+ }
876
+ return remainder;
877
+ };
878
+ module.exports = ReedSolomonEncoder;
879
+ }
880
+ });
881
+
882
+ // node_modules/qrcode/lib/core/version-check.js
883
+ var require_version_check = __commonJS({
884
+ "node_modules/qrcode/lib/core/version-check.js"(exports) {
885
+ exports.isValid = function isValid(version) {
886
+ return !isNaN(version) && version >= 1 && version <= 40;
887
+ };
888
+ }
889
+ });
890
+
891
+ // node_modules/qrcode/lib/core/regex.js
892
+ var require_regex = __commonJS({
893
+ "node_modules/qrcode/lib/core/regex.js"(exports) {
894
+ var numeric = "[0-9]+";
895
+ var alphanumeric = "[A-Z $%*+\\-./:]+";
896
+ var kanji = "(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";
897
+ kanji = kanji.replace(/u/g, "\\u");
898
+ var byte = "(?:(?![A-Z0-9 $%*+\\-./:]|" + kanji + ")(?:.|[\r\n]))+";
899
+ exports.KANJI = new RegExp(kanji, "g");
900
+ exports.BYTE_KANJI = new RegExp("[^A-Z0-9 $%*+\\-./:]+", "g");
901
+ exports.BYTE = new RegExp(byte, "g");
902
+ exports.NUMERIC = new RegExp(numeric, "g");
903
+ exports.ALPHANUMERIC = new RegExp(alphanumeric, "g");
904
+ var TEST_KANJI = new RegExp("^" + kanji + "$");
905
+ var TEST_NUMERIC = new RegExp("^" + numeric + "$");
906
+ var TEST_ALPHANUMERIC = new RegExp("^[A-Z0-9 $%*+\\-./:]+$");
907
+ exports.testKanji = function testKanji(str) {
908
+ return TEST_KANJI.test(str);
909
+ };
910
+ exports.testNumeric = function testNumeric(str) {
911
+ return TEST_NUMERIC.test(str);
912
+ };
913
+ exports.testAlphanumeric = function testAlphanumeric(str) {
914
+ return TEST_ALPHANUMERIC.test(str);
915
+ };
916
+ }
917
+ });
918
+
919
+ // node_modules/qrcode/lib/core/mode.js
920
+ var require_mode = __commonJS({
921
+ "node_modules/qrcode/lib/core/mode.js"(exports) {
922
+ var VersionCheck = require_version_check();
923
+ var Regex = require_regex();
924
+ exports.NUMERIC = {
925
+ id: "Numeric",
926
+ bit: 1 << 0,
927
+ ccBits: [10, 12, 14]
928
+ };
929
+ exports.ALPHANUMERIC = {
930
+ id: "Alphanumeric",
931
+ bit: 1 << 1,
932
+ ccBits: [9, 11, 13]
933
+ };
934
+ exports.BYTE = {
935
+ id: "Byte",
936
+ bit: 1 << 2,
937
+ ccBits: [8, 16, 16]
938
+ };
939
+ exports.KANJI = {
940
+ id: "Kanji",
941
+ bit: 1 << 3,
942
+ ccBits: [8, 10, 12]
943
+ };
944
+ exports.MIXED = {
945
+ bit: -1
946
+ };
947
+ exports.getCharCountIndicator = function getCharCountIndicator(mode, version) {
948
+ if (!mode.ccBits) throw new Error("Invalid mode: " + mode);
949
+ if (!VersionCheck.isValid(version)) {
950
+ throw new Error("Invalid version: " + version);
951
+ }
952
+ if (version >= 1 && version < 10) return mode.ccBits[0];
953
+ else if (version < 27) return mode.ccBits[1];
954
+ return mode.ccBits[2];
955
+ };
956
+ exports.getBestModeForData = function getBestModeForData(dataStr) {
957
+ if (Regex.testNumeric(dataStr)) return exports.NUMERIC;
958
+ else if (Regex.testAlphanumeric(dataStr)) return exports.ALPHANUMERIC;
959
+ else if (Regex.testKanji(dataStr)) return exports.KANJI;
960
+ else return exports.BYTE;
961
+ };
962
+ exports.toString = function toString(mode) {
963
+ if (mode && mode.id) return mode.id;
964
+ throw new Error("Invalid mode");
965
+ };
966
+ exports.isValid = function isValid(mode) {
967
+ return mode && mode.bit && mode.ccBits;
968
+ };
969
+ function fromString(string) {
970
+ if (typeof string !== "string") {
971
+ throw new Error("Param is not a string");
972
+ }
973
+ const lcStr = string.toLowerCase();
974
+ switch (lcStr) {
975
+ case "numeric":
976
+ return exports.NUMERIC;
977
+ case "alphanumeric":
978
+ return exports.ALPHANUMERIC;
979
+ case "kanji":
980
+ return exports.KANJI;
981
+ case "byte":
982
+ return exports.BYTE;
983
+ default:
984
+ throw new Error("Unknown mode: " + string);
985
+ }
986
+ }
987
+ exports.from = function from(value, defaultValue) {
988
+ if (exports.isValid(value)) {
989
+ return value;
990
+ }
991
+ try {
992
+ return fromString(value);
993
+ } catch (e) {
994
+ return defaultValue;
995
+ }
996
+ };
997
+ }
998
+ });
999
+
1000
+ // node_modules/qrcode/lib/core/version.js
1001
+ var require_version = __commonJS({
1002
+ "node_modules/qrcode/lib/core/version.js"(exports) {
1003
+ var Utils = require_utils();
1004
+ var ECCode = require_error_correction_code();
1005
+ var ECLevel = require_error_correction_level();
1006
+ var Mode = require_mode();
1007
+ var VersionCheck = require_version_check();
1008
+ var G18 = 1 << 12 | 1 << 11 | 1 << 10 | 1 << 9 | 1 << 8 | 1 << 5 | 1 << 2 | 1 << 0;
1009
+ var G18_BCH = Utils.getBCHDigit(G18);
1010
+ function getBestVersionForDataLength(mode, length, errorCorrectionLevel) {
1011
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
1012
+ if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, mode)) {
1013
+ return currentVersion;
1014
+ }
1015
+ }
1016
+ return void 0;
1017
+ }
1018
+ function getReservedBitsCount(mode, version) {
1019
+ return Mode.getCharCountIndicator(mode, version) + 4;
1020
+ }
1021
+ function getTotalBitsFromDataArray(segments, version) {
1022
+ let totalBits = 0;
1023
+ segments.forEach(function(data) {
1024
+ const reservedBits = getReservedBitsCount(data.mode, version);
1025
+ totalBits += reservedBits + data.getBitsLength();
1026
+ });
1027
+ return totalBits;
1028
+ }
1029
+ function getBestVersionForMixedData(segments, errorCorrectionLevel) {
1030
+ for (let currentVersion = 1; currentVersion <= 40; currentVersion++) {
1031
+ const length = getTotalBitsFromDataArray(segments, currentVersion);
1032
+ if (length <= exports.getCapacity(currentVersion, errorCorrectionLevel, Mode.MIXED)) {
1033
+ return currentVersion;
1034
+ }
1035
+ }
1036
+ return void 0;
1037
+ }
1038
+ exports.from = function from(value, defaultValue) {
1039
+ if (VersionCheck.isValid(value)) {
1040
+ return parseInt(value, 10);
1041
+ }
1042
+ return defaultValue;
1043
+ };
1044
+ exports.getCapacity = function getCapacity(version, errorCorrectionLevel, mode) {
1045
+ if (!VersionCheck.isValid(version)) {
1046
+ throw new Error("Invalid QR Code version");
1047
+ }
1048
+ if (typeof mode === "undefined") mode = Mode.BYTE;
1049
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
1050
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
1051
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
1052
+ if (mode === Mode.MIXED) return dataTotalCodewordsBits;
1053
+ const usableBits = dataTotalCodewordsBits - getReservedBitsCount(mode, version);
1054
+ switch (mode) {
1055
+ case Mode.NUMERIC:
1056
+ return Math.floor(usableBits / 10 * 3);
1057
+ case Mode.ALPHANUMERIC:
1058
+ return Math.floor(usableBits / 11 * 2);
1059
+ case Mode.KANJI:
1060
+ return Math.floor(usableBits / 13);
1061
+ case Mode.BYTE:
1062
+ default:
1063
+ return Math.floor(usableBits / 8);
1064
+ }
1065
+ };
1066
+ exports.getBestVersionForData = function getBestVersionForData(data, errorCorrectionLevel) {
1067
+ let seg;
1068
+ const ecl = ECLevel.from(errorCorrectionLevel, ECLevel.M);
1069
+ if (Array.isArray(data)) {
1070
+ if (data.length > 1) {
1071
+ return getBestVersionForMixedData(data, ecl);
1072
+ }
1073
+ if (data.length === 0) {
1074
+ return 1;
1075
+ }
1076
+ seg = data[0];
1077
+ } else {
1078
+ seg = data;
1079
+ }
1080
+ return getBestVersionForDataLength(seg.mode, seg.getLength(), ecl);
1081
+ };
1082
+ exports.getEncodedBits = function getEncodedBits(version) {
1083
+ if (!VersionCheck.isValid(version) || version < 7) {
1084
+ throw new Error("Invalid QR Code version");
1085
+ }
1086
+ let d = version << 12;
1087
+ while (Utils.getBCHDigit(d) - G18_BCH >= 0) {
1088
+ d ^= G18 << Utils.getBCHDigit(d) - G18_BCH;
1089
+ }
1090
+ return version << 12 | d;
1091
+ };
1092
+ }
1093
+ });
1094
+
1095
+ // node_modules/qrcode/lib/core/format-info.js
1096
+ var require_format_info = __commonJS({
1097
+ "node_modules/qrcode/lib/core/format-info.js"(exports) {
1098
+ var Utils = require_utils();
1099
+ var G15 = 1 << 10 | 1 << 8 | 1 << 5 | 1 << 4 | 1 << 2 | 1 << 1 | 1 << 0;
1100
+ var G15_MASK = 1 << 14 | 1 << 12 | 1 << 10 | 1 << 4 | 1 << 1;
1101
+ var G15_BCH = Utils.getBCHDigit(G15);
1102
+ exports.getEncodedBits = function getEncodedBits(errorCorrectionLevel, mask) {
1103
+ const data = errorCorrectionLevel.bit << 3 | mask;
1104
+ let d = data << 10;
1105
+ while (Utils.getBCHDigit(d) - G15_BCH >= 0) {
1106
+ d ^= G15 << Utils.getBCHDigit(d) - G15_BCH;
1107
+ }
1108
+ return (data << 10 | d) ^ G15_MASK;
1109
+ };
1110
+ }
1111
+ });
1112
+
1113
+ // node_modules/qrcode/lib/core/numeric-data.js
1114
+ var require_numeric_data = __commonJS({
1115
+ "node_modules/qrcode/lib/core/numeric-data.js"(exports, module) {
1116
+ var Mode = require_mode();
1117
+ function NumericData(data) {
1118
+ this.mode = Mode.NUMERIC;
1119
+ this.data = data.toString();
1120
+ }
1121
+ NumericData.getBitsLength = function getBitsLength(length) {
1122
+ return 10 * Math.floor(length / 3) + (length % 3 ? length % 3 * 3 + 1 : 0);
1123
+ };
1124
+ NumericData.prototype.getLength = function getLength() {
1125
+ return this.data.length;
1126
+ };
1127
+ NumericData.prototype.getBitsLength = function getBitsLength() {
1128
+ return NumericData.getBitsLength(this.data.length);
1129
+ };
1130
+ NumericData.prototype.write = function write(bitBuffer) {
1131
+ let i, group, value;
1132
+ for (i = 0; i + 3 <= this.data.length; i += 3) {
1133
+ group = this.data.substr(i, 3);
1134
+ value = parseInt(group, 10);
1135
+ bitBuffer.put(value, 10);
1136
+ }
1137
+ const remainingNum = this.data.length - i;
1138
+ if (remainingNum > 0) {
1139
+ group = this.data.substr(i);
1140
+ value = parseInt(group, 10);
1141
+ bitBuffer.put(value, remainingNum * 3 + 1);
1142
+ }
1143
+ };
1144
+ module.exports = NumericData;
1145
+ }
1146
+ });
1147
+
1148
+ // node_modules/qrcode/lib/core/alphanumeric-data.js
1149
+ var require_alphanumeric_data = __commonJS({
1150
+ "node_modules/qrcode/lib/core/alphanumeric-data.js"(exports, module) {
1151
+ var Mode = require_mode();
1152
+ var ALPHA_NUM_CHARS = [
1153
+ "0",
1154
+ "1",
1155
+ "2",
1156
+ "3",
1157
+ "4",
1158
+ "5",
1159
+ "6",
1160
+ "7",
1161
+ "8",
1162
+ "9",
1163
+ "A",
1164
+ "B",
1165
+ "C",
1166
+ "D",
1167
+ "E",
1168
+ "F",
1169
+ "G",
1170
+ "H",
1171
+ "I",
1172
+ "J",
1173
+ "K",
1174
+ "L",
1175
+ "M",
1176
+ "N",
1177
+ "O",
1178
+ "P",
1179
+ "Q",
1180
+ "R",
1181
+ "S",
1182
+ "T",
1183
+ "U",
1184
+ "V",
1185
+ "W",
1186
+ "X",
1187
+ "Y",
1188
+ "Z",
1189
+ " ",
1190
+ "$",
1191
+ "%",
1192
+ "*",
1193
+ "+",
1194
+ "-",
1195
+ ".",
1196
+ "/",
1197
+ ":"
1198
+ ];
1199
+ function AlphanumericData(data) {
1200
+ this.mode = Mode.ALPHANUMERIC;
1201
+ this.data = data;
1202
+ }
1203
+ AlphanumericData.getBitsLength = function getBitsLength(length) {
1204
+ return 11 * Math.floor(length / 2) + 6 * (length % 2);
1205
+ };
1206
+ AlphanumericData.prototype.getLength = function getLength() {
1207
+ return this.data.length;
1208
+ };
1209
+ AlphanumericData.prototype.getBitsLength = function getBitsLength() {
1210
+ return AlphanumericData.getBitsLength(this.data.length);
1211
+ };
1212
+ AlphanumericData.prototype.write = function write(bitBuffer) {
1213
+ let i;
1214
+ for (i = 0; i + 2 <= this.data.length; i += 2) {
1215
+ let value = ALPHA_NUM_CHARS.indexOf(this.data[i]) * 45;
1216
+ value += ALPHA_NUM_CHARS.indexOf(this.data[i + 1]);
1217
+ bitBuffer.put(value, 11);
1218
+ }
1219
+ if (this.data.length % 2) {
1220
+ bitBuffer.put(ALPHA_NUM_CHARS.indexOf(this.data[i]), 6);
1221
+ }
1222
+ };
1223
+ module.exports = AlphanumericData;
1224
+ }
1225
+ });
1226
+
1227
+ // node_modules/qrcode/lib/core/byte-data.js
1228
+ var require_byte_data = __commonJS({
1229
+ "node_modules/qrcode/lib/core/byte-data.js"(exports, module) {
1230
+ var Mode = require_mode();
1231
+ function ByteData(data) {
1232
+ this.mode = Mode.BYTE;
1233
+ if (typeof data === "string") {
1234
+ this.data = new TextEncoder().encode(data);
1235
+ } else {
1236
+ this.data = new Uint8Array(data);
1237
+ }
1238
+ }
1239
+ ByteData.getBitsLength = function getBitsLength(length) {
1240
+ return length * 8;
1241
+ };
1242
+ ByteData.prototype.getLength = function getLength() {
1243
+ return this.data.length;
1244
+ };
1245
+ ByteData.prototype.getBitsLength = function getBitsLength() {
1246
+ return ByteData.getBitsLength(this.data.length);
1247
+ };
1248
+ ByteData.prototype.write = function(bitBuffer) {
1249
+ for (let i = 0, l = this.data.length; i < l; i++) {
1250
+ bitBuffer.put(this.data[i], 8);
1251
+ }
1252
+ };
1253
+ module.exports = ByteData;
1254
+ }
1255
+ });
1256
+
1257
+ // node_modules/qrcode/lib/core/kanji-data.js
1258
+ var require_kanji_data = __commonJS({
1259
+ "node_modules/qrcode/lib/core/kanji-data.js"(exports, module) {
1260
+ var Mode = require_mode();
1261
+ var Utils = require_utils();
1262
+ function KanjiData(data) {
1263
+ this.mode = Mode.KANJI;
1264
+ this.data = data;
1265
+ }
1266
+ KanjiData.getBitsLength = function getBitsLength(length) {
1267
+ return length * 13;
1268
+ };
1269
+ KanjiData.prototype.getLength = function getLength() {
1270
+ return this.data.length;
1271
+ };
1272
+ KanjiData.prototype.getBitsLength = function getBitsLength() {
1273
+ return KanjiData.getBitsLength(this.data.length);
1274
+ };
1275
+ KanjiData.prototype.write = function(bitBuffer) {
1276
+ let i;
1277
+ for (i = 0; i < this.data.length; i++) {
1278
+ let value = Utils.toSJIS(this.data[i]);
1279
+ if (value >= 33088 && value <= 40956) {
1280
+ value -= 33088;
1281
+ } else if (value >= 57408 && value <= 60351) {
1282
+ value -= 49472;
1283
+ } else {
1284
+ throw new Error(
1285
+ "Invalid SJIS character: " + this.data[i] + "\nMake sure your charset is UTF-8"
1286
+ );
1287
+ }
1288
+ value = (value >>> 8 & 255) * 192 + (value & 255);
1289
+ bitBuffer.put(value, 13);
1290
+ }
1291
+ };
1292
+ module.exports = KanjiData;
1293
+ }
1294
+ });
1295
+
1296
+ // node_modules/dijkstrajs/dijkstra.js
1297
+ var require_dijkstra = __commonJS({
1298
+ "node_modules/dijkstrajs/dijkstra.js"(exports, module) {
1299
+ "use strict";
1300
+ var dijkstra = {
1301
+ single_source_shortest_paths: function(graph, s, d) {
1302
+ var predecessors = {};
1303
+ var costs = {};
1304
+ costs[s] = 0;
1305
+ var open = dijkstra.PriorityQueue.make();
1306
+ open.push(s, 0);
1307
+ var closest, u, v, cost_of_s_to_u, adjacent_nodes, cost_of_e, cost_of_s_to_u_plus_cost_of_e, cost_of_s_to_v, first_visit;
1308
+ while (!open.empty()) {
1309
+ closest = open.pop();
1310
+ u = closest.value;
1311
+ cost_of_s_to_u = closest.cost;
1312
+ adjacent_nodes = graph[u] || {};
1313
+ for (v in adjacent_nodes) {
1314
+ if (adjacent_nodes.hasOwnProperty(v)) {
1315
+ cost_of_e = adjacent_nodes[v];
1316
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
1317
+ cost_of_s_to_v = costs[v];
1318
+ first_visit = typeof costs[v] === "undefined";
1319
+ if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
1320
+ costs[v] = cost_of_s_to_u_plus_cost_of_e;
1321
+ open.push(v, cost_of_s_to_u_plus_cost_of_e);
1322
+ predecessors[v] = u;
1323
+ }
1324
+ }
1325
+ }
1326
+ }
1327
+ if (typeof d !== "undefined" && typeof costs[d] === "undefined") {
1328
+ var msg = ["Could not find a path from ", s, " to ", d, "."].join("");
1329
+ throw new Error(msg);
1330
+ }
1331
+ return predecessors;
1332
+ },
1333
+ extract_shortest_path_from_predecessor_list: function(predecessors, d) {
1334
+ var nodes = [];
1335
+ var u = d;
1336
+ var predecessor;
1337
+ while (u) {
1338
+ nodes.push(u);
1339
+ predecessor = predecessors[u];
1340
+ u = predecessors[u];
1341
+ }
1342
+ nodes.reverse();
1343
+ return nodes;
1344
+ },
1345
+ find_path: function(graph, s, d) {
1346
+ var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
1347
+ return dijkstra.extract_shortest_path_from_predecessor_list(
1348
+ predecessors,
1349
+ d
1350
+ );
1351
+ },
1352
+ /**
1353
+ * A very naive priority queue implementation.
1354
+ */
1355
+ PriorityQueue: {
1356
+ make: function(opts) {
1357
+ var T = dijkstra.PriorityQueue, t = {}, key;
1358
+ opts = opts || {};
1359
+ for (key in T) {
1360
+ if (T.hasOwnProperty(key)) {
1361
+ t[key] = T[key];
1362
+ }
1363
+ }
1364
+ t.queue = [];
1365
+ t.sorter = opts.sorter || T.default_sorter;
1366
+ return t;
1367
+ },
1368
+ default_sorter: function(a, b) {
1369
+ return a.cost - b.cost;
1370
+ },
1371
+ /**
1372
+ * Add a new item to the queue and ensure the highest priority element
1373
+ * is at the front of the queue.
1374
+ */
1375
+ push: function(value, cost) {
1376
+ var item = { value, cost };
1377
+ this.queue.push(item);
1378
+ this.queue.sort(this.sorter);
1379
+ },
1380
+ /**
1381
+ * Return the highest priority element in the queue.
1382
+ */
1383
+ pop: function() {
1384
+ return this.queue.shift();
1385
+ },
1386
+ empty: function() {
1387
+ return this.queue.length === 0;
1388
+ }
1389
+ }
1390
+ };
1391
+ if (typeof module !== "undefined") {
1392
+ module.exports = dijkstra;
1393
+ }
1394
+ }
1395
+ });
1396
+
1397
+ // node_modules/qrcode/lib/core/segments.js
1398
+ var require_segments = __commonJS({
1399
+ "node_modules/qrcode/lib/core/segments.js"(exports) {
1400
+ var Mode = require_mode();
1401
+ var NumericData = require_numeric_data();
1402
+ var AlphanumericData = require_alphanumeric_data();
1403
+ var ByteData = require_byte_data();
1404
+ var KanjiData = require_kanji_data();
1405
+ var Regex = require_regex();
1406
+ var Utils = require_utils();
1407
+ var dijkstra = require_dijkstra();
1408
+ function getStringByteLength(str) {
1409
+ return unescape(encodeURIComponent(str)).length;
1410
+ }
1411
+ function getSegments(regex, mode, str) {
1412
+ const segments = [];
1413
+ let result;
1414
+ while ((result = regex.exec(str)) !== null) {
1415
+ segments.push({
1416
+ data: result[0],
1417
+ index: result.index,
1418
+ mode,
1419
+ length: result[0].length
1420
+ });
1421
+ }
1422
+ return segments;
1423
+ }
1424
+ function getSegmentsFromString(dataStr) {
1425
+ const numSegs = getSegments(Regex.NUMERIC, Mode.NUMERIC, dataStr);
1426
+ const alphaNumSegs = getSegments(Regex.ALPHANUMERIC, Mode.ALPHANUMERIC, dataStr);
1427
+ let byteSegs;
1428
+ let kanjiSegs;
1429
+ if (Utils.isKanjiModeEnabled()) {
1430
+ byteSegs = getSegments(Regex.BYTE, Mode.BYTE, dataStr);
1431
+ kanjiSegs = getSegments(Regex.KANJI, Mode.KANJI, dataStr);
1432
+ } else {
1433
+ byteSegs = getSegments(Regex.BYTE_KANJI, Mode.BYTE, dataStr);
1434
+ kanjiSegs = [];
1435
+ }
1436
+ const segs = numSegs.concat(alphaNumSegs, byteSegs, kanjiSegs);
1437
+ return segs.sort(function(s1, s2) {
1438
+ return s1.index - s2.index;
1439
+ }).map(function(obj) {
1440
+ return {
1441
+ data: obj.data,
1442
+ mode: obj.mode,
1443
+ length: obj.length
1444
+ };
1445
+ });
1446
+ }
1447
+ function getSegmentBitsLength(length, mode) {
1448
+ switch (mode) {
1449
+ case Mode.NUMERIC:
1450
+ return NumericData.getBitsLength(length);
1451
+ case Mode.ALPHANUMERIC:
1452
+ return AlphanumericData.getBitsLength(length);
1453
+ case Mode.KANJI:
1454
+ return KanjiData.getBitsLength(length);
1455
+ case Mode.BYTE:
1456
+ return ByteData.getBitsLength(length);
1457
+ }
1458
+ }
1459
+ function mergeSegments(segs) {
1460
+ return segs.reduce(function(acc, curr) {
1461
+ const prevSeg = acc.length - 1 >= 0 ? acc[acc.length - 1] : null;
1462
+ if (prevSeg && prevSeg.mode === curr.mode) {
1463
+ acc[acc.length - 1].data += curr.data;
1464
+ return acc;
1465
+ }
1466
+ acc.push(curr);
1467
+ return acc;
1468
+ }, []);
1469
+ }
1470
+ function buildNodes(segs) {
1471
+ const nodes = [];
1472
+ for (let i = 0; i < segs.length; i++) {
1473
+ const seg = segs[i];
1474
+ switch (seg.mode) {
1475
+ case Mode.NUMERIC:
1476
+ nodes.push([
1477
+ seg,
1478
+ { data: seg.data, mode: Mode.ALPHANUMERIC, length: seg.length },
1479
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
1480
+ ]);
1481
+ break;
1482
+ case Mode.ALPHANUMERIC:
1483
+ nodes.push([
1484
+ seg,
1485
+ { data: seg.data, mode: Mode.BYTE, length: seg.length }
1486
+ ]);
1487
+ break;
1488
+ case Mode.KANJI:
1489
+ nodes.push([
1490
+ seg,
1491
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
1492
+ ]);
1493
+ break;
1494
+ case Mode.BYTE:
1495
+ nodes.push([
1496
+ { data: seg.data, mode: Mode.BYTE, length: getStringByteLength(seg.data) }
1497
+ ]);
1498
+ }
1499
+ }
1500
+ return nodes;
1501
+ }
1502
+ function buildGraph(nodes, version) {
1503
+ const table = {};
1504
+ const graph = { start: {} };
1505
+ let prevNodeIds = ["start"];
1506
+ for (let i = 0; i < nodes.length; i++) {
1507
+ const nodeGroup = nodes[i];
1508
+ const currentNodeIds = [];
1509
+ for (let j = 0; j < nodeGroup.length; j++) {
1510
+ const node = nodeGroup[j];
1511
+ const key = "" + i + j;
1512
+ currentNodeIds.push(key);
1513
+ table[key] = { node, lastCount: 0 };
1514
+ graph[key] = {};
1515
+ for (let n = 0; n < prevNodeIds.length; n++) {
1516
+ const prevNodeId = prevNodeIds[n];
1517
+ if (table[prevNodeId] && table[prevNodeId].node.mode === node.mode) {
1518
+ graph[prevNodeId][key] = getSegmentBitsLength(table[prevNodeId].lastCount + node.length, node.mode) - getSegmentBitsLength(table[prevNodeId].lastCount, node.mode);
1519
+ table[prevNodeId].lastCount += node.length;
1520
+ } else {
1521
+ if (table[prevNodeId]) table[prevNodeId].lastCount = node.length;
1522
+ graph[prevNodeId][key] = getSegmentBitsLength(node.length, node.mode) + 4 + Mode.getCharCountIndicator(node.mode, version);
1523
+ }
1524
+ }
1525
+ }
1526
+ prevNodeIds = currentNodeIds;
1527
+ }
1528
+ for (let n = 0; n < prevNodeIds.length; n++) {
1529
+ graph[prevNodeIds[n]].end = 0;
1530
+ }
1531
+ return { map: graph, table };
1532
+ }
1533
+ function buildSingleSegment(data, modesHint) {
1534
+ let mode;
1535
+ const bestMode = Mode.getBestModeForData(data);
1536
+ mode = Mode.from(modesHint, bestMode);
1537
+ if (mode !== Mode.BYTE && mode.bit < bestMode.bit) {
1538
+ throw new Error('"' + data + '" cannot be encoded with mode ' + Mode.toString(mode) + ".\n Suggested mode is: " + Mode.toString(bestMode));
1539
+ }
1540
+ if (mode === Mode.KANJI && !Utils.isKanjiModeEnabled()) {
1541
+ mode = Mode.BYTE;
1542
+ }
1543
+ switch (mode) {
1544
+ case Mode.NUMERIC:
1545
+ return new NumericData(data);
1546
+ case Mode.ALPHANUMERIC:
1547
+ return new AlphanumericData(data);
1548
+ case Mode.KANJI:
1549
+ return new KanjiData(data);
1550
+ case Mode.BYTE:
1551
+ return new ByteData(data);
1552
+ }
1553
+ }
1554
+ exports.fromArray = function fromArray(array) {
1555
+ return array.reduce(function(acc, seg) {
1556
+ if (typeof seg === "string") {
1557
+ acc.push(buildSingleSegment(seg, null));
1558
+ } else if (seg.data) {
1559
+ acc.push(buildSingleSegment(seg.data, seg.mode));
1560
+ }
1561
+ return acc;
1562
+ }, []);
1563
+ };
1564
+ exports.fromString = function fromString(data, version) {
1565
+ const segs = getSegmentsFromString(data, Utils.isKanjiModeEnabled());
1566
+ const nodes = buildNodes(segs);
1567
+ const graph = buildGraph(nodes, version);
1568
+ const path = dijkstra.find_path(graph.map, "start", "end");
1569
+ const optimizedSegs = [];
1570
+ for (let i = 1; i < path.length - 1; i++) {
1571
+ optimizedSegs.push(graph.table[path[i]].node);
1572
+ }
1573
+ return exports.fromArray(mergeSegments(optimizedSegs));
1574
+ };
1575
+ exports.rawSplit = function rawSplit(data) {
1576
+ return exports.fromArray(
1577
+ getSegmentsFromString(data, Utils.isKanjiModeEnabled())
1578
+ );
1579
+ };
1580
+ }
1581
+ });
1582
+
1583
+ // node_modules/qrcode/lib/core/qrcode.js
1584
+ var require_qrcode = __commonJS({
1585
+ "node_modules/qrcode/lib/core/qrcode.js"(exports) {
1586
+ var Utils = require_utils();
1587
+ var ECLevel = require_error_correction_level();
1588
+ var BitBuffer = require_bit_buffer();
1589
+ var BitMatrix = require_bit_matrix();
1590
+ var AlignmentPattern = require_alignment_pattern();
1591
+ var FinderPattern = require_finder_pattern();
1592
+ var MaskPattern = require_mask_pattern();
1593
+ var ECCode = require_error_correction_code();
1594
+ var ReedSolomonEncoder = require_reed_solomon_encoder();
1595
+ var Version = require_version();
1596
+ var FormatInfo = require_format_info();
1597
+ var Mode = require_mode();
1598
+ var Segments = require_segments();
1599
+ function setupFinderPattern(matrix, version) {
1600
+ const size = matrix.size;
1601
+ const pos = FinderPattern.getPositions(version);
1602
+ for (let i = 0; i < pos.length; i++) {
1603
+ const row = pos[i][0];
1604
+ const col = pos[i][1];
1605
+ for (let r = -1; r <= 7; r++) {
1606
+ if (row + r <= -1 || size <= row + r) continue;
1607
+ for (let c = -1; c <= 7; c++) {
1608
+ if (col + c <= -1 || size <= col + c) continue;
1609
+ if (r >= 0 && r <= 6 && (c === 0 || c === 6) || c >= 0 && c <= 6 && (r === 0 || r === 6) || r >= 2 && r <= 4 && c >= 2 && c <= 4) {
1610
+ matrix.set(row + r, col + c, true, true);
1611
+ } else {
1612
+ matrix.set(row + r, col + c, false, true);
1613
+ }
1614
+ }
1615
+ }
1616
+ }
1617
+ }
1618
+ function setupTimingPattern(matrix) {
1619
+ const size = matrix.size;
1620
+ for (let r = 8; r < size - 8; r++) {
1621
+ const value = r % 2 === 0;
1622
+ matrix.set(r, 6, value, true);
1623
+ matrix.set(6, r, value, true);
1624
+ }
1625
+ }
1626
+ function setupAlignmentPattern(matrix, version) {
1627
+ const pos = AlignmentPattern.getPositions(version);
1628
+ for (let i = 0; i < pos.length; i++) {
1629
+ const row = pos[i][0];
1630
+ const col = pos[i][1];
1631
+ for (let r = -2; r <= 2; r++) {
1632
+ for (let c = -2; c <= 2; c++) {
1633
+ if (r === -2 || r === 2 || c === -2 || c === 2 || r === 0 && c === 0) {
1634
+ matrix.set(row + r, col + c, true, true);
1635
+ } else {
1636
+ matrix.set(row + r, col + c, false, true);
1637
+ }
1638
+ }
1639
+ }
1640
+ }
1641
+ }
1642
+ function setupVersionInfo(matrix, version) {
1643
+ const size = matrix.size;
1644
+ const bits = Version.getEncodedBits(version);
1645
+ let row, col, mod;
1646
+ for (let i = 0; i < 18; i++) {
1647
+ row = Math.floor(i / 3);
1648
+ col = i % 3 + size - 8 - 3;
1649
+ mod = (bits >> i & 1) === 1;
1650
+ matrix.set(row, col, mod, true);
1651
+ matrix.set(col, row, mod, true);
1652
+ }
1653
+ }
1654
+ function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
1655
+ const size = matrix.size;
1656
+ const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
1657
+ let i, mod;
1658
+ for (i = 0; i < 15; i++) {
1659
+ mod = (bits >> i & 1) === 1;
1660
+ if (i < 6) {
1661
+ matrix.set(i, 8, mod, true);
1662
+ } else if (i < 8) {
1663
+ matrix.set(i + 1, 8, mod, true);
1664
+ } else {
1665
+ matrix.set(size - 15 + i, 8, mod, true);
1666
+ }
1667
+ if (i < 8) {
1668
+ matrix.set(8, size - i - 1, mod, true);
1669
+ } else if (i < 9) {
1670
+ matrix.set(8, 15 - i - 1 + 1, mod, true);
1671
+ } else {
1672
+ matrix.set(8, 15 - i - 1, mod, true);
1673
+ }
1674
+ }
1675
+ matrix.set(size - 8, 8, 1, true);
1676
+ }
1677
+ function setupData(matrix, data) {
1678
+ const size = matrix.size;
1679
+ let inc = -1;
1680
+ let row = size - 1;
1681
+ let bitIndex = 7;
1682
+ let byteIndex = 0;
1683
+ for (let col = size - 1; col > 0; col -= 2) {
1684
+ if (col === 6) col--;
1685
+ while (true) {
1686
+ for (let c = 0; c < 2; c++) {
1687
+ if (!matrix.isReserved(row, col - c)) {
1688
+ let dark = false;
1689
+ if (byteIndex < data.length) {
1690
+ dark = (data[byteIndex] >>> bitIndex & 1) === 1;
1691
+ }
1692
+ matrix.set(row, col - c, dark);
1693
+ bitIndex--;
1694
+ if (bitIndex === -1) {
1695
+ byteIndex++;
1696
+ bitIndex = 7;
1697
+ }
1698
+ }
1699
+ }
1700
+ row += inc;
1701
+ if (row < 0 || size <= row) {
1702
+ row -= inc;
1703
+ inc = -inc;
1704
+ break;
1705
+ }
1706
+ }
1707
+ }
1708
+ }
1709
+ function createData(version, errorCorrectionLevel, segments) {
1710
+ const buffer = new BitBuffer();
1711
+ segments.forEach(function(data) {
1712
+ buffer.put(data.mode.bit, 4);
1713
+ buffer.put(data.getLength(), Mode.getCharCountIndicator(data.mode, version));
1714
+ data.write(buffer);
1715
+ });
1716
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
1717
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
1718
+ const dataTotalCodewordsBits = (totalCodewords - ecTotalCodewords) * 8;
1719
+ if (buffer.getLengthInBits() + 4 <= dataTotalCodewordsBits) {
1720
+ buffer.put(0, 4);
1721
+ }
1722
+ while (buffer.getLengthInBits() % 8 !== 0) {
1723
+ buffer.putBit(0);
1724
+ }
1725
+ const remainingByte = (dataTotalCodewordsBits - buffer.getLengthInBits()) / 8;
1726
+ for (let i = 0; i < remainingByte; i++) {
1727
+ buffer.put(i % 2 ? 17 : 236, 8);
1728
+ }
1729
+ return createCodewords(buffer, version, errorCorrectionLevel);
1730
+ }
1731
+ function createCodewords(bitBuffer, version, errorCorrectionLevel) {
1732
+ const totalCodewords = Utils.getSymbolTotalCodewords(version);
1733
+ const ecTotalCodewords = ECCode.getTotalCodewordsCount(version, errorCorrectionLevel);
1734
+ const dataTotalCodewords = totalCodewords - ecTotalCodewords;
1735
+ const ecTotalBlocks = ECCode.getBlocksCount(version, errorCorrectionLevel);
1736
+ const blocksInGroup2 = totalCodewords % ecTotalBlocks;
1737
+ const blocksInGroup1 = ecTotalBlocks - blocksInGroup2;
1738
+ const totalCodewordsInGroup1 = Math.floor(totalCodewords / ecTotalBlocks);
1739
+ const dataCodewordsInGroup1 = Math.floor(dataTotalCodewords / ecTotalBlocks);
1740
+ const dataCodewordsInGroup2 = dataCodewordsInGroup1 + 1;
1741
+ const ecCount = totalCodewordsInGroup1 - dataCodewordsInGroup1;
1742
+ const rs = new ReedSolomonEncoder(ecCount);
1743
+ let offset = 0;
1744
+ const dcData = new Array(ecTotalBlocks);
1745
+ const ecData = new Array(ecTotalBlocks);
1746
+ let maxDataSize = 0;
1747
+ const buffer = new Uint8Array(bitBuffer.buffer);
1748
+ for (let b = 0; b < ecTotalBlocks; b++) {
1749
+ const dataSize = b < blocksInGroup1 ? dataCodewordsInGroup1 : dataCodewordsInGroup2;
1750
+ dcData[b] = buffer.slice(offset, offset + dataSize);
1751
+ ecData[b] = rs.encode(dcData[b]);
1752
+ offset += dataSize;
1753
+ maxDataSize = Math.max(maxDataSize, dataSize);
1754
+ }
1755
+ const data = new Uint8Array(totalCodewords);
1756
+ let index = 0;
1757
+ let i, r;
1758
+ for (i = 0; i < maxDataSize; i++) {
1759
+ for (r = 0; r < ecTotalBlocks; r++) {
1760
+ if (i < dcData[r].length) {
1761
+ data[index++] = dcData[r][i];
1762
+ }
1763
+ }
1764
+ }
1765
+ for (i = 0; i < ecCount; i++) {
1766
+ for (r = 0; r < ecTotalBlocks; r++) {
1767
+ data[index++] = ecData[r][i];
1768
+ }
1769
+ }
1770
+ return data;
1771
+ }
1772
+ function createSymbol(data, version, errorCorrectionLevel, maskPattern) {
1773
+ let segments;
1774
+ if (Array.isArray(data)) {
1775
+ segments = Segments.fromArray(data);
1776
+ } else if (typeof data === "string") {
1777
+ let estimatedVersion = version;
1778
+ if (!estimatedVersion) {
1779
+ const rawSegments = Segments.rawSplit(data);
1780
+ estimatedVersion = Version.getBestVersionForData(rawSegments, errorCorrectionLevel);
1781
+ }
1782
+ segments = Segments.fromString(data, estimatedVersion || 40);
1783
+ } else {
1784
+ throw new Error("Invalid data");
1785
+ }
1786
+ const bestVersion = Version.getBestVersionForData(segments, errorCorrectionLevel);
1787
+ if (!bestVersion) {
1788
+ throw new Error("The amount of data is too big to be stored in a QR Code");
1789
+ }
1790
+ if (!version) {
1791
+ version = bestVersion;
1792
+ } else if (version < bestVersion) {
1793
+ throw new Error(
1794
+ "\nThe chosen QR Code version cannot contain this amount of data.\nMinimum version required to store current data is: " + bestVersion + ".\n"
1795
+ );
1796
+ }
1797
+ const dataBits = createData(version, errorCorrectionLevel, segments);
1798
+ const moduleCount = Utils.getSymbolSize(version);
1799
+ const modules = new BitMatrix(moduleCount);
1800
+ setupFinderPattern(modules, version);
1801
+ setupTimingPattern(modules);
1802
+ setupAlignmentPattern(modules, version);
1803
+ setupFormatInfo(modules, errorCorrectionLevel, 0);
1804
+ if (version >= 7) {
1805
+ setupVersionInfo(modules, version);
1806
+ }
1807
+ setupData(modules, dataBits);
1808
+ if (isNaN(maskPattern)) {
1809
+ maskPattern = MaskPattern.getBestMask(
1810
+ modules,
1811
+ setupFormatInfo.bind(null, modules, errorCorrectionLevel)
1812
+ );
1813
+ }
1814
+ MaskPattern.applyMask(maskPattern, modules);
1815
+ setupFormatInfo(modules, errorCorrectionLevel, maskPattern);
1816
+ return {
1817
+ modules,
1818
+ version,
1819
+ errorCorrectionLevel,
1820
+ maskPattern,
1821
+ segments
1822
+ };
1823
+ }
1824
+ exports.create = function create(data, options) {
1825
+ if (typeof data === "undefined" || data === "") {
1826
+ throw new Error("No input text");
1827
+ }
1828
+ let errorCorrectionLevel = ECLevel.M;
1829
+ let version;
1830
+ let mask;
1831
+ if (typeof options !== "undefined") {
1832
+ errorCorrectionLevel = ECLevel.from(options.errorCorrectionLevel, ECLevel.M);
1833
+ version = Version.from(options.version);
1834
+ mask = MaskPattern.from(options.maskPattern);
1835
+ if (options.toSJISFunc) {
1836
+ Utils.setToSJISFunction(options.toSJISFunc);
1837
+ }
1838
+ }
1839
+ return createSymbol(data, version, errorCorrectionLevel, mask);
1840
+ };
1841
+ }
1842
+ });
1843
+
1844
+ // node_modules/qrcode/lib/renderer/utils.js
1845
+ var require_utils2 = __commonJS({
1846
+ "node_modules/qrcode/lib/renderer/utils.js"(exports) {
1847
+ function hex2rgba(hex) {
1848
+ if (typeof hex === "number") {
1849
+ hex = hex.toString();
1850
+ }
1851
+ if (typeof hex !== "string") {
1852
+ throw new Error("Color should be defined as hex string");
1853
+ }
1854
+ let hexCode = hex.slice().replace("#", "").split("");
1855
+ if (hexCode.length < 3 || hexCode.length === 5 || hexCode.length > 8) {
1856
+ throw new Error("Invalid hex color: " + hex);
1857
+ }
1858
+ if (hexCode.length === 3 || hexCode.length === 4) {
1859
+ hexCode = Array.prototype.concat.apply([], hexCode.map(function(c) {
1860
+ return [c, c];
1861
+ }));
1862
+ }
1863
+ if (hexCode.length === 6) hexCode.push("F", "F");
1864
+ const hexValue = parseInt(hexCode.join(""), 16);
1865
+ return {
1866
+ r: hexValue >> 24 & 255,
1867
+ g: hexValue >> 16 & 255,
1868
+ b: hexValue >> 8 & 255,
1869
+ a: hexValue & 255,
1870
+ hex: "#" + hexCode.slice(0, 6).join("")
1871
+ };
1872
+ }
1873
+ exports.getOptions = function getOptions(options) {
1874
+ if (!options) options = {};
1875
+ if (!options.color) options.color = {};
1876
+ const margin = typeof options.margin === "undefined" || options.margin === null || options.margin < 0 ? 4 : options.margin;
1877
+ const width = options.width && options.width >= 21 ? options.width : void 0;
1878
+ const scale = options.scale || 4;
1879
+ return {
1880
+ width,
1881
+ scale: width ? 4 : scale,
1882
+ margin,
1883
+ color: {
1884
+ dark: hex2rgba(options.color.dark || "#000000ff"),
1885
+ light: hex2rgba(options.color.light || "#ffffffff")
1886
+ },
1887
+ type: options.type,
1888
+ rendererOpts: options.rendererOpts || {}
1889
+ };
1890
+ };
1891
+ exports.getScale = function getScale(qrSize, opts) {
1892
+ return opts.width && opts.width >= qrSize + opts.margin * 2 ? opts.width / (qrSize + opts.margin * 2) : opts.scale;
1893
+ };
1894
+ exports.getImageWidth = function getImageWidth(qrSize, opts) {
1895
+ const scale = exports.getScale(qrSize, opts);
1896
+ return Math.floor((qrSize + opts.margin * 2) * scale);
1897
+ };
1898
+ exports.qrToImageData = function qrToImageData(imgData, qr, opts) {
1899
+ const size = qr.modules.size;
1900
+ const data = qr.modules.data;
1901
+ const scale = exports.getScale(size, opts);
1902
+ const symbolSize = Math.floor((size + opts.margin * 2) * scale);
1903
+ const scaledMargin = opts.margin * scale;
1904
+ const palette = [opts.color.light, opts.color.dark];
1905
+ for (let i = 0; i < symbolSize; i++) {
1906
+ for (let j = 0; j < symbolSize; j++) {
1907
+ let posDst = (i * symbolSize + j) * 4;
1908
+ let pxColor = opts.color.light;
1909
+ if (i >= scaledMargin && j >= scaledMargin && i < symbolSize - scaledMargin && j < symbolSize - scaledMargin) {
1910
+ const iSrc = Math.floor((i - scaledMargin) / scale);
1911
+ const jSrc = Math.floor((j - scaledMargin) / scale);
1912
+ pxColor = palette[data[iSrc * size + jSrc] ? 1 : 0];
1913
+ }
1914
+ imgData[posDst++] = pxColor.r;
1915
+ imgData[posDst++] = pxColor.g;
1916
+ imgData[posDst++] = pxColor.b;
1917
+ imgData[posDst] = pxColor.a;
1918
+ }
1919
+ }
1920
+ };
1921
+ }
1922
+ });
1923
+
1924
+ // node_modules/qrcode/lib/renderer/canvas.js
1925
+ var require_canvas = __commonJS({
1926
+ "node_modules/qrcode/lib/renderer/canvas.js"(exports) {
1927
+ var Utils = require_utils2();
1928
+ function clearCanvas(ctx, canvas, size) {
1929
+ ctx.clearRect(0, 0, canvas.width, canvas.height);
1930
+ if (!canvas.style) canvas.style = {};
1931
+ canvas.height = size;
1932
+ canvas.width = size;
1933
+ canvas.style.height = size + "px";
1934
+ canvas.style.width = size + "px";
1935
+ }
1936
+ function getCanvasElement() {
1937
+ try {
1938
+ return document.createElement("canvas");
1939
+ } catch (e) {
1940
+ throw new Error("You need to specify a canvas element");
1941
+ }
1942
+ }
1943
+ exports.render = function render(qrData, canvas, options) {
1944
+ let opts = options;
1945
+ let canvasEl = canvas;
1946
+ if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
1947
+ opts = canvas;
1948
+ canvas = void 0;
1949
+ }
1950
+ if (!canvas) {
1951
+ canvasEl = getCanvasElement();
1952
+ }
1953
+ opts = Utils.getOptions(opts);
1954
+ const size = Utils.getImageWidth(qrData.modules.size, opts);
1955
+ const ctx = canvasEl.getContext("2d");
1956
+ const image = ctx.createImageData(size, size);
1957
+ Utils.qrToImageData(image.data, qrData, opts);
1958
+ clearCanvas(ctx, canvasEl, size);
1959
+ ctx.putImageData(image, 0, 0);
1960
+ return canvasEl;
1961
+ };
1962
+ exports.renderToDataURL = function renderToDataURL(qrData, canvas, options) {
1963
+ let opts = options;
1964
+ if (typeof opts === "undefined" && (!canvas || !canvas.getContext)) {
1965
+ opts = canvas;
1966
+ canvas = void 0;
1967
+ }
1968
+ if (!opts) opts = {};
1969
+ const canvasEl = exports.render(qrData, canvas, opts);
1970
+ const type = opts.type || "image/png";
1971
+ const rendererOpts = opts.rendererOpts || {};
1972
+ return canvasEl.toDataURL(type, rendererOpts.quality);
1973
+ };
1974
+ }
1975
+ });
1976
+
1977
+ // node_modules/qrcode/lib/renderer/svg-tag.js
1978
+ var require_svg_tag = __commonJS({
1979
+ "node_modules/qrcode/lib/renderer/svg-tag.js"(exports) {
1980
+ var Utils = require_utils2();
1981
+ function getColorAttrib(color, attrib) {
1982
+ const alpha = color.a / 255;
1983
+ const str = attrib + '="' + color.hex + '"';
1984
+ return alpha < 1 ? str + " " + attrib + '-opacity="' + alpha.toFixed(2).slice(1) + '"' : str;
1985
+ }
1986
+ function svgCmd(cmd, x, y) {
1987
+ let str = cmd + x;
1988
+ if (typeof y !== "undefined") str += " " + y;
1989
+ return str;
1990
+ }
1991
+ function qrToPath(data, size, margin) {
1992
+ let path = "";
1993
+ let moveBy = 0;
1994
+ let newRow = false;
1995
+ let lineLength = 0;
1996
+ for (let i = 0; i < data.length; i++) {
1997
+ const col = Math.floor(i % size);
1998
+ const row = Math.floor(i / size);
1999
+ if (!col && !newRow) newRow = true;
2000
+ if (data[i]) {
2001
+ lineLength++;
2002
+ if (!(i > 0 && col > 0 && data[i - 1])) {
2003
+ path += newRow ? svgCmd("M", col + margin, 0.5 + row + margin) : svgCmd("m", moveBy, 0);
2004
+ moveBy = 0;
2005
+ newRow = false;
2006
+ }
2007
+ if (!(col + 1 < size && data[i + 1])) {
2008
+ path += svgCmd("h", lineLength);
2009
+ lineLength = 0;
2010
+ }
2011
+ } else {
2012
+ moveBy++;
2013
+ }
2014
+ }
2015
+ return path;
2016
+ }
2017
+ exports.render = function render(qrData, options, cb) {
2018
+ const opts = Utils.getOptions(options);
2019
+ const size = qrData.modules.size;
2020
+ const data = qrData.modules.data;
2021
+ const qrcodesize = size + opts.margin * 2;
2022
+ const bg = !opts.color.light.a ? "" : "<path " + getColorAttrib(opts.color.light, "fill") + ' d="M0 0h' + qrcodesize + "v" + qrcodesize + 'H0z"/>';
2023
+ const path = "<path " + getColorAttrib(opts.color.dark, "stroke") + ' d="' + qrToPath(data, size, opts.margin) + '"/>';
2024
+ const viewBox = 'viewBox="0 0 ' + qrcodesize + " " + qrcodesize + '"';
2025
+ const width = !opts.width ? "" : 'width="' + opts.width + '" height="' + opts.width + '" ';
2026
+ const svgTag = '<svg xmlns="http://www.w3.org/2000/svg" ' + width + viewBox + ' shape-rendering="crispEdges">' + bg + path + "</svg>\n";
2027
+ if (typeof cb === "function") {
2028
+ cb(null, svgTag);
2029
+ }
2030
+ return svgTag;
2031
+ };
2032
+ }
2033
+ });
2034
+
2035
+ // node_modules/qrcode/lib/browser.js
2036
+ var require_browser = __commonJS({
2037
+ "node_modules/qrcode/lib/browser.js"(exports) {
2038
+ var canPromise = require_can_promise();
2039
+ var QRCode2 = require_qrcode();
2040
+ var CanvasRenderer = require_canvas();
2041
+ var SvgRenderer = require_svg_tag();
2042
+ function renderCanvas(renderFunc, canvas, text, opts, cb) {
2043
+ const args = [].slice.call(arguments, 1);
2044
+ const argsNum = args.length;
2045
+ const isLastArgCb = typeof args[argsNum - 1] === "function";
2046
+ if (!isLastArgCb && !canPromise()) {
2047
+ throw new Error("Callback required as last argument");
2048
+ }
2049
+ if (isLastArgCb) {
2050
+ if (argsNum < 2) {
2051
+ throw new Error("Too few arguments provided");
2052
+ }
2053
+ if (argsNum === 2) {
2054
+ cb = text;
2055
+ text = canvas;
2056
+ canvas = opts = void 0;
2057
+ } else if (argsNum === 3) {
2058
+ if (canvas.getContext && typeof cb === "undefined") {
2059
+ cb = opts;
2060
+ opts = void 0;
2061
+ } else {
2062
+ cb = opts;
2063
+ opts = text;
2064
+ text = canvas;
2065
+ canvas = void 0;
2066
+ }
2067
+ }
2068
+ } else {
2069
+ if (argsNum < 1) {
2070
+ throw new Error("Too few arguments provided");
2071
+ }
2072
+ if (argsNum === 1) {
2073
+ text = canvas;
2074
+ canvas = opts = void 0;
2075
+ } else if (argsNum === 2 && !canvas.getContext) {
2076
+ opts = text;
2077
+ text = canvas;
2078
+ canvas = void 0;
2079
+ }
2080
+ return new Promise(function(resolve, reject) {
2081
+ try {
2082
+ const data = QRCode2.create(text, opts);
2083
+ resolve(renderFunc(data, canvas, opts));
2084
+ } catch (e) {
2085
+ reject(e);
2086
+ }
2087
+ });
2088
+ }
2089
+ try {
2090
+ const data = QRCode2.create(text, opts);
2091
+ cb(null, renderFunc(data, canvas, opts));
2092
+ } catch (e) {
2093
+ cb(e);
2094
+ }
2095
+ }
2096
+ exports.create = QRCode2.create;
2097
+ exports.toCanvas = renderCanvas.bind(null, CanvasRenderer.render);
2098
+ exports.toDataURL = renderCanvas.bind(null, CanvasRenderer.renderToDataURL);
2099
+ exports.toString = renderCanvas.bind(null, function(data, _, opts) {
2100
+ return SvgRenderer.render(data, opts);
2101
+ });
2102
+ }
2103
+ });
2104
+
2105
+ // src/qr-renderer.ts
2106
+ var import_qrcode = __toESM(require_browser(), 1);
2107
+
2108
+ // src/button.ts
2109
+ var P_STEM = "M46.2623 100.265C43.9277 100.265 41.9617 99.5892 40.3643 98.2375C38.8898 96.8859 38.1526 95.1657 38.1526 93.0768V70.5907C38.1526 66.0444 37.1082 62.7882 35.0193 60.8222C33.0533 58.8562 30.5958 57.8732 27.6468 57.8732C24.5749 57.8732 21.9946 58.8562 19.9057 60.8222C17.9397 62.7882 16.711 65.0614 16.2195 67.6417V92.3396C16.2195 94.4284 15.4208 96.2101 13.8234 97.6846C12.3489 99.0362 10.5058 99.712 8.29404 99.712C5.95942 99.712 3.99343 99.0362 2.39606 97.6846C0.798686 96.333 0 94.6127 0 92.5239V51.238C0 49.272 0.737248 47.6132 2.21174 46.2615C3.80912 44.787 5.83655 44.0498 8.29404 44.0498C10.26 44.0498 11.9188 44.6027 13.2705 45.7086C14.6221 46.6916 15.5437 47.9818 16.0352 49.5792C19.3528 45.2785 24.3906 43.1282 31.1487 43.1282C38.0297 43.1282 43.6205 45.1557 47.9211 49.2105C52.2218 53.2654 54.3721 59.7163 54.3721 68.5633V93.4454C54.3721 95.4114 53.5734 97.0702 51.976 98.4219C50.5015 99.6506 48.597 100.265 46.2623 100.265Z";
2110
+ var P_DOT = "M26.7637 0.900391C29.8673 0.900391 32.6569 1.60533 35.1299 3.01758C37.6743 4.35994 39.6881 6.26878 41.1719 8.74121C42.6585 11.1465 43.3994 13.9742 43.3994 17.2197C43.3994 20.3955 42.6579 23.2567 41.1738 25.8008C39.6892 28.2744 37.6757 30.2181 35.1328 31.6309C32.6582 33.043 29.8683 33.75 26.7637 33.75C23.9181 33.75 21.2882 33.1284 18.875 31.8867L18.3945 31.6309C15.8521 30.2184 13.8036 28.2754 12.25 25.8037C10.764 23.2567 10.0235 20.3954 10.0234 17.2197C10.0234 13.9742 10.7643 11.1466 12.25 8.74121L12.5469 8.2832C14.0617 6.03176 16.012 4.27606 18.3965 3.01758C20.9392 1.60538 23.729 0.900409 26.7637 0.900391ZM26.7637 9.63086C24.682 9.63089 22.9161 10.3241 21.4609 11.71C20.0799 13.0921 19.3857 14.9255 19.3857 17.2197C19.3858 19.4431 20.0804 21.3133 21.4658 22.8379C22.9209 24.2919 24.6846 25.0185 26.7637 25.0186C28.915 25.0186 30.6429 24.2913 31.9561 22.8398L32.208 22.5498C33.4264 21.0797 34.0361 19.3046 34.0361 17.2197C34.0361 14.9244 33.3414 13.0904 31.959 11.708L31.7061 11.4551C30.4267 10.2404 28.7819 9.63086 26.7637 9.63086Z";
2111
+ function prsonMarkSvg(opts = {}) {
2112
+ const size = opts.size ?? 24;
2113
+ const square = opts.square ?? "#FBBF24";
2114
+ const glyph = opts.glyph ?? "#0A0A0A";
2115
+ return `<svg class="prson-mark" width="${size}" height="${size}" viewBox="0 0 24 24" aria-hidden="true" focusable="false" xmlns="http://www.w3.org/2000/svg"><rect width="24" height="24" rx="6" fill="${square}"/><g transform="translate(7.2 3.15) scale(0.175)" fill="${glyph}"><path d="${P_STEM}"/><path d="${P_DOT}"/></g></svg>`;
2116
+ }
2117
+ var MARK_COLOURS = {
2118
+ amber: { square: "#0A0A0A", glyph: "#FBBF24" },
2119
+ dark: { square: "#FBBF24", glyph: "#0A0A0A" },
2120
+ light: { square: "#FBBF24", glyph: "#0A0A0A" },
2121
+ outline: { square: "#FBBF24", glyph: "#0A0A0A" }
2122
+ };
2123
+ var VARIANTS = ["amber", "dark", "light", "outline"];
2124
+ function variantOf(v) {
2125
+ return VARIANTS.includes(v) ? v : "amber";
2126
+ }
2127
+ function decorate(btn, o) {
2128
+ const variant = variantOf(o.variant);
2129
+ btn.className = [
2130
+ "prson-signin-btn",
2131
+ `prson-signin-btn--${variant}`,
2132
+ o.size === "lg" ? "prson-signin-btn--lg" : "",
2133
+ o.fullWidth ? "prson-signin-btn--block" : ""
2134
+ ].filter(Boolean).join(" ");
2135
+ btn.innerHTML = prsonMarkSvg({ size: o.size === "lg" ? 26 : 22, ...MARK_COLOURS[variant] });
2136
+ const label = document.createElement("span");
2137
+ label.className = "prson-signin-btn__label";
2138
+ label.textContent = o.label ?? "Sign in with Prson";
2139
+ btn.append(label);
2140
+ }
2141
+ function createSignInButton(opts = {}) {
2142
+ const btn = document.createElement("button");
2143
+ btn.type = "button";
2144
+ decorate(btn, opts);
2145
+ if (opts.onClick) btn.addEventListener("click", opts.onClick);
2146
+ return btn;
2147
+ }
2148
+ function defineSignInButtonElement(tag = "prson-signin-button") {
2149
+ if (typeof window === "undefined" || !("customElements" in window) || customElements.get(tag)) return;
2150
+ class PrsonSignInButtonElement extends HTMLElement {
2151
+ constructor() {
2152
+ super(...arguments);
2153
+ this.btn = null;
2154
+ }
2155
+ static get observedAttributes() {
2156
+ return ["variant", "size", "label", "full-width", "disabled", "busy"];
2157
+ }
2158
+ connectedCallback() {
2159
+ if (!this.btn) {
2160
+ this.btn = document.createElement("button");
2161
+ this.btn.type = "button";
2162
+ this.append(this.btn);
2163
+ }
2164
+ this.render();
2165
+ }
2166
+ attributeChangedCallback() {
2167
+ if (this.btn) this.render();
2168
+ }
2169
+ render() {
2170
+ const btn = this.btn;
2171
+ decorate(btn, {
2172
+ variant: variantOf(this.getAttribute("variant")),
2173
+ size: this.getAttribute("size") === "lg" ? "lg" : "md",
2174
+ label: this.getAttribute("label") ?? void 0,
2175
+ fullWidth: this.hasAttribute("full-width")
2176
+ });
2177
+ if (this.hasAttribute("full-width")) this.style.display = "block";
2178
+ btn.disabled = this.hasAttribute("disabled");
2179
+ const busy = this.hasAttribute("busy");
2180
+ if (busy) btn.setAttribute("aria-busy", "true");
2181
+ else btn.removeAttribute("aria-busy");
2182
+ btn.classList.toggle("prson-signin-btn--busy", busy);
2183
+ }
2184
+ }
2185
+ customElements.define(tag, PrsonSignInButtonElement);
2186
+ }
2187
+
2188
+ // src/describe.ts
2189
+ function b64uDecode(s) {
2190
+ const pad = s.length % 4 === 0 ? "" : "=".repeat(4 - s.length % 4);
2191
+ const bin = atob(s.replace(/-/g, "+").replace(/_/g, "/") + pad);
2192
+ const bytes = new Uint8Array(bin.length);
2193
+ for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i);
2194
+ return new TextDecoder().decode(bytes);
2195
+ }
2196
+ function param(url, name) {
2197
+ try {
2198
+ return new URL(url).searchParams.get(name);
2199
+ } catch {
2200
+ const m = url.match(new RegExp(`[?&]${name}=([^&#]*)`));
2201
+ const cap = m?.[1];
2202
+ return cap ? decodeURIComponent(cap) : null;
2203
+ }
2204
+ }
2205
+ var CLAIMS = {
2206
+ given_name: { icon: "user", label: "Your name" },
2207
+ family_name: { icon: "user", label: "Your name" },
2208
+ name: { icon: "user", label: "Your name" },
2209
+ full_name: { icon: "user", label: "Your name" },
2210
+ birthdate: { icon: "calendar", label: "Date of birth" },
2211
+ birth_date: { icon: "calendar", label: "Date of birth" },
2212
+ age: { icon: "calendar", label: "Your age" },
2213
+ email: { icon: "mail", label: "Email address" },
2214
+ phone: { icon: "phone", label: "Phone number" },
2215
+ phone_number: { icon: "phone", label: "Phone number" },
2216
+ address: { icon: "home", label: "Address" },
2217
+ nationality: { icon: "flag", label: "Nationality" },
2218
+ nationalities: { icon: "flag", label: "Nationality" },
2219
+ document_number: { icon: "id", label: "Document number" },
2220
+ document_type: { icon: "id", label: "Document type" },
2221
+ picture: { icon: "user", label: "Photo" }
2222
+ };
2223
+ var PREDICATES = {
2224
+ phone_verified: { icon: "phone", label: "A verified phone number", detail: "Not the number itself" },
2225
+ email_verified: { icon: "mail", label: "A verified email", detail: "Not the address itself" },
2226
+ address_verified: { icon: "home", label: "A verified address", detail: "Not the address itself" },
2227
+ bank_verified: { icon: "check", label: "A verified bank account", detail: "Not the account itself" }
2228
+ };
2229
+ function humanize(s) {
2230
+ const t = s.replace(/[_-]+/g, " ").trim();
2231
+ return t ? t.charAt(0).toUpperCase() + t.slice(1) : s;
2232
+ }
2233
+ function predicateItem(p) {
2234
+ const known = PREDICATES[p];
2235
+ if (known) return known;
2236
+ const age = p.match(/^age_(gte|gt|over|lt|under)_(\d{1,3})$/);
2237
+ if (age) {
2238
+ const n = Number(age[2]);
2239
+ const label = age[1] === "gte" || age[1] === "over" ? `${n} or older` : age[1] === "gt" ? `Older than ${n}` : `Under ${n}`;
2240
+ return { icon: "calendar", label, detail: "Not your date of birth" };
2241
+ }
2242
+ return { icon: "check", label: humanize(p), detail: "Yes or no only" };
2243
+ }
2244
+ function describeShares(req) {
2245
+ const r = req.required ?? {};
2246
+ const out = [];
2247
+ const seen = /* @__PURE__ */ new Set();
2248
+ const add = (i) => {
2249
+ if (seen.has(i.label)) return;
2250
+ seen.add(i.label);
2251
+ out.push(i);
2252
+ };
2253
+ if (r.identityType === "organization") add({ icon: "building", label: "An organisation identity" });
2254
+ const level = r.minVerificationLevel ?? 1;
2255
+ if (r.uniqueHumanId) {
2256
+ add({ icon: "shield", label: "Verified unique person", detail: "Passport or ID checked \xB7 not trackable across sites" });
2257
+ } else if (level >= 4) {
2258
+ add({ icon: "shield", label: "Verified human", detail: "Passport or ID checked" });
2259
+ } else if (level >= 1) {
2260
+ add({ icon: "shield", label: "Verified human" });
2261
+ } else {
2262
+ add({ icon: "shield", label: "Your Prson identity", detail: "Verified or not" });
2263
+ }
2264
+ for (const p of r.predicates ?? []) add(predicateItem(p));
2265
+ for (const c of r.requiredClaims ?? []) add(CLAIMS[c] ?? { icon: "check", label: humanize(c) });
2266
+ add(
2267
+ req.ephemeralIdentity ? { icon: "key", label: "A one-time key", detail: "Nothing links your visits" } : { icon: "key", label: "A sign-in key just for this site" }
2268
+ );
2269
+ return out;
2270
+ }
2271
+ function describeCode(url) {
2272
+ let req = {};
2273
+ const raw = param(url, "req");
2274
+ if (raw) {
2275
+ try {
2276
+ req = JSON.parse(b64uDecode(raw));
2277
+ } catch {
2278
+ req = {};
2279
+ }
2280
+ }
2281
+ const t = param(url, "t");
2282
+ const serverTs = t && /^\d+$/.test(t) ? parseInt(t, 10) : null;
2283
+ return {
2284
+ domain: param(url, "d") ?? req.domain ?? "",
2285
+ serverTs,
2286
+ shares: describeShares(req),
2287
+ anonymousAllowed: req.allowAnonymous === true
2288
+ };
2289
+ }
2290
+ function monogram(domain) {
2291
+ const host = domain.replace(/:\d+$/, "").toLowerCase();
2292
+ const parts = host.split(".").filter(Boolean);
2293
+ const name = parts.length >= 3 ? parts[parts.length - 2] : parts[0];
2294
+ const ch = (name ?? host).match(/[a-z0-9]/i)?.[0] ?? "?";
2295
+ return ch.toUpperCase();
2296
+ }
2297
+
2298
+ // src/qr-renderer.ts
2299
+ var DRAFT_TTL_SECONDS = 180;
2300
+ var COUNTDOWN_WARN_SECONDS = 30;
2301
+ var svg = (body, cls = "") => `<svg${cls ? ` class="${cls}"` : ""} viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false">${body}</svg>`;
2302
+ var ICONS = {
2303
+ shield: svg('<path d="M12 3l8 4v5c0 5-3.5 8.5-8 9-4.5-.5-8-4-8-9V7l8-4z"/><path d="M9 12l2 2 4-4"/>'),
2304
+ user: svg('<circle cx="12" cy="8" r="4"/><path d="M6 21v-1a6 6 0 0 1 12 0v1"/>'),
2305
+ calendar: svg('<rect x="4" y="5" width="16" height="16" rx="2"/><path d="M16 3v4M8 3v4M4 11h16"/>'),
2306
+ id: svg('<rect x="3" y="5" width="18" height="14" rx="2"/><circle cx="9" cy="11" r="2"/><path d="M15 9h2M15 13h2M7 16h4"/>'),
2307
+ mail: svg('<rect x="3" y="5" width="18" height="14" rx="2"/><path d="M3 7l9 6 9-6"/>'),
2308
+ phone: svg('<rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/>'),
2309
+ device: svg('<rect x="7" y="3" width="10" height="18" rx="2"/><path d="M11 18h2"/>'),
2310
+ home: svg('<path d="M5 12H3l9-9 9 9h-2"/><path d="M5 12v7a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-7"/>'),
2311
+ building: svg('<path d="M3 21h18M5 21V7l8-4v18M19 21V11l-6-4M9 9v.01M9 12v.01M9 15v.01"/>'),
2312
+ key: svg('<circle cx="8" cy="15" r="4"/><path d="M10.85 12.15L19 4M18 5l2 2M15 8l2 2"/>'),
2313
+ flag: svg('<path d="M5 5a5 5 0 0 1 7 0 5 5 0 0 0 7 0v9a5 5 0 0 1-7 0 5 5 0 0 0-7 0V5z"/><path d="M5 21v-7"/>'),
2314
+ check: svg('<path d="M5 12l5 5L20 7"/>'),
2315
+ close: svg('<path d="M18 6L6 18M6 6l12 12"/>'),
2316
+ lock: svg('<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V7a4 4 0 0 1 8 0v4"/>'),
2317
+ clock: svg('<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 3"/>'),
2318
+ alert: svg('<circle cx="12" cy="12" r="9"/><path d="M12 8v4M12 16h.01"/>'),
2319
+ refresh: svg('<path d="M20 11A8.1 8.1 0 0 0 4.5 9M4 5v4h4"/><path d="M4 13a8.1 8.1 0 0 0 15.5 2M20 19v-4h-4"/>')
2320
+ };
2321
+ var SPINNER = svg('<path d="M12 3a9 9 0 1 0 9 9" />', "prson-spinner");
2322
+ var CHECK = `<svg class="prson-check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M5 12.5l4.5 4.5L19 7.5"/></svg>`;
2323
+ var MONO_TINTS = ["#FEF3C7", "#E0F2FE", "#DCFCE7", "#EDE9FE", "#FCE7F3", "#E2E8F0", "#FFEDD5"];
2324
+ function tintFor(domain) {
2325
+ let h = 0;
2326
+ for (let i = 0; i < domain.length; i++) h = h * 31 + domain.charCodeAt(i) >>> 0;
2327
+ return MONO_TINTS[h % MONO_TINTS.length];
2328
+ }
2329
+ function fmtSeconds(seconds) {
2330
+ const s = Math.max(0, seconds);
2331
+ return Math.floor(s / 60) + ":" + String(s % 60).padStart(2, "0");
2332
+ }
2333
+ function prefersReducedMotion() {
2334
+ return typeof window.matchMedia === "function" && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
2335
+ }
2336
+ function isPhone() {
2337
+ const ua = navigator.userAgent || "";
2338
+ if (/iPhone|iPod|Android.+Mobile|Windows Phone|Mobile Safari/i.test(ua)) return true;
2339
+ return typeof window.matchMedia === "function" && window.matchMedia("(pointer: coarse)").matches && window.matchMedia("(max-width: 820px)").matches;
2340
+ }
2341
+ function el(tag, cls, html) {
2342
+ const e = document.createElement(tag);
2343
+ if (cls) e.className = cls;
2344
+ if (html !== void 0) e.innerHTML = html;
2345
+ return e;
2346
+ }
2347
+ function renderQrCard(url, mount, theme, context) {
2348
+ Array.from(mount.querySelectorAll(".prson-card, .prson-qr-card")).forEach((orphan) => orphan.remove());
2349
+ const info = describeCode(url);
2350
+ const domain = context?.domain || info.domain || window.location.host;
2351
+ const mode = context?.mode ?? "inline";
2352
+ const titleId = context?.titleId ?? `prson-login-title-${Math.random().toString(36).slice(2, 10)}`;
2353
+ const getAppUrl = context?.getAppUrl ?? "https://app.prson.net/";
2354
+ const phone = isPhone();
2355
+ const sheet = mode === "modal" && typeof window.matchMedia === "function" && window.matchMedia("(max-width: 480px)").matches;
2356
+ const card = el("section", "prson-card");
2357
+ card.setAttribute("data-prson-login-ui", "1");
2358
+ card.dataset.theme = theme === "light" || theme === "dark" ? theme : "auto";
2359
+ card.dataset.mode = mode;
2360
+ card.dataset.device = phone ? "phone" : "desktop";
2361
+ card.dataset.state = "waiting";
2362
+ if (sheet) card.dataset.sheet = "1";
2363
+ card.setAttribute("aria-labelledby", titleId);
2364
+ card.classList.add("prson-qr-card");
2365
+ const head = el("div", "prson-head");
2366
+ const brand = el("span", "prson-brand", prsonMarkSvg({ size: 22 }));
2367
+ brand.append(document.createTextNode("Sign in with Prson"));
2368
+ head.append(brand);
2369
+ if (mode === "modal" && context?.cancel) {
2370
+ const close = el("button", "prson-close", ICONS.close);
2371
+ close.type = "button";
2372
+ close.setAttribute("aria-label", "Close");
2373
+ close.addEventListener("click", () => context.cancel?.());
2374
+ head.append(close);
2375
+ }
2376
+ const site = el("div", "prson-site");
2377
+ const mono = el("div", "prson-monogram");
2378
+ mono.textContent = monogram(domain);
2379
+ mono.style.setProperty("--prson-mono-bg", tintFor(domain));
2380
+ mono.setAttribute("aria-hidden", "true");
2381
+ const siteText = el("div", "prson-site-text");
2382
+ const eyebrow = el("p", "prson-eyebrow");
2383
+ eyebrow.textContent = "Sign in to";
2384
+ const title = el("h2", "prson-domain");
2385
+ title.id = titleId;
2386
+ title.textContent = domain;
2387
+ title.setAttribute("aria-label", `Sign in to ${domain}`);
2388
+ siteText.append(eyebrow, title);
2389
+ site.append(mono, siteText);
2390
+ const stage = el("div", "prson-stage");
2391
+ const frame = el("div", "prson-frame");
2392
+ const ring = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2393
+ ring.setAttribute("class", "prson-ring");
2394
+ ring.setAttribute("viewBox", "0 0 272 272");
2395
+ ring.setAttribute("aria-hidden", "true");
2396
+ ring.innerHTML = '<rect class="prson-ring-track" x="2" y="2" width="268" height="268" rx="24" pathLength="100"/><rect class="prson-ring-fill" x="2" y="2" width="268" height="268" rx="24" pathLength="100"/>';
2397
+ const ringFill = ring.querySelector(".prson-ring-fill");
2398
+ const code = el("div", "prson-code");
2399
+ code.setAttribute("role", "img");
2400
+ code.setAttribute("aria-label", `Sign-in code for ${domain}. Scan it with the Prson app.`);
2401
+ import_qrcode.default.toString(
2402
+ url,
2403
+ { type: "svg", errorCorrectionLevel: "H", margin: 0, color: { dark: "#0A0A0A", light: "#FFFFFF" } },
2404
+ (err, svgString) => {
2405
+ if (err) {
2406
+ code.textContent = "The code couldn't be drawn. Use Get a new code.";
2407
+ return;
2408
+ }
2409
+ code.innerHTML = svgString.replace("<svg ", '<svg class="prson-qr" aria-hidden="true" focusable="false" ');
2410
+ const logo = el("span", "prson-code-logo", prsonMarkSvg({ size: 36 }));
2411
+ code.append(logo);
2412
+ }
2413
+ );
2414
+ frame.append(ring, code);
2415
+ const open = el("div", "prson-open");
2416
+ const openBtn = el("a", "prson-btn prson-btn--big", prsonMarkSvg({ size: 26, square: "#0A0A0A", glyph: "#FBBF24" }));
2417
+ openBtn.href = url;
2418
+ openBtn.append(document.createTextNode("Open Prson"));
2419
+ const showCode = el("button", "prson-linkish");
2420
+ showCode.type = "button";
2421
+ showCode.textContent = "Scan with another phone instead";
2422
+ showCode.setAttribute("aria-expanded", "false");
2423
+ showCode.addEventListener("click", () => {
2424
+ const on = card.dataset.showCode !== "1";
2425
+ card.dataset.showCode = on ? "1" : "";
2426
+ showCode.setAttribute("aria-expanded", String(on));
2427
+ showCode.textContent = on ? "Hide the code" : "Scan with another phone instead";
2428
+ });
2429
+ open.append(openBtn, showCode);
2430
+ const overlay = el("div", "prson-overlay");
2431
+ const overlayIcon = el("div", "prson-overlay-icon");
2432
+ const overlayTitle = el("p", "prson-overlay-title");
2433
+ const overlayText = el("p", "prson-overlay-text");
2434
+ overlay.append(overlayIcon, overlayTitle, overlayText);
2435
+ (phone ? open : frame).append(overlay);
2436
+ const timer = el("p", "prson-timer");
2437
+ stage.append(frame, open);
2438
+ if (!phone) stage.append(el("p", "prson-hint", "Open <b>Prson</b> on your phone and scan this code."));
2439
+ stage.append(timer);
2440
+ const share = el("div", "prson-share");
2441
+ const shareTitle = el("p", "prson-share-title");
2442
+ shareTitle.textContent = `${domain} will get`;
2443
+ const list = el("ul");
2444
+ list.setAttribute("aria-label", `What ${domain} will get`);
2445
+ for (const item of info.shares) {
2446
+ const li = el("li", "", ICONS[item.icon]);
2447
+ const text = el("span");
2448
+ text.textContent = item.label;
2449
+ if (item.detail) {
2450
+ const small = el("small");
2451
+ small.textContent = item.detail;
2452
+ text.append(small);
2453
+ }
2454
+ li.append(text);
2455
+ list.append(li);
2456
+ }
2457
+ share.append(shareTitle, list);
2458
+ if (info.anonymousAllowed) {
2459
+ const note = el("p", "prson-share-note");
2460
+ note.textContent = "You can also choose to sign in anonymously in the app.";
2461
+ share.append(note);
2462
+ }
2463
+ const guard = el("p", "prson-guard", ICONS.lock);
2464
+ const guardText = el("span");
2465
+ guardText.append(document.createTextNode("Only scan codes shown on "));
2466
+ const guardDomain = el("b");
2467
+ guardDomain.textContent = domain;
2468
+ guardText.append(guardDomain, document.createTextNode(". Never scan one someone sent you."));
2469
+ guard.append(guardText);
2470
+ const foot = el("p", "prson-foot");
2471
+ foot.append(document.createTextNode("Don't have Prson? "));
2472
+ const get = el("a");
2473
+ get.href = getAppUrl;
2474
+ get.target = "_blank";
2475
+ get.rel = "noopener";
2476
+ get.textContent = "Get the app";
2477
+ foot.append(get);
2478
+ const live = el("div", "prson-sr");
2479
+ live.setAttribute("aria-live", "polite");
2480
+ live.setAttribute("role", "status");
2481
+ card.append(head, site, stage, share, guard, foot, live);
2482
+ mount.append(card);
2483
+ const announce = (text) => {
2484
+ live.textContent = "";
2485
+ setTimeout(() => live.textContent = text, 50);
2486
+ };
2487
+ announce(phone ? `Sign in to ${domain}. Open Prson to continue.` : `Sign in to ${domain}. Scan the code with the Prson app.`);
2488
+ const nowS = Date.now() / 1e3;
2489
+ const startS = info.serverTs && Math.abs(nowS - info.serverTs) < 60 ? info.serverTs : nowS;
2490
+ const deadlineMs = (startS + DRAFT_TTL_SECONDS) * 1e3;
2491
+ let tickHandle = null;
2492
+ let expired = false;
2493
+ let warned = false;
2494
+ let settled = false;
2495
+ const timers = [];
2496
+ function action(label, icon, onClick) {
2497
+ const b = el("button", "prson-btn", icon);
2498
+ b.type = "button";
2499
+ b.append(document.createTextNode(label));
2500
+ b.addEventListener("click", onClick);
2501
+ return b;
2502
+ }
2503
+ function requestRefresh() {
2504
+ card.dispatchEvent(new CustomEvent("prson-login-refresh-requested", { bubbles: true }));
2505
+ context?.refresh?.();
2506
+ }
2507
+ function setOverlay(icon, titleText, text, button, pulse = false) {
2508
+ overlayIcon.innerHTML = icon;
2509
+ overlayIcon.classList.toggle("prson-pulse", pulse);
2510
+ overlayTitle.textContent = titleText;
2511
+ overlayText.textContent = text;
2512
+ overlay.querySelector(".prson-btn")?.remove();
2513
+ if (button) {
2514
+ overlay.append(button);
2515
+ if (mount.contains(document.activeElement) || mode === "modal") setTimeout(() => button.focus(), 30);
2516
+ }
2517
+ }
2518
+ function tick() {
2519
+ if (settled) return;
2520
+ const remainingMs = deadlineMs - Date.now();
2521
+ const remaining = Math.max(0, Math.ceil(remainingMs / 1e3));
2522
+ const ratio = Math.max(0, Math.min(1, remainingMs / (DRAFT_TTL_SECONDS * 1e3)));
2523
+ ringFill.style.strokeDashoffset = String(100 - ratio * 100);
2524
+ if (remaining > 0) {
2525
+ timer.innerHTML = `Code expires in <b>${fmtSeconds(remaining)}</b>`;
2526
+ card.dataset.urgency = remaining <= COUNTDOWN_WARN_SECONDS ? "warn" : "";
2527
+ if (remaining <= COUNTDOWN_WARN_SECONDS && !warned) {
2528
+ warned = true;
2529
+ announce("30 seconds left on this code.");
2530
+ }
2531
+ } else if (!expired && card.dataset.state === "waiting") {
2532
+ expired = true;
2533
+ card.dataset.state = "expired";
2534
+ timer.textContent = "";
2535
+ setOverlay(ICONS.clock, "This code expired", "Codes last 3 minutes, so a copied one is useless.", action("Get a new code", ICONS.refresh, requestRefresh));
2536
+ announce("The code expired. Get a new code to continue.");
2537
+ }
2538
+ }
2539
+ tick();
2540
+ tickHandle = window.setInterval(tick, 1e3);
2541
+ return {
2542
+ dispose() {
2543
+ if (tickHandle != null) window.clearInterval(tickHandle);
2544
+ tickHandle = null;
2545
+ timers.forEach((t) => window.clearTimeout(t));
2546
+ card.remove();
2547
+ },
2548
+ update(s) {
2549
+ if (!card.isConnected) return;
2550
+ card.dataset.state = s.state;
2551
+ switch (s.state) {
2552
+ case "waiting":
2553
+ return;
2554
+ case "scanned":
2555
+ setOverlay(ICONS.device, "Phone connected", "Finishing on your phone\u2026", void 0, true);
2556
+ announce("Phone connected. Finishing on your phone.");
2557
+ return;
2558
+ case "approving":
2559
+ setOverlay(SPINNER, "Receiving your proof", "Your phone is sending a signed, encrypted proof.");
2560
+ return;
2561
+ case "verifying":
2562
+ setOverlay(SPINNER, "Checking the proof", "Almost there.");
2563
+ announce("Checking the proof.");
2564
+ return;
2565
+ case "success": {
2566
+ settled = true;
2567
+ setOverlay(CHECK, "Signed in", `You're signed in to ${s.domain || domain}.`);
2568
+ announce(`You're signed in to ${s.domain || domain}.`);
2569
+ const hold = prefersReducedMotion() ? 450 : 1e3;
2570
+ return new Promise((resolve) => timers.push(window.setTimeout(resolve, hold)));
2571
+ }
2572
+ case "error":
2573
+ settled = true;
2574
+ timer.textContent = "";
2575
+ setOverlay(ICONS.alert, "Sign-in didn't finish", s.message, action("Try again", ICONS.refresh, requestRefresh));
2576
+ announce(`Sign-in didn't finish. ${s.message}`);
2577
+ return;
2578
+ }
2579
+ }
2580
+ };
2581
+ }
2582
+
2583
+ // src/styles.ts
2584
+ var DARK_VARS = `
2585
+ --prson-bg: #18181B;
2586
+ --prson-fg: #FAFAFA;
2587
+ --prson-muted: #A1A1AA;
2588
+ --prson-soft: #232327;
2589
+ --prson-line: rgba(255, 255, 255, 0.10);
2590
+ --prson-line-strong: rgba(255, 255, 255, 0.20);
2591
+ --prson-accent-text: #FBBF24;
2592
+ --prson-focus: #FBBF24;
2593
+ --prson-danger: #FCA5A5;
2594
+ --prson-danger-soft: rgba(248, 113, 113, 0.14);
2595
+ --prson-ring-track: rgba(255, 255, 255, 0.12);
2596
+ --prson-shadow: 0 24px 64px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.4);`;
2597
+ var PRSON_LOGIN_UI_CSS = `
2598
+ [data-prson-login-ui] {
2599
+ --prson-bg: #FFFFFF;
2600
+ --prson-fg: #0A0A0A;
2601
+ --prson-muted: #52525B;
2602
+ --prson-soft: #FAFAF9;
2603
+ --prson-line: rgba(10, 10, 10, 0.08);
2604
+ --prson-line-strong: rgba(10, 10, 10, 0.16);
2605
+ --prson-amber: #FBBF24;
2606
+ --prson-amber-hover: #F59E0B;
2607
+ --prson-accent-text: #B45309;
2608
+ --prson-focus: #0A0A0A;
2609
+ --prson-danger: #B91C1C;
2610
+ --prson-danger-soft: #FEF2F2;
2611
+ --prson-ring-track: rgba(10, 10, 10, 0.08);
2612
+ --prson-shadow: 0 24px 64px rgba(10, 10, 10, 0.18), 0 2px 6px rgba(10, 10, 10, 0.06);
2613
+ --prson-radius: 24px;
2614
+ --prson-font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
2615
+ --prson-spring: cubic-bezier(0.16, 1, 0.3, 1);
2616
+ }
2617
+ [data-prson-login-ui][data-theme="dark"] {${DARK_VARS}
2618
+ }
2619
+ @media (prefers-color-scheme: dark) {
2620
+ [data-prson-login-ui][data-theme="auto"] {${DARK_VARS}
2621
+ }
2622
+ }
2623
+
2624
+ /* \u2500\u2500 The card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2625
+ .prson-card {
2626
+ box-sizing: border-box;
2627
+ position: relative;
2628
+ width: 400px;
2629
+ max-width: 100%;
2630
+ padding: 20px 24px 20px;
2631
+ background: var(--prson-bg);
2632
+ color: var(--prson-fg);
2633
+ border: 1px solid var(--prson-line);
2634
+ border-radius: var(--prson-radius);
2635
+ box-shadow: var(--prson-shadow);
2636
+ font-family: var(--prson-font);
2637
+ font-size: 14px;
2638
+ line-height: 1.45;
2639
+ text-align: left;
2640
+ -webkit-font-smoothing: antialiased;
2641
+ animation: prson-enter 320ms var(--prson-spring);
2642
+ }
2643
+ .prson-card *, .prson-card *::before, .prson-card *::after { box-sizing: border-box; }
2644
+ .prson-card[data-mode="inline"] { margin-top: 24px; box-shadow: 0 8px 24px rgba(10, 10, 10, 0.06), 0 1px 3px rgba(10, 10, 10, 0.05); }
2645
+ .prson-card[data-sheet="1"] {
2646
+ width: 100%;
2647
+ border-radius: var(--prson-radius) var(--prson-radius) 0 0;
2648
+ border-bottom: 0;
2649
+ padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
2650
+ animation-name: prson-sheet;
2651
+ }
2652
+ @keyframes prson-enter { from { opacity: 0; transform: translateY(8px) scale(0.98); } to { opacity: 1; transform: none; } }
2653
+ @keyframes prson-sheet { from { transform: translateY(100%); } to { transform: none; } }
2654
+
2655
+ .prson-card button, .prson-card a { font-family: inherit; }
2656
+ .prson-card :focus-visible { outline: 3px solid var(--prson-focus); outline-offset: 2px; border-radius: 10px; }
2657
+
2658
+ .prson-head { display: flex; align-items: center; gap: 8px; min-height: 44px; margin: -4px -8px 4px 0; }
2659
+ .prson-brand { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: var(--prson-muted); letter-spacing: -0.1px; }
2660
+ .prson-brand .prson-mark { display: block; }
2661
+ .prson-close {
2662
+ margin-left: auto; width: 44px; height: 44px; display: inline-grid; place-items: center;
2663
+ border: 0; border-radius: 12px; background: transparent; color: var(--prson-muted); cursor: pointer;
2664
+ }
2665
+ .prson-close:hover { background: var(--prson-soft); color: var(--prson-fg); }
2666
+ .prson-close svg { width: 20px; height: 20px; }
2667
+
2668
+ .prson-site { display: flex; align-items: center; gap: 14px; margin: 4px 0 18px; min-width: 0; }
2669
+ .prson-monogram {
2670
+ flex: none; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center;
2671
+ font-size: 22px; font-weight: 700; letter-spacing: -0.5px; color: #0A0A0A;
2672
+ background: var(--prson-mono-bg, #FEF3C7);
2673
+ box-shadow: inset 0 0 0 1px rgba(10, 10, 10, 0.06);
2674
+ }
2675
+ .prson-site-text { min-width: 0; }
2676
+ .prson-eyebrow { margin: 0; font-size: 13px; color: var(--prson-muted); }
2677
+ .prson-domain {
2678
+ margin: 0; font-size: 24px; line-height: 1.15; font-weight: 700; letter-spacing: -0.6px;
2679
+ color: var(--prson-fg); overflow-wrap: anywhere;
2680
+ }
2681
+
2682
+ /* \u2500\u2500 The code, its frame and the countdown ring \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2683
+ .prson-stage { position: relative; display: flex; flex-direction: column; align-items: center; gap: 12px; }
2684
+ .prson-frame { position: relative; width: 272px; height: 272px; max-width: 100%; aspect-ratio: 1; }
2685
+ .prson-ring { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
2686
+ .prson-ring rect { fill: none; stroke-width: 4; }
2687
+ .prson-ring .prson-ring-track { stroke: var(--prson-ring-track); }
2688
+ .prson-ring .prson-ring-fill {
2689
+ stroke: var(--prson-amber); stroke-linecap: round;
2690
+ stroke-dasharray: 100 100; transition: stroke-dashoffset 1s linear, stroke 300ms ease;
2691
+ }
2692
+ .prson-card[data-urgency="warn"] .prson-ring-fill { stroke: #D97706; }
2693
+ .prson-code {
2694
+ position: absolute; inset: 10px; border-radius: 18px; background: #FFFFFF; /* always white: cameras need contrast */
2695
+ display: grid; place-items: center; padding: 12px;
2696
+ box-shadow: inset 0 0 0 1px rgba(10, 10, 10, 0.06);
2697
+ transition: filter 300ms ease, opacity 300ms ease;
2698
+ }
2699
+ .prson-code svg.prson-qr { display: block; width: 100%; height: 100%; }
2700
+ .prson-code-logo {
2701
+ position: absolute; left: 50%; top: 50%; width: 44px; height: 44px; margin: -22px 0 0 -22px;
2702
+ border-radius: 12px; background: #FFFFFF; display: grid; place-items: center;
2703
+ }
2704
+ .prson-code-logo .prson-mark { width: 36px; height: 36px; }
2705
+ .prson-card[data-state]:not([data-state="waiting"]) .prson-code { filter: blur(3px); opacity: 0.25; }
2706
+ .prson-card[data-state="waiting"] .prson-code { filter: none; opacity: 1; }
2707
+
2708
+ .prson-overlay {
2709
+ position: absolute; inset: 10px; border-radius: 18px; display: none;
2710
+ flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 18px; text-align: center;
2711
+ background: var(--prson-bg);
2712
+ background: color-mix(in srgb, var(--prson-bg) 82%, transparent);
2713
+ animation: prson-fade 220ms ease;
2714
+ }
2715
+ .prson-card:not([data-state="waiting"]) .prson-overlay { display: flex; }
2716
+ @keyframes prson-fade { from { opacity: 0; } to { opacity: 1; } }
2717
+ .prson-overlay-icon { width: 56px; height: 56px; display: grid; place-items: center; border-radius: 50%; margin-bottom: 6px; background: var(--prson-soft); color: var(--prson-fg); }
2718
+ .prson-overlay-icon svg { width: 28px; height: 28px; }
2719
+ .prson-overlay-title { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -0.3px; color: var(--prson-fg); }
2720
+ .prson-overlay-text { margin: 0; font-size: 13.5px; color: var(--prson-muted); max-width: 230px; }
2721
+ .prson-overlay .prson-btn { margin-top: 10px; }
2722
+ .prson-card[data-state="error"] .prson-overlay-icon { background: var(--prson-danger-soft); color: var(--prson-danger); }
2723
+
2724
+ .prson-spinner { width: 28px; height: 28px; animation: prson-spin 900ms linear infinite; }
2725
+ @keyframes prson-spin { to { transform: rotate(360deg); } }
2726
+ .prson-pulse { animation: prson-pulse 1.6s ease-in-out infinite; }
2727
+ @keyframes prson-pulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.45); } 50% { box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); } }
2728
+
2729
+ /* Success: an amber disc pops in and the check draws itself. */
2730
+ .prson-card[data-state="success"] .prson-overlay-icon { background: var(--prson-amber); color: #0A0A0A; width: 72px; height: 72px; animation: prson-pop 420ms var(--prson-spring); }
2731
+ .prson-card[data-state="success"] .prson-overlay-icon svg { width: 36px; height: 36px; }
2732
+ .prson-check path { stroke-dasharray: 24; stroke-dashoffset: 24; animation: prson-draw 380ms 160ms ease-out forwards; }
2733
+ @keyframes prson-pop { 0% { transform: scale(0.4); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
2734
+ @keyframes prson-draw { to { stroke-dashoffset: 0; } }
2735
+ .prson-card[data-state="success"] .prson-ring-fill { stroke: var(--prson-amber); stroke-dashoffset: 0 !important; }
2736
+
2737
+ .prson-timer { margin: 0; min-height: 20px; font-size: 13px; color: var(--prson-muted); font-variant-numeric: tabular-nums; }
2738
+ .prson-timer b { color: var(--prson-fg); font-weight: 600; }
2739
+ .prson-card[data-urgency="warn"] .prson-timer b { color: var(--prson-accent-text); }
2740
+ .prson-card[data-state="success"] .prson-timer, .prson-card[data-state="error"] .prson-timer { visibility: hidden; }
2741
+ .prson-hint { margin: 0; font-size: 13px; color: var(--prson-muted); text-align: center; }
2742
+ .prson-card:not([data-state="waiting"]) .prson-hint { visibility: hidden; }
2743
+ .prson-hint b { color: var(--prson-fg); font-weight: 600; }
2744
+
2745
+ /* \u2500\u2500 Phones: one big "Open Prson" button \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2746
+ .prson-open { position: relative; display: flex; flex-direction: column; align-items: stretch; justify-content: center; gap: 10px; width: 100%; }
2747
+ .prson-card[data-device="phone"] .prson-frame { display: none; }
2748
+ .prson-card[data-device="phone"][data-show-code="1"] .prson-frame { display: block; }
2749
+ .prson-card[data-device="desktop"] .prson-open { display: none; }
2750
+ .prson-card[data-device="phone"] .prson-overlay { inset: 0; }
2751
+ .prson-card[data-device="phone"]:not([data-state="waiting"]) .prson-open { min-height: 236px; }
2752
+ .prson-card[data-device="phone"]:not([data-state="waiting"]) .prson-open > :not(.prson-overlay) { visibility: hidden; }
2753
+ .prson-linkish {
2754
+ min-height: 44px; border: 0; background: transparent; color: var(--prson-fg); cursor: pointer;
2755
+ font-size: 14px; font-weight: 500; text-decoration: underline; text-underline-offset: 3px; padding: 0 8px;
2756
+ }
2757
+
2758
+ /* \u2500\u2500 Buttons inside the card \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2759
+ .prson-btn {
2760
+ display: inline-flex; align-items: center; justify-content: center; gap: 10px;
2761
+ min-height: 48px; padding: 0 20px; border-radius: 14px; border: 0; cursor: pointer;
2762
+ font-size: 15px; font-weight: 600; letter-spacing: -0.1px; text-decoration: none;
2763
+ background: var(--prson-amber); color: #0A0A0A;
2764
+ transition: background-color 150ms ease, transform 80ms ease;
2765
+ }
2766
+ .prson-btn:hover { background: var(--prson-amber-hover); }
2767
+ .prson-btn:active { transform: translateY(1px); }
2768
+ .prson-btn--big { min-height: 56px; font-size: 16px; border-radius: 16px; }
2769
+ .prson-btn .prson-mark { flex: none; }
2770
+ .prson-btn { white-space: nowrap; }
2771
+ .prson-btn svg:not(.prson-mark) { flex: none; width: 20px; height: 20px; }
2772
+
2773
+ /* \u2500\u2500 What the site gets \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2774
+ .prson-share { margin: 18px 0 0; padding: 14px 16px; border-radius: 16px; background: var(--prson-soft); border: 1px solid var(--prson-line); }
2775
+ .prson-share-title { margin: 0 0 8px; font-size: 12.5px; font-weight: 600; color: var(--prson-muted); letter-spacing: 0.1px; }
2776
+ .prson-share ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
2777
+ .prson-share li { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--prson-fg); }
2778
+ .prson-share li svg { flex: none; width: 18px; height: 18px; margin-top: 1px; color: var(--prson-fg); opacity: 0.8; }
2779
+ .prson-share li small { display: block; font-size: 12.5px; color: var(--prson-muted); }
2780
+ .prson-share-note { margin: 10px 0 0; font-size: 12.5px; color: var(--prson-muted); }
2781
+
2782
+ /* \u2500\u2500 Anti-relay cue and footer \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2783
+ .prson-guard { display: flex; gap: 8px; align-items: flex-start; margin: 14px 2px 0; font-size: 12.5px; color: var(--prson-muted); }
2784
+ .prson-guard svg { flex: none; width: 16px; height: 16px; margin-top: 1px; }
2785
+ .prson-guard b { color: var(--prson-fg); font-weight: 600; overflow-wrap: anywhere; }
2786
+ .prson-foot { margin: 12px 0 0; padding-top: 12px; border-top: 1px solid var(--prson-line); font-size: 13px; color: var(--prson-muted); text-align: center; }
2787
+ .prson-foot a { color: var(--prson-fg); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; display: inline-block; padding: 12px 4px; margin: -12px 0; }
2788
+
2789
+ .prson-sr { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
2790
+
2791
+ @media (max-width: 380px) {
2792
+ .prson-card { padding: 16px 16px 18px; }
2793
+ .prson-frame { width: 248px; height: 248px; }
2794
+ .prson-domain { font-size: 21px; }
2795
+ }
2796
+
2797
+ /* \u2500\u2500 "Sign in with Prson" button (host page) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500 */
2798
+ .prson-signin-btn {
2799
+ box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
2800
+ min-height: 44px; padding: 0 18px 0 12px; border-radius: 12px; cursor: pointer;
2801
+ font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
2802
+ font-size: 15px; font-weight: 600; line-height: 1; letter-spacing: -0.1px; white-space: nowrap;
2803
+ border: 1px solid transparent; text-decoration: none; -webkit-font-smoothing: antialiased;
2804
+ transition: background-color 150ms ease, border-color 150ms ease, transform 80ms ease;
2805
+ }
2806
+ .prson-signin-btn .prson-mark { flex: none; display: block; }
2807
+ .prson-signin-btn:focus-visible { outline: 3px solid #0A0A0A; outline-offset: 2px; }
2808
+ .prson-signin-btn:active:not(:disabled) { transform: translateY(1px); }
2809
+ .prson-signin-btn:disabled { opacity: 0.55; cursor: not-allowed; }
2810
+ .prson-signin-btn--lg { min-height: 52px; padding: 0 22px 0 14px; font-size: 16px; border-radius: 14px; }
2811
+ .prson-signin-btn--block { display: flex; width: 100%; }
2812
+ .prson-signin-btn--amber { background: #FBBF24; color: #0A0A0A; }
2813
+ .prson-signin-btn--amber:hover:not(:disabled) { background: #F59E0B; }
2814
+ .prson-signin-btn--dark { background: #0A0A0A; color: #FFFFFF; }
2815
+ .prson-signin-btn--dark:hover:not(:disabled) { background: #27272A; }
2816
+ .prson-signin-btn--dark:focus-visible { outline-color: #D97706; }
2817
+ .prson-signin-btn--light { background: #FFFFFF; color: #0A0A0A; border-color: rgba(10, 10, 10, 0.16); }
2818
+ .prson-signin-btn--light:hover:not(:disabled) { background: #FAFAF9; border-color: rgba(10, 10, 10, 0.28); }
2819
+ .prson-signin-btn--light:focus-visible { outline-color: #FBBF24; }
2820
+ .prson-signin-btn--outline { background: transparent; color: inherit; border: 1.5px solid currentColor; }
2821
+ .prson-signin-btn--outline:hover:not(:disabled) { background: rgba(127, 127, 127, 0.10); }
2822
+ .prson-signin-btn--outline:focus-visible { outline-color: currentColor; }
2823
+ .prson-signin-btn--busy { cursor: progress; }
2824
+ .prson-signin-btn--busy .prson-mark { animation: prson-busy 1s ease-in-out infinite; }
2825
+ @keyframes prson-busy { 50% { opacity: 0.35; } }
2826
+ prson-signin-button { display: inline-block; }
2827
+
2828
+ @media (prefers-reduced-motion: reduce) {
2829
+ .prson-card, .prson-card *, .prson-signin-btn, .prson-signin-btn * {
2830
+ animation: none !important;
2831
+ transition: none !important;
2832
+ }
2833
+ .prson-check path { stroke-dashoffset: 0; }
2834
+ .prson-signin-btn:active:not(:disabled), .prson-btn:active { transform: none; }
2835
+ }
2836
+ `;
2837
+ function injectStylesOnce() {
2838
+ if (typeof document === "undefined") return;
2839
+ if (document.querySelector("style[data-prson-login-ui]")) return;
2840
+ const el2 = document.createElement("style");
2841
+ el2.setAttribute("data-prson-login-ui", "1");
2842
+ el2.textContent = PRSON_LOGIN_UI_CSS;
2843
+ document.head.append(el2);
2844
+ }
2845
+
2846
+ // src/index.ts
2847
+ if (typeof window !== "undefined") {
2848
+ injectStylesOnce();
2849
+ window.__prsonLoginQrRenderer = renderQrCard;
2850
+ defineSignInButtonElement();
2851
+ }
2852
+ export {
2853
+ PRSON_LOGIN_UI_CSS,
2854
+ createSignInButton,
2855
+ defineSignInButtonElement,
2856
+ describeCode,
2857
+ describeShares,
2858
+ injectStylesOnce,
2859
+ monogram,
2860
+ prsonMarkSvg,
2861
+ renderQrCard
2862
+ };
2863
+ //# sourceMappingURL=index.js.map