edge-core-js 2.43.0 → 2.43.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/android/src/main/assets/edge-core-js/2088bbb2041078df2819.js +2 -0
- package/android/src/main/assets/edge-core-js/edge-core.js +1 -1
- package/android/src/main/assets/edge-core-js/go_conn.wasm +0 -0
- package/android/src/main/assets/edge-core-js/mix_fetch_wasm_bg.wasm +0 -0
- package/android/src/main/assets/edge-core-js/web-worker-0.js +1 -1
- package/lib/util/nym.js +7 -1
- package/package.json +2 -2
- package/android/src/main/assets/edge-core-js/6f5df9597ed41e29f436.js +0 -2
- /package/android/src/main/assets/edge-core-js/{6f5df9597ed41e29f436.js.LICENSE.txt → 2088bbb2041078df2819.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! For license information please see edge-core.js.LICENSE.txt */
|
|
2
|
-
!function(){var e={8826:function(e){"use strict";!function(t){function n(e){return parseInt(e)===e}function r(e){if(!n(e.length))return!1;for(var t=0;t<e.length;t++)if(!n(e[t])||e[t]<0||e[t]>255)return!1;return!0}function o(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!r(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(n(e.length)&&r(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function i(e){return new Uint8Array(e)}function a(e,t,n,r,o){null==r&&null==o||(e=e.slice?e.slice(r,o):Array.prototype.slice.call(e,r,o)),t.set(e,n)}var s,c={toBytes:function(e){var t=[],n=0;for(e=encodeURI(e);n<e.length;){var r=e.charCodeAt(n++);37===r?(t.push(parseInt(e.substr(n,2),16)),n+=2):t.push(r)}return o(t)},fromBytes:function(e){for(var t=[],n=0;n<e.length;){var r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}},u=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},fromBytes:function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(s[(240&r)>>4]+s[15&r])}return t.join("")}}),l={16:10,24:12,32:14},d=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],f=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],p=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],h=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],y=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],b=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],g=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],w=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],v=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],m=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],I=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],S=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],O=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function T(e){for(var t=[],n=0;n<e.length;n+=4)t.push(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]);return t}var _=function(e){if(!(this instanceof _))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:o(e,!0)}),this._prepare()};_.prototype._prepare=function(){var e=l[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var n,r=4*(e+1),o=this.key.length/4,i=T(this.key);for(t=0;t<o;t++)n=t>>2,this._Ke[n][t%4]=i[t],this._Kd[e-n][t%4]=i[t];for(var a,s=0,c=o;c<r;){if(a=i[o-1],i[0]^=f[a>>16&255]<<24^f[a>>8&255]<<16^f[255&a]<<8^f[a>>24&255]^d[s]<<24,s+=1,8!=o)for(t=1;t<o;t++)i[t]^=i[t-1];else{for(t=1;t<o/2;t++)i[t]^=i[t-1];a=i[o/2-1],i[o/2]^=f[255&a]^f[a>>8&255]<<8^f[a>>16&255]<<16^f[a>>24&255]<<24;for(t=o/2+1;t<o;t++)i[t]^=i[t-1]}for(t=0;t<o&&c<r;)u=c>>2,p=c%4,this._Ke[u][p]=i[t],this._Kd[e-u][p]=i[t++],c++}for(var u=1;u<e;u++)for(var p=0;p<4;p++)a=this._Kd[u][p],this._Kd[u][p]=E[a>>24&255]^S[a>>16&255]^O[a>>8&255]^A[255&a]},_.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,n=[0,0,0,0],r=T(e),o=0;o<4;o++)r[o]^=this._Ke[0][o];for(var a=1;a<t;a++){for(o=0;o<4;o++)n[o]=h[r[o]>>24&255]^y[r[(o+1)%4]>>16&255]^b[r[(o+2)%4]>>8&255]^g[255&r[(o+3)%4]]^this._Ke[a][o];r=n.slice()}var s,c=i(16);for(o=0;o<4;o++)s=this._Ke[t][o],c[4*o]=255&(f[r[o]>>24&255]^s>>24),c[4*o+1]=255&(f[r[(o+1)%4]>>16&255]^s>>16),c[4*o+2]=255&(f[r[(o+2)%4]>>8&255]^s>>8),c[4*o+3]=255&(f[255&r[(o+3)%4]]^s);return c},_.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,n=[0,0,0,0],r=T(e),o=0;o<4;o++)r[o]^=this._Kd[0][o];for(var a=1;a<t;a++){for(o=0;o<4;o++)n[o]=w[r[o]>>24&255]^v[r[(o+3)%4]>>16&255]^m[r[(o+2)%4]>>8&255]^I[255&r[(o+1)%4]]^this._Kd[a][o];r=n.slice()}var s,c=i(16);for(o=0;o<4;o++)s=this._Kd[t][o],c[4*o]=255&(p[r[o]>>24&255]^s>>24),c[4*o+1]=255&(p[r[(o+3)%4]>>16&255]^s>>16),c[4*o+2]=255&(p[r[(o+2)%4]>>8&255]^s>>8),c[4*o+3]=255&(p[255&r[(o+1)%4]]^s);return c};var k=function(e){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new _(e)};k.prototype.encrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16)a(e,n,0,r,r+16),a(n=this._aes.encrypt(n),t,r);return t},k.prototype.decrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16)a(e,n,0,r,r+16),a(n=this._aes.decrypt(n),t,r);return t};var x=function(e,t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=i(16);this._lastCipherblock=o(t,!0),this._aes=new _(e)};x.prototype.encrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16){a(e,n,0,r,r+16);for(var s=0;s<16;s++)n[s]^=this._lastCipherblock[s];this._lastCipherblock=this._aes.encrypt(n),a(this._lastCipherblock,t,r)}return t},x.prototype.decrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16){a(e,n,0,r,r+16),n=this._aes.decrypt(n);for(var s=0;s<16;s++)t[r+s]=n[s]^this._lastCipherblock[s];a(e,this._lastCipherblock,0,r,r+16)}return t};var P=function(e,t,n){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=i(16);n||(n=1),this.segmentSize=n,this._shiftRegister=o(t,!0),this._aes=new _(e)};P.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,n=o(e,!0),r=0;r<n.length;r+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var i=0;i<this.segmentSize;i++)n[r+i]^=t[i];a(this._shiftRegister,this._shiftRegister,0,this.segmentSize),a(n,this._shiftRegister,16-this.segmentSize,r,r+this.segmentSize)}return n},P.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,n=o(e,!0),r=0;r<n.length;r+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var i=0;i<this.segmentSize;i++)n[r+i]^=t[i];a(this._shiftRegister,this._shiftRegister,0,this.segmentSize),a(e,this._shiftRegister,16-this.segmentSize,r,r+this.segmentSize)}return n};var M=function(e,t){if(!(this instanceof M))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=i(16);this._lastPrecipher=o(t,!0),this._lastPrecipherIndex=16,this._aes=new _(e)};M.prototype.encrypt=function(e){for(var t=o(e,!0),n=0;n<t.length;n++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[n]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},M.prototype.decrypt=M.prototype.encrypt;var C=function(e){if(!(this instanceof C))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=i(16),this.setValue(e)):this.setBytes(e)};C.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},C.prototype.setBytes=function(e){if(16!=(e=o(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},C.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var N=function(e,t){if(!(this instanceof N))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof C||(t=new C(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new _(e)};N.prototype.encrypt=function(e){for(var t=o(e,!0),n=0;n<t.length;n++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[n]^=this._remainingCounter[this._remainingCounterIndex++];return t},N.prototype.decrypt=N.prototype.encrypt;var j={AES:_,Counter:C,ModeOfOperation:{ecb:k,cbc:x,cfb:P,ofb:M,ctr:N},utils:{hex:u,utf8:c},padding:{pkcs7:{pad:function(e){var t=16-(e=o(e,!0)).length%16,n=i(e.length+t);a(e,n);for(var r=e.length;r<n.length;r++)n[r]=t;return n},strip:function(e){if((e=o(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var n=e.length-t,r=0;r<t;r++)if(e[n+r]!==t)throw new Error("PKCS#7 invalid padding byte");var s=i(n);return a(e,s,0,0,n),s}}},_arrayTest:{coerceArray:o,createArray:i,copyArray:a}};e.exports=j}()},8162:function(e){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var r=0;r<e.length;r++){var o=e.charAt(r),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=r}var a=e.length,s=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var n=0,r=0,o=0;e[n]===s;)r++,n++;for(var i=(e.length-n)*c+1>>>0,u=new Uint8Array(i);e[n];){var l=t[e.charCodeAt(n)];if(255===l)return;for(var d=0,f=i-1;(0!==l||d<o)&&-1!==f;f--,d++)l+=a*u[f]>>>0,u[f]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,n++}for(var p=i-o;p!==i&&0===u[p];)p++;for(var h=new Uint8Array(r+(i-p)),y=r;p!==i;)h[y++]=u[p++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,o=0,i=t.length;o!==i&&0===t[o];)o++,n++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var d=t[o],f=0,p=c-1;(0!==d||f<r)&&-1!==p;p--,f++)d+=256*l[p]>>>0,l[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");r=f,o++}for(var h=c-r;h!==c&&0===l[h];)h++;for(var y=s.repeat(n);h<c;++h)y+=e.charAt(l[h]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},7591:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.log10=t.toFixed=t.toBns=t.round=t.ceil=t.floor=t.max=t.abs=t.min=t.eq=t.gte=t.gt=t.lte=t.lt=t.div=t.sub=t.mul=t.add=void 0;const o=r(n(3550)),i=/^(-?\d*\.?\d*)e((?:\+|-)?\d+)$/;function a(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.add(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")}function s(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.mul(l).toString(n);return f=d(f,2*a),10===n?f:f.replace(/^(-)?/,"$10x")}function c(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gt(c)}function u(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gte(c)}function l(e){let t="number"==typeof e?e.toString():e.replace(/^\s+|\s+$/g,"");""!==t&&"."!==t||(t="0");const n=t.match(i);if(null!=n){t=function(e,t){const n=t>=0?"1"+"0".repeat(Math.abs(t)):`0.${"0".repeat(Math.abs(t)-1)}1`;return s(e,n)}(n[1],parseInt(n[2]))}return function(...e){for(const t of e){if(t.split(".").length-1>1)throw new Error(`Invalid number: more than one decimal point '${t}'`);if(t.split("-").length-1>1)throw new Error(`Invalid number: more than one negative sign '${t}'`);if(!/^-?(?:0x[0-9A-Fa-f]+|(?:\d+(?:\.\d*)?|\.\d+))$/.test(t))throw new Error(`Invalid number: non-number characters '${t}'`)}}(t),t}function d(e,t){if(0===t)return e;let n,r=!1;return"-"===e.slice(0,1)&&(r=!0,e=e.slice(1)),n=t>e.length?"0."+f("",t-e.length)+e:e.substr(0,e.length-t)+"."+e.substr(e.length-t,e.length),n=g(n),r&&(n=`-${n}`),n}function f(e,t){let n=e;for(let r=0;r<t;r++)n+="0";return n}function p(e){return e.replace("0x","")}function h(e,t,n){let r=l(e),o=l(t),i=r.indexOf("."),a=o.indexOf(".");const s=y(r),c=y(o);if(-1!==i&&(r=g(r),i=r.indexOf(".")),-1!==a&&(o=g(o),a=o.indexOf(".")),-1!==i||-1!==a||"number"==typeof n){if(s||c)throw new Error("Cannot operate on base16 float values");let e=0,t=0;-1!==i&&(e=r.length-i-1),-1!==a&&(t=o.length-a-1);const u=e>t?e:t;let l=0;"number"==typeof n&&(l=n),r=f(r.replace(".",""),u+l-e),o=f(o.replace(".",""),u-t);return{x:r,y:o,shift:u}}return{x:r,y:o,shift:0}}function y(e){const t=l(e);return!!(t.startsWith("0x")||t.startsWith("-0x")||t.toLowerCase().includes("a")||t.toLowerCase().includes("b")||t.toLowerCase().includes("c")||t.toLowerCase().includes("d")||t.toLowerCase().includes("e")||t.toLowerCase().includes("f"))}function b(e,t,n=0){var r,o;let i=l(t),s=!1,d="";i.includes("-")&&(s=!0,i=i.replace(/^-+/,""));const[f,p=""]=i.split("."),h=i.indexOf("."),y=-1!==h?h-n:i.length-n,b=f+p;if("round"===e){e=u(null!==(r=b[y])&&void 0!==r?r:"0","5")?"ceil":"floor"}const w=Math.max(b.length-y+1,0),v=new Array(w).join("0");let m=b.substring(0,y)+v;const I=c(b.substring(y),"0");if("ceil"===e&&I){const e="1"+v,t=(null!==(o=m.match(/^0+/))&&void 0!==o?o:[""])[0].length;m=new Array(t).join("0")+a(m,e)}const E=h+(m.length-b.length);return d=-1!==h?m.substring(0,E)+"."+m.substring(E):m,d=g(d),s&&"0"!==d&&(d="-"+d),d}function g(e){let t=e.replace(/^0+/,"");return t=t.replace(/^\.+/,"0."),t.includes(".")&&(t=t.replace(/0+$/,""),t=t.replace(/\.+$/,""),""===t&&(t="0")),""===t&&(t="0"),t}t.add=a,t.mul=s,t.sub=function(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.sub(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.div=function(e,t,n=0,r=10){if(10!==r&&n>0)throw new Error("Cannot operate on floating point hex values");if(10!==r&&16!==r)throw new Error("Unsupported base");let{x:i,y:a}=h(e,t,n);const s=y(i)?16:10,c=y(a)?16:10;i=p(i),a=p(a);const u=new o.default(i,s),l=new o.default(a,c);let f=u.div(l).toString(r);return f=d(f,n),10===r?f:f.replace(/^(-)?/,"$10x")},t.lt=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lt(c)},t.lte=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lte(c)},t.gt=c,t.gte=u,t.eq=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.eq(c)},t.min=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.lte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.abs=function(e,t=10){if(10!==t&&16!==t)throw new Error("Unsupported base");let{x:n,shift:r}=h(e,"0");const i=y(e)?16:10;n=p(n);let a=new o.default(n,i).abs().toString(t);return a=d(a,r),10===t?a:a.replace(/^(-)?/,"$10x")},t.max=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.gte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.floor=(e,t)=>b("floor",e,t),t.ceil=(e,t)=>b("ceil",e,t),t.round=(e,t)=>b("round",e,t),t.toBns=l,t.toFixed=function(e,t=2,n=8){let r=l(e),o=!1,i="";r.includes("-")&&(o=!0,r=r.replace(/^-+/,"")),r=g(r);const a=r.indexOf(".");if(-1===a)i=r+"."+f("",t);else{const e=r.length-a-1;i=e>n?r.substr(0,r.length-(e-n)):e<t?r+f("",t-e):r}return i=i.replace(/\.+$/,""),o&&"0"!==i&&(i="-"+i),i},t.log10=function(e){if(null===e.match(/^[0-1]+$/g))throw new Error("InvalidLogInputValue: Must be a power of 10");if(!e.startsWith("1"))throw new Error("InvalidLogInputValue: Must not have leading zeros");if((e.match(/1/g)||[]).length>1)throw new Error("InvalidLogInputValue: Must be power of 10.");return(e.match(/0/g)||[]).length}},3550:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(6601).Buffer}catch(A){}function s(e,t){var n=e.charCodeAt(t);return n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,r){for(var o=0,i=Math.min(e.length,n),a=t;a<i;a++){var s=e.charCodeAt(a)-48;o*=r,o+=s>=49?s-49+10:s>=17?s-17+10:s}return o}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,n):(this._parseBase(e,t,o),"le"===n&&this._initArray(this.toArray(),t,n)))},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,a,s=0;if("be"===n)for(o=e.length-1,i=0;o>=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o<e.length;o+=3)a=e[o]|e[o+1]<<8|e[o+2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,i=0,a=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,a=i%r,s=Math.min(i,i-a)+n,c=0,l=n;l<s;l+=r)c=u(e,l,l+r,t),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var d=1;for(c=u(e,l,e.length,t),l=0;l<a;l++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,c=a/67108864|0;n.words[0]=s;for(var u=1;u<r;u++){for(var l=c>>>26,d=67108863&c,f=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=f;p++){var h=u-p|0;l+=(a=(o=0|e.words[h])*(i=0|t.words[p])+d)/67108864|0,d=67108863&a}n.words[u]=0|d,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var o=0,i=0,a=0;a<this.length;a++){var s=this.words[a],c=(16777215&(s<<o|i)).toString(16);n=0!==(i=s>>>24-o&16777215)||a!==this.length-1?l[6-c.length]+c+n:c+n,(o+=2)>=26&&(o-=26,a--)}for(0!==i&&(n=i.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=d[e],p=f[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modn(p).toString(e);n=(h=h.idivn(p)).isZero()?y+n:l[u-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0"),this.strip();var a,s,c="le"===t,u=new e(i),l=this.clone();if(c){for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[s]=a;for(;s<i;s++)u[s]=0}else{for(s=0;s<i-o;s++)u[s]=0;for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[i-s-1]=a}return u},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},i.prototype.ior=function(e){return r(0==(this.negative|e.negative)),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this.strip()},i.prototype.iand=function(e){return r(0==(this.negative|e.negative)),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this.strip()},i.prototype.ixor=function(e){return r(0==(this.negative|e.negative)),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var o=0;o<t;o++)this.words[o]=67108863&~this.words[o];return n>0&&(this.words[o]=~this.words[o]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,o=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<o:this.words[n]&~(1<<o),this.strip()},i.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i<r.length;i++)t=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<n.length;i++)t=(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;i<n.length;i++)this.words[i]=n.words[i];return this},i.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)i=(t=(0|n.words[a])-(0|r.words[a])+i)>>26,this.words[a]=67108863&t;for(;0!==i&&a<n.length;a++)i=(t=(0|n.words[a])+i)>>26,this.words[a]=67108863&t;if(0===i&&a<n.length&&n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this.length=Math.max(this.length,a),n!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(e){return this.clone().isub(e)};var h=function(e,t,n){var r,o,i,a=e.words,s=t.words,c=n.words,u=0,l=0|a[0],d=8191&l,f=l>>>13,p=0|a[1],h=8191&p,y=p>>>13,b=0|a[2],g=8191&b,w=b>>>13,v=0|a[3],m=8191&v,I=v>>>13,E=0|a[4],S=8191&E,O=E>>>13,A=0|a[5],T=8191&A,_=A>>>13,k=0|a[6],x=8191&k,P=k>>>13,M=0|a[7],C=8191&M,N=M>>>13,j=0|a[8],D=8191&j,R=j>>>13,L=0|a[9],B=8191&L,K=L>>>13,U=0|s[0],F=8191&U,W=U>>>13,G=0|s[1],q=8191&G,z=G>>>13,$=0|s[2],H=8191&$,Y=$>>>13,V=0|s[3],J=8191&V,X=V>>>13,Z=0|s[4],Q=8191&Z,ee=Z>>>13,te=0|s[5],ne=8191&te,re=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],ce=8191&se,ue=se>>>13,le=0|s[8],de=8191&le,fe=le>>>13,pe=0|s[9],he=8191&pe,ye=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(r=Math.imul(d,F))|0)+((8191&(o=(o=Math.imul(d,W))+Math.imul(f,F)|0))<<13)|0;u=((i=Math.imul(f,W))+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(h,F),o=(o=Math.imul(h,W))+Math.imul(y,F)|0,i=Math.imul(y,W);var ge=(u+(r=r+Math.imul(d,q)|0)|0)+((8191&(o=(o=o+Math.imul(d,z)|0)+Math.imul(f,q)|0))<<13)|0;u=((i=i+Math.imul(f,z)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,F),o=(o=Math.imul(g,W))+Math.imul(w,F)|0,i=Math.imul(w,W),r=r+Math.imul(h,q)|0,o=(o=o+Math.imul(h,z)|0)+Math.imul(y,q)|0,i=i+Math.imul(y,z)|0;var we=(u+(r=r+Math.imul(d,H)|0)|0)+((8191&(o=(o=o+Math.imul(d,Y)|0)+Math.imul(f,H)|0))<<13)|0;u=((i=i+Math.imul(f,Y)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(m,F),o=(o=Math.imul(m,W))+Math.imul(I,F)|0,i=Math.imul(I,W),r=r+Math.imul(g,q)|0,o=(o=o+Math.imul(g,z)|0)+Math.imul(w,q)|0,i=i+Math.imul(w,z)|0,r=r+Math.imul(h,H)|0,o=(o=o+Math.imul(h,Y)|0)+Math.imul(y,H)|0,i=i+Math.imul(y,Y)|0;var ve=(u+(r=r+Math.imul(d,J)|0)|0)+((8191&(o=(o=o+Math.imul(d,X)|0)+Math.imul(f,J)|0))<<13)|0;u=((i=i+Math.imul(f,X)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(S,F),o=(o=Math.imul(S,W))+Math.imul(O,F)|0,i=Math.imul(O,W),r=r+Math.imul(m,q)|0,o=(o=o+Math.imul(m,z)|0)+Math.imul(I,q)|0,i=i+Math.imul(I,z)|0,r=r+Math.imul(g,H)|0,o=(o=o+Math.imul(g,Y)|0)+Math.imul(w,H)|0,i=i+Math.imul(w,Y)|0,r=r+Math.imul(h,J)|0,o=(o=o+Math.imul(h,X)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,X)|0;var me=(u+(r=r+Math.imul(d,Q)|0)|0)+((8191&(o=(o=o+Math.imul(d,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((i=i+Math.imul(f,ee)|0)+(o>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(T,F),o=(o=Math.imul(T,W))+Math.imul(_,F)|0,i=Math.imul(_,W),r=r+Math.imul(S,q)|0,o=(o=o+Math.imul(S,z)|0)+Math.imul(O,q)|0,i=i+Math.imul(O,z)|0,r=r+Math.imul(m,H)|0,o=(o=o+Math.imul(m,Y)|0)+Math.imul(I,H)|0,i=i+Math.imul(I,Y)|0,r=r+Math.imul(g,J)|0,o=(o=o+Math.imul(g,X)|0)+Math.imul(w,J)|0,i=i+Math.imul(w,X)|0,r=r+Math.imul(h,Q)|0,o=(o=o+Math.imul(h,ee)|0)+Math.imul(y,Q)|0,i=i+Math.imul(y,ee)|0;var Ie=(u+(r=r+Math.imul(d,ne)|0)|0)+((8191&(o=(o=o+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;u=((i=i+Math.imul(f,re)|0)+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(x,F),o=(o=Math.imul(x,W))+Math.imul(P,F)|0,i=Math.imul(P,W),r=r+Math.imul(T,q)|0,o=(o=o+Math.imul(T,z)|0)+Math.imul(_,q)|0,i=i+Math.imul(_,z)|0,r=r+Math.imul(S,H)|0,o=(o=o+Math.imul(S,Y)|0)+Math.imul(O,H)|0,i=i+Math.imul(O,Y)|0,r=r+Math.imul(m,J)|0,o=(o=o+Math.imul(m,X)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,X)|0,r=r+Math.imul(g,Q)|0,o=(o=o+Math.imul(g,ee)|0)+Math.imul(w,Q)|0,i=i+Math.imul(w,ee)|0,r=r+Math.imul(h,ne)|0,o=(o=o+Math.imul(h,re)|0)+Math.imul(y,ne)|0,i=i+Math.imul(y,re)|0;var Ee=(u+(r=r+Math.imul(d,ie)|0)|0)+((8191&(o=(o=o+Math.imul(d,ae)|0)+Math.imul(f,ie)|0))<<13)|0;u=((i=i+Math.imul(f,ae)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(C,F),o=(o=Math.imul(C,W))+Math.imul(N,F)|0,i=Math.imul(N,W),r=r+Math.imul(x,q)|0,o=(o=o+Math.imul(x,z)|0)+Math.imul(P,q)|0,i=i+Math.imul(P,z)|0,r=r+Math.imul(T,H)|0,o=(o=o+Math.imul(T,Y)|0)+Math.imul(_,H)|0,i=i+Math.imul(_,Y)|0,r=r+Math.imul(S,J)|0,o=(o=o+Math.imul(S,X)|0)+Math.imul(O,J)|0,i=i+Math.imul(O,X)|0,r=r+Math.imul(m,Q)|0,o=(o=o+Math.imul(m,ee)|0)+Math.imul(I,Q)|0,i=i+Math.imul(I,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(w,ne)|0,i=i+Math.imul(w,re)|0,r=r+Math.imul(h,ie)|0,o=(o=o+Math.imul(h,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0;var Se=(u+(r=r+Math.imul(d,ce)|0)|0)+((8191&(o=(o=o+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((i=i+Math.imul(f,ue)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(D,F),o=(o=Math.imul(D,W))+Math.imul(R,F)|0,i=Math.imul(R,W),r=r+Math.imul(C,q)|0,o=(o=o+Math.imul(C,z)|0)+Math.imul(N,q)|0,i=i+Math.imul(N,z)|0,r=r+Math.imul(x,H)|0,o=(o=o+Math.imul(x,Y)|0)+Math.imul(P,H)|0,i=i+Math.imul(P,Y)|0,r=r+Math.imul(T,J)|0,o=(o=o+Math.imul(T,X)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,X)|0,r=r+Math.imul(S,Q)|0,o=(o=o+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,i=i+Math.imul(O,ee)|0,r=r+Math.imul(m,ne)|0,o=(o=o+Math.imul(m,re)|0)+Math.imul(I,ne)|0,i=i+Math.imul(I,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,ae)|0)+Math.imul(w,ie)|0,i=i+Math.imul(w,ae)|0,r=r+Math.imul(h,ce)|0,o=(o=o+Math.imul(h,ue)|0)+Math.imul(y,ce)|0,i=i+Math.imul(y,ue)|0;var Oe=(u+(r=r+Math.imul(d,de)|0)|0)+((8191&(o=(o=o+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((i=i+Math.imul(f,fe)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(B,F),o=(o=Math.imul(B,W))+Math.imul(K,F)|0,i=Math.imul(K,W),r=r+Math.imul(D,q)|0,o=(o=o+Math.imul(D,z)|0)+Math.imul(R,q)|0,i=i+Math.imul(R,z)|0,r=r+Math.imul(C,H)|0,o=(o=o+Math.imul(C,Y)|0)+Math.imul(N,H)|0,i=i+Math.imul(N,Y)|0,r=r+Math.imul(x,J)|0,o=(o=o+Math.imul(x,X)|0)+Math.imul(P,J)|0,i=i+Math.imul(P,X)|0,r=r+Math.imul(T,Q)|0,o=(o=o+Math.imul(T,ee)|0)+Math.imul(_,Q)|0,i=i+Math.imul(_,ee)|0,r=r+Math.imul(S,ne)|0,o=(o=o+Math.imul(S,re)|0)+Math.imul(O,ne)|0,i=i+Math.imul(O,re)|0,r=r+Math.imul(m,ie)|0,o=(o=o+Math.imul(m,ae)|0)+Math.imul(I,ie)|0,i=i+Math.imul(I,ae)|0,r=r+Math.imul(g,ce)|0,o=(o=o+Math.imul(g,ue)|0)+Math.imul(w,ce)|0,i=i+Math.imul(w,ue)|0,r=r+Math.imul(h,de)|0,o=(o=o+Math.imul(h,fe)|0)+Math.imul(y,de)|0,i=i+Math.imul(y,fe)|0;var Ae=(u+(r=r+Math.imul(d,he)|0)|0)+((8191&(o=(o=o+Math.imul(d,ye)|0)+Math.imul(f,he)|0))<<13)|0;u=((i=i+Math.imul(f,ye)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,q),o=(o=Math.imul(B,z))+Math.imul(K,q)|0,i=Math.imul(K,z),r=r+Math.imul(D,H)|0,o=(o=o+Math.imul(D,Y)|0)+Math.imul(R,H)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(C,J)|0,o=(o=o+Math.imul(C,X)|0)+Math.imul(N,J)|0,i=i+Math.imul(N,X)|0,r=r+Math.imul(x,Q)|0,o=(o=o+Math.imul(x,ee)|0)+Math.imul(P,Q)|0,i=i+Math.imul(P,ee)|0,r=r+Math.imul(T,ne)|0,o=(o=o+Math.imul(T,re)|0)+Math.imul(_,ne)|0,i=i+Math.imul(_,re)|0,r=r+Math.imul(S,ie)|0,o=(o=o+Math.imul(S,ae)|0)+Math.imul(O,ie)|0,i=i+Math.imul(O,ae)|0,r=r+Math.imul(m,ce)|0,o=(o=o+Math.imul(m,ue)|0)+Math.imul(I,ce)|0,i=i+Math.imul(I,ue)|0,r=r+Math.imul(g,de)|0,o=(o=o+Math.imul(g,fe)|0)+Math.imul(w,de)|0,i=i+Math.imul(w,fe)|0;var Te=(u+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,ye)|0)+Math.imul(y,he)|0))<<13)|0;u=((i=i+Math.imul(y,ye)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,H),o=(o=Math.imul(B,Y))+Math.imul(K,H)|0,i=Math.imul(K,Y),r=r+Math.imul(D,J)|0,o=(o=o+Math.imul(D,X)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,X)|0,r=r+Math.imul(C,Q)|0,o=(o=o+Math.imul(C,ee)|0)+Math.imul(N,Q)|0,i=i+Math.imul(N,ee)|0,r=r+Math.imul(x,ne)|0,o=(o=o+Math.imul(x,re)|0)+Math.imul(P,ne)|0,i=i+Math.imul(P,re)|0,r=r+Math.imul(T,ie)|0,o=(o=o+Math.imul(T,ae)|0)+Math.imul(_,ie)|0,i=i+Math.imul(_,ae)|0,r=r+Math.imul(S,ce)|0,o=(o=o+Math.imul(S,ue)|0)+Math.imul(O,ce)|0,i=i+Math.imul(O,ue)|0,r=r+Math.imul(m,de)|0,o=(o=o+Math.imul(m,fe)|0)+Math.imul(I,de)|0,i=i+Math.imul(I,fe)|0;var _e=(u+(r=r+Math.imul(g,he)|0)|0)+((8191&(o=(o=o+Math.imul(g,ye)|0)+Math.imul(w,he)|0))<<13)|0;u=((i=i+Math.imul(w,ye)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(B,J),o=(o=Math.imul(B,X))+Math.imul(K,J)|0,i=Math.imul(K,X),r=r+Math.imul(D,Q)|0,o=(o=o+Math.imul(D,ee)|0)+Math.imul(R,Q)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(C,ne)|0,o=(o=o+Math.imul(C,re)|0)+Math.imul(N,ne)|0,i=i+Math.imul(N,re)|0,r=r+Math.imul(x,ie)|0,o=(o=o+Math.imul(x,ae)|0)+Math.imul(P,ie)|0,i=i+Math.imul(P,ae)|0,r=r+Math.imul(T,ce)|0,o=(o=o+Math.imul(T,ue)|0)+Math.imul(_,ce)|0,i=i+Math.imul(_,ue)|0,r=r+Math.imul(S,de)|0,o=(o=o+Math.imul(S,fe)|0)+Math.imul(O,de)|0,i=i+Math.imul(O,fe)|0;var ke=(u+(r=r+Math.imul(m,he)|0)|0)+((8191&(o=(o=o+Math.imul(m,ye)|0)+Math.imul(I,he)|0))<<13)|0;u=((i=i+Math.imul(I,ye)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,Q),o=(o=Math.imul(B,ee))+Math.imul(K,Q)|0,i=Math.imul(K,ee),r=r+Math.imul(D,ne)|0,o=(o=o+Math.imul(D,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(C,ie)|0,o=(o=o+Math.imul(C,ae)|0)+Math.imul(N,ie)|0,i=i+Math.imul(N,ae)|0,r=r+Math.imul(x,ce)|0,o=(o=o+Math.imul(x,ue)|0)+Math.imul(P,ce)|0,i=i+Math.imul(P,ue)|0,r=r+Math.imul(T,de)|0,o=(o=o+Math.imul(T,fe)|0)+Math.imul(_,de)|0,i=i+Math.imul(_,fe)|0;var xe=(u+(r=r+Math.imul(S,he)|0)|0)+((8191&(o=(o=o+Math.imul(S,ye)|0)+Math.imul(O,he)|0))<<13)|0;u=((i=i+Math.imul(O,ye)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,ne),o=(o=Math.imul(B,re))+Math.imul(K,ne)|0,i=Math.imul(K,re),r=r+Math.imul(D,ie)|0,o=(o=o+Math.imul(D,ae)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,ae)|0,r=r+Math.imul(C,ce)|0,o=(o=o+Math.imul(C,ue)|0)+Math.imul(N,ce)|0,i=i+Math.imul(N,ue)|0,r=r+Math.imul(x,de)|0,o=(o=o+Math.imul(x,fe)|0)+Math.imul(P,de)|0,i=i+Math.imul(P,fe)|0;var Pe=(u+(r=r+Math.imul(T,he)|0)|0)+((8191&(o=(o=o+Math.imul(T,ye)|0)+Math.imul(_,he)|0))<<13)|0;u=((i=i+Math.imul(_,ye)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ie),o=(o=Math.imul(B,ae))+Math.imul(K,ie)|0,i=Math.imul(K,ae),r=r+Math.imul(D,ce)|0,o=(o=o+Math.imul(D,ue)|0)+Math.imul(R,ce)|0,i=i+Math.imul(R,ue)|0,r=r+Math.imul(C,de)|0,o=(o=o+Math.imul(C,fe)|0)+Math.imul(N,de)|0,i=i+Math.imul(N,fe)|0;var Me=(u+(r=r+Math.imul(x,he)|0)|0)+((8191&(o=(o=o+Math.imul(x,ye)|0)+Math.imul(P,he)|0))<<13)|0;u=((i=i+Math.imul(P,ye)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,ce),o=(o=Math.imul(B,ue))+Math.imul(K,ce)|0,i=Math.imul(K,ue),r=r+Math.imul(D,de)|0,o=(o=o+Math.imul(D,fe)|0)+Math.imul(R,de)|0,i=i+Math.imul(R,fe)|0;var Ce=(u+(r=r+Math.imul(C,he)|0)|0)+((8191&(o=(o=o+Math.imul(C,ye)|0)+Math.imul(N,he)|0))<<13)|0;u=((i=i+Math.imul(N,ye)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,de),o=(o=Math.imul(B,fe))+Math.imul(K,de)|0,i=Math.imul(K,fe);var Ne=(u+(r=r+Math.imul(D,he)|0)|0)+((8191&(o=(o=o+Math.imul(D,ye)|0)+Math.imul(R,he)|0))<<13)|0;u=((i=i+Math.imul(R,ye)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863;var je=(u+(r=Math.imul(B,he))|0)+((8191&(o=(o=Math.imul(B,ye))+Math.imul(K,he)|0))<<13)|0;return u=((i=Math.imul(K,ye))+(o>>>13)|0)+(je>>>26)|0,je&=67108863,c[0]=be,c[1]=ge,c[2]=we,c[3]=ve,c[4]=me,c[5]=Ie,c[6]=Ee,c[7]=Se,c[8]=Oe,c[9]=Ae,c[10]=Te,c[11]=_e,c[12]=ke,c[13]=xe,c[14]=Pe,c[15]=Me,c[16]=Ce,c[17]=Ne,c[18]=je,0!==u&&(c[19]=u,n.length++),n};function y(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(h=p),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?h(this,e,t):r<63?p(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i<n.length-1;i++){var a=o;o=0;for(var s=67108863&r,c=Math.min(i,t.length-1),u=Math.max(0,i-e.length+1);u<=c;u++){var l=i-u,d=(0|e.words[l])*(0|t.words[u]),f=67108863&d;s=67108863&(f=f+s|0),o+=(a=(a=a+(d/67108864|0)|0)+(f>>>26)|0)>>>26,a&=67108863}n.words[i]=s,r=a,a=o}return 0!==r?n.words[i]=r:n.length--,n.strip()}(this,e,t):y(this,e,t),n},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},b.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,o=0;o<t;o++)r|=(1&e)<<t-o-1,e>>=1;return r},b.prototype.permute=function(e,t,n,r,o,i){for(var a=0;a<i;a++)r[a]=t[e[a]],o[a]=n[e[a]]},b.prototype.transform=function(e,t,n,r,o,i){this.permute(i,e,t,n,r,o);for(var a=1;a<o;a<<=1)for(var s=a<<1,c=Math.cos(2*Math.PI/s),u=Math.sin(2*Math.PI/s),l=0;l<o;l+=s)for(var d=c,f=u,p=0;p<a;p++){var h=n[l+p],y=r[l+p],b=n[l+p+a],g=r[l+p+a],w=d*b-f*g;g=d*g+f*b,b=w,n[l+p]=h+b,r[l+p]=y+g,n[l+p+a]=h-b,r[l+p+a]=y-g,p!==s&&(w=c*d-u*f,f=c*f+u*d,d=w)}},b.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,o=0;for(n=n/2|0;n;n>>>=1)o++;return 1<<o+1+r},b.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var o=e[r];e[r]=e[n-r-1],e[n-r-1]=o,o=t[r],t[r]=-t[n-r-1],t[n-r-1]=-o}},b.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var o=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&o,n=o<67108864?0:o/67108864|0}return e},b.prototype.convert13b=function(e,t,n,o){for(var i=0,a=0;a<t;a++)i+=0|e[a],n[2*a]=8191&i,i>>>=13,n[2*a+1]=8191&i,i>>>=13;for(a=2*t;a<o;++a)n[a]=0;r(0===i),r(0==(-8192&i))},b.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},b.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),o=this.makeRBT(r),i=this.stub(r),a=new Array(r),s=new Array(r),c=new Array(r),u=new Array(r),l=new Array(r),d=new Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,a,r),this.convert13b(t.words,t.length,u,r),this.transform(a,i,s,c,r,o),this.transform(u,i,l,d,r,o);for(var p=0;p<r;p++){var h=s[p]*l[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*l[p],s[p]=h}return this.conjugate(s,c,r),this.transform(s,c,f,i,r,o),this.conjugate(f,i,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n.strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),y(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){r("number"==typeof e),r(e<67108864);for(var t=0,n=0;n<this.length;n++){var o=(0|this.words[n])*e,i=(67108863&o)+(67108863&t);t>>=26,t+=o/67108864|0,t+=i>>>26,this.words[n]=67108863&i}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,o=n%26;t[n]=(e.words[r]&1<<o)>>>o}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var o=n.sqr();r<t.length;r++,o=o.sqr())0!==t[r]&&(n=n.mul(o));return n},i.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,o=(e-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t<this.length;t++){var s=this.words[t]&i,c=(0|this.words[t])-s<<n;this.words[t]=c|a,a=s>>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this.strip()},i.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},i.prototype.iushrn=function(e,t,n){var o;r("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<<i,c=n;if(o-=a,o=Math.max(0,o),c){for(var u=0;u<a;u++)c.words[u]=this.words[u];c.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=o);u--){var d=0|this.words[u];this.words[u]=l<<26-i|d>>>i,l=d&s}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,o=1<<t;return!(this.length<=n)&&!!(this.words[n]&o)},i.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return this.strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,n){var o,i,a=e.length+n;this._expand(a);var s=0;for(o=0;o<e.length;o++){i=(0|this.words[o+n])+s;var c=(0|e.words[o])*t;s=((i-=67108863&c)>>26)-(c/67108864|0),this.words[o+n]=67108863&i}for(;o<this.length-n;o++)s=(i=(0|this.words[o+n])+s)>>26,this.words[o+n]=67108863&i;if(0===s)return this.strip();for(r(-1===s),s=0,o=0;o<this.length;o++)s=(i=-(0|this.words[o])+s)>>26,this.words[o]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,c=r.length-o.length;if("mod"!==t){(s=new i(null)).length=c+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=r.clone()._ishlnsubmul(o,1,c);0===l.negative&&(r=l,s&&(s.words[c]=1));for(var d=c-1;d>=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s.strip(),r.strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,o=this.length-1;o>=0;o--)n=(t*n+(0|this.words[o]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*t;this.words[n]=o/e|0,t=o%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),c=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;0==(t.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var h=0,y=1;0==(n.words[0]&y)&&h<26;++h,y<<=1);if(h>0)for(n.iushrn(h);h-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(l),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(c)):(n.isub(t),s.isub(o),c.isub(a))}return{a:s,b:c,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var d=0,f=1;0==(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,o=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=o,this;for(var i=o,a=n;0!==i&&a<this.length;a++){var s=0|this.words[a];i=(s+=i)>>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},i.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){r<o?t=-1:r>o&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new S(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},o(v,w),v.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o<r;o++)t.words[o]=e.words[o];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&n,o=10;o<e.length;o++){var a=0|e.words[o];e.words[o-10]=(a&n)<<4|i>>>22,i=a}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},o(m,w),o(I,w),o(E,w),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,o=67108863&r;r>>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new m;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return g[e]=t,t},S.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),c=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,o),f=this.pow(e,o.addn(1).iushrn(1)),p=this.pow(e,o),h=a;0!==p.cmp(s);){for(var y=p,b=0;0!==y.cmp(s);b++)y=y.redSqr();r(b<h);var g=this.pow(d,new i(1).iushln(h-b-1));f=f.redMul(g),d=g.redSqr(),p=p.redMul(d),h=b}return f},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new i(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var o=n[0],a=0,s=0,c=t.bitLength()%26;for(0===c&&(c=26),r=t.length-1;r>=0;r--){for(var u=t.words[r],l=c-1;l>=0;l--){var d=u>>l&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===l)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}c=26}return o},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)},o(O,S),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},9931:function(e,t,n){var r;function o(e){this.rand=e}if(e.exports=function(e){return r||(r=new o(null)),r.generate(e)},e.exports.Rand=o,o.prototype.generate=function(e){return this._rand(e)},o.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n<t.length;n++)t[n]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(o.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var i=n(9214);if("function"!=typeof i.randomBytes)throw new Error("Not supported");o.prototype._rand=function(e){return i.randomBytes(e)}}catch(a){}},7445:function(e,t){"use strict";function n(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function r(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function o(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){for(var r=0;r<t.length;++r)if(e===t[r])return e;var o="Expected ";1!==t.length&&(o+="one of: ");for(var i=0;i<t.length;++i)i>0&&(o+=" | "),o+=JSON.stringify(t[i]);throw o+=", got "+n(e),new TypeError(o)}}function i(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+n(e));return e}Object.defineProperty(t,"__esModule",{value:!0});var a=o(null),s=o(void 0);var c=r(a);function u(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function l(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+n(t));for(var r={},o=Object.keys(t),i=0;i<o.length;++i){var a=o[i];if("__proto__"!==a)try{r[a]=e(t[a])}catch(s){throw u(s,"["+JSON.stringify(a)+"]",0)}}return r};var t=Object.keys(e);function r(r){return function(o){if("object"!=typeof o||null==o)throw new TypeError("Expected an object, got "+n(o));var i,a={};if(r){var s=Object.keys(o);for(i=0;i<s.length;++i){var c=s[i];"__proto__"!==c&&(a[c]=o[c])}}for(i=0;i<t.length;++i){var l=t[i];try{a[l]=e[l](o[l])}catch(d){throw u(d,"."+l,0)}}return a}}var o=r(!1);return o.shape=e,o.withRest=r(!0),o}var d=l;function f(e,t){return function(n){return p[h]>0?t(n):e(n)}}var p="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,h="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",y=f((function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+n(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+n(e));return t}),(function(e){return e.toISOString()}));t.asArray=function(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+n(t));for(var r=[],o=0;o<t.length;++o)try{r[o]=e(t[o])}catch(i){throw u(i,"["+o+"]",0)}return r}},t.asBoolean=function(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+n(e));return e},t.asCodec=f,t.asDate=y,t.asEither=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}},t.asJSON=function(e){return f((function(t){var n=JSON.parse(i(t));try{return e(n)}catch(r){throw u(r,"JSON.parse()",11)}}),(function(t){return JSON.stringify(e(t))}))},t.asMap=d,t.asMaybe=function(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}},t.asNone=c,t.asNull=a,t.asNumber=function(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+n(e));return e},t.asObject=l,t.asOptional=r,t.asString=i,t.asTuple=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+n(e));for(var r=[],o=0;o<t.length;++o)try{r[o]=t[o](e[o])}catch(i){throw u(i,"["+o+"]")}return r}},t.asUndefined=s,t.asUnknown=function(e){return e},t.asValue=o,t.uncleaner=function(e){return function(t){null==p[h]&&Object.defineProperty(p,h,{value:0,writable:!0});try{return++p[h],e(t)}finally{--p[h]}}}},4098:function(e,t){var n="undefined"!=typeof self?self:this,r=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,a="ArrayBuffer"in e;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function h(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function y(e){var t=new FileReader,n=h(t);return t.readAsArrayBuffer(e),n}function b(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=b(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=b(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=h(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=u(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[u(e)]},f.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},f.prototype.set=function(e,t){this.map[u(e)]=l(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),d(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),d(e)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var n,r,o=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),w.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function m(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(o))}})),t}function I(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},g.call(v.prototype),g.call(I.prototype),I.prototype.clone=function(){return new I(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},I.error=function(){var e=new I(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];I.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new I(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(O){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,n){return new Promise((function(r,i){var a=new v(e,n);if(a.signal&&a.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();t.append(r,o)}})),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;r(new I(o,n))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),a.headers.forEach((function(e,t){s.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=f,e.Request=v,e.Response=I),t.Headers=f,t.Request=v,t.Response=I,t.fetch=S,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var o=r;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t},4550:function(e){e.exports=[{code:"AED",number:"784",digits:2,currency:"UAE Dirham",countries:["United Arab Emirates (The)"]},{code:"AFN",number:"971",digits:2,currency:"Afghani",countries:["Afghanistan"]},{code:"ALL",number:"008",digits:2,currency:"Lek",countries:["Albania"]},{code:"AMD",number:"051",digits:2,currency:"Armenian Dram",countries:["Armenia"]},{code:"ANG",number:"532",digits:2,currency:"Netherlands Antillean Guilder",countries:["CuraçAo","Sint Maarten (Dutch Part)"]},{code:"AOA",number:"973",digits:2,currency:"Kwanza",countries:["Angola"]},{code:"ARS",number:"032",digits:2,currency:"Argentine Peso",countries:["Argentina"]},{code:"AUD",number:"036",digits:2,currency:"Australian Dollar",countries:["Australia","Christmas Island","Cocos (Keeling) Islands (The)","Heard Island And Mcdonald Islands","Kiribati","Nauru","Norfolk Island","Tuvalu"]},{code:"AWG",number:"533",digits:2,currency:"Aruban Florin",countries:["Aruba"]},{code:"AZN",number:"944",digits:2,currency:"Azerbaijan Manat",countries:["Azerbaijan"]},{code:"BAM",number:"977",digits:2,currency:"Convertible Mark",countries:["Bosnia And Herzegovina"]},{code:"BBD",number:"052",digits:2,currency:"Barbados Dollar",countries:["Barbados"]},{code:"BDT",number:"050",digits:2,currency:"Taka",countries:["Bangladesh"]},{code:"BGN",number:"975",digits:2,currency:"Bulgarian Lev",countries:["Bulgaria"]},{code:"BHD",number:"048",digits:3,currency:"Bahraini Dinar",countries:["Bahrain"]},{code:"BIF",number:"108",digits:0,currency:"Burundi Franc",countries:["Burundi"]},{code:"BMD",number:"060",digits:2,currency:"Bermudian Dollar",countries:["Bermuda"]},{code:"BND",number:"096",digits:2,currency:"Brunei Dollar",countries:["Brunei Darussalam"]},{code:"BOB",number:"068",digits:2,currency:"Boliviano",countries:["Bolivia (Plurinational State Of)"]},{code:"BOV",number:"984",digits:2,currency:"Mvdol",countries:["Bolivia (Plurinational State Of)"]},{code:"BRL",number:"986",digits:2,currency:"Brazilian Real",countries:["Brazil"]},{code:"BSD",number:"044",digits:2,currency:"Bahamian Dollar",countries:["Bahamas (The)"]},{code:"BTN",number:"064",digits:2,currency:"Ngultrum",countries:["Bhutan"]},{code:"BWP",number:"072",digits:2,currency:"Pula",countries:["Botswana"]},{code:"BYN",number:"933",digits:2,currency:"Belarusian Ruble",countries:["Belarus"]},{code:"BZD",number:"084",digits:2,currency:"Belize Dollar",countries:["Belize"]},{code:"CAD",number:"124",digits:2,currency:"Canadian Dollar",countries:["Canada"]},{code:"CDF",number:"976",digits:2,currency:"Congolese Franc",countries:["Congo (The Democratic Republic Of The)"]},{code:"CHE",number:"947",digits:2,currency:"WIR Euro",countries:["Switzerland"]},{code:"CHF",number:"756",digits:2,currency:"Swiss Franc",countries:["Liechtenstein","Switzerland"]},{code:"CHW",number:"948",digits:2,currency:"WIR Franc",countries:["Switzerland"]},{code:"CLF",number:"990",digits:4,currency:"Unidad de Fomento",countries:["Chile"]},{code:"CLP",number:"152",digits:0,currency:"Chilean Peso",countries:["Chile"]},{code:"CNY",number:"156",digits:2,currency:"Yuan Renminbi",countries:["China"]},{code:"COP",number:"170",digits:2,currency:"Colombian Peso",countries:["Colombia"]},{code:"COU",number:"970",digits:2,currency:"Unidad de Valor Real",countries:["Colombia"]},{code:"CRC",number:"188",digits:2,currency:"Costa Rican Colon",countries:["Costa Rica"]},{code:"CUC",number:"931",digits:2,currency:"Peso Convertible",countries:["Cuba"]},{code:"CUP",number:"192",digits:2,currency:"Cuban Peso",countries:["Cuba"]},{code:"CVE",number:"132",digits:2,currency:"Cabo Verde Escudo",countries:["Cabo Verde"]},{code:"CZK",number:"203",digits:2,currency:"Czech Koruna",countries:["Czechia"]},{code:"DJF",number:"262",digits:0,currency:"Djibouti Franc",countries:["Djibouti"]},{code:"DKK",number:"208",digits:2,currency:"Danish Krone",countries:["Denmark","Faroe Islands (The)","Greenland"]},{code:"DOP",number:"214",digits:2,currency:"Dominican Peso",countries:["Dominican Republic (The)"]},{code:"DZD",number:"012",digits:2,currency:"Algerian Dinar",countries:["Algeria"]},{code:"EGP",number:"818",digits:2,currency:"Egyptian Pound",countries:["Egypt"]},{code:"ERN",number:"232",digits:2,currency:"Nakfa",countries:["Eritrea"]},{code:"ETB",number:"230",digits:2,currency:"Ethiopian Birr",countries:["Ethiopia"]},{code:"EUR",number:"978",digits:2,currency:"Euro",countries:["Andorra","Austria","Belgium","Cyprus","Estonia","European Union","Finland","France","French Guiana","French Southern Territories (The)","Germany","Greece","Guadeloupe","Holy See (The)","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Martinique","Mayotte","Monaco","Montenegro","Netherlands (The)","Portugal","Réunion","Saint Barthélemy","Saint Martin (French Part)","Saint Pierre And Miquelon","San Marino","Slovakia","Slovenia","Spain","Åland Islands"]},{code:"FJD",number:"242",digits:2,currency:"Fiji Dollar",countries:["Fiji"]},{code:"FKP",number:"238",digits:2,currency:"Falkland Islands Pound",countries:["Falkland Islands (The) [Malvinas]"]},{code:"GBP",number:"826",digits:2,currency:"Pound Sterling",countries:["Guernsey","Isle Of Man","Jersey","United Kingdom Of Great Britain And Northern Ireland (The)"]},{code:"GEL",number:"981",digits:2,currency:"Lari",countries:["Georgia"]},{code:"GHS",number:"936",digits:2,currency:"Ghana Cedi",countries:["Ghana"]},{code:"GIP",number:"292",digits:2,currency:"Gibraltar Pound",countries:["Gibraltar"]},{code:"GMD",number:"270",digits:2,currency:"Dalasi",countries:["Gambia (The)"]},{code:"GNF",number:"324",digits:0,currency:"Guinean Franc",countries:["Guinea"]},{code:"GTQ",number:"320",digits:2,currency:"Quetzal",countries:["Guatemala"]},{code:"GYD",number:"328",digits:2,currency:"Guyana Dollar",countries:["Guyana"]},{code:"HKD",number:"344",digits:2,currency:"Hong Kong Dollar",countries:["Hong Kong"]},{code:"HNL",number:"340",digits:2,currency:"Lempira",countries:["Honduras"]},{code:"HRK",number:"191",digits:2,currency:"Kuna",countries:["Croatia"]},{code:"HTG",number:"332",digits:2,currency:"Gourde",countries:["Haiti"]},{code:"HUF",number:"348",digits:2,currency:"Forint",countries:["Hungary"]},{code:"IDR",number:"360",digits:2,currency:"Rupiah",countries:["Indonesia"]},{code:"ILS",number:"376",digits:2,currency:"New Israeli Sheqel",countries:["Israel"]},{code:"INR",number:"356",digits:2,currency:"Indian Rupee",countries:["Bhutan","India"]},{code:"IQD",number:"368",digits:3,currency:"Iraqi Dinar",countries:["Iraq"]},{code:"IRR",number:"364",digits:2,currency:"Iranian Rial",countries:["Iran (Islamic Republic Of)"]},{code:"ISK",number:"352",digits:0,currency:"Iceland Krona",countries:["Iceland"]},{code:"JMD",number:"388",digits:2,currency:"Jamaican Dollar",countries:["Jamaica"]},{code:"JOD",number:"400",digits:3,currency:"Jordanian Dinar",countries:["Jordan"]},{code:"JPY",number:"392",digits:0,currency:"Yen",countries:["Japan"]},{code:"KES",number:"404",digits:2,currency:"Kenyan Shilling",countries:["Kenya"]},{code:"KGS",number:"417",digits:2,currency:"Som",countries:["Kyrgyzstan"]},{code:"KHR",number:"116",digits:2,currency:"Riel",countries:["Cambodia"]},{code:"KMF",number:"174",digits:0,currency:"Comorian Franc ",countries:["Comoros (The)"]},{code:"KPW",number:"408",digits:2,currency:"North Korean Won",countries:["Korea (The Democratic People's Republic Of)"]},{code:"KRW",number:"410",digits:0,currency:"Won",countries:["Korea (The Republic Of)"]},{code:"KWD",number:"414",digits:3,currency:"Kuwaiti Dinar",countries:["Kuwait"]},{code:"KYD",number:"136",digits:2,currency:"Cayman Islands Dollar",countries:["Cayman Islands (The)"]},{code:"KZT",number:"398",digits:2,currency:"Tenge",countries:["Kazakhstan"]},{code:"LAK",number:"418",digits:2,currency:"Lao Kip",countries:["Lao People's Democratic Republic (The)"]},{code:"LBP",number:"422",digits:2,currency:"Lebanese Pound",countries:["Lebanon"]},{code:"LKR",number:"144",digits:2,currency:"Sri Lanka Rupee",countries:["Sri Lanka"]},{code:"LRD",number:"430",digits:2,currency:"Liberian Dollar",countries:["Liberia"]},{code:"LSL",number:"426",digits:2,currency:"Loti",countries:["Lesotho"]},{code:"LYD",number:"434",digits:3,currency:"Libyan Dinar",countries:["Libya"]},{code:"MAD",number:"504",digits:2,currency:"Moroccan Dirham",countries:["Morocco","Western Sahara"]},{code:"MDL",number:"498",digits:2,currency:"Moldovan Leu",countries:["Moldova (The Republic Of)"]},{code:"MGA",number:"969",digits:2,currency:"Malagasy Ariary",countries:["Madagascar"]},{code:"MKD",number:"807",digits:2,currency:"Denar",countries:["Macedonia (The Former Yugoslav Republic Of)"]},{code:"MMK",number:"104",digits:2,currency:"Kyat",countries:["Myanmar"]},{code:"MNT",number:"496",digits:2,currency:"Tugrik",countries:["Mongolia"]},{code:"MOP",number:"446",digits:2,currency:"Pataca",countries:["Macao"]},{code:"MRU",number:"929",digits:2,currency:"Ouguiya",countries:["Mauritania"]},{code:"MUR",number:"480",digits:2,currency:"Mauritius Rupee",countries:["Mauritius"]},{code:"MVR",number:"462",digits:2,currency:"Rufiyaa",countries:["Maldives"]},{code:"MWK",number:"454",digits:2,currency:"Malawi Kwacha",countries:["Malawi"]},{code:"MXN",number:"484",digits:2,currency:"Mexican Peso",countries:["Mexico"]},{code:"MXV",number:"979",digits:2,currency:"Mexican Unidad de Inversion (UDI)",countries:["Mexico"]},{code:"MYR",number:"458",digits:2,currency:"Malaysian Ringgit",countries:["Malaysia"]},{code:"MZN",number:"943",digits:2,currency:"Mozambique Metical",countries:["Mozambique"]},{code:"NAD",number:"516",digits:2,currency:"Namibia Dollar",countries:["Namibia"]},{code:"NGN",number:"566",digits:2,currency:"Naira",countries:["Nigeria"]},{code:"NIO",number:"558",digits:2,currency:"Cordoba Oro",countries:["Nicaragua"]},{code:"NOK",number:"578",digits:2,currency:"Norwegian Krone",countries:["Bouvet Island","Norway","Svalbard And Jan Mayen"]},{code:"NPR",number:"524",digits:2,currency:"Nepalese Rupee",countries:["Nepal"]},{code:"NZD",number:"554",digits:2,currency:"New Zealand Dollar",countries:["Cook Islands (The)","New Zealand","Niue","Pitcairn","Tokelau"]},{code:"OMR",number:"512",digits:3,currency:"Rial Omani",countries:["Oman"]},{code:"PAB",number:"590",digits:2,currency:"Balboa",countries:["Panama"]},{code:"PEN",number:"604",digits:2,currency:"Sol",countries:["Peru"]},{code:"PGK",number:"598",digits:2,currency:"Kina",countries:["Papua New Guinea"]},{code:"PHP",number:"608",digits:2,currency:"Philippine Piso",countries:["Philippines (The)"]},{code:"PKR",number:"586",digits:2,currency:"Pakistan Rupee",countries:["Pakistan"]},{code:"PLN",number:"985",digits:2,currency:"Zloty",countries:["Poland"]},{code:"PYG",number:"600",digits:0,currency:"Guarani",countries:["Paraguay"]},{code:"QAR",number:"634",digits:2,currency:"Qatari Rial",countries:["Qatar"]},{code:"RON",number:"946",digits:2,currency:"Romanian Leu",countries:["Romania"]},{code:"RSD",number:"941",digits:2,currency:"Serbian Dinar",countries:["Serbia"]},{code:"RUB",number:"643",digits:2,currency:"Russian Ruble",countries:["Russian Federation (The)"]},{code:"RWF",number:"646",digits:0,currency:"Rwanda Franc",countries:["Rwanda"]},{code:"SAR",number:"682",digits:2,currency:"Saudi Riyal",countries:["Saudi Arabia"]},{code:"SBD",number:"090",digits:2,currency:"Solomon Islands Dollar",countries:["Solomon Islands"]},{code:"SCR",number:"690",digits:2,currency:"Seychelles Rupee",countries:["Seychelles"]},{code:"SDG",number:"938",digits:2,currency:"Sudanese Pound",countries:["Sudan (The)"]},{code:"SEK",number:"752",digits:2,currency:"Swedish Krona",countries:["Sweden"]},{code:"SGD",number:"702",digits:2,currency:"Singapore Dollar",countries:["Singapore"]},{code:"SHP",number:"654",digits:2,currency:"Saint Helena Pound",countries:["Saint Helena, Ascension And Tristan Da Cunha"]},{code:"SLL",number:"694",digits:2,currency:"Leone",countries:["Sierra Leone"]},{code:"SOS",number:"706",digits:2,currency:"Somali Shilling",countries:["Somalia"]},{code:"SRD",number:"968",digits:2,currency:"Surinam Dollar",countries:["Suriname"]},{code:"SSP",number:"728",digits:2,currency:"South Sudanese Pound",countries:["South Sudan"]},{code:"STN",number:"930",digits:2,currency:"Dobra",countries:["Sao Tome And Principe"]},{code:"SVC",number:"222",digits:2,currency:"El Salvador Colon",countries:["El Salvador"]},{code:"SYP",number:"760",digits:2,currency:"Syrian Pound",countries:["Syrian Arab Republic"]},{code:"SZL",number:"748",digits:2,currency:"Lilangeni",countries:["Swaziland"]},{code:"THB",number:"764",digits:2,currency:"Baht",countries:["Thailand"]},{code:"TJS",number:"972",digits:2,currency:"Somoni",countries:["Tajikistan"]},{code:"TMT",number:"934",digits:2,currency:"Turkmenistan New Manat",countries:["Turkmenistan"]},{code:"TND",number:"788",digits:3,currency:"Tunisian Dinar",countries:["Tunisia"]},{code:"TOP",number:"776",digits:2,currency:"Pa'anga",countries:["Tonga"]},{code:"TRY",number:"949",digits:2,currency:"Turkish Lira",countries:["Turkey"]},{code:"TTD",number:"780",digits:2,currency:"Trinidad and Tobago Dollar",countries:["Trinidad And Tobago"]},{code:"TWD",number:"901",digits:2,currency:"New Taiwan Dollar",countries:["Taiwan (Province Of China)"]},{code:"TZS",number:"834",digits:2,currency:"Tanzanian Shilling",countries:["Tanzania, United Republic Of"]},{code:"UAH",number:"980",digits:2,currency:"Hryvnia",countries:["Ukraine"]},{code:"UGX",number:"800",digits:0,currency:"Uganda Shilling",countries:["Uganda"]},{code:"USD",number:"840",digits:2,currency:"US Dollar",countries:["American Samoa","Bonaire, Sint Eustatius And Saba","British Indian Ocean Territory (The)","Ecuador","El Salvador","Guam","Haiti","Marshall Islands (The)","Micronesia (Federated States Of)","Northern Mariana Islands (The)","Palau","Panama","Puerto Rico","Timor-Leste","Turks And Caicos Islands (The)","United States Minor Outlying Islands (The)","United States Of America (The)","Virgin Islands (British)","Virgin Islands (U.S.)"]},{code:"USN",number:"997",digits:2,currency:"US Dollar (Next day)",countries:["United States Of America (The)"]},{code:"UYI",number:"940",digits:0,currency:"Uruguay Peso en Unidades Indexadas (URUIURUI)",countries:["Uruguay"]},{code:"UYU",number:"858",digits:2,currency:"Peso Uruguayo",countries:["Uruguay"]},{code:"UZS",number:"860",digits:2,currency:"Uzbekistan Sum",countries:["Uzbekistan"]},{code:"VEF",number:"937",digits:2,currency:"Bolívar",countries:["Venezuela (Bolivarian Republic Of)"]},{code:"VND",number:"704",digits:0,currency:"Dong",countries:["Viet Nam"]},{code:"VUV",number:"548",digits:0,currency:"Vatu",countries:["Vanuatu"]},{code:"WST",number:"882",digits:2,currency:"Tala",countries:["Samoa"]},{code:"XAF",number:"950",digits:0,currency:"CFA Franc BEAC",countries:["Cameroon","Central African Republic (The)","Chad","Congo (The)","Equatorial Guinea","Gabon"]},{code:"XAG",number:"961",digits:0,currency:"Silver",countries:[]},{code:"XAU",number:"959",digits:0,currency:"Gold",countries:[]},{code:"XBA",number:"955",digits:0,currency:"Bond Markets Unit European Composite Unit (EURCO)",countries:[]},{code:"XBB",number:"956",digits:0,currency:"Bond Markets Unit European Monetary Unit (E.M.U.-6)",countries:[]},{code:"XBC",number:"957",digits:0,currency:"Bond Markets Unit European Unit of Account 9 (E.U.A.-9)",countries:[]},{code:"XBD",number:"958",digits:0,currency:"Bond Markets Unit European Unit of Account 17 (E.U.A.-17)",countries:[]},{code:"XCD",number:"951",digits:2,currency:"East Caribbean Dollar",countries:["Anguilla","Antigua And Barbuda","Dominica","Grenada","Montserrat","Saint Kitts And Nevis","Saint Lucia","Saint Vincent And The Grenadines"]},{code:"XDR",number:"960",digits:0,currency:"SDR (Special Drawing Right)",countries:["International Monetary Fund (Imf) "]},{code:"XOF",number:"952",digits:0,currency:"CFA Franc BCEAO",countries:["Benin","Burkina Faso","Côte d'Ivoire","Guinea-Bissau","Mali","Niger (The)","Senegal","Togo"]},{code:"XPD",number:"964",digits:0,currency:"Palladium",countries:[]},{code:"XPF",number:"953",digits:0,currency:"CFP Franc",countries:["French Polynesia","New Caledonia","Wallis And Futuna"]},{code:"XPT",number:"962",digits:0,currency:"Platinum",countries:[]},{code:"XSU",number:"994",digits:0,currency:"Sucre",countries:['Sistema Unitario De Compensacion Regional De Pagos "Sucre"']},{code:"XTS",number:"963",digits:0,currency:"Codes specifically reserved for testing purposes",countries:[]},{code:"XUA",number:"965",digits:0,currency:"ADB Unit of Account",countries:["Member Countries Of The African Development Bank Group"]},{code:"XXX",number:"999",digits:0,currency:"The codes assigned for transactions where no currency is involved",countries:[]},{code:"YER",number:"886",digits:2,currency:"Yemeni Rial",countries:["Yemen"]},{code:"ZAR",number:"710",digits:2,currency:"Rand",countries:["Lesotho","Namibia","South Africa"]},{code:"ZMW",number:"967",digits:2,currency:"Zambian Kwacha",countries:["Zambia"]},{code:"ZWL",number:"932",digits:2,currency:"Zimbabwe Dollar",countries:["Zimbabwe"]}]},3546:function(e,t,n){var r=n(7680),o=n(2719),i=n(4550);t.Rx=function(e){return r(i,(function(t){return t.number===String(e)}))}},4638:function(e,t,n){"use strict";var r=n(5352);function o(e){throw new Error("makeNodeDisklet is not available on this platform")}function i(){throw new Error("makeReactNativeDisklet is not available on this platform")}function a(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){a(i,r,o,s,c,"next",e)}function c(e){a(i,r,o,s,c,"throw",e)}s(void 0)}))}}function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function u(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");for(var t=e.split("/"),n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}function l(e){return""===e?e:e+"/"}function d(e){for(var t=[],n=0;n<e.length;++n){var r=e.key(n);null!=r&&t.push(r)}return t}function f(e,t){void 0===e&&(e=window.localStorage),void 0===t&&(t={});var n=null!=t.prefix?l(t.prefix):"/";return{delete:function(t){var r=u(t);null!=e.getItem(n+r)&&e.removeItem(n+r);for(var o=l(r),i=0,a=d(e);i<a.length;i++){var s=a[i];0===s.indexOf(n+o)&&e.removeItem(s)}return Promise.resolve()},getData:function(e){return this.getText(e).then((function(e){return r.base64.parse(e)}))},getText:function(t){var r=u(t),o=e.getItem(n+r);return null==o?Promise.reject(new Error('Cannot load "'+r+'"')):Promise.resolve(o)},list:function(t){return s((function*(){void 0===t&&(t="");var r=u(t),o={};null!=e.getItem(n+r)&&(o[r]="file");for(var i=l(r),a=0,s=d(e);a<s.length;a++){var c=s[a];if(0===c.indexOf(n+i)){var f=c.indexOf("/",n.length+i.length);f<0?o[c.slice(n.length)]="file":o[c.slice(n.length,f)]="folder"}}return o}))()},setData:function(e,t){return this.setText(e,r.base64.stringify(t))},setText:function(t,r){return"string"!=typeof r?Promise.reject(new TypeError("setText expects a string")):(e.setItem(n+u(t),r),Promise.resolve())}}}function p(e){return void 0===e&&(e={}),{delete:function(t){var n=u(t);null!=e["/"+n]&&delete e["/"+n];for(var r=l(n),o=0,i=Object.keys(e);o<i.length;o++){var a=i[o];0===a.indexOf("/"+r)&&delete e[a]}return Promise.resolve()},getData:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"==typeof r?Promise.reject(new Error('"'+n+'" is a text file.')):Promise.resolve(r)},getText:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"!=typeof r?Promise.reject(new Error('"'+n+'" is a binary file.')):Promise.resolve(r)},list:function(t){return s((function*(){void 0===t&&(t="");var n=u(t),r={};null!=e["/"+n]&&(r[n]="file");for(var o=l(n),i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];if(0===s.indexOf("/"+o)){var c=s.indexOf("/",1+o.length);c<0?r[s.slice(1)]="file":r[s.slice(1,c)]="folder"}}return r}))()},setData:function(t,n){var r=n,o=Uint8Array.from(r);return e["/"+u(t)]=o,Promise.resolve()},setText:function(t,n){return"string"!=typeof n?Promise.reject(new TypeError("setText expects a string")):(e["/"+u(t)]=n,Promise.resolve())}}}var h=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.getData=function(){return this._disklet.getData(this._path)},t.getText=function(){return this._disklet.getText(this._path)},t.setData=function(e){return this._disklet.setData(this._path,e)},t.setText=function(e){return this._disklet.setText(this._path,e)},e}(),y=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.file=function(e){return new h(this._disklet,this._path+"/"+e)},t.folder=function(t){return new e(this._disklet,this._path+"/"+t)},t.listFiles=function(){return this._disklet.list(this._path).then((function(e){return Object.keys(e).filter((function(t){return"file"===e[t]})).map((function(e){return e.replace(/^.*\//,"")}))}))},t.listFolders=function(){return this._disklet.list(this._path).then((function(e){return Object.keys(e).filter((function(t){return"folder"===e[t]})).map((function(e){return e.replace(/^.*\//,"")}))}))},e}();function b(e){return new y(e,".")}function g(e,t){for(var n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}for(n=0;n<r;++n)e=e.folder(t[n]);return e}function w(e,t){return e.listFiles().then((function(n){return Promise.all(n.map((function(n){return t(e.file(n),n,e)})))}))}function v(e,t){return e.listFolders().then((function(n){return Promise.all(n.map((function(n){return t(e.folder(n),n,e)})))}))}function m(e,t){console.log(t+' "'+e+'"')}function I(e,t,n){var r=n.callback,o=void 0===r?m:r,i=n.verbose;(void 0!==i&&i||/set|delete/.test(t))&&o(e,t)}var E=function(){function e(e,t,n){this._file=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete file",this._opts),this._file.delete()},t.getData=function(){return I(this._path,"get data",this._opts),this._file.getData()},t.getText=function(){return I(this._path,"get text",this._opts),this._file.getText()},t.setData=function(e){return I(this._path,"set data",this._opts),this._file.setData(e)},t.setText=function(e){return I(this._path,"set text",this._opts),this._file.setText(e)},t.getPath=function(){return this._path},e}(),S=function(){function e(e,t,n){this._folder=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete folder",this._opts),this._folder.delete()},t.file=function(e){return new E(this._folder.file(e),this._path+e,this._opts)},t.folder=function(t){return new e(this._folder.folder(t),this._path+t+"/",this._opts)},t.listFiles=function(){return I(this._path,"list files",this._opts),this._folder.listFiles()},t.listFolders=function(){return I(this._path,"list folders",this._opts),this._folder.listFolders()},e}();function O(e,t){var n={},r=[];return e.forEach((function(e){/\._x_$/.test(e)?n[e]=!0:(n[e+"._x_"]=!0,r.push(e))})),t.forEach((function(e){n[e+"._x_"]||r.push(e)})),r}var A=function(){function e(e,t,n){this._master=e,this._fallback=t,this._whiteout=n}var t=e.prototype;return t.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch((function(e){return null}))])},t.getData=function(){var e=this;return this._master.getData().catch((function(t){return e._whiteout.getData().then((function(e){throw new Error("File has been deleted")}),(function(t){return e._fallback.getData()}))}))},t.getText=function(){var e=this;return this._master.getText().catch((function(t){return e._whiteout.getData().then((function(e){throw new Error("File has been deleted")}),(function(t){return e._fallback.getText()}))}))},t.setData=function(e){return this._master.setData(e)},t.setText=function(e){return this._master.setText(e)},t.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},e}(),T=function(){function e(e,t){this._master=e,this._fallback=t}var t=e.prototype;return t.delete=function(){return Promise.all([w(this,(function(e){return e.delete()})),v(this,(function(e){return e.delete()}))]).then((function(){}))},t.file=function(e){return new A(this._master.file(e),this._fallback.file(e),this._master.file(e+"._x_"))},t.folder=function(t){return new e(this._master.folder(t),this._fallback.folder(t))},t.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then((function(e){return O(e[0],e[1])}))},t.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then((function(e){return O(e[0],e[1])}))},e}();function _(e,t){var n=l(u(t));return{delete:function(t){return e.delete(n+t)},getData:function(t){return e.getData(n+t)},getText:function(t){return e.getText(n+t)},list:function(t){return void 0===t&&(t="."),e.list(n+t).then((function(e){var t={};for(var r in e)t[r.replace(n,"")]=e[r];return t}))},setData:function(t,r){return e.setData(n+t,r)},setText:function(t,r){return e.setText(n+t,r)}}}t.gQ=function(e){return Object.keys(e).filter((function(t){return"file"===e[t]}))},t.ji=function(e){return Object.keys(e).filter((function(t){return"folder"===e[t]}))},t.Wh=p,t.Cl=function(e,t){return{delete:function(n){return Promise.all([e.delete(n),t.delete(n)])},getData:function(n){return e.getData(n).catch((function(e){return t.getData(n)}))},getText:function(n){return e.getText(n).catch((function(e){return t.getText(n)}))},list:function(n){return Promise.all([e.list(n),t.list(n)]).then((function(e){var t=e[0];return c(e[1],t)}))},setData:function(t,n){return e.setData(t,n)},setText:function(t,n){return e.setText(t,n)}}},t.HN=_},1649:function(e,t,n){"use strict";var r=n(7445),o=n(4098),i=n(1223),a=n(3715),s=n(5352);function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o),l=c(i),d=c(a);const f=/^[a-z0-9-_.]+(\/+[a-z0-9-_.]+)*$/i,p=/^[a-f0-9]{40}$/,h=r.asObject({infoServers:r.asOptional(r.asArray(r.asString)),syncServers:r.asOptional(r.asArray(r.asString))}),y=e=>{const t=r.asString(e);if(""===t)throw new TypeError("Expected non empty string");return t},b=e=>{const t=r.asString(e);if(!p.test(t))throw new TypeError(`Invalid sync key '${t}'`);return t},g=r.asObject({iv_hex:r.asString,encryptionType:r.asNumber,data_base64:r.asString}),w=r.asObject({success:r.asValue(!1),message:r.asString,stack:r.asOptional(r.asString)}),v=r.asEither(g,r.asNull),m=r.asObject(v),I=r.asObject({syncKey:b,hash:r.asOptional(y)}),E=r.asObject({hash:r.asOptional(r.asString),changes:m}),S=r.asObject({syncKey:b,hash:r.asOptional(y)}),O=r.asObject({changes:m}),A=r.asObject({hash:r.asString,changes:m}),T=r.asObject({syncKey:b}),_=r.asUndefined,k=()=>{};async function x(e,t,n={}){const{log:o=k,fetch:i=u.default}=n,{method:a,url:s,body:c,numbUrl:l=s,headers:d={}}=e,f=Date.now(),p=await i(s,{method:a,headers:{"Content-Type":"application/json",...d},body:JSON.stringify(c)}),h=Date.now()-f;o(`${a} ${l} returned ${p.status} in ${h}ms`);const y=await p.text();if(!p.ok)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${y}`);const b=r.asMaybe(w)(y);if(null!=b)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${b.message}`);return t(""!==y.trim()?JSON.parse(y):void 0)}const P=l.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),M=e=>{const t=C(C(s.base16.parse(e)));return P.encode(t)};function C(e){const t=d.default.sha256();return Uint8Array.from(t.update(e).digest())}class N extends Error{constructor(e="Cannot reach the network"){super(e),this.name="NetworkError"}}const j={infoServers:["https://info-eu1.edge.app","https://info-us1.edge.app"],syncServers:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]};function D(e={}){const{log:t=(()=>{})}=e,n={...j,...e.edgeServers},{edgeServersCacheTTL:r=6e5}=e,o=function(e,t){let n=Date.now()+t,r=e(void 0);return{get:()=>{if(Date.now()>n||null==r){n=Date.now()+t;const o=e(r);r=o}return r}}}(((r={current:n})=>(r.current.infoServers.length>0&&async function(e,t={}){const{log:n=k,fetch:r=u.default}=t;let o=new Error("No info servers");for(const a of e){const[e,t]=["GET","/v1/edgeServers"],s=Date.now(),c=`${a}${t}`;try{const t=await r(c,{method:e,headers:{"Content-Type":"application/json"}}).catch((t=>{const r=Date.now()-s,o=`${e} ${c} failed in ${r}ms, ${String(t)}`;throw n(o),new N(o)})),{ok:o,status:i}=t,a=Date.now()-s,u=`${e} ${c} returned ${i} in ${a}ms`;if(!o)throw n(u),new N(u);n(u);const l=await t.text(),d=JSON.parse(l);return h(d)}catch(i){o=i;continue}}throw o}(r.current.infoServers,e).then((e=>{return r.current={...r.current,...e,infoServers:(t=e.infoServers,n=()=>j.infoServers,null!=t?t:n())};var t,n})).catch((async e=>{t(String(e))})),r)),r);return{async getEdgeServers(){const{current:e}=await o.get();return e}}}function R(e,t){return null!=e?e:t()}t.bS=m,t.Ei=g,t.h8=h,t.wJ=v,t.PG=I,t.SR=E,t.Th=y,t.Qw=e=>{const t=r.asString(e);try{if(f.test(t))return function(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder");if(0===r&&n===t.length)throw new Error("Path would evaluate to empty file name")}return t.slice(0,r).join("/")}(t)}catch(n){}throw new Error(`Invalid path '${t}'`)},t.YK=O,t.KI=S,t.Wn=A,t.tp=T,t.RQ=_,t.tE=w,t.Jj=b,t.LZ=function(e={}){const t=D(e);async function n(){const{syncServers:e}=await t.getEdgeServers();return function(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}(e)}return{async createRepo(t,r){const o=await n();let i=new Error(`Failed to create repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"PUT",url:o,numbUrl:s,headers:null!=r?{"X-API-Key":r}:{}},_,e)}catch(a){i=a}}throw i},async readRepo(t,r){const o=await n();let i=new Error(`Failed to read repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}/${R(r,(()=>""))}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"GET",url:o,numbUrl:s},E,e)}catch(a){i=a}}throw i},async updateRepo(t,r,o){const i=await n();let a=new Error(`Failed to update repo ${t}: empty sync server list`);for(const n of i){const i=`${n}/api/v2/store/${t}/${R(r,(()=>""))}`,c=i.replace(t,`<${M(t)}>`);try{return await x({method:"POST",url:i,numbUrl:c,body:o},A,e)}catch(s){a=s}}throw a}}},t.m8=M},1223:function(e){e.exports=function(e){for(var t={},n=e.length,r=e.charAt(0),o=0;o<e.length;o++)t[e.charAt(o)]=o;function i(e){if(0===e.length)return[];for(var o=[0],i=0;i<e.length;i++){var a=t[e[i]];if(void 0===a)return;for(var s=0,c=a;s<o.length;++s)c+=o[s]*n,o[s]=255&c,c>>=8;for(;c>0;)o.push(255&c),c>>=8}for(var u=0;e[u]===r&&u<e.length-1;++u)o.push(0);return o.reverse()}return{encode:function(t){if(0===t.length)return"";for(var r=[0],o=0;o<t.length;++o){for(var i=0,a=t[o];i<r.length;++i)a+=r[i]<<8,r[i]=a%n,a=a/n|0;for(;a>0;)r.push(a%n),a=a/n|0}for(var s="",c=0;0===t[c]&&c<t.length-1;++c)s+=e[0];for(var u=r.length-1;u>=0;--u)s+=e[r[u]];return s},decodeUnsafe:i,decode:function(e){var t=i(e);if(t)return t;throw new Error("Non-base"+n+" character")}}}},6266:function(e,t,n){"use strict";var r=t;r.version=n(8597).i8,r.utils=n(953),r.rand=n(9931),r.curve=n(8254),r.curves=n(5427),r.ec=n(7954),r.eddsa=n(5980)},4918:function(e,t,n){"use strict";var r=n(3550),o=n(953),i=o.getNAF,a=o.getJSF,s=o.assert;function c(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){s(e.precomputed);var n=e._getDoubles(),r=i(t,1,this._bitLength),o=(1<<n.step+1)-(n.step%2==0?2:1);o/=3;var a,c,u=[];for(a=0;a<r.length;a+=n.step){c=0;for(var l=a+n.step-1;l>=a;l--)c=(c<<1)+r[l];u.push(c)}for(var d=this.jpoint(null,null,null),f=this.jpoint(null,null,null),p=o;p>0;p--){for(a=0;a<u.length;a++)(c=u[a])===p?f=f.mixedAdd(n.points[a]):c===-p&&(f=f.mixedAdd(n.points[a].neg()));d=d.add(f)}return d.toP()},c.prototype._wnafMul=function(e,t){var n=4,r=e._getNAFPoints(n);n=r.wnd;for(var o=r.points,a=i(t,n,this._bitLength),c=this.jpoint(null,null,null),u=a.length-1;u>=0;u--){for(var l=0;u>=0&&0===a[u];u--)l++;if(u>=0&&l++,c=c.dblp(l),u<0)break;var d=a[u];s(0!==d),c="affine"===e.type?d>0?c.mixedAdd(o[d-1>>1]):c.mixedAdd(o[-d-1>>1].neg()):d>0?c.add(o[d-1>>1]):c.add(o[-d-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,n,r,o){var s,c,u,l=this._wnafT1,d=this._wnafT2,f=this._wnafT3,p=0;for(s=0;s<r;s++){var h=(u=t[s])._getNAFPoints(e);l[s]=h.wnd,d[s]=h.points}for(s=r-1;s>=1;s-=2){var y=s-1,b=s;if(1===l[y]&&1===l[b]){var g=[t[y],null,null,t[b]];0===t[y].y.cmp(t[b].y)?(g[1]=t[y].add(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg())):0===t[y].y.cmp(t[b].y.redNeg())?(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].add(t[b].neg())):(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg()));var w=[-3,-1,-5,-7,0,7,5,1,3],v=a(n[y],n[b]);for(p=Math.max(v[0].length,p),f[y]=new Array(p),f[b]=new Array(p),c=0;c<p;c++){var m=0|v[0][c],I=0|v[1][c];f[y][c]=w[3*(m+1)+(I+1)],f[b][c]=0,d[y]=g}}else f[y]=i(n[y],l[y],this._bitLength),f[b]=i(n[b],l[b],this._bitLength),p=Math.max(f[y].length,p),p=Math.max(f[b].length,p)}var E=this.jpoint(null,null,null),S=this._wnafT4;for(s=p;s>=0;s--){for(var O=0;s>=0;){var A=!0;for(c=0;c<r;c++)S[c]=0|f[c][s],0!==S[c]&&(A=!1);if(!A)break;O++,s--}if(s>=0&&O++,E=E.dblp(O),s<0)break;for(c=0;c<r;c++){var T=S[c];0!==T&&(T>0?u=d[c][T-1>>1]:T<0&&(u=d[c][-T-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(s=0;s<r;s++)d[s]=null;return o?E:E.toP()},c.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(e,t){e=o.toArray(e,t);var n=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*n)return 6===e[0]?s(e[e.length-1]%2==0):7===e[0]&&s(e[e.length-1]%2==1),this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));if((2===e[0]||3===e[0])&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),3===e[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(e){return this.encode(e,!0)},u.prototype._encode=function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},u.prototype.encode=function(e,t){return o.encode(this._encode(t),e)},u.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},u.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,o=0;o<t;o+=e){for(var i=0;i<e;i++)r=r.dbl();n.push(r)}return{step:e,points:n}},u.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,r=1===n?null:this.dbl(),o=1;o<n;o++)t[o]=t[o-1].add(r);return{wnd:e,points:t}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t}},1138:function(e,t,n){"use strict";var r=n(953),o=n(3550),i=n(5717),a=n(4918),s=r.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}i(c,a),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),i=this.one.redSub(this.c2.redMul(this.d).redMul(n)),a=r.redMul(i.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var c=s.fromRed().isOdd();return(t&&!c||!t&&c)&&(s=s.redNeg()),this.point(e,s)},c.prototype.pointFromY=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),i=n.redMul(this.d).redMul(this.c2).redSub(this.a),a=r.redMul(i.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),o=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(o)},i(u,a.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,n,r){return new u(this,e,t,n,r)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),i=r.redAdd(t),a=i.redSub(n),s=r.redSub(t),c=o.redMul(a),u=i.redMul(s),l=o.redMul(s),d=a.redMul(i);return this.curve.point(c,u,d,l)},u.prototype._projDbl=function(){var e,t,n,r,o,i,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(s)).redAdd(c);this.zOne?(e=a.redSub(s).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(r.redSub(c)),n=u.redSqr().redSub(u).redSub(u)):(o=this.z.redSqr(),i=u.redSub(o).redISub(o),e=a.redSub(s).redISub(c).redMul(i),t=u.redMul(r.redSub(c)),n=u.redMul(i))}else r=s.redAdd(c),o=this.curve._mulC(this.z).redSqr(),i=r.redSub(o).redSub(o),e=this.curve._mulC(a.redISub(r)).redMul(i),t=this.curve._mulC(r).redMul(s.redISub(c)),n=r.redMul(i);return this.curve.point(e,t,n)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),i=n.redSub(t),a=o.redSub(r),s=o.redAdd(r),c=n.redAdd(t),u=i.redMul(a),l=s.redMul(c),d=i.redMul(c),f=a.redMul(s);return this.curve.point(u,l,f,d)},u.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),o=r.redSqr(),i=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(i).redMul(a),c=o.redSub(s),u=o.redAdd(s),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(a),d=r.redMul(c).redMul(l);return this.curve.twisted?(t=r.redMul(u).redMul(a.redSub(this.curve._mulA(i))),n=c.redMul(u)):(t=r.redMul(u).redMul(a.redSub(i)),n=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,n)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},u.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},8254:function(e,t,n){"use strict";var r=t;r.base=n(4918),r.short=n(6673),r.mont=n(2881),r.edwards=n(1138)},2881:function(e,t,n){"use strict";var r=n(3550),o=n(5717),i=n(4918),a=n(953);function s(e){i.call(this,"mont",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){i.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(t,16),this.z=new r(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(s,i),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},o(c,i.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new c(this,e,t)},s.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),o=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,o)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),o=e.x.redAdd(e.z),i=e.x.redSub(e.z).redMul(n),a=o.redMul(r),s=t.z.redMul(i.redAdd(a).redSqr()),c=t.x.redMul(i.redISub(a).redSqr());return this.curve.point(s,c)},c.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),o=[];0!==t.cmpn(0);t.iushrn(1))o.push(t.andln(1));for(var i=o.length-1;i>=0;i--)0===o[i]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},6673:function(e,t,n){"use strict";var r=n(953),o=n(3550),i=n(5717),a=n(4918),s=r.assert;function c(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,n,r){a.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function l(e,t,n,r){a.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(n,16),this.z=new o(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}i(c,a),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);t=(t=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(e.lambda)n=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?n=i[0]:(n=i[1],s(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:n,basis:e.basis?e.basis.map((function(e){return{a:new o(e.a,16),b:new o(e.b,16)}})):this._getEndoBasis(n)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),n=new o(2).toRed(t).redInvm(),r=n.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(n);return[r.redAdd(i).fromRed(),r.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,n,r,i,a,s,c,u,l,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,p=this.n.clone(),h=new o(1),y=new o(0),b=new o(0),g=new o(1),w=0;0!==f.cmpn(0);){var v=p.div(f);u=p.sub(v.mul(f)),l=b.sub(v.mul(h));var m=g.sub(v.mul(y));if(!r&&u.cmp(d)<0)t=c.neg(),n=h,r=u.neg(),i=l;else if(r&&2==++w)break;c=u,p=f,f=u,b=h,h=l,g=y,y=m}a=u.neg(),s=l;var I=r.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(I)>=0&&(a=t,s=n),r.negative&&(r=r.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:r,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],o=r.b.mul(e).divRound(this.n),i=n.b.neg().mul(e).divRound(this.n),a=o.mul(n.a),s=i.mul(r.a),c=o.mul(n.b),u=i.mul(r.b);return{k1:e.sub(a).sub(s),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var i=r.fromRed().isOdd();return(t&&!i||!t&&i)&&(r=r.redNeg()),this.point(e,r)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),o=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(o).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,o=this._endoWnafT2,i=0;i<e.length;i++){var a=this._endoSplit(t[i]),s=e[i],c=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),c=c.neg(!0)),r[2*i]=s,r[2*i+1]=c,o[2*i]=a.k1,o[2*i+1]=a.k2}for(var u=this._wnafMulAdd(1,r,o,2*i,n),l=0;l<2*i;l++)r[l]=null,o[l]=null;return u},i(u,a.BasePoint),c.prototype.point=function(e,t,n){return new u(this,e,t,n)},c.prototype.pointFromJSON=function(e,t){return u.fromJSON(this,e,t)},u.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,r=function(e){return n.point(e.x.redMul(n.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(r)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(r)}}}return t}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(e,t,n){"string"==typeof t&&(t=JSON.parse(t));var r=e.point(t[0],t[1],n);if(!t[2])return r;function o(t){return e.point(t[0],t[1],n)}var i=t[2];return r.precomputed={beta:null,doubles:i.doubles&&{step:i.doubles.step,points:[r].concat(i.doubles.points.map(o))},naf:i.naf&&{wnd:i.naf.wnd,points:[r].concat(i.naf.points.map(o))}},r},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),r=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),i=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,a)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new o(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o):this.curve._wnafMulAdd(1,r,o,2)},u.prototype.jmulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o,!0):this.curve._wnafMulAdd(1,r,o,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},i(l,a.BasePoint),c.prototype.jpoint=function(e,t,n){return new l(this,e,t,n)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),o=e.x.redMul(n),i=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=r.redSub(o),c=i.redSub(a);if(0===s.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),d=r.redMul(u),f=c.redSqr().redIAdd(l).redISub(d).redISub(d),p=c.redMul(d.redISub(f)).redISub(i.redMul(l)),h=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(f,p,h)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),o=this.y,i=e.y.redMul(t).redMul(this.z),a=n.redSub(r),s=o.redSub(i);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),u=c.redMul(a),l=n.redMul(c),d=s.redSqr().redIAdd(u).redISub(l).redISub(l),f=s.redMul(l.redISub(d)).redISub(o.redMul(u)),p=this.z.redMul(a);return this.curve.jpoint(d,f,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t<e;t++)n=n.dbl();return n}var r=this.curve.a,o=this.curve.tinv,i=this.x,a=this.y,s=this.z,c=s.redSqr().redSqr(),u=a.redAdd(a);for(t=0;t<e;t++){var l=i.redSqr(),d=u.redSqr(),f=d.redSqr(),p=l.redAdd(l).redIAdd(l).redIAdd(r.redMul(c)),h=i.redMul(d),y=p.redSqr().redISub(h.redAdd(h)),b=h.redISub(y),g=p.redMul(b);g=g.redIAdd(g).redISub(f);var w=u.redMul(s);t+1<e&&(c=c.redMul(f)),i=y,s=w,u=g}return this.curve.jpoint(i,u.redMul(o),s)},l.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},l.prototype._zeroDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r),c=s.redSqr().redISub(a).redISub(a),u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),e=c,t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),d=this.y.redSqr(),f=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(l).redISub(f);p=p.redIAdd(p);var h=l.redAdd(l).redIAdd(l),y=h.redSqr(),b=f.redIAdd(f);b=(b=b.redIAdd(b)).redIAdd(b),e=y.redISub(p).redISub(p),t=h.redMul(p.redISub(e)).redISub(b),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(e,t,n)},l.prototype._threeDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),c=s.redSqr().redISub(a).redISub(a);e=c;var u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),d=this.y.redSqr(),f=this.x.redMul(d),p=this.x.redSub(l).redMul(this.x.redAdd(l));p=p.redAdd(p).redIAdd(p);var h=f.redIAdd(f),y=(h=h.redIAdd(h)).redAdd(h);e=p.redSqr().redISub(y),n=this.y.redAdd(this.z).redSqr().redISub(d).redISub(l);var b=d.redSqr();b=(b=(b=b.redIAdd(b)).redIAdd(b)).redIAdd(b),t=p.redMul(h.redISub(e)).redISub(b)}return this.curve.jpoint(e,t,n)},l.prototype._dbl=function(){var e=this.curve.a,t=this.x,n=this.y,r=this.z,o=r.redSqr().redSqr(),i=t.redSqr(),a=n.redSqr(),s=i.redAdd(i).redIAdd(i).redIAdd(e.redMul(o)),c=t.redAdd(t),u=(c=c.redIAdd(c)).redMul(a),l=s.redSqr().redISub(u.redAdd(u)),d=u.redISub(l),f=a.redSqr();f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=s.redMul(d).redISub(f),h=n.redAdd(n).redMul(r);return this.curve.jpoint(l,p,h)},l.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),r=t.redSqr(),o=e.redAdd(e).redIAdd(e),i=o.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(r),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(i)).redSqr(),c=r.redIAdd(r);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var u=o.redIAdd(a).redSqr().redISub(i).redISub(s).redISub(c),l=t.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var d=this.x.redMul(s).redISub(l);d=(d=d.redIAdd(d)).redIAdd(d);var f=this.y.redMul(u.redMul(c.redISub(u)).redISub(a.redMul(s)));f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=this.z.redAdd(a).redSqr().redISub(n).redISub(s);return this.curve.jpoint(d,f,p)},l.prototype.mul=function(e,t){return e=new o(e,t),this.curve._wnafMul(this,e)},l.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(0!==this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0))return!1;var r=t.redMul(this.z),o=n.redMul(e.z);return 0===this.y.redMul(o).redISub(e.y.redMul(r)).cmpn(0)},l.prototype.eqXToP=function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(n))return!0;for(var r=e.clone(),o=this.curve.redN.redMul(t);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),0===this.x.cmp(n))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},5427:function(e,t,n){"use strict";var r,o=t,i=n(3715),a=n(8254),s=n(953).assert;function c(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get:function(){var n=new c(t);return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:n}),n}})}o.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:i.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:i.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=n(1037)}catch(l){r=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},7954:function(e,t,n){"use strict";var r=n(3550),o=n(2156),i=n(953),a=n(5427),s=n(9931),c=i.assert,u=n(1251),l=n(611);function d(e){if(!(this instanceof d))return new d(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=d,d.prototype.keyPair=function(e){return new u(this,e)},d.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},d.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},d.prototype.genKeyPair=function(e){e||(e={});for(var t=new o({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new r(2));;){var a=new r(t.generate(n));if(!(a.cmp(i)>0))return a.iaddn(1),this.keyFromPrivate(a)}},d.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,n,i){"object"==typeof n&&(i=n,n=null),i||(i={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new r(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),u=new o({hash:this.hash,entropy:s,nonce:c,pers:i.pers,persEnc:i.persEnc||"utf8"}),d=this.n.sub(new r(1)),f=0;;f++){var p=i.k?i.k(f):new r(u.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(d)>=0)){var h=this.g.mul(p);if(!h.isInfinity()){var y=h.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var g=p.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var w=(h.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return i.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),w^=1),new l({r:b,s:g,recoveryParam:w})}}}}}},d.prototype.verify=function(e,t,n,o){e=this._truncateToN(new r(e,16)),n=this.keyFromPublic(n,o);var i=(t=new l(t,"hex")).r,a=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),u=c.mul(e).umod(this.n),d=c.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(u,n.getPublic(),d)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(u,n.getPublic(),d)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},d.prototype.recoverPubKey=function(e,t,n,o){c((3&n)===n,"The recovery param is more than two bits"),t=new l(t,o);var i=this.n,a=new r(e),s=t.r,u=t.s,d=1&n,f=n>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");s=f?this.curve.pointFromX(s.add(this.curve.n),d):this.curve.pointFromX(s,d);var p=t.r.invm(i),h=i.sub(a).mul(p).umod(i),y=u.mul(p).umod(i);return this.g.mulAdd(h,s,y)},d.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new l(t,r)).recoveryParam)return t.recoveryParam;for(var o=0;o<4;o++){var i;try{i=this.recoverPubKey(e,t,o)}catch(e){continue}if(i.eq(n))return o}throw new Error("Unable to find valid recovery factor")}},1251:function(e,t,n){"use strict";var r=n(3550),o=n(953).assert;function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=i,i.fromPublic=function(e,t,n){return t instanceof i?t:new i(e,{pub:t,pubEnc:n})},i.fromPrivate=function(e,t,n){return t instanceof i?t:new i(e,{priv:t,privEnc:n})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new r(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?o(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||o(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},i.prototype.derive=function(e){return e.validate()||o(e.validate(),"public point not validated"),e.mul(this.priv).getX()},i.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},611:function(e,t,n){"use strict";var r=n(3550),o=n(953),i=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(i(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function c(e,t){var n=e[t.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var o=0,i=0,a=t.place;i<r;i++,a++)o<<=8,o|=e[a],o>>>=0;return!(o<=127)&&(t.place=a,o)}function u(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t<n;)t++;return 0===t?e:e.slice(t)}function l(e,t){if(t<128)e.push(t);else{var n=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=o.toArray(e,t);var n=new s;if(48!==e[n.place++])return!1;var i=c(e,n);if(!1===i)return!1;if(i+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var a=c(e,n);if(!1===a)return!1;var u=e.slice(n.place,a+n.place);if(n.place+=a,2!==e[n.place++])return!1;var l=c(e,n);if(!1===l)return!1;if(e.length!==l+n.place)return!1;var d=e.slice(n.place,l+n.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new r(u),this.s=new r(d),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=u(t),n=u(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];l(r,t.length),(r=r.concat(t)).push(2),l(r,n.length);var i=r.concat(n),a=[48];return l(a,i.length),a=a.concat(i),o.encode(a,e)}},5980:function(e,t,n){"use strict";var r=n(3715),o=n(5427),i=n(953),a=i.assert,s=i.parseBytes,c=n(9087),u=n(3622);function l(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=o[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=l,l.prototype.sign=function(e,t){e=s(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),o=this.g.mul(r),i=this.encodePoint(o),a=this.hashInt(i,n.pubBytes(),e).mul(n.priv()),c=r.add(a).umod(this.curve.n);return this.makeSignature({R:o,S:c,Rencoded:i})},l.prototype.verify=function(e,t,n){e=s(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),o=this.hashInt(t.Rencoded(),r.pubBytes(),e),i=this.g.mul(t.S());return t.R().add(r.pub().mul(o)).eq(i)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return i.intFromLE(e.digest()).umod(this.curve.n)},l.prototype.keyFromPublic=function(e){return c.fromPublic(this,e)},l.prototype.keyFromSecret=function(e){return c.fromSecret(this,e)},l.prototype.makeSignature=function(e){return e instanceof u?e:new u(this,e)},l.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},l.prototype.decodePoint=function(e){var t=(e=i.parseBytes(e)).length-1,n=e.slice(0,t).concat(-129&e[t]),r=0!=(128&e[t]),o=i.intFromLE(n);return this.curve.pointFromY(o,r)},l.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},l.prototype.decodeInt=function(e){return i.intFromLE(e)},l.prototype.isPoint=function(e){return e instanceof this.pointClass}},9087:function(e,t,n){"use strict";var r=n(953),o=r.assert,i=r.parseBytes,a=r.cachedProperty;function s(e,t){this.eddsa=e,this._secret=i(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=i(t.pub)}s.fromPublic=function(e,t){return t instanceof s?t:new s(e,{pub:t})},s.fromSecret=function(e,t){return t instanceof s?t:new s(e,{secret:t})},s.prototype.secret=function(){return this._secret},a(s,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),a(s,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),a(s,"privBytes",(function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r})),a(s,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),a(s,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),a(s,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),s.prototype.sign=function(e){return o(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},s.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},s.prototype.getSecret=function(e){return o(this._secret,"KeyPair is public only"),r.encode(this.secret(),e)},s.prototype.getPublic=function(e){return r.encode(this.pubBytes(),e)},e.exports=s},3622:function(e,t,n){"use strict";var r=n(3550),o=n(953),i=o.assert,a=o.cachedProperty,s=o.parseBytes;function c(e,t){this.eddsa=e,"object"!=typeof t&&(t=s(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),i(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof r&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(c,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),a(c,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),a(c,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),a(c,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return o.encode(this.toBytes(),"hex").toUpperCase()},e.exports=c},1037:function(e){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},953:function(e,t,n){"use strict";var r=t,o=n(3550),i=n(9746),a=n(4504);r.assert=i,r.toArray=a.toArray,r.zero2=a.zero2,r.toHex=a.toHex,r.encode=a.encode,r.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var o=1<<t+1,i=e.clone(),a=0;a<r.length;a++){var s,c=i.andln(o-1);i.isOdd()?(s=c>(o>>1)-1?(o>>1)-c:c,i.isubn(s)):s=0,r[a]=s,i.iushrn(1)}return r},r.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r,o=0,i=0;e.cmpn(-o)>0||t.cmpn(-i)>0;){var a,s,c=e.andln(3)+o&3,u=t.andln(3)+i&3;3===c&&(c=-1),3===u&&(u=-1),a=0==(1&c)?0:3!==(r=e.andln(7)+o&7)&&5!==r||2!==u?c:-c,n[0].push(a),s=0==(1&u)?0:3!==(r=t.andln(7)+i&7)&&5!==r||2!==c?u:-u,n[1].push(s),2*o===a+1&&(o=1-o),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n},r.cachedProperty=function(e,t,n){var r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new o(e,"hex","le")}},7680:function(e){function t(e){return e}e.exports=function(e,n,r){n=n||t,r=r||e;for(var o=0,i=e.length;o<i;o+=1)if(n.call(r,e[o],o))return e[o]}},3715:function(e,t,n){var r=t;r.utils=n(6436),r.common=n(5772),r.sha=n(9041),r.ripemd=n(2949),r.hmac=n(2344),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},5772:function(e,t,n){"use strict";var r=n(6436),o=n(9746);function i(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=i,i.prototype.update=function(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-n,this.endian);for(var o=0;o<e.length;o+=this._delta32)this._update(e,o,o+this._delta32)}return this},i.prototype.digest=function(e){return this.update(this._pad()),o(null===this.pending),this._digest(e)},i.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,n=t-(e+this.padLength)%t,r=new Array(n+this.padLength);r[0]=128;for(var o=1;o<n;o++)r[o]=0;if(e<<=3,"big"===this.endian){for(var i=8;i<this.padLength;i++)r[o++]=0;r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=e>>>24&255,r[o++]=e>>>16&255,r[o++]=e>>>8&255,r[o++]=255&e}else for(r[o++]=255&e,r[o++]=e>>>8&255,r[o++]=e>>>16&255,r[o++]=e>>>24&255,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,i=8;i<this.padLength;i++)r[o++]=0;return r}},2344:function(e,t,n){"use strict";var r=n(6436),o=n(9746);function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(t,n))}e.exports=i,i.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},i.prototype.update=function(e,t){return this.inner.update(e,t),this},i.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},2949:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=r.rotl32,a=r.sum32,s=r.sum32_3,c=r.sum32_4,u=o.BlockHash;function l(){if(!(this instanceof l))return new l;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function d(e,t,n,r){return e<=15?t^n^r:e<=31?t&n|~t&r:e<=47?(t|~n)^r:e<=63?t&r|n&~r:t^(n|~r)}function f(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function p(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}r.inherits(l,u),t.ripemd160=l,l.blockSize=512,l.outSize=160,l.hmacStrength=192,l.padLength=64,l.prototype._update=function(e,t){for(var n=this.h[0],r=this.h[1],o=this.h[2],u=this.h[3],l=this.h[4],w=n,v=r,m=o,I=u,E=l,S=0;S<80;S++){var O=a(i(c(n,d(S,r,o,u),e[h[S]+t],f(S)),b[S]),l);n=l,l=u,u=i(o,10),o=r,r=O,O=a(i(c(w,d(79-S,v,m,I),e[y[S]+t],p(S)),g[S]),E),w=E,E=I,I=i(m,10),m=v,v=O}O=s(this.h[1],o,I),this.h[1]=s(this.h[2],u,E),this.h[2]=s(this.h[3],l,w),this.h[3]=s(this.h[4],n,v),this.h[4]=s(this.h[0],r,m),this.h[0]=O},l.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],y=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],b=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},9041:function(e,t,n){"use strict";t.sha1=n(4761),t.sha224=n(799),t.sha256=n(9344),t.sha384=n(772),t.sha512=n(5900)},4761:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=n(7038),a=r.rotl32,s=r.sum32,c=r.sum32_5,u=i.ft_1,l=o.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(f,l),e.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=a(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var o=this.h[0],i=this.h[1],l=this.h[2],f=this.h[3],p=this.h[4];for(r=0;r<n.length;r++){var h=~~(r/20),y=c(a(o,5),u(h,i,l,f),p,n[r],d[h]);p=f,f=l,l=a(i,30),i=o,o=y}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],l),this.h[3]=s(this.h[3],f),this.h[4]=s(this.h[4],p)},f.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},799:function(e,t,n){"use strict";var r=n(6436),o=n(9344);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=512,i.outSize=224,i.hmacStrength=192,i.padLength=64,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},9344:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=n(7038),a=n(9746),s=r.sum32,c=r.sum32_4,u=r.sum32_5,l=i.ch32,d=i.maj32,f=i.s0_256,p=i.s1_256,h=i.g0_256,y=i.g1_256,b=o.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function w(){if(!(this instanceof w))return new w;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(w,b),e.exports=w,w.blockSize=512,w.outSize=256,w.hmacStrength=192,w.padLength=64,w.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=c(y(n[r-2]),n[r-7],h(n[r-15]),n[r-16]);var o=this.h[0],i=this.h[1],b=this.h[2],g=this.h[3],w=this.h[4],v=this.h[5],m=this.h[6],I=this.h[7];for(a(this.k.length===n.length),r=0;r<n.length;r++){var E=u(I,p(w),l(w,v,m),this.k[r],n[r]),S=s(f(o),d(o,i,b));I=m,m=v,v=w,w=s(g,E),g=b,b=i,i=o,o=s(E,S)}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],b),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],w),this.h[5]=s(this.h[5],v),this.h[6]=s(this.h[6],m),this.h[7]=s(this.h[7],I)},w.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},772:function(e,t,n){"use strict";var r=n(6436),o=n(5900);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=1024,i.outSize=384,i.hmacStrength=192,i.padLength=128,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},5900:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=n(9746),a=r.rotr64_hi,s=r.rotr64_lo,c=r.shr64_hi,u=r.shr64_lo,l=r.sum64,d=r.sum64_hi,f=r.sum64_lo,p=r.sum64_4_hi,h=r.sum64_4_lo,y=r.sum64_5_hi,b=r.sum64_5_lo,g=o.BlockHash,w=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=w,this.W=new Array(160)}function m(e,t,n,r,o){var i=e&n^~e&o;return i<0&&(i+=4294967296),i}function I(e,t,n,r,o,i){var a=t&r^~t&i;return a<0&&(a+=4294967296),a}function E(e,t,n,r,o){var i=e&n^e&o^n&o;return i<0&&(i+=4294967296),i}function S(e,t,n,r,o,i){var a=t&r^t&i^r&i;return a<0&&(a+=4294967296),a}function O(e,t){var n=a(e,t,28)^a(t,e,2)^a(t,e,7);return n<0&&(n+=4294967296),n}function A(e,t){var n=s(e,t,28)^s(t,e,2)^s(t,e,7);return n<0&&(n+=4294967296),n}function T(e,t){var n=a(e,t,14)^a(e,t,18)^a(t,e,9);return n<0&&(n+=4294967296),n}function _(e,t){var n=s(e,t,14)^s(e,t,18)^s(t,e,9);return n<0&&(n+=4294967296),n}function k(e,t){var n=a(e,t,1)^a(e,t,8)^c(e,t,7);return n<0&&(n+=4294967296),n}function x(e,t){var n=s(e,t,1)^s(e,t,8)^u(e,t,7);return n<0&&(n+=4294967296),n}function P(e,t){var n=a(e,t,19)^a(t,e,29)^c(e,t,6);return n<0&&(n+=4294967296),n}function M(e,t){var n=s(e,t,19)^s(t,e,29)^u(e,t,6);return n<0&&(n+=4294967296),n}r.inherits(v,g),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(e,t){for(var n=this.W,r=0;r<32;r++)n[r]=e[t+r];for(;r<n.length;r+=2){var o=P(n[r-4],n[r-3]),i=M(n[r-4],n[r-3]),a=n[r-14],s=n[r-13],c=k(n[r-30],n[r-29]),u=x(n[r-30],n[r-29]),l=n[r-32],d=n[r-31];n[r]=p(o,i,a,s,c,u,l,d),n[r+1]=h(o,i,a,s,c,u,l,d)}},v.prototype._update=function(e,t){this._prepareBlock(e,t);var n=this.W,r=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],h=this.h[7],g=this.h[8],w=this.h[9],v=this.h[10],k=this.h[11],x=this.h[12],P=this.h[13],M=this.h[14],C=this.h[15];i(this.k.length===n.length);for(var N=0;N<n.length;N+=2){var j=M,D=C,R=T(g,w),L=_(g,w),B=m(g,w,v,k,x),K=I(g,w,v,k,x,P),U=this.k[N],F=this.k[N+1],W=n[N],G=n[N+1],q=y(j,D,R,L,B,K,U,F,W,G),z=b(j,D,R,L,B,K,U,F,W,G);j=O(r,o),D=A(r,o),R=E(r,o,a,s,c),L=S(r,o,a,s,c,u);var $=d(j,D,R,L),H=f(j,D,R,L);M=x,C=P,x=v,P=k,v=g,k=w,g=d(p,h,q,z),w=f(h,h,q,z),p=c,h=u,c=a,u=s,a=r,s=o,r=d(q,z,$,H),o=f(q,z,$,H)}l(this.h,0,r,o),l(this.h,2,a,s),l(this.h,4,c,u),l(this.h,6,p,h),l(this.h,8,g,w),l(this.h,10,v,k),l(this.h,12,x,P),l(this.h,14,M,C)},v.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},7038:function(e,t,n){"use strict";var r=n(6436).rotr32;function o(e,t,n){return e&t^~e&n}function i(e,t,n){return e&t^e&n^t&n}function a(e,t,n){return e^t^n}t.ft_1=function(e,t,n,r){return 0===e?o(t,n,r):1===e||3===e?a(t,n,r):2===e?i(t,n,r):void 0},t.ch32=o,t.maj32=i,t.p32=a,t.s0_256=function(e){return r(e,2)^r(e,13)^r(e,22)},t.s1_256=function(e){return r(e,6)^r(e,11)^r(e,25)},t.g0_256=function(e){return r(e,7)^r(e,18)^e>>>3},t.g1_256=function(e){return r(e,17)^r(e,19)^e>>>10}},6436:function(e,t,n){"use strict";var r=n(9746),o=n(5717);function i(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=o,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),o=0;o<e.length;o+=2)n.push(parseInt(e[o]+e[o+1],16))}else for(var r=0,o=0;o<e.length;o++){var a=e.charCodeAt(o);a<128?n[r++]=a:a<2048?(n[r++]=a>>6|192,n[r++]=63&a|128):i(e,o)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++o)),n[r++]=a>>18|240,n[r++]=a>>12&63|128,n[r++]=a>>6&63|128,n[r++]=63&a|128):(n[r++]=a>>12|224,n[r++]=a>>6&63|128,n[r++]=63&a|128)}else for(o=0;o<e.length;o++)n[o]=0|e[o];return n},t.toHex=function(e){for(var t="",n=0;n<e.length;n++)t+=s(e[n].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var n="",r=0;r<e.length;r++){var o=e[r];"little"===t&&(o=a(o)),n+=c(o.toString(16))}return n},t.zero2=s,t.zero8=c,t.join32=function(e,t,n,o){var i=n-t;r(i%4==0);for(var a=new Array(i/4),s=0,c=t;s<a.length;s++,c+=4){var u;u="big"===o?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],a[s]=u>>>0}return a},t.split32=function(e,t){for(var n=new Array(4*e.length),r=0,o=0;r<e.length;r++,o+=4){var i=e[r];"big"===t?(n[o]=i>>>24,n[o+1]=i>>>16&255,n[o+2]=i>>>8&255,n[o+3]=255&i):(n[o+3]=i>>>24,n[o+2]=i>>>16&255,n[o+1]=i>>>8&255,n[o]=255&i)}return n},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,n){return e+t+n>>>0},t.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},t.sum32_5=function(e,t,n,r,o){return e+t+n+r+o>>>0},t.sum64=function(e,t,n,r){var o=e[t],i=r+e[t+1]>>>0,a=(i<r?1:0)+n+o;e[t]=a>>>0,e[t+1]=i},t.sum64_hi=function(e,t,n,r){return(t+r>>>0<t?1:0)+e+n>>>0},t.sum64_lo=function(e,t,n,r){return t+r>>>0},t.sum64_4_hi=function(e,t,n,r,o,i,a,s){var c=0,u=t;return c+=(u=u+r>>>0)<t?1:0,c+=(u=u+i>>>0)<i?1:0,e+n+o+a+(c+=(u=u+s>>>0)<s?1:0)>>>0},t.sum64_4_lo=function(e,t,n,r,o,i,a,s){return t+r+i+s>>>0},t.sum64_5_hi=function(e,t,n,r,o,i,a,s,c,u){var l=0,d=t;return l+=(d=d+r>>>0)<t?1:0,l+=(d=d+i>>>0)<i?1:0,l+=(d=d+s>>>0)<s?1:0,e+n+o+a+c+(l+=(d=d+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,n,r,o,i,a,s,c,u){return t+r+i+s+u>>>0},t.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},t.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},t.shr64_hi=function(e,t,n){return e>>>n},t.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0}},2156:function(e,t,n){"use strict";var r=n(3715),o=n(4504),i=n(9746);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=o.toArray(e.entropy,e.entropyEnc||"hex"),n=o.toArray(e.nonce,e.nonceEnc||"hex"),r=o.toArray(e.pers,e.persEnc||"hex");i(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new r.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,n,r){"string"!=typeof t&&(r=n,n=t,t=null),e=o.toArray(e,t),n=o.toArray(n,r),i(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},a.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(r=n,n=t,t=null),n&&(n=o.toArray(n,r||"hex"),this._update(n));for(var i=[];i.length<e;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,e);return this._update(n),this._reseed++,o.encode(a,t)}},5717:function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},9746:function(e){function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)}},4504:function(e,t){"use strict";var n=t;function r(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",n=0;n<e.length;n++)t+=r(e[n].toString(16));return t}n.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r<e.length;r++)n[r]=0|e[r];return n}if("hex"===t){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(r=0;r<e.length;r+=2)n.push(parseInt(e[r]+e[r+1],16))}else for(r=0;r<e.length;r++){var o=e.charCodeAt(r),i=o>>8,a=255&o;i?n.push(i,a):n.push(a)}return n},n.zero2=r,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},2719:function(e){var t=e.exports=function(e,n){if("function"==typeof e||n)return t.by(e,n);for(var r={object:[],function:[],string:{},number:{},boolean:{},undefined:{}},o=[],i=0;i<e.length;i++){var a=e[i],s="__proto__"===a?r.objects:r[typeof a]||r.objects;Array.isArray(s)?s.indexOf(a)<0&&(s.push(a),o.push(a)):Object.hasOwnProperty.call(s,a)||(s[a]=!0,o.push(a))}return o};t.by=function(e,t){if("function"==typeof e){var n=t;t=e,e=n}for(var r=[],o=0;o<e.length;o++){for(var i=e[o],a=!1,s=0;s<r.length;s++){var c=r[s];if(t.call(r,i,c)){a=!0;break}}a||r.push(i)}return r}},7635:function(e){"use strict";!function(t){var n=2147483647;function r(e){var t=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=1779033703,r=3144134277,o=1013904242,i=2773480762,a=1359893119,s=2600822924,c=528734635,u=1541459225,l=new Array(64);function d(e){for(var d=0,f=e.length;f>=64;){var p,h,y,b,g,w=n,v=r,m=o,I=i,E=a,S=s,O=c,A=u;for(h=0;h<16;h++)y=d+4*h,l[h]=(255&e[y])<<24|(255&e[y+1])<<16|(255&e[y+2])<<8|255&e[y+3];for(h=16;h<64;h++)b=((p=l[h-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,g=((p=l[h-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,l[h]=(b+l[h-7]|0)+(g+l[h-16]|0)|0;for(h=0;h<64;h++)b=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&S^~E&O)|0)+(A+(t[h]+l[h]|0)|0)|0,g=((w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10))+(w&v^w&m^v&m)|0,A=O,O=S,S=E,E=I+b|0,I=m,m=v,v=w,w=b+g|0;n=n+w|0,r=r+v|0,o=o+m|0,i=i+I|0,a=a+E|0,s=s+S|0,c=c+O|0,u=u+A|0,d+=64,f-=64}}d(e);var f,p=e.length%64,h=e.length/536870912|0,y=e.length<<3,b=p<56?56:120,g=e.slice(e.length-p,e.length);for(g.push(128),f=p+1;f<b;f++)g.push(0);return g.push(h>>>24&255),g.push(h>>>16&255),g.push(h>>>8&255),g.push(h>>>0&255),g.push(y>>>24&255),g.push(y>>>16&255),g.push(y>>>8&255),g.push(y>>>0&255),d(g),[n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255]}function o(e,t,n){var o;e=e.length<=64?e:r(e);var i=64+t.length+4,a=new Array(i),s=new Array(64),c=[];for(o=0;o<64;o++)a[o]=54;for(o=0;o<e.length;o++)a[o]^=e[o];for(o=0;o<t.length;o++)a[64+o]=t[o];for(o=i-4;o<i;o++)a[o]=0;for(o=0;o<64;o++)s[o]=92;for(o=0;o<e.length;o++)s[o]^=e[o];function u(){for(var e=i-1;e>=i-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;n>=32;)u(),c=c.concat(r(s.concat(r(a)))),n-=32;return n>0&&(u(),c=c.concat(r(s.concat(r(a))).slice(0,n))),c}function i(e,t,n,r,o){var i;for(u(e,16*(2*n-1),o,0,16),i=0;i<2*n;i++)c(e,16*i,o,16),s(o,r),u(o,0,e,t+16*i,16);for(i=0;i<n;i++)u(e,t+2*i*16,e,16*i,16);for(i=0;i<n;i++)u(e,t+16*(2*i+1),e,16*(i+n),16)}function a(e,t){return e<<t|e>>>32-t}function s(e,t){u(e,0,t,0,16);for(var n=8;n>0;n-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(n=0;n<16;++n)e[n]+=t[n]}function c(e,t,n,r){for(var o=0;o<r;o++)n[o]^=e[t+o]}function u(e,t,n,r,o){for(;o--;)n[r++]=e[t++]}function l(e){if(!e||"number"!=typeof e.length)return!1;for(var t=0;t<e.length;t++){if("number"!=typeof e[t])return!1;var n=parseInt(e[t]);if(n!=e[t]||n<0||n>=256)return!1}return!0}function d(e,t){var n=parseInt(e);if(e!=n)throw new Error("invalid "+t);return n}e.exports=function(e,t,r,a,s,f,p){if(!p)throw new Error("missing callback");if(r=d(r,"N"),a=d(a,"r"),s=d(s,"p"),f=d(f,"dkLen"),0===r||0!=(r&r-1))throw new Error("N must be power of 2");if(r>n/128/a)throw new Error("N too large");if(a>n/128/s)throw new Error("r too large");if(!l(e))throw new Error("password must be an array or buffer");if(!l(t))throw new Error("salt must be an array or buffer");for(var h=o(e,t,128*s*a),y=new Uint32Array(32*s*a),b=0;b<y.length;b++){var g=4*b;y[b]=(255&h[g+3])<<24|(255&h[g+2])<<16|(255&h[g+1])<<8|(255&h[g+0])<<0}var w,v,m=new Uint32Array(64*a),I=new Uint32Array(32*a*r),E=32*a,S=new Uint32Array(16),O=new Uint32Array(16),A=s*r*2,T=0,_=null,k=!1,x=0,P=0,M=parseInt(1e3/a),C="undefined"!=typeof setImmediate?setImmediate:setTimeout,N=function(){if(k)return p(new Error("cancelled"),T/A);switch(x){case 0:u(y,v=32*P*a,m,0,E),x=1,w=0;case 1:(n=r-w)>M&&(n=M);for(var t=0;t<n;t++)u(m,0,I,(w+t)*E,E),i(m,E,a,S,O);if(w+=n,T+=n,(l=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=l}if(w<r)break;w=0,x=2;case 2:var n,l;for((n=r-w)>M&&(n=M),t=0;t<n;t++){var d=m[16*(2*a-1)]&r-1;c(I,d*E,m,E),i(m,E,a,S,O)}if(w+=n,T+=n,(l=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=l}if(w<r)break;if(u(m,0,y,v,E),++P<s){x=0;break}for(h=[],t=0;t<y.length;t++)h.push(y[t]>>0&255),h.push(y[t]>>8&255),h.push(y[t]>>16&255),h.push(y[t]>>24&255);var b=o(e,h,f);return p(null,1,b)}C(N)};N()}}()},7716:function(e,t){"use strict";function n(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,c,"next",e)}function c(e){n(a,o,i,s,c,"throw",e)}s(void 0)}))}}function o(){return o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s={parse:function(e){for(var t=encodeURI(e),n=new Uint8Array(t.length),r=0,o=0;o<t.length;++o){var i=t.charCodeAt(o);37===i?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=i}return n.subarray(0,r)},stringify:function(e){for(var t="",n=0;n<e.length;++n){var r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)}};function c(e){var t=e.body,n=void 0===t?"":t,o=e.headers,i=void 0===o?{}:o,a=e.status,c=void 0===a?200:a,l=Promise.resolve(n),d={headers:u(i),ok:c>=200&&c<300,status:c,arrayBuffer:function(){return r((function*(){return yield l.then((function(e){return"string"==typeof e?s.parse(e).buffer:e}))}))()},json:function(){return r((function*(){return yield d.text().then((function(e){return JSON.parse(e)}))}))()},text:function(){return r((function*(){return yield l.then((function(e){return"string"==typeof e?e:s.stringify(new Uint8Array(e))}))}))()}};return d}function u(e){var t={forEach:function(t,n){for(var r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];t.call(n,e[i],i)}},get:function(n){return t.has(n)?e[n]:null},has:function(t){return Object.prototype.hasOwnProperty.call(e,t)}};return t}t.hd=function(e){return function(){var t=r((function*(t,n){void 0===n&&(n={});var r=n,i=r.body,a=void 0===i?"":i,u=r.method,l=void 0===u?"GET":u,d=r.headers,f=void 0===d?{}:d,p=new URL(t),h=p.host,y={method:l,path:p.pathname+p.search,version:"HTTP/1.1",headers:o({},f,{host:h}),body:"string"==typeof a?s.parse(a):new Uint8Array(a)};return c(yield e(y))}));return function(e,n){return t.apply(this,arguments)}}()},t.O7=c,t.h6=function(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];t[o.toUpperCase()]=e[o]}null==t.OPTIONS&&(t.OPTIONS=function(){return{status:204,headers:i}});var i={"content-length":"0",allow:Object.keys(t).join(", ")};return function(e){var n=t[e.method];return null!=n?n(e):{status:405,headers:i}}},t.Fl=function(e,t){void 0===t&&(t=function(){return{status:404}});for(var n=[],r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];n.push({regexp:new RegExp("^"+i+"$"),server:e[i]})}return function(e){for(var r,o=a(n);!(r=o()).done;){var i=r.value,s=i.regexp,c=i.server;if(s.test(e.path))return c(e)}return t(e)}},t.o3=function(e){return function(){var t=r((function*(t){var n=yield e(t),r=n.headers;return o({},n,{headers:o({},void 0===r?{}:r,{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Accept, Authorization, Content-Type","Access-Control-Allow-Methods":"DELETE, GET, OPTIONS, POST, PUT"})})}));return function(e){return t.apply(this,arguments)}}()}},8326:function(e,t,n){"use strict";e.exports=n.p+"6f5df9597ed41e29f436.js"},6601:function(){},9214:function(){},5352:function(e,t){"use strict";function n(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function r(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}Object.defineProperty(t,"__esModule",{value:!0});var o={chars:"0123456789ABCDEF",bits:4},i={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},a={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},s={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},u={parse:function(e,t){return n(e.toUpperCase(),o,t)},stringify:function(e,t){return r(e,o,t)}},l={parse:function(e,t){return void 0===t&&(t={}),n(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,i,t)},stringify:function(e,t){return r(e,i,t)}},d={parse:function(e,t){return n(e,a,t)},stringify:function(e,t){return r(e,a,t)}},f={parse:function(e,t){return n(e,s,t)},stringify:function(e,t){return r(e,s,t)}},p={parse:function(e,t){return n(e,c,t)},stringify:function(e,t){return r(e,c,t)}},h={parse:n,stringify:r};t.base16=u,t.base32=l,t.base32hex=d,t.base64=f,t.base64url=p,t.codec=h},8597:function(e){"use strict";e.exports={i8:"6.5.4"}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},function(){var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e}(),n.b=document.baseURI||self.location.href,function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var n=function(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"===e(n)?n:String(n)}function r(e,n,r){return(n=t(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var o=n(3715),i=n.n(o),a=n(2156),s=n.n(a);function c(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function u(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}var l={chars:"0123456789ABCDEF",bits:4},d={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},f={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},p={parse:function(e,t){return c(e.toUpperCase(),l,t)},stringify:function(e,t){return u(e,l,t)}},h={parse:function(e,t){return void 0===t&&(t={}),c(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,d,t)},stringify:function(e,t){return u(e,d,t)}},y={parse:function(e,t){return c(e,f,t)},stringify:function(e,t){return u(e,f,t)}},b=n(7716);const g=b.hd,w=b.O7,v=b.h6,m=b.Fl;b.o3;function I(){return I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(this,arguments)}var E="_yaob",S=1,O={};function A(e,t){Object.prototype.hasOwnProperty.call(e,E)?I(e[E],t):Object.defineProperty(e,E,{value:t})}function T(e){var t=e.prototype;if(!Object.prototype.hasOwnProperty.call(t,E)){A(t,{})}return e}function _(e){Object.prototype.hasOwnProperty.call(e,E)&&null!=e[E].localId||A(e,{localId:S++,bridges:[],listeners:{},watchers:{}});return e}function k(e){if(null==e[E])throw new TypeError("Not a bridgeable object");return _(e),e[E]}function x(e,t){null==t?t="":t+=".";for(var n=0,r=Object.getOwnPropertyNames(e);n<r.length;n++){var o=r[n],i=t+o;if(null!=O[i])throw new Error("A shared value named "+i+" already exists");O[i]=e[o],A(e[o],{shareId:i})}}function P(e,t){try{var n=N(e,t),r=j(e,n,t);return""!==n?{map:n,raw:r}:{raw:r}}catch(t){return M(e,t)}}function M(e,t){var n=N(e,t);return{map:n,raw:j(e,n,t),throw:!0}}function C(e,t,n,r){void 0===r&&(r=!1);var o=t.map,i=t.raw,a=null!=o?D(e,o,i,n,r):i;if(t.throw)throw a;return a}function N(e,t){switch(typeof t){case"boolean":case"number":case"string":return"";case"object":if(null===t)return"";if(t instanceof Date)return"d";if(t instanceof Error)return"e";if(t instanceof ArrayBuffer)return"ab";if(t instanceof Uint8Array)return"u8";if(t instanceof Map)return"M";if(t instanceof Set)return"S";if(null!=t[E])return null!=t[E].shareId?"s":"o";if(Array.isArray(t)){for(var n="",r=0;r<t.length;++r){var o=N(e,t[r]);if(""!==o&&""===n){n=[];for(var i=0;i<r;++i)n[i]=""}""!==n&&(n[r]=o)}return n}var a="";for(var s in t){var c=N(e,t[s]);""!==c&&(""===a&&(a={}),a[s]=c)}return a;case"undefined":return"u";case"function":return null!=t[E]&&null!=t[E].shareId?"s":"?";default:return"?"}}function j(e,t,n){switch(t){case"":return n;case"?":return typeof n;case"d":return n.toISOString();case"e":return function(e,t){var n=I({message:t.message,stack:t.stack},t),r=null;return t instanceof EvalError?r="EvalError":t instanceof RangeError?r="RangeError":t instanceof ReferenceError?r="ReferenceError":t instanceof SyntaxError?r="SyntaxError":t instanceof TypeError?r="TypeError":t instanceof URIError&&(r="URIError"),I({base:r},P(e,n))}(e,n);case"o":return e.getPackedId(n);case"s":return n[E].shareId;case"u":return null;case"ab":return y.stringify(new Uint8Array(n));case"u8":return y.stringify(n);case"M":return P(e,Array.from(n.entries()));case"S":return P(e,Array.from(n.values()));default:if(Array.isArray(t)){for(var r=[],o=0;o<t.length;++o)r[o]=j(e,t[o],n[o]);return r}var i={};for(var a in n)i[a]=a in t?j(e,t[a],n[a]):n[a];return i}}function D(e,t,n,r,o){switch(t){case"":return n;case"?":throw new TypeError("Unsupported value of type "+("string"==typeof n?n:"?")+" at "+r);case"d":return new Date(n);case"e":if("object"!=typeof n||null===n)throw new TypeError("Expecting an error description at "+r);return function(e,t,n){var r={EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError},o=new(null!=t.base&&r[t.base]||Error),i=C(e,t,n,!0);for(var a in i)o[a]=i[a];return o}(e,n,r);case"o":if(null===n)throw new TypeError("Closed bridge object at "+r);if("number"!=typeof n)throw new TypeError("Expecting a packedId at "+r);var i=e.getObject(-n);if(null==i)throw new RangeError("Invalid packedId "+n+" at "+r);return i;case"s":if("string"!=typeof n)throw new TypeError("Expecting a shareId at "+r);var a=O[n];if(null==a)throw new RangeError("Invalid shareId '"+n+"' at "+r);return a;case"u":return;case"ab":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return y.parse(n).buffer;case"u8":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return y.parse(n);case"M":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Map description at "+r);return new Map(C(e,n,r));case"S":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Set description at "+r);return new Set(C(e,n,r));default:if("object"!=typeof t||null===t)throw new TypeError("Invalid type information "+t+" at "+r);if("object"!=typeof n||null===n)throw new TypeError("Expecting an array or object at "+r);if(Array.isArray(t)){if(!Array.isArray(n))throw new TypeError("Expecting an array at "+r);for(var s=[],c=0;c<t.length;++c)!0===o&&"?"===t[c]||(s[c]=D(e,t[c],n[c],r+"["+c+"]",o));return s}var u={};for(var l in n)!0===o&&"?"===t[l]||(u[l]=l in t?D(e,t[l],n[l],r+"."+l,o):n[l]);return u}}var R={};function L(e,t,n){var r=k(e),o=r.closed,i=r.listeners;return o?function(){}:(null==i[t]?i[t]=[n]:i[t].push(n),function(){i[t]=i[t].filter((function(e){return e!==n}))})}function B(e){var t=k(e),n=t.listeners.close;if(null!=n)for(var r=0;r<n.length;r++){F(e,n[r],void 0,!0)}t.closed=!0;for(var o=0,i=t.bridges;o<i.length;o++){i[o].emitClose(t.localId)}t.bridges=[],t.listeners={},t.watchers={}}function K(e,t,n){var r=k(e);if(r.closed)throw new Error("Cannot emit event on closed object");for(var o=0,i=r.bridges;o<i.length;o++){i[o].emitEvent(r.localId,t,n)}var a=r.listeners[t];if(null!=a)for(var s=0;s<a.length;s++){F(e,a[s],n,"error"!==t)}}function U(e,t){var n=k(e);if(n.closed)throw new Error("Cannot update closed object");for(var r=0,o=n.bridges;r<o.length;r++){o[r].markDirty(n.localId,t)}for(var i in null!=t&&null!=n.watchers[t]&&(n.watchers[t].data=R),n.watchers){var a=n.watchers[i];try{var s=e[i];if(s!==a.data){a.data=s;for(var c=0,u=a.fs;c<u.length;c++){F(e,u[c],a.data,!0)}}}catch(l){}}}function F(e,t,n,r){try{var o=t(n);r&&null!=o&&"function"==typeof o.then&&o.then(void 0,(function(t){return K(e,"error",t)}))}catch(i){r&&K(e,"error",i)}}var W={};function G(e,t,n){var r=!1,o={};for(var i in n)try{var a=t[i];a!==n[i]&&(r=!0,o[i]=P(e,a),n[i]=a)}catch(s){o[i]=M(e,s),n[i]=W}return{dirty:r,props:o}}function q(e,t){var n,r={},o=(n=t.localId,{localId:S++,bridges:[],listeners:{},watchers:{},remoteId:n,errors:{},props:{}});for(var i in r[E]={value:o},t.props)r[i]={enumerable:e.hideProperties.indexOf(i)<0,get:$(o,i)};for(var a=0,s=t.methods;a<s.length;a++){var c=s[a];r[c]={value:H(e,o,c)}}return Object.create(Object.prototype,r)}function z(e,t,n){var r=t[E];for(var o in n)try{r.props[o]=C(e,n[o],o),r.errors[o]=!1}catch(i){r.props[o]=i,r.errors[o]=!0}}function $(e,t){return function(){if(e.errors[t])throw e.props[t];return e.props[t]}}function H(e,t,n){return function(){if(t.closed)return Promise.reject(new TypeError("Cannot call method '"+n+"' of closed proxy"));for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.emitCall(t.remoteId,n,o)}}var Y=function(){function e(e){var t=e.hideProperties,n=void 0===t?[]:t,r=e.sendMessage,o=e.throttleMs,i=void 0===o?0:o;this.hideProperties=n,this.sendMessage=r,this.throttleMs=i,this.proxies={},this.objects={},this.caches={},this.nextCallId=0,this.pendingCalls={},this.dirty={},this.message={},this.lastUpdate=0,this.sendPending=!1}var t=e.prototype;return t.close=function(e){for(var t in this.pendingCalls){this.pendingCalls[Number(t)].reject(e)}for(var n in this.proxies)B(this.proxies[Number(n)]);this.closed=!0},t.getObject=function(e){return e<0?this.proxies[-e]:this.objects[e]},t.getPackedId=function(e){var t=k(e);if(t.closed)return null;if(null!=t.remoteId&&null!=this.proxies[t.remoteId])return-t.remoteId;if(null==this.objects[t.localId]){this.objects[t.localId]=e;var n=function(e,t){for(var n={},r=Object.prototype,o=t;o!==r&&null!=o;o=Object.getPrototypeOf(o))for(var i=0,a=Object.getOwnPropertyNames(o);i<a.length;i++){var s=a[i];s===E||/^_/.test(s)||"constructor"===s||(n[s]=!0)}var c={},u=[],l={};for(var d in n)try{var f=t[d];"function"!=typeof f||null!=f[E]&&null!=f[E].shareId?(c[d]=f,l[d]=P(e,f)):u.push(d)}catch(p){c[d]=W,l[d]=M(e,p)}return{cache:c,create:{localId:k(t).localId,methods:u,props:l}}}(this,e),r=n.cache,o=n.create;this.caches[t.localId]=r,t.bridges.push(this),this.emitCreate(o,e)}return t.localId},t.markDirty=function(e,t){var n=this.caches[e];null!=t&&t in n&&(n[t]=W),this.dirty[e]={cache:n,object:this.objects[e]},this.wakeup()},t.emitClose=function(e){delete this.objects[e],delete this.caches[e],null==this.message.closed&&(this.message.closed=[]),this.message.closed.push(e),this.wakeup()},t.emitCreate=function(e,t){null==this.message.created&&(this.message.created=[]),this.message.created.push(e)},t.emitCall=function(e,t,n){var r=this,o=this.nextCallId++,i=I({callId:o,remoteId:e,name:t},P(this,n));return null==this.message.calls&&(this.message.calls=[]),this.message.calls.push(i),this.wakeup(),new Promise((function(e,n){r.pendingCalls[o]={name:t,resolve:e,reject:n}}))},t.emitEvent=function(e,t,n){var r=I({localId:e,name:t},P(this,n));null==this.message.events&&(this.message.events=[]),this.message.events.push(r),this.wakeup()},t.emitReturn=function(e,t,n){var r=I({callId:e},t?M(this,n):P(this,n));null==this.message.returns&&(this.message.returns=[]),this.message.returns.push(r),this.wakeup()},t.handleMessage=function(e){var t=this;if(e.created){for(var n=0,r=e.created;n<r.length;n++){var o=r[n];this.proxies[o.localId]=q(this,o)}for(var i=0,a=e.created;i<a.length;i++){var s=a[i];z(this,this.proxies[s.localId],s.props)}}if(e.changed){for(var c=0,u=e.changed;c<u.length;c++){var l=u[c],d=l.localId,f=l.props,p=this.proxies[d];if(null==p)throw new RangeError("Invalid localId "+d);z(this,p,f)}for(var h=0,y=e.changed;h<y.length;h++){var b=y[h];U(this.proxies[b.localId])}}if(e.events)for(var g=0,w=e.events;g<w.length;g++){var v=w[g],m=v.localId,I=v.name,E=0===m?this:this.proxies[m];if(null!=E)try{K(E,I,C(this,v,I))}catch(R){K(E,"error",R)}}if(e.calls)for(var S=function(e,n){var r=n[e],o=r.callId,i=r.remoteId,a=r.name;try{var s=t.objects[i];if(null==s)throw new TypeError("Cannot call method '"+a+"' of closed proxy (remote)");if("function"!=typeof s[a])throw new TypeError("'"+a+"' is not a function");var c=C(t,r,a+".arguments");Promise.resolve(s[a].apply(s,c)).then((function(e){return t.emitReturn(o,!1,e)}),(function(e){return t.emitReturn(o,!0,e)}))}catch(R){t.emitReturn(o,!0,R)}},O=0,A=e.calls;O<A.length;O++)S(O,A);if(e.returns)for(var T=0,_=e.returns;T<_.length;T++){var k=_[T],x=k.callId,P=this.pendingCalls[x];if(null==P)throw new RangeError("Invalid callId "+x);try{P.resolve(C(this,k,P.name+".return"))}catch(R){P.reject(R)}finally{delete this.pendingCalls[x]}}if(e.closed)for(var M=0,N=e.closed;M<N.length;M++){var j=N[M],D=this.proxies[j];if(null==D)return;delete this.proxies[j],B(D)}},t.sendNow=function(){if(!this.closed){for(var e in this.dirty){var t=Number(e),n=this.dirty[t],r=G(this,n.object,n.cache),o=r.dirty,i=r.props;if(o){var a={localId:t,props:i};null==this.message.changed&&(this.message.changed=[]),this.message.changed.push(a)}}var s=this.message;this.dirty={},this.message={},null==s.calls&&null==s.changed&&null==s.closed&&null==s.created&&null==s.events&&null==s.returns||this.sendMessage(s)}},t.wakeup=function(){var e=this;if(!this.sendPending){this.sendPending=!0;var t=this.lastUpdate+this.throttleMs-Date.now();setTimeout((function(){e.sendPending=!1,e.lastUpdate=Date.now(),e.sendNow()}),t<0?0:t)}},e}();T(Y);var V=function(){function e(e){var t=this;this._state=new Y(e),this._rootPromise=new Promise((function(e){return L(t._state,"root",e)}))}var t=e.prototype;return t.handleMessage=function(e){this._state.handleMessage(e)},t.getRoot=function(){return this._rootPromise},t.sendRoot=function(e){this._state.emitEvent(0,"root",e)},t.close=function(e){this._state.close(e)},e}();var J=function(e,t){return L(this,e,t)},X=function(e,t){return function(e,t,n){var r=k(e),o=r.closed,i=r.watchers,a=e[t];return o?function(){}:(null==i[t]?i[t]={data:a,fs:[n]}:i[t].fs.push(n),function(){i[t].fs=i[t].fs.filter((function(e){return e!==n}))})}(this,e,t)};x({onMethod:J,watchMethod:X});var Z=function(){function e(){}var t=e.prototype;return t._close=function(){B(this)},t._emit=function(e,t){return K(this,e,t)},t._update=function(e){U(this,e)},e}(),Q=Z.prototype;Q.on=J,Q.watch=X,T(Z);var ee=n(4638);n(7635);class te{getFirstWalletInfo(e){return this.allKeys.find((t=>t.type===e))}getWalletInfo(e){return this.allKeys.find((t=>t.id===e))}listWalletIds(){return this.allKeys.map((e=>e.id))}}function ne(e){const t=e.length<10,n=!/[0-9]/.test(e),r=!/[a-z]/.test(e),o=!/[A-Z]/.test(e),i=(/[0-9]/.test(e)?10:0)+(/[A-Z]/.test(e)?26:0)+(/[a-z]/.test(e)?26:0)+(/[^0-9A-Za-z]/.test(e)?30:0);return{secondsToCrack:Math.pow(i,e.length)/1e6,tooShort:t,noNumber:n,noLowerCase:r,noUpperCase:o,passed:e.length>=16||!(t||n||o||r)}}function re(e){const t=e.toLowerCase().replace(/[ \f\r\n\t\v]+/g," ").replace(/ $/,"").replace(/^ /,"");for(let n=0;n<t.length;++n){const e=t.charCodeAt(n);if(e<32||e>126)throw new Error("Bad characters in username")}return t}function oe(e){let t,n=!1;const r={next:async()=>{if(null==t&&(t=await this.$internalStreamTransactions(e)),!n){const e=await t.next();if(!e.done)return e;B(t),n=!0}return{done:!0,value:void 0}},return:async()=>(null==t||n||(B(t),n=!0),{done:!0,value:void 0}),[Symbol.asyncIterator]:()=>r};return r}function ie(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function ae(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function se(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;++n)if(e===t[n])return e;var r="Expected ";1!==t.length&&(r+="one of: ");for(var o=0;o<t.length;++o)o>0&&(r+=" | "),r+=JSON.stringify(t[o]);throw r+=", got "+ie(e),new TypeError(r)}}function ce(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+ie(e));return e}function ue(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+ie(e));return e}function le(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+ie(e));return e}x(te.prototype,"AccountSync"),x({checkPasswordRules:ne}),x({fixUsername:re}),x({streamTransactions:oe},"CurrencyWalletSync");var de=se(null);se(void 0);function fe(e){return e}ae(de);function pe(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function he(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+ie(t));for(var n=[],r=0;r<t.length;++r)try{n[r]=e(t[r])}catch(o){throw pe(o,"["+r+"]",0)}return n}}function ye(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+ie(t));for(var n={},r=Object.keys(t),o=0;o<r.length;++o){var i=r[o];if("__proto__"!==i)try{n[i]=e(t[i])}catch(a){throw pe(a,"["+JSON.stringify(i)+"]",0)}}return n};var t=Object.keys(e);function n(n){return function(r){if("object"!=typeof r||null==r)throw new TypeError("Expected an object, got "+ie(r));var o,i={};if(n){var a=Object.keys(r);for(o=0;o<a.length;++o){var s=a[o];"__proto__"!==s&&(i[s]=r[s])}}for(o=0;o<t.length;++o){var c=t[o];try{i[c]=e[c](r[c])}catch(u){throw pe(u,"."+c,0)}}return i}}var r=n(!1);return r.shape=e,r.withRest=n(!0),r}function be(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}}function ge(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}}function we(e,t){return function(n){return me[Ie]>0?t(n):e(n)}}function ve(e){return function(t){null==me[Ie]&&Object.defineProperty(me,Ie,{value:0,writable:!0});try{return++me[Ie],e(t)}finally{--me[Ie]}}}var me="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,Ie="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",Ee=we((function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+ie(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+ie(e));return t}),(function(e){return e.toISOString()}));const Se=we((e=>p.parse(le(e))),(e=>p.stringify(e).toLowerCase())),Oe=we((e=>h.parse(le(e),{loose:!0})),(e=>h.stringify(e,{pad:!1}))),Ae=we((e=>y.parse(le(e))),(e=>y.stringify(e))),Te=ye({voucherId:le,activates:Ee,created:Ee,ip:le,ipDescription:le,deviceDescription:ae(le)}),_e=ye({encryptionType:ue,data_base64:Ae,iv_hex:Se}),ke=ye({created:ae(Ee),data_base64:Ae,encryptionType:ue,iv_hex:Se}),xe=ye({salt_hex:Se,n:ue,r:ue,p:ue}),Pe=ye({loginRequest:ae(ye({appId:le}).withRest),publicKey:Ae,timeout:ae(ue)}).withRest,Me=ye({publicKey:Ae,box:_e}),Ce=he(Ae),Ne=ye({data:fe,challengeId:ae(le),deviceDescription:ae(le),otp:ae(le),syncToken:ae(le),voucherId:ae(le),voucherAuth:ae(Ae),loginId:ae(Ae),loginAuth:ae(Ae),userId:ae(Ae),passwordAuth:ae(Ae),pin2Id:ae(Ae),pin2Auth:ae(Ae),recovery2Id:ae(Ae),recovery2Auth:ae(Ce),loginIds:ae(he(Ae)),otpResetAuth:ae(le),did:ae(le),l1:ae(Ae),lp1:ae(Ae),lpin1:ae(Ae),lra1:ae(Ae),recoveryAuth:ae(Ae)}),je=ye({results:ae(fe),status_code:ue,message:le}),De=ye({otpTimeout:ae(ue,604800),otpKey:Oe}),Re=ye({passwordAuth:Ae,passwordAuthBox:_e,passwordAuthSnrp:xe,passwordBox:_e,passwordKeySnrp:xe}),Le=ye({pin2Id:Ae}),Be=ye({pin2Id:ae(Ae),pin2Auth:ae(Ae),pin2Box:ae(_e),pin2KeyBox:ae(_e),pin2TextBox:_e}),Ke=ye({recovery2Id:Ae}),Ue=ye({recovery2Id:Ae,recovery2Auth:Ce,recovery2Box:_e,recovery2KeyBox:_e,question2Box:_e}),Fe=ye({loginAuthBox:_e,loginAuth:Ae}),We=ye({userId:Ae,userTextBox:_e}),Ge=ye({approvedVouchers:ae(he(le)),rejectedVouchers:ae(he(le))}),qe=ye({allowExisting:ae(ce,!1),keyBoxes:he(_e),newSyncKeys:ae(he(le),(()=>[]))}),ze=ye({appId:le,loginId:Ae,parentBox:ae(_e)}),$e=ye({challengeId:le,challengeUri:le}),He=ye({challengeId:le,challengeUri:ae(le)}),Ye=ye({request:Pe,replies:he(Me)}),Ve=se(!0),Je=ye({appId:le,created:Ee,loginId:Ae,syncToken:ae(le),children:ae(he((e=>Je(e)))),parentBox:ae(_e),otpKey:ae(be(Ve,Oe)),otpResetDate:ae(Ee),otpTimeout:ae(ue),passwordAuthBox:ae(_e),passwordAuthSnrp:ae(xe),passwordBox:ae(be(Ve,_e)),passwordKeySnrp:ae(xe),pin2Box:ae(be(Ve,_e)),pin2KeyBox:ae(_e),pin2TextBox:ae(_e),question2Box:ae(_e),recovery2Box:ae(be(Ve,_e)),recovery2KeyBox:ae(_e),loginAuthBox:ae(_e),userId:ae(Ae),userTextBox:ae(_e),pendingVouchers:ae(he(Te),(()=>[])),keyBoxes:ae(he(ke)),mnemonicBox:ae(_e),rootKeyBox:ae(_e),syncKeyBox:ae(_e)}),Xe=he(ye({loginId:Ae,otpResetPending:ae(ce,!1),pendingVouchers:ae(he(Te),(()=>[])),recovery2Corrupt:ae(ce,!1)})),Ze=ye({login_id:ae(Ae),otp_reset_auth:ae(le),otp_timeout_date:ae(Ee),reason:ae(se("ip","otp"),"otp"),voucher_activates:ae(Ee),voucher_auth:ae(Ae),voucher_id:ae(le)}),Qe=ye({otpResetDate:Ee}),et=ye({wait_seconds:ae(ue)}),tt=ye({question2Box:_e}),nt=ye({loginId:Ae,passwordAuthSnrp:ae(xe),questionBox:ae(_e),questionKeySnrp:ae(xe),recoveryAuthSnrp:ae(xe)}),rt=ve(_e),ot=ve(Me),it=ve(Pe),at=ve(Ne),st=ve(je),ct=ve(De),ut=ve(Re),lt=ve(Le),dt=ve(Be),ft=ve(Ke),pt=ve(Ue),ht=ve(Fe),yt=ve(We),bt=ve(Ge),gt=ve(qe),wt=ve(ze),vt=(ve($e),ve(He),ve(Ye)),mt=ve(Je),It=ve(Xe),Et=ve(Ze),St=ve(Qe),Ot=ve(et),At=ve(tt),Tt=ve(nt),_t=ye(_e),kt=ye({loginId:Ae,voucherAuth:Ae,voucherId:le,created:Ee,activates:Ee,status:se("pending","approved","rejected"),ip:le,ipDescription:le,deviceDescription:ae(le)}),xt=ye({appId:le,created:ae(Ee,(()=>new Date)),loginId:Ae,children:ae(he((e=>xt(e))),(()=>[])),parentBox:ae(_e),parentId:()=>{},otpKey:ae(Oe),otpResetAuth:ae(le),otpResetDate:ae(Ee),otpTimeout:ae(ue),passwordAuth:ae(Ae),passwordAuthBox:ae(_e),passwordAuthSnrp:ae(xe),passwordBox:ae(_e),passwordKeySnrp:ae(xe),pin2Id:ae(Ae),pin2Auth:ae(Ae),pin2Box:ae(_e),pin2KeyBox:ae(_e),pin2TextBox:ae(_e),recovery2Id:ae(Ae),recovery2Auth:ae(Ce),question2Box:ae(_e),recovery2Box:ae(_e),recovery2KeyBox:ae(_e),loginAuth:ae(Ae),loginAuthBox:ae(_e),userId:ae(Ae),userTextBox:ae(_e),keyBoxes:ae(he(ke),(()=>[])),mnemonicBox:ae(_e),rootKeyBox:ae(_e),syncKeyBox:ae(_e),vouchers:ae(he(kt),(()=>[])),pinBox:ae(_e),pinId:ae(le),pinKeyBox:ae(_e)}),Pt=ve(xt),Mt=ve(_t);var Ct=n(8162);const Nt=n.n(Ct)()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),jt={parse(e){return Nt.decode(e)},stringify(e){return Nt.encode(e)}},Dt={parse(e){const t=encodeURI(e),n=new Uint8Array(t.length);let r=0;for(let o=0;o<t.length;++o){const e=t.charCodeAt(o);37===e?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=e}return n.subarray(0,r)},stringify(e){let t="";for(let n=0;n<e.length;++n){const r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)}};function Rt(e){const t=new URL(e);if("http:"!==t.protocol&&"ws:"!==t.protocol||"localhost"!==t.hostname){if("https:"===t.protocol||"wss:"===t.protocol){if("localhost"===t.hostname)return;if(/^([A-Za-z0-9_-]+\.)*edge(test)?\.app$/.test(t.hostname))return}throw new Error(`Only *.edge.app or localhost are valid login domain names, not ${t.hostname}`)}}function Lt(e,t="Login requires a CAPTCHA"){if(!(this instanceof Lt))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var n;return function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Lt,configurable:!0,writable:!0})}(t),n.name="ChallengeError",n.challengeId=e.challengeId,n.challengeUri=e.challengeUri,n}function Bt(e="Cannot reach the network"){if(!(this instanceof Bt))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Bt,configurable:!0,writable:!0})}(e),t.name="NetworkError",t}function Kt(e="The application is too old. Please upgrade."){if(!(this instanceof Kt))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Kt,configurable:!0,writable:!0})}(e),t.name="ObsoleteApiError",t}function Ut(e,t="Invalid OTP token"){if(!(this instanceof Ut))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Ut,configurable:!0,writable:!0})}(t),n.name="OtpError",n.reason="otp";const r=ge(Ze)(e);if(null!=r)return null!=r.login_id&&(n.loginId=y.stringify(r.login_id)),n.resetToken=r.otp_reset_auth,n.reason=r.reason,n.resetDate=r.otp_timeout_date,n.voucherActivates=r.voucher_activates,null!=r.voucher_auth&&(n.voucherAuth=y.stringify(r.voucher_auth)),n.voucherId=r.voucher_id,n}function Ft(e,t="Invalid password"){if(!(this instanceof Ft))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Ft,configurable:!0,writable:!0})}(t),n.name="PasswordError";const r=ge(et)(e);if(null!=r)return n.wait=r.wait_seconds,n}function Wt(e){if(!(this instanceof Wt))throw new TypeError("Class constructor PinDisabledError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Wt,configurable:!0,writable:!0})}(e),t.name="PinDisabledError",t}function Gt(e="Invalid username"){if(!(this instanceof Gt))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Gt,configurable:!0,writable:!0})}(e),t.name="UsernameError",t}function qt(e){return function(t){if(t instanceof Error&&t.name===e){return t}}}qt("ChallengeError"),qt("DustSpendError");const zt=qt("InsufficientFundsError"),$t=(qt("NetworkError"),qt("NoAmountSpecifiedError"),qt("ObsoleteApiError"),qt("OtpError")),Ht=qt("PasswordError"),Yt=qt("PinDisabledError"),Vt=qt("PendingFundsError"),Jt=(qt("SameCurrencyError"),qt("SpendToSelfError"),qt("SwapAboveLimitError")),Xt=qt("SwapBelowLimitError"),Zt=qt("SwapCurrencyError"),Qt=qt("SwapPermissionError"),en=qt("SwapAddressError"),tn=qt("UsernameError");var nn=n(8826);function rn(e,t){const n=i().hmac(i().sha256,t);return Uint8Array.from(n.update(e).digest())}function on(e){const t=i().sha256();return Uint8Array.from(t.update(e).digest())}function an(e,t){const n=e.length;if(n!==t.length)return!1;let r=0;for(let o=0;o<n;++o)r|=e[o]^t[o];return 0===r}const sn=n.n(nn)().ModeOfOperation.cbc;function cn(e,t){const n=un(e,t);return 0===n[n.length-1]?Dt.stringify(n.subarray(0,-1)):Dt.stringify(n)}function un(e,t){if(0!==e.encryptionType)throw new Error("Unknown encryption type");const n=e.iv_hex,r=e.data_base64,o=new sn(t,n).decrypt(r),i=1+o[0]+4,a=o[i-4]<<24|o[i-3]<<16|o[i-2]<<8|o[i-1],s=i+a+1,c=s+o[s-1],u=c+32;if(!an(on(o.subarray(0,c)),o.subarray(c,u)))throw new Error("Invalid checksum");if(!an(dn(u),o.subarray(u)))throw new Error("Invalid PKCS7 padding");return o.subarray(i,i+a)}function ln(e,t,n){const r=31&e.random(1)[0],o=1+r+4,i=t.length,a=o+i+1,s=31&e.random(1)[0],c=a+s,u=c+32,l=dn(u),d=new Uint8Array(u+l.length);d.set(l,u),d[0]=r,d.set(e.random(r),1),d[o-4]=i>>24&255,d[o-3]=i>>16&255,d[o-2]=i>>8&255,d[o-1]=255&i,d.set(t,o),d[a-1]=s,d.set(e.random(s),a),d.set(on(d.subarray(0,c)),c);const f=e.random(16);return{encryptionType:0,iv_hex:f,data_base64:new sn(n,f).encrypt(d)}}function dn(e){const t=new Uint8Array(16-(15&e));for(let n=0;n<t.length;++n)t[n]=t.length;return t}function fn(e,t,n){const r=function(e,t){const n=i().hmac(i().sha1,t);return Uint8Array.from(n.update(e).digest())}(function(e){const t=Math.floor(e/4294967296);return new Uint8Array([t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e])}(t),e),o=15&r[19],a=((127&r[o])<<24|r[o+1]<<16|r[o+2]<<8|r[o+3]).toString();return(Array(n).join("0")+a).slice(-n)}function pn(e,t=Date.now()/1e3){return fn(e,t/30,6)}function hn(...e){return[].concat(...e.filter((e=>null!=e)))}function yn(e,t){for(const n of Object.keys(t))Object.defineProperty(e,n,{writable:!0,configurable:!0,value:t[n]});return e}function bn(e,t,n=new Error(`Timeout of ${t}ms exceeded`)){return new Promise(((r,o)=>{const i=setTimeout((()=>o(n)),t);e.then((e=>{clearTimeout(i),r(e)}),(e=>{clearTimeout(i),o(e)}))}))}async function gn(e,t,n,r){const{loginServers:o}=e.props.state.login,i=Math.floor(255*Math.random());let a,s=new Error("No login servers available");for(let l=0;l<o.length;++l)try{const s=(i+l)%o.length;a=await wn(e,o[s],t,n,r);break}catch(u){s=u}if(null==a)throw s;const{status:c}=a;return function(e){const t=je(e);switch(t.status_code){case 0:return t.results;case 2:throw new Gt("Account already exists on server");case 3:throw new Gt("Account does not exist on server");case 4:case 5:throw new Ft(t.results);case 6:throw new Error("Invalid API key");case 8:throw new Ut(t.results);case 1e3:throw new Kt;default:{const e=ge($e)(t.results);if(null!=e)throw new Lt(e);throw new Error(`Server error: ${t.message}`)}}}(await a.json().catch((()=>{throw new Error(`Invalid reply JSON, HTTP status ${c}`)})))}function wn(e,t,n,r,o){const{state:i,io:a,log:s}=e.props,{apiKey:c,apiSecret:u}=i.login,l="GET"===n||null==o?void 0:JSON.stringify(at(o));let d=`Token ${c}`;if(null!=u){const e=`${n}\n/api${r}\n${null!=l?l:""}`,t=rn(Dt.parse(e),u);d=`HMAC ${c} ${y.stringify(t)}`}const f={body:l,method:n,headers:{"content-type":"application/json",accept:"application/json",authorization:d},corsBypass:"never"},p=Date.now(),h=`${t}/api${r}`;return bn(a.fetch(h,f),3e4).then((e=>{const t=Date.now()-p;return s(`${n} ${h} returned ${e.status} in ${t}ms`),409===e.status&&s.crash("Login API conflict error",{path:r}),e}),(e=>{const t=Date.now()-p;throw s.error(`${n} ${h} failed in ${t}ms, ${String(e)}`),new Bt(`Could not reach the auth server: ${r}`)}))}function vn(e,t){const{io:n}=e.props,{loginId:r,loginKey:o}=t,i=n.random(32),a=ln(n,i,o);return{loginId:r,server:ht({loginAuth:i,loginAuthBox:a}),serverPath:"/v2/login/secret",stash:{loginAuthBox:a}}}function mn(e,t=2e3){return e.props.output.scrypt.makeSnrp(t)}async function In(e,t,n){"string"==typeof t&&(t=Dt.parse(t));return(await e.props.output.scrypt.timeScrypt(t,n)).hash}const En={salt_hex:Uint8Array.from([181,134,95,251,159,167,179,191,228,178,56,77,71,206,131,30,226,42,74,157,92,52,199,239,125,33,70,124,199,88,248,27]),n:16384,r:1,p:1};function Sn(e){return{username:e,appId:"",loginId:new Uint8Array(0),pendingVouchers:[]}}function On(e,t){const{stashes:n}=e.props.state.login;for(const r of n)if(r.username===t)return r}function An(e,t){const{stashes:n}=e.props.state.login;for(const r of n){const e=r,n=Un(e,(e=>an(e.loginId,t)));if(null!=n)return{stashTree:e,stash:n}}throw new Error(`Cannot find stash '${y.stringify(t)}'`)}function Tn(e,t){const n=Un(e,(e=>an(e.loginId,t)));if(null!=n)return n;throw new Error(`Cannot find child stash '${y.stringify(t)}'`)}const _n={};function kn(e,t){return null==_n[t]&&(_n[t]=In(e,t,En)),_n[t]}async function xn(e,t){const n=[],r=await e.list("logins").then(ee.gQ);for(const i of r)try{n.push(Mn(JSON.parse(await e.getText(i))))}catch(o){t.error(`Could not load ${i}: ${String(o)}`)}return n}async function Pn(e,t){const{dispatch:n,io:r}=e.props,{appId:o,loginId:i}=t;if(""!==o)throw new Error("Cannot save a login without an appId.");if(null==i||32!==i.length)throw new Error("Invalid loginId");await r.disklet.setText(`logins/${jt.stringify(i)}.json`,JSON.stringify(Cn(t))),n({type:"LOGIN_STASH_SAVED",payload:t})}const Mn=ye({appId:le,created:ae(Ee),lastLogin:ae(Ee),loginId:Ae,otpKey:ae(Oe),otpResetDate:ae(Ee),otpTimeout:ae(ue),pendingVouchers:ae(he(Te),(()=>[])),voucherId:ae(le),voucherAuth:ae(Ae),loginAuthBox:ae(_e),parentBox:ae(_e),passwordAuthBox:ae(_e),passwordAuthSnrp:ae(xe),passwordBox:ae(_e),passwordKeySnrp:ae(xe),pin2Key:ae(we((e=>{const t=le(e);return"="!==e.slice(-1)?jt.parse(t):y.parse(t)}),(e=>y.stringify(e)))),pin2TextBox:ae(_e),recovery2Key:ae(Ae),userId:ae(Ae),username:ae((e=>re(le(e)))),children:ae(he((e=>Mn(e)))),keyBoxes:ae(he(ke)),mnemonicBox:ae(_e),rootKeyBox:ae(_e),syncKeyBox:ae(_e),wipChange:ae((e=>Mn(e)))}),Cn=ve(Mn);function Nn(e,t){const n=t.endsWith(".duress")?t:t+".duress";return e.appId===n?e:Un(e,(e=>e.appId===n))}function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Dn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Rn(e){if(null!=e.otpKey)return pn(e.otpKey)}function Ln(e,t){const{otp:n,otpKey:r}=t;return null!=n?n:null!=r?pn(h.parse(r,{loose:!0})):null!=e.otpKey?pn(e.otpKey):void 0}function Bn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Kn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bn(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Un(e,t){if(t(e))return e;const n=e;if(null!=n.children)for(const r of n.children){const e=Un(r,t);if(null!=e)return e}}function Fn(e,t,n,r){if(t(e))return n(e);const o=null!=e.children?e.children.map((e=>Fn(e,t,n,r))):[];return r(e,o)}function Wn(e,t,n){const{children:r=[]}=e,{appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,children:v=[],keyBoxes:m=[],mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O}=n,A={appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:!0===u?e.otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:!0===b?e.passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,keyBoxes:m,mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O};null!=e.lastLogin&&(A.lastLogin=e.lastLogin),null!=e.username&&(A.username=e.username),null!=e.userId&&null==A.userId&&(A.userId=e.userId),null!=n.pin2KeyBox&&(A.pin2Key=un(n.pin2KeyBox,t)),null!=n.recovery2KeyBox&&(A.recovery2Key=un(n.recovery2KeyBox,t)),null!=n.userTextBox&&(A.username=Dt.stringify(un(n.userTextBox,t))),v.sort(((e,t)=>e.created.valueOf()-t.created.valueOf())),A.children=v.map((e=>{const{appId:n,loginId:o,parentBox:i}=e;if(null==i)throw new Error("Key integrity violation: No parentBox on child login.");const a=un(i,t),s=r.find((e=>an(e.loginId,o)));return Wn(null!=s?s:{appId:n,loginId:o,pendingVouchers:[]},a,e)}));for(const{loginId:T}of r){if(null==v.find((e=>an(e.loginId,T))))throw new Error("The server has lost children!")}return A}function Gn(e,t,n){return Fn(e,(e=>e.appId===n.appId),(e=>Wn(e,t,n)),((e,t)=>Kn(Kn({},e),{},{children:t,wipChange:void 0})))}function qn(e,t){const{appId:n,created:r,lastLogin:o=new Date,loginId:i,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:f=[]}=e,p={appId:n,created:r,isRoot:null==e.parentBox,lastLogin:o,loginId:i,loginKey:t,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:[]};if(null!=e.loginAuthBox&&(p.loginAuth=un(e.loginAuthBox,t)),null!=e.passwordAuthBox&&(null==p.userId&&(p.userId=i),p.passwordAuth=un(e.passwordAuthBox,t)),null==p.loginAuth&&null==p.passwordAuth)throw new Error("No server authentication methods on login");return p.pin2Key=e.pin2Key,null!=e.pin2TextBox&&(p.pin=cn(e.pin2TextBox,t)),p.recovery2Key=e.recovery2Key,p.children=f.map((e=>{if(null==e.parentBox)throw new Error("Key integrity violation: No parentBox on child login.");return qn(e,un(e.parentBox,t))})),p}function zn(e,t){return Fn(e,(e=>an(e.loginId,t.loginId)),(e=>qn(e,t.loginKey)),((e,t)=>{const{appId:n,lastLogin:r=new Date,loginId:o,otpKey:i,pendingVouchers:a,username:s}=e;return{appId:n,children:t,isRoot:null==e.parentBox,lastLogin:r,loginId:o,loginKey:undefined,otpKey:i,pendingVouchers:a,username:s}}))}function $n(e,t){return Fn(e,(e=>e.appId===t),(e=>e),((e,t)=>{const{appId:n,loginId:r,username:o}=e;return{appId:n,children:t,loginId:r,pendingVouchers:[],username:o}}))}async function Hn(e,t,n,r,o,i){const{now:a=new Date}=r,{deviceDescription:s}=e.props.state.login.deviceInfo,c=Kn({challengeId:r.challengeId,otp:Ln(n,r),voucherId:n.voucherId,voucherAuth:n.voucherAuth},o);null!=s&&(c.deviceDescription=s);let u=Je(await gn(e,"POST","/v2/login",c).catch((r=>{const o=$t(r);throw null!=o&&(0===n.loginId.length&&null!=o.loginId||null!=o.voucherId&&null!=o.voucherAuth)&&(null!=o.loginId&&(n.loginId=y.parse(o.loginId)),null!=o.voucherAuth&&(n.voucherId=o.voucherId,n.voucherAuth=y.parse(o.voucherAuth)),t.lastLogin=a,Pn(e,t).catch((()=>{}))),r})));const{loginId:l}=u,d=await i(u);if((t=Gn(t,d,u)).lastLogin=a,await Pn(e,t),null==u.loginAuthBox){const{stash:t,stashTree:n}=An(e,l),i=vn(e,{loginId:l,loginKey:d}),a=Kn(Kn({},o),{},{otp:Ln(t,r),data:i.server});u=Je(await gn(e,"POST",i.serverPath,a)),await Pn(e,Gn(n,d,u))}return{loginId:l,loginKey:d}}async function Yn(e,t,n){const{serverMethod:r="POST",serverPath:o}=n,{stashTree:i}=An(e,n.loginId),{deviceDescription:a}=e.props.state.login.deviceInfo,s=Fn(i,(e=>an(e.loginId,n.loginId)),(e=>Kn(Kn(Kn({},e),n.stash),{},{children:hn(e.children,n.stash.children),keyBoxes:hn(e.keyBoxes,n.stash.keyBoxes),wipChange:void 0})),((e,t)=>Kn(Kn({},e),{},{children:t,wipChange:void 0})));if(""!==o&&(i.wipChange=s,await Pn(e,i)),""!==o){const s=Zn(i,Xn(i,t,n.loginId));null!=a&&(s.deviceDescription=a),s.data=n.server;try{await gn(e,r,o,s)}catch(c){throw Jn(e,t).catch((()=>{})),c}}return await Pn(e,s),s}async function Vn(e,t,n){for(const r of n)null!=r&&await Yn(e,t,r)}async function Jn(e,t){const{stashTree:n,stash:r}=An(e,t.loginId),{syncToken:o}=r;if(null!=o)try{if(ce(await gn(e,"POST","/v2/sync",{loginId:r.loginId,syncToken:o})))return}catch(s){}const i=Zn(n,t),a={now:n.lastLogin};await Hn(e,n,r,a,i,(async()=>t.loginKey))}function Xn(e,t,n){var r;if(an(n,t.loginId))return t;const o=Tn(e,t.loginId),i=function e(t,r){for(const o of t){if(null==o.parentBox)continue;if(an(o.loginId,n))return{loginId:o.loginId,loginKey:un(o.parentBox,r)};const{children:t=[]}=o;if(0===t.length)continue;const i=e(t,un(o.parentBox,r));if(null!=i)return i}}(null!==(r=null==o?void 0:o.children)&&void 0!==r?r:[],t.loginKey);if(null==i)throw new Error(`Cannot decrypt child login '${y.stringify(t.loginId)}'`);return i}function Zn(e,t){const n=Tn(e,t.loginId),{loginAuthBox:r,otpKey:o,passwordAuthBox:i,syncToken:a,userId:s,voucherAuth:c,voucherId:u}=n,l=null!=o?pn(o):void 0;if(null!=r)return{loginAuth:un(r,t.loginKey),loginId:t.loginId,otp:l,syncToken:a,voucherAuth:c,voucherId:u};if(null!=i&&null!=s)return{passwordAuth:un(i,t.loginKey),userId:s,otp:l,syncToken:a,voucherAuth:c,voucherId:u};throw new Error("No server authentication methods available")}var Qn=n(1649);Qn.bS,Qn.Ei,Qn.h8,Qn.wJ,Qn.PG,Qn.SR,Qn.Th,Qn.Qw,Qn.YK,Qn.KI,Qn.Wn,Qn.tp,Qn.RQ,Qn.tE,Qn.Jj;const er=Qn.LZ;Qn.m8;function tr(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var nr="function"==typeof Symbol&&Symbol.observable||"@@observable",rr=function(){return Math.random().toString(36).substring(7).split("").join(".")},or={INIT:"@@redux/INIT"+rr(),REPLACE:"@@redux/REPLACE"+rr(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+rr()}};function ir(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ar(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(tr(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(tr(1));return n(ar)(e,t)}if("function"!=typeof e)throw new Error(tr(2));var o=e,i=t,a=[],s=a,c=!1;function u(){s===a&&(s=a.slice())}function l(){if(c)throw new Error(tr(3));return i}function d(e){if("function"!=typeof e)throw new Error(tr(4));if(c)throw new Error(tr(5));var t=!0;return u(),s.push(e),function(){if(t){if(c)throw new Error(tr(6));t=!1,u();var n=s.indexOf(e);s.splice(n,1),a=null}}}function f(e){if(!ir(e))throw new Error(tr(7));if(void 0===e.type)throw new Error(tr(8));if(c)throw new Error(tr(9));try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}return f({type:or.INIT}),(r={dispatch:f,subscribe:d,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw new Error(tr(10));o=e,f({type:or.REPLACE})}})[nr]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(tr(11));function n(){e.next&&e.next(l())}return n(),{unsubscribe:t(n)}}})[nr]=function(){return this},e},r}function sr(e){function t(t){var n=void 0,r=void 0,o=!0,i=!1,a=!1,s=void 0,c=void 0,u=void 0;function l(){if(n){try{if(c){var e=c;s=void 0,c=void 0,u=void 0,e(((r=new Error("Pixie has been destroyed")).name="PixieShutdownError",r))}var t=n;n=void 0,t.destroy()}catch(r){d(r)}a=!0}var r}function d(e){a||t.onError(e),l()}function f(){i=!1,p()}function p(){for(;n&&o&&!i;){o=!1,i=!0;try{var e=n.update(r);e&&"function"==typeof e.then?e.then(f,d):i=!1}catch(t){d(t)}}}function h(){return s||(s=new Promise((function(e,t){u=e,c=t}))),s}var y={onError:d,onOutput:function(e){a||t.onOutput(e)},get props(){return r},nextProps:h,waitFor:function(e){return new Promise((function(t,n){return function o(){try{var i=e(r);null!=i?t(i):h().then(o,n)}catch(a){n(a)}}()}))}};try{n=function(e){return"function"==typeof e?{update:e,destroy:function(){}}:e}(e(y))}catch(b){d(b)}return{update:function(e){if(r=e,o=!0,u){var t=u;s=void 0,c=void 0,u=void 0,t(e)}p()},destroy:l}}return t.tame=!0,t.defaultOutput=e.defaultOutput,t}function cr(e){return e.tame?e:sr(e)}function ur(e,t,n){n(e)}var lr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},dr=(function(){function e(e){this.value=e}function t(t){var n,r;function o(n,r){try{var a=t[n](r),s=a.value;s instanceof e?Promise.resolve(s.value).then((function(e){o("next",e)}),(function(e){o("throw",e)})):i(a.done?"return":"normal",a.value)}catch(c){i("throw",c)}}function i(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise((function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};r?r=r.next=s:(n=r=s,o(e,t))}))},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),fr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};function pr(e){}function hr(e){}function yr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:hr;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ur,n=cr(e);function r(e){var r=e.onOutput,o=void 0,i=void 0,a=function(){var e=o;o=void 0,e&&e.destroy()},s={onError:function(n){a();try{t(n,i,e.onError)}catch(n){e.onError(n)}},onOutput:r};return{update:function(e){i=e,o||(o=n(s)),o.update(e)},destroy:a}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}(function(e){var t=cr(e);function n(n){var r=n.onError,o=void 0,i=e.defaultOutput,a=void 0,s=!0,c=!1,u=function(){for(;o&&s&&!c;)s=!1,c=!0,o.update(fr({},a,{output:i})),c=!1},l={onError:r,onOutput:function(e){e!==i&&(i=e,s=!0,n.onOutput(e),u())}};return{update:function(e){a=e,s=!0,o||(o=t(l)),u()},destroy:function(){var e=o;o=void 0,e&&e.destroy()}}}return n.tame=!0,n.defaultOutput=e.defaultOutput,n}(e))({onError:t,onOutput:n})}function br(e){var t={},n=Object.keys(e),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var i;if(r){if(o>=n.length)break;i=n[o++]}else{if((o=n.next()).done)break;i=o.value}var a=i;t[a]=e[a].defaultOutput}function s(n){var r=n.onError,o={},i={},a=fr({},t),s=!1,c=function(){if(l){if(d>=u.length)return"break";f=u[d++]}else{if((d=u.next()).done)return"break";f=d.value}var t=f;if(o[t]={onError:r,onOutput:function(e){e!==a[t]&&((a=fr({},a))[t]=e,n.onOutput(a))}},i[t]=cr(e[t])(o[t]),s)return"break"},u=Object.keys(e),l=Array.isArray(u),d=0;for(u=l?u:u[Symbol.iterator]();;){var f;if("break"===c())break}return{update:function(e){var t=Object.keys(i),n=Array.isArray(t),r=0;for(t=n?t:t[Symbol.iterator]();;){var o;if(n){if(r>=t.length)break;o=t[r++]}else{if((r=t.next()).done)break;o=r.value}if(i[o].update(e),s)return}},destroy:function(){s=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}i[r].destroy()}}}}return s.tame=!0,s.defaultOutput=t,s}function gr(e,t){return function(){try{return e.apply(void 0,arguments)}catch(n){t(n)}}}function wr(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":lr(e)))return!1;if("object"!==(void 0===t?"undefined":lr(t)))return!1;if(!e||!t)return!1;var n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;var r=n,o=Array.isArray(r),i=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(i>=r.length)break;a=r[i++]}else{if((i=r.next()).done)break;a=i.value}var s=a;if(!Object.prototype.hasOwnProperty.call(t,s)||e[s]!==t[s])return!1}return!0}function vr(e,t){var n=cr(e);function r(e){var r=e.onError,o=e.onOutput,i=void 0,a=void 0,s=!1,c=gr(t,r),u={onError:r,onOutput:o};return{update:function(e){var t=c(e);if(!s){var r=!wr(t,a);if(a=t,t){if(i||(i=n(u)),s)return;r&&i.update(t)}else i&&i.destroy(),i=void 0}},destroy:function(){s=!0,i&&i.destroy(),i=void 0}}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}function mr(e,t,n){var r=cr(e);function o(e){var o=e.onError,i={},a={},s=!1,c={},u=!1,l=!1,d=gr(t,o),f=gr(n,o),p=function(){if(s&&!u){s=!1;var t={},n=Object.keys(i),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var c;if(r){if(o>=n.length)break;c=n[o++]}else{if((o=n.next()).done)break;c=o.value}var l=c;t[l]=a[l]}a=t,e.onOutput(a)}};return{update:function(e){var t=d(e);if(!l&&t){u=!0;var n={},h=function(){if(b){if(g>=y.length)return"break";w=y[g++]}else{if((g=y.next()).done)return"break";w=g.value}var t=w,u=f(e,t);if(l)return{v:void 0};var d=!wr(u,c[t]);if(c[t]=u,u){if(!i[t]){if(i[t]=r({onError:o,onOutput:function(e){e!==a[t]&&(a[t]=e,s=!0,p())}}),l)return{v:void 0}}if(d&&i[t].update(u),l)return{v:void 0};n[t]=i[t]}};var y=t,b=Array.isArray(y),g=0;e:for(y=b?y:y[Symbol.iterator]();;){var w,v=h();if("break"===v)break e;if("object"===(void 0===v?"undefined":lr(v)))return v.v}var m=i;i=n;var I=Object.keys(m),E=Array.isArray(I),S=0;for(I=E?I:I[Symbol.iterator]();;){var O;if(E){if(S>=I.length)break;O=I[S++]}else{if((S=I.next()).done)break;O=S.value}var A=O;n[A]||(s=!0,m[A].destroy())}l||(u=!1,p())}},destroy:function(){l=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}var o=r;i[o]&&i[o].destroy()}}}}return o.tame=!0,o.defaultOutput={},o}!function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.props=t}dr(e,[{key:"update",value:function(e,t){}},{key:"destroy",value:function(e,t){}}])}();var Ir={then:function(){}};function Er(e){const t=ve(e);return{async load(t,n){try{return e(JSON.parse(await t.getText(n)))}catch(r){}},async save(e,n,r){await e.setText(n,JSON.stringify(t(r)))}}}const Sr=e=>{if(null==e||"object"!=typeof e)throw new TypeError("Expected a JSON object");return e},Or="client.json",Ar=Er(ye({clientId:Ae,duressEnabled:ge(ce,!1),loginWaitTimestamps:ge(ye(ue),(()=>({})))})),Tr="infoCache.json",_r=ye({corePlugins:ye(Sr),syncServers:he(le)}),kr=Er(_r);function xr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Pr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xr(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Mr(e,t,n){return function(){let r="";for(let e=0;e<arguments.length;++e){const t=arguments[e];e>0&&(r+=" "),"string"==typeof t?r+=t:t instanceof Error?r+=String(t):r+=JSON.stringify(t,null,2)}e({message:r,source:n,time:new Date,type:t})}}function Cr(e,t){const{onLog:n,crashReporter:r}=e;return yn(Mr(n,"info",t),{breadcrumb(e,o){const i=new Date;null!=r?r.logBreadcrumb({message:e,metadata:o,source:t,time:i}):(e=`${e} ${JSON.stringify(o,null,2)}`,n({message:e,source:t,time:i,type:"warn"}))},crash(e,o){const i=new Date;if(null!=r)r.logCrash({error:e,metadata:o,source:t,time:i});else{const r=`${String(e)} ${JSON.stringify(o,null,2)}`;n({message:r,source:t,time:i,type:"error"})}},warn:Mr(n,"warn",t),error:Mr(n,"error",t)})}const Nr=we((e=>jt.parse(le(e))),(e=>jt.stringify(e))),jr=Er(ye({SNRP2:xe,SNRP3:ae(xe),SNRP4:ae(xe),ERQ:ae(_e)})),Dr=Er(ye({EMK_LP2:_e,EMK_LRA3:ae(_e),ESyncKey:_e,ELP1:_e})),Rr=Er(ye({TOTP:Oe})),Lr=Er(ye({pin2Key:Nr})),Br=Er(ye({recovery2Key:Nr})),Kr=Er(ye({userName:le}));function Ur(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Fr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ur(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ur(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Wr={};let Gr=!1;const qr=[],zr=[];function $r(){Gr=!0;for(const e of zr)e()}function Hr(e,t,n={}){const{onError:r=(()=>{})}=n;let o,i=!1;function a(){o=void 0,u.started&&(i=!0,new Promise((t=>t(e()))).catch(r).then(c,c))}function s(e){i=!1,u.started&&(o=setTimeout(a,e))}function c(){s(t)}const u={started:!1,setDelay(e){t=e},start(e={}){const{wait:n}=e;u.started=!0,i||null!=o||("number"==typeof n?s(n):!0===n?s(t):a())},stop(){u.started=!1,null!=o&&(clearTimeout(o),o=void 0)}};return u}function Yr(e){return new Promise((t=>setTimeout((()=>t(e)),e)))}function Vr(e,t){const n=Jr(e,t);if(null==n)throw new Error(`Cannot find a currency plugin for wallet type ${t}`);return n}function Jr(e,t){return Object.keys(e).find((n=>e[n].currencyInfo.walletType===t))}function Xr(e,t){const{dispatch:n,state:r}=e.props,o=r.plugins.currencyTools[t];if(null!=o)return o;const i=r.plugins.currency[t].makeCurrencyTools();return n({type:"CURRENCY_TOOLS_LOADED",payload:{pluginId:t,tools:i}}),i}const Zr=ye({dataKey:Ae,syncKey:Ae}),Qr=ve(Zr);function eo(e){const{io:t}=e.props;return{dataKey:t.random(32),syncKey:t.random(20)}}function to(e,t,n){const r={delete(e){return n.delete(e)},async getData(e){const r=await n.getText(e);return un(_e(JSON.parse(r)),t)},async getText(e){const r=await n.getText(e);return cn(_e(JSON.parse(r)),t)},list(e){return n.list(e)},setData(r,o){return n.setText(r,JSON.stringify(rt(ln(e,Uint8Array.from(o),t))))},setText(e,t){return this.setData(e,Dt.parse(t))}};return _(r),r}function no(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}const ro=100;function oo(e,t){return(0,ee.HN)(e.disklet,"local/"+jt.stringify(y.parse(t)))}function io(e,t){const{dataKey:n,syncKey:r}=t,o=(0,ee.HN)(e.disklet,"repos/"+jt.stringify(on(on(r)))),i=(0,ee.HN)(o,"changes"),a=(0,ee.HN)(o,"data");return{dataKey:n,syncKey:r,baseDisklet:o,changesDisklet:i,dataDisklet:a,disklet:to(e,n,(0,ee.Cl)(i,a))}}function ao(e){const t={lastSync:0,lastHash:void 0};return e.baseDisklet.getText("status.json").then((e=>function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?no(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):no(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({lastSync:0},JSON.parse(e)))).catch((()=>t))}async function so(e,t){await Promise.all(Object.keys(t).map((n=>{const r=t[n];return null!=r?e.setText(n,JSON.stringify(rt(r))):e.delete(n)})))}async function co(e,t,n){const{changesDisklet:r,dataDisklet:o,syncKey:i}=t,a=await uo(r).then((e=>Promise.all(e.map((async e=>({path:e,box:_e(JSON.parse(await r.getText(e)))})))))),s=p.stringify(i).toLowerCase(),c=await(()=>{if(0===a.length)return e.readRepo(s,n.lastHash);const t={};for(const e of a)t[e.path]=rt(e.box);return e.updateRepo(s,n.lastHash,{changes:t})})(),{hash:u}=c,l={};for(const f of Object.keys(null!==(d=c.changes)&&void 0!==d?d:{})){var d;const e=c.changes[f];l[f]=null==e?null:_e(e)}return await so(o,l),await Promise.all(a.map((e=>r.delete(e.path)))),n.lastSync=Date.now()/1e3,null!=u&&(n.lastHash=u),await t.baseDisklet.setText("status.json",JSON.stringify(n)),{status:n,changes:l}}async function uo(e,t="",n=ro){const r=await e.list(t),o=Object.keys(r).filter((e=>"file"===r[e])),i=Object.keys(r).filter((e=>"folder"===r[e]));for(const a of i){if(o.length>=n)break;const t=n-o.length,r=await uo(e,a,t);o.push(...r.slice(0,t))}return o}function lo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}const fo=3e4;async function po(e,t){const{dispatch:n,io:r,onError:o}=e.props,i=io(r,Zr(t.keys)),a=oo(r,t.id);_(a);const s=await ao(i);n({type:"STORAGE_WALLET_ADDED",payload:{id:t.id,initialState:{localDisklet:a,paths:i,status:s,lastChanges:[]}}});const c=ho(e,t.id);s.lastSync>0?c.catch((n=>{const{syncKey:r}=t.keys,{lastHash:i}=s;e.props.log.error(`Could not sync ${String(r)} with last hash ${String(i)}: ${String(n)}`),o(n)})):await c}function ho(e,t){const{dispatch:n,syncClient:o,state:i}=e.props,{paths:a,status:s}=i.storageWallets[t];return co(o,a,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lo(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},s)).then((({changes:e,status:r})=>(n({type:"STORAGE_WALLET_SYNCED",payload:{id:t,changes:Object.keys(e),status:r}}),Object.keys(e))))}async function yo(e){try{return{ok:!0,result:await e}}catch(t){return{ok:!1,error:t}}}function bo(e,t){return e.storageWallets[t].paths.disklet}function go(e,t){return e.storageWallets[t].localDisklet}function wo(e,t,n){const r=e.storageWallets[t].paths.dataKey;return jt.stringify(rn(Dt.parse(n),r))}const vo=ye({multiplier:le,name:le,symbol:ae(le)}),mo=ye({currencyCode:le,denominations:he(vo),displayName:le,networkLocation:ae(Sr)}),Io=ye({enabled:ae(ce,!0)}).withRest,Eo=ye({SortIndex:ae(ue,0),Archived:ae(ce,!1),BitcoinSeed:Se,MK:Se,SyncKey:Se}).withRest,So=ye({id:le,archived:ae(ce),deleted:ae(ce),hidden:ae(ce),migratedFromWalletId:ae(le),sortIndex:ae(ue)}),Oo=ye({userSettings:ae(ye(Sr),(()=>({}))),swapSettings:ae(ye(Io),(()=>({})))}).withRest,Ao=ye({customTokens:he(ye({contractAddress:le,currencyCode:le,currencyName:le,denomination:le,denominations:he(vo),isVisible:ae(ce,!0),multiplier:le,walletType:ae(le,"wallet:ethereum")}))});function To(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?To(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):To(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const ko=Er(ye({customTokens:ye(ye(mo))})),xo=Er(Ao),Po="CustomTokens.json",Mo="Settings.json",Co=ge(ye({contractAddress:le}));async function No(e,t,n){const r=await Xr(e,t);if(null!=r.getTokenId)return await r.getTokenId(n);const o=function(e,t){for(const n of Object.keys(e.props.state.currency.wallets)){const r=e.props.output.currency.wallets[n];if(null!=(null==r?void 0:r.engine)&&e.props.state.currency.wallets[n].pluginId===t)return r.engine}}(e,t);if(null==o)throw new Error("A wallet must exist before adding tokens to a legacy currency plugin");if(null==o.addCustomToken)throw new Error(`${t} doesn't support tokens`);const i=Lo(n);if(null==i)throw new Error("A token must have a contract address to be added to a legacy currency plugin");return await o.addCustomToken(_o(_o({},i),n)),jo(i.contractAddress)}function jo(e){return e.toLowerCase().replace(/^0x/,"")}function Do(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=Co(o);return{currencyCode:t,currencyName:n,denominations:r,contractAddress:null==i?void 0:i.contractAddress}}function Ro(e={}){const t=[];for(const n of Object.keys(e))t.push(Do(e[n]));return t}function Lo(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=Co(o);if(null!=i)return{currencyCode:t,currencyName:n,multiplier:r[0].multiplier,contractAddress:i.contractAddress}}async function Bo(e,t){const{dispatch:n,state:r}=e.props;await Promise.all(Object.keys(r.plugins.currency).map((async e=>{var o;const i=r.plugins.currency[e],a=null==i.getBuiltinTokens?function(e){const t={};for(const n of e){const{contractAddress:e}=n;null!=e&&(t[jo(e)]={currencyCode:n.currencyCode,denominations:n.denominations,displayName:n.currencyName,networkLocation:{contractAddress:n.contractAddress}})}return t}(null!==(o=i.currencyInfo.metaTokens)&&void 0!==o?o:[]):await i.getBuiltinTokens();n({type:"ACCOUNT_BUILTIN_TOKENS_LOADED",payload:{accountId:t,pluginId:e,tokens:a}})})))}async function Ko(e,t){const{dispatch:n,state:r}=e.props,{accountWalletInfo:o}=r.accounts[t],i=bo(r,o.id),a=await ko.load(i,Po);if(null!=a){const{customTokens:e}=a;n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:e}})}else{const r=await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=bo(n,r.id),i=await xo.load(o,Mo);if(null==i)return{};const a={};for(const s of i.customTokens){if(!s.isVisible)continue;const e=Jr(n.plugins.currency,s.walletType);if(null==e)continue;null==a[e]&&(a[e]={});const t=jo(s.contractAddress);a[e][t]={currencyCode:s.currencyCode,denominations:s.denominations,displayName:s.currencyName,networkLocation:{contractAddress:s.contractAddress}}}return a}(e,t);n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:r}})}}var Uo=n(7591);function Fo(e){var t;const{currencyInfo:n,allTokens:r}=e;let o=e.tokenId;void 0===o&&null!=e.currencyCode&&e.currencyCode!==n.currencyCode&&(o=Object.keys(r).find((t=>r[t].currencyCode===e.currencyCode)));const{currencyCode:i}=null==o?n:r[o];return{currencyCode:i,tokenId:null!==(t=o)&&void 0!==t?t:null}}function Wo(e){return null!=e.networkFee&&void 0===e.networkFee.tokenId&&(e.networkFee.tokenId=null),e}const Go=e=>{null!=e.networkFees&&0!==e.networkFees.length||(e.networkFees=[{tokenId:e.tokenId,nativeAmount:e.networkFee}],null!=e.parentNetworkFee&&e.networkFees.push({tokenId:null,nativeAmount:e.parentNetworkFee}))};function qo(e,t,n){for(const r of e.denominations)if(r.name===n)return r.multiplier;for(const r of Object.keys(t)){const e=t[r];for(const t of e.denominations)if(t.name===n)return t.multiplier}return"1"}function zo(e,t){return e.waitFor((e=>{if(null==e.state.currency.wallets[t])throw new Error(`Wallet id ${t} does not exist in this account`);const{engineFailure:n}=e.state.currency.wallets[t];if(null!=n)throw n;if(null!=e.output.currency.wallets[t])return e.output.currency.wallets[t].walletApi}))}const $o=ye({id:le,keys:Sr,type:le}),Ho=ve($o);function Yo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Vo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yo(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jo(e,t){return e.find((e=>e.type===t))}function Xo(e){return""===e?"account-repo:co.airbitz.wallet":`account-repo:${e}`}function Zo(e,t,n){const r=rn(Dt.parse(e),null!=n?n:Zr(t).dataKey);return{id:y.stringify(r),type:e,keys:t}}function Qo(e,t,n,r=!1){e.props.log.breadcrumb("makeKeysKit",{});const{io:o}=e.props,i=n.map((e=>Vo({created:new Date},ln(o,Dt.parse(JSON.stringify(Ho(e))),t.loginKey)))),a=[];for(const s of n){const e=ge(Zr)(s.keys);null!=e&&a.push(p.stringify(e.syncKey).toLowerCase())}return{loginId:t.loginId,server:gt({allowExisting:r,keyBoxes:i,newSyncKeys:a}),serverPath:"/v2/login/keys",stash:{keyBoxes:i}}}function ei(e){const t=[],n=new Map;for(const r of e){const{id:e,keys:o,type:i}=r;if(null==e||32!==y.parse(e).length)throw new Error(`Key integrity violation: invalid id ${e}`);const a=n.get(e);if(null!=a){const n=t[a];if(n.type!==i)throw new Error(`Key integrity violation for ${e}: type ${i} does not match ${n.type}`);for(const t of Object.keys(o))if(null!=n.keys[t]&&n.keys[t]!==o[t])throw new Error(`Key integrity violation for ${e}: ${t} keys do not match`);t[a]={id:e,keys:Vo(Vo({},n.keys),o),type:i}}else n.set(e,t.length),t.push(r)}return t}function ti(e,t,n=new Map){const{appId:r,keyBoxes:o=[]}=e,i=[],{mnemonicBox:a,rootKeyBox:s}=e;if(null!=a&&null!=s){const e=un(s,t),n={mnemonic:cn(a,rn(e,Dt.parse("infoKey"))),rootKey:y.stringify(e)};i.push(Zo("wallet:bitid",n,e))}if(null!=e.syncKeyBox){const n=un(e.syncKeyBox,t),o=Xo(r),a=Qr({dataKey:t,syncKey:n});i.push(Zo(o,a,t))}const c=o.map((e=>{const r=$o(JSON.parse(cn(e,t))),o=(i=e.created,a=n.get(r.id),null==i?a:null==a?i:new Date(Math.min(i.valueOf(),a.valueOf())));var i,a;return null!=o&&n.set(r.id,o),r}));return ei([...i,...c]).map((e=>ni(e)))}function ni(e){const{id:t,keys:n,type:r}=e,o={"wallet:bitcoin-bip44":{format:"bip44",coinType:0},"wallet:bitcoin-bip49":{format:"bip49",coinType:0},"wallet:bitcoincash-bip32":{format:"bip32"},"wallet:bitcoincash-bip44":{format:"bip44",coinType:145},"wallet:bitcoincash-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip49-testnet":{format:"bip49",coinType:1},"wallet:dash-bip44":{format:"bip44",coinType:5},"wallet:dogecoin-bip44":{format:"bip44",coinType:3},"wallet:litecoin-bip44":{format:"bip44",coinType:2},"wallet:litecoin-bip49":{format:"bip49",coinType:2},"wallet:feathercoin-bip49":{format:"bip49",coinType:8},"wallet:feathercoin-bip44":{format:"bip44",coinType:8},"wallet:qtum-bip44":{format:"bip44",coinType:2301},"wallet:ufo-bip49":{format:"bip49",coinType:202},"wallet:ufo-bip84":{format:"bip84",coinType:202},"wallet:zcoin-bip44":{format:"bip44",coinType:136},"wallet:bitcoin-testnet":{format:"bip32"},"wallet:bitcoin":{format:"bip32"},"wallet:bitcoincash-testnet":{format:"bip32"},"wallet:litecoin":{format:"bip32",coinType:2},"wallet:zcoin":{format:"bip32",coinType:136}};return null!=o[r]?{id:t,keys:Vo(Vo({},o[r]),n),type:r.replace(/-bip[0-9]+/,"")}:e}async function ri(e,t,n){const{importText:r,keyOptions:o,keys:i}=n;function a(n,r){return null!=r&&(n=Vo(Vo({},n),{},{imported:r})),ni(Zo(t,Vo(Vo({},Qr(eo(e))),n)))}if(null!=i)return a(i);const s=Vr(e.props.state.plugins.currency,t),c=await Xr(e,s);if(null!=r){if(null==c.importPrivateKey)throw new Error("This wallet does not support importing keys");return a(await c.importPrivateKey(r,o),!0)}return a(await c.createPrivateKey(t,o),!1)}async function oi(e,t,n,r){const{enabledTokenIds:o,fiatCurrencyCode:i,migratedFromWalletId:a,name:s}=r,c=await zo(e,n);return null!=a&&await hi(e,t,{[n]:{migratedFromWalletId:a}}),null!=s&&await c.renameWallet(s),null!=i&&await c.setFiatCurrencyCode(i),null!=o&&o.length>0&&await c.changeEnabledTokenIds(o),c}function ii(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ai(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ii(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ii(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const si=Er(Eo),ci=Er(So),ui=Er(Oo),li=Oo({}),di="PluginSettings.json";function fi(e,t){for(const n of Object.keys(t))if(e[n]!==t[n])return!0;return!1}async function pi(e,t){const n=e.props.state.accounts[t],{accountWalletInfo:r,accountWalletInfos:o}=n,i=await Promise.all(o.map((t=>async function(e){const t=[],n={},r=(0,ee.gQ)(await e.list("Wallets"));return await Promise.all(r.map((async r=>{const o=await si.load(e,r);if(null==o)return;const i=Zo("wallet:bitcoin",ai(ai({},Qr({dataKey:o.MK,syncKey:o.SyncKey})),{},{bitcoinKey:y.stringify(o.BitcoinSeed),format:"bip32"}),o.MK);t.push(i),n[i.id]={archived:o.Archived,deleted:!1,hidden:!1,migratedFromWalletId:void 0,sortIndex:o.SortIndex}}))),{walletInfos:t,walletStates:n}}(bo(e.props.state,t.id))))),a=await async function(e){const t={},n=(0,ee.gQ)(await e.list("Keys"));return await Promise.all(n.map((async n=>{const r=await ci.load(e,n);if(null==r)return;const{id:o,archived:i,deleted:a,hidden:s,migratedFromWalletId:c,sortIndex:u}=r;t[o]={archived:i,deleted:a,hidden:s,sortIndex:u,migratedFromWalletId:c}}))),t}(bo(e.props.state,r.id)),s=[];for(const l of i)s.push(...l.walletInfos);const c=i.map((e=>e.walletStates)),u=Object.assign({},...c,a);e.props.dispatch({type:"ACCOUNT_KEYS_LOADED",payload:{accountId:t,legacyWalletInfos:s,walletStates:u}})}async function hi(e,t,n){const{accountWalletInfo:r,walletStates:o}=e.props.state.accounts[t],i=bo(e.props.state,r.id),a={};for(const c of Object.keys(n))null==o[c]?a[c]=n[c]:fi(o[c],n[c])&&(a[c]=ai(ai({},o[c]),n[c]));const s=Object.keys(a);s.length<1||(await Promise.all(s.map((async t=>{const{archived:n,deleted:o,hidden:s,migratedFromWalletId:c,sortIndex:u}=a[t],l=wo(e.props.state,r.id,t);await ci.save(i,`Keys/${l}.json`,{archived:n,deleted:o,hidden:s,id:t,migratedFromWalletId:c,sortIndex:u})}))),e.props.dispatch({type:"ACCOUNT_CHANGED_WALLET_STATES",payload:{accountId:t,walletStates:ai(ai({},o),a)}}))}async function yi(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=bo(e.props.state,i.id),s=null!==(o=await ui.load(a,di))&&void 0!==o?o:li;await ui.save(a,di,ai(ai({},s),{},{userSettings:ai(ai({},e.props.state.accounts[t].userSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,userSettings:ai({},r)}})}async function bi(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=bo(e.props.state,n.id),o=await ui.load(r,di),{userSettings:i,swapSettings:a}=null!=o?o:{userSettings:{},swapSettings:{}};e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_LOADED",payload:{accountId:t,userSettings:i,swapSettings:a}})}function gi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gi(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vi(e,t){const{id:n,type:r,keys:o}=e,i=ge(Zr)(o);if(null==i)throw new Error(`Wallet ${n} is not a splittable type`);const{dataKey:a,syncKey:s}=i,c=Ii(rn(Dt.parse(r),a),rn(Dt.parse(t),a)),u=Ii(y.parse(n),c),l=Ii(s,c.subarray(0,s.length)),d=r.replace(/wallet:/,"").replace("-",""),f=t.replace(/wallet:/,"").replace("-",""),p=Qr({dataKey:a,syncKey:l});for(const h of Object.keys(o)){const e=h===d+"Key"?f+"Key":h;null==p[e]&&(p[e]=o[h])}return{id:y.stringify(u),keys:p,type:t}}async function mi(e,t,n,r,o){const i=e.props.state.accounts[t],{allWalletInfosFull:a,sessionKey:s}=i,c=e.props.state.plugins.currency,u=new Map;for(const h of r){const{walletType:e}=h;if(null==Jr(c,h.walletType))throw new Error(`Cannot find plugin for wallet type "${e}"`);if(u.has(e))throw new Error(`Duplicate wallet type "${e}"`);u.set(e,vi(n,e))}if("wallet:bitcoincash"===n.type&&u.has("wallet:bitcoinsv")){var l;const t=null===(l=e.props.output)||void 0===l||null===(l=l.currency)||void 0===l||null===(l=l.wallets[n.id])||void 0===l?void 0:l.walletApi;if(null==t)throw new Error(`Cannot find wallet ${n.id}`);await async function(e){const t={currencyCode:"BCH",tokenId:null},n=wi(wi({},t),{},{spendTargets:[{nativeAmount:"10000",otherParams:{script:{type:"replayProtection"}},publicAddress:""}],metadata:{},networkFeeOption:"high"}),r=await e.makeSpend(n),o=await e.signTx(r),i=await e.broadcastTx(o);await e.saveTx(i);const{publicAddress:a}=await e.getReceiveAddress(t),s=wi(wi({},t),{},{metadata:{name:"Replay Protection Tx",notes:"This transaction is to protect your BCH wallet from unintentionally spending BSV funds. Please wait for the transaction to confirm before making additional transactions using this BCH wallet."},networkFeeOption:"high",spendTargets:[{publicAddress:a,nativeAmount:"0"}]}),c=await e.getMaxSpendable(s);s.spendTargets[0].nativeAmount=c;const u=await e.makeSpend(s),l=await e.signTx(u),d=await e.broadcastTx(l);await e.saveTx(d)}(t)}const d=[],f=[];for(const h of u.values()){const e=a.find((e=>e.id===h.id));if(null==e)f.push(h);else if(e.archived||e.deleted)d.push(e);else if(o&&("wallet:bitcoincash"!==n.type||"wallet:bitcoinsv"!==h.type))throw new Error(`This wallet has already been split (${h.type})`)}if(d.length>0){const n={};let r=!1;for(const e of d)(e.archived||e.deleted)&&(r=!0,n[e.id]={archived:!1,deleted:!1,migratedFromWalletId:e.migratedFromWalletId});r&&await hi(e,t,n)}if(f.length>0){const t=Qo(e,s,f,!0);await Yn(e,s,t)}const p=await Promise.all(r.map((async t=>{const n=u.get(t.walletType);if(null==n)throw new Error(`Missing wallet info for ${t.walletType}`);return await yo(async function(e,t,n){const r=await zo(e,t);null!=(null==n?void 0:n.name)&&await r.renameWallet(n.name).catch((t=>e.props.onError(t)));null!=(null==n?void 0:n.fiatCurrencyCode)&&await r.setFiatCurrencyCode(n.fiatCurrencyCode).catch((t=>e.props.onError(t)));return r}(e,n.id,null!=f.find((e=>e.type===t.walletType))?t:void 0))})));return p}function Ii(e,t){if(e.length!==t.length)throw new Error(`Array lengths do not match: ${e.length}, ${t.length}`);const n=new Uint8Array(e.length);for(let r=0;r<e.length;++r)n[r]=e[r]^t[r];return n}function Ei(e,t){const{id:n,type:r,keys:o}=t;return{id:n,type:r,keys:o,get disklet(){return bo(e.props.state,n)},get localDisklet(){return go(e.props.state,n)},async sync(){await ho(e,n)}}}const Si={"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Int8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0};function Oi(e,t){if(e===t)return!0;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;const n=Object.prototype.toString.call(e);return n===Object.prototype.toString.call(t)&&function(e,t,n){if("[object Object]"===n){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Oi(e[r],t[r]))return!1;return!0}if("[object Array]"===n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!Oi(e[n],t[n]))return!1;return!0}if("[object Date]"===n)return e.getTime()===t.getTime();if("[object Map]"===n)return function(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0}(e,t);if(Si[n]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}(e,t,n)}let Ai=500,Ti=3;const _i=[];let ki;function xi(e){_i.length<=0&&Pi();let t=!1;for(const n of _i)if(n.id===e.id&&n.action===e.action){n.updateFunc=e.updateFunc,t=!0;break}t||_i.push(e)}function Pi(){ki=setTimeout((()=>{const e=Math.min(Ti,_i.length);for(let t=0;t<e;t++){const e=_i.shift();null!=e&&e.updateFunc()}_i.length>0&&Pi()}),Ai)}function Mi(e,t){var n,r,o,i,a,s;const c={exchangeAmount:{}},{exchangeAmount:u={}}=c,l=null!==(n=e.exchangeAmount)&&void 0!==n?n:{},d=null!==(r=t.exchangeAmount)&&void 0!==r?r:{};for(const f of Object.keys(l))null!==d[f]&&(u[f]=l[f]);for(const f of Object.keys(d)){const e=d[f];null!=e&&(u[f]=e)}return null!==t.bizId&&(c.bizId=null!==(o=t.bizId)&&void 0!==o?o:e.bizId),null!==t.category&&(c.category=null!==(i=t.category)&&void 0!==i?i:e.category),null!==t.name&&(c.name=null!==(a=t.name)&&void 0!==a?a:e.name),null!==t.notes&&(c.notes=null!==(s=t.notes)&&void 0!==s?s:e.notes),c}const Ci=ye({bizId:ae(ue),category:ae(le),exchangeAmount:ae(ye(ue)),name:ae(le),notes:ae(le)}),Ni=be(le,de),ji=se("high","standard","low"),Di=ye({orderId:ae(le),orderUri:ae(le),isEstimate:ce,plugin:ye({pluginId:le,displayName:le,supportEmail:ae(le)}),payoutAddress:le,payoutCurrencyCode:le,payoutTokenId:ae(Ni),payoutNativeAmount:le,payoutWalletId:le,refundAddress:ae(le)});function Ri(e){const t=le(e);if(!/^\d+$/.test(t))throw new Error("Expected an integer string");return t}const Li=ye({pluginId:le,tokenId:Ni,nativeAmount:ae(Ri)}),Bi=ye({fiatCurrencyCode:le,fiatAmount:le}),Ki=ye({pluginId:le,displayName:le,isDex:ae(ce),orderUri:ae(le),supportEmail:le}),Ui=be(ye({actionType:se("swap"),swapInfo:Ki,orderId:ae(le),orderUri:ae(le),isEstimate:ae(ce),canBePartial:ae(ce),fromAsset:Li,toAsset:Li,payoutWalletId:le,payoutAddress:le,refundAddress:ae(le)}),ye({actionType:se("stake"),pluginId:le,stakeAssets:he(Li)}),ye({actionType:se("fiat"),orderId:le,orderUri:ae(le),isEstimate:ce,fiatPlugin:ye({providerId:le,providerDisplayName:le,supportEmail:ae(le)}),payinAddress:ae(le),payoutAddress:ae(le),fiatAsset:Bi,cryptoAsset:Li}),ye({actionType:se("tokenApproval"),tokenApproved:Li,tokenContractAddress:le,contractAddress:le}),ye({actionType:se("giftCard"),orderId:le,orderUri:ae(le),productId:ae(le),quoteId:ae(le),provider:ye({providerId:le,displayName:le,supportEmail:ae(le)}),card:ye({name:le,imageUrl:ae(le),fiatAmount:le,fiatCurrencyCode:le}),redemption:ae(ye({code:ae(le),url:ae(le)}))})),Fi=ye({assetActionType:se("claim","claimOrder","stake","stakeNetworkFee","stakeOrder","unstake","unstakeNetworkFee","unstakeOrder","swap","swapNetworkFee","swapOrderPost","swapOrderFill","swapOrderCancel","buy","sell","sellNetworkFee","tokenApproval","transfer","transferNetworkFee","giftCard")}),Wi=he(le),Gi=ye({enabledTokenIds:he(le),detectedTokenIds:he(le)}),qi=ye({assetAction:ae(Fi),metadata:e=>{const t=Ci(e),{exchangeAmount:n={}}=t;for(const r of Object.keys(n))String(n[r]).includes("e")&&delete n[r];return t},nativeAmount:ae(le),providerFeeSent:ae(le)}),zi=ye({txid:le,internal:ce,creationDate:ue,currencies:function(e){const t=ye(e);return we((e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(t,n[t]);return r}),(e=>{const n={};return e.forEach(((e,t)=>{n[t]=e})),t(n)}))}(qi),tokens:ae(function(e){const t=ye(e);return we((e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(""===t?null:t,n[t]);return r}),(e=>{const n={};return e.forEach(((e,t)=>{n[null==t?"":t]=e})),t(n)}))}(qi),(()=>new Map)),deviceDescription:ae(le),feeRateRequested:ae(be(ji,Sr)),feeRateUsed:ae(Sr),payees:ae(he(ye({address:le,amount:le,currency:le,tag:ae(le)}))),savedAction:ae(Ui),secret:ae(le),swap:ae(Di)}),$i=ye({airbitzFeeWanted:ue,meta:ye({amountFeeAirBitzSatoshi:ue,balance:ue,fee:ue,amountCurrency:ue,bizId:ue,category:le,name:le,notes:le,attributes:ue,amountSatoshi:ue,amountFeeMinersSatoshi:ue,airbitzFee:ue}),ntxid:le,state:ye({creationDate:ue,internal:ce,malleableTxId:le})}),Hi=ye({seq:ue,address:le,state:ye({recycleable:ae(ce,!0),creationDate:ae(ue,0)}),meta:ye({amountSatoshi:ae(ue,0)}).withRest}),Yi=ye(ye({timestamp:ue,txidHash:le})),Vi=ye({walletInfo:ye({id:le,keys:Sr,type:le})}),Ji=ye({checkpoint:ae(le),subscribedAddresses:ae(he(ye({address:le,checkpoint:ae(le)})),(()=>[]))}),Xi=ye({fiat:ae(le),num:ae(ue)}),Zi=ye({walletName:be(le,de)});var Qi=n(3546);function ea(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}const ta=En;function na(e,t){return e+t}async function ra(e,t,n,r){return await async function(e,t,n,r){const{now:o=new Date}=r,{passwordBox:i,passwordKeySnrp:a,username:s}=t;if(null==i||null==a||null==s)throw new Error("Missing data for offline password login");const c=na(s,n),u=await In(e,c,a),l={loginId:t.loginId,loginKey:un(i,u)};t.lastLogin=o,Pn(e,t).catch((()=>{}));const{log:d}=e.props;return Jn(e,l).catch((e=>d.error(e))),l}(e,t,n,r).catch((()=>async function(e,t,n,r){const{username:o}=t;if(null==o)throw new Error("Password login requires a username");const i=na(o,n),[a,s]=await Promise.all([kn(e,o),In(e,i,ta)]),c={userId:a,passwordAuth:s};return await Hn(e,t,t,r,c,(async t=>{const{passwordBox:n,passwordKeySnrp:r}=t;if(null==n||!0===n||null==r)throw new Error("Missing data for online password login");return un(n,await In(e,i,r))}))}(e,t,n,r)))}async function oa(e,t,n,r){const o=na(n,r),{io:i}=e.props,[{passwordKeySnrp:a,passwordBox:s},{passwordAuth:c,passwordAuthBox:u}]=await Promise.all([mn(e).then((async n=>{const r=await In(e,o,n);return{passwordKeySnrp:n,passwordBox:ln(i,t.loginKey,r)}})),In(e,o,ta).then((e=>({passwordAuth:e,passwordAuthBox:ln(i,e,t.loginKey)})))]);return{loginId:t.loginId,server:ut({passwordAuth:c,passwordAuthSnrp:ta,passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}),serverPath:"/v2/login/password",stash:{passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}}}function ia(e,t){return rn(null==t?Uint8Array.from([0]):Dt.parse(t),e)}function aa(e,t){return rn(Dt.parse(t),e)}function sa(e,t){if(null!=e.pin2Key)return e;const n=Un(e,(e=>e.appId===t));return null!=(null==n?void 0:n.pin2Key)?n:void 0}async function ca(e,t,n,r,o){if(null==n.pin2Key)throw new Wt("PIN login is not enabled for this account on this device");const{pin2Key:i}=n,a={pin2Id:ia(i,t.username),pin2Auth:aa(i,r)};return await Hn(e,t,n,o,a,(async e=>{if(null==e.pin2Box||!0===e.pin2Box)throw new Error("Missing data for PIN v2 login");return un(e.pin2Box,i)}))}async function ua(e,t,n){const r=e.props.state.accounts[t],o=r.activeAppId.endsWith(".duress"),{loginTree:i,login:a,sessionKey:s}=r,{username:c}=r.stashTree;let{pin:u,enableLogin:l,forDuressAccount:d=!1}=n;if(null==l&&(l=null!=i.pin2Key||null!=u&&null==i.pin),null==u&&(u=a.pin),o&&!d)return await Vn(e,s,da(e,i,c,l,!0)),void(null!=u&&await Vn(e,s,la(e,i,c,u,!0,!0)));if(null==u){if(l)throw new Error("Please change your PIN in the settings area above before enabling.");return void(await Vn(e,s,pa(i,d||o)))}const f=la(e,i,c,u,l,d||o);await Vn(e,s,f)}function la(e,t,n,r,o,i){const a=[];i===t.appId.endsWith(".duress")&&a.push(fa(e,t,n,r,o));for(const s of t.children)a.push(...la(e,s,n,r,o,i));return a}function da(e,t,n,r,o){const i=[];o===t.appId.endsWith(".duress")&&i.push(function(e,t){const{loginId:n}=e;return{loginId:n,server:void 0,serverPath:"",stash:{fakePinDisabled:!t}}}(t,r));for(const a of t.children)i.push(...da(e,a,n,r,o));return i}function fa(e,t,n,r,o){const{io:i}=e.props,a=ln(i,Dt.parse(r),t.loginKey);if(o){const{loginId:e,loginKey:o,pin2Key:s=i.random(32)}=t,c=ln(i,o,s),u=ln(i,s,o);return{loginId:e,server:dt({pin2Id:ia(s,n),pin2Auth:aa(s,r),pin2Box:c,pin2KeyBox:u,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:s,pin2TextBox:a}}}return{loginId:t.loginId,server:dt({pin2Id:void 0,pin2Auth:void 0,pin2Box:void 0,pin2KeyBox:void 0,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:void 0,pin2TextBox:a}}}function pa(e,t){const n=[];null!=t&&t!==e.appId.endsWith(".duress")||n.push(function(e){return{loginId:e.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/pin2",stash:{pin2Key:void 0}}}(e));for(const r of e.children)n.push(...pa(r,t));return n}function ha(e,t){return rn(Dt.parse(t),e)}function ya(e,t){return t.map((t=>rn(Dt.parse(t),e)))}async function ba(e,t,n,r){const o=e.props.state.accounts[t],{loginTree:i,sessionKey:a}=o,{username:s}=o.stashTree;if(null==s)throw new Error("Recovery login requires a username");const c=function(e,t,n,r,o){const{io:i}=e.props;if(!Array.isArray(r))throw new TypeError("Questions must be an array of strings");if(!Array.isArray(o))throw new TypeError("Answers must be an array of strings");const{loginId:a,loginKey:s,recovery2Key:c=i.random(32)}=t,u=ln(i,Dt.parse(JSON.stringify(wa(r))),c),l=ln(i,s,c),d=ln(i,c,s);return{loginId:a,server:pt({recovery2Id:ha(c,n),recovery2Auth:ya(c,o),recovery2Box:l,recovery2KeyBox:d,question2Box:u}),serverPath:"/v2/login/recovery2",stash:{recovery2Key:c}}}(e,i,s,n,r);await Yn(e,a,c)}const ga=he(le),wa=ve(ga);function va(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ma(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?va(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):va(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function Ia(e,t,n){var r,o,i,a;const{password:s,username:c}=n,{isRoot:u,loginId:l,passwordAuth:d}=t;if(null!=d&&null==s)throw new Error("A password is required to change the username");const f=function(e,t){const{loginId:n,pin2Key:r}=e;if(null!=r)return{loginId:n,server:lt({pin2Id:ia(r,t)}),serverPath:"",stash:{}}}(t,c),p=function(e,t){const{loginId:n,recovery2Key:r}=e;if(null!=r)return{loginId:n,server:ft({recovery2Id:ha(r,t)}),serverPath:"",stash:{}}}(t,c);let h,y;if(null!=s&&(h=await oa(e,t,c,s)),u&&(y=await Ea(e,t,c)),null!=h||null!=f||null!=p||null!=y)return{loginId:l,server:ma(ma(ma(ma({},null===(r=h)||void 0===r?void 0:r.server),null==f?void 0:f.server),null==p?void 0:p.server),null===(o=y)||void 0===o?void 0:o.server),serverPath:"/v2/login/username",stash:ma(ma(ma(ma({},null===(i=h)||void 0===i?void 0:i.stash),null==f?void 0:f.stash),null==p?void 0:p.stash),null===(a=y)||void 0===a?void 0:a.stash)}}async function Ea(e,t,n){const{io:r}=e.props,{loginId:o,loginKey:i}=t,a=await kn(e,n);return{loginId:o,server:yt({userId:a,userTextBox:ln(r,Dt.parse(n),i)}),serverPath:"",stash:{userId:a,username:n}}}function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Oa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Sa(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function Aa(e,t,n,r){var o,i,a,s,c,u,l,d;const{keyInfo:f,password:p,pin:h,username:y}=r,{io:b}=e.props;e.props.log.breadcrumb("makeCreateKit",{});const g=null==t,w=b.random(32),v=b.random(32),m={loginId:w,loginKey:v},I={appId:n,lastLogin:new Date,loginId:w,loginKey:v,isRoot:g,pendingVouchers:[],children:[]},E=vn(e,I);let S,O,A,T,_;null!=f&&(S=Qo(e,m,[f])),null!=t&&(O=ln(b,v,t.loginKey)),null!=p&&null!=y&&(A=await oa(e,I,y,p)),null!=h&&(T=fa(e,I,y,h,!0)),g&&null!=y&&(_=await Ea(e,I,y));return{kit:{loginId:w,server:Oa(Oa(Oa(Oa(Oa(Oa({},wt({appId:n,loginId:w,parentBox:O})),null===(o=S)||void 0===o?void 0:o.server),null===(i=A)||void 0===i?void 0:i.server),null===(a=T)||void 0===a?void 0:a.server),E.server),null===(s=_)||void 0===s?void 0:s.server),serverPath:"/v2/login/create",stash:Oa(Oa(Oa(Oa(Oa({appId:n,loginId:w,parentBox:O},null===(c=S)||void 0===c?void 0:c.stash),null===(u=A)||void 0===u?void 0:u.stash),null===(l=T)||void 0===l?void 0:l.stash),E.stash),null===(d=_)||void 0===d?void 0:d.stash)},sessionKey:m}}async function Ta(e,t,n,r){const{log:o}=e.props,i=Un(t,(e=>e.appId===r));if(null==i)return e.props.log.breadcrumb("createChildLogin",{}),await async function(e,t,n,r){let o;null!=t.pin2TextBox&&(o=cn(t.pin2TextBox,n.loginKey));const{kit:i}=await Aa(e,n,r,{keyInfo:Zo(Xo(r),Qr(eo(e))),pin:o,username:t.username}),a={loginId:n.loginId,server:i.server,serverPath:i.serverPath,stash:{children:[i.stash]}};return await Yn(e,n,a)}(e,t,n,r);const a=Xn(t,n,i.loginId),s=ti(i,a.loginKey);o.warn(`Login: decrypted keys for user ${y.stringify(t.loginId)}`);const c=Xo(r);if(null==Jo(s,c)){e.props.log.breadcrumb("createAccountRepo",{});const t=Qo(e,a,[Zo(c,Qr(eo(e)))]);return await Yn(e,n,t)}return t}async function _a(e,t,n,r){const{pauseWallets:o=!1}=r,i=!0===r.duressMode?e.props.state.login.contextAppId+".duress":e.props.state.login.contextAppId,{log:a}=e.props;e.props.log.breadcrumb("makeAccount",{});const{stashTree:s}=An(e,t.loginId);return await Ta(e,s,t,i),a.warn("Login: account exists for appId"),e.props.dispatch({type:"LOGIN",payload:{appId:i,loginType:n,pauseWallets:o,rootLoginId:s.loginId,sessionKey:t}}),await function(e,t){const n=e.waitFor((e=>{const n=e.state.accounts[t];if(null!=n.loadFailure)throw n.loadFailure;const r=e.output.accounts[t];if(null!=(null==r?void 0:r.accountApi))return r.accountApi}));return n}(e,e.props.state.lastAccountId)}var ka=n(6266);function xa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xa(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ma=new(0,n.n(ka)().ec)("secp256k1");function Ca(e,t){const n=e.derive(Ma.keyFromPublic(t).getPublic()).toArray("be");return rn(Uint8Array.from([0,0,0,1,...n]),Dt.parse("dataKey"))}function Na(e,t){const{publicKey:n}=t,r=Ca(e,n);return JSON.parse(cn(t.box,r))}function ja(e,t,n){const r=Ma.genKeyPair({entropy:e.random(32)}),o=Ca(r,t);return{publicKey:Uint8Array.from(r.getPublic().encodeCompressed()),box:ln(e,Dt.parse(JSON.stringify(n)),o)}}async function Da(e,t,n=1e3){const{io:r}=e.props,{timeout:o=600}=t,i=Ma.genKeyPair({entropy:r.random(32)}),a=Uint8Array.from(i.getPublic().encodeCompressed()),s=jt.stringify(on(on(a)).slice(0,10)),c={data:it(Pa(Pa({},t),{},{publicKey:a,timeout:o}))};await gn(e,"PUT",`/v2/lobby/${s}`,c);const[u,l]=(d={},[function(e,t){var n=d[e];return null==n&&(n=d[e]=function(){var e=[],t=!1;function n(){t&&(t=!1,e=e.slice())}return[function(t){n(),e.push(t);var r=!0;return function(){r&&(r=!1,n(),e.splice(e.indexOf(t),1))}},function(n){t=!0;for(var r=e,o=0;o<r.length;++o)r[o](n);t=!1}]}()),n[0](t)},function(e,t){var n=d[e];null!=n&&n[1](t)}]);var d;const f=[],p=Hr((async()=>{const t=Ye(await gn(e,"GET","/v2/lobby/"+s));for(;f.length<t.replies.length;){const e=t.replies[f.length],n=Na(i,e);l("reply",n),f.push(n)}}),n,{onError(e){l("error",e)}});return p.start({wait:!1}),{close:()=>p.stop(),lobbyId:s,on:u,replies:f}}async function Ra(e,t){const n=Ye(await gn(e,"GET","/v2/lobby/"+t)),{publicKey:r}=n.request,o=on(on(r)),i=jt.parse(t);if(!an(i,o.subarray(0,i.length)))throw new Error("Lobby ECDH integrity error");return n.request}async function La(e,t,n,r){const{io:o}=e.props,{publicKey:i}=n,a={data:ot(ja(o,i,r))};await gn(e,"POST","/v2/lobby/"+t,a)}const Ba=ye({appId:le,loginKey:Ae,loginStash:Mn});async function Ka(e,t,n={}){function r(e){for(const t of a)t();s.state="error",s.error=e,U(s),B(s)}async function o(r){for(const e of a)e();const o=Ba(r),{username:i}=o.loginStash;s.state="started",s.username=i,U(s);const c=await async function(e,t,n,r){const{now:o=new Date}=r,{loginKey:i,loginStash:a}=t;e.props.log.breadcrumb("unpackAccount",{});const s=Un(a,(e=>e.appId===n));if(null==s)throw new Error(`Cannot find requested appId: "${n}"`);try{const t=An(e,s.loginId);s.voucherId=t.stash.voucherId,s.voucherAuth=t.stash.voucherAuth}catch(u){}a.lastLogin=o,await Pn(e,a);const c={loginId:s.loginId,loginKey:i};return await Jn(e,c),await _a(e,c,"edgeLogin",r)}(e,o,t,n);s.state="done",s.account=c,U(s),B(s)}const i=await Da(e,{loginRequest:{appId:t}}),a=[i.close,i.on("error",(function(e){s.error=e,U(s)})),i.on("reply",(e=>{o(e).catch(r)}))],s={id:i.lobbyId,cancelRequest:async function(){for(const e of a)e();s.state="closed",U(s),B(s)},watch:X,state:"pending",account:void 0,error:void 0,username:void 0};return _(s)}const Ua=ve(Ba),Fa=ye({appName:le,darkImageUrl:ae(le),lightImageUrl:ae(le),imageUrl:ae(le)});async function Wa(e,t){try{const[n]=ea(e.props.state.infoServers),r=`${n}/v1/appIdInfo/${t}`,o=await e.props.io.fetch(r,{corsBypass:"never"});if(404===o.status)return{appName:t};if(!o.ok)throw new Error(`Fetching ${r} returned ${o.status}`);const i=Fa(await o.json());return null==i.lightImageUrl&&(i.lightImageUrl=i.imageUrl),null==i.darkImageUrl&&(i.darkImageUrl=i.imageUrl),i}catch(n){return e.props.onError(n),{appName:t}}}async function Ga(e,t,n){const r=await Ra(e,n);let o;null!=r.loginRequest&&(o=await async function(e,t,n,r,o){e.props.log.breadcrumb("unpackLoginRequest",{});const i=await Wa(e,o),a={appId:o,displayName:i.appName,displayImageDarkUrl:i.darkImageUrl,displayImageLightUrl:i.lightImageUrl,approve(){return async function(e,t,n,r,o){const{sessionKey:i}=e.props.state.accounts[t];e.props.log.breadcrumb("approveLoginRequest",{}),await Jn(e,i);const{stashTree:a}=An(e,i.loginId),s=await Ta(e,a,i,n),c=Un(s,(e=>e.appId===n));if(null==c)throw new Error("Failed to create the requested login object");const u=Xn(s,i,c.loginId),l=Ua({appId:n,loginKey:u.loginKey,loginStash:$n(s,n)});let d;await La(e,r,o,l);const f=e.props.output.accounts[t].accountApi;null!=f&&f.on("close",(()=>{null!=d&&clearTimeout(d)})),d=setTimeout((()=>{d=void 0,Jn(e,i).then((()=>{d=setTimeout((()=>{d=void 0,Jn(e,i).catch((t=>e.props.onError(t)))}),2e4)})).catch((t=>e.props.onError(t)))}),1e4)}(e,t,o,n,r)},async close(){B(a)}};return _(a),a}(e,t,n,r,r.loginRequest.appId));const i={loginRequest:o};return _(i),i}function qa(e){const t={};for(const n of Object.keys(e)){t[e[n].currencyCode]=n}return t}function za(e={},t={},n,r){const o=[];for(const a of r){var i;const n=null!==(i=t[a])&&void 0!==i?i:e[a];null!=n&&o.push(n.currencyCode)}return o}function $a(e,t=[]){const n=new Set(t),r=[];for(const o of e)n.has(o)||(n.add(o),r.push(o));return r}function Ha(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ya(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ha(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ha(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Va="Currency.json",Ja="fixedLegacyFileNames.json",Xa="EnabledTokens.json",Za="seenTxCheckpoint.json",Qa="Tokens.json",es="WalletName.json",ts=Er(Hi),ns=Er(Yi),rs=Er(Wi),os=Er($i),is=Er(Ji),as=Er(Gi),ss=Er(zi),cs=Er(Xi),us=Er(Zi);function ls(e,t,n,r){var o;const i=e.currency.wallets[t].fileNames,a=wo(e,t,n),{creationDate:s=Math.min(r,Date.now()/1e3)}=null!==(o=i[a])&&void 0!==o?o:{},c=`${s.toFixed(0)}-${a}.json`;return{creationDate:s,fileName:c,txidHash:a}}async function ds(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await cs.load(o,Va);let a="iso:USD";if(null!=i)if(null!=i.fiat)a=i.fiat;else if(null!=i.num){const e=(0,Qi.Rx)(`000${i.num}`.slice(-3));null!=e&&(a=`iso:${e.code}`)}t({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:a,walletId:r}})}async function fs(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await us.load(o,es);let a=null;if(null==i||null==i.walletName){const{appIds:t=[]}=e.props.walletState.walletInfo,n=t.find((e=>""!==e));if(null!=n){const{appName:t}=await Wa(yu(e),n);a=t}}else a=i.walletName;t({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:"string"==typeof a?a:null,walletId:r}})}async function ps(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await as.load(o,Qa);if(null!=i){const n=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${n} loaded modern file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:Ya({walletId:e.props.walletId},i)})}const a=await rs.load(o,Xa);if(null!=a){const{accountId:n,currencyInfo:o,pluginId:i}=e.props.walletState,s=e.props.state.accounts[n],c=function(e={},t={},n,r){const o=qa(e),i=qa(t),a=[];for(const c of r){var s;const e=null!==(s=i[c])&&void 0!==s?s:o[c];null!=e&&a.push(e)}return a}(s.builtinTokens[i],s.customTokens[i],0,a),u=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${u} loaded legacy file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:c}})}const s=r.slice(0,2);e.props.log.warn(`enabledTokenIds: ${s} loaded neither file`),t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:[]}})}async function hs(e,t){const{dispatch:n,walletId:r}=e.props,o=bo(e.props.state,r),i=e.props.walletState.currencyInfo.currencyCode,a=e.props.walletState.fileNames,s=e.props.walletState.fiat,c={};return await Promise.all(t.map((async e=>{if(null==a[e])return;const t=`Transactions/${a[e].fileName}`,n=await os.load(o,t);null!=n&&(c[e]=function(e,t,n){const r={creationDate:e.state.creationDate,currencies:new Map,tokens:new Map,internal:e.state.internal,txid:e.state.malleableTxId},o={};return o[n]=e.meta.amountCurrency,r.currencies.set(t,{metadata:{bizId:e.meta.bizId,category:e.meta.category,exchangeAmount:o,name:e.meta.name,notes:e.meta.notes},providerFeeSent:e.meta.amountFeeAirBitzSatoshi.toFixed()}),r}(n,i,s))}))),await Promise.all(t.map((async e=>{if(null==a[e])return;const t=`transaction/${a[e].fileName}`,n=await ss.load(o,t);null!=n&&(c[e]=n)}))),n({type:"CURRENCY_WALLET_FILES_LOADED",payload:{files:c,walletId:r}}),c}async function ys(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await async function(e,t,n){var r;const o=go(e,t),i=null!==(r=await ns.load(o,Ja))&&void 0!==r?r:{},a=(0,ee.gQ)(await n.list()),s={},c=[];for(let l=0;l<a.length;l++){const e=a[l],t=i[e];if(null!=t){const{timestamp:n,txidHash:r}=t;s[r]={creationDate:n,fileName:e}}else c.push(e)}const u=c.map((async r=>{const o=await os.load(n,r);if(null==o)return;const{creationDate:a,malleableTxId:c}=o.state,u=r,l=wo(e,t,c);s[l]={creationDate:a,fileName:u},i[u]={timestamp:a,txidHash:l}}));return u.length>0&&(await Promise.all(u),await ns.save(o,Ja,i).catch((()=>{}))),s}(n,r,(0,ee.HN)(o,"Transactions")),a=await(0,ee.HN)(o,"transaction").list();for(const s of(0,ee.gQ)(a)){const e=s.split(".json")[0].split("-"),[t,n]=e,r=parseInt(t);(null==i[n]||r<i[n].creationDate)&&(i[n]={creationDate:r,fileName:s})}t({type:"CURRENCY_WALLET_FILE_NAMES_LOADED",payload:{txFileNames:i,walletId:r}})}async function bs(e){var t;const{state:n,walletId:r}=e.props,o=bo(n,r),i=[],a=(0,ee.gQ)(await o.list("Addresses"));await Promise.all(a.map((async e=>{const t=await ts.load(o,e);null!=t&&(""===t.address||t.state.recycleable||i.push(t.address))})));const s=null===(t=e.props.walletOutput)||void 0===t?void 0:t.engine;null!=s&&await s.addGapLimitAddresses(i)}async function gs(e,t,n,r,o,i,a){var s,c;const{dispatch:u,state:l,walletId:d}=e.props,f=bo(l,d),{accountId:p,currencyInfo:h,pluginId:y}=e.props.walletState,b=e.props.state.accounts[p].allTokens[y],{currencyCode:g}=null==n?h:b[n],w=e.props.walletState.txs[t];if(null==w)throw new Error(`Setting metatdata for missing tx ${t}`);const{creationDate:v,fileName:m,txidHash:I}=ls(l,d,w.txid,w.date),E=await ss.load(f,`transaction/${m}`),S=Ya(Ya({},E),{},{creationDate:v,currencies:new Map(null!==(s=null==E?void 0:E.currencies)&&void 0!==s?s:[]),internal:!0,tokens:new Map(null!==(c=null==E?void 0:E.tokens)&&void 0!==c?c:[]),txid:t}),O=Ya(Ya({metadata:{}},S.currencies.get(g)),S.tokens.get(n));var A;(S.tokens.set(n,O),S.currencies.delete(g),null!=o)&&(O.metadata=Mi(null!==(A=O.metadata)&&void 0!==A?A:{},o));null!=i&&(O.assetAction=i),null!=a&&(S.savedAction=a),u({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:v,fileName:m,json:S,txid:t,txidHash:I,walletId:d}}),await ss.save(f,"transaction/"+m,S);const T=ac(e,w,S,n);r.onTransactions([{isNew:!1,transaction:T}])}async function ws(e,t){var n;const{dispatch:r,state:o,walletId:i}=e.props,{creationDate:a,fileName:s,txidHash:c}=ls(o,i,t.txid,t.date),u={txid:t.txid,internal:!0,creationDate:a,currencies:new Map,feeRateUsed:t.feeRateUsed,tokens:new Map,savedAction:t.savedAction,swap:t.swapData};return u.tokens.set(t.tokenId,{assetAction:t.assetAction,metadata:null!==(n=t.metadata)&&void 0!==n?n:{},nativeAmount:t.nativeAmount}),null!=t.networkFeeOption&&(u.feeRateRequested="custom"===t.networkFeeOption?t.requestedCustomFee:t.networkFeeOption),null!=t.spendTargets&&(u.payees=t.spendTargets.map((e=>({currency:e.currencyCode,address:e.publicAddress,amount:e.nativeAmount,tag:e.memo}))),null!=t.deviceDescription&&(u.deviceDescription=t.deviceDescription)),"string"==typeof t.txSecret&&(u.secret=t.txSecret),r({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:a,fileName:s,json:u,txid:t.txid,txidHash:c,walletId:i}}),{fileName:s,txFile:u}}async function vs(e,t,n){var r;const{dispatch:o,state:i,walletId:a}=e.props,s=bo(i,a),c=await is.load(s,Za),u={checkpoint:t,subscribedAddresses:null!==(r=null!=n?n:(null!=c?c:{checkpoint:void 0,subscribedAddresses:[]}).subscribedAddresses)&&void 0!==r?r:[]};null!=t&&o({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:t,walletId:a}}),await is.save(s,Za,u)}var ms="redux-keto wrapper";function Is(e,t,n){for(var r=Object.create(null),o=function(){var e=a[i],o=t(e);Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var t=this,r=t[ms];if(r.running[e]){var i=new ReferenceError("Reducer '"+e+"' depends on its own result");throw i.name="ReduxKetoCircularReferenceError",i}r.running[e]=!0;try{var a=o(r.state[e],r.action,n(r.next,t,e),n(r.prev,r.state,e));if(void 0===a)throw new TypeError("Reducer '"+e+"' returned undefined");return Object.defineProperty(t,e,{configurable:!0,enumerable:!0,writable:!1,value:a}),a}finally{r.running[e]=!1}}})},i=0,a=e;i<a.length;i+=1)o();return r}function Es(e,t,n,r,o){var i=Object.create(e);return Object.defineProperty(i,ms,{configurable:!0,enumerable:!1,writable:!1,value:{state:t,action:n,next:r,prev:o,running:{}}}),i}function Ss(e,t){if(void 0===e&&(e={}),null===t||null==t[ms])return t;for(var n=Object.keys(Object.getPrototypeOf(t)),r=Object.keys(e).length===n.length,o=0,i=n;o<i.length;o+=1){var a=i[o];Object.defineProperty(t,a,{configurable:!1,enumerable:!0,writable:!1,value:Ss(e[a],t[a])}),t[a]!==e[a]&&(r=!1)}return r?e:(delete t[ms],t)}function Os(e,t,n){return void 0!==e?e:t}function As(e,t){if(void 0===t&&(t=Os),"object"!=typeof e||null===e)throw new TypeError("The reducer map must be an object.");for(var n=Object.keys(e),r=0,o=n;r<o.length;r+=1){var i=o[r];if("function"!=typeof e[i])throw new TypeError("Reducers must be functions.")}for(var a=Is(n,(function(t){return e[t]}),t),s={},c=0,u=n;c<u.length;c+=1){var l=u[c];s[l]=e[l].defaultState}function d(e,t,n,r){void 0===e&&(e=s);var o=Es(a,e,t,n,r);return void 0===n?Ss(e,o):o}return d.defaultState=s,d}function Ts(e,t){return e}function _s(e){return e}function ks(e,t,n){void 0===t&&(t=Ts),void 0===n&&(n=_s);var r=e.defaultState;function o(o,i,a,s){void 0===o&&(o=r);var c=t(i,a),u=n(a),l=n(s);if(!c)return o;var d=e(o,c,u,l);return void 0===a?Ss(o,d):d}return o.defaultState=r,o}function xs(e,t,n){return{id:n,root:void 0!==e?e:t,get self(){return t[n]}}}var Ps={};function Ms(e,t,n){function r(r,o,i,a){void 0===r&&(r=Ps);var s=t(i),c=Es(r===Ps||s!==t(a)?Is(s,(function(t){return e}),n):Object.getPrototypeOf(r),r,o,i,a);return void 0===i?Ss(r,c):c}return void 0===n&&(n=xs),r.defaultState=Ps,r}function Cs(){for(var e=arguments,t=arguments.length-1,n=arguments[t],r=[];t-- >0;)r[t]=e[t];if("function"!=typeof n)throw new TypeError("The reducer must be a function");for(var o=0,i=r;o<i.length;o+=1){if("function"!=typeof i[o])throw new TypeError("Each argument filter must be a function")}return function(e,t,o,i){void 0===e&&(e=n.defaultState);for(var a=void 0!==e,s=[],c=0;c<r.length;++c)s[c]=r[c](o),a&&s[c]!==r[c](i)&&(a=!1);return a?e:n.apply(void 0,s)}}function Ns(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function js(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ns(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ns(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ds=[],Rs={totalRatio:0},Ls=As({accountId(e,t,n){if(null!=e)return e;for(const r of Object.keys(n.root.accounts)){const e=n.root.accounts[r];for(const t of Object.keys(e.walletInfos))if(t===n.id)return r}throw new Error(`Cannot find account for walletId ${n.id}`)},allEnabledTokenIds:Cs((e=>e.root.accounts[e.self.accountId].alwaysEnabledTokenIds[e.self.pluginId]),(e=>e.self.enabledTokenIds),((e=[],t=[])=>$a([...e,...t]))),pluginId:Cs((e=>e.root.login.walletInfos[e.id].type),(e=>e.root.plugins.currency),((e,t)=>Vr(t,e))),paused(e,t,n){return null==e?n.root.accounts[n.self.accountId].pauseWallets:"CURRENCY_WALLET_CHANGED_PAUSED"===t.type?t.payload.paused:e},currencyInfo(e,t,n){if(null!=e)return e;const{pluginId:r}=n.self;return n.root.plugins.currency[r].currencyInfo},detectedTokenIds:Fs(((e=Ds,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.detectedTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{detectedTokenIds:n}=t.payload;return $a([...e,...n])}return"CURRENCY_ENGINE_CLEARED"===t.type?[]:e})),enabledTokenIds:Fs(((e=Ds,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_WALLET_ENABLED_TOKENS_CHANGED"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{enablingTokenIds:n}=t.payload;return $a([...e,...n])}return e})),changeServiceSubscriptions(e=[],t){if("CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS"===t.type){return[...e.filter((e=>!t.payload.subscriptions.some((t=>t.address===e.address)))),...t.payload.subscriptions]}return"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES"===t.type?t.payload.subscribedAddresses:e},tokenFileDirty(e=!1,t,n,r){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":case"CURRENCY_WALLET_SAVED_TOKEN_FILE":return!1;case"CURRENCY_ENGINE_CLEARED":case"CURRENCY_ENGINE_DETECTED_TOKENS":case"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED":return n.self.detectedTokenIds!==r.self.detectedTokenIds||n.self.enabledTokenIds!==r.self.enabledTokenIds;default:return e}},tokenFileLoaded(e=!1,t){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":return!0;case"CURRENCY_ENGINE_CLEARED":return!1;default:return e}},engineFailure(e=null,t){if("CURRENCY_ENGINE_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},engineStarted(e=!1,t){return"CURRENCY_ENGINE_STARTED"===t.type||"CURRENCY_ENGINE_STOPPED"!==t.type&&e},fiat(e="",t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type?t.payload.fiatCurrencyCode:e},fiatLoaded(e=!1,t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type||e},files(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_CHANGED":{const{json:n,txidHash:r}=t.payload,o=js({},e);return o[r]=n,o}case"CURRENCY_WALLET_FILES_LOADED":{const{files:n}=t.payload;return js(js({},e),n)}}return e},fileNames(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload;return js(js({},e),n)}case"CURRENCY_WALLET_FILE_CHANGED":{const{fileName:n,creationDate:r,txidHash:o}=t.payload;return(null==e[o]||r<e[o].creationDate)&&(e[o]={creationDate:r,fileName:n}),e}}return e},syncStatus(e=Rs,t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_SYNC_STATUS":return t.payload.status;case"CURRENCY_ENGINE_CLEARED":return Rs}return e},balanceMap(e=new Map,t){if("CURRENCY_ENGINE_CHANGED_BALANCE"===t.type){const{balance:n,tokenId:r}=t.payload,o=new Map(e);return o.set(r,n),o}return e},balances:Cs((e=>e.self.balanceMap),(e=>e.self.currencyInfo),(e=>e.root.accounts[e.self.accountId].allTokens[e.self.pluginId]),((e,t,n)=>{const r={};for(const o of e.keys()){const i=e.get(o),{currencyCode:a}=null==o?t:n[o];null!=i&&(r[a]=i)}return r})),height(e=0,t){return"CURRENCY_ENGINE_CHANGED_HEIGHT"===t.type?t.payload.height:e},name(e=null,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type?t.payload.name:e},nameLoaded(e=!1,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type||e},seenTxCheckpoint(e=null,t){return"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED"===t.type?t.payload.checkpoint:e},sortedTxidHashes:Cs((e=>e.self.txidHashes),(e=>Object.keys(e).sort(((t,n)=>e[t].date>e[n].date?-1:e[t].date<e[n].date?1:0)))),stakingStatus(e={stakedAmounts:[]},t){return"CURRENCY_ENGINE_CHANGED_STAKING"===t.type?t.payload.stakingStatus:e},txidHashes(e={},t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_TXS":return Bs(e,t.payload.txidHashes);case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload,r={};for(const e of Object.keys(n))r[e]={date:n[e].creationDate};return Bs(e,r)}}return e},txs(e={},t,n){switch(t.type){case"CHANGE_MERGE_TX":{const{tx:n}=t.payload,r=js({},e);return r[n.txid]=n,r}case"CURRENCY_ENGINE_CHANGED_TXS":{const{txs:n}=t.payload,r=js({},e);for(const e of n)r[e.txid]=Us(e,r[e.txid]);return r}case"CURRENCY_ENGINE_CLEARED":return{}}return e},unactivatedTokenIds(e=[],t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS":return t.payload.unactivatedTokenIds;case"CURRENCY_ENGINE_CLEARED":return[]}return e},gotTxs(e=new Set,t){switch(t.type){case"CURRENCY_ENGINE_GOT_TXS":{const{tokenId:n}=t.payload,r=new Set(e);return r.add(n),r}case"CURRENCY_ENGINE_CLEARED":return new Set;default:return e}},walletInfo(e,t,n){return n.root.login.walletInfos[n.id]},publicWalletInfo(e=null,t){return"CURRENCY_WALLET_PUBLIC_INFO"===t.type?t.payload.walletInfo:e}});function Bs(e,t){const n=js({},e);for(const o of Object.keys(t)){var r;const e=n[o],i=t[o];n[o]=null==e?i:{date:Math.min(i.date,e.date),txid:null!==(r=i.txid)&&void 0!==r?r:e.txid}}return n}const Ks=ks(Ls,((e,t)=>/^CURRENCY_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"walletId"in e.payload&&e.payload.walletId===t.id?e:{type:"UPDATE_NEXT"}));function Us(e,t){var n,r,o,i;const{confirmations:a="unconfirmed",isSend:s=(0,Uo.lt)(e.nativeAmount,"0"),tokenId:c=null}=e,u={blockHeight:e.blockHeight,chainAction:e.chainAction,chainAssetAction:new Map(null!==(n=null==t?void 0:t.chainAssetAction)&&void 0!==n?n:[]),confirmations:a,date:e.date,isSend:s,memos:e.memos,nativeAmount:new Map(null!==(r=null==t?void 0:t.nativeAmount)&&void 0!==r?r:[]),networkFee:new Map(null!==(o=null==t?void 0:t.networkFee)&&void 0!==o?o:[]),otherParams:e.otherParams,ourReceiveAddresses:e.ourReceiveAddresses,signedTx:e.signedTx,txid:e.txid};return u.nativeAmount.set(c,e.nativeAmount),u.networkFee.set(c,null!==(i=e.networkFee)&&void 0!==i?i:"0"),null!=e.feeRateUsed&&(u.feeRateUsed=e.feeRateUsed),null!=e.parentNetworkFee&&u.networkFee.set(null,String(e.parentNetworkFee)),null!=e.chainAssetAction&&u.chainAssetAction.set(c,e.chainAssetAction),u}function Fs(e){return(t,n)=>{const r=e(t,n);return r===t?t:(r.sort(((e,t)=>e===t?0:e>t?1:-1)),null!=t&&Oi(r,t)?t:r)}}let Ws=5e3;function Gs(e,t){const{log:n,walletId:r}=e.props;let o=!1,i=0,a=[];return e=>{if(o)n(`throttledTxCallback delay, walletId: ${r}`),a.push(...e);else{const s=Date.now();s-i>Ws?(i=s,t(e)):(n(`throttledTxCallback delay, walletId: ${r}`),o=!0,a=e,setTimeout((()=>{i=Date.now(),t(a),o=!1,a=[]}),Ws))}}}function qs(e){const{walletId:t}=e.props;"narfavJN4rp9ZzYigcRj1i0vrU2OAGGp4+KksAksj54="===t&&(Ws=25,Ti=99,Ai=1);const n=Gs(e,(t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&K(e.props.walletOutput.walletApi,"transactionsChanged",t)})),r=Gs(e,(t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&K(e.props.walletOutput.walletApi,"newTransactions",t)})),o={onAddressesChecked(n){xi({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:{totalRatio:n},walletId:t}})}})},onNewTokens(n){xi({id:t,action:"onNewTokens",updateFunc:()=>{const{detectedTokenIds:r,enabledTokenIds:o}=e.props.walletState,i=$a(n,[...r,...o]),a=pc(n,r),s=pc(r,n),c=t.slice(0,2);if(e.props.log.warn(`enabledTokenIds: ${c} engine detected tokens, add [${a}], remove [${s}]`),e.props.dispatch({type:"CURRENCY_ENGINE_DETECTED_TOKENS",payload:{detectedTokenIds:n,enablingTokenIds:i,walletId:t}}),i.length>0){var u;const t=null===(u=e.props)||void 0===u||null===(u=u.walletOutput)||void 0===u?void 0:u.walletApi;null!=t&&K(t,"enabledDetectedTokens",i)}}})},onUnactivatedTokenIdsChanged(n){xi({id:t,action:"onUnactivatedTokenIdsChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS",payload:{unactivatedTokenIds:n,walletId:t}})}})},onBalanceChanged(t,n){const{accountId:r,currencyInfo:i,pluginId:a}=e.props.walletState,s=e.props.state.accounts[r].allTokens[a];if(t===i.currencyCode)o.onTokenBalanceChanged(null,n);else{const{tokenId:e}=Fo({allTokens:s,currencyInfo:i,currencyCode:t});null!=e&&o.onTokenBalanceChanged(e,n)}},onTokenBalanceChanged(n,r){const o=ge(Ri)(r);null!=o?xi({id:`${t}==${String(n)}`,action:"onTokenBalanceChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:o,tokenId:n,walletId:t}})}}):e.props.onError(new Error(`Plugin sent bogus balance for ${String(n)}: "${r}"`))},onBlockHeightChanged(r){xi({id:t,action:"onBlockHeightChanged",updateFunc:()=>{const{txs:o,files:i}=e.props.walletState,a=[];for(const n of Object.keys(o)){const s=o[n];if($s(s.confirmations)){const n=wo(e.props.state,t,s.txid),o=ac(e,s,i[n],null,r);a.push(o)}}a.length>0&&n(a),e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:r,walletId:t}})}})},onSeenTxCheckpoint(t){vs(e,t).catch((t=>e.props.onError(t)))},onStakingStatusChanged(n){xi({id:t,action:"onStakingStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:n,walletId:t}})}})},onSubscribeAddresses(n){var r;const o=n.map((e=>"string"==typeof e?{address:e,checkpoint:void 0}:e));vs(e,null!==(r=e.props.walletState.seenTxCheckpoint)&&void 0!==r?r:void 0,o).catch((t=>e.props.onError(t)));const i=o.map((({address:e,checkpoint:t})=>({address:e,status:"subscribing",checkpoint:t})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:i,walletId:t}})},onSyncStatusChanged(n){xi({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:n,walletId:t}})}})},onTransactions(o){const{accountId:i,currencyInfo:a,pluginId:s}=e.props.walletState,c=e.props.state.accounts[i].allTokens[s];if(null==o||0===o.length)return;const u=[];for(const t of o){const n=t.transaction;if(Go(n),"string"!=typeof n.txid||"number"!=typeof n.date||"string"!=typeof n.networkFee||"number"!=typeof n.blockHeight||"string"!=typeof n.nativeAmount||"object"!=typeof n.ourReceiveAddresses)return void e.props.onError(new Error(`Plugin sent bogus tx: ${JSON.stringify(n,null,2)}`));if(null==n.isSend&&(n.isSend=(0,Uo.lt)(n.nativeAmount,"0")),null==n.memos&&(n.memos=[]),void 0===n.tokenId){const{tokenId:e}=Fo({allTokens:c,currencyInfo:a,currencyCode:n.currencyCode});n.tokenId=null!=e?e:null}u.push(n)}const{state:l}=e.props,{txs:d}=e.props.walletState,f={},p=[],h=[];for(const n of o){const{isNew:r,transaction:o}=n,{txid:i}=o,a=Us(o,d[i]);if(Oi(a,d[i])&&null==o.metadata)continue;const s=wo(l,t,i);null==e.props.walletState.fileNames[s]&&ws(e,o).catch((t=>e.props.onError(t)));const{files:c}=e.props.walletState,u=ac(e,a,c[s],o.tokenId);r?h.push(u):p.push(u),f[s]={date:u.date,txid:i}}e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_TXS",payload:{txs:u,walletId:t,txidHashes:f}}),p.length>0&&n(p),h.length>0&&r(h)},onTransactionsChanged(e){o.onTransactions(e.map((e=>({isNew:!1,transaction:e}))))},onAddressChanged(){null!=e.props.walletOutput.walletApi&&K(e.props.walletOutput.walletApi,"addressChanged",void 0)},onWcNewContractCall(t){null!=e.props.walletOutput.walletApi&&K(e.props.walletOutput.walletApi,"wcNewContractCall",t)},onTxidsChanged(){}};return o}function zs(e){const{walletId:t}=e.props;let n;async function r(r){const o=function(e,t){return e.storageWallets[t].lastChanges}(r.state,t);o!==n&&(n=o,await async function(e,t){(t.includes(Qa)||t.includes(Xa))&&await ps(e),t.includes(Va)&&await ds(e),t.includes(es)&&await fs(e),await ys(e),await bs(e)}(e,o))}!function t(){e.nextProps().then(r).then(t,(n=>{var r;(r=n)instanceof Error&&"PixieShutdownError"===r.name||(e.props.onError(n),t())}))}()}const $s=e=>"number"!=typeof e&&"confirmed"!==e&&"dropped"!==e&&"failed"!==e,Hs=(e,t,n=1)=>{if(e.blockHeight>0){const r=1+t-e.blockHeight;return r<=0?"syncing":r>=n?"confirmed":r}return e.blockHeight<0?"dropped":"unconfirmed"};function Ys(e,t=new Date(0),n=new Date){return 1e3*e.date>=t.valueOf()&&1e3*e.date<n.valueOf()}function Vs(e,t,n){var r;const o=e.props.state.currency;if(null==n||""===n)return!0;let i=n.toLowerCase().replace(".","").replace(",","");for(let c=0;c<i.length;c++)if("0"!==i[c]){i=i.substring(c);break}function a(e){return null!=e&&("string"==typeof e||"number"==typeof e)&&!!e.toString().toLowerCase().replace(".","").replace(",","").includes(i)}if(a(t.nativeAmount))return!0;if(null!=t.metadata){const{category:e="",name:n="",notes:r="",exchangeAmount:i={}}=t.metadata,s=null!=t.walletId?o.wallets[t.walletId]:void 0;if(a(e)||a(n)||a(r)||null!=s&&a(i[s.fiat]))return!0}if(null!=t.swapData){const{displayName:e="",pluginId:n=""}=t.swapData.plugin;if(a(e)||a(n))return!0}const s=null!==(r=t.savedAction)&&void 0!==r?r:t.chainAction;if(null!=s&&"swap"===s.actionType){const{pluginId:e}=s.toAsset,{pluginId:t}=s.fromAsset,{displayName:n,supportEmail:r}=s.swapInfo;if(a(t)||a(e)||a(n)||a(r))return!0}if(null!=t.spendTargets)for(const c of t.spendTargets){const{publicAddress:e="",memo:t=""}=c;if(a(e)||a(t))return!0}if(t.ourReceiveAddresses.length>0)for(const c of t.ourReceiveAddresses)if(a(c))return!0;return!!a(t.txid)}function Js(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Xs(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Js(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Js(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Zs(e,t){var n,r;const o=[],{memoType:i}=t;if("hex"===i||"number"===i||"text"===i)for(const c of e.spendTargets){var a;null!=c.memo?o.push({type:i,value:c.memo}):null!=c.uniqueIdentifier?o.push({type:i,value:c.uniqueIdentifier}):"string"==typeof(null===(a=c.otherParams)||void 0===a?void 0:a.uniqueIdentifier)&&o.push({type:i,value:c.otherParams.uniqueIdentifier})}for(const c of o)"hex"===c.type&&(c.value=c.value.replace(/^0x/i,""));const s=Xs(Xs({},e),{},{spendTargets:e.spendTargets.map((e=>Xs(Xs({},e),{},{memo:void 0,uniqueIdentifier:void 0}))),memos:null!==(n=e.memos)&&void 0!==n?n:o});if(1===(null===(r=s.memos)||void 0===r?void 0:r.length)&&s.spendTargets.length>=1){const[e]=s.memos;if(e.type===t.memoType){const[t]=s.spendTargets;t.memo=e.value,t.uniqueIdentifier=e.value,t.otherParams=Xs(Xs({},t.otherParams),{},{uniqueIdenfitifer:e.value})}}return s}function Qs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ec(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qs(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qs(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const tc=async(e,t,n,r,o)=>{var i;e=Zs(e,t.currencyInfo);const a=Fo({allTokens:r,currencyInfo:t.currencyInfo,tokenId:e.tokenId}),s=null!==(i=t.currencyInfo.unsafeMakeSpend)&&void 0!==i&&i;if("function"==typeof n.getMaxSpendable){const t=s?o.keys:void 0;return await n.getMaxSpendable(ec(ec({},e),a),{privateKeys:t})}const{networkFeeOption:c,customNetworkFee:u}=e,l=n.getBalance(a),d=e.spendTargets.map((e=>ec(ec({},e),{},{nativeAmount:"0"})));return await function t(r,i){const l=(0,Uo.sub)(i,r);if((0,Uo.lte)(l,"1"))return Promise.resolve(r);const f=(0,Uo.add)(r,(0,Uo.div)(l,"2"));d[0].nativeAmount=f;const p=s?o.keys:void 0;return n.makeSpend(ec(ec({},a),{},{spendTargets:d,networkFeeOption:c,customNetworkFee:u,memos:e.memos,otherParams:e.otherParams}),{privateKeys:p}).then((()=>t(f,i))).catch((()=>t(r,f)))}("0",(0,Uo.add)(l,"1"))};function nc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function rc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const oc={bizId:0,category:"",exchangeAmount:{},name:"",notes:""};function ic(e,t,n,r){const o=yu(e),{accountId:i,pluginId:a,walletInfo:s}=e.props.walletState,c=e.props.state.plugins.currency[a],{unsafeBroadcastTx:u=!1,unsafeMakeSpend:l=!1}=c.currencyInfo,d=Ei(o,s),f=qs(e),p={};if(null!=t.otherMethods)for(const y of Object.keys(t.otherMethods)){const e=t.otherMethods[y];"function"==typeof e&&(p[y]=e)}if(null!=t.otherMethodsWithKeys)for(const y of Object.keys(t.otherMethodsWithKeys)){const e=t.otherMethodsWithKeys[y];"function"==typeof e&&(p[y]=(...t)=>e(s.keys,...t))}_(p);const h={on:J,watch:X,get created(){return s.created},get disklet(){return d.disklet},get id(){return d.id},get localDisklet(){return d.localDisklet},publicWalletInfo:r,async sync(){await d.sync()},get type(){return d.type},get name(){return e.props.walletState.name},async renameWallet(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=bo(r,o);await us.save(i,es,{walletName:t}),n({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:t,walletId:o}})}(e,t)},get fiatCurrencyCode(){return e.props.walletState.fiat},async setFiatCurrencyCode(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=bo(r,o);if(!/^iso:/.test(t))throw new TypeError("Fiat currency codes must start with `iso:`");await cs.save(i,Va,{fiat:t,num:void 0}),n({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:t,walletId:o}})}(e,t)},get currencyConfig(){const{accountApi:t}=e.props.output.accounts[i];return t.currencyConfig[a]},get currencyInfo(){return c.currencyInfo},async denominationToNative(t,n){const r=qo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Uo.mul)(t,r)},async nativeToDenomination(t,n){const r=qo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Uo.div)(t,r,r.length)},get balances(){return e.props.walletState.balances},get balanceMap(){return e.props.walletState.balanceMap},get blockHeight(){const{skipBlockHeight:t}=e.props.state;return t?0:e.props.walletState.height},get syncRatio(){return e.props.walletState.syncStatus.totalRatio},get syncStatus(){return e.props.walletState.syncStatus},get unactivatedTokenIds(){return e.props.walletState.unactivatedTokenIds},async changePaused(t){e.props.dispatch({type:"CURRENCY_WALLET_CHANGED_PAUSED",payload:{walletId:e.props.walletId,paused:t}})},get paused(){return e.props.walletState.paused},async changeEnabledTokenIds(t){var n;const{dispatch:r,walletId:o,walletState:i}=e.props,{accountId:a,pluginId:s}=i,c=null!==(n=e.props.state.accounts[a].allTokens[s])&&void 0!==n?n:{},u=$a(t).filter((e=>null!=c[e])),l=o.slice(0,2);e.props.log.warn(`enabledTokenIds: ${l} changeEnabledTokenIds`),r({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:o,enabledTokenIds:u}})},get detectedTokenIds(){return e.props.walletState.detectedTokenIds},get enabledTokenIds(){return e.props.walletState.enabledTokenIds},async getNumTransactions(n){const r=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId});return t.getNumTransactions(r)},async $internalStreamTransactions(n){const{afterDate:r,batchSize:i=10,beforeDate:a,firstBatchSize:s=i,searchString:c,spamThreshold:u="0",tokenId:l=null}=n,{currencyCode:d}=null==l?this.currencyInfo:this.currencyConfig.allTokens[l],p={currencyCode:d,tokenId:l};let h=e.props.walletState;if(!h.gotTxs.has(l)){const n=await t.getTransactions(p);f.onTransactionsChanged(n),e.props.dispatch({type:"CURRENCY_ENGINE_GOT_TXS",payload:{walletId:e.props.walletId,tokenId:l}}),h=e.props.walletState}const{files:y,sortedTxidHashes:b,txidHashes:g,txs:w}=h;let v=0,m=!0,I=0;return _({async next(){const t=m?s:i,n=[];for(;v<b.length&&n.length<t;){var d,f;if(v>=I){const n=b.slice(I,I+t).filter((e=>null==y[e])),r=await hs(e,n);Object.assign(y,r),I+=t}const i=b[v++],s=y[i],p=null!==(d=null==s?void 0:s.txid)&&void 0!==d?d:null===(f=g[i])||void 0===f?void 0:f.txid;if(null==p)continue;const h=w[p],m=null==h?void 0:h.nativeAmount.get(l),E=null==h?void 0:h.networkFee.get(l);if(null==h||null==m||null==E)continue;const S=ac(e,h,s,l);if(Go(S),!Vs(o,S,c))continue;if(!Ys(S,r,a))continue;!(h.isSend||null!=S.assetAction||null!=S.chainAction||null!=S.chainAssetAction||null!=S.savedAction)&&(0,Uo.lt)((0,Uo.abs)(m),u)||n.push(S)}return m=!1,{done:0===n.length,value:n}}})},async getTransactions(t){const{endDate:n,startDate:r,searchString:o,spamThreshold:s}=t,u=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:t.tokenId}),l=await h.$internalStreamTransactions(rc(rc({},u),{},{afterDate:r,beforeDate:n,searchString:o,spamThreshold:s})),d=[];for(;;){const e=await l.next();if(e.done)return d;d.push(...e.value)}},streamTransactions:oe,async getAddresses(n){if(null!=t.getAddresses)return await t.getAddresses(n);{const r=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),o=await t.getFreshAddress(rc(rc({},r),{},{forceIndex:n.forceIndex})),{publicAddress:s,legacyAddress:u,segwitAddress:l,nativeBalance:d,legacyNativeBalance:f,segwitNativeBalance:p}=o,h=[{addressType:"publicAddress",publicAddress:s,nativeBalance:d}];return null!=l&&h.unshift({addressType:"segwitAddress",publicAddress:l,nativeBalance:p}),null!=u&&h.push({addressType:"legacyAddress",publicAddress:u,nativeBalance:f}),h}},async getReceiveAddress(e){var t;const n=await this.getAddresses(e);if(n.length<1)throw new Error("No addresses available");const r=null!==(t=n.find((e=>"publicAddress"===e.addressType)))&&void 0!==t?t:n[0],o={publicAddress:r.publicAddress,nativeBalance:r.nativeBalance,metadata:oc,nativeAmount:"0"},i=n.find((e=>"segwitAddress"===e.addressType));null!=i&&(o.segwitAddress=i.publicAddress,o.segwitNativeBalance=i.nativeBalance);const a=n.find((e=>"legacyAddress"===e.addressType));return null!=a&&(o.legacyAddress=a.publicAddress,o.legacyNativeBalance=a.nativeBalance),o},async lockReceiveAddress(e){},async saveReceiveAddress(e){},async broadcastTx(e){const n=u?s.keys:void 0;return await t.broadcastTx(e,{privateKeys:n})},async getMaxSpendable(n){return await tc(n,c,t,e.props.state.accounts[i].allTokens[a],s)},async getPaymentProtocolInfo(e){if(null==t.getPaymentProtocolInfo)throw new Error("'getPaymentProtocolInfo' is not implemented on wallets of this type");return await t.getPaymentProtocolInfo(e)},async makeSpend(n){n=Zs(n,c.currencyInfo);const{assetAction:r,customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p="standard",noUnconfirmed:h=!1,otherParams:y,pendingTxs:b,rbfTxid:g,savedAction:w,skipChecks:v,spendTargets:m=[],swapData:I}=n,E=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),S=[],O=[];for(const e of m){const{memo:t,publicAddress:n,nativeAmount:r="0",otherParams:o={}}=e;null!=n&&(S.push({memo:t,nativeAmount:r,otherParams:o,publicAddress:n,uniqueIdentifier:t}),O.push({currencyCode:E.currencyCode,memo:t,nativeAmount:r,publicAddress:n,uniqueIdentifier:t}))}if(null!=n.privateKeys)throw new TypeError("Only sweepPrivateKeys takes private keys");const A=l?s.keys:void 0,T=await t.makeSpend(rc(rc({},E),{},{customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p,noUnconfirmed:h,otherParams:y,pendingTxs:b,rbfTxid:g,skipChecks:v,spendTargets:S}),{privateKeys:A});return Go(T),T.networkFeeOption=p,T.requestedCustomFee=o,T.spendTargets=O,T.currencyCode=E.currencyCode,T.tokenId=E.tokenId,null!=f&&(T.metadata=f),null!=I&&(T.swapData=Di(I)),null!=w&&(T.savedAction=Ui(w)),null!=r&&(T.assetAction=Fi(r)),null!=e.props.state.login.deviceInfo.deviceDescription&&(T.deviceDescription=e.props.state.login.deviceInfo.deviceDescription),T},async saveTx(n){if(null==e.props.walletState.txs[n.txid]){const{fileName:t,txFile:r}=await ws(e,n);await async function(e,t,n){const{state:r,walletId:o}=e.props,i=bo(r,o);await ss.save(i,"transaction/"+t,n)}(e,t,r),f.onTransactions([{isNew:!0,transaction:n}])}else await gs(e,n.txid,n.tokenId,f);await t.saveTx(n)},async saveTxAction(t){const{txid:n,tokenId:r,assetAction:o,savedAction:i}=t;await gs(e,n,r,f,void 0,o,i)},async saveTxMetadata(t){const{txid:n,tokenId:r,metadata:o}=t;await gs(e,n,r,f,o)},async signBytes(e,n={}){const r=s.keys;if(null!=t.signBytes)return await t.signBytes(e,r,n);if("bitcoin"===a&&null!=t.signMessage)return await t.signMessage(y.stringify(e),r,n);throw new Error(`${a} doesn't support signBytes`)},async signMessage(e,n={}){if(null==t.signMessage)throw new Error(`${a} doesn't support signing messages`);const r=s.keys;return await t.signMessage(e,r,n)},async signTx(e){const n=s.keys;return await t.signTx(e,n)},async sweepPrivateKeys(e){if(null==t.sweepPrivateKeys)throw new Error("Sweeping this currency is not supported.");return await t.sweepPrivateKeys(e)},async accelerate(e){return null==t.accelerate?null:await t.accelerate(e)},get stakingStatus(){return e.props.walletState.stakingStatus},async dumpData(){return await t.dumpData()},async resyncBlockchain(){const n=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${n} resyncBlockchain`),o.props.dispatch({type:"CURRENCY_ENGINE_CLEARED",payload:{walletId:e.props.walletId}}),await t.resyncBlockchain(),K(h,"transactionsRemoved",void 0)},async split(e){return await mi(o,i,s,e,!1)},async encodeUri(t){return await n.encodeUri(t,Ro(e.props.state.accounts[i].customTokens[a]))},async parseUri(t,r){const o=await n.parseUri(t,r,Ro(e.props.state.accounts[i].customTokens[a]));if(void 0===o.tokenId){var s;const{tokenId:t=null}=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,currencyCode:null!==(s=o.currencyCode)&&void 0!==s?s:r});o.tokenId=t}return o},otherMethods:p};return _(h)}function ac(e,t,n,r,o){var i,a,s;const c=e.props.walletId,{accountId:u,currencyInfo:l,pluginId:d}=e.props.walletState,f=e.props.state.accounts[u].allTokens[d],{currencyCode:p}=null==r?l:f[r],h=l.currencyCode,y=null!=o?o:e.props.walletState.height,b=$s(t.confirmations)?Hs(t,y,l.requiredConfirmations):t.confirmations,g={chainAction:t.chainAction,chainAssetAction:t.chainAssetAction.get(r),blockHeight:t.blockHeight,confirmations:b,currencyCode:p,feeRateUsed:t.feeRateUsed,date:t.date,isSend:t.isSend,memos:t.memos,metadata:{},nativeAmount:null!==(i=t.nativeAmount.get(r))&&void 0!==i?i:"0",networkFee:null!==(a=t.networkFee.get(r))&&void 0!==a?a:"0",networkFees:[],otherParams:rc({},t.otherParams),ourReceiveAddresses:t.ourReceiveAddresses,parentNetworkFee:h===p?void 0:null!==(s=t.networkFee.get(null))&&void 0!==s?s:"0",signedTx:t.signedTx,tokenId:r,txid:t.txid,walletId:c};if(null!=n){var w,v,m,I,E,S,O,A,T;n.creationDate<g.date&&(g.date=n.creationDate),g.metadata=Mi(null!==(w=null!==(v=null===(m=n.tokens.get(null))||void 0===m?void 0:m.metadata)&&void 0!==v?v:null===(I=n.currencies.get(h))||void 0===I?void 0:I.metadata)&&void 0!==w?w:{},null!==(E=null!==(S=null===(O=n.tokens.get(r))||void 0===O?void 0:O.metadata)&&void 0!==S?S:null===(A=n.currencies.get(p))||void 0===A?void 0:A.metadata)&&void 0!==E?E:{}),null!=n.feeRateRequested&&("string"==typeof n.feeRateRequested?g.networkFeeOption=n.feeRateRequested:(g.networkFeeOption="custom",g.requestedCustomFee=n.feeRateRequested)),null==g.feeRateUsed&&(g.feeRateUsed=n.feeRateUsed),null!=n.payees&&(g.spendTargets=n.payees.map((e=>({currencyCode:e.currency,memo:e.tag,nativeAmount:e.amount,publicAddress:e.address,uniqueIdentifier:e.tag}))));const e=null===(T=n.tokens.get(r))||void 0===T?void 0:T.assetAction;null!=e&&(g.assetAction=e),null!=n.savedAction&&(g.savedAction=n.savedAction),null!=n.swap&&(g.swapData=n.swap),null!=n.secret&&(g.txSecret=n.secret),null!=n.deviceDescription&&(g.deviceDescription=n.deviceDescription)}return g}function sc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function cc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const uc="publicKey.json",lc=Er(Vi),dc=br({engine:e=>async()=>{const{state:t,walletId:n,walletState:r}=e.props,{accountId:o,pluginId:i,walletInfo:a}=r,s=t.plugins.currency[i],{currencyCode:c}=s.currencyInfo;try{var u,l;const t=yu(e);await po(t,a);const{state:r}=e.props,d=go(r,a.id),f=function(e,t,n){return to(n,e.storageWallets[t].paths.dataKey,e.storageWallets[t].localDisklet)}(r,a.id,e.props.io);await ys(e);const p=await Xr(t,i),h=await fc(a,d,p);e.props.dispatch({type:"CURRENCY_WALLET_PUBLIC_INFO",payload:{walletInfo:h,walletId:n}});const{checkpoint:y,subscribedAddresses:b}=await async function(e){var t;const{dispatch:n,state:r,walletId:o}=e.props,i=bo(r,o),a=await is.load(i,Za),s=null!=a?a:{checkpoint:void 0,subscribedAddresses:[]},c=s.checkpoint,u=null!==(t=s.subscribedAddresses)&&void 0!==t?t:[];if(null!=c&&n({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:c,walletId:o}}),u.length>0){const e=u.map((({address:e,checkpoint:t})=>({address:e,checkpoint:t,status:"subscribing"})));n({type:"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES",payload:{subscribedAddresses:e,walletId:o}})}return{checkpoint:c,subscribedAddresses:u}}(e);await ps(e);const g=r.accounts[o],w=await s.makeCurrencyEngine(h,{callbacks:qs(e),seenTxCheckpoint:y,subscribedAddresses:b,log:Cr(e.props.logBackend,`${i}-${a.id.slice(0,2)}`),walletLocalDisklet:d,walletLocalEncryptedDisklet:f,customTokens:null!==(u=g.customTokens[i])&&void 0!==u?u:{},enabledTokenIds:e.props.walletState.allEnabledTokenIds,userSettings:null!==(l=g.userSettings[i])&&void 0!==l?l:{}});e.onOutput(w);const v={currencyCode:c,tokenId:null},m=ge(Ri)(w.getBalance(v));null!=m&&e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:m,tokenId:null,walletId:n}});const I=w.getBlockHeight();e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:I,walletId:n}}),null!=w.getStakingStatus&&await w.getStakingStatus().then((t=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:t,walletId:n}})}),(t=>e.props.onError(t))),await ds(e),await fs(e),await bs(e)}catch(d){e.props.onError(d),e.props.dispatch({type:"CURRENCY_ENGINE_FAILED",payload:{error:d,walletId:n}})}return zs(e),await Ir},walletApi:e=>async()=>{const{walletOutput:t,walletState:n}=e.props;if(null==t)return;const{engine:r}=t,{nameLoaded:o,pluginId:i,publicWalletInfo:a}=n;if(null==r||null==a||!o)return;const s=await Xr(yu(e),i),c=ic(e,r,s,a);return e.onOutput(c),await Ir},engineStarted:vr((e=>{let t;return{update(){const{log:n,walletId:r,walletOutput:o,walletState:i}=e.props;if(null==o)return;const{engine:a,walletApi:s}=o;null!=s&&i.fiatLoaded&&!i.engineStarted&&null!=a&&null==t&&(n(`${r} startEngine`),e.props.dispatch({type:"CURRENCY_ENGINE_STARTED",payload:{walletId:r}}),t=Promise.resolve().then((()=>a.startEngine())).then((()=>{e.onOutput(!0)})).catch((t=>e.props.onError(t))))},destroy(){const{log:n,walletId:r,walletOutput:o}=e.props;if(null==o)return;const{engine:i}=o;null!=i&&null!=t&&(n(`${r} killEngine`),t.then((()=>i.killEngine())).catch((t=>e.props.onError(t))).then((()=>{e.onOutput(!1),e.props.dispatch({type:"CURRENCY_ENGINE_STOPPED",payload:{walletId:r}})})).catch((()=>{})))}}}),(e=>e.state.paused||e.walletState.paused?void 0:e)),syncNetworkUpdate:vr((e=>({async update(e){if(null==e.walletOutput)return;const{engine:t,engineStarted:n}=e.walletOutput;if(null==(null==t?void 0:t.syncNetwork)||!n)return;const{walletState:r}=e,{currencyInfo:o,walletInfo:i,publicWalletInfo:a}=r,s=!0===o.unsafeSyncNetwork&&null!=a?i.keys:void 0;for(const c of r.changeServiceSubscriptions)await t.syncNetwork({privateKeys:s,subscribeParam:{address:c.address,checkpoint:c.checkpoint,needsSync:"syncing"===c.status}});e.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:r.changeServiceSubscriptions.map((e=>cc(cc({},e),{},{status:"listening"}))),walletId:e.walletId}})},destroy(){}})),(e=>!e.state.paused&&!e.walletState.paused&&e.walletState.engineStarted&&e.walletState.changeServiceSubscriptions.some((e=>"syncing"===e.status||"synced"===e.status))?e:void 0)),syncNetworkTask:vr((e=>{const t=Hr((async()=>{if(null==e.props.walletOutput)return;const{engine:n,engineStarted:r}=e.props.walletOutput;if(null==(null==n?void 0:n.syncNetwork)||!r)return void t.stop();const{walletState:o}=e.props,{currencyInfo:i,walletInfo:a,publicWalletInfo:s}=o,c=!0===i.unsafeSyncNetwork&&null!=s?a.keys:void 0,u=await n.syncNetwork({privateKeys:c});t.setDelay(u)}),1e4,{onError:t=>{e.props.log.error(t)}});return{update(e){if(null==e.walletOutput)return;const{engine:n,engineStarted:r}=e.walletOutput;null==(null==n?void 0:n.syncNetwork)||!r||null!=t&&t.started||t.start({wait:!1})},destroy(){null!=t&&t.stop()}}}),(e=>e.state.paused||e.walletState.paused||!e.walletState.engineStarted||!0===e.walletState.currencyInfo.usesChangeServer&&!e.walletState.changeServiceSubscriptions.some((e=>"avoiding"===e.status||"reconnecting"===e.status||"resubscribing"===e.status||"subscribingSlowly"===e.status))?void 0:e)),syncTimer:vr((e=>{const t=Hr((async function(){const{walletId:t}=e.props;await ho(yu(e),t)}),fo);return{update(){const{state:n,walletId:r,walletOutput:o}=e.props;null!=o&&null!=n.storageWallets[r]&&n.storageWallets[r].status.lastSync>0&&t.start({wait:fo*(1+Math.random())})},destroy(){t.stop()}}}),(e=>e.state.paused||e.walletState.paused?void 0:e)),tokenSaver(e){let t=Ds;return async function(){const{detectedTokenIds:n,enabledTokenIds:r,tokenFileDirty:o,tokenFileLoaded:i}=e.props.walletState;if(o&&i){const o=pc(r,t),i=pc(t,r),a=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${a} write to disk, add [${o}], remove [${i}]`),await async function(e,t,n){const{state:r,walletId:o}=e.props,i=bo(r,o);await as.save(i,Qa,{detectedTokenIds:t,enabledTokenIds:n})}(e,n,r).catch((t=>e.props.onError(t))),e.props.dispatch({type:"CURRENCY_WALLET_SAVED_TOKEN_FILE",payload:{walletId:e.props.walletId}}),await Yr(100)}t=r}},watcher(e){let t,n={},r={},o=Ds;return async()=>{var i,a;const{state:s,walletState:c,walletOutput:u}=e.props;if(null==c||null==u)return;const{engine:l,walletApi:d}=u,{accountId:f,pluginId:p}=c,h=s.accounts[f];t!==c&&null!=d&&U(d),t=c;const y=null!==(i=h.userSettings[p])&&void 0!==i?i:n;n!==y&&null!=l&&await l.changeUserSettings(y),n=y;const b=null!==(a=h.customTokens[p])&&void 0!==a?a:r;if(r!==b&&null!=l)if(null!=l.changeCustomTokens)await l.changeCustomTokens(b);else if(null!=l.addCustomToken)for(const t of Object.keys(b)){const n=b[t];if(n===r[t])continue;const o=Lo(n);null!=o&&await l.addCustomToken(cc(cc({},o),n)).catch((t=>e.props.onError(t)))}r=b;const{allEnabledTokenIds:g}=c;if(o!==g&&null!=l)if(null!=l.changeEnabledTokenIds)await l.changeEnabledTokenIds(g).catch((t=>e.props.onError(t)));else if(null!=l.disableTokens&&null!=l.enableTokens){const t=za(h.builtinTokens[p],h.customTokens[p],c.currencyInfo,$a(o,g)),n=za(h.builtinTokens[p],h.customTokens[p],c.currencyInfo,$a(g,o));await l.disableTokens(t).catch((t=>e.props.onError(t))),await l.enableTokens(n).catch((t=>e.props.onError(t)))}o=g}}});async function fc(e,t,n){const r=await lc.load(t,uc);if(null!=r&&(null==n.checkPublicKey||await n.checkPublicKey(r.walletInfo.keys)))return r.walletInfo;let o={};try{o=await n.derivePublicKey(e)}catch(a){}const i={id:e.id,type:e.type,keys:o};return Object.keys(o).length>0&&await lc.save(t,uc,{walletInfo:i}),i}function pc(e,t){const n=new Set(t);return e.filter((e=>!n.has(e))).join(", ")}async function hc(e,t,n){const{stashTree:r}=An(e,t.loginId),{deviceDescription:o}=e.props.state.login.deviceInfo,i=Zn(r,t);null!=o&&(i.deviceDescription=o),i.data=bt(n);const a=await gn(e,"POST","/v2/login/vouchers",i),s=Gn(r,t.loginKey,Je(a));return await Pn(e,s)}function yc(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const bc=["fromWallet","toWallet"];function gc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function vc(e,t,n,r={}){const{disabled:o={},noResponseMs:i,preferPluginId:a,promoCodes:s={},slowResponseMs:c=2e4}=r,{log:u,state:l}=e.props,d=l.accounts[t],{swapSettings:f,userSettings:p}=d,h=l.plugins.swap;u.warn("Requesting swap quotes for: ",wc(wc({},n),{},{fromWallet:n.fromWallet.id,toWallet:n.toWallet.id}),{preferPluginId:a,promoCodes:s});const y=new Set,b=[];for(const m of Object.keys(h)){var g,w;const{enabled:e=!0}=null!=f[m]?f[m]:{};e&&!o[m]&&(y.add(m),b.push(h[m].fetchSwapQuote(n,p[m],{infoPayload:null!==(g=null===(w=l.infoCache.corePlugins)||void 0===w?void 0:w[m])&&void 0!==g?g:{},promoCode:s[m]}).then((e=>{var t;Wo(e);const n=null!==(t=e.request)&&void 0!==t?t:{},{fromWallet:r,toWallet:o}=n,i=yc(n,bc),a=wc(wc({},e),{},{request:i});return y.delete(m),u.warn(`${m} gave swap quote:`,a),e}),(e=>{throw y.delete(m),u.warn(`${m} gave swap error: ${String(e)}`),Ic(e)&&u.crash(`Unknown swap error: ${String(e)}`,{error:e,swapPluginId:m,request:{fromToken:String(n.fromTokenId),fromWalletType:n.fromWallet.type,toToken:String(n.toTokenId),toWalletType:n.toWallet.type,quoteFor:n.quoteFor}}),e}))))}const v=function(e,t){return new Promise(((n,r)=>{let o=!1;const i=[],a=[];let s=setTimeout((()=>{s=void 0,i.length>0&&(o=!0,n({results:i,errors:a}))}),t);function c(){const t=i.length+a.length===e.length;t&&null!=s&&clearTimeout(s),(t||null==s&&i.length>0)&&(o=!0,i.length>0?n({results:i,errors:a}):r(a))}c();for(const t of e)t.then((e=>{o||(i.push(e),c())}),(e=>{o||(a.push(e),c())}))}))}(b,c).then((({results:e,errors:t})=>{for(const n of y)u.warn(`${n} gave swap timeout`);const o=function(e,t){const{preferPluginId:n,preferType:r,promoCodes:o}=t;return e.sort(((e,t)=>{if("transfer"===e.pluginId)return-1;if("transfer"===t.pluginId)return 1;if(e.pluginId===n)return-1;if(t.pluginId===n)return 1;if(null!=r){const n=!0===e.swapInfo.isDex&&"DEX"===r||!0!==e.swapInfo.isDex&&"CEX"===r,o=!0===t.swapInfo.isDex&&"DEX"===r||!0!==t.swapInfo.isDex&&"CEX"===r;if(n&&!o)return-1;if(!n&&o)return 1}if(null!=o){const n=null!=o[e.pluginId],r=null!=o[t.pluginId];if(n&&!r)return-1;if(!n&&r)return 1}const{isEstimate:i=!0}=e,{isEstimate:a=!0}=t;if(!i&&a)return-1;if(i&&!a)return 1;const s=Number(e.toNativeAmount)/Number(e.fromNativeAmount),c=Number(t.toNativeAmount)/Number(t.fromNativeAmount);return s>c?-1:c>s?1:0}))}(e,r);return u.warn(`${b.length} swap quotes requested, ${e.length} resolved, ${t.length} failed, sorted ${o.map((e=>e.pluginId)).join(", ")}.`),e.map((e=>function(e,t,n){var r,o;const i=_({canBePartial:n.canBePartial,expirationDate:n.expirationDate,fromNativeAmount:n.fromNativeAmount,isEstimate:n.isEstimate,maxFulfillmentSeconds:n.maxFulfillmentSeconds,networkFee:n.networkFee,pluginId:n.pluginId,request:null!==(r=n.request)&&void 0!==r?r:t,swapInfo:null!==(o=n.swapInfo)&&void 0!==o?o:e[n.pluginId].swapInfo,toNativeAmount:n.toNativeAmount,minReceiveAmount:n.minReceiveAmount,async approve(e){return await n.approve(e)},async close(){await n.close(),B(i)}});return i}(h,n,e)))}),(e=>{throw u.warn(`All ${b.length} swap quotes rejected.`),function(e){return e.reduce(((e,t)=>{const n=mc(e)-mc(t);if(n>0)return e;if(n<0)return t;const r=Xt(e),o=Xt(t);if(null!=r&&null!=o)return(0,Uo.lt)(r.nativeMin,o.nativeMin)?r:o;const i=Jt(e),a=Jt(t);return null!=i&&null!=a?(0,Uo.gt)(i.nativeMax,a.nativeMax)?i:a:e}))}(e)}));return null==i?await v:await bn(v,i)}function mc(e){return null==e?0:null!=zt(e)||null!=Vt(e)?6:null!=Xt(e)?5:null!=Jt(e)?4:null!=en(e)?3.5:null!=Qt(e)?3:null!=Zt(e)?2:1}function Ic(e){return!(mc(e)>1)}const Ec=Er(ye({name:le})),Sc=Er(ye({key:le,data:le}));function Oc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ac(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}let Tc=0;const _c=async(e,t,n,r={})=>{var o;const{keys:i}=r;if(null==i)throw new Error("No keys provided");const a="memorywallet-"+Tc++,s={id:a,type:n,keys:i},c=await Xr(e,t.currencyInfo.pluginId),u=await c.derivePublicKey(s);s.keys=Ac(Ac({},u),s.keys);const l=Cr(e.props.logBackend,`${a}-${n}`);let d=new Map,f=[],p={totalRatio:0},h=!1;const y=Hr((async()=>{await Yr(1e3),h&&(U(O),h=!1)}),0),b=e.props.state.plugins.currency[t.currencyInfo.pluginId],g={onAddressChanged:()=>{},onAddressesChecked(e){g.onSyncStatusChanged({totalRatio:e})},onNewTokens:e=>{const t=e.sort(((e,t)=>e.localeCompare(t)));if(f.length!==t.length)return f=t,void(h=!0);for(let n=0;n<t.length;n++)if(f[n]!==t[n])return f=t,void(h=!0)},onSeenTxCheckpoint:()=>{},onStakingStatusChanged:()=>{},onSubscribeAddresses:()=>{},onSyncStatusChanged(e){1!==p.totalRatio&&1===e.totalRatio&&(p=e,h=!0)},onTokenBalanceChanged:(e,t)=>{d.get(e)!==t&&(d=new Map(d),d.set(e,t),h=!0)},onTransactions:()=>{},onTransactionsChanged:()=>{},onTxidsChanged:()=>{},onUnactivatedTokenIdsChanged:()=>{},onWcNewContractCall:()=>{},onBlockHeightChanged:()=>{},onBalanceChanged:()=>{}},w=await b.makeCurrencyEngine(s,{callbacks:g,customTokens:Ac({},t.customTokens),enabledTokenIds:[...Object.keys(t.allTokens)],lightMode:!0,log:l,userSettings:Ac({},null!==(o=t.userSettings)&&void 0!==o?o:{}),walletLocalDisklet:(0,ee.Wh)(),walletLocalEncryptedDisklet:(0,ee.Wh)()}),{unsafeBroadcastTx:v=!1,unsafeMakeSpend:m=!1,unsafeSyncNetwork:I=!1}=b.currencyInfo,E=Ac({},i);let S;if(null!=w.syncNetwork){const t=async()=>{if(null!=w.syncNetwork){const e=await w.syncNetwork({privateKeys:I?{privateKeys:i}:void 0});S.setDelay(e)}else S.stop()};S=Hr(t,1e4,{onError:t=>{e.props.log.error(t)}}),S.start({wait:!1})}const O=_({watch:X,get balanceMap(){return d},get detectedTokenIds(){return f},get syncRatio(){return p.totalRatio},get syncStatus(){return p},async changeEnabledTokenIds(e){null!=w.changeEnabledTokenIds&&await w.changeEnabledTokenIds(e)},async startEngine(){var e;await w.startEngine(),null===(e=S)||void 0===e||e.start({wait:!1})},async getMaxSpendable(e){return await tc(e,b,w,t.allTokens,s)},async makeSpend(e){return await w.makeSpend(e,m?E:void 0)},async signTx(e){return await w.signTx(e,E)},async broadcastTx(e){return await w.broadcastTx(e,v?E:void 0)},async saveTx(){},async close(){var e;l.warn("killing memory wallet"),null===(e=S)||void 0===e||e.stop(),B(O),await w.killEngine()}});return y.start({wait:!1}),O};function kc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function xc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Pc={},Mc=[];class Cc extends Z{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n;const{otherMethods:r}=e.props.state.plugins.currency[n];null!=r?(_(r),this.otherMethods=r):this.otherMethods={}}get currencyInfo(){return this._ai.props.state.plugins.currency[this._pluginId].currencyInfo}get allTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].allTokens[n]}get builtinTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].builtinTokens[n]}get customTokens(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].customTokens[r])&&void 0!==e?e:Pc}async getTokenDetails(e){const{_ai:t,_pluginId:n}=this,r=await Xr(t,n);return null==r.getTokenDetails?[]:await r.getTokenDetails(e)}async getTokenId(e){const{_ai:t,_pluginId:n}=this;return await No(t,n,e)}async addCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this,o=await No(n,r,e);return n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:t,pluginId:r,tokenId:o,token:e}}),o}async changeCustomToken(e,t){const{_accountId:n,_ai:r,_pluginId:o}=this;if(null==r.props.state.accounts[n].customTokens[o][e])throw new Error(`There is no token with id "${e}"`);const i=await No(r,o,t);if(r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:n,pluginId:o,tokenId:i,token:t}}),i!==e){const{wallets:t}=r.props.state.currency;for(const a of Object.keys(t)){const s=t[a];if(s.accountId!==n||s.pluginId!==o||!s.enabledTokenIds.includes(e))continue;const c=a.slice(0,2);r.props.log.warn(`enabledTokenIds: ${c} changeCustomToken edited id`),r.props.dispatch({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:a,enabledTokenIds:$a([...s.enabledTokenIds,i],[e])}})}r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:n,pluginId:o,tokenId:e}})}}async removeCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:t,pluginId:r,tokenId:e}})}get alwaysEnabledTokenIds(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].alwaysEnabledTokenIds[r])&&void 0!==e?e:Mc}async changeAlwaysEnabledTokenIds(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED",payload:{accountId:t,pluginId:r,tokenIds:e}})}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeUserSettings(e){await yi(this._ai,this._accountId,this._pluginId,e)}async importKey(e,t={}){const n=await Xr(this._ai,this._pluginId);if(null==n.importPrivateKey)throw new Error("This wallet does not support importing keys");return xc(xc({},await n.importPrivateKey(e,t.keyOptions)),{},{imported:!0})}}class Nc extends Z{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n}get enabled(){const{swapSettings:e}=this._ai.props.state.accounts[this._accountId],{enabled:t=!0}=null!=e[this._pluginId]?e[this._pluginId]:{};return t}get needsActivation(){var e,t;const n=this._ai.props.state.plugins.swap[this._pluginId];if(null==n.checkSettings)return!1;const r=null!==(e=this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId])&&void 0!==e?e:{};return null!==(t=n.checkSettings(r).needsActivation)&&void 0!==t&&t}get swapInfo(){return this._ai.props.state.plugins.swap[this._pluginId].swapInfo}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeEnabled(e){const t=this._ai.props.state.accounts[this._accountId];return await async function(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=bo(e.props.state,i.id),s=null!==(o=await ui.load(a,di))&&void 0!==o?o:li;await ui.save(a,di,ai(ai({},s),{},{swapSettings:ai(ai({},e.props.state.accounts[t].swapSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_SWAP_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,swapSettings:r}})}(this._ai,this._accountId,this._pluginId,xc(xc({},t.swapSettings[this._pluginId]),{},{enabled:e}))}async changeUserSettings(e){await yi(this._ai,this._accountId,this._pluginId,e)}}function jc(e,t){let n=e.props.state.accounts[t];const r=()=>{const r=e.props.state.accounts[t];return null!=r&&(n=r),n},{accountWalletInfo:o,loginType:i}=r(),a={};for(const p of Object.keys(e.props.state.plugins.currency)){const n=new Cc(e,t,p);a[p]=n}const s={};for(const p of Object.keys(e.props.state.plugins.swap)){const n=new Nc(e,t,p);s[p]=n}const c=function(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=bo(e.props.state,n.id),o=t=>wo(e.props.state,n.id,t),i=e=>`Plugins/${o(e)}`,a=(e,t)=>`${i(e)}/${o(t)}.json`,s={async deleteItem(e,t){await r.delete(a(e,t))},async deleteStore(e){await r.delete(i(e))},async listItemIds(e){const t=[],n=(0,ee.gQ)(await r.list(i(e)));return await Promise.all(n.map((async e=>{const n=await Sc.load(r,e);null!=n&&t.push(n.key)}))),t},async listStoreIds(){const e=[],t=(0,ee.ji)(await r.list("Plugins"));return await Promise.all(t.map((async t=>{const n=await Ec.load(r,`${t}/Name.json`);null!=n&&e.push(n.name)}))),e},async getItem(e,t){const n=await Sc.load(r,a(e,t));if(null==n)throw new Error(`No item named "${t}"`);return n.data},async setItem(e,t,n){const o=`${i(e)}/Name.json`,s=await Ec.load(r,o);if(null==s)await Ec.save(r,o,{name:e});else if(s.name!==e)throw new Error(`Warning: folder name doesn't match for ${e}`);await Sc.save(r,a(e,t),{key:t,data:n})}};return _(s),s}(e,t),u=Ei(e,o);function l(){if(e.props.state.hideKeys)throw new Error("Not available when `hideKeys` is enabled")}let d=!1;const f={on:J,watch:X,get id(){return u.id},get type(){return u.type},get disklet(){return l(),u.disklet},get localDisklet(){return l(),u.localDisklet},async sync(){await u.sync()},get appId(){return r().login.appId},get created(){return r().login.created},async getLoginKey(){return l(),jt.stringify(r().login.loginKey)},get lastLogin(){return r().login.lastLogin},get loggedIn(){return null!=e.props.state.accounts[t]},get recoveryKey(){l();const{login:e}=r();return null!=e.recovery2Key?jt.stringify(e.recovery2Key):void 0},get rootLoginId(){l();const{loginTree:e}=r();return jt.stringify(e.loginId)},get username(){const{loginTree:e}=r();return e.username},get canDuressLogin(){const{activeAppId:t}=r();if(e.props.state.clientInfo.duressEnabled)return d;const n=t.endsWith(".duress")?t:t+".duress",o=Un(r().loginTree,(e=>e.appId===n));return null!=(null==o?void 0:o.pin2Key)},get isDuressAccount(){const{activeAppId:e}=r();return e.endsWith(".duress")},get currencyConfig(){return a},get swapConfig(){return s},get dataStore(){return c},get edgeLogin(){const{loginTree:e}=r();return null==e.loginKey},keyLogin:"keyLogin"===i,newAccount:"newAccount"===i,passwordLogin:"passwordLogin"===i,pinLogin:"pinLogin"===i,recoveryLogin:"recoveryLogin"===i,async changePassword(n){l(),this.isDuressAccount||await async function(e,t,n){const r=e.props.state.accounts[t],{loginTree:o,sessionKey:i}=r,{username:a}=r.stashTree;if(null==a)throw new Error("Password login requires a username");const s=await oa(e,o,a,n);await Yn(e,i,s)}(e,t,n)},async changePin(n){l(),e.props.log.breadcrumb("EdgeAccount.changePin",{});const{forDuressAccount:o=!1}=n,{activeAppId:i}=r(),a=i.endsWith(".duress")?i:i+".duress";var s;if(this.isDuressAccount&&o)return d=null!==(s=n.enableLogin)&&void 0!==s?s:null!=n.pin,e.props.dispatch({type:"UPDATE_NEXT"}),"";o&&await Ta(e,r().stashTree,r().sessionKey,a),await ua(e,t,n);const c=o?Un(r().login,(e=>e.appId===a)):r().login;if(null==c)throw new Error("Failed to find account.");return null!=c.pin2Key?jt.stringify(c.pin2Key):""},async changeRecovery(n,o){if(l(),this.isDuressAccount)return"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";await ba(e,t,n,o);const{loginTree:i}=r();if(null==i.recovery2Key)throw new Error("Missing recoveryKey");return jt.stringify(i.recovery2Key)},async changeUsername(n){l(),n.username=re(n.username),await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=await Promise.all(function t(r){const o=[Ia(e,r,n)];for(const e of r.children)o.push(...t(e));return o}(r));await Vn(e,r,o)}(e,t,n)},async checkPassword(t){l();const{loginTree:n,stashTree:o}=r(),{loginKey:i}=n;return await async function(e,t,n,r){if(null!=r){const{passwordAuthBox:o,username:i}=t;if(null==o||null==i)return!1;const a=un(o,r),s=na(i,n),c=await In(e,s,ta);for(let e=0;e<a.length;++e)if(c[e]!==a[e])return!1;return!0}{const{passwordBox:r,passwordKeySnrp:i,username:a}=t;if(null==r||null==i||null==a)throw new Error("Missing data for offline password login");const s=na(a,n),c=await In(e,s,i);try{return un(r,c),!0}catch(o){return!1}}}(e,o,t,i)},async checkPin(t,n={}){l();const{login:o,loginTree:i}=r();return null!=o.pin&&null==n.forDuressAccount?t===o.pin:await async function(e,t,n,r){const{loginId:o,username:i}=t;if(null==i)return!1;const a=!0===r?t.appId+".duress":t.appId;if(e.props.state.clientInfo.duressEnabled)return!1;const{stashTree:s}=An(e,o),c=!0===r?Nn(s,a):sa(s,a);if(null==c||null==c.pin2Key)throw new Wt("No PIN set locally for this account");const{pin2Key:u}=c,l={pin2Id:ia(u,i),pin2Auth:aa(u,n),otp:Rn(t)};return await gn(e,"POST","/v2/login",l).then((e=>!0),(e=>!1))}(e,i,t,n.forDuressAccount)},async getPin(){var e;const{login:t,loginTree:n}=r();return null!==(e=t.pin)&&void 0!==e?e:n.pin},async deletePassword(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/password",stash:{passwordAuthSnrp:void 0,passwordBox:void 0,passwordKeySnrp:void 0}};null!=n.loginAuth&&(o.stash.passwordAuthBox=void 0),await Yn(e,r,o)}(e,t)},async deletePin(){l();const n=e.props.state.clientInfo.duressEnabled;await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=pa(r,n);await Vn(e,r,o)}(e,t,n)},async deleteRecovery(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={login:{recovery2Key:void 0},loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/recovery2",stash:{recovery2Key:void 0}};await Yn(e,r,o)}(e,t)},get otpKey(){l();const{loginTree:e}=r();return null!=e.otpKey?h.stringify(e.otpKey,{pad:!1}):void 0},get otpResetDate(){l();const{loginTree:e}=r();return e.otpResetDate},async cancelOtpReset(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],{otpTimeout:o,otpKey:i}=n;if(null==o||null==i)throw new Error("Cannot cancel 2FA reset: 2FA is not enabled.");const a={loginId:n.loginId,server:ct({otpTimeout:o,otpKey:i}),serverPath:"/v2/login/otp",stash:{otpResetDate:void 0}};await Yn(e,r,a)}(e,t)},async enableOtp(n=604800){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t],r=e.props.io.random(10);await Pn(e,Dn(Dn({},n),{},{otpKey:r}))}(e,t);await async function(e,t,n){const{loginTree:r,sessionKey:o}=e.props.state.accounts[t],{otpKey:i=e.props.io.random(10)}=r,a={loginId:r.loginId,server:ct({otpKey:i,otpTimeout:n}),serverPath:"/v2/login/otp",stash:{otpKey:i,otpResetDate:void 0,otpTimeout:n}};await Yn(e,o,a)}(e,t,n)},async disableOtp(){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t];await Pn(e,Dn(Dn({},n),{},{otpKey:void 0}))}(e,t);await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/otp",stash:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0}};await Yn(e,r,o)}(e,t)},async repairOtp(n){l(),await async function(e,t,n){if(null==e.props.state.accounts[t])return;const{login:r}=e.props.state.accounts[t],{userId:o,passwordAuth:i}=r,{stashTree:a,stash:s}=An(e,r.loginId);if(null==i||null==o)throw new Error("Cannot repair OTP: There is no password on this account");const c={userId:o,passwordAuth:i,otp:pn(n)},u={now:a.lastLogin};await Hn(e,a,s,u,c,(async()=>r.loginKey))}(e,t,h.parse(n,{loose:!0}))},get pendingVouchers(){const{login:e}=r();return e.pendingVouchers},async approveVoucher(t){const{loginTree:n}=r();return await hc(e,n,{approvedVouchers:[t]})},async rejectVoucher(t){const{loginTree:n}=r();return await hc(e,n,{rejectedVouchers:[t]})},async fetchLobby(n){return e.props.log.breadcrumb("EdgeAccount.fetchLobby",{}),l(),await Ga(e,t,n)},async deleteRemoteAccount(){const{loginTree:t}=r();this.isDuressAccount||await async function(e,t){const{stashTree:n}=An(e,t.loginId),{deviceDescription:r}=e.props.state.login.deviceInfo,o=Zn(n,t);null!=r&&(o.deviceDescription=r),await gn(e,"POST","/v2/login/delete",o)}(e,t)},async logout(){e.props.dispatch({type:"LOGOUT",payload:{accountId:t}})},get allKeys(){return e.props.state.accounts[t].allWalletInfosClean},async changeWalletStates(n){await hi(e,t,n)},async createWallet(t,n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.createWallet",{});const s=await ri(e,t,{keys:n}),c=Xn(a,i,o.loginId);return await Yn(e,i,Qo(e,c,[s])),s.id},getFirstWalletInfo:te.prototype.getFirstWalletInfo,getWalletInfo:te.prototype.getWalletInfo,listWalletIds:te.prototype.listWalletIds,async splitWalletInfo(n,o){var i,a;const{allWalletInfosFull:s}=r(),c=s.find((e=>e.id===n));if(null==c)throw new Error(`Invalid wallet id ${n}`);const u=null===(i=e.props.output)||void 0===i||null===(i=i.currency)||void 0===i||null===(i=i.wallets[c.id])||void 0===i?void 0:i.walletApi;if("wallet:bitcoin"===c.type&&"bip49"===c.keys.format&&"wallet:bitcoincash"===o)throw new Error("Cannot split segwit-format Bitcoin wallets to Bitcoin Cash");const[l]=await mi(e,t,c,[{walletType:o,name:null!==(a=null==u?void 0:u.name)&&void 0!==a?a:void 0,fiatCurrencyCode:null==u?void 0:u.fiatCurrencyCode}],!0);if(l.ok)return l.result.id;throw l.error},async listSplittableWalletTypes(n){return await async function(e,t,n){const{allWalletInfosFull:r}=e.props.state.accounts[t],o=r.find((e=>e.id===n));if(null==o)throw new Error(`Invalid wallet id ${n}`);const i=Jr(e.props.state.plugins.currency,o.type);if(null==i)return[];const a=await Xr(e,i);return null==a.getSplittableTypes?[]:(await a.getSplittableTypes(o)).filter((e=>{const t=vi(o,e),n=r.find((e=>e.id===t.id));return null==n||n.archived||n.deleted}))}(e,t,n)},async getDisplayPrivateKey(n){const r=Dc(e,t,n),o=Vr(e.props.state.plugins.currency,r.type),i=await Xr(e,o);if(null!=i.getDisplayPrivateKey)return await i.getDisplayPrivateKey(r);const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPrivateSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPrivateSeed(r.keys);if(null==s)throw new Error("The engine failed to return a key");return s},async getDisplayPublicKey(n){const r=Dc(e,t,n),o=Vr(e.props.state.plugins.currency,r.type),i=await Xr(e,o);if(null!=i.getDisplayPublicKey){const t=oo(e.props.io,n),o=await fc(r,t,i);return await i.getDisplayPublicKey(o)}const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPublicSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPublicSeed();if(null==s)throw new Error("The engine failed to return a key");return s},async getRawPrivateKey(n){return Dc(e,t,n).keys},async getRawPublicKey(n){const r=Dc(e,t,n),o=Vr(e.props.state.plugins.currency,r.type),i=await Xr(e,o),a=oo(e.props.io,n);return(await fc(r,a,i)).keys},get activeWalletIds(){return e.props.state.accounts[t].activeWalletIds},get archivedWalletIds(){return e.props.state.accounts[t].archivedWalletIds},get hiddenWalletIds(){return e.props.state.accounts[t].hiddenWalletIds},get currencyWallets(){return e.props.output.accounts[t].currencyWallets},get currencyWalletErrors(){return e.props.state.accounts[t].currencyWalletErrors},async createCurrencyWallet(n,o={}){const{login:i,sessionKey:a,stashTree:s}=r();e.props.log.breadcrumb("EdgeAccount.createCurrencyWallet",{});const c=await ri(e,n,o),u=Xn(s,a,i.loginId);return await Yn(e,a,Qo(e,u,[c])),await oi(e,t,c.id,o)},async makeMemoryWallet(t,n={}){const r=Object.values(a).find((e=>e.currencyInfo.walletType===t));if(null==r)throw new Error("Invalid walletType");return await _c(e,r,t,n)},async createCurrencyWallets(n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.makeMemoryWallet",{});const s=await Promise.all(n.map((async t=>await ri(e,t.walletType,t)))),c=Xn(a,i,o.loginId);return await Yn(e,i,Qo(e,c,s)),await Promise.all(s.map((async(r,o)=>await yo(oi(e,t,r.id,n[o])))))},async waitForCurrencyWallet(e){return await new Promise(((t,n)=>{const r=()=>{const r=this.currencyWallets[e];null!=r&&(t(r),o());const i=this.currencyWalletErrors[e];null!=i&&(n(i),o())},o=()=>{for(const e of i)e()},i=[this.watch("currencyWallets",r),this.watch("currencyWalletErrors",r)];r()}))},async waitForAllWallets(){return await new Promise(((e,t)=>{const n=()=>{if(null==this.activeWalletIds.find((e=>null==this.currencyWallets[e]&&null==this.currencyWalletErrors[e]))){for(const e of r)e();e()}},r=[this.watch("activeWalletIds",n),this.watch("currencyWallets",n),this.watch("currencyWalletErrors",n)];n()}))},async getActivationAssets({activateWalletId:n,activateTokenIds:r}){const{currencyWallets:o}=e.props.output.accounts[t],i=e.props.output.currency.wallets[n],{engine:a}=i;if(null==a)throw new Error(`Invalid wallet: ${n} not found`);if(null==a.engineGetActivationAssets)throw new Error(`getActivationAssets unsupported by walletId ${n}`);const s=await a.engineGetActivationAssets({currencyWallets:o,activateTokenIds:r});return s.assetOptions.forEach((e=>{var t;return e.tokenId=null!==(t=e.tokenId)&&void 0!==t?t:null})),s},async activateWallet(n){var r;const{activateWalletId:o,activateTokenIds:i,paymentInfo:a}=n,{currencyWallets:s}=e.props.output.accounts[t],c=e.props.output.currency.wallets[o],{engine:u}=c;if(null==u)throw new Error(`Invalid wallet: ${o} not found`);if(null==u.engineActivateWallet)throw new Error(`activateWallet unsupported by walletId ${o}`);const l=null!==(r=null==a?void 0:a.walletId)&&void 0!==r?r:"",d=s[l];if(null==d)throw new Error(`No wallet for walletId ${l}`);const f=await u.engineActivateWallet({activateTokenIds:i,paymentInfo:null!=a?{wallet:d,tokenId:a.tokenId}:void 0,paymentTokenId:null==a?void 0:a.tokenId,paymentWallet:d});return void 0===f.networkFee.tokenId&&(f.networkFee.tokenId=null),_(f)},async fetchSwapQuote(n,r){const[o,...i]=await vc(e,t,n,r);for(const e of i)e.close().catch((()=>{}));if(null==o)throw new Error("No swap providers enabled");return o},async fetchSwapQuotes(n,r){return await vc(e,t,n,r)}};return _(f),f}function Dc(e,t,n){const r=e.props.state.accounts[t].allWalletInfosFull.find((e=>e.id===n));if(null==r)throw new Error(`Invalid wallet: ${n} not found`);return r}function Rc(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function Lc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Bc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Kc={},Uc={loginId:new Uint8Array,loginKey:new Uint8Array},Fc=As({accountWalletInfo:Cs((e=>e.self.activeAppId),(e=>e.self.allWalletInfosFull),((e,t)=>{const n=Xo(e),r=Jo(t,n);if(null==r)throw new Error(`Cannot find a "${n}" repo`);return r})),accountWalletInfos:Cs((e=>e.self.activeAppId),(e=>e.self.allWalletInfosFull),((e,t)=>{const n=[Xo(e)];return""===e&&n.push("account:repo:co.airbitz.wallet",""),t.filter((e=>n.includes(e.type)))})),allWalletInfosFull:Cs((e=>e.self.stashTree),(e=>e.self.login),(e=>e.self.legacyWalletInfos),(e=>e.self.walletStates),((e,t,n,r)=>function(e,t,n,r){const o=new Map,i=new Map,a=[...n],s=Tn(e,t.loginId);for(const c of n){a.push(c);const e=i.get(c.id);null!=e?e.push(s.appId):i.set(c.id,[s.appId])}return function e(t,n){const r=ti(t,n,o);for(const o of r){a.push(o);const e=i.get(o.id);null!=e?e.push(t.appId):i.set(o.id,[t.appId])}for(const o of null!==(s=t.children)&&void 0!==s?s:[]){var s;null!=o.parentBox&&e(o,un(o.parentBox,n))}}(s,t.loginKey),ei(a).map((e=>{var t,n,s;return Vo(Vo({appId:(s=null!==(t=i.get(e.id))&&void 0!==t?t:[],s[s.length-1]),appIds:null!==(n=i.get(e.id))&&void 0!==n?n:[],archived:!1,created:o.get(e.id),deleted:!1,hidden:!1,sortIndex:a.length,imported:e.keys.imported},r[e.id]),e)}))}(e,t,n,r))),allWalletInfosClean:Cs((e=>e.self.allWalletInfosFull),(e=>e.map((e=>Bc(Bc({},e),{},{keys:{}}))))),currencyWalletErrors(e={},t,n,r){var o;const{activeWalletIds:i}=n.self,a=n.root.currency.wallets;let s=i!==(null===(o=r.self)||void 0===o?void 0:o.activeWalletIds);const c={};for(const u of i){const t=a[u].engineFailure;null!=t&&(c[u]=t),c[u]!==e[u]&&(s=!0)}return s?c:e},currencyWalletIds:Cs((e=>e.self.walletInfos),(e=>e.root.plugins.currency),((e,t)=>Object.keys(e).filter((n=>{const r=e[n],o=Jr(t,r.type);return!r.deleted&&null!=o})).sort(((t,n)=>{const r=e[t],o=e[n];return r.sortIndex-o.sortIndex})))),activeWalletIds:Cs((e=>e.self.walletInfos),(e=>e.self.currencyWalletIds),(e=>e.self.keysLoaded),((e,t,n)=>n?t.filter((t=>!e[t].archived)):[])),archivedWalletIds:Cs((e=>e.self.walletInfos),(e=>e.self.currencyWalletIds),(e=>e.self.keysLoaded),((e,t,n)=>n?t.filter((t=>e[t].archived)):[])),hiddenWalletIds:Cs((e=>e.self.walletInfos),(e=>e.self.currencyWalletIds),(e=>e.self.keysLoaded),((e,t,n)=>n?t.filter((t=>e[t].hidden)):[])),keysLoaded(e=!1,t){return"ACCOUNT_KEYS_LOADED"===t.type||e},legacyWalletInfos(e=[],t){return"ACCOUNT_KEYS_LOADED"===t.type?t.payload.legacyWalletInfos:e},walletInfos:Cs((e=>e.self.allWalletInfosFull),(e=>{const t={};for(const n of e)t[n.id]=n;return t})),walletStates(e={},t){return"ACCOUNT_CHANGED_WALLET_STATES"===t.type||"ACCOUNT_KEYS_LOADED"===t.type?t.payload.walletStates:e},pauseWallets(e=!1,t){return"LOGIN"===t.type?t.payload.pauseWallets:e},activeAppId:(e="",t)=>"LOGIN"===t.type?t.payload.appId:e,loadFailure(e=null,t){if("ACCOUNT_LOAD_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},login:Cs((e=>e.self.activeAppId),(e=>e.self.loginTree),((e,t)=>{const n=Un(t,(t=>t.appId===e));if(null==n)throw new Error(`Internal error: cannot find login for ${e}`);return n})),loginTree:Cs((e=>e.self.stashTree),(e=>e.self.sessionKey),((e,t)=>zn(e,t))),loginType(e="newAccount",t){return"LOGIN"===t.type?t.payload.loginType:e},rootLoginId(e=new Uint8Array(0),t){return"LOGIN"===t.type?t.payload.rootLoginId:e},sessionKey(e=Uc,t){return"LOGIN"===t.type?t.payload.sessionKey:e},stashTree:Cs((e=>e.self.rootLoginId),(e=>e.root.login.stashes),((e,t)=>{for(const n of t)if(an(n.loginId,e))return n;throw new Error("There is no stash")})),allTokens(e={},t,n,r){const{builtinTokens:o,customTokens:i}=n.self;if(null==r.self||o!==r.self.builtinTokens||i!==r.self.customTokens){const t=Bc({},e);for(const e of Object.keys(n.root.plugins.currency))null!=r.self&&o[e]===r.self.builtinTokens[e]&&i[e]===r.self.customTokens[e]||(t[e]=Bc(Bc({},i[e]),o[e]));return t}return e},builtinTokens(e={},t){if("ACCOUNT_BUILTIN_TOKENS_LOADED"===t.type){const{pluginId:n,tokens:r}=t.payload;return Bc(Bc({},e),{},{[n]:r})}return e},customTokens(e=Kc,t){switch(t.type){case"ACCOUNT_CUSTOM_TOKENS_LOADED":{const{customTokens:e}=t.payload;return e}case"ACCOUNT_CUSTOM_TOKEN_ADDED":{var n;const{pluginId:r,tokenId:o,token:i}=t.payload,a=null!==(n=e[r])&&void 0!==n?n:{};if(Oi(a[o],i))return e;const s=Bc(Bc({},a),{},{[o]:i});return Bc(Bc({},e),{},{[r]:s})}case"ACCOUNT_CUSTOM_TOKEN_REMOVED":{var r;const{pluginId:n,tokenId:o}=t.payload,i=null!==(r=e[n])&&void 0!==r?r:{};if(null==i[o])return e;const{[o]:a}=i,s=yc(i,[o].map(Rc));return Bc(Bc({},e),{},{[n]:s})}}return e},alwaysEnabledTokenIds(e={},t){if("ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED"===t.type){const{pluginId:n,tokenIds:r}=t.payload;return Bc(Bc({},e),{},{[n]:r})}return e},swapSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.swapSettings;case"ACCOUNT_SWAP_SETTINGS_CHANGED":{const{pluginId:n,swapSettings:r}=t.payload,o=Bc({},e);return o[n]=r,o}}return e},userSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_CHANGED":{const{pluginId:n,userSettings:r}=t.payload,o=Bc({},e);return o[n]=r,o}case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.userSettings}return e}}),Wc=ks(Fc,((e,t)=>/^ACCOUNT_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"accountId"in e.payload&&e.payload.accountId===t.id||"LOGIN"===e.type&&t.root.lastAccountId===t.id?e:{type:"UPDATE_NEXT"}));function Gc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Gc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Gc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const zc=br({accountApi(e){return{destroy(){e.props.state={accounts:{}};const{accountOutput:t}=e.props;if(null==t)return;const{accountApi:n}=t;if(null==n)return;U(n),B(n),B(n.dataStore);const{currencyConfig:r,swapConfig:o}=n;for(const e of Object.keys(r))B(r[e]);for(const e of Object.keys(o))B(o[e])},async update(){const t=yu(e),{accountId:n,accountState:r,log:o}=e.props,{accountWalletInfos:i}=r;try{await async function(e){await e.waitFor((e=>{const{init:t,locked:n}=e.state.plugins;if(!n)return;const{currency:r,swap:o}=e.state.plugins,i=[];for(const a of Object.keys(t))!1!==t[a]&&null!=t[a]&&null==r[a]&&null==o[a]&&i.push(a);if(i.length>0)throw new Error("The following plugins are missing or failed to load: "+i.join(", "));return!0}))}(t),await Bo(t,n),o.warn("Login: currency plugins exist"),await Promise.all(i.map((e=>po(t,e)))),o.warn("Login: synced account repos"),await async function(){await Promise.all([pi(t,n),Ko(t,n),bi(t,n)])}(),o.warn("Login: loaded files"),e.onOutput(jc(t,n)),o.warn("Login: complete")}catch(a){e.props.dispatch({type:"ACCOUNT_LOAD_FAILED",payload:{accountId:n,error:a}})}return await Ir}}},syncTimer:vr((e=>{const t=Hr((async function(){const t=yu(e),{accountId:n,accountState:r}=e.props,{accountWalletInfos:o}=r;if(null==e.props.state.accounts[n])return;const i=await Promise.all(o.map((e=>ho(t,e.id)))),a=[];for(const e of i)a.push(...e);a.length>0&&await Promise.all([bi(t,n),pi(t,n)])}),fo),n=Hr((async function(){const t=yu(e),{accountId:n}=e.props;if(null==e.props.state.accounts[n])return;const{sessionKey:r}=e.props.state.accounts[n];await Jn(t,r)}),fo,{onError(t){const n=$t(t);null!=n&&e.props.onError(n)}});return{update(){var r;if(null==(null===(r=e.props.accountOutput)||void 0===r?void 0:r.accountApi))return;const{accountId:o}=e.props,{stashTree:i}=e.props.state.accounts[o],a=null!=i.wipChange?5e3:fo;t.setDelay(fo),n.setDelay(a),t.start({wait:fo*(1+Math.random())}),n.start({wait:a*(1+Math.random())})},destroy(){t.stop(),n.stop()}}}),(e=>e.state.paused?void 0:e)),tokenSaver(e){let t=Kc;return async function(){const{accountId:n,accountState:r}=e.props,{customTokens:o}=r;o!==t&&t!==Kc&&(await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=bo(n,r.id),{customTokens:i}=e.props.state.accounts[t],a=await ko.load(o,Po);await ko.save(o,Po,_o(_o({},a),{},{customTokens:i}))}(yu(e),n).catch((t=>e.props.onError(t))),await Yr(100)),t=o}},watcher(e){let t;return()=>{const{accountState:n,accountOutput:r}=e.props;if(null==n||null==r)return;const{accountApi:o}=r;if(null!=o&&U(o),t!==n&&(t=n,null!=o)){const{currencyConfig:e,swapConfig:t}=o;for(const n of Object.keys(e))U(e[n]);for(const n of Object.keys(t))U(t[n])}}},currencyWallets(e){let t;return()=>{const{accountOutput:n,accountState:r}=e.props,{activeWalletIds:o}=r;let i=t!==o;t=o;let a={};null!=(null==n?void 0:n.currencyWallets)&&(a=n.currencyWallets);const s={},{wallets:c}=e.props.output.currency;for(const e of o){var u;const t=null===(u=c[e])||void 0===u?void 0:u.walletApi;t!==a[e]&&(i=!0),null!=t&&(s[e]=t)}i&&e.onOutput(s)}}}),$c=mr(zc,(e=>e.state.accountIds),((e,t)=>qc(qc({},e),{},{accountId:t,accountState:e.state.accounts[t],accountOutput:e.output.accounts[t]}))),Hc=["loginId"];function Yc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Vc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class Jc extends Z{constructor(e){super(),this._lobby=e,this._cleanups=[e.close,e.on("reply",(e=>U(this,"replies"))),e.on("error",(e=>K(this,"error",e)))]}get lobbyId(){return this._lobby.lobbyId}get replies(){return this._lobby.replies}close(){this._cleanups.forEach((e=>e())),B(this)}}class Xc extends Z{constructor(e){super(),this._ai=e}authRequest(e,t,n){return gn(this._ai,e,t,n)}hashUsername(e){return kn(this._ai,e)}async makeLobby(e,t=1e3){const n=await Da(this._ai,e,t);return new Jc(n)}fetchLobbyRequest(e){return Ra(this._ai,e)}async sendLobbyReply(e,t,n){await La(this._ai,e,t,n)}async syncRepo(e){const{io:t,syncClient:n}=this._ai.props,r=io(t,{dataKey:new Uint8Array(0),syncKey:e});return await co(n,r,{lastSync:0,lastHash:void 0})}async getRepoDisklet(e,t){const{io:n}=this._ai.props,r=io(n,{dataKey:t,syncKey:e});return _(r.disklet),r.disklet}}function Zc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Qc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function eu(e){const t=e.props.state.login.contextAppId,n=jt.stringify(e.props.state.clientInfo.clientId),r=new Xc(e);let o;const i={on:J,watch:X,appId:t,clientId:n,async close(){e.props.close()},$internalStuff:r,fixUsername:re,get localUsers(){return e.props.state.login.localUsers},async forgetAccount(t){const n=jt.parse(t);for(const r of e.props.state.accountIds){if(an(e.props.state.accounts[r].stashTree.loginId,n))throw new Error("Cannot remove logged-in user")}await async function(e,t){const{dispatch:n,io:r}=e.props,o=await r.disklet.list("logins").then(ee.gQ);for(const a of o)try{an(Mn(JSON.parse(await r.disklet.getText(a))).loginId,t)&&await r.disklet.delete(a)}catch(i){}n({type:"LOGIN_STASH_DELETED",payload:t})}(e,n)},async fetchChallenge(){const t=await gn(e,"POST","/v2/captcha/create",{}),{challengeId:n,challengeUri:r}=$e(t);return{challengeId:n,challengeUri:r}},async usernameAvailable(t,n={}){const{challengeId:r}=n;return t=re(t),await async function(e,t,n){const r={challengeId:n,userId:await kn(e,t)};return await gn(e,"POST","/v2/login",r).then((e=>!1)).catch((e=>{if(null!=tn(e))return!0;throw e}))}(e,t,r)},async createAccount(t){e.props.log.breadcrumb("EdgeContext.createAccount",{}),null!=t.username&&(t.username=re(t.username));const n=await async function(e,t,n){const{challengeId:r,now:o=new Date}=t;e.props.log.breadcrumb("createLogin",{});const{kit:i,sessionKey:a}=await Aa(e,void 0,"",n),s={challengeId:r,data:i.server};return await gn(e,"POST",i.serverPath,s),i.stash.lastLogin=o,await Pn(e,i.stash),a}(e,t,t);return await _a(e,n,"newAccount",t)},async loginWithKey(n,r,o={}){const{now:i=new Date,useLoginId:a=!1}=o,s=e.props.state.clientInfo.duressEnabled,c=a?An(e,jt.parse(n)).stashTree:On(e,re(n));if(null==c)throw new Error("User does not exist on this device");const u=Un(c,(e=>e.appId===t));if(null==u)throw new Error(`Cannot find requested appId: "${t}"`);const l=t+".duress",d=Un(c,(e=>e.appId===l));let f;try{f={loginId:u.loginId,loginKey:jt.parse(r)},Zn(c,f)}catch(p){if(!(p instanceof Error&&"Invalid checksum"===p.message))throw p;if(null==d)throw p;f={loginId:d.loginId,loginKey:jt.parse(r)},Zn(c,f)}return c.lastLogin=i,Pn(e,c).catch((()=>{})),Jn(e,f).catch((t=>e.props.onError(t))),await _a(e,f,"keyLogin",Qc(Qc({},o),{},{duressMode:s&&null!=(null==d?void 0:d.pin2Key)}))},async loginWithPassword(n,r,o={}){var i;e.props.log.breadcrumb("EdgeContext.loginWithPassword",{}),n=re(n);const a=null!==(i=On(e,n))&&void 0!==i?i:Sn(n),s=await ra(e,a,r,o);if(e.props.state.clientInfo.duressEnabled){const r=t+".duress",i=On(e,n);if(null==i)throw new Error("Missing stash after login with password");const a=Un(i,(e=>e.appId===r));if(null!=(null==a?void 0:a.pin2Key)){const t=Xn(i,s,a.loginId);return await _a(e,t,"passwordLogin",Qc(Qc({},o),{},{duressMode:!0}))}}return await _a(e,s,"passwordLogin",o)},checkPasswordRules:ne,async loginWithPIN(n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithPIN",{});const{useLoginId:i=!1}=o,a=i?An(e,jt.parse(n)).stashTree:On(e,re(n));if(null==a)throw new Error("User does not exist on this device");const s=sa(a,t),c=t+".duress",u=Un(a,(e=>e.appId===c));async function l(t,n){const i=null!=t.wipChange?await ca(e,t.wipChange,n,r,o).catch((async()=>await ca(e,t,n,r,o))):await ca(e,t,n,r,o);return await _a(e,i,"pinLogin",o)}async function d(t,n){if(!0===n.fakePinDisabled)throw new Wt("PIN login is not enabled for this account on this device");const i=await ca(e,t,n,r,o);return await _a(e,i,"pinLogin",Qc(Qc({},o),{},{duressMode:!0}))}if(null==s){if(null==u)throw new Wt("PIN login is not enabled for this account on this device");return await d(a,u)}if(null==(null==u?void 0:u.pin2Key))return await l(a,s);const f=e.props.state.clientInfo.duressEnabled,p=jt.stringify(s.loginId),h=e.props.state.clientInfo.loginWaitTimestamps[p];if(null!=h&&h>Date.now())throw new Ft({wait_seconds:Math.ceil((h-Date.now())/1e3)});try{return f?await d(a,u):await l(a,s)}catch(b){if(null==Ht(b))throw b;try{const t=f?await l(a,s):await d(a,u);return f?await async function(){await Ar.save(e.props.io.disklet,Or,Qc(Qc({},e.props.state.clientInfo),{},{duressEnabled:!1})),e.props.dispatch({type:"LOGIN_DURESS_MODE_DISABLED"})}():await async function(){await Ar.save(e.props.io.disklet,Or,Qc(Qc({},e.props.state.clientInfo),{},{duressEnabled:!0})),e.props.dispatch({type:"LOGIN_DURESS_MODE_ENABLED"})}(),t}catch(g){var y;const t=[Ht(g),Ht(b)].reduce(((e,t)=>{var n,r;return(null!==(n=null==e?void 0:e.wait)&&void 0!==n?n:0)>(null!==(r=null==t?void 0:t.wait)&&void 0!==r?r:0)?e:t})),n=1e3*(null!==(y=null==t?void 0:t.wait)&&void 0!==y?y:0);if(null!=t&&n>0){const r=Date.now()+n;throw await async function(t,n){await Ar.save(e.props.io.disklet,Or,Qc(Qc({},e.props.state.clientInfo),{},{loginWaitTimestamps:Qc(Qc({},e.props.state.clientInfo.loginWaitTimestamps),{},{[t]:n})})),e.props.dispatch({type:"LOGIN_WAIT_TIMESTAMP_UPDATED",payload:{loginId:t,timestamp:n}})}(p,r),t}if(null!=Yt(g))throw b;throw g}}},async loginWithRecovery2(t,n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithRecovery2",{}),n=re(n);const i=On(e,n),a=await async function(e,t,n,r,o){const{username:i}=t;if(null==i)throw new Error("Recovery login requires a username");const a={recovery2Id:ha(n,i),recovery2Auth:ya(n,r)};return await Hn(e,t,t,o,a,(async e=>{if(null==e.recovery2Box||!0===e.recovery2Box)throw new Error("Missing data for recovery v2 login");return un(e.recovery2Box,n)}))}(e,null!=i?i:Sn(n),jt.parse(t),r,o);return await _a(e,a,"recoveryLogin",o)},async fetchRecovery2Questions(t,n){return n=re(n),await async function(e,t,n){const r={recovery2Id:ha(t,n)},o=await gn(e,"POST","/v2/login",r),{question2Box:i}=tt(o);if(null==i)throw new Error("Login has no recovery questions");return ga(JSON.parse(cn(i,t)))}(e,jt.parse(t),n)},async requestEdgeLogin(n){return e.props.log.breadcrumb("EdgeContext.requestEdgeLogin",{}),await Ka(e,t,n)},async requestOtpReset(t,n){return t=re(t),await async function(e,t,n){const r={userId:await kn(e,t),otpResetAuth:n},o=await gn(e,"DELETE","/v2/login/otp",r),{otpResetDate:i}=Qe(o);return i}(e,t,n)},async fetchLoginMessages(){return await async function(e){const{stashes:t}=e.props.state.login,n={},r=[];for(const s of t){const{loginId:e,username:t}=s;null!=t&&(n[y.stringify(e)]=t,r.push(e))}const o={loginIds:r},i=await gn(e,"POST","/v2/messages",o),a=[];for(const s of Xe(i)){const{loginId:e}=s,t=yc(s,Hc),r=y.stringify(e),o=n[r];null!=o&&a.push(Vc(Vc({},t),{},{loginId:r,username:o}))}return a}(e)},get paused(){return e.props.state.paused},async changePaused(t,n={}){const{secondsDelay:r=0}=n;null!=o&&(clearTimeout(o),o=void 0),e.props.state.paused!==t&&(0===r?e.props.dispatch({type:"PAUSE",payload:t}):o=setTimeout((()=>{o=void 0,e.props.dispatch({type:"PAUSE",payload:t})}),1e3*r))},get logSettings(){return e.props.state.logSettings},async changeLogSettings(t){const n=Qc(Qc({},e.props.state.logSettings),t);e.props.dispatch({type:"CHANGE_LOG_SETTINGS",payload:n})}};return _(i),i}const tu=br({api(e){return{destroy(){B(e.props.output.context.api)},update(){return e.onOutput(eu(e)),Ir}}},watcher(e){let t,n,r;return()=>{t===e.props.state.login.localUsers&&n===e.props.state.paused&&r===e.props.state.logSettings||(t=e.props.state.login.localUsers,n=e.props.state.paused,r=e.props.state.logSettings,null!=e.props.output.context.api&&U(e.props.output.context.api))}},infoFetcher:vr((e=>{const t=Hr((async function(){const{dispatch:t,io:n}=e.props,{contextAppId:r,deviceInfo:o}=e.props.state.login,{appVersion:i,osType:a,osVersion:s}=o,[c]=ea(e.props.state.infoServers);let u;if(null!=a&&null!=s&&null!=i){const e=new URLSearchParams;e.set("appId",""!==r?r:"edge"),e.set("os",a),e.set("osVersion",s),e.set("appVersion",i),u=`${c}/v2/coreRollup?${e.toString()}`}else u=`${c}/v1/coreRollup`;const l=await fetch(u,{headers:{accept:"application/json"}});if(!l.ok)return;const d=await l.json(),f=_r(d);t({type:"INFO_CACHE_FETCHED",payload:f}),await kr.save(n.disklet,Tr,f)}),6e5,{onError(t){e.props.onError(t)}});return{update(){t.started||t.start()},destroy(){t.stop()}}}),(e=>e.state.paused?void 0:e))});function nu(e,t){if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return e===t;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!nu(e[n],t[n]))return!1;return!0}const r=Object.getOwnPropertyNames(e).filter((t=>void 0!==e[t])),o=Object.getOwnPropertyNames(t).filter((e=>void 0!==t[e]));if(r.length!==o.length)return!1;for(const i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!nu(e[i],t[i]))return!1}return!0}function ru(e,t,n,r,o,i){const{handleError:a,handleSend:s,localMethods:c}=i,u=ve(n),l=ve(r),d=async(e,t,n=null)=>{const r=l({jsonrpc:"2.0",result:void 0,error:{code:e,message:t,data:void 0},id:n});return await s(JSON.stringify(r))};let f=0;const p=new Map,h=new Map,y={};for(const b of Object.keys(t)){const{asParams:n,asResult:r}=t[b],i=ve(n);y[b]=null==r?e=>{const t=u({jsonrpc:"2.0",method:b,params:i(e)});s(JSON.stringify(t)).catch(a)}:t=>{const n=f++,c=new Promise(((e,t)=>{p.set(n,{asResult:r,resolve:e,reject:t})}));o&&null!=e[b]&&null==e[b].asResult&&h.set(n,b);const l=u({jsonrpc:"2.0",method:b,params:i(t),id:n});return s(JSON.stringify(l)).catch(a),c}}return{handleClose:function(){for(const e of p.values())e.reject(new Error("JSON-RPC connection closed"))},handleMessage:function(t){let o;try{o=JSON.parse(t)}catch(f){return void d(-32700,`Parse error: ${ou(f)}`).catch(a)}const i=ge(n)(o),u=ge(r)(o);if(null!=i){const t=e[i.method];if(null==t)return void d(-32601,`Method not found: ${i.method}`).catch(a);if(null!=t.asResult&&null==i.id)return void d(-32600,"Invalid JSON-RPC request: missing id").catch(a);if(null==t.asResult&&null!=i.id)return void d(-32600,"Invalid JSON-RPC request: notification has an id").catch(a);let n;try{n=t.asParams(i.params)}catch(f){return void d(-32602,`Invalid params: ${ou(f)}`).catch(a)}const r=c[i.method](n);if(null!=t.asResult&&null!=(null==r?void 0:r.then)){const e=ve(t.asResult);r.then((t=>{var n;const r=l({jsonrpc:"2.0",result:e(t),error:void 0,id:null!==(n=i.id)&&void 0!==n?n:null});s(JSON.stringify(r)).catch(a)}),(e=>{d(1,ou(e),i.id).catch(a)}))}}else if(null!=u){const{error:t,id:n,result:r}=u;if("number"!=typeof n)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);const o=p.get(n);if(null==o){const t=h.get(n);if(null==t)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);let o;try{o=e[t].asParams(r)}catch(f){return void d(-32602,`Invalid params: ${ou(f)}`).catch(a)}return void c[t](o)}if(p.delete(n),null!=t)o.reject(new Error(t.message));else{const{asResult:e}=o;let t;try{t=e(r)}catch(f){o.reject(f)}o.resolve(t)}}else d(-32600,"Invalid JSON-RPC request / response").catch(a)},remoteMethods:y}}function ou(e){return e instanceof Error?e.message:String(e)}const iu=e=>{if(null===e)return e;if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e;throw new TypeError("Expected a string or an integer")},au=ye({jsonrpc:se("2.0"),method:le,params:fe,id:ae(iu)}),su=ye({jsonrpc:se("2.0"),result:fe,error:ae(ye({code:ue,message:le,data:fe})),id:iu}),cu=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+ie(e));for(var n=[],r=0;r<t.length;++r)try{n[r]=t[r](e[r])}catch(o){throw pe(o,"["+r+"]")}return n}}(le,le,ae(le)),uu=se(-1,0,1,2),lu=function(e){const{serverMethods:t,clientMethods:n,asCall:r=au,asReturn:o=su,allowMultipleReturns:i=!1}=e;return{makeServerCodec(e){return ru(t,n,r,o,i,e)},makeClientCodec(e){return ru(n,t,r,o,i,e)}}}({serverMethods:{subscribe:{asParams:he(cu),asResult:he(uu)},unsubscribe:{asParams:he(cu),asResult:se(void 0)}},clientMethods:{update:{asParams:cu},subLost:{asParams:cu}}});function du(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?du(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):du(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const pu=br({wallets:mr(dc,(e=>e.state.currency.currencyWalletIds),((e,t)=>fu(fu({},e),{},{walletId:t,walletState:e.state.currency.wallets[t],walletOutput:e.output.currency.wallets[t]}))),pluginUpdater(e){let t;return async()=>{const{infoCache:n,plugins:r}=e.props.state;if(t!==n){if(null!=t)for(const e of Object.keys(r.currency)){var o,i,a,s;const c=r.currency[e],u=null!==(o=null===(i=n.corePlugins)||void 0===i?void 0:i[e])&&void 0!==o?o:{},l=null!==(a=null===(s=t.corePlugins)||void 0===s?void 0:s[e])&&void 0!==a?a:{};null==c.updateInfoPayload||nu(l,u)||await c.updateInfoPayload(u)}t=n}}},changeServiceManager(e){let t,n;return{async update(){var r,o;const{wallets:i}=e.props.state.currency;if(i===t)return;t=i;let{changeService:a,changeServiceConnected:s=!1}=null!==(r=e.props.output.currency.changeServiceManager)&&void 0!==r?r:{};const c=Object.entries(i).filter((([,e])=>e.changeServiceSubscriptions.some((e=>"avoiding"!==e.status))));if(null==a&&c.length>0){const t=e.props.state.changeServers[0];a=function(e,t){let n,r,o=!1;!function s(){n=new WebSocket(e),n.binaryType="arraybuffer",n.addEventListener("message",(e=>{i.handleMessage(e.data)})),n.addEventListener("close",(()=>{a.connected=!1,i.handleClose(),t.handleDisconnect(),r=setTimeout((()=>{o||s()}),5e3)})),n.addEventListener("error",(e=>{console.error("changeServer websocket error:",e),n.close()})),n.addEventListener("open",(()=>{a.connected=!0,t.handleConnect()}))}();const i=lu.makeClientCodec({handleError(e){console.error("changeServer error:",e),n.close()},async handleSend(e){n.send(e)},localMethods:{update(e){t.handleChange(e)},subLost(e){t.handleSubLost(e)}}}),a={async subscribe(e){return await i.remoteMethods.subscribe(e)},async unsubscribe(e){await i.remoteMethods.unsubscribe(e)},close(){o=!0,null!=r&&(clearTimeout(r),r=void 0),n.close()},connected:!1};return a}(t,{handleChange([t,n,r]){const o=Object.entries(e.props.state.currency.wallets).filter((([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some((e=>e.address===n))));for(const[i,a]of o){const t=a.changeServiceSubscriptions.filter((e=>e.address===n&&"listening"===e.status)).map((e=>fu(fu({},e),{},{status:"syncing",checkpoint:r})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:i,subscriptions:t}})}},handleConnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter((e=>"reconnecting"===e.status)).map((e=>fu(fu({},e),{},{status:"subscribing"})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!0})},handleDisconnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter((e=>"avoiding"!==e.status)).map((e=>fu(fu({},e),{},{status:"reconnecting"})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!1})},handleSubLost([t,n]){const r=Object.entries(e.props.state.currency.wallets).filter((([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some((e=>e.address===n))&&e.changeServiceSubscriptions.some((e=>"avoiding"!==e.status))));for(const[o,i]of r){const t=i.changeServiceSubscriptions.filter((e=>"avoiding"!==e.status)).map((e=>fu(fu({},e),{},{status:"subscribing"})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:o,subscriptions:t}})}}}),e.onOutput({changeService:a,changeServiceConnected:!1})}if(null!=a&&0===c.length&&(a.close(),a=void 0,e.onOutput({changeService:a,changeServiceConnected:!1})),!0===(null===(o=a)||void 0===o?void 0:o.connected)&&s){const t=c.filter((([,e])=>e.changeServiceSubscriptions.some((e=>"subscribing"===e.status||"resubscribing"===e.status)))),r=[],o=[];for(const[e,n]of t){if(n.paused)continue;const t=n.changeServiceSubscriptions.map((e=>[n.currencyInfo.pluginId,e.address,e.checkpoint]));if(0===t.length)continue;let i=o[o.length-1];(null==i||i.length+t.length>100)&&(o.push([]),i=o[o.length-1]),i.push(...t);for(let o=0;o<t.length;o++)r[r.length]={walletId:e,wallet:n}}n=setTimeout((()=>{n=void 0;const t=new Set(r.map((e=>e.walletId)));for(const n of t){const t=e.props.state.currency.wallets[n];if(null==t)continue;const r=t.changeServiceSubscriptions.filter((e=>"subscribing"===e.status)).map((e=>fu(fu({},e),{},{status:"subscribingSlowly"})));r.length>0&&e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:r}})}}),15e3);const i=[];try{for(const t of o){const n=await a.subscribe(t).catch((n=>(e.props.log(`Failed to subscribe: ${String(n)}`),t.map((()=>0)))));i.push(...n)}}finally{clearTimeout(n),n=void 0}const s=new Map;for(let n=0;n<i.length;n++){const t=i[n],{walletId:o}=r[n],a=e.props.state.currency.wallets[o];if(null==a)continue;let c;switch(t){case-1:c="avoiding";break;case 0:c="resubscribing";break;case 1:c="synced";break;case 2:c="syncing"}const u=a.changeServiceSubscriptions.filter((e=>"subscribing"===e.status||"subscribingSlowly"===e.status||"resubscribing"===e.status)).map((e=>fu(fu({},e),{},{status:c})));s.set(o,u)}const u=Array.from(s.entries());for(const[n,a]of u)e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:a}})}},destroy(){null!=n&&clearTimeout(n)}}}});const hu=br({makeSnrp:e=>()=>{const{io:t,log:n}=e.props;let r;return e.onOutput((async function(o){null==r&&(r=e.props.output.scrypt.timeScrypt(Dt.parse("1reallyJunkiePasswordToCheck"),{salt_hex:p.parse("b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b"),n:16384,r:8,p:1}).then((e=>e.time)));const i=await r,a=function(e,t,n){const r={salt_hex:e,n:16384,r:8,p:1};if(0===t)return r.n=131072,r.r=8,r.p=64,r;let o=t;const i=t/8;let a=(n-o)/i;a=a>0?a:0,a>0&&(a=0),a=Math.floor(a),r.r=8+a,o+=a*i;let s=14,c=(n-o)/o;c=c>0?c:0,c>3&&(c=3),c=Math.floor(c),s+=c>=0?c:0,o+=c*o,r.n=Math.pow(2,s);let u=(n-o)/o;return u=u>0?u:0,u>64&&(u=64),u=Math.floor(u),r.p=u>=1?u:1,o+=u*o,r}(t.random(32),i,o);return n(`snrp for ${o}ms target: ${a.n} ${a.r} ${a.p} based on ${i}ms benchmark`),a})),Ir},timeScrypt:e=>()=>{const{io:t,log:n}=e.props,r="undefined"!=typeof window&&null!=window.performance&&"function"==typeof window.performance.now?()=>window.performance.now():()=>Date.now();return e.onOutput(function(e){let t=Promise.resolve();return function(...n){const r=()=>e.apply(this,n),o=t.then(r,r);return t=o,o}}((function(e,o,i=32){const a=o.salt_hex,s=r();return n(`starting scrypt n=${o.n} r=${o.r} p=${o.p}`),t.scrypt(e,a,o.n,o.r,o.p,i).then((e=>{const t=r()-s;return n(`finished scrypt n=${o.n} r=${o.r} p=${o.p} in ${t}ms`),{hash:e,time:t}}))}))),Ir}}),yu=e=>e,bu=br({accounts:$c,context:tu,currency:pu,scrypt:hu}),gu=As({currencyWalletIds(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].activeWalletIds}const r=[];for(const o of n.accountIds)r.push(...n.accounts[o].activeWalletIds);return r},wallets:Ms(Ks,(e=>e.currency.currencyWalletIds))}),wu=As({apiKey(e="",t){return"INIT"===t.type?t.payload.apiKey:e},apiSecret(e=null,t){var n;return"INIT"===t.type?null!==(n=t.payload.apiSecret)&&void 0!==n?n:null:e},contextAppId(e="",t){return"INIT"===t.type?t.payload.appId:e},deviceInfo(e={},t){if("INIT"===t.type){const{appVersion:e,deviceDescription:n,osType:r,osVersion:o}=t.payload;return{deviceDescription:null!=n?n:void 0,osType:r,osVersion:o,appVersion:e}}return e},localUsers:Cs((e=>e.login.contextAppId),(e=>e.login.stashes),(e=>e.clientInfo),((e,t,n)=>t.map((function(t){const{lastLogin:r,loginId:o,recovery2Key:i,username:a}=t,s=Un(t,(t=>t.appId===e)),c=null!=s&&(null!=s.passwordAuthBox||null!=s.loginAuthBox),u=n.duressEnabled?Nn(t,e):void 0,l=null!=(null==u?void 0:u.pin2Key)&&!0===(null==u?void 0:u.fakePinDisabled),d=sa(t,e),f=!l&&null!=(null==d?void 0:d.pin2Key);return{keyLoginEnabled:c,lastLogin:r,loginId:jt.stringify(o),pinLoginEnabled:f,recovery2Key:null!=i?jt.stringify(i):void 0,username:a,voucherId:null!=s?s.voucherId:void 0}})))),loginServers(e=[],t){return"INIT"===t.type?t.payload.loginServers:e},stashes(e=[],t){switch(t.type){case"INIT":return t.payload.stashes;case"LOGIN_STASH_DELETED":{const n=t.payload;return e.filter((e=>!an(e.loginId,n)))}case"LOGIN_STASH_SAVED":{const n=t.payload,r=e.filter((e=>!an(e.loginId,n.loginId)));return r.unshift(n),r}}return e},walletInfos(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].walletInfos}const r={};for(const o of n.accountIds){const e=n.accounts[o];for(const t of Object.keys(e.walletInfos)){const n=e.walletInfos[t];r[t]=n}}return r}});function vu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Iu={init:{},locked:!1,currency:{},swap:{},currencyTools:{}};function Eu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Su(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Eu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Eu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ou=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];0,"function"==typeof e[o]&&(n[o]=e[o])}var i,a=Object.keys(n);try{!function(e){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:or.INIT}))throw new Error(tr(12));if(void 0===n(void 0,{type:or.PROBE_UNKNOWN_ACTION()}))throw new Error(tr(13))}))}(n)}catch(s){i=s}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},s=0;s<a.length;s++){var c=a[s],u=n[c],l=e[c],d=u(l,t);if(void 0===d){t&&t.type;throw new Error(tr(14))}o[c]=d,r=r||d!==l}return(r=r||a.length!==Object.keys(e).length)?o:e}}({lastChanges(e=[],t){if("STORAGE_WALLET_SYNCED"===t.type){const{changes:n}=t.payload;return n.length>0?n:e}return e},localDisklet(e=null){return e},paths(e=null){return e},status(e={lastSync:0,lastHash:void 0},t){return"STORAGE_WALLET_SYNCED"===t.type?t.payload.status:e}});function Au(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Au(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Au(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const _u={sources:{},defaultLogLevel:"warn"},ku={clientId:new Uint8Array(0),duressEnabled:!1,loginWaitTimestamps:{}},xu=As({accountCount(e=0,t){return"LOGIN"===t.type?e+1:e},accountIds(e=[],t,n){switch(t.type){case"LOGIN":return[...e,n.lastAccountId];case"LOGOUT":{const{accountId:n}=t.payload,r=e.filter((e=>e!==n));if(r.length===e.length)throw new Error(`Login ${n} does not exist`);return r}case"CLOSE":return[]}return e},accounts:Ms(Wc,(e=>e.accountIds)),changeServers(e=[],t){return"INIT"===t.type?t.payload.changeServers:e},clientInfo(e=ku,t){switch(t.type){case"INIT":return t.payload.clientInfo;case"LOGIN_DURESS_MODE_DISABLED":return Tu(Tu({},e),{},{duressEnabled:!1});case"LOGIN_DURESS_MODE_ENABLED":return Tu(Tu({},e),{},{duressEnabled:!0});case"LOGIN_WAIT_TIMESTAMP_UPDATED":return Tu(Tu({},e),{},{loginWaitTimestamps:Tu(Tu({},e.loginWaitTimestamps),{},{[t.payload.loginId]:t.payload.timestamp})})}return e},hideKeys(e=!0,t){return"INIT"===t.type?t.payload.hideKeys:e},infoCache(e={},t){switch(t.type){case"INIT":return t.payload.infoCache;case"INFO_CACHE_FETCHED":return t.payload}return e},infoServers(e=[],t){return"INIT"===t.type?t.payload.infoServers:e},lastAccountId(e,t,n){return`login${n.accountCount}`},logSettings(e=_u,t){switch(t.type){case"INIT":return t.payload.logSettings;case"CHANGE_LOG_SETTINGS":return t.payload}return e},paused(e=!1,t){return"PAUSE"===t.type?t.payload:e},ready(e=!1,t){return"INIT"===t.type||e},skipBlockHeight(e=!1,t){return"INIT"===t.type?t.payload.skipBlockHeight:e},syncServers(e=[],t){return"INIT"===t.type?t.payload.syncServers:e},currency:gu,login:wu,plugins:(e=Iu,t)=>{switch(t.type){case"CORE_PLUGINS_ADDED":{const n=mu(mu({},e),{},{currency:mu({},e.currency),swap:mu({},e.swap)});for(const e of Object.keys(t.payload)){const r=t.payload[e];null!=r?("currencyInfo"in r&&(null==r.currencyInfo.chainDisplayName&&(r.currencyInfo.chainDisplayName=r.currencyInfo.displayName),null==r.currencyInfo.assetDisplayName&&(r.currencyInfo.assetDisplayName=r.currencyInfo.displayName),n.currency[e]=r),"swapInfo"in r&&(n.swap[e]=r)):n.init=mu(mu({},n.init),{},{[e]:!1})}return n}case"CORE_PLUGINS_LOCKED":return mu(mu({},e),{},{locked:!0});case"CURRENCY_TOOLS_LOADED":{const n=mu({},e.currencyTools);return n[t.payload.pluginId]=t.payload.tools,mu(mu({},e),{},{currencyTools:n})}case"INIT":return mu(mu({},e),{},{init:t.payload.pluginsInit})}return e},storageWallets:function(e={},t){switch(t.type){case"STORAGE_WALLET_ADDED":{const{id:n,initialState:r}=t.payload,o=Su({},e);return o[n]=Ou(r,{type:"UPDATE_NEXT"}),o}case"STORAGE_WALLET_SYNCED":{const{id:n}=t.payload;if(null!=e[n]){const r=Su({},e);return r[n]=Ou(e[n],t),r}return e}}return e}});function Pu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Mu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Pu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}let Cu=[];const Nu="object"==typeof window&&null!=window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__({name:"core"}):void 0;async function ju(e,t,n){const{io:r}=e,{airbitzSupport:o=!1,apiSecret:i,appId:a="",appVersion:s,authServer:c,deviceDescription:u=null,changeServer:l,hideKeys:d=!1,infoServer:f,loginServer:p,osType:h,osVersion:y,plugins:b={},skipBlockHeight:g=!1,syncServer:w}=n;let{apiKey:v}=n;null!=v&&""!==v||(v="4248c1bf41e53b840a5fdb2c872dd3ade525e66d");const m=Du(c,["https://login1.edge.app","https://login2.edge.app"]),I=Du(l,["wss://change1.edge.app","wss://change2.edge.app"]),E=Du(f,["https://info1.edge.app","https://info2.edge.app"]),S=Du(p,m.map((e=>e.replace(/\/api$/,"")))),O=Du(w,["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]),A=Mu(Mu({},_u),n.logSettings);I.map((e=>Rt(e))),E.map((e=>Rt(e))),S.map((e=>Rt(e))),O.map((e=>Rt(e)));const T=ar(xu,Nu);var _,k;k=()=>{const e=T.getState();return e.ready?e.logSettings:A};const x=Cr(t=Pr(Pr({},_=t),{},{onLog:function(e){const{sources:t,defaultLogLevel:n}=k(),r=null!=t[e.source]?t[e.source]:n;switch(e.type){case"info":"info"===r&&_.onLog(e);break;case"warn":"info"!==r&&"warn"!==r||_.onLog(e);break;case"error":"silent"!==r&&_.onLog(e)}}}),"edge-core");let[P,M={},C]=await Promise.all([Ar.load(r.disklet,Or),kr.load(r.disklet,Tr),xn(r.disklet,x)]);if(o){const e=new Set;for(const{username:n}of C)null!=n&&e.add(n);const t=await async function(e,t){const n=[],r=await e.disklet.list("Accounts").then(ee.ji);for(const o of r){const r=(0,ee.HN)(e.disklet,o),[i,a,s,c,u,l]=await Promise.all([await jr.load(r,"CarePackage.json"),await Dr.load(r,"LoginPackage.json"),await Rr.load(r,"OtpKey.json"),await Lr.load(r,"Pin2Key.json"),await Br.load(r,"Recovery2Key.json"),await Kr.load(r,"UserName.json")]);if(null==l)continue;const d=re(l.userName);if(t.has(d))continue;const f={appId:"",loginId:await e.scrypt(Dt.parse(d),En.salt_hex,En.n,En.r,En.p,32),pendingVouchers:[],username:d};null!=i&&null!=a&&(f.passwordKeySnrp=i.SNRP2,f.passwordBox=a.EMK_LP2,f.syncKeyBox=a.ESyncKey,f.passwordAuthBox=a.ELP1),null!=s&&(f.otpKey=s.TOTP),null!=c&&(f.pin2Key=c.pin2Key),null!=u&&(f.recovery2Key=u.recovery2Key),n.push(f)}return n}(r,e);C.push(...t)}null==P&&(P={clientId:r.random(16),duressEnabled:!1,loginWaitTimestamps:{}},await Ar.save(r.disklet,Or,P)),T.dispatch({type:"INIT",payload:{apiKey:v,apiSecret:i,appId:a,appVersion:s,osType:h,osVersion:y,changeServers:I,loginServers:S,infoCache:M,infoServers:E,syncServers:O,clientInfo:P,deviceDescription:u,hideKeys:d,logSettings:A,pluginsInit:b,skipBlockHeight:g,stashes:C}});const N=function(e,t,n,r,o){const{io:i,nativeIo:a}=e,s=Fr(Fr({},i),{},{console:console});function c(e){const c={};for(const o of Object.keys(e)){const f=e[o],p=Cr(n,o),h=r[o];if(!1!==h&&null!=h)try{if("function"==typeof f){var u,l;const e={infoPayload:null!==(u=null===(l=t.corePlugins)||void 0===l?void 0:l[o])&&void 0!==u?u:{},initOptions:"object"==typeof h?h:{},io:s,log:p,nativeIo:a,pluginDisklet:(0,ee.HN)(i.disklet,"plugins/"+o)};c[o]=f(e)}else{if("object"!=typeof f||null==f)throw new TypeError("Plugins must be functions or objects, got "+typeof f);c[o]=f}}catch(d){p.error(d)}}o({type:"CORE_PLUGINS_ADDED",payload:c})}function u(){o({type:"CORE_PLUGINS_LOCKED",payload:r})}return c(Wr),Gr&&u(),qr.push(c),zr.push(u),()=>{qr.filter((e=>e!==c)),zr.filter((e=>e!==u))}}(e,M,t,b,T.dispatch),j=er({log:x,fetch:(e,t)=>r.fetch(e,Mu(Mu({},t),{},{corsBypass:"never"})),edgeServers:{infoServers:E,syncServers:O}}),D={output:{}},R=function(e,t,n,r){var o=yr(t,n,r);o.update({dispatch:e.dispatch,output:void 0,state:e.getState()});var i=e.subscribe((function(){o.update({dispatch:e.dispatch,output:void 0,state:e.getState()})}));return function(){i(),o.destroy()}}(T,vr(bu,(e=>Mu(Mu({},e),{},{close(){R(),N(),T.dispatch({type:"CLOSE"})},io:r,log:x,logBackend:t,onError:e=>{var t;null!=(null===(t=D.output.context)||void 0===t?void 0:t.api)&&K(D.output.context.api,"error",e)},syncClient:j}))),(e=>x.error(e)),(e=>D.output=e)),L=D.output.context.api;return Cu.push(L),L}function Du(e,t){return"string"==typeof e?[e]:null!=e&&e.length>0?e:t}const Ru=["children"];function Lu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Bu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class Ku{constructor(){this.lobbies=new Map,this.logins=[],this.repos=new Map}getLoginById(e){return this.logins.find((t=>an(t.loginId,e)))}getLoginByUserId(e){return this.logins.find((t=>null==t.userId?an(t.loginId,e):an(t.userId,e)))}getLoginByPin2Id(e){return this.logins.find((t=>null!=t.pin2Id&&an(t.pin2Id,e)))}getLoginByRecovery2Id(e){return this.logins.find((t=>null!=t.recovery2Id&&an(t.recovery2Id,e)))}getLoginsByParent(e){return this.logins.filter((t=>t.parentId===e.loginId))}insertLogin(e){this.logins.push(e)}setupLogin(e){const{children:t}=e,n=yc(e,Ru);this.insertLogin(n);for(const r of t)r.parentId=e.loginId,this.setupLogin(r)}setupRepo(e,t){this.repos.set(e,t)}dumpLogin(e){const t=e=>Bu(Bu({},e),{},{children:this.getLoginsByParent(e).map((e=>t(e)))});return t(e)}}function Uu(e,t){const n=e.getLoginsByParent(t).map((t=>Uu(e,t)));return{appId:t.appId,created:t.created,loginId:t.loginId,children:n,parentBox:t.parentBox,passwordAuthBox:t.passwordAuthBox,passwordAuthSnrp:t.passwordAuthSnrp,passwordBox:t.passwordBox,passwordKeySnrp:t.passwordKeySnrp,pin2Box:t.pin2Box,pin2KeyBox:t.pin2KeyBox,pin2TextBox:t.pin2TextBox,question2Box:t.question2Box,recovery2Box:t.recovery2Box,recovery2KeyBox:t.recovery2KeyBox,otpKey:t.otpKey,otpResetDate:t.otpResetDate,otpTimeout:t.otpTimeout,pendingVouchers:Fu(t),loginAuthBox:t.loginAuthBox,userId:t.userId,userTextBox:t.userTextBox,keyBoxes:t.keyBoxes,mnemonicBox:t.mnemonicBox,rootKeyBox:t.rootKeyBox,syncKeyBox:t.syncKeyBox}}function Fu(e){return e.vouchers.filter((e=>"pending"===e.status)).map((e=>({activates:e.activates,created:e.created,deviceDescription:e.deviceDescription,ip:e.ip,ipDescription:e.ipDescription,voucherId:e.voucherId})))}function Wu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Gu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const qu={success:{code:0,httpStatus:200,message:"Success"},error:{code:1,httpStatus:503,message:"Error"},accountExists:{code:2,httpStatus:401,message:"Account already exists"},noAccount:{code:3,httpStatus:401,message:"No account"},invalidPassword:{code:4,httpStatus:401,message:"Invalid Password"},invalidAnswers:{code:5,httpStatus:401,message:"Invalid Answers"},invalidApiKey:{code:6,httpStatus:401,message:"Invalid API Key"},invalidOtp:{code:8,httpStatus:401,message:"Invalid OTP"},conflict:{code:10,httpStatus:409,message:"Conflicting change"},obsolete:{code:1e3,httpStatus:410,message:"Obsolete API"},created:{code:0,httpStatus:201,message:"Account created"},invalidRequest:{code:1,httpStatus:401,message:"Invalid request"},notFound:{code:1,httpStatus:404,message:"Not found"},noLobby:{code:3,httpStatus:404,message:"Not found"},invalidAppId:{code:10,httpStatus:401,message:"A login with the same appId already exists"}};function zu(e,t){try{return[e(t),{status:200}]}catch(n){return[void 0,Hu(qu.invalidRequest,`Invalid request: ${String(n)}`)]}}function $u(e,t={}){const{status:n=200,headers:r={}}=t;return{status:n,headers:Gu({"content-type":"application/json"},r),body:JSON.stringify(e)}}function Hu(e=qu.success,t=e.message){const{code:n,httpStatus:r}=e;return $u(st({status_code:n,message:t}),{status:r})}function Yu(e,t=qu.success,n=t.message){const{code:r,httpStatus:o}=t;return $u(st({status_code:r,message:n,results:e}),{status:o})}function Vu(e){return Yu(Ot({wait_seconds:e}),qu.invalidPassword)}function Ju(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Xu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ju(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ju(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Zu=e=>async t=>{const{json:n}=t,[r,o]=zu(Ne,n);return null==r?o:await e(Xu(Xu({},t),{},{body:r,payload:r.data}))},Qu=e=>async t=>{const{body:n,login:r}=t,{otp:o,voucherAuth:i,voucherId:a}=n,{otpKey:s}=r;if(null==s)return await e(t);if(null!=o&&function(e,t,n={}){const{now:r=Date.now()/1e3,spread:o=1}=n,i=r/30;if(t===fn(e,i,6))return!0;for(let a=1;a<=o;++a){if(t===fn(e,i-a,6))return!0;if(t===fn(e,i+a,6))return!0}return!1}(s,o,{spread:2}))return await e(t);if(null!=i&&null!=a){const n=r.vouchers.find((e=>e.voucherId===a));if(null!=n&&"approved"===n.status&&an(i,n.voucherAuth))return await e(t)}r.otpResetAuth="Super secret reset token";const c={activates:new Date("2020-01-01T00:00:00Z"),created:new Date("2020-01-08T00:00:00Z"),deviceDescription:"A phone",ip:"localhost",ipDescription:"here",loginId:r.loginId,status:"pending",voucherAuth:Uint8Array.from([170,187]),voucherId:`voucher-${r.vouchers.length}`};return r.vouchers.push(c),function(e,t={}){const{reason:n="otp",voucher:r}=t;return Yu(Et({login_id:e.loginId,otp_reset_auth:e.otpResetAuth,otp_timeout_date:e.otpResetDate,reason:n,voucher_auth:null==r?void 0:r.voucherAuth,voucher_activates:null==r?void 0:r.activates,voucher_id:null==r?void 0:r.voucherId}),qu.invalidOtp)}(r,{voucher:c})},el=e=>Hu(qu.invalidRequest),tl=(e,t=el)=>n=>{const{db:r,body:o}=n,{loginAuth:i,loginId:a,passwordAuth:s,pin2Auth:c,pin2Id:u,recovery2Auth:l,recovery2Id:d,userId:f}=o;if(null!=a&&null!=i){const t=r.getLoginById(a);return null==t?Hu(qu.noAccount):null!=t.loginAuth&&an(i,t.loginAuth)?Qu(e)(Xu(Xu({},n),{},{login:t})):Vu(0)}if(null!=f&&null!=s){const t=r.getLoginByUserId(f);return null==t?Hu(qu.noAccount):null!=t.passwordAuth&&an(s,t.passwordAuth)?Qu(e)(Xu(Xu({},n),{},{login:t})):Vu(0)}if(null!=u&&null!=c){const t=r.getLoginByPin2Id(u);return null==t?Hu(qu.noAccount):null!=t.pin2Auth&&an(c,t.pin2Auth)?Qu(e)(Xu(Xu({},n),{},{login:t})):Vu(0)}if(null!=d&&null!=l){const t=r.getLoginByRecovery2Id(d);if(null==t)return Hu(qu.noAccount);const o=t.recovery2Auth,i=l;if(null==o||i.length!==o.length)return Vu(0);for(let e=0;e<i.length;++e)if(!an(i[e],o[e]))return Vu(0);return Qu(e)(Xu(Xu({},n),{},{login:t}))}return t(n)},nl=tl((e=>{const{db:t,login:n}=e;return Yu(mt(Uu(t,n)))}),(e=>{const{db:t,json:n}=e,r=Ne(n),{userId:o,passwordAuth:i,recovery2Id:a,recovery2Auth:s}=r;if(null!=o&&null==i){const e=t.getLoginByUserId(o);if(null==e)return Hu(qu.noAccount);const{loginId:n,passwordAuthSnrp:r=En}=e;return Yu(Tt({loginId:n,passwordAuthSnrp:r}))}if(null!=a&&null==s){const e=t.getLoginByRecovery2Id(a);if(null==e)return Hu(qu.noAccount);const{question2Box:n}=e;return null==n?Hu(qu.noAccount):Yu(At({question2Box:n}))}return Hu(qu.invalidRequest)}));function rl(e,t){const{db:n,json:r}=e,o=new Date,[i,a]=zu(Ne,r);if(null==i)return a;const[s,c]=zu(ze,i.data);if(null==s)return c;const[u,l]=zu(Fe,i.data);if(null==u)return l;if(null!=n.getLoginById(s.loginId))return Hu(qu.accountExists);const d=ge(qe,(()=>({allowExisting:!1,newSyncKeys:[],keyBoxes:[]})))(i.data);for(const p of d.newSyncKeys)n.repos.set(p,{});const f=Xu(Xu(Xu(Xu(Xu(Xu(Xu({},s),u),{},{created:o,keyBoxes:d.keyBoxes.map((e=>Xu(Xu({},e),{},{created:o}))),vouchers:[]},ge(De)(i.data)),ge(Re)(i.data)),ge(Be)(i.data)),ge(Ue)(i.data)),ge(We)(i.data));if(null!=t){if(null!=n.getLoginsByParent(t).find((e=>e.appId===s.appId)))return Hu(qu.invalidAppId);f.parentId=t.loginId}return n.insertLogin(f),Hu(qu.created,"Account created")}const ol=tl((e=>rl(e,e.login)),(e=>rl(e))),il=tl((e=>{const{db:t,login:n,payload:r}=e,o=new Date,[i,a]=zu(qe,r);if(null==i)return a;for(const s of i.newSyncKeys)t.repos.set(s,{});return n.keyBoxes=hn(n.keyBoxes,i.keyBoxes.map((e=>Xu(Xu({},e),{},{created:o})))),Hu()})),al=tl((e=>{const{login:t,payload:n}=e,[r,o]=zu(De,n);return null==r?o:(t.otpKey=r.otpKey,t.otpTimeout=r.otpTimeout,t.otpResetDate=void 0,Hu())})),sl=tl((e=>{const{login:t}=e;return t.otpKey=void 0,t.otpResetAuth=void 0,t.otpResetDate=void 0,t.otpTimeout=void 0,Hu()}),(e=>{const{db:t,json:n}=e,r=Ne(n);if(null==r.userId||null==r.otpResetAuth)return Hu(qu.invalidRequest);const o=t.getLoginByUserId(r.userId);if(null==o)return Hu(qu.noAccount);if(r.otpResetAuth!==o.otpResetAuth)return Vu(0);const{otpKey:i,otpTimeout:a}=o;return null==i||null==a?Hu(qu.invalidRequest,"OTP not setup for this account."):(null==o.otpResetDate&&(o.otpResetDate=new Date(Date.now()+1e3*a)),Yu(St({otpResetDate:o.otpResetDate})))})),cl=tl((e=>{const{login:t}=e;return t.passwordAuth=void 0,t.passwordAuthBox=void 0,t.passwordAuthSnrp=void 0,t.passwordBox=void 0,t.passwordKeySnrp=void 0,Hu()})),ul=tl((e=>{const{login:t,payload:n}=e,[r,o]=zu(Re,n);return null==r?o:(t.passwordAuth=r.passwordAuth,t.passwordAuthBox=r.passwordAuthBox,t.passwordAuthSnrp=r.passwordAuthSnrp,t.passwordBox=r.passwordBox,t.passwordKeySnrp=r.passwordKeySnrp,Hu())})),ll=tl((e=>{const{login:t}=e;return t.pin2Auth=void 0,t.pin2Box=void 0,t.pin2Id=void 0,t.pin2KeyBox=void 0,t.pin2TextBox=void 0,Hu()})),dl=tl((e=>{const{login:t,payload:n}=e,[r,o]=zu(Be,n);return null==r?o:(t.pin2Auth=r.pin2Auth,t.pin2Box=r.pin2Box,t.pin2Id=r.pin2Id,t.pin2KeyBox=r.pin2KeyBox,t.pin2TextBox=r.pin2TextBox,Hu())})),fl=tl((e=>{const{login:t}=e;return t.question2Box=void 0,t.recovery2Auth=void 0,t.recovery2Box=void 0,t.recovery2Id=void 0,t.recovery2KeyBox=void 0,Hu()})),pl=tl((e=>{const{login:t,payload:n}=e,[r,o]=zu(Ue,n);return null==r?o:(t.question2Box=r.question2Box,t.recovery2Auth=r.recovery2Auth,t.recovery2Box=r.recovery2Box,t.recovery2Id=r.recovery2Id,t.recovery2KeyBox=r.recovery2KeyBox,Hu())})),hl=tl((e=>{const{db:t,login:n,payload:r}=e,[o,i]=zu(Fe,r);return null==o?i:null!=n.loginAuth?Hu(qu.conflict,"The secret-key login is already configured"):(n.loginAuth=o.loginAuth,n.loginAuthBox=o.loginAuthBox,Yu(mt(Uu(t,n))))})),yl=tl((async e=>{const{db:t,login:n,payload:r}=e,o=ge(Re)(r),i=ge(Le)(r),a=ge(Ke)(r),s=ge(We)(r);if(null!=n.passwordAuth&&null==o)return Hu(qu.invalidRequest,"Missing password payload");if(null!=n.pin2Auth&&null==i)return Hu(qu.invalidRequest,"Missing pin2Id payload");if(null!=n.recovery2Auth&&null==a)return Hu(qu.invalidRequest,"Missing recovery2Id payload");if(null==n.parentBox&&null==s)return Hu(qu.invalidRequest,"Missing username payload");if(null!=o&&(n.passwordAuth=o.passwordAuth,n.passwordAuthBox=o.passwordAuthBox,n.passwordAuthSnrp=o.passwordAuthSnrp,n.passwordBox=o.passwordBox,n.passwordKeySnrp=o.passwordKeySnrp),null!=i){if(null==n.pin2Auth)return Hu(qu.invalidRequest,"Login lacks pin2");if(null!=t.getLoginByPin2Id(i.pin2Id))return Hu(qu.conflict);n.pin2Id=i.pin2Id}if(null!=a){if(null==n.recovery2Auth)return Hu(qu.invalidRequest,"Login lacks recovery2");if(null!=t.getLoginByRecovery2Id(a.recovery2Id))return Hu(qu.conflict);n.recovery2Id=a.recovery2Id}if(null!=s){if(null!=n.parentBox)return Hu(qu.invalidRequest,"Only top-level logins can have usernames");if(null!=t.getLoginByUserId(s.userId))return Hu(qu.conflict);n.userId=s.userId,n.userTextBox=s.userTextBox}return Yu(mt(Uu(t,n)))})),bl=tl((async e=>{const{db:t,login:n,payload:r}=e,[o,i]=zu(Ge,r);if(null==o)return i;const{approvedVouchers:a=[],rejectedVouchers:s=[]}=o,c={};for(const u of a)c[u]="approved";for(const u of s)c[u]="rejected";for(const u of n.vouchers)null!=c[u.voucherId]&&(u.status=c[u.voucherId]);return Yu(mt(Uu(t,n)))})),gl=e=>Hu(qu.noLobby,`Cannot find lobby ${e.lobbyId}`),wl=(e,t=gl)=>n=>{const{db:r,path:o}=n,i=o.split("/")[4],a=r.lobbies.get(i);return null!=a?e(Xu(Xu({},n),{},{lobby:a,lobbyId:i})):t(Xu(Xu({},n),{},{lobbyId:i}))},vl=wl((e=>Hu(qu.accountExists,`Lobby ${e.lobbyId} already exists.`)),(e=>{const{db:t,json:n,lobbyId:r}=e,[o,i]=zu(Ne,n);if(null==o)return i;const[a,s]=zu(Pe,o.data);if(null==a)return s;const{timeout:c=600}=a,u=new Date(Date.now()+1e3*c).toISOString();return t.lobbies.set(r,{request:a,replies:[],expires:u}),Hu()})),ml=wl((e=>{const{json:t,lobby:n}=e,[r,o]=zu(Ne,t);if(null==r)return o;const[i,a]=zu(Me,r.data);return null==i?a:(n.replies.push(i),Hu())})),Il=wl((e=>{const{lobby:t}=e;return Yu(vt(t))})),El=wl((e=>{const{db:t,lobbyId:n}=e;return t.lobbies.delete(n),Hu()})),Sl=e=>t=>{const{db:n,path:r}=t,o=r.split("/")[4],i=n.repos.get(o);return null==i?$u({msg:"Hash not found"},{status:404}):e(Xu(Xu({},t),{},{repo:i}))},Ol=Sl((e=>{const{repo:t}=e;return $u({changes:Mt(t)})})),Al=Sl((e=>{const{json:t,repo:n}=e,{changes:r}=Tl(t);for(const o of Object.keys(r))n[o]=r[o];return $u({changes:Mt(n),hash:"1111111111111111111111111111111111111111"})})),Tl=ye({changes:ye(_e)}),_l=m({"/api/v2/login/?":v({GET:Zu(nl),POST:Zu(nl)}),"/api/v2/login/create/?":v({POST:Zu(ol),PUT:Zu(ol)}),"/api/v2/login/keys/?":v({POST:Zu(il)}),"/api/v2/login/otp/?":v({DELETE:Zu(sl),POST:Zu(al),PUT:Zu(al)}),"/api/v2/login/password/?":v({DELETE:Zu(cl),POST:Zu(ul),PUT:Zu(ul)}),"/api/v2/login/pin2/?":v({DELETE:Zu(ll),POST:Zu(dl),PUT:Zu(dl)}),"/api/v2/login/recovery2/?":v({DELETE:Zu(fl),POST:Zu(pl),PUT:Zu(pl)}),"/api/v2/login/secret/?":v({POST:Zu(hl)}),"/api/v2/login/username/?":v({POST:Zu(yl)}),"/api/v2/login/vouchers/?":v({POST:Zu(bl)}),"/api/v2/messages/?":v({POST:Zu((e=>{const{db:t,json:n}=e,[r,o]=zu(Ne,n);if(null==r)return o;const{loginIds:i}=r;if(null==i)return Hu(qu.invalidRequest);const a=[];for(const s of i){const e=t.getLoginById(s);null!=e&&a.push({loginId:s,otpResetPending:null!=e.otpResetDate,pendingVouchers:Fu(e),recovery2Corrupt:!1})}return Yu(It(a))}))}),"/api/v2/lobby/[^/]+/?":v({DELETE:Zu(El),GET:Zu(Il),POST:Zu(ml),PUT:Zu(vl)}),"/api/v2/store/[^/]+/?":v({GET:Ol,POST:Al}),"/v1/edgeServers":v({GET:e=>$u({infoServers:["https://info-fake1.edge.app"],syncServers:["https://sync-fake1.edge.app","https://sync-fake2.edge.app","https://sync-fake3.edge.app"]})})},(e=>Hu(qu.notFound,`Unknown API endpoint ${e.path}`)));function kl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function xl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kl(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kl(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function Pl(e,t){const{lastLogin:n,server:r}=t,o=y.parse(t.loginId),i=y.parse(t.loginKey),a=Gn({appId:"",lastLogin:n,loginId:o,pendingVouchers:[],username:null==t.username?void 0:re(t.username)},i,Je(r)),s=`logins/${jt.stringify(o)}.json`;await e.disklet.setText(s,JSON.stringify(Cn(a))).catch((()=>{}))}async function Ml(e,t,n){const r=io(e,{dataKey:new Uint8Array(0),syncKey:t});await so(r.dataDisklet,n),await r.baseDisklet.setText("status.json",JSON.stringify({lastSync:1,lastHash:null}))}function Cl(e,t,n){const{io:r,nativeIo:o}=e,i=new Ku,a=function(e){const t=yn((n=>{if(t.offline)throw new Error("Fake network error");const r=n.body.byteLength>0?JSON.parse(Dt.stringify(new Uint8Array(n.body))):{};return _l(Xu(Xu({},n),{},{db:e,json:r}))}),{offline:!1});return t}(i);for(const u of n){i.setupLogin(xt(u.server));for(const e of Object.keys(u.repos))i.setupRepo(e,_t(u.repos[e]))}const s=[],c={async close(){await Promise.all(s.map((e=>e.close()))),B(c)},async makeEdgeContext(e){const{allowNetworkAccess:i=!1,cleanDevice:c=!1,extraFiles:u={}}=e,l=g(a),d=i?(e,t)=>{try{Rt(e)}catch(n){return r.fetch(e,t)}return l(e,t)}:l,f=xl(xl({},r),{},{disklet:(0,ee.Wh)(),fetch:d});if(!c)for(const t of n){await Pl(f,t);for(const e of Object.keys(t.repos))await Ml(f,p.parse(e),_t(t.repos[e]))}if(null!=u)for(const t of Object.keys(u))await f.disklet.setText(t,u[t]);const h=await ju({io:f,nativeIo:o},t,xl({},e));return s.push(h),h},async goOffline(e=!0){a.offline=e},async dumpFakeUser(e){if(""!==e.appId)throw new Error("Only root logins are dumpable.");const t=jt.parse(e.rootLoginId),n=jt.parse(await e.getLoginKey()),r=i.getLoginById(t);if(null==r)throw new Error(`Cannot find user ${e.rootLoginId}`);const o=[];for(const i of e.allKeys){const t=await e.getRawPrivateKey(i.id);null!=t.syncKey&&o.push(p.stringify(y.parse(t.syncKey)).toLowerCase())}const a={};for(const s of o){const e=i.repos.get(s);null!=e&&(a[s]=Mt(e))}return{lastLogin:e.lastLogin,loginId:y.stringify(t),loginKey:y.stringify(n),repos:a,server:Pt(i.dumpLogin(r)),username:e.username}}};return _(c),c}function Nl(e){return function(t){return new Worker(e,t)}}var jl=Nl(new URL(n(8326),n.b));const Dl=Symbol("Comlink.proxy"),Rl=Symbol("Comlink.endpoint"),Ll=Symbol("Comlink.releaseProxy"),Bl=Symbol("Comlink.finalizer"),Kl=Symbol("Comlink.thrown"),Ul=e=>"object"==typeof e&&null!==e||"function"==typeof e,Fl=new Map([["proxy",{canHandle:e=>Ul(e)&&e[Dl],serialize(e){const{port1:t,port2:n}=new MessageChannel;return Wl(e,t),[n,[n]]},deserialize(e){return e.start(),ql(e)}}],["throw",{canHandle:e=>Ul(e)&&Kl in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function Wl(e,t=globalThis,n=["*"]){t.addEventListener("message",(function r(o){if(!o||!o.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(n,o.origin))return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);const{id:i,type:a,path:s}=Object.assign({path:[]},o.data),c=(o.data.argumentList||[]).map(Ql);let u;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),n=s.reduce(((e,t)=>e[t]),e);switch(a){case"GET":u=n;break;case"SET":t[s.slice(-1)[0]]=Ql(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[Dl]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;Wl(e,n),u=function(e,t){return Xl.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[Kl]:0}}Promise.resolve(u).catch((e=>({value:e,[Kl]:0}))).then((n=>{const[o,s]=Zl(n);t.postMessage(Object.assign(Object.assign({},o),{id:i}),s),"RELEASE"===a&&(t.removeEventListener("message",r),Gl(t),Bl in e&&"function"==typeof e[Bl]&&e[Bl]())})).catch((e=>{const[n,r]=Zl({value:new TypeError("Unserializable return value"),[Kl]:0});t.postMessage(Object.assign(Object.assign({},n),{id:i}),r)}))})),t.start&&t.start()}function Gl(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function ql(e,t){const n=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}})),Vl(e,n,[],t)}function zl(e){if(e)throw new Error("Proxy has been released and is not useable")}function $l(e){return ed(e,new Map,{type:"RELEASE"}).then((()=>{Gl(e)}))}const Hl=new WeakMap,Yl="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(Hl.get(e)||0)-1;Hl.set(e,t),0===t&&$l(e)}));function Vl(e,t,n=[],r=function(){}){let o=!1;const i=new Proxy(r,{get(r,a){if(zl(o),a===Ll)return()=>{!function(e){Yl&&Yl.unregister(e)}(i),$l(e),t.clear(),o=!0};if("then"===a){if(0===n.length)return{then:()=>i};const r=ed(e,t,{type:"GET",path:n.map((e=>e.toString()))}).then(Ql);return r.then.bind(r)}return Vl(e,t,[...n,a])},set(r,i,a){zl(o);const[s,c]=Zl(a);return ed(e,t,{type:"SET",path:[...n,i].map((e=>e.toString())),value:s},c).then(Ql)},apply(r,i,a){zl(o);const s=n[n.length-1];if(s===Rl)return ed(e,t,{type:"ENDPOINT"}).then(Ql);if("bind"===s)return Vl(e,t,n.slice(0,-1));const[c,u]=Jl(a);return ed(e,t,{type:"APPLY",path:n.map((e=>e.toString())),argumentList:c},u).then(Ql)},construct(r,i){zl(o);const[a,s]=Jl(i);return ed(e,t,{type:"CONSTRUCT",path:n.map((e=>e.toString())),argumentList:a},s).then(Ql)}});return function(e,t){const n=(Hl.get(t)||0)+1;Hl.set(t,n),Yl&&Yl.register(e,t,e)}(i,e),i}function Jl(e){const t=e.map(Zl);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const Xl=new WeakMap;function Zl(e){for(const[t,n]of Fl)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},Xl.get(e)||[]]}function Ql(e){switch(e.type){case"HANDLER":return Fl.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ed(e,t,n,r){return new Promise((o=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(i,o),e.start&&e.start(),e.postMessage(Object.assign({id:i},n),r)}))}var td;!function(e){e.Loaded="Loaded"}(td||(td={}));const nd=async()=>{const e=ql(await(async()=>new Promise(((e,t)=>{const n=new jl({type:"module"});n.addEventListener("error",t),n.addEventListener("message",(r=>{n.removeEventListener("error",t),r.data?.kind===td.Loaded?e(n):t(r)}),{once:!0})})))());return{setupMixFetch:e.setupMixFetch,mixFetch:async(t,n)=>{const r=await e.mixFetch(t,n);if(!r)throw new Error("No response received");console.log({workerResponse:r});const{headers:o,status:i,statusText:a}=r,s=(e=>{const t=new Headers;return Object.keys(e).forEach((n=>{t.append(n,e[n])})),t})(o);if(r.body.blobUrl){const e=await(await fetch(r.body.blobUrl)).blob(),t=await e.arrayBuffer();return new Response(t,{headers:s,status:i,statusText:a})}const c=Object.values(r.body)[0];return new Response(c,{headers:s,status:i,statusText:a})},disconnectMixFetch:e.disconnectMixFetch}},rd=async e=>{if(!window)throw new Error("`window` is not defined");return window.__mixFetchGlobal||(window.__mixFetchGlobal=await nd(),await window.__mixFetchGlobal.setupMixFetch(e),window.onunload=async()=>{window.__mixFetchGlobal&&await window.__mixFetchGlobal.disconnectMixFetch()}),window.__mixFetchGlobal},od=async(e,t,n)=>(await rd({mixFetchOverride:{requestTimeoutMs:6e4},...n})).mixFetch(e,t),id={forceTls:!0};let ad=null;const sd=new Map;async function cd(e,t){var n;const r=function(e){try{const t=new URL(e),n=""!==t.port?t.port:"https:"===t.protocol?"443":"80";return`${t.hostname}:${n}`}catch(t){return e}}(e),o=(null!==(n=sd.get(r))&&void 0!==n?n:Promise.resolve()).catch((()=>{})).then((async()=>await od(e,t,id))).finally((()=>{sd.get(r)===o&&sd.delete(r)}));return sd.set(r,o),await o}const ud=["allKeys","displayPrivateSeed","displayPublicSeed","keys","otpKey","loginKey","publicWalletInfo","recoveryKey"];function ld(e){const t=function(){const e={resolve(){},reject(){}};let t=0;if("undefined"!=typeof Map){const n=new Map;return{add(e){const r=++t;return n.set(r,e),r},grab(t){const r=n.get(t);return null==r?e:(n.delete(t),r)}}}const n={};return{add(e){const r=++t;return n[String(r)]=e,r},grab(t){const r=n[String(t)];return null==r?e:(delete n[String(t)],r)}}}();return{call(n,...r){return new Promise(((o,i)=>{e(t.add({resolve:o,reject:i}),n,r)}))},resolve(e,n){t.grab(e).resolve(n)},reject(e,n){t.grab(e).reject(new Error(n))}}}function dd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dd(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dd(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const pd=new Map,[hd,yd]=null!=window.edgeCore?[ld(((e,t,n)=>{window.edgeCore.call(e,t,JSON.stringify(n))})),new V({hideProperties:ud,sendMessage(e){window.edgeCore.postMessage(JSON.stringify(e))},throttleMs:50})]:[ld(((e,t,n)=>{window.webkit.messageHandlers.edgeCore.postMessage([e,t,n])})),new V({hideProperties:ud,sendMessage(e){window.webkit.messageHandlers.edgeCore.postMessage([0,"postMessage",[JSON.stringify(e)]])},throttleMs:50})];function bd(e){const{head:t}=window.document;if(null==t||0===e.length)return void $r();let n=0;const r=()=>{++n>=e.length&&$r()};for(const o of e){const e=document.createElement("script");e.addEventListener("error",r),e.addEventListener("load",r),e.charset="utf-8",e.defer=!0,e.src=o,t.appendChild(e)}}async function gd(e){const t=Cr(e,"react-native-io"),n=new(s())({hash:i().sha256,entropy:y.parse(await hd.call("randomBytes",32))}),r=async(e,t={})=>{const{method:n="GET",headers:r={},body:o}=t,i=await hd.call("fetch",e,n,r,o instanceof ArrayBuffer?y.stringify(new Uint8Array(o)):o,o instanceof ArrayBuffer);return w({status:i.status,headers:i.headers,body:i.bodyIsBase64?y.parse(i.body):i.body})},o={disklet:{delete(e){return hd.call("diskletDelete",wd(e))},async getData(e){const t=await hd.call("diskletGetData",wd(e));return y.parse(t)},getText(e){return hd.call("diskletGetText",wd(e))},list(e=""){return hd.call("diskletList",wd(e))},setData(e,t){return hd.call("diskletSetData",wd(e),y.stringify(t))},setText(e,t){return hd.call("diskletSetText",wd(e),t)}},random:e=>n.generate(e),async scrypt(e,t,n,r,o,i){const a=await hd.call("scrypt",y.stringify(e),y.stringify(t),n,r,o,i);return y.parse(a)},async fetch(e,n){var o;const{corsBypass:i="auto",privacy:a="none"}=null!=n?n:{};if("nym"===a){await async function(e){return null==ad&&(e("Initializing mixFetch..."),ad=rd(id).then((t=>(e("mixFetch initialized successfully"),t))).catch((t=>{throw ad=null,e.error("mixFetch initialization failed:",t),t}))),await ad}(t);return await cd(e,fd(fd({},n),{},{mode:"unsafe-ignore-cors"}))}if("always"===i)return await r(e,n);if("never"===i)return await window.fetch(e,n);const{protocol:s,host:c,pathname:u}=new URL(e),l=`${s}//${c}${u}`,d=null!==(o=pd.get(l))&&void 0!==o?o:{windowSuccess:!1,nativeSuccess:!1};if(pd.has(l)||pd.set(l,d),!d.nativeSuccess)try{const t=await window.fetch(e,n);return d.windowSuccess=!0,t}catch(p){if(d.windowSuccess)throw p}const f=await r(e,n);return d.nativeSuccess=!0,f},async fetchCors(e,t={}){return await o.fetch(e,t)}};return o}function wd(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}window.addEdgeCorePlugins=function(e){if(Gr)throw new Error("The Edge core plugin list has already been locked");for(const t of Object.keys(e))Wr[t]=e[t];for(const t of qr)t(e)},window.nativeBridge=hd,window.reactBridge=yd;const vd=_({async makeEdgeContext(e,t,n,r){bd(n);const o=await gd(t);return await ju({io:o,nativeIo:e},t,r)},async makeFakeEdgeWorld(e,t,n,r=[]){bd(n);return Cl({io:await gd(t),nativeIo:e},t,r)}});yd.sendRoot(vd)}()}();
|
|
2
|
+
!function(){var e={8826:function(e){"use strict";!function(t){function n(e){return parseInt(e)===e}function r(e){if(!n(e.length))return!1;for(var t=0;t<e.length;t++)if(!n(e[t])||e[t]<0||e[t]>255)return!1;return!0}function o(e,t){if(e.buffer&&ArrayBuffer.isView(e)&&"Uint8Array"===e.name)return t&&(e=e.slice?e.slice():Array.prototype.slice.call(e)),e;if(Array.isArray(e)){if(!r(e))throw new Error("Array contains invalid value: "+e);return new Uint8Array(e)}if(n(e.length)&&r(e))return new Uint8Array(e);throw new Error("unsupported array-like object")}function i(e){return new Uint8Array(e)}function a(e,t,n,r,o){null==r&&null==o||(e=e.slice?e.slice(r,o):Array.prototype.slice.call(e,r,o)),t.set(e,n)}var s,c={toBytes:function(e){var t=[],n=0;for(e=encodeURI(e);n<e.length;){var r=e.charCodeAt(n++);37===r?(t.push(parseInt(e.substr(n,2),16)),n+=2):t.push(r)}return o(t)},fromBytes:function(e){for(var t=[],n=0;n<e.length;){var r=e[n];r<128?(t.push(String.fromCharCode(r)),n++):r>191&&r<224?(t.push(String.fromCharCode((31&r)<<6|63&e[n+1])),n+=2):(t.push(String.fromCharCode((15&r)<<12|(63&e[n+1])<<6|63&e[n+2])),n+=3)}return t.join("")}},u=(s="0123456789abcdef",{toBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},fromBytes:function(e){for(var t=[],n=0;n<e.length;n++){var r=e[n];t.push(s[(240&r)>>4]+s[15&r])}return t.join("")}}),l={16:10,24:12,32:14},d=[1,2,4,8,16,32,64,128,27,54,108,216,171,77,154,47,94,188,99,198,151,53,106,212,179,125,250,239,197,145],f=[99,124,119,123,242,107,111,197,48,1,103,43,254,215,171,118,202,130,201,125,250,89,71,240,173,212,162,175,156,164,114,192,183,253,147,38,54,63,247,204,52,165,229,241,113,216,49,21,4,199,35,195,24,150,5,154,7,18,128,226,235,39,178,117,9,131,44,26,27,110,90,160,82,59,214,179,41,227,47,132,83,209,0,237,32,252,177,91,106,203,190,57,74,76,88,207,208,239,170,251,67,77,51,133,69,249,2,127,80,60,159,168,81,163,64,143,146,157,56,245,188,182,218,33,16,255,243,210,205,12,19,236,95,151,68,23,196,167,126,61,100,93,25,115,96,129,79,220,34,42,144,136,70,238,184,20,222,94,11,219,224,50,58,10,73,6,36,92,194,211,172,98,145,149,228,121,231,200,55,109,141,213,78,169,108,86,244,234,101,122,174,8,186,120,37,46,28,166,180,198,232,221,116,31,75,189,139,138,112,62,181,102,72,3,246,14,97,53,87,185,134,193,29,158,225,248,152,17,105,217,142,148,155,30,135,233,206,85,40,223,140,161,137,13,191,230,66,104,65,153,45,15,176,84,187,22],p=[82,9,106,213,48,54,165,56,191,64,163,158,129,243,215,251,124,227,57,130,155,47,255,135,52,142,67,68,196,222,233,203,84,123,148,50,166,194,35,61,238,76,149,11,66,250,195,78,8,46,161,102,40,217,36,178,118,91,162,73,109,139,209,37,114,248,246,100,134,104,152,22,212,164,92,204,93,101,182,146,108,112,72,80,253,237,185,218,94,21,70,87,167,141,157,132,144,216,171,0,140,188,211,10,247,228,88,5,184,179,69,6,208,44,30,143,202,63,15,2,193,175,189,3,1,19,138,107,58,145,17,65,79,103,220,234,151,242,207,206,240,180,230,115,150,172,116,34,231,173,53,133,226,249,55,232,28,117,223,110,71,241,26,113,29,41,197,137,111,183,98,14,170,24,190,27,252,86,62,75,198,210,121,32,154,219,192,254,120,205,90,244,31,221,168,51,136,7,199,49,177,18,16,89,39,128,236,95,96,81,127,169,25,181,74,13,45,229,122,159,147,201,156,239,160,224,59,77,174,42,245,176,200,235,187,60,131,83,153,97,23,43,4,126,186,119,214,38,225,105,20,99,85,33,12,125],h=[3328402341,4168907908,4000806809,4135287693,4294111757,3597364157,3731845041,2445657428,1613770832,33620227,3462883241,1445669757,3892248089,3050821474,1303096294,3967186586,2412431941,528646813,2311702848,4202528135,4026202645,2992200171,2387036105,4226871307,1101901292,3017069671,1604494077,1169141738,597466303,1403299063,3832705686,2613100635,1974974402,3791519004,1033081774,1277568618,1815492186,2118074177,4126668546,2211236943,1748251740,1369810420,3521504564,4193382664,3799085459,2883115123,1647391059,706024767,134480908,2512897874,1176707941,2646852446,806885416,932615841,168101135,798661301,235341577,605164086,461406363,3756188221,3454790438,1311188841,2142417613,3933566367,302582043,495158174,1479289972,874125870,907746093,3698224818,3025820398,1537253627,2756858614,1983593293,3084310113,2108928974,1378429307,3722699582,1580150641,327451799,2790478837,3117535592,0,3253595436,1075847264,3825007647,2041688520,3059440621,3563743934,2378943302,1740553945,1916352843,2487896798,2555137236,2958579944,2244988746,3151024235,3320835882,1336584933,3992714006,2252555205,2588757463,1714631509,293963156,2319795663,3925473552,67240454,4269768577,2689618160,2017213508,631218106,1269344483,2723238387,1571005438,2151694528,93294474,1066570413,563977660,1882732616,4059428100,1673313503,2008463041,2950355573,1109467491,537923632,3858759450,4260623118,3218264685,2177748300,403442708,638784309,3287084079,3193921505,899127202,2286175436,773265209,2479146071,1437050866,4236148354,2050833735,3362022572,3126681063,840505643,3866325909,3227541664,427917720,2655997905,2749160575,1143087718,1412049534,999329963,193497219,2353415882,3354324521,1807268051,672404540,2816401017,3160301282,369822493,2916866934,3688947771,1681011286,1949973070,336202270,2454276571,201721354,1210328172,3093060836,2680341085,3184776046,1135389935,3294782118,965841320,831886756,3554993207,4068047243,3588745010,2345191491,1849112409,3664604599,26054028,2983581028,2622377682,1235855840,3630984372,2891339514,4092916743,3488279077,3395642799,4101667470,1202630377,268961816,1874508501,4034427016,1243948399,1546530418,941366308,1470539505,1941222599,2546386513,3421038627,2715671932,3899946140,1042226977,2521517021,1639824860,227249030,260737669,3765465232,2084453954,1907733956,3429263018,2420656344,100860677,4160157185,470683154,3261161891,1781871967,2924959737,1773779408,394692241,2579611992,974986535,664706745,3655459128,3958962195,731420851,571543859,3530123707,2849626480,126783113,865375399,765172662,1008606754,361203602,3387549984,2278477385,2857719295,1344809080,2782912378,59542671,1503764984,160008576,437062935,1707065306,3622233649,2218934982,3496503480,2185314755,697932208,1512910199,504303377,2075177163,2824099068,1841019862,739644986],y=[2781242211,2230877308,2582542199,2381740923,234877682,3184946027,2984144751,1418839493,1348481072,50462977,2848876391,2102799147,434634494,1656084439,3863849899,2599188086,1167051466,2636087938,1082771913,2281340285,368048890,3954334041,3381544775,201060592,3963727277,1739838676,4250903202,3930435503,3206782108,4149453988,2531553906,1536934080,3262494647,484572669,2923271059,1783375398,1517041206,1098792767,49674231,1334037708,1550332980,4098991525,886171109,150598129,2481090929,1940642008,1398944049,1059722517,201851908,1385547719,1699095331,1587397571,674240536,2704774806,252314885,3039795866,151914247,908333586,2602270848,1038082786,651029483,1766729511,3447698098,2682942837,454166793,2652734339,1951935532,775166490,758520603,3000790638,4004797018,4217086112,4137964114,1299594043,1639438038,3464344499,2068982057,1054729187,1901997871,2534638724,4121318227,1757008337,0,750906861,1614815264,535035132,3363418545,3988151131,3201591914,1183697867,3647454910,1265776953,3734260298,3566750796,3903871064,1250283471,1807470800,717615087,3847203498,384695291,3313910595,3617213773,1432761139,2484176261,3481945413,283769337,100925954,2180939647,4037038160,1148730428,3123027871,3813386408,4087501137,4267549603,3229630528,2315620239,2906624658,3156319645,1215313976,82966005,3747855548,3245848246,1974459098,1665278241,807407632,451280895,251524083,1841287890,1283575245,337120268,891687699,801369324,3787349855,2721421207,3431482436,959321879,1469301956,4065699751,2197585534,1199193405,2898814052,3887750493,724703513,2514908019,2696962144,2551808385,3516813135,2141445340,1715741218,2119445034,2872807568,2198571144,3398190662,700968686,3547052216,1009259540,2041044702,3803995742,487983883,1991105499,1004265696,1449407026,1316239930,504629770,3683797321,168560134,1816667172,3837287516,1570751170,1857934291,4014189740,2797888098,2822345105,2754712981,936633572,2347923833,852879335,1133234376,1500395319,3084545389,2348912013,1689376213,3533459022,3762923945,3034082412,4205598294,133428468,634383082,2949277029,2398386810,3913789102,403703816,3580869306,2297460856,1867130149,1918643758,607656988,4049053350,3346248884,1368901318,600565992,2090982877,2632479860,557719327,3717614411,3697393085,2249034635,2232388234,2430627952,1115438654,3295786421,2865522278,3633334344,84280067,33027830,303828494,2747425121,1600795957,4188952407,3496589753,2434238086,1486471617,658119965,3106381470,953803233,334231800,3005978776,857870609,3151128937,1890179545,2298973838,2805175444,3056442267,574365214,2450884487,550103529,1233637070,4289353045,2018519080,2057691103,2399374476,4166623649,2148108681,387583245,3664101311,836232934,3330556482,3100665960,3280093505,2955516313,2002398509,287182607,3413881008,4238890068,3597515707,975967766],b=[1671808611,2089089148,2006576759,2072901243,4061003762,1807603307,1873927791,3310653893,810573872,16974337,1739181671,729634347,4263110654,3613570519,2883997099,1989864566,3393556426,2191335298,3376449993,2106063485,4195741690,1508618841,1204391495,4027317232,2917941677,3563566036,2734514082,2951366063,2629772188,2767672228,1922491506,3227229120,3082974647,4246528509,2477669779,644500518,911895606,1061256767,4144166391,3427763148,878471220,2784252325,3845444069,4043897329,1905517169,3631459288,827548209,356461077,67897348,3344078279,593839651,3277757891,405286936,2527147926,84871685,2595565466,118033927,305538066,2157648768,3795705826,3945188843,661212711,2999812018,1973414517,152769033,2208177539,745822252,439235610,455947803,1857215598,1525593178,2700827552,1391895634,994932283,3596728278,3016654259,695947817,3812548067,795958831,2224493444,1408607827,3513301457,0,3979133421,543178784,4229948412,2982705585,1542305371,1790891114,3410398667,3201918910,961245753,1256100938,1289001036,1491644504,3477767631,3496721360,4012557807,2867154858,4212583931,1137018435,1305975373,861234739,2241073541,1171229253,4178635257,33948674,2139225727,1357946960,1011120188,2679776671,2833468328,1374921297,2751356323,1086357568,2408187279,2460827538,2646352285,944271416,4110742005,3168756668,3066132406,3665145818,560153121,271589392,4279952895,4077846003,3530407890,3444343245,202643468,322250259,3962553324,1608629855,2543990167,1154254916,389623319,3294073796,2817676711,2122513534,1028094525,1689045092,1575467613,422261273,1939203699,1621147744,2174228865,1339137615,3699352540,577127458,712922154,2427141008,2290289544,1187679302,3995715566,3100863416,339486740,3732514782,1591917662,186455563,3681988059,3762019296,844522546,978220090,169743370,1239126601,101321734,611076132,1558493276,3260915650,3547250131,2901361580,1655096418,2443721105,2510565781,3828863972,2039214713,3878868455,3359869896,928607799,1840765549,2374762893,3580146133,1322425422,2850048425,1823791212,1459268694,4094161908,3928346602,1706019429,2056189050,2934523822,135794696,3134549946,2022240376,628050469,779246638,472135708,2800834470,3032970164,3327236038,3894660072,3715932637,1956440180,522272287,1272813131,3185336765,2340818315,2323976074,1888542832,1044544574,3049550261,1722469478,1222152264,50660867,4127324150,236067854,1638122081,895445557,1475980887,3117443513,2257655686,3243809217,489110045,2662934430,3778599393,4162055160,2561878936,288563729,1773916777,3648039385,2391345038,2493985684,2612407707,505560094,2274497927,3911240169,3460925390,1442818645,678973480,3749357023,2358182796,2717407649,2306869641,219617805,3218761151,3862026214,1120306242,1756942440,1103331905,2578459033,762796589,252780047,2966125488,1425844308,3151392187,372911126],g=[1667474886,2088535288,2004326894,2071694838,4075949567,1802223062,1869591006,3318043793,808472672,16843522,1734846926,724270422,4278065639,3621216949,2880169549,1987484396,3402253711,2189597983,3385409673,2105378810,4210693615,1499065266,1195886990,4042263547,2913856577,3570689971,2728590687,2947541573,2627518243,2762274643,1920112356,3233831835,3082273397,4261223649,2475929149,640051788,909531756,1061110142,4160160501,3435941763,875846760,2779116625,3857003729,4059105529,1903268834,3638064043,825316194,353713962,67374088,3351728789,589522246,3284360861,404236336,2526454071,84217610,2593830191,117901582,303183396,2155911963,3806477791,3958056653,656894286,2998062463,1970642922,151591698,2206440989,741110872,437923380,454765878,1852748508,1515908788,2694904667,1381168804,993742198,3604373943,3014905469,690584402,3823320797,791638366,2223281939,1398011302,3520161977,0,3991743681,538992704,4244381667,2981218425,1532751286,1785380564,3419096717,3200178535,960056178,1246420628,1280103576,1482221744,3486468741,3503319995,4025428677,2863326543,4227536621,1128514950,1296947098,859002214,2240123921,1162203018,4193849577,33687044,2139062782,1347481760,1010582648,2678045221,2829640523,1364325282,2745433693,1077985408,2408548869,2459086143,2644360225,943212656,4126475505,3166494563,3065430391,3671750063,555836226,269496352,4294908645,4092792573,3537006015,3452783745,202118168,320025894,3974901699,1600119230,2543297077,1145359496,387397934,3301201811,2812801621,2122220284,1027426170,1684319432,1566435258,421079858,1936954854,1616945344,2172753945,1330631070,3705438115,572679748,707427924,2425400123,2290647819,1179044492,4008585671,3099120491,336870440,3739122087,1583276732,185277718,3688593069,3772791771,842159716,976899700,168435220,1229577106,101059084,606366792,1549591736,3267517855,3553849021,2897014595,1650632388,2442242105,2509612081,3840161747,2038008818,3890688725,3368567691,926374254,1835907034,2374863873,3587531953,1313788572,2846482505,1819063512,1448540844,4109633523,3941213647,1701162954,2054852340,2930698567,134748176,3132806511,2021165296,623210314,774795868,471606328,2795958615,3031746419,3334885783,3907527627,3722280097,1953799400,522133822,1263263126,3183336545,2341176845,2324333839,1886425312,1044267644,3048588401,1718004428,1212733584,50529542,4143317495,235803164,1633788866,892690282,1465383342,3115962473,2256965911,3250673817,488449850,2661202215,3789633753,4177007595,2560144171,286339874,1768537042,3654906025,2391705863,2492770099,2610673197,505291324,2273808917,3924369609,3469625735,1431699370,673740880,3755965093,2358021891,2711746649,2307489801,218961690,3217021541,3873845719,1111672452,1751693520,1094828930,2576986153,757954394,252645662,2964376443,1414855848,3149649517,370555436],w=[1374988112,2118214995,437757123,975658646,1001089995,530400753,2902087851,1273168787,540080725,2910219766,2295101073,4110568485,1340463100,3307916247,641025152,3043140495,3736164937,632953703,1172967064,1576976609,3274667266,2169303058,2370213795,1809054150,59727847,361929877,3211623147,2505202138,3569255213,1484005843,1239443753,2395588676,1975683434,4102977912,2572697195,666464733,3202437046,4035489047,3374361702,2110667444,1675577880,3843699074,2538681184,1649639237,2976151520,3144396420,4269907996,4178062228,1883793496,2403728665,2497604743,1383856311,2876494627,1917518562,3810496343,1716890410,3001755655,800440835,2261089178,3543599269,807962610,599762354,33778362,3977675356,2328828971,2809771154,4077384432,1315562145,1708848333,101039829,3509871135,3299278474,875451293,2733856160,92987698,2767645557,193195065,1080094634,1584504582,3178106961,1042385657,2531067453,3711829422,1306967366,2438237621,1908694277,67556463,1615861247,429456164,3602770327,2302690252,1742315127,2968011453,126454664,3877198648,2043211483,2709260871,2084704233,4169408201,0,159417987,841739592,504459436,1817866830,4245618683,260388950,1034867998,908933415,168810852,1750902305,2606453969,607530554,202008497,2472011535,3035535058,463180190,2160117071,1641816226,1517767529,470948374,3801332234,3231722213,1008918595,303765277,235474187,4069246893,766945465,337553864,1475418501,2943682380,4003061179,2743034109,4144047775,1551037884,1147550661,1543208500,2336434550,3408119516,3069049960,3102011747,3610369226,1113818384,328671808,2227573024,2236228733,3535486456,2935566865,3341394285,496906059,3702665459,226906860,2009195472,733156972,2842737049,294930682,1206477858,2835123396,2700099354,1451044056,573804783,2269728455,3644379585,2362090238,2564033334,2801107407,2776292904,3669462566,1068351396,742039012,1350078989,1784663195,1417561698,4136440770,2430122216,775550814,2193862645,2673705150,1775276924,1876241833,3475313331,3366754619,270040487,3902563182,3678124923,3441850377,1851332852,3969562369,2203032232,3868552805,2868897406,566021896,4011190502,3135740889,1248802510,3936291284,699432150,832877231,708780849,3332740144,899835584,1951317047,4236429990,3767586992,866637845,4043610186,1106041591,2144161806,395441711,1984812685,1139781709,3433712980,3835036895,2664543715,1282050075,3240894392,1181045119,2640243204,25965917,4203181171,4211818798,3009879386,2463879762,3910161971,1842759443,2597806476,933301370,1509430414,3943906441,3467192302,3076639029,3776767469,2051518780,2631065433,1441952575,404016761,1942435775,1408749034,1610459739,3745345300,2017778566,3400528769,3110650942,941896748,3265478751,371049330,3168937228,675039627,4279080257,967311729,135050206,3635733660,1683407248,2076935265,3576870512,1215061108,3501741890],v=[1347548327,1400783205,3273267108,2520393566,3409685355,4045380933,2880240216,2471224067,1428173050,4138563181,2441661558,636813900,4233094615,3620022987,2149987652,2411029155,1239331162,1730525723,2554718734,3781033664,46346101,310463728,2743944855,3328955385,3875770207,2501218972,3955191162,3667219033,768917123,3545789473,692707433,1150208456,1786102409,2029293177,1805211710,3710368113,3065962831,401639597,1724457132,3028143674,409198410,2196052529,1620529459,1164071807,3769721975,2226875310,486441376,2499348523,1483753576,428819965,2274680428,3075636216,598438867,3799141122,1474502543,711349675,129166120,53458370,2592523643,2782082824,4063242375,2988687269,3120694122,1559041666,730517276,2460449204,4042459122,2706270690,3446004468,3573941694,533804130,2328143614,2637442643,2695033685,839224033,1973745387,957055980,2856345839,106852767,1371368976,4181598602,1033297158,2933734917,1179510461,3046200461,91341917,1862534868,4284502037,605657339,2547432937,3431546947,2003294622,3182487618,2282195339,954669403,3682191598,1201765386,3917234703,3388507166,0,2198438022,1211247597,2887651696,1315723890,4227665663,1443857720,507358933,657861945,1678381017,560487590,3516619604,975451694,2970356327,261314535,3535072918,2652609425,1333838021,2724322336,1767536459,370938394,182621114,3854606378,1128014560,487725847,185469197,2918353863,3106780840,3356761769,2237133081,1286567175,3152976349,4255350624,2683765030,3160175349,3309594171,878443390,1988838185,3704300486,1756818940,1673061617,3403100636,272786309,1075025698,545572369,2105887268,4174560061,296679730,1841768865,1260232239,4091327024,3960309330,3497509347,1814803222,2578018489,4195456072,575138148,3299409036,446754879,3629546796,4011996048,3347532110,3252238545,4270639778,915985419,3483825537,681933534,651868046,2755636671,3828103837,223377554,2607439820,1649704518,3270937875,3901806776,1580087799,4118987695,3198115200,2087309459,2842678573,3016697106,1003007129,2802849917,1860738147,2077965243,164439672,4100872472,32283319,2827177882,1709610350,2125135846,136428751,3874428392,3652904859,3460984630,3572145929,3593056380,2939266226,824852259,818324884,3224740454,930369212,2801566410,2967507152,355706840,1257309336,4148292826,243256656,790073846,2373340630,1296297904,1422699085,3756299780,3818836405,457992840,3099667487,2135319889,77422314,1560382517,1945798516,788204353,1521706781,1385356242,870912086,325965383,2358957921,2050466060,2388260884,2313884476,4006521127,901210569,3990953189,1014646705,1503449823,1062597235,2031621326,3212035895,3931371469,1533017514,350174575,2256028891,2177544179,1052338372,741876788,1606591296,1914052035,213705253,2334669897,1107234197,1899603969,3725069491,2631447780,2422494913,1635502980,1893020342,1950903388,1120974935],m=[2807058932,1699970625,2764249623,1586903591,1808481195,1173430173,1487645946,59984867,4199882800,1844882806,1989249228,1277555970,3623636965,3419915562,1149249077,2744104290,1514790577,459744698,244860394,3235995134,1963115311,4027744588,2544078150,4190530515,1608975247,2627016082,2062270317,1507497298,2200818878,567498868,1764313568,3359936201,2305455554,2037970062,1047239e3,1910319033,1337376481,2904027272,2892417312,984907214,1243112415,830661914,861968209,2135253587,2011214180,2927934315,2686254721,731183368,1750626376,4246310725,1820824798,4172763771,3542330227,48394827,2404901663,2871682645,671593195,3254988725,2073724613,145085239,2280796200,2779915199,1790575107,2187128086,472615631,3029510009,4075877127,3802222185,4107101658,3201631749,1646252340,4270507174,1402811438,1436590835,3778151818,3950355702,3963161475,4020912224,2667994737,273792366,2331590177,104699613,95345982,3175501286,2377486676,1560637892,3564045318,369057872,4213447064,3919042237,1137477952,2658625497,1119727848,2340947849,1530455833,4007360968,172466556,266959938,516552836,0,2256734592,3980931627,1890328081,1917742170,4294704398,945164165,3575528878,958871085,3647212047,2787207260,1423022939,775562294,1739656202,3876557655,2530391278,2443058075,3310321856,547512796,1265195639,437656594,3121275539,719700128,3762502690,387781147,218828297,3350065803,2830708150,2848461854,428169201,122466165,3720081049,1627235199,648017665,4122762354,1002783846,2117360635,695634755,3336358691,4234721005,4049844452,3704280881,2232435299,574624663,287343814,612205898,1039717051,840019705,2708326185,793451934,821288114,1391201670,3822090177,376187827,3113855344,1224348052,1679968233,2361698556,1058709744,752375421,2431590963,1321699145,3519142200,2734591178,188127444,2177869557,3727205754,2384911031,3215212461,2648976442,2450346104,3432737375,1180849278,331544205,3102249176,4150144569,2952102595,2159976285,2474404304,766078933,313773861,2570832044,2108100632,1668212892,3145456443,2013908262,418672217,3070356634,2594734927,1852171925,3867060991,3473416636,3907448597,2614737639,919489135,164948639,2094410160,2997825956,590424639,2486224549,1723872674,3157750862,3399941250,3501252752,3625268135,2555048196,3673637356,1343127501,4130281361,3599595085,2957853679,1297403050,81781910,3051593425,2283490410,532201772,1367295589,3926170974,895287692,1953757831,1093597963,492483431,3528626907,1446242576,1192455638,1636604631,209336225,344873464,1015671571,669961897,3375740769,3857572124,2973530695,3747192018,1933530610,3464042516,935293895,3454686199,2858115069,1863638845,3683022916,4085369519,3292445032,875313188,1080017571,3279033885,621591778,1233856572,2504130317,24197544,3017672716,3835484340,3247465558,2220981195,3060847922,1551124588,1463996600],I=[4104605777,1097159550,396673818,660510266,2875968315,2638606623,4200115116,3808662347,821712160,1986918061,3430322568,38544885,3856137295,718002117,893681702,1654886325,2975484382,3122358053,3926825029,4274053469,796197571,1290801793,1184342925,3556361835,2405426947,2459735317,1836772287,1381620373,3196267988,1948373848,3764988233,3385345166,3263785589,2390325492,1480485785,3111247143,3780097726,2293045232,548169417,3459953789,3746175075,439452389,1362321559,1400849762,1685577905,1806599355,2174754046,137073913,1214797936,1174215055,3731654548,2079897426,1943217067,1258480242,529487843,1437280870,3945269170,3049390895,3313212038,923313619,679998e3,3215307299,57326082,377642221,3474729866,2041877159,133361907,1776460110,3673476453,96392454,878845905,2801699524,777231668,4082475170,2330014213,4142626212,2213296395,1626319424,1906247262,1846563261,562755902,3708173718,1040559837,3871163981,1418573201,3294430577,114585348,1343618912,2566595609,3186202582,1078185097,3651041127,3896688048,2307622919,425408743,3371096953,2081048481,1108339068,2216610296,0,2156299017,736970802,292596766,1517440620,251657213,2235061775,2933202493,758720310,265905162,1554391400,1532285339,908999204,174567692,1474760595,4002861748,2610011675,3234156416,3693126241,2001430874,303699484,2478443234,2687165888,585122620,454499602,151849742,2345119218,3064510765,514443284,4044981591,1963412655,2581445614,2137062819,19308535,1928707164,1715193156,4219352155,1126790795,600235211,3992742070,3841024952,836553431,1669664834,2535604243,3323011204,1243905413,3141400786,4180808110,698445255,2653899549,2989552604,2253581325,3252932727,3004591147,1891211689,2487810577,3915653703,4237083816,4030667424,2100090966,865136418,1229899655,953270745,3399679628,3557504664,4118925222,2061379749,3079546586,2915017791,983426092,2022837584,1607244650,2118541908,2366882550,3635996816,972512814,3283088770,1568718495,3499326569,3576539503,621982671,2895723464,410887952,2623762152,1002142683,645401037,1494807662,2595684844,1335535747,2507040230,4293295786,3167684641,367585007,3885750714,1865862730,2668221674,2960971305,2763173681,1059270954,2777952454,2724642869,1320957812,2194319100,2429595872,2815956275,77089521,3973773121,3444575871,2448830231,1305906550,4021308739,2857194700,2516901860,3518358430,1787304780,740276417,1699839814,1592394909,2352307457,2272556026,188821243,1729977011,3687994002,274084841,3594982253,3613494426,2701949495,4162096729,322734571,2837966542,1640576439,484830689,1202797690,3537852828,4067639125,349075736,3342319475,4157467219,4255800159,1030690015,1155237496,2951971274,1757691577,607398968,2738905026,499347990,3794078908,1011452712,227885567,2818666809,213114376,3034881240,1455525988,3414450555,850817237,1817998408,3092726480],E=[0,235474187,470948374,303765277,941896748,908933415,607530554,708780849,1883793496,2118214995,1817866830,1649639237,1215061108,1181045119,1417561698,1517767529,3767586992,4003061179,4236429990,4069246893,3635733660,3602770327,3299278474,3400528769,2430122216,2664543715,2362090238,2193862645,2835123396,2801107407,3035535058,3135740889,3678124923,3576870512,3341394285,3374361702,3810496343,3977675356,4279080257,4043610186,2876494627,2776292904,3076639029,3110650942,2472011535,2640243204,2403728665,2169303058,1001089995,899835584,666464733,699432150,59727847,226906860,530400753,294930682,1273168787,1172967064,1475418501,1509430414,1942435775,2110667444,1876241833,1641816226,2910219766,2743034109,2976151520,3211623147,2505202138,2606453969,2302690252,2269728455,3711829422,3543599269,3240894392,3475313331,3843699074,3943906441,4178062228,4144047775,1306967366,1139781709,1374988112,1610459739,1975683434,2076935265,1775276924,1742315127,1034867998,866637845,566021896,800440835,92987698,193195065,429456164,395441711,1984812685,2017778566,1784663195,1683407248,1315562145,1080094634,1383856311,1551037884,101039829,135050206,437757123,337553864,1042385657,807962610,573804783,742039012,2531067453,2564033334,2328828971,2227573024,2935566865,2700099354,3001755655,3168937228,3868552805,3902563182,4203181171,4102977912,3736164937,3501741890,3265478751,3433712980,1106041591,1340463100,1576976609,1408749034,2043211483,2009195472,1708848333,1809054150,832877231,1068351396,766945465,599762354,159417987,126454664,361929877,463180190,2709260871,2943682380,3178106961,3009879386,2572697195,2538681184,2236228733,2336434550,3509871135,3745345300,3441850377,3274667266,3910161971,3877198648,4110568485,4211818798,2597806476,2497604743,2261089178,2295101073,2733856160,2902087851,3202437046,2968011453,3936291284,3835036895,4136440770,4169408201,3535486456,3702665459,3467192302,3231722213,2051518780,1951317047,1716890410,1750902305,1113818384,1282050075,1584504582,1350078989,168810852,67556463,371049330,404016761,841739592,1008918595,775550814,540080725,3969562369,3801332234,4035489047,4269907996,3569255213,3669462566,3366754619,3332740144,2631065433,2463879762,2160117071,2395588676,2767645557,2868897406,3102011747,3069049960,202008497,33778362,270040487,504459436,875451293,975658646,675039627,641025152,2084704233,1917518562,1615861247,1851332852,1147550661,1248802510,1484005843,1451044056,933301370,967311729,733156972,632953703,260388950,25965917,328671808,496906059,1206477858,1239443753,1543208500,1441952575,2144161806,1908694277,1675577880,1842759443,3610369226,3644379585,3408119516,3307916247,4011190502,3776767469,4077384432,4245618683,2809771154,2842737049,3144396420,3043140495,2673705150,2438237621,2203032232,2370213795],S=[0,185469197,370938394,487725847,741876788,657861945,975451694,824852259,1483753576,1400783205,1315723890,1164071807,1950903388,2135319889,1649704518,1767536459,2967507152,3152976349,2801566410,2918353863,2631447780,2547432937,2328143614,2177544179,3901806776,3818836405,4270639778,4118987695,3299409036,3483825537,3535072918,3652904859,2077965243,1893020342,1841768865,1724457132,1474502543,1559041666,1107234197,1257309336,598438867,681933534,901210569,1052338372,261314535,77422314,428819965,310463728,3409685355,3224740454,3710368113,3593056380,3875770207,3960309330,4045380933,4195456072,2471224067,2554718734,2237133081,2388260884,3212035895,3028143674,2842678573,2724322336,4138563181,4255350624,3769721975,3955191162,3667219033,3516619604,3431546947,3347532110,2933734917,2782082824,3099667487,3016697106,2196052529,2313884476,2499348523,2683765030,1179510461,1296297904,1347548327,1533017514,1786102409,1635502980,2087309459,2003294622,507358933,355706840,136428751,53458370,839224033,957055980,605657339,790073846,2373340630,2256028891,2607439820,2422494913,2706270690,2856345839,3075636216,3160175349,3573941694,3725069491,3273267108,3356761769,4181598602,4063242375,4011996048,3828103837,1033297158,915985419,730517276,545572369,296679730,446754879,129166120,213705253,1709610350,1860738147,1945798516,2029293177,1239331162,1120974935,1606591296,1422699085,4148292826,4233094615,3781033664,3931371469,3682191598,3497509347,3446004468,3328955385,2939266226,2755636671,3106780840,2988687269,2198438022,2282195339,2501218972,2652609425,1201765386,1286567175,1371368976,1521706781,1805211710,1620529459,2105887268,1988838185,533804130,350174575,164439672,46346101,870912086,954669403,636813900,788204353,2358957921,2274680428,2592523643,2441661558,2695033685,2880240216,3065962831,3182487618,3572145929,3756299780,3270937875,3388507166,4174560061,4091327024,4006521127,3854606378,1014646705,930369212,711349675,560487590,272786309,457992840,106852767,223377554,1678381017,1862534868,1914052035,2031621326,1211247597,1128014560,1580087799,1428173050,32283319,182621114,401639597,486441376,768917123,651868046,1003007129,818324884,1503449823,1385356242,1333838021,1150208456,1973745387,2125135846,1673061617,1756818940,2970356327,3120694122,2802849917,2887651696,2637442643,2520393566,2334669897,2149987652,3917234703,3799141122,4284502037,4100872472,3309594171,3460984630,3545789473,3629546796,2050466060,1899603969,1814803222,1730525723,1443857720,1560382517,1075025698,1260232239,575138148,692707433,878443390,1062597235,243256656,91341917,409198410,325965383,3403100636,3252238545,3704300486,3620022987,3874428392,3990953189,4042459122,4227665663,2460449204,2578018489,2226875310,2411029155,3198115200,3046200461,2827177882,2743944855],O=[0,218828297,437656594,387781147,875313188,958871085,775562294,590424639,1750626376,1699970625,1917742170,2135253587,1551124588,1367295589,1180849278,1265195639,3501252752,3720081049,3399941250,3350065803,3835484340,3919042237,4270507174,4085369519,3102249176,3051593425,2734591178,2952102595,2361698556,2177869557,2530391278,2614737639,3145456443,3060847922,2708326185,2892417312,2404901663,2187128086,2504130317,2555048196,3542330227,3727205754,3375740769,3292445032,3876557655,3926170974,4246310725,4027744588,1808481195,1723872674,1910319033,2094410160,1608975247,1391201670,1173430173,1224348052,59984867,244860394,428169201,344873464,935293895,984907214,766078933,547512796,1844882806,1627235199,2011214180,2062270317,1507497298,1423022939,1137477952,1321699145,95345982,145085239,532201772,313773861,830661914,1015671571,731183368,648017665,3175501286,2957853679,2807058932,2858115069,2305455554,2220981195,2474404304,2658625497,3575528878,3625268135,3473416636,3254988725,3778151818,3963161475,4213447064,4130281361,3599595085,3683022916,3432737375,3247465558,3802222185,4020912224,4172763771,4122762354,3201631749,3017672716,2764249623,2848461854,2331590177,2280796200,2431590963,2648976442,104699613,188127444,472615631,287343814,840019705,1058709744,671593195,621591778,1852171925,1668212892,1953757831,2037970062,1514790577,1463996600,1080017571,1297403050,3673637356,3623636965,3235995134,3454686199,4007360968,3822090177,4107101658,4190530515,2997825956,3215212461,2830708150,2779915199,2256734592,2340947849,2627016082,2443058075,172466556,122466165,273792366,492483431,1047239e3,861968209,612205898,695634755,1646252340,1863638845,2013908262,1963115311,1446242576,1530455833,1277555970,1093597963,1636604631,1820824798,2073724613,1989249228,1436590835,1487645946,1337376481,1119727848,164948639,81781910,331544205,516552836,1039717051,821288114,669961897,719700128,2973530695,3157750862,2871682645,2787207260,2232435299,2283490410,2667994737,2450346104,3647212047,3564045318,3279033885,3464042516,3980931627,3762502690,4150144569,4199882800,3070356634,3121275539,2904027272,2686254721,2200818878,2384911031,2570832044,2486224549,3747192018,3528626907,3310321856,3359936201,3950355702,3867060991,4049844452,4234721005,1739656202,1790575107,2108100632,1890328081,1402811438,1586903591,1233856572,1149249077,266959938,48394827,369057872,418672217,1002783846,919489135,567498868,752375421,209336225,24197544,376187827,459744698,945164165,895287692,574624663,793451934,1679968233,1764313568,2117360635,1933530610,1343127501,1560637892,1243112415,1192455638,3704280881,3519142200,3336358691,3419915562,3907448597,3857572124,4075877127,4294704398,3029510009,3113855344,2927934315,2744104290,2159976285,2377486676,2594734927,2544078150],A=[0,151849742,303699484,454499602,607398968,758720310,908999204,1059270954,1214797936,1097159550,1517440620,1400849762,1817998408,1699839814,2118541908,2001430874,2429595872,2581445614,2194319100,2345119218,3034881240,3186202582,2801699524,2951971274,3635996816,3518358430,3399679628,3283088770,4237083816,4118925222,4002861748,3885750714,1002142683,850817237,698445255,548169417,529487843,377642221,227885567,77089521,1943217067,2061379749,1640576439,1757691577,1474760595,1592394909,1174215055,1290801793,2875968315,2724642869,3111247143,2960971305,2405426947,2253581325,2638606623,2487810577,3808662347,3926825029,4044981591,4162096729,3342319475,3459953789,3576539503,3693126241,1986918061,2137062819,1685577905,1836772287,1381620373,1532285339,1078185097,1229899655,1040559837,923313619,740276417,621982671,439452389,322734571,137073913,19308535,3871163981,4021308739,4104605777,4255800159,3263785589,3414450555,3499326569,3651041127,2933202493,2815956275,3167684641,3049390895,2330014213,2213296395,2566595609,2448830231,1305906550,1155237496,1607244650,1455525988,1776460110,1626319424,2079897426,1928707164,96392454,213114376,396673818,514443284,562755902,679998e3,865136418,983426092,3708173718,3557504664,3474729866,3323011204,4180808110,4030667424,3945269170,3794078908,2507040230,2623762152,2272556026,2390325492,2975484382,3092726480,2738905026,2857194700,3973773121,3856137295,4274053469,4157467219,3371096953,3252932727,3673476453,3556361835,2763173681,2915017791,3064510765,3215307299,2156299017,2307622919,2459735317,2610011675,2081048481,1963412655,1846563261,1729977011,1480485785,1362321559,1243905413,1126790795,878845905,1030690015,645401037,796197571,274084841,425408743,38544885,188821243,3613494426,3731654548,3313212038,3430322568,4082475170,4200115116,3780097726,3896688048,2668221674,2516901860,2366882550,2216610296,3141400786,2989552604,2837966542,2687165888,1202797690,1320957812,1437280870,1554391400,1669664834,1787304780,1906247262,2022837584,265905162,114585348,499347990,349075736,736970802,585122620,972512814,821712160,2595684844,2478443234,2293045232,2174754046,3196267988,3079546586,2895723464,2777952454,3537852828,3687994002,3234156416,3385345166,4142626212,4293295786,3841024952,3992742070,174567692,57326082,410887952,292596766,777231668,660510266,1011452712,893681702,1108339068,1258480242,1343618912,1494807662,1715193156,1865862730,1948373848,2100090966,2701949495,2818666809,3004591147,3122358053,2235061775,2352307457,2535604243,2653899549,3915653703,3764988233,4219352155,4067639125,3444575871,3294430577,3746175075,3594982253,836553431,953270745,600235211,718002117,367585007,484830689,133361907,251657213,2041877159,1891211689,1806599355,1654886325,1568718495,1418573201,1335535747,1184342925];function T(e){for(var t=[],n=0;n<e.length;n+=4)t.push(e[n]<<24|e[n+1]<<16|e[n+2]<<8|e[n+3]);return t}var _=function(e){if(!(this instanceof _))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:o(e,!0)}),this._prepare()};_.prototype._prepare=function(){var e=l[this.key.length];if(null==e)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var t=0;t<=e;t++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var n,r=4*(e+1),o=this.key.length/4,i=T(this.key);for(t=0;t<o;t++)n=t>>2,this._Ke[n][t%4]=i[t],this._Kd[e-n][t%4]=i[t];for(var a,s=0,c=o;c<r;){if(a=i[o-1],i[0]^=f[a>>16&255]<<24^f[a>>8&255]<<16^f[255&a]<<8^f[a>>24&255]^d[s]<<24,s+=1,8!=o)for(t=1;t<o;t++)i[t]^=i[t-1];else{for(t=1;t<o/2;t++)i[t]^=i[t-1];a=i[o/2-1],i[o/2]^=f[255&a]^f[a>>8&255]<<8^f[a>>16&255]<<16^f[a>>24&255]<<24;for(t=o/2+1;t<o;t++)i[t]^=i[t-1]}for(t=0;t<o&&c<r;)u=c>>2,p=c%4,this._Ke[u][p]=i[t],this._Kd[e-u][p]=i[t++],c++}for(var u=1;u<e;u++)for(var p=0;p<4;p++)a=this._Kd[u][p],this._Kd[u][p]=E[a>>24&255]^S[a>>16&255]^O[a>>8&255]^A[255&a]},_.prototype.encrypt=function(e){if(16!=e.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var t=this._Ke.length-1,n=[0,0,0,0],r=T(e),o=0;o<4;o++)r[o]^=this._Ke[0][o];for(var a=1;a<t;a++){for(o=0;o<4;o++)n[o]=h[r[o]>>24&255]^y[r[(o+1)%4]>>16&255]^b[r[(o+2)%4]>>8&255]^g[255&r[(o+3)%4]]^this._Ke[a][o];r=n.slice()}var s,c=i(16);for(o=0;o<4;o++)s=this._Ke[t][o],c[4*o]=255&(f[r[o]>>24&255]^s>>24),c[4*o+1]=255&(f[r[(o+1)%4]>>16&255]^s>>16),c[4*o+2]=255&(f[r[(o+2)%4]>>8&255]^s>>8),c[4*o+3]=255&(f[255&r[(o+3)%4]]^s);return c},_.prototype.decrypt=function(e){if(16!=e.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var t=this._Kd.length-1,n=[0,0,0,0],r=T(e),o=0;o<4;o++)r[o]^=this._Kd[0][o];for(var a=1;a<t;a++){for(o=0;o<4;o++)n[o]=w[r[o]>>24&255]^v[r[(o+3)%4]>>16&255]^m[r[(o+2)%4]>>8&255]^I[255&r[(o+1)%4]]^this._Kd[a][o];r=n.slice()}var s,c=i(16);for(o=0;o<4;o++)s=this._Kd[t][o],c[4*o]=255&(p[r[o]>>24&255]^s>>24),c[4*o+1]=255&(p[r[(o+3)%4]>>16&255]^s>>16),c[4*o+2]=255&(p[r[(o+2)%4]>>8&255]^s>>8),c[4*o+3]=255&(p[255&r[(o+1)%4]]^s);return c};var k=function(e){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new _(e)};k.prototype.encrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16)a(e,n,0,r,r+16),a(n=this._aes.encrypt(n),t,r);return t},k.prototype.decrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16)a(e,n,0,r,r+16),a(n=this._aes.decrypt(n),t,r);return t};var x=function(e,t){if(!(this instanceof x))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=i(16);this._lastCipherblock=o(t,!0),this._aes=new _(e)};x.prototype.encrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16){a(e,n,0,r,r+16);for(var s=0;s<16;s++)n[s]^=this._lastCipherblock[s];this._lastCipherblock=this._aes.encrypt(n),a(this._lastCipherblock,t,r)}return t},x.prototype.decrypt=function(e){if((e=o(e)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var t=i(e.length),n=i(16),r=0;r<e.length;r+=16){a(e,n,0,r,r+16),n=this._aes.decrypt(n);for(var s=0;s<16;s++)t[r+s]=n[s]^this._lastCipherblock[s];a(e,this._lastCipherblock,0,r,r+16)}return t};var P=function(e,t,n){if(!(this instanceof P))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 size)")}else t=i(16);n||(n=1),this.segmentSize=n,this._shiftRegister=o(t,!0),this._aes=new _(e)};P.prototype.encrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var t,n=o(e,!0),r=0;r<n.length;r+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var i=0;i<this.segmentSize;i++)n[r+i]^=t[i];a(this._shiftRegister,this._shiftRegister,0,this.segmentSize),a(n,this._shiftRegister,16-this.segmentSize,r,r+this.segmentSize)}return n},P.prototype.decrypt=function(e){if(e.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var t,n=o(e,!0),r=0;r<n.length;r+=this.segmentSize){t=this._aes.encrypt(this._shiftRegister);for(var i=0;i<this.segmentSize;i++)n[r+i]^=t[i];a(this._shiftRegister,this._shiftRegister,0,this.segmentSize),a(e,this._shiftRegister,16-this.segmentSize,r,r+this.segmentSize)}return n};var M=function(e,t){if(!(this instanceof M))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",t){if(16!=t.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else t=i(16);this._lastPrecipher=o(t,!0),this._lastPrecipherIndex=16,this._aes=new _(e)};M.prototype.encrypt=function(e){for(var t=o(e,!0),n=0;n<t.length;n++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),t[n]^=this._lastPrecipher[this._lastPrecipherIndex++];return t},M.prototype.decrypt=M.prototype.encrypt;var C=function(e){if(!(this instanceof C))throw Error("Counter must be instanitated with `new`");0===e||e||(e=1),"number"==typeof e?(this._counter=i(16),this.setValue(e)):this.setBytes(e)};C.prototype.setValue=function(e){if("number"!=typeof e||parseInt(e)!=e)throw new Error("invalid counter value (must be an integer)");if(e>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var t=15;t>=0;--t)this._counter[t]=e%256,e=parseInt(e/256)},C.prototype.setBytes=function(e){if(16!=(e=o(e,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=e},C.prototype.increment=function(){for(var e=15;e>=0;e--){if(255!==this._counter[e]){this._counter[e]++;break}this._counter[e]=0}};var N=function(e,t){if(!(this instanceof N))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",t instanceof C||(t=new C(t)),this._counter=t,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new _(e)};N.prototype.encrypt=function(e){for(var t=o(e,!0),n=0;n<t.length;n++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),t[n]^=this._remainingCounter[this._remainingCounterIndex++];return t},N.prototype.decrypt=N.prototype.encrypt;var j={AES:_,Counter:C,ModeOfOperation:{ecb:k,cbc:x,cfb:P,ofb:M,ctr:N},utils:{hex:u,utf8:c},padding:{pkcs7:{pad:function(e){var t=16-(e=o(e,!0)).length%16,n=i(e.length+t);a(e,n);for(var r=e.length;r<n.length;r++)n[r]=t;return n},strip:function(e){if((e=o(e,!0)).length<16)throw new Error("PKCS#7 invalid length");var t=e[e.length-1];if(t>16)throw new Error("PKCS#7 padding byte out of range");for(var n=e.length-t,r=0;r<t;r++)if(e[n+r]!==t)throw new Error("PKCS#7 invalid padding byte");var s=i(n);return a(e,s,0,0,n),s}}},_arrayTest:{coerceArray:o,createArray:i,copyArray:a}};e.exports=j}()},8162:function(e){"use strict";e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),n=0;n<t.length;n++)t[n]=255;for(var r=0;r<e.length;r++){var o=e.charAt(r),i=o.charCodeAt(0);if(255!==t[i])throw new TypeError(o+" is ambiguous");t[i]=r}var a=e.length,s=e.charAt(0),c=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;for(var n=0,r=0,o=0;e[n]===s;)r++,n++;for(var i=(e.length-n)*c+1>>>0,u=new Uint8Array(i);e[n];){var l=t[e.charCodeAt(n)];if(255===l)return;for(var d=0,f=i-1;(0!==l||d<o)&&-1!==f;f--,d++)l+=a*u[f]>>>0,u[f]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=d,n++}for(var p=i-o;p!==i&&0===u[p];)p++;for(var h=new Uint8Array(r+(i-p)),y=r;p!==i;)h[y++]=u[p++];return h}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var n=0,r=0,o=0,i=t.length;o!==i&&0===t[o];)o++,n++;for(var c=(i-o)*u+1>>>0,l=new Uint8Array(c);o!==i;){for(var d=t[o],f=0,p=c-1;(0!==d||f<r)&&-1!==p;p--,f++)d+=256*l[p]>>>0,l[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw new Error("Non-zero carry");r=f,o++}for(var h=c-r;h!==c&&0===l[h];)h++;for(var y=s.repeat(n);h<c;++h)y+=e.charAt(l[h]);return y},decodeUnsafe:l,decode:function(e){var t=l(e);if(t)return t;throw new Error("Non-base"+a+" character")}}}},7591:function(e,t,n){"use strict";var r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.log10=t.toFixed=t.toBns=t.round=t.ceil=t.floor=t.max=t.abs=t.min=t.eq=t.gte=t.gt=t.lte=t.lt=t.div=t.sub=t.mul=t.add=void 0;const o=r(n(3550)),i=/^(-?\d*\.?\d*)e((?:\+|-)?\d+)$/;function a(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.add(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")}function s(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.mul(l).toString(n);return f=d(f,2*a),10===n?f:f.replace(/^(-)?/,"$10x")}function c(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gt(c)}function u(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.gte(c)}function l(e){let t="number"==typeof e?e.toString():e.replace(/^\s+|\s+$/g,"");""!==t&&"."!==t||(t="0");const n=t.match(i);if(null!=n){t=function(e,t){const n=t>=0?"1"+"0".repeat(Math.abs(t)):`0.${"0".repeat(Math.abs(t)-1)}1`;return s(e,n)}(n[1],parseInt(n[2]))}return function(...e){for(const t of e){if(t.split(".").length-1>1)throw new Error(`Invalid number: more than one decimal point '${t}'`);if(t.split("-").length-1>1)throw new Error(`Invalid number: more than one negative sign '${t}'`);if(!/^-?(?:0x[0-9A-Fa-f]+|(?:\d+(?:\.\d*)?|\.\d+))$/.test(t))throw new Error(`Invalid number: non-number characters '${t}'`)}}(t),t}function d(e,t){if(0===t)return e;let n,r=!1;return"-"===e.slice(0,1)&&(r=!0,e=e.slice(1)),n=t>e.length?"0."+f("",t-e.length)+e:e.substr(0,e.length-t)+"."+e.substr(e.length-t,e.length),n=g(n),r&&(n=`-${n}`),n}function f(e,t){let n=e;for(let r=0;r<t;r++)n+="0";return n}function p(e){return e.replace("0x","")}function h(e,t,n){let r=l(e),o=l(t),i=r.indexOf("."),a=o.indexOf(".");const s=y(r),c=y(o);if(-1!==i&&(r=g(r),i=r.indexOf(".")),-1!==a&&(o=g(o),a=o.indexOf(".")),-1!==i||-1!==a||"number"==typeof n){if(s||c)throw new Error("Cannot operate on base16 float values");let e=0,t=0;-1!==i&&(e=r.length-i-1),-1!==a&&(t=o.length-a-1);const u=e>t?e:t;let l=0;"number"==typeof n&&(l=n),r=f(r.replace(".",""),u+l-e),o=f(o.replace(".",""),u-t);return{x:r,y:o,shift:u}}return{x:r,y:o,shift:0}}function y(e){const t=l(e);return!!(t.startsWith("0x")||t.startsWith("-0x")||t.toLowerCase().includes("a")||t.toLowerCase().includes("b")||t.toLowerCase().includes("c")||t.toLowerCase().includes("d")||t.toLowerCase().includes("e")||t.toLowerCase().includes("f"))}function b(e,t,n=0){var r,o;let i=l(t),s=!1,d="";i.includes("-")&&(s=!0,i=i.replace(/^-+/,""));const[f,p=""]=i.split("."),h=i.indexOf("."),y=-1!==h?h-n:i.length-n,b=f+p;if("round"===e){e=u(null!==(r=b[y])&&void 0!==r?r:"0","5")?"ceil":"floor"}const w=Math.max(b.length-y+1,0),v=new Array(w).join("0");let m=b.substring(0,y)+v;const I=c(b.substring(y),"0");if("ceil"===e&&I){const e="1"+v,t=(null!==(o=m.match(/^0+/))&&void 0!==o?o:[""])[0].length;m=new Array(t).join("0")+a(m,e)}const E=h+(m.length-b.length);return d=-1!==h?m.substring(0,E)+"."+m.substring(E):m,d=g(d),s&&"0"!==d&&(d="-"+d),d}function g(e){let t=e.replace(/^0+/,"");return t=t.replace(/^\.+/,"0."),t.includes(".")&&(t=t.replace(/0+$/,""),t=t.replace(/\.+$/,""),""===t&&(t="0")),""===t&&(t="0"),t}t.add=a,t.mul=s,t.sub=function(e,t,n=10){if(10!==n&&16!==n)throw new Error("Unsupported base");let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f=u.sub(l).toString(n);return f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.div=function(e,t,n=0,r=10){if(10!==r&&n>0)throw new Error("Cannot operate on floating point hex values");if(10!==r&&16!==r)throw new Error("Unsupported base");let{x:i,y:a}=h(e,t,n);const s=y(i)?16:10,c=y(a)?16:10;i=p(i),a=p(a);const u=new o.default(i,s),l=new o.default(a,c);let f=u.div(l).toString(r);return f=d(f,n),10===r?f:f.replace(/^(-)?/,"$10x")},t.lt=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lt(c)},t.lte=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.lte(c)},t.gt=c,t.gte=u,t.eq=function(e,t){let{x:n,y:r}=h(e,t);const i=y(n)?16:10,a=y(r)?16:10;n=p(n),r=p(r);const s=new o.default(n,i),c=new o.default(r,a);return s.eq(c)},t.min=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.lte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.abs=function(e,t=10){if(10!==t&&16!==t)throw new Error("Unsupported base");let{x:n,shift:r}=h(e,"0");const i=y(e)?16:10;n=p(n);let a=new o.default(n,i).abs().toString(t);return a=d(a,r),10===t?a:a.replace(/^(-)?/,"$10x")},t.max=function(e,t,n=10){let{x:r,y:i,shift:a}=h(e,t);const s=y(r)?16:10,c=y(i)?16:10;r=p(r),i=p(i);const u=new o.default(r,s),l=new o.default(i,c);let f;return f=u.gte(l)?u.toString(n):l.toString(n),f=d(f,a),10===n?f:f.replace(/^(-)?/,"$10x")},t.floor=(e,t)=>b("floor",e,t),t.ceil=(e,t)=>b("ceil",e,t),t.round=(e,t)=>b("round",e,t),t.toBns=l,t.toFixed=function(e,t=2,n=8){let r=l(e),o=!1,i="";r.includes("-")&&(o=!0,r=r.replace(/^-+/,"")),r=g(r);const a=r.indexOf(".");if(-1===a)i=r+"."+f("",t);else{const e=r.length-a-1;i=e>n?r.substr(0,r.length-(e-n)):e<t?r+f("",t-e):r}return i=i.replace(/\.+$/,""),o&&"0"!==i&&(i="-"+i),i},t.log10=function(e){if(null===e.match(/^[0-1]+$/g))throw new Error("InvalidLogInputValue: Must be a power of 10");if(!e.startsWith("1"))throw new Error("InvalidLogInputValue: Must not have leading zeros");if((e.match(/1/g)||[]).length>1)throw new Error("InvalidLogInputValue: Must be power of 10.");return(e.match(/0/g)||[]).length}},3550:function(e,t,n){!function(e,t){"use strict";function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function o(e,t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}function i(e,t,n){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(n=t,t=10),this._init(e||0,t||10,n||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(6601).Buffer}catch(A){}function s(e,t){var n=e.charCodeAt(t);return n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:n-48&15}function c(e,t,n){var r=s(e,n);return n-1>=t&&(r|=s(e,n-1)<<4),r}function u(e,t,n,r){for(var o=0,i=Math.min(e.length,n),a=t;a<i;a++){var s=e.charCodeAt(a)-48;o*=r,o+=s>=49?s-49+10:s>=17?s-17+10:s}return o}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var o=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(o++,this.negative=1),o<e.length&&(16===t?this._parseHex(e,o,n):(this._parseBase(e,t,o),"le"===n&&this._initArray(this.toArray(),t,n)))},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var o=0;o<this.length;o++)this.words[o]=0;var i,a,s=0;if("be"===n)for(o=e.length-1,i=0;o>=0;o-=3)a=e[o]|e[o-1]<<8|e[o-2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);else if("le"===n)for(o=0,i=0;o<e.length;o+=3)a=e[o]|e[o+1]<<8|e[o+2]<<16,this.words[i]|=a<<s&67108863,this.words[i+1]=a>>>26-s&67108863,(s+=24)>=26&&(s-=26,i++);return this.strip()},i.prototype._parseHex=function(e,t,n){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var o,i=0,a=0;if("be"===n)for(r=e.length-1;r>=t;r-=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;else for(r=(e.length-t)%2==0?t+1:t;r<e.length;r+=2)o=c(e,t,r)<<i,this.words[a]|=67108863&o,i>=18?(i-=18,a+=1,this.words[a]|=o>>>26):i+=8;this.strip()},i.prototype._parseBase=function(e,t,n){this.words=[0],this.length=1;for(var r=0,o=1;o<=67108863;o*=t)r++;r--,o=o/t|0;for(var i=e.length-n,a=i%r,s=Math.min(i,i-a)+n,c=0,l=n;l<s;l+=r)c=u(e,l,l+r,t),this.imuln(o),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==a){var d=1;for(c=u(e,l,e.length,t),l=0;l<a;l++)d*=t;this.imuln(d),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},i.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},i.prototype.clone=function(){var e=new i(null);return this.copy(e),e},i.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},i.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var l=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],d=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],f=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(e,t,n){n.negative=t.negative^e.negative;var r=e.length+t.length|0;n.length=r,r=r-1|0;var o=0|e.words[0],i=0|t.words[0],a=o*i,s=67108863&a,c=a/67108864|0;n.words[0]=s;for(var u=1;u<r;u++){for(var l=c>>>26,d=67108863&c,f=Math.min(u,t.length-1),p=Math.max(0,u-e.length+1);p<=f;p++){var h=u-p|0;l+=(a=(o=0|e.words[h])*(i=0|t.words[p])+d)/67108864|0,d=67108863&a}n.words[u]=0|d,c=0|l}return 0!==c?n.words[u]=0|c:n.length--,n.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var o=0,i=0,a=0;a<this.length;a++){var s=this.words[a],c=(16777215&(s<<o|i)).toString(16);n=0!==(i=s>>>24-o&16777215)||a!==this.length-1?l[6-c.length]+c+n:c+n,(o+=2)>=26&&(o-=26,a--)}for(0!==i&&(n=i.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var u=d[e],p=f[e];n="";var h=this.clone();for(h.negative=0;!h.isZero();){var y=h.modn(p).toString(e);n=(h=h.idivn(p)).isZero()?y+n:l[u-y.length]+y+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var o=this.byteLength(),i=n||Math.max(1,o);r(o<=i,"byte array longer than desired length"),r(i>0,"Requested array length <= 0"),this.strip();var a,s,c="le"===t,u=new e(i),l=this.clone();if(c){for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[s]=a;for(;s<i;s++)u[s]=0}else{for(s=0;s<i-o;s++)u[s]=0;for(s=0;!l.isZero();s++)a=l.andln(255),l.iushrn(8),u[i-s-1]=a}return u},Math.clz32?i.prototype._countBits=function(e){return 32-Math.clz32(e)}:i.prototype._countBits=function(e){var t=e,n=0;return t>=4096&&(n+=13,t>>>=13),t>=64&&(n+=7,t>>>=7),t>=8&&(n+=4,t>>>=4),t>=2&&(n+=2,t>>>=2),n+t},i.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,n=0;return 0==(8191&t)&&(n+=13,t>>>=13),0==(127&t)&&(n+=7,t>>>=7),0==(15&t)&&(n+=4,t>>>=4),0==(3&t)&&(n+=2,t>>>=2),0==(1&t)&&n++,n},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var n=this._zeroBits(this.words[t]);if(e+=n,26!==n)break}return e},i.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},i.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},i.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},i.prototype.isNeg=function(){return 0!==this.negative},i.prototype.neg=function(){return this.clone().ineg()},i.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},i.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},i.prototype.ior=function(e){return r(0==(this.negative|e.negative)),this.iuor(e)},i.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var n=0;n<t.length;n++)this.words[n]=this.words[n]&e.words[n];return this.length=t.length,this.strip()},i.prototype.iand=function(e){return r(0==(this.negative|e.negative)),this.iuand(e)},i.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,n;this.length>e.length?(t=this,n=e):(t=e,n=this);for(var r=0;r<n.length;r++)this.words[r]=t.words[r]^n.words[r];if(this!==t)for(;r<t.length;r++)this.words[r]=t.words[r];return this.length=t.length,this.strip()},i.prototype.ixor=function(e){return r(0==(this.negative|e.negative)),this.iuxor(e)},i.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var o=0;o<t;o++)this.words[o]=67108863&~this.words[o];return n>0&&(this.words[o]=~this.words[o]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,o=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<<o:this.words[n]&~(1<<o),this.strip()},i.prototype.iadd=function(e){var t,n,r;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(n=this,r=e):(n=e,r=this);for(var o=0,i=0;i<r.length;i++)t=(0|n.words[i])+(0|r.words[i])+o,this.words[i]=67108863&t,o=t>>>26;for(;0!==o&&i<n.length;i++)t=(0|n.words[i])+o,this.words[i]=67108863&t,o=t>>>26;if(this.length=n.length,0!==o)this.words[this.length]=o,this.length++;else if(n!==this)for(;i<n.length;i++)this.words[i]=n.words[i];return this},i.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var n,r,o=this.cmp(e);if(0===o)return this.negative=0,this.length=1,this.words[0]=0,this;o>0?(n=this,r=e):(n=e,r=this);for(var i=0,a=0;a<r.length;a++)i=(t=(0|n.words[a])-(0|r.words[a])+i)>>26,this.words[a]=67108863&t;for(;0!==i&&a<n.length;a++)i=(t=(0|n.words[a])+i)>>26,this.words[a]=67108863&t;if(0===i&&a<n.length&&n!==this)for(;a<n.length;a++)this.words[a]=n.words[a];return this.length=Math.max(this.length,a),n!==this&&(this.negative=1),this.strip()},i.prototype.sub=function(e){return this.clone().isub(e)};var h=function(e,t,n){var r,o,i,a=e.words,s=t.words,c=n.words,u=0,l=0|a[0],d=8191&l,f=l>>>13,p=0|a[1],h=8191&p,y=p>>>13,b=0|a[2],g=8191&b,w=b>>>13,v=0|a[3],m=8191&v,I=v>>>13,E=0|a[4],S=8191&E,O=E>>>13,A=0|a[5],T=8191&A,_=A>>>13,k=0|a[6],x=8191&k,P=k>>>13,M=0|a[7],C=8191&M,N=M>>>13,j=0|a[8],D=8191&j,R=j>>>13,L=0|a[9],B=8191&L,K=L>>>13,U=0|s[0],F=8191&U,W=U>>>13,q=0|s[1],z=8191&q,G=q>>>13,$=0|s[2],H=8191&$,Y=$>>>13,V=0|s[3],J=8191&V,X=V>>>13,Z=0|s[4],Q=8191&Z,ee=Z>>>13,te=0|s[5],ne=8191&te,re=te>>>13,oe=0|s[6],ie=8191&oe,ae=oe>>>13,se=0|s[7],ce=8191&se,ue=se>>>13,le=0|s[8],de=8191&le,fe=le>>>13,pe=0|s[9],he=8191&pe,ye=pe>>>13;n.negative=e.negative^t.negative,n.length=19;var be=(u+(r=Math.imul(d,F))|0)+((8191&(o=(o=Math.imul(d,W))+Math.imul(f,F)|0))<<13)|0;u=((i=Math.imul(f,W))+(o>>>13)|0)+(be>>>26)|0,be&=67108863,r=Math.imul(h,F),o=(o=Math.imul(h,W))+Math.imul(y,F)|0,i=Math.imul(y,W);var ge=(u+(r=r+Math.imul(d,z)|0)|0)+((8191&(o=(o=o+Math.imul(d,G)|0)+Math.imul(f,z)|0))<<13)|0;u=((i=i+Math.imul(f,G)|0)+(o>>>13)|0)+(ge>>>26)|0,ge&=67108863,r=Math.imul(g,F),o=(o=Math.imul(g,W))+Math.imul(w,F)|0,i=Math.imul(w,W),r=r+Math.imul(h,z)|0,o=(o=o+Math.imul(h,G)|0)+Math.imul(y,z)|0,i=i+Math.imul(y,G)|0;var we=(u+(r=r+Math.imul(d,H)|0)|0)+((8191&(o=(o=o+Math.imul(d,Y)|0)+Math.imul(f,H)|0))<<13)|0;u=((i=i+Math.imul(f,Y)|0)+(o>>>13)|0)+(we>>>26)|0,we&=67108863,r=Math.imul(m,F),o=(o=Math.imul(m,W))+Math.imul(I,F)|0,i=Math.imul(I,W),r=r+Math.imul(g,z)|0,o=(o=o+Math.imul(g,G)|0)+Math.imul(w,z)|0,i=i+Math.imul(w,G)|0,r=r+Math.imul(h,H)|0,o=(o=o+Math.imul(h,Y)|0)+Math.imul(y,H)|0,i=i+Math.imul(y,Y)|0;var ve=(u+(r=r+Math.imul(d,J)|0)|0)+((8191&(o=(o=o+Math.imul(d,X)|0)+Math.imul(f,J)|0))<<13)|0;u=((i=i+Math.imul(f,X)|0)+(o>>>13)|0)+(ve>>>26)|0,ve&=67108863,r=Math.imul(S,F),o=(o=Math.imul(S,W))+Math.imul(O,F)|0,i=Math.imul(O,W),r=r+Math.imul(m,z)|0,o=(o=o+Math.imul(m,G)|0)+Math.imul(I,z)|0,i=i+Math.imul(I,G)|0,r=r+Math.imul(g,H)|0,o=(o=o+Math.imul(g,Y)|0)+Math.imul(w,H)|0,i=i+Math.imul(w,Y)|0,r=r+Math.imul(h,J)|0,o=(o=o+Math.imul(h,X)|0)+Math.imul(y,J)|0,i=i+Math.imul(y,X)|0;var me=(u+(r=r+Math.imul(d,Q)|0)|0)+((8191&(o=(o=o+Math.imul(d,ee)|0)+Math.imul(f,Q)|0))<<13)|0;u=((i=i+Math.imul(f,ee)|0)+(o>>>13)|0)+(me>>>26)|0,me&=67108863,r=Math.imul(T,F),o=(o=Math.imul(T,W))+Math.imul(_,F)|0,i=Math.imul(_,W),r=r+Math.imul(S,z)|0,o=(o=o+Math.imul(S,G)|0)+Math.imul(O,z)|0,i=i+Math.imul(O,G)|0,r=r+Math.imul(m,H)|0,o=(o=o+Math.imul(m,Y)|0)+Math.imul(I,H)|0,i=i+Math.imul(I,Y)|0,r=r+Math.imul(g,J)|0,o=(o=o+Math.imul(g,X)|0)+Math.imul(w,J)|0,i=i+Math.imul(w,X)|0,r=r+Math.imul(h,Q)|0,o=(o=o+Math.imul(h,ee)|0)+Math.imul(y,Q)|0,i=i+Math.imul(y,ee)|0;var Ie=(u+(r=r+Math.imul(d,ne)|0)|0)+((8191&(o=(o=o+Math.imul(d,re)|0)+Math.imul(f,ne)|0))<<13)|0;u=((i=i+Math.imul(f,re)|0)+(o>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,r=Math.imul(x,F),o=(o=Math.imul(x,W))+Math.imul(P,F)|0,i=Math.imul(P,W),r=r+Math.imul(T,z)|0,o=(o=o+Math.imul(T,G)|0)+Math.imul(_,z)|0,i=i+Math.imul(_,G)|0,r=r+Math.imul(S,H)|0,o=(o=o+Math.imul(S,Y)|0)+Math.imul(O,H)|0,i=i+Math.imul(O,Y)|0,r=r+Math.imul(m,J)|0,o=(o=o+Math.imul(m,X)|0)+Math.imul(I,J)|0,i=i+Math.imul(I,X)|0,r=r+Math.imul(g,Q)|0,o=(o=o+Math.imul(g,ee)|0)+Math.imul(w,Q)|0,i=i+Math.imul(w,ee)|0,r=r+Math.imul(h,ne)|0,o=(o=o+Math.imul(h,re)|0)+Math.imul(y,ne)|0,i=i+Math.imul(y,re)|0;var Ee=(u+(r=r+Math.imul(d,ie)|0)|0)+((8191&(o=(o=o+Math.imul(d,ae)|0)+Math.imul(f,ie)|0))<<13)|0;u=((i=i+Math.imul(f,ae)|0)+(o>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,r=Math.imul(C,F),o=(o=Math.imul(C,W))+Math.imul(N,F)|0,i=Math.imul(N,W),r=r+Math.imul(x,z)|0,o=(o=o+Math.imul(x,G)|0)+Math.imul(P,z)|0,i=i+Math.imul(P,G)|0,r=r+Math.imul(T,H)|0,o=(o=o+Math.imul(T,Y)|0)+Math.imul(_,H)|0,i=i+Math.imul(_,Y)|0,r=r+Math.imul(S,J)|0,o=(o=o+Math.imul(S,X)|0)+Math.imul(O,J)|0,i=i+Math.imul(O,X)|0,r=r+Math.imul(m,Q)|0,o=(o=o+Math.imul(m,ee)|0)+Math.imul(I,Q)|0,i=i+Math.imul(I,ee)|0,r=r+Math.imul(g,ne)|0,o=(o=o+Math.imul(g,re)|0)+Math.imul(w,ne)|0,i=i+Math.imul(w,re)|0,r=r+Math.imul(h,ie)|0,o=(o=o+Math.imul(h,ae)|0)+Math.imul(y,ie)|0,i=i+Math.imul(y,ae)|0;var Se=(u+(r=r+Math.imul(d,ce)|0)|0)+((8191&(o=(o=o+Math.imul(d,ue)|0)+Math.imul(f,ce)|0))<<13)|0;u=((i=i+Math.imul(f,ue)|0)+(o>>>13)|0)+(Se>>>26)|0,Se&=67108863,r=Math.imul(D,F),o=(o=Math.imul(D,W))+Math.imul(R,F)|0,i=Math.imul(R,W),r=r+Math.imul(C,z)|0,o=(o=o+Math.imul(C,G)|0)+Math.imul(N,z)|0,i=i+Math.imul(N,G)|0,r=r+Math.imul(x,H)|0,o=(o=o+Math.imul(x,Y)|0)+Math.imul(P,H)|0,i=i+Math.imul(P,Y)|0,r=r+Math.imul(T,J)|0,o=(o=o+Math.imul(T,X)|0)+Math.imul(_,J)|0,i=i+Math.imul(_,X)|0,r=r+Math.imul(S,Q)|0,o=(o=o+Math.imul(S,ee)|0)+Math.imul(O,Q)|0,i=i+Math.imul(O,ee)|0,r=r+Math.imul(m,ne)|0,o=(o=o+Math.imul(m,re)|0)+Math.imul(I,ne)|0,i=i+Math.imul(I,re)|0,r=r+Math.imul(g,ie)|0,o=(o=o+Math.imul(g,ae)|0)+Math.imul(w,ie)|0,i=i+Math.imul(w,ae)|0,r=r+Math.imul(h,ce)|0,o=(o=o+Math.imul(h,ue)|0)+Math.imul(y,ce)|0,i=i+Math.imul(y,ue)|0;var Oe=(u+(r=r+Math.imul(d,de)|0)|0)+((8191&(o=(o=o+Math.imul(d,fe)|0)+Math.imul(f,de)|0))<<13)|0;u=((i=i+Math.imul(f,fe)|0)+(o>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,r=Math.imul(B,F),o=(o=Math.imul(B,W))+Math.imul(K,F)|0,i=Math.imul(K,W),r=r+Math.imul(D,z)|0,o=(o=o+Math.imul(D,G)|0)+Math.imul(R,z)|0,i=i+Math.imul(R,G)|0,r=r+Math.imul(C,H)|0,o=(o=o+Math.imul(C,Y)|0)+Math.imul(N,H)|0,i=i+Math.imul(N,Y)|0,r=r+Math.imul(x,J)|0,o=(o=o+Math.imul(x,X)|0)+Math.imul(P,J)|0,i=i+Math.imul(P,X)|0,r=r+Math.imul(T,Q)|0,o=(o=o+Math.imul(T,ee)|0)+Math.imul(_,Q)|0,i=i+Math.imul(_,ee)|0,r=r+Math.imul(S,ne)|0,o=(o=o+Math.imul(S,re)|0)+Math.imul(O,ne)|0,i=i+Math.imul(O,re)|0,r=r+Math.imul(m,ie)|0,o=(o=o+Math.imul(m,ae)|0)+Math.imul(I,ie)|0,i=i+Math.imul(I,ae)|0,r=r+Math.imul(g,ce)|0,o=(o=o+Math.imul(g,ue)|0)+Math.imul(w,ce)|0,i=i+Math.imul(w,ue)|0,r=r+Math.imul(h,de)|0,o=(o=o+Math.imul(h,fe)|0)+Math.imul(y,de)|0,i=i+Math.imul(y,fe)|0;var Ae=(u+(r=r+Math.imul(d,he)|0)|0)+((8191&(o=(o=o+Math.imul(d,ye)|0)+Math.imul(f,he)|0))<<13)|0;u=((i=i+Math.imul(f,ye)|0)+(o>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,r=Math.imul(B,z),o=(o=Math.imul(B,G))+Math.imul(K,z)|0,i=Math.imul(K,G),r=r+Math.imul(D,H)|0,o=(o=o+Math.imul(D,Y)|0)+Math.imul(R,H)|0,i=i+Math.imul(R,Y)|0,r=r+Math.imul(C,J)|0,o=(o=o+Math.imul(C,X)|0)+Math.imul(N,J)|0,i=i+Math.imul(N,X)|0,r=r+Math.imul(x,Q)|0,o=(o=o+Math.imul(x,ee)|0)+Math.imul(P,Q)|0,i=i+Math.imul(P,ee)|0,r=r+Math.imul(T,ne)|0,o=(o=o+Math.imul(T,re)|0)+Math.imul(_,ne)|0,i=i+Math.imul(_,re)|0,r=r+Math.imul(S,ie)|0,o=(o=o+Math.imul(S,ae)|0)+Math.imul(O,ie)|0,i=i+Math.imul(O,ae)|0,r=r+Math.imul(m,ce)|0,o=(o=o+Math.imul(m,ue)|0)+Math.imul(I,ce)|0,i=i+Math.imul(I,ue)|0,r=r+Math.imul(g,de)|0,o=(o=o+Math.imul(g,fe)|0)+Math.imul(w,de)|0,i=i+Math.imul(w,fe)|0;var Te=(u+(r=r+Math.imul(h,he)|0)|0)+((8191&(o=(o=o+Math.imul(h,ye)|0)+Math.imul(y,he)|0))<<13)|0;u=((i=i+Math.imul(y,ye)|0)+(o>>>13)|0)+(Te>>>26)|0,Te&=67108863,r=Math.imul(B,H),o=(o=Math.imul(B,Y))+Math.imul(K,H)|0,i=Math.imul(K,Y),r=r+Math.imul(D,J)|0,o=(o=o+Math.imul(D,X)|0)+Math.imul(R,J)|0,i=i+Math.imul(R,X)|0,r=r+Math.imul(C,Q)|0,o=(o=o+Math.imul(C,ee)|0)+Math.imul(N,Q)|0,i=i+Math.imul(N,ee)|0,r=r+Math.imul(x,ne)|0,o=(o=o+Math.imul(x,re)|0)+Math.imul(P,ne)|0,i=i+Math.imul(P,re)|0,r=r+Math.imul(T,ie)|0,o=(o=o+Math.imul(T,ae)|0)+Math.imul(_,ie)|0,i=i+Math.imul(_,ae)|0,r=r+Math.imul(S,ce)|0,o=(o=o+Math.imul(S,ue)|0)+Math.imul(O,ce)|0,i=i+Math.imul(O,ue)|0,r=r+Math.imul(m,de)|0,o=(o=o+Math.imul(m,fe)|0)+Math.imul(I,de)|0,i=i+Math.imul(I,fe)|0;var _e=(u+(r=r+Math.imul(g,he)|0)|0)+((8191&(o=(o=o+Math.imul(g,ye)|0)+Math.imul(w,he)|0))<<13)|0;u=((i=i+Math.imul(w,ye)|0)+(o>>>13)|0)+(_e>>>26)|0,_e&=67108863,r=Math.imul(B,J),o=(o=Math.imul(B,X))+Math.imul(K,J)|0,i=Math.imul(K,X),r=r+Math.imul(D,Q)|0,o=(o=o+Math.imul(D,ee)|0)+Math.imul(R,Q)|0,i=i+Math.imul(R,ee)|0,r=r+Math.imul(C,ne)|0,o=(o=o+Math.imul(C,re)|0)+Math.imul(N,ne)|0,i=i+Math.imul(N,re)|0,r=r+Math.imul(x,ie)|0,o=(o=o+Math.imul(x,ae)|0)+Math.imul(P,ie)|0,i=i+Math.imul(P,ae)|0,r=r+Math.imul(T,ce)|0,o=(o=o+Math.imul(T,ue)|0)+Math.imul(_,ce)|0,i=i+Math.imul(_,ue)|0,r=r+Math.imul(S,de)|0,o=(o=o+Math.imul(S,fe)|0)+Math.imul(O,de)|0,i=i+Math.imul(O,fe)|0;var ke=(u+(r=r+Math.imul(m,he)|0)|0)+((8191&(o=(o=o+Math.imul(m,ye)|0)+Math.imul(I,he)|0))<<13)|0;u=((i=i+Math.imul(I,ye)|0)+(o>>>13)|0)+(ke>>>26)|0,ke&=67108863,r=Math.imul(B,Q),o=(o=Math.imul(B,ee))+Math.imul(K,Q)|0,i=Math.imul(K,ee),r=r+Math.imul(D,ne)|0,o=(o=o+Math.imul(D,re)|0)+Math.imul(R,ne)|0,i=i+Math.imul(R,re)|0,r=r+Math.imul(C,ie)|0,o=(o=o+Math.imul(C,ae)|0)+Math.imul(N,ie)|0,i=i+Math.imul(N,ae)|0,r=r+Math.imul(x,ce)|0,o=(o=o+Math.imul(x,ue)|0)+Math.imul(P,ce)|0,i=i+Math.imul(P,ue)|0,r=r+Math.imul(T,de)|0,o=(o=o+Math.imul(T,fe)|0)+Math.imul(_,de)|0,i=i+Math.imul(_,fe)|0;var xe=(u+(r=r+Math.imul(S,he)|0)|0)+((8191&(o=(o=o+Math.imul(S,ye)|0)+Math.imul(O,he)|0))<<13)|0;u=((i=i+Math.imul(O,ye)|0)+(o>>>13)|0)+(xe>>>26)|0,xe&=67108863,r=Math.imul(B,ne),o=(o=Math.imul(B,re))+Math.imul(K,ne)|0,i=Math.imul(K,re),r=r+Math.imul(D,ie)|0,o=(o=o+Math.imul(D,ae)|0)+Math.imul(R,ie)|0,i=i+Math.imul(R,ae)|0,r=r+Math.imul(C,ce)|0,o=(o=o+Math.imul(C,ue)|0)+Math.imul(N,ce)|0,i=i+Math.imul(N,ue)|0,r=r+Math.imul(x,de)|0,o=(o=o+Math.imul(x,fe)|0)+Math.imul(P,de)|0,i=i+Math.imul(P,fe)|0;var Pe=(u+(r=r+Math.imul(T,he)|0)|0)+((8191&(o=(o=o+Math.imul(T,ye)|0)+Math.imul(_,he)|0))<<13)|0;u=((i=i+Math.imul(_,ye)|0)+(o>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,r=Math.imul(B,ie),o=(o=Math.imul(B,ae))+Math.imul(K,ie)|0,i=Math.imul(K,ae),r=r+Math.imul(D,ce)|0,o=(o=o+Math.imul(D,ue)|0)+Math.imul(R,ce)|0,i=i+Math.imul(R,ue)|0,r=r+Math.imul(C,de)|0,o=(o=o+Math.imul(C,fe)|0)+Math.imul(N,de)|0,i=i+Math.imul(N,fe)|0;var Me=(u+(r=r+Math.imul(x,he)|0)|0)+((8191&(o=(o=o+Math.imul(x,ye)|0)+Math.imul(P,he)|0))<<13)|0;u=((i=i+Math.imul(P,ye)|0)+(o>>>13)|0)+(Me>>>26)|0,Me&=67108863,r=Math.imul(B,ce),o=(o=Math.imul(B,ue))+Math.imul(K,ce)|0,i=Math.imul(K,ue),r=r+Math.imul(D,de)|0,o=(o=o+Math.imul(D,fe)|0)+Math.imul(R,de)|0,i=i+Math.imul(R,fe)|0;var Ce=(u+(r=r+Math.imul(C,he)|0)|0)+((8191&(o=(o=o+Math.imul(C,ye)|0)+Math.imul(N,he)|0))<<13)|0;u=((i=i+Math.imul(N,ye)|0)+(o>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,r=Math.imul(B,de),o=(o=Math.imul(B,fe))+Math.imul(K,de)|0,i=Math.imul(K,fe);var Ne=(u+(r=r+Math.imul(D,he)|0)|0)+((8191&(o=(o=o+Math.imul(D,ye)|0)+Math.imul(R,he)|0))<<13)|0;u=((i=i+Math.imul(R,ye)|0)+(o>>>13)|0)+(Ne>>>26)|0,Ne&=67108863;var je=(u+(r=Math.imul(B,he))|0)+((8191&(o=(o=Math.imul(B,ye))+Math.imul(K,he)|0))<<13)|0;return u=((i=Math.imul(K,ye))+(o>>>13)|0)+(je>>>26)|0,je&=67108863,c[0]=be,c[1]=ge,c[2]=we,c[3]=ve,c[4]=me,c[5]=Ie,c[6]=Ee,c[7]=Se,c[8]=Oe,c[9]=Ae,c[10]=Te,c[11]=_e,c[12]=ke,c[13]=xe,c[14]=Pe,c[15]=Me,c[16]=Ce,c[17]=Ne,c[18]=je,0!==u&&(c[19]=u,n.length++),n};function y(e,t,n){return(new b).mulp(e,t,n)}function b(e,t){this.x=e,this.y=t}Math.imul||(h=p),i.prototype.mulTo=function(e,t){var n,r=this.length+e.length;return n=10===this.length&&10===e.length?h(this,e,t):r<63?p(this,e,t):r<1024?function(e,t,n){n.negative=t.negative^e.negative,n.length=e.length+t.length;for(var r=0,o=0,i=0;i<n.length-1;i++){var a=o;o=0;for(var s=67108863&r,c=Math.min(i,t.length-1),u=Math.max(0,i-e.length+1);u<=c;u++){var l=i-u,d=(0|e.words[l])*(0|t.words[u]),f=67108863&d;s=67108863&(f=f+s|0),o+=(a=(a=a+(d/67108864|0)|0)+(f>>>26)|0)>>>26,a&=67108863}n.words[i]=s,r=a,a=o}return 0!==r?n.words[i]=r:n.length--,n.strip()}(this,e,t):y(this,e,t),n},b.prototype.makeRBT=function(e){for(var t=new Array(e),n=i.prototype._countBits(e)-1,r=0;r<e;r++)t[r]=this.revBin(r,n,e);return t},b.prototype.revBin=function(e,t,n){if(0===e||e===n-1)return e;for(var r=0,o=0;o<t;o++)r|=(1&e)<<t-o-1,e>>=1;return r},b.prototype.permute=function(e,t,n,r,o,i){for(var a=0;a<i;a++)r[a]=t[e[a]],o[a]=n[e[a]]},b.prototype.transform=function(e,t,n,r,o,i){this.permute(i,e,t,n,r,o);for(var a=1;a<o;a<<=1)for(var s=a<<1,c=Math.cos(2*Math.PI/s),u=Math.sin(2*Math.PI/s),l=0;l<o;l+=s)for(var d=c,f=u,p=0;p<a;p++){var h=n[l+p],y=r[l+p],b=n[l+p+a],g=r[l+p+a],w=d*b-f*g;g=d*g+f*b,b=w,n[l+p]=h+b,r[l+p]=y+g,n[l+p+a]=h-b,r[l+p+a]=y-g,p!==s&&(w=c*d-u*f,f=c*f+u*d,d=w)}},b.prototype.guessLen13b=function(e,t){var n=1|Math.max(t,e),r=1&n,o=0;for(n=n/2|0;n;n>>>=1)o++;return 1<<o+1+r},b.prototype.conjugate=function(e,t,n){if(!(n<=1))for(var r=0;r<n/2;r++){var o=e[r];e[r]=e[n-r-1],e[n-r-1]=o,o=t[r],t[r]=-t[n-r-1],t[n-r-1]=-o}},b.prototype.normalize13b=function(e,t){for(var n=0,r=0;r<t/2;r++){var o=8192*Math.round(e[2*r+1]/t)+Math.round(e[2*r]/t)+n;e[r]=67108863&o,n=o<67108864?0:o/67108864|0}return e},b.prototype.convert13b=function(e,t,n,o){for(var i=0,a=0;a<t;a++)i+=0|e[a],n[2*a]=8191&i,i>>>=13,n[2*a+1]=8191&i,i>>>=13;for(a=2*t;a<o;++a)n[a]=0;r(0===i),r(0==(-8192&i))},b.prototype.stub=function(e){for(var t=new Array(e),n=0;n<e;n++)t[n]=0;return t},b.prototype.mulp=function(e,t,n){var r=2*this.guessLen13b(e.length,t.length),o=this.makeRBT(r),i=this.stub(r),a=new Array(r),s=new Array(r),c=new Array(r),u=new Array(r),l=new Array(r),d=new Array(r),f=n.words;f.length=r,this.convert13b(e.words,e.length,a,r),this.convert13b(t.words,t.length,u,r),this.transform(a,i,s,c,r,o),this.transform(u,i,l,d,r,o);for(var p=0;p<r;p++){var h=s[p]*l[p]-c[p]*d[p];c[p]=s[p]*d[p]+c[p]*l[p],s[p]=h}return this.conjugate(s,c,r),this.transform(s,c,f,i,r,o),this.conjugate(f,i,r),this.normalize13b(f,r),n.negative=e.negative^t.negative,n.length=e.length+t.length,n.strip()},i.prototype.mul=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},i.prototype.mulf=function(e){var t=new i(null);return t.words=new Array(this.length+e.length),y(this,e,t)},i.prototype.imul=function(e){return this.clone().mulTo(e,this)},i.prototype.imuln=function(e){r("number"==typeof e),r(e<67108864);for(var t=0,n=0;n<this.length;n++){var o=(0|this.words[n])*e,i=(67108863&o)+(67108863&t);t>>=26,t+=o/67108864|0,t+=i>>>26,this.words[n]=67108863&i}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),n=0;n<t.length;n++){var r=n/26|0,o=n%26;t[n]=(e.words[r]&1<<o)>>>o}return t}(e);if(0===t.length)return new i(1);for(var n=this,r=0;r<t.length&&0===t[r];r++,n=n.sqr());if(++r<t.length)for(var o=n.sqr();r<t.length;r++,o=o.sqr())0!==t[r]&&(n=n.mul(o));return n},i.prototype.iushln=function(e){r("number"==typeof e&&e>=0);var t,n=e%26,o=(e-n)/26,i=67108863>>>26-n<<26-n;if(0!==n){var a=0;for(t=0;t<this.length;t++){var s=this.words[t]&i,c=(0|this.words[t])-s<<n;this.words[t]=c|a,a=s>>>26-n}a&&(this.words[t]=a,this.length++)}if(0!==o){for(t=this.length-1;t>=0;t--)this.words[t+o]=this.words[t];for(t=0;t<o;t++)this.words[t]=0;this.length+=o}return this.strip()},i.prototype.ishln=function(e){return r(0===this.negative),this.iushln(e)},i.prototype.iushrn=function(e,t,n){var o;r("number"==typeof e&&e>=0),o=t?(t-t%26)/26:0;var i=e%26,a=Math.min((e-i)/26,this.length),s=67108863^67108863>>>i<<i,c=n;if(o-=a,o=Math.max(0,o),c){for(var u=0;u<a;u++)c.words[u]=this.words[u];c.length=a}if(0===a);else if(this.length>a)for(this.length-=a,u=0;u<this.length;u++)this.words[u]=this.words[u+a];else this.words[0]=0,this.length=1;var l=0;for(u=this.length-1;u>=0&&(0!==l||u>=o);u--){var d=0|this.words[u];this.words[u]=l<<26-i|d>>>i,l=d&s}return c&&0!==l&&(c.words[c.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,o=1<<t;return!(this.length<=n)&&!!(this.words[n]&o)},i.prototype.imaskn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var o=67108863^67108863>>>t<<t;this.words[this.length-1]&=o}return this.strip()},i.prototype.maskn=function(e){return this.clone().imaskn(e)},i.prototype.iaddn=function(e){return r("number"==typeof e),r(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},i.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},i.prototype.addn=function(e){return this.clone().iaddn(e)},i.prototype.subn=function(e){return this.clone().isubn(e)},i.prototype.iabs=function(){return this.negative=0,this},i.prototype.abs=function(){return this.clone().iabs()},i.prototype._ishlnsubmul=function(e,t,n){var o,i,a=e.length+n;this._expand(a);var s=0;for(o=0;o<e.length;o++){i=(0|this.words[o+n])+s;var c=(0|e.words[o])*t;s=((i-=67108863&c)>>26)-(c/67108864|0),this.words[o+n]=67108863&i}for(;o<this.length-n;o++)s=(i=(0|this.words[o+n])+s)>>26,this.words[o+n]=67108863&i;if(0===s)return this.strip();for(r(-1===s),s=0,o=0;o<this.length;o++)s=(i=-(0|this.words[o])+s)>>26,this.words[o]=67108863&i;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var n=(this.length,e.length),r=this.clone(),o=e,a=0|o.words[o.length-1];0!==(n=26-this._countBits(a))&&(o=o.ushln(n),r.iushln(n),a=0|o.words[o.length-1]);var s,c=r.length-o.length;if("mod"!==t){(s=new i(null)).length=c+1,s.words=new Array(s.length);for(var u=0;u<s.length;u++)s.words[u]=0}var l=r.clone()._ishlnsubmul(o,1,c);0===l.negative&&(r=l,s&&(s.words[c]=1));for(var d=c-1;d>=0;d--){var f=67108864*(0|r.words[o.length+d])+(0|r.words[o.length+d-1]);for(f=Math.min(f/a|0,67108863),r._ishlnsubmul(o,f,d);0!==r.negative;)f--,r.negative=0,r._ishlnsubmul(o,1,d),r.isZero()||(r.negative^=1);s&&(s.words[d]=f)}return s&&s.strip(),r.strip(),"div"!==t&&0!==n&&r.iushrn(n),{div:s||null,mod:r}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(o=s.div.neg()),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.iadd(e)),{div:o,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(o=s.div.neg()),{div:o,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),n&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var o,a,s},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var n=0!==t.div.negative?t.mod.isub(e):t.mod,r=e.ushrn(1),o=e.andln(1),i=n.cmp(r);return i<0||1===o&&0===i?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,o=this.length-1;o>=0;o--)n=(t*n+(0|this.words[o]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var o=(0|this.words[n])+67108864*t;this.words[n]=o/e|0,t=o%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o=new i(1),a=new i(0),s=new i(0),c=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var l=n.clone(),d=t.clone();!t.isZero();){for(var f=0,p=1;0==(t.words[0]&p)&&f<26;++f,p<<=1);if(f>0)for(t.iushrn(f);f-- >0;)(o.isOdd()||a.isOdd())&&(o.iadd(l),a.isub(d)),o.iushrn(1),a.iushrn(1);for(var h=0,y=1;0==(n.words[0]&y)&&h<26;++h,y<<=1);if(h>0)for(n.iushrn(h);h-- >0;)(s.isOdd()||c.isOdd())&&(s.iadd(l),c.isub(d)),s.iushrn(1),c.iushrn(1);t.cmp(n)>=0?(t.isub(n),o.isub(s),a.isub(c)):(n.isub(t),s.isub(o),c.isub(a))}return{a:s,b:c,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var o,a=new i(1),s=new i(0),c=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,l=1;0==(t.words[0]&l)&&u<26;++u,l<<=1);if(u>0)for(t.iushrn(u);u-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);for(var d=0,f=1;0==(n.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(n.iushrn(d);d-- >0;)s.isOdd()&&s.iadd(c),s.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(s)):(n.isub(t),s.isub(a))}return(o=0===t.cmpn(1)?a:s).cmpn(0)<0&&o.iadd(e),o},i.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),n=e.clone();t.negative=0,n.negative=0;for(var r=0;t.isEven()&&n.isEven();r++)t.iushrn(1),n.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;n.isEven();)n.iushrn(1);var o=t.cmp(n);if(o<0){var i=t;t=n,n=i}else if(0===o||0===n.cmpn(1))break;t.isub(n)}return n.iushln(r)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,o=1<<t;if(this.length<=n)return this._expand(n+1),this.words[n]|=o,this;for(var i=o,a=n;0!==i&&a<this.length;a++){var s=0|this.words[a];i=(s+=i)>>>26,s&=67108863,this.words[a]=s}return 0!==i&&(this.words[a]=i,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var o=0|this.words[0];t=o===e?0:o<e?-1:1}return 0!==this.negative?0|-t:t},i.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},i.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,n=this.length-1;n>=0;n--){var r=0|this.words[n],o=0|e.words[n];if(r!==o){r<o?t=-1:r>o&&(t=1);break}}return t},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new S(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function w(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function v(){w.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function m(){w.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){w.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){w.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function S(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function O(e){S.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}w.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},w.prototype.ireduce=function(e){var t,n=e;do{this.split(n,this.tmp),t=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(t>this.n);var r=t<this.n?-1:n.ucmp(this.p);return 0===r?(n.words[0]=0,n.length=1):r>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},w.prototype.split=function(e,t){e.iushrn(this.n,0,t)},w.prototype.imulK=function(e){return e.imul(this.k)},o(v,w),v.prototype.split=function(e,t){for(var n=4194303,r=Math.min(e.length,9),o=0;o<r;o++)t.words[o]=e.words[o];if(t.length=r,e.length<=9)return e.words[0]=0,void(e.length=1);var i=e.words[9];for(t.words[t.length++]=i&n,o=10;o<e.length;o++){var a=0|e.words[o];e.words[o-10]=(a&n)<<4|i>>>22,i=a}i>>>=22,e.words[o-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},v.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,n=0;n<e.length;n++){var r=0|e.words[n];t+=977*r,e.words[n]=67108863&t,t=64*r+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},o(m,w),o(I,w),o(E,w),E.prototype.imulK=function(e){for(var t=0,n=0;n<e.length;n++){var r=19*(0|e.words[n])+t,o=67108863&r;r>>>=26,e.words[n]=o,t=r}return 0!==t&&(e.words[e.length++]=t),e},i._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new v;else if("p224"===e)t=new m;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return g[e]=t,t},S.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},S.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},S.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},S.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},S.prototype.add=function(e,t){this._verify2(e,t);var n=e.add(t);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},S.prototype.iadd=function(e,t){this._verify2(e,t);var n=e.iadd(t);return n.cmp(this.m)>=0&&n.isub(this.m),n},S.prototype.sub=function(e,t){this._verify2(e,t);var n=e.sub(t);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},S.prototype.isub=function(e,t){this._verify2(e,t);var n=e.isub(t);return n.cmpn(0)<0&&n.iadd(this.m),n},S.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},S.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},S.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},S.prototype.isqr=function(e){return this.imul(e,e.clone())},S.prototype.sqr=function(e){return this.mul(e,e)},S.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var o=this.m.subn(1),a=0;!o.isZero()&&0===o.andln(1);)a++,o.iushrn(1);r(!o.isZero());var s=new i(1).toRed(this),c=s.redNeg(),u=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new i(2*l*l).toRed(this);0!==this.pow(l,u).cmp(c);)l.redIAdd(c);for(var d=this.pow(l,o),f=this.pow(e,o.addn(1).iushrn(1)),p=this.pow(e,o),h=a;0!==p.cmp(s);){for(var y=p,b=0;0!==y.cmp(s);b++)y=y.redSqr();r(b<h);var g=this.pow(d,new i(1).iushln(h-b-1));f=f.redMul(g),d=g.redSqr(),p=p.redMul(d),h=b}return f},S.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},S.prototype.pow=function(e,t){if(t.isZero())return new i(1).toRed(this);if(0===t.cmpn(1))return e.clone();var n=new Array(16);n[0]=new i(1).toRed(this),n[1]=e;for(var r=2;r<n.length;r++)n[r]=this.mul(n[r-1],e);var o=n[0],a=0,s=0,c=t.bitLength()%26;for(0===c&&(c=26),r=t.length-1;r>=0;r--){for(var u=t.words[r],l=c-1;l>=0;l--){var d=u>>l&1;o!==n[0]&&(o=this.sqr(o)),0!==d||0!==a?(a<<=1,a|=d,(4===++s||0===r&&0===l)&&(o=this.mul(o,n[a]),s=0,a=0)):s=0}c=26}return o},S.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},S.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new O(e)},o(O,S),O.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},O.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},O.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var n=e.imul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),i=o;return o.cmp(this.m)>=0?i=o.isub(this.m):o.cmpn(0)<0&&(i=o.iadd(this.m)),i._forceRed(this)},O.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var n=e.mul(t),r=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),o=n.isub(r).iushrn(this.shift),a=o;return o.cmp(this.m)>=0?a=o.isub(this.m):o.cmpn(0)<0&&(a=o.iadd(this.m)),a._forceRed(this)},O.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=n.nmd(e),this)},9931:function(e,t,n){var r;function o(e){this.rand=e}if(e.exports=function(e){return r||(r=new o(null)),r.generate(e)},e.exports.Rand=o,o.prototype.generate=function(e){return this._rand(e)},o.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),n=0;n<t.length;n++)t[n]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?o.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(o.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var i=n(9214);if("function"!=typeof i.randomBytes)throw new Error("Not supported");o.prototype._rand=function(e){return i.randomBytes(e)}}catch(a){}},7445:function(e,t){"use strict";function n(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function r(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function o(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){for(var r=0;r<t.length;++r)if(e===t[r])return e;var o="Expected ";1!==t.length&&(o+="one of: ");for(var i=0;i<t.length;++i)i>0&&(o+=" | "),o+=JSON.stringify(t[i]);throw o+=", got "+n(e),new TypeError(o)}}function i(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+n(e));return e}Object.defineProperty(t,"__esModule",{value:!0});var a=o(null),s=o(void 0);var c=r(a);function u(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function l(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+n(t));for(var r={},o=Object.keys(t),i=0;i<o.length;++i){var a=o[i];if("__proto__"!==a)try{r[a]=e(t[a])}catch(s){throw u(s,"["+JSON.stringify(a)+"]",0)}}return r};var t=Object.keys(e);function r(r){return function(o){if("object"!=typeof o||null==o)throw new TypeError("Expected an object, got "+n(o));var i,a={};if(r){var s=Object.keys(o);for(i=0;i<s.length;++i){var c=s[i];"__proto__"!==c&&(a[c]=o[c])}}for(i=0;i<t.length;++i){var l=t[i];try{a[l]=e[l](o[l])}catch(d){throw u(d,"."+l,0)}}return a}}var o=r(!1);return o.shape=e,o.withRest=r(!0),o}var d=l;function f(e,t){return function(n){return p[h]>0?t(n):e(n)}}var p="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,h="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",y=f((function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+n(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+n(e));return t}),(function(e){return e.toISOString()}));t.asArray=function(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+n(t));for(var r=[],o=0;o<t.length;++o)try{r[o]=e(t[o])}catch(i){throw u(i,"["+o+"]",0)}return r}},t.asBoolean=function(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+n(e));return e},t.asCodec=f,t.asDate=y,t.asEither=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}},t.asJSON=function(e){return f((function(t){var n=JSON.parse(i(t));try{return e(n)}catch(r){throw u(r,"JSON.parse()",11)}}),(function(t){return JSON.stringify(e(t))}))},t.asMap=d,t.asMaybe=function(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}},t.asNone=c,t.asNull=a,t.asNumber=function(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+n(e));return e},t.asObject=l,t.asOptional=r,t.asString=i,t.asTuple=function(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+n(e));for(var r=[],o=0;o<t.length;++o)try{r[o]=t[o](e[o])}catch(i){throw u(i,"["+o+"]")}return r}},t.asUndefined=s,t.asUnknown=function(e){return e},t.asValue=o,t.uncleaner=function(e){return function(t){null==p[h]&&Object.defineProperty(p,h,{value:0,writable:!0});try{return++p[h],e(t)}finally{--p[h]}}}},4098:function(e,t){var n="undefined"!=typeof self?self:this,r=function(){function e(){this.fetch=!1,this.DOMException=n.DOMException}return e.prototype=n,new e}();!function(e){!function(t){var n="URLSearchParams"in e,r="Symbol"in e&&"iterator"in Symbol,o="FileReader"in e&&"Blob"in e&&function(){try{return new Blob,!0}catch(e){return!1}}(),i="FormData"in e,a="ArrayBuffer"in e;if(a)var s=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&s.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function l(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function p(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function h(e){return new Promise((function(t,n){e.onload=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function y(e){var t=new FileReader,n=h(t);return t.readAsArrayBuffer(e),n}function b(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function g(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:i&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:n&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=b(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=b(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):n&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=p(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?p(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,n,r=p(this);if(r)return r;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,n=h(t),t.readAsText(e),n;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),n=new Array(t.length),r=0;r<t.length;r++)n[r]=String.fromCharCode(t[r]);return n.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(m)}),this.json=function(){return this.text().then(JSON.parse)},this}f.prototype.append=function(e,t){e=u(e),t=l(t);var n=this.map[e];this.map[e]=n?n+", "+t:t},f.prototype.delete=function(e){delete this.map[u(e)]},f.prototype.get=function(e){return e=u(e),this.has(e)?this.map[e]:null},f.prototype.has=function(e){return this.map.hasOwnProperty(u(e))},f.prototype.set=function(e,t){this.map[u(e)]=l(t)},f.prototype.forEach=function(e,t){for(var n in this.map)this.map.hasOwnProperty(n)&&e.call(t,this.map[n],n,this)},f.prototype.keys=function(){var e=[];return this.forEach((function(t,n){e.push(n)})),d(e)},f.prototype.values=function(){var e=[];return this.forEach((function(t){e.push(t)})),d(e)},f.prototype.entries=function(){var e=[];return this.forEach((function(t,n){e.push([n,t])})),d(e)},r&&(f.prototype[Symbol.iterator]=f.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(e,t){var n,r,o=(t=t||{}).body;if(e instanceof v){if(e.bodyUsed)throw new TypeError("Already read");this.url=e.url,this.credentials=e.credentials,t.headers||(this.headers=new f(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,o||null==e._bodyInit||(o=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=t.credentials||this.credentials||"same-origin",!t.headers&&this.headers||(this.headers=new f(t.headers)),this.method=(n=t.method||this.method||"GET",r=n.toUpperCase(),w.indexOf(r)>-1?r:n),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function m(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var n=e.split("="),r=n.shift().replace(/\+/g," "),o=n.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(o))}})),t}function I(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new f(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},g.call(v.prototype),g.call(I.prototype),I.prototype.clone=function(){return new I(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},I.error=function(){var e=new I(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];I.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new I(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(O){t.DOMException=function(e,t){this.message=e,this.name=t;var n=Error(e);this.stack=n.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,n){return new Promise((function(r,i){var a=new v(e,n);if(a.signal&&a.signal.aborted)return i(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function c(){s.abort()}s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new f,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var n=e.split(":"),r=n.shift().trim();if(r){var o=n.join(":").trim();t.append(r,o)}})),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var o="response"in s?s.response:s.responseText;r(new I(o,n))},s.onerror=function(){i(new TypeError("Network request failed"))},s.ontimeout=function(){i(new TypeError("Network request failed"))},s.onabort=function(){i(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&o&&(s.responseType="blob"),a.headers.forEach((function(e,t){s.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",c),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",c)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=f,e.Request=v,e.Response=I),t.Headers=f,t.Request=v,t.Response=I,t.fetch=S,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var o=r;(t=o.fetch).default=o.fetch,t.fetch=o.fetch,t.Headers=o.Headers,t.Request=o.Request,t.Response=o.Response,e.exports=t},4550:function(e){e.exports=[{code:"AED",number:"784",digits:2,currency:"UAE Dirham",countries:["United Arab Emirates (The)"]},{code:"AFN",number:"971",digits:2,currency:"Afghani",countries:["Afghanistan"]},{code:"ALL",number:"008",digits:2,currency:"Lek",countries:["Albania"]},{code:"AMD",number:"051",digits:2,currency:"Armenian Dram",countries:["Armenia"]},{code:"ANG",number:"532",digits:2,currency:"Netherlands Antillean Guilder",countries:["CuraçAo","Sint Maarten (Dutch Part)"]},{code:"AOA",number:"973",digits:2,currency:"Kwanza",countries:["Angola"]},{code:"ARS",number:"032",digits:2,currency:"Argentine Peso",countries:["Argentina"]},{code:"AUD",number:"036",digits:2,currency:"Australian Dollar",countries:["Australia","Christmas Island","Cocos (Keeling) Islands (The)","Heard Island And Mcdonald Islands","Kiribati","Nauru","Norfolk Island","Tuvalu"]},{code:"AWG",number:"533",digits:2,currency:"Aruban Florin",countries:["Aruba"]},{code:"AZN",number:"944",digits:2,currency:"Azerbaijan Manat",countries:["Azerbaijan"]},{code:"BAM",number:"977",digits:2,currency:"Convertible Mark",countries:["Bosnia And Herzegovina"]},{code:"BBD",number:"052",digits:2,currency:"Barbados Dollar",countries:["Barbados"]},{code:"BDT",number:"050",digits:2,currency:"Taka",countries:["Bangladesh"]},{code:"BGN",number:"975",digits:2,currency:"Bulgarian Lev",countries:["Bulgaria"]},{code:"BHD",number:"048",digits:3,currency:"Bahraini Dinar",countries:["Bahrain"]},{code:"BIF",number:"108",digits:0,currency:"Burundi Franc",countries:["Burundi"]},{code:"BMD",number:"060",digits:2,currency:"Bermudian Dollar",countries:["Bermuda"]},{code:"BND",number:"096",digits:2,currency:"Brunei Dollar",countries:["Brunei Darussalam"]},{code:"BOB",number:"068",digits:2,currency:"Boliviano",countries:["Bolivia (Plurinational State Of)"]},{code:"BOV",number:"984",digits:2,currency:"Mvdol",countries:["Bolivia (Plurinational State Of)"]},{code:"BRL",number:"986",digits:2,currency:"Brazilian Real",countries:["Brazil"]},{code:"BSD",number:"044",digits:2,currency:"Bahamian Dollar",countries:["Bahamas (The)"]},{code:"BTN",number:"064",digits:2,currency:"Ngultrum",countries:["Bhutan"]},{code:"BWP",number:"072",digits:2,currency:"Pula",countries:["Botswana"]},{code:"BYN",number:"933",digits:2,currency:"Belarusian Ruble",countries:["Belarus"]},{code:"BZD",number:"084",digits:2,currency:"Belize Dollar",countries:["Belize"]},{code:"CAD",number:"124",digits:2,currency:"Canadian Dollar",countries:["Canada"]},{code:"CDF",number:"976",digits:2,currency:"Congolese Franc",countries:["Congo (The Democratic Republic Of The)"]},{code:"CHE",number:"947",digits:2,currency:"WIR Euro",countries:["Switzerland"]},{code:"CHF",number:"756",digits:2,currency:"Swiss Franc",countries:["Liechtenstein","Switzerland"]},{code:"CHW",number:"948",digits:2,currency:"WIR Franc",countries:["Switzerland"]},{code:"CLF",number:"990",digits:4,currency:"Unidad de Fomento",countries:["Chile"]},{code:"CLP",number:"152",digits:0,currency:"Chilean Peso",countries:["Chile"]},{code:"CNY",number:"156",digits:2,currency:"Yuan Renminbi",countries:["China"]},{code:"COP",number:"170",digits:2,currency:"Colombian Peso",countries:["Colombia"]},{code:"COU",number:"970",digits:2,currency:"Unidad de Valor Real",countries:["Colombia"]},{code:"CRC",number:"188",digits:2,currency:"Costa Rican Colon",countries:["Costa Rica"]},{code:"CUC",number:"931",digits:2,currency:"Peso Convertible",countries:["Cuba"]},{code:"CUP",number:"192",digits:2,currency:"Cuban Peso",countries:["Cuba"]},{code:"CVE",number:"132",digits:2,currency:"Cabo Verde Escudo",countries:["Cabo Verde"]},{code:"CZK",number:"203",digits:2,currency:"Czech Koruna",countries:["Czechia"]},{code:"DJF",number:"262",digits:0,currency:"Djibouti Franc",countries:["Djibouti"]},{code:"DKK",number:"208",digits:2,currency:"Danish Krone",countries:["Denmark","Faroe Islands (The)","Greenland"]},{code:"DOP",number:"214",digits:2,currency:"Dominican Peso",countries:["Dominican Republic (The)"]},{code:"DZD",number:"012",digits:2,currency:"Algerian Dinar",countries:["Algeria"]},{code:"EGP",number:"818",digits:2,currency:"Egyptian Pound",countries:["Egypt"]},{code:"ERN",number:"232",digits:2,currency:"Nakfa",countries:["Eritrea"]},{code:"ETB",number:"230",digits:2,currency:"Ethiopian Birr",countries:["Ethiopia"]},{code:"EUR",number:"978",digits:2,currency:"Euro",countries:["Andorra","Austria","Belgium","Cyprus","Estonia","European Union","Finland","France","French Guiana","French Southern Territories (The)","Germany","Greece","Guadeloupe","Holy See (The)","Ireland","Italy","Latvia","Lithuania","Luxembourg","Malta","Martinique","Mayotte","Monaco","Montenegro","Netherlands (The)","Portugal","Réunion","Saint Barthélemy","Saint Martin (French Part)","Saint Pierre And Miquelon","San Marino","Slovakia","Slovenia","Spain","Åland Islands"]},{code:"FJD",number:"242",digits:2,currency:"Fiji Dollar",countries:["Fiji"]},{code:"FKP",number:"238",digits:2,currency:"Falkland Islands Pound",countries:["Falkland Islands (The) [Malvinas]"]},{code:"GBP",number:"826",digits:2,currency:"Pound Sterling",countries:["Guernsey","Isle Of Man","Jersey","United Kingdom Of Great Britain And Northern Ireland (The)"]},{code:"GEL",number:"981",digits:2,currency:"Lari",countries:["Georgia"]},{code:"GHS",number:"936",digits:2,currency:"Ghana Cedi",countries:["Ghana"]},{code:"GIP",number:"292",digits:2,currency:"Gibraltar Pound",countries:["Gibraltar"]},{code:"GMD",number:"270",digits:2,currency:"Dalasi",countries:["Gambia (The)"]},{code:"GNF",number:"324",digits:0,currency:"Guinean Franc",countries:["Guinea"]},{code:"GTQ",number:"320",digits:2,currency:"Quetzal",countries:["Guatemala"]},{code:"GYD",number:"328",digits:2,currency:"Guyana Dollar",countries:["Guyana"]},{code:"HKD",number:"344",digits:2,currency:"Hong Kong Dollar",countries:["Hong Kong"]},{code:"HNL",number:"340",digits:2,currency:"Lempira",countries:["Honduras"]},{code:"HRK",number:"191",digits:2,currency:"Kuna",countries:["Croatia"]},{code:"HTG",number:"332",digits:2,currency:"Gourde",countries:["Haiti"]},{code:"HUF",number:"348",digits:2,currency:"Forint",countries:["Hungary"]},{code:"IDR",number:"360",digits:2,currency:"Rupiah",countries:["Indonesia"]},{code:"ILS",number:"376",digits:2,currency:"New Israeli Sheqel",countries:["Israel"]},{code:"INR",number:"356",digits:2,currency:"Indian Rupee",countries:["Bhutan","India"]},{code:"IQD",number:"368",digits:3,currency:"Iraqi Dinar",countries:["Iraq"]},{code:"IRR",number:"364",digits:2,currency:"Iranian Rial",countries:["Iran (Islamic Republic Of)"]},{code:"ISK",number:"352",digits:0,currency:"Iceland Krona",countries:["Iceland"]},{code:"JMD",number:"388",digits:2,currency:"Jamaican Dollar",countries:["Jamaica"]},{code:"JOD",number:"400",digits:3,currency:"Jordanian Dinar",countries:["Jordan"]},{code:"JPY",number:"392",digits:0,currency:"Yen",countries:["Japan"]},{code:"KES",number:"404",digits:2,currency:"Kenyan Shilling",countries:["Kenya"]},{code:"KGS",number:"417",digits:2,currency:"Som",countries:["Kyrgyzstan"]},{code:"KHR",number:"116",digits:2,currency:"Riel",countries:["Cambodia"]},{code:"KMF",number:"174",digits:0,currency:"Comorian Franc ",countries:["Comoros (The)"]},{code:"KPW",number:"408",digits:2,currency:"North Korean Won",countries:["Korea (The Democratic People's Republic Of)"]},{code:"KRW",number:"410",digits:0,currency:"Won",countries:["Korea (The Republic Of)"]},{code:"KWD",number:"414",digits:3,currency:"Kuwaiti Dinar",countries:["Kuwait"]},{code:"KYD",number:"136",digits:2,currency:"Cayman Islands Dollar",countries:["Cayman Islands (The)"]},{code:"KZT",number:"398",digits:2,currency:"Tenge",countries:["Kazakhstan"]},{code:"LAK",number:"418",digits:2,currency:"Lao Kip",countries:["Lao People's Democratic Republic (The)"]},{code:"LBP",number:"422",digits:2,currency:"Lebanese Pound",countries:["Lebanon"]},{code:"LKR",number:"144",digits:2,currency:"Sri Lanka Rupee",countries:["Sri Lanka"]},{code:"LRD",number:"430",digits:2,currency:"Liberian Dollar",countries:["Liberia"]},{code:"LSL",number:"426",digits:2,currency:"Loti",countries:["Lesotho"]},{code:"LYD",number:"434",digits:3,currency:"Libyan Dinar",countries:["Libya"]},{code:"MAD",number:"504",digits:2,currency:"Moroccan Dirham",countries:["Morocco","Western Sahara"]},{code:"MDL",number:"498",digits:2,currency:"Moldovan Leu",countries:["Moldova (The Republic Of)"]},{code:"MGA",number:"969",digits:2,currency:"Malagasy Ariary",countries:["Madagascar"]},{code:"MKD",number:"807",digits:2,currency:"Denar",countries:["Macedonia (The Former Yugoslav Republic Of)"]},{code:"MMK",number:"104",digits:2,currency:"Kyat",countries:["Myanmar"]},{code:"MNT",number:"496",digits:2,currency:"Tugrik",countries:["Mongolia"]},{code:"MOP",number:"446",digits:2,currency:"Pataca",countries:["Macao"]},{code:"MRU",number:"929",digits:2,currency:"Ouguiya",countries:["Mauritania"]},{code:"MUR",number:"480",digits:2,currency:"Mauritius Rupee",countries:["Mauritius"]},{code:"MVR",number:"462",digits:2,currency:"Rufiyaa",countries:["Maldives"]},{code:"MWK",number:"454",digits:2,currency:"Malawi Kwacha",countries:["Malawi"]},{code:"MXN",number:"484",digits:2,currency:"Mexican Peso",countries:["Mexico"]},{code:"MXV",number:"979",digits:2,currency:"Mexican Unidad de Inversion (UDI)",countries:["Mexico"]},{code:"MYR",number:"458",digits:2,currency:"Malaysian Ringgit",countries:["Malaysia"]},{code:"MZN",number:"943",digits:2,currency:"Mozambique Metical",countries:["Mozambique"]},{code:"NAD",number:"516",digits:2,currency:"Namibia Dollar",countries:["Namibia"]},{code:"NGN",number:"566",digits:2,currency:"Naira",countries:["Nigeria"]},{code:"NIO",number:"558",digits:2,currency:"Cordoba Oro",countries:["Nicaragua"]},{code:"NOK",number:"578",digits:2,currency:"Norwegian Krone",countries:["Bouvet Island","Norway","Svalbard And Jan Mayen"]},{code:"NPR",number:"524",digits:2,currency:"Nepalese Rupee",countries:["Nepal"]},{code:"NZD",number:"554",digits:2,currency:"New Zealand Dollar",countries:["Cook Islands (The)","New Zealand","Niue","Pitcairn","Tokelau"]},{code:"OMR",number:"512",digits:3,currency:"Rial Omani",countries:["Oman"]},{code:"PAB",number:"590",digits:2,currency:"Balboa",countries:["Panama"]},{code:"PEN",number:"604",digits:2,currency:"Sol",countries:["Peru"]},{code:"PGK",number:"598",digits:2,currency:"Kina",countries:["Papua New Guinea"]},{code:"PHP",number:"608",digits:2,currency:"Philippine Piso",countries:["Philippines (The)"]},{code:"PKR",number:"586",digits:2,currency:"Pakistan Rupee",countries:["Pakistan"]},{code:"PLN",number:"985",digits:2,currency:"Zloty",countries:["Poland"]},{code:"PYG",number:"600",digits:0,currency:"Guarani",countries:["Paraguay"]},{code:"QAR",number:"634",digits:2,currency:"Qatari Rial",countries:["Qatar"]},{code:"RON",number:"946",digits:2,currency:"Romanian Leu",countries:["Romania"]},{code:"RSD",number:"941",digits:2,currency:"Serbian Dinar",countries:["Serbia"]},{code:"RUB",number:"643",digits:2,currency:"Russian Ruble",countries:["Russian Federation (The)"]},{code:"RWF",number:"646",digits:0,currency:"Rwanda Franc",countries:["Rwanda"]},{code:"SAR",number:"682",digits:2,currency:"Saudi Riyal",countries:["Saudi Arabia"]},{code:"SBD",number:"090",digits:2,currency:"Solomon Islands Dollar",countries:["Solomon Islands"]},{code:"SCR",number:"690",digits:2,currency:"Seychelles Rupee",countries:["Seychelles"]},{code:"SDG",number:"938",digits:2,currency:"Sudanese Pound",countries:["Sudan (The)"]},{code:"SEK",number:"752",digits:2,currency:"Swedish Krona",countries:["Sweden"]},{code:"SGD",number:"702",digits:2,currency:"Singapore Dollar",countries:["Singapore"]},{code:"SHP",number:"654",digits:2,currency:"Saint Helena Pound",countries:["Saint Helena, Ascension And Tristan Da Cunha"]},{code:"SLL",number:"694",digits:2,currency:"Leone",countries:["Sierra Leone"]},{code:"SOS",number:"706",digits:2,currency:"Somali Shilling",countries:["Somalia"]},{code:"SRD",number:"968",digits:2,currency:"Surinam Dollar",countries:["Suriname"]},{code:"SSP",number:"728",digits:2,currency:"South Sudanese Pound",countries:["South Sudan"]},{code:"STN",number:"930",digits:2,currency:"Dobra",countries:["Sao Tome And Principe"]},{code:"SVC",number:"222",digits:2,currency:"El Salvador Colon",countries:["El Salvador"]},{code:"SYP",number:"760",digits:2,currency:"Syrian Pound",countries:["Syrian Arab Republic"]},{code:"SZL",number:"748",digits:2,currency:"Lilangeni",countries:["Swaziland"]},{code:"THB",number:"764",digits:2,currency:"Baht",countries:["Thailand"]},{code:"TJS",number:"972",digits:2,currency:"Somoni",countries:["Tajikistan"]},{code:"TMT",number:"934",digits:2,currency:"Turkmenistan New Manat",countries:["Turkmenistan"]},{code:"TND",number:"788",digits:3,currency:"Tunisian Dinar",countries:["Tunisia"]},{code:"TOP",number:"776",digits:2,currency:"Pa'anga",countries:["Tonga"]},{code:"TRY",number:"949",digits:2,currency:"Turkish Lira",countries:["Turkey"]},{code:"TTD",number:"780",digits:2,currency:"Trinidad and Tobago Dollar",countries:["Trinidad And Tobago"]},{code:"TWD",number:"901",digits:2,currency:"New Taiwan Dollar",countries:["Taiwan (Province Of China)"]},{code:"TZS",number:"834",digits:2,currency:"Tanzanian Shilling",countries:["Tanzania, United Republic Of"]},{code:"UAH",number:"980",digits:2,currency:"Hryvnia",countries:["Ukraine"]},{code:"UGX",number:"800",digits:0,currency:"Uganda Shilling",countries:["Uganda"]},{code:"USD",number:"840",digits:2,currency:"US Dollar",countries:["American Samoa","Bonaire, Sint Eustatius And Saba","British Indian Ocean Territory (The)","Ecuador","El Salvador","Guam","Haiti","Marshall Islands (The)","Micronesia (Federated States Of)","Northern Mariana Islands (The)","Palau","Panama","Puerto Rico","Timor-Leste","Turks And Caicos Islands (The)","United States Minor Outlying Islands (The)","United States Of America (The)","Virgin Islands (British)","Virgin Islands (U.S.)"]},{code:"USN",number:"997",digits:2,currency:"US Dollar (Next day)",countries:["United States Of America (The)"]},{code:"UYI",number:"940",digits:0,currency:"Uruguay Peso en Unidades Indexadas (URUIURUI)",countries:["Uruguay"]},{code:"UYU",number:"858",digits:2,currency:"Peso Uruguayo",countries:["Uruguay"]},{code:"UZS",number:"860",digits:2,currency:"Uzbekistan Sum",countries:["Uzbekistan"]},{code:"VEF",number:"937",digits:2,currency:"Bolívar",countries:["Venezuela (Bolivarian Republic Of)"]},{code:"VND",number:"704",digits:0,currency:"Dong",countries:["Viet Nam"]},{code:"VUV",number:"548",digits:0,currency:"Vatu",countries:["Vanuatu"]},{code:"WST",number:"882",digits:2,currency:"Tala",countries:["Samoa"]},{code:"XAF",number:"950",digits:0,currency:"CFA Franc BEAC",countries:["Cameroon","Central African Republic (The)","Chad","Congo (The)","Equatorial Guinea","Gabon"]},{code:"XAG",number:"961",digits:0,currency:"Silver",countries:[]},{code:"XAU",number:"959",digits:0,currency:"Gold",countries:[]},{code:"XBA",number:"955",digits:0,currency:"Bond Markets Unit European Composite Unit (EURCO)",countries:[]},{code:"XBB",number:"956",digits:0,currency:"Bond Markets Unit European Monetary Unit (E.M.U.-6)",countries:[]},{code:"XBC",number:"957",digits:0,currency:"Bond Markets Unit European Unit of Account 9 (E.U.A.-9)",countries:[]},{code:"XBD",number:"958",digits:0,currency:"Bond Markets Unit European Unit of Account 17 (E.U.A.-17)",countries:[]},{code:"XCD",number:"951",digits:2,currency:"East Caribbean Dollar",countries:["Anguilla","Antigua And Barbuda","Dominica","Grenada","Montserrat","Saint Kitts And Nevis","Saint Lucia","Saint Vincent And The Grenadines"]},{code:"XDR",number:"960",digits:0,currency:"SDR (Special Drawing Right)",countries:["International Monetary Fund (Imf) "]},{code:"XOF",number:"952",digits:0,currency:"CFA Franc BCEAO",countries:["Benin","Burkina Faso","Côte d'Ivoire","Guinea-Bissau","Mali","Niger (The)","Senegal","Togo"]},{code:"XPD",number:"964",digits:0,currency:"Palladium",countries:[]},{code:"XPF",number:"953",digits:0,currency:"CFP Franc",countries:["French Polynesia","New Caledonia","Wallis And Futuna"]},{code:"XPT",number:"962",digits:0,currency:"Platinum",countries:[]},{code:"XSU",number:"994",digits:0,currency:"Sucre",countries:['Sistema Unitario De Compensacion Regional De Pagos "Sucre"']},{code:"XTS",number:"963",digits:0,currency:"Codes specifically reserved for testing purposes",countries:[]},{code:"XUA",number:"965",digits:0,currency:"ADB Unit of Account",countries:["Member Countries Of The African Development Bank Group"]},{code:"XXX",number:"999",digits:0,currency:"The codes assigned for transactions where no currency is involved",countries:[]},{code:"YER",number:"886",digits:2,currency:"Yemeni Rial",countries:["Yemen"]},{code:"ZAR",number:"710",digits:2,currency:"Rand",countries:["Lesotho","Namibia","South Africa"]},{code:"ZMW",number:"967",digits:2,currency:"Zambian Kwacha",countries:["Zambia"]},{code:"ZWL",number:"932",digits:2,currency:"Zimbabwe Dollar",countries:["Zimbabwe"]}]},3546:function(e,t,n){var r=n(7680),o=n(2719),i=n(4550);t.Rx=function(e){return r(i,(function(t){return t.number===String(e)}))}},4638:function(e,t,n){"use strict";var r=n(5352);function o(e){throw new Error("makeNodeDisklet is not available on this platform")}function i(){throw new Error("makeReactNativeDisklet is not available on this platform")}function a(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function s(e){return function(){var t=this,n=arguments;return new Promise((function(r,o){var i=e.apply(t,n);function s(e){a(i,r,o,s,c,"next",e)}function c(e){a(i,r,o,s,c,"throw",e)}s(void 0)}))}}function c(){return c=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},c.apply(this,arguments)}function u(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");for(var t=e.split("/"),n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}function l(e){return""===e?e:e+"/"}function d(e){for(var t=[],n=0;n<e.length;++n){var r=e.key(n);null!=r&&t.push(r)}return t}function f(e,t){void 0===e&&(e=window.localStorage),void 0===t&&(t={});var n=null!=t.prefix?l(t.prefix):"/";return{delete:function(t){var r=u(t);null!=e.getItem(n+r)&&e.removeItem(n+r);for(var o=l(r),i=0,a=d(e);i<a.length;i++){var s=a[i];0===s.indexOf(n+o)&&e.removeItem(s)}return Promise.resolve()},getData:function(e){return this.getText(e).then((function(e){return r.base64.parse(e)}))},getText:function(t){var r=u(t),o=e.getItem(n+r);return null==o?Promise.reject(new Error('Cannot load "'+r+'"')):Promise.resolve(o)},list:function(t){return s((function*(){void 0===t&&(t="");var r=u(t),o={};null!=e.getItem(n+r)&&(o[r]="file");for(var i=l(r),a=0,s=d(e);a<s.length;a++){var c=s[a];if(0===c.indexOf(n+i)){var f=c.indexOf("/",n.length+i.length);f<0?o[c.slice(n.length)]="file":o[c.slice(n.length,f)]="folder"}}return o}))()},setData:function(e,t){return this.setText(e,r.base64.stringify(t))},setText:function(t,r){return"string"!=typeof r?Promise.reject(new TypeError("setText expects a string")):(e.setItem(n+u(t),r),Promise.resolve())}}}function p(e){return void 0===e&&(e={}),{delete:function(t){var n=u(t);null!=e["/"+n]&&delete e["/"+n];for(var r=l(n),o=0,i=Object.keys(e);o<i.length;o++){var a=i[o];0===a.indexOf("/"+r)&&delete e[a]}return Promise.resolve()},getData:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"==typeof r?Promise.reject(new Error('"'+n+'" is a text file.')):Promise.resolve(r)},getText:function(t){var n=u(t),r=e["/"+n];return null==r?Promise.reject(new Error('Cannot load "'+n+'"')):"string"!=typeof r?Promise.reject(new Error('"'+n+'" is a binary file.')):Promise.resolve(r)},list:function(t){return s((function*(){void 0===t&&(t="");var n=u(t),r={};null!=e["/"+n]&&(r[n]="file");for(var o=l(n),i=0,a=Object.keys(e);i<a.length;i++){var s=a[i];if(0===s.indexOf("/"+o)){var c=s.indexOf("/",1+o.length);c<0?r[s.slice(1)]="file":r[s.slice(1,c)]="folder"}}return r}))()},setData:function(t,n){var r=n,o=Uint8Array.from(r);return e["/"+u(t)]=o,Promise.resolve()},setText:function(t,n){return"string"!=typeof n?Promise.reject(new TypeError("setText expects a string")):(e["/"+u(t)]=n,Promise.resolve())}}}var h=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.getData=function(){return this._disklet.getData(this._path)},t.getText=function(){return this._disklet.getText(this._path)},t.setData=function(e){return this._disklet.setData(this._path,e)},t.setText=function(e){return this._disklet.setText(this._path,e)},e}(),y=function(){function e(e,t){this._disklet=e,this._path=t}var t=e.prototype;return t.delete=function(){return this._disklet.delete(this._path)},t.file=function(e){return new h(this._disklet,this._path+"/"+e)},t.folder=function(t){return new e(this._disklet,this._path+"/"+t)},t.listFiles=function(){return this._disklet.list(this._path).then((function(e){return Object.keys(e).filter((function(t){return"file"===e[t]})).map((function(e){return e.replace(/^.*\//,"")}))}))},t.listFolders=function(){return this._disklet.list(this._path).then((function(e){return Object.keys(e).filter((function(t){return"folder"===e[t]})).map((function(e){return e.replace(/^.*\//,"")}))}))},e}();function b(e){return new y(e,".")}function g(e,t){for(var n=0,r=0;n<t.length;){var o=t[n++];if(".."===o?r--:"."!==o&&""!==o&&(t[r++]=o),r<0)throw new Error("Path would escape folder")}for(n=0;n<r;++n)e=e.folder(t[n]);return e}function w(e,t){return e.listFiles().then((function(n){return Promise.all(n.map((function(n){return t(e.file(n),n,e)})))}))}function v(e,t){return e.listFolders().then((function(n){return Promise.all(n.map((function(n){return t(e.folder(n),n,e)})))}))}function m(e,t){console.log(t+' "'+e+'"')}function I(e,t,n){var r=n.callback,o=void 0===r?m:r,i=n.verbose;(void 0!==i&&i||/set|delete/.test(t))&&o(e,t)}var E=function(){function e(e,t,n){this._file=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete file",this._opts),this._file.delete()},t.getData=function(){return I(this._path,"get data",this._opts),this._file.getData()},t.getText=function(){return I(this._path,"get text",this._opts),this._file.getText()},t.setData=function(e){return I(this._path,"set data",this._opts),this._file.setData(e)},t.setText=function(e){return I(this._path,"set text",this._opts),this._file.setText(e)},t.getPath=function(){return this._path},e}(),S=function(){function e(e,t,n){this._folder=e,this._path=t,this._opts=n}var t=e.prototype;return t.delete=function(){return I(this._path,"delete folder",this._opts),this._folder.delete()},t.file=function(e){return new E(this._folder.file(e),this._path+e,this._opts)},t.folder=function(t){return new e(this._folder.folder(t),this._path+t+"/",this._opts)},t.listFiles=function(){return I(this._path,"list files",this._opts),this._folder.listFiles()},t.listFolders=function(){return I(this._path,"list folders",this._opts),this._folder.listFolders()},e}();function O(e,t){var n={},r=[];return e.forEach((function(e){/\._x_$/.test(e)?n[e]=!0:(n[e+"._x_"]=!0,r.push(e))})),t.forEach((function(e){n[e+"._x_"]||r.push(e)})),r}var A=function(){function e(e,t,n){this._master=e,this._fallback=t,this._whiteout=n}var t=e.prototype;return t.delete=function(){return Promise.all([this._whiteout.setData([]),this._master.delete().catch((function(e){return null}))])},t.getData=function(){var e=this;return this._master.getData().catch((function(t){return e._whiteout.getData().then((function(e){throw new Error("File has been deleted")}),(function(t){return e._fallback.getData()}))}))},t.getText=function(){var e=this;return this._master.getText().catch((function(t){return e._whiteout.getData().then((function(e){throw new Error("File has been deleted")}),(function(t){return e._fallback.getText()}))}))},t.setData=function(e){return this._master.setData(e)},t.setText=function(e){return this._master.setText(e)},t.getPath=function(){throw new Error("Cannot call getPath on a Union Folder")},e}(),T=function(){function e(e,t){this._master=e,this._fallback=t}var t=e.prototype;return t.delete=function(){return Promise.all([w(this,(function(e){return e.delete()})),v(this,(function(e){return e.delete()}))]).then((function(){}))},t.file=function(e){return new A(this._master.file(e),this._fallback.file(e),this._master.file(e+"._x_"))},t.folder=function(t){return new e(this._master.folder(t),this._fallback.folder(t))},t.listFiles=function(){return Promise.all([this._master.listFiles(),this._fallback.listFiles()]).then((function(e){return O(e[0],e[1])}))},t.listFolders=function(){return Promise.all([this._master.listFolders(),this._fallback.listFolders()]).then((function(e){return O(e[0],e[1])}))},e}();function _(e,t){var n=l(u(t));return{delete:function(t){return e.delete(n+t)},getData:function(t){return e.getData(n+t)},getText:function(t){return e.getText(n+t)},list:function(t){return void 0===t&&(t="."),e.list(n+t).then((function(e){var t={};for(var r in e)t[r.replace(n,"")]=e[r];return t}))},setData:function(t,r){return e.setData(n+t,r)},setText:function(t,r){return e.setText(n+t,r)}}}t.gQ=function(e){return Object.keys(e).filter((function(t){return"file"===e[t]}))},t.ji=function(e){return Object.keys(e).filter((function(t){return"folder"===e[t]}))},t.Wh=p,t.Cl=function(e,t){return{delete:function(n){return Promise.all([e.delete(n),t.delete(n)])},getData:function(n){return e.getData(n).catch((function(e){return t.getData(n)}))},getText:function(n){return e.getText(n).catch((function(e){return t.getText(n)}))},list:function(n){return Promise.all([e.list(n),t.list(n)]).then((function(e){var t=e[0];return c(e[1],t)}))},setData:function(t,n){return e.setData(t,n)},setText:function(t,n){return e.setText(t,n)}}},t.HN=_},1649:function(e,t,n){"use strict";var r=n(7445),o=n(4098),i=n(1223),a=n(3715),s=n(5352);function c(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var u=c(o),l=c(i),d=c(a);const f=/^[a-z0-9-_.]+(\/+[a-z0-9-_.]+)*$/i,p=/^[a-f0-9]{40}$/,h=r.asObject({infoServers:r.asOptional(r.asArray(r.asString)),syncServers:r.asOptional(r.asArray(r.asString))}),y=e=>{const t=r.asString(e);if(""===t)throw new TypeError("Expected non empty string");return t},b=e=>{const t=r.asString(e);if(!p.test(t))throw new TypeError(`Invalid sync key '${t}'`);return t},g=r.asObject({iv_hex:r.asString,encryptionType:r.asNumber,data_base64:r.asString}),w=r.asObject({success:r.asValue(!1),message:r.asString,stack:r.asOptional(r.asString)}),v=r.asEither(g,r.asNull),m=r.asObject(v),I=r.asObject({syncKey:b,hash:r.asOptional(y)}),E=r.asObject({hash:r.asOptional(r.asString),changes:m}),S=r.asObject({syncKey:b,hash:r.asOptional(y)}),O=r.asObject({changes:m}),A=r.asObject({hash:r.asString,changes:m}),T=r.asObject({syncKey:b}),_=r.asUndefined,k=()=>{};async function x(e,t,n={}){const{log:o=k,fetch:i=u.default}=n,{method:a,url:s,body:c,numbUrl:l=s,headers:d={}}=e,f=Date.now(),p=await i(s,{method:a,headers:{"Content-Type":"application/json",...d},body:JSON.stringify(c)}),h=Date.now()-f;o(`${a} ${l} returned ${p.status} in ${h}ms`);const y=await p.text();if(!p.ok)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${y}`);const b=r.asMaybe(w)(y);if(null!=b)throw new Error(`Failed request ${a} ${l} failed ${p.status}: ${b.message}`);return t(""!==y.trim()?JSON.parse(y):void 0)}const P=l.default("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),M=e=>{const t=C(C(s.base16.parse(e)));return P.encode(t)};function C(e){const t=d.default.sha256();return Uint8Array.from(t.update(e).digest())}class N extends Error{constructor(e="Cannot reach the network"){super(e),this.name="NetworkError"}}const j={infoServers:["https://info-eu1.edge.app","https://info-us1.edge.app"],syncServers:["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]};function D(e={}){const{log:t=(()=>{})}=e,n={...j,...e.edgeServers},{edgeServersCacheTTL:r=6e5}=e,o=function(e,t){let n=Date.now()+t,r=e(void 0);return{get:()=>{if(Date.now()>n||null==r){n=Date.now()+t;const o=e(r);r=o}return r}}}(((r={current:n})=>(r.current.infoServers.length>0&&async function(e,t={}){const{log:n=k,fetch:r=u.default}=t;let o=new Error("No info servers");for(const a of e){const[e,t]=["GET","/v1/edgeServers"],s=Date.now(),c=`${a}${t}`;try{const t=await r(c,{method:e,headers:{"Content-Type":"application/json"}}).catch((t=>{const r=Date.now()-s,o=`${e} ${c} failed in ${r}ms, ${String(t)}`;throw n(o),new N(o)})),{ok:o,status:i}=t,a=Date.now()-s,u=`${e} ${c} returned ${i} in ${a}ms`;if(!o)throw n(u),new N(u);n(u);const l=await t.text(),d=JSON.parse(l);return h(d)}catch(i){o=i;continue}}throw o}(r.current.infoServers,e).then((e=>{return r.current={...r.current,...e,infoServers:(t=e.infoServers,n=()=>j.infoServers,null!=t?t:n())};var t,n})).catch((async e=>{t(String(e))})),r)),r);return{async getEdgeServers(){const{current:e}=await o.get();return e}}}function R(e,t){return null!=e?e:t()}t.bS=m,t.Ei=g,t.h8=h,t.wJ=v,t.PG=I,t.SR=E,t.Th=y,t.Qw=e=>{const t=r.asString(e);try{if(f.test(t))return function(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder");if(0===r&&n===t.length)throw new Error("Path would evaluate to empty file name")}return t.slice(0,r).join("/")}(t)}catch(n){}throw new Error(`Invalid path '${t}'`)},t.YK=O,t.KI=S,t.Wn=A,t.tp=T,t.RQ=_,t.tE=w,t.Jj=b,t.LZ=function(e={}){const t=D(e);async function n(){const{syncServers:e}=await t.getEdgeServers();return function(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}(e)}return{async createRepo(t,r){const o=await n();let i=new Error(`Failed to create repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"PUT",url:o,numbUrl:s,headers:null!=r?{"X-API-Key":r}:{}},_,e)}catch(a){i=a}}throw i},async readRepo(t,r){const o=await n();let i=new Error(`Failed to read repo ${t}: empty sync server list`);for(const n of o){const o=`${n}/api/v2/store/${t}/${R(r,(()=>""))}`,s=o.replace(t,`<${M(t)}>`);try{return await x({method:"GET",url:o,numbUrl:s},E,e)}catch(a){i=a}}throw i},async updateRepo(t,r,o){const i=await n();let a=new Error(`Failed to update repo ${t}: empty sync server list`);for(const n of i){const i=`${n}/api/v2/store/${t}/${R(r,(()=>""))}`,c=i.replace(t,`<${M(t)}>`);try{return await x({method:"POST",url:i,numbUrl:c,body:o},A,e)}catch(s){a=s}}throw a}}},t.m8=M},1223:function(e){e.exports=function(e){for(var t={},n=e.length,r=e.charAt(0),o=0;o<e.length;o++)t[e.charAt(o)]=o;function i(e){if(0===e.length)return[];for(var o=[0],i=0;i<e.length;i++){var a=t[e[i]];if(void 0===a)return;for(var s=0,c=a;s<o.length;++s)c+=o[s]*n,o[s]=255&c,c>>=8;for(;c>0;)o.push(255&c),c>>=8}for(var u=0;e[u]===r&&u<e.length-1;++u)o.push(0);return o.reverse()}return{encode:function(t){if(0===t.length)return"";for(var r=[0],o=0;o<t.length;++o){for(var i=0,a=t[o];i<r.length;++i)a+=r[i]<<8,r[i]=a%n,a=a/n|0;for(;a>0;)r.push(a%n),a=a/n|0}for(var s="",c=0;0===t[c]&&c<t.length-1;++c)s+=e[0];for(var u=r.length-1;u>=0;--u)s+=e[r[u]];return s},decodeUnsafe:i,decode:function(e){var t=i(e);if(t)return t;throw new Error("Non-base"+n+" character")}}}},6266:function(e,t,n){"use strict";var r=t;r.version=n(8597).i8,r.utils=n(953),r.rand=n(9931),r.curve=n(8254),r.curves=n(5427),r.ec=n(7954),r.eddsa=n(5980)},4918:function(e,t,n){"use strict";var r=n(3550),o=n(953),i=o.getNAF,a=o.getJSF,s=o.assert;function c(e,t){this.type=e,this.p=new r(t.p,16),this.red=t.prime?r.red(t.prime):r.mont(this.p),this.zero=new r(0).toRed(this.red),this.one=new r(1).toRed(this.red),this.two=new r(2).toRed(this.red),this.n=t.n&&new r(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var n=this.n&&this.p.div(this.n);!n||n.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function u(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){s(e.precomputed);var n=e._getDoubles(),r=i(t,1,this._bitLength),o=(1<<n.step+1)-(n.step%2==0?2:1);o/=3;var a,c,u=[];for(a=0;a<r.length;a+=n.step){c=0;for(var l=a+n.step-1;l>=a;l--)c=(c<<1)+r[l];u.push(c)}for(var d=this.jpoint(null,null,null),f=this.jpoint(null,null,null),p=o;p>0;p--){for(a=0;a<u.length;a++)(c=u[a])===p?f=f.mixedAdd(n.points[a]):c===-p&&(f=f.mixedAdd(n.points[a].neg()));d=d.add(f)}return d.toP()},c.prototype._wnafMul=function(e,t){var n=4,r=e._getNAFPoints(n);n=r.wnd;for(var o=r.points,a=i(t,n,this._bitLength),c=this.jpoint(null,null,null),u=a.length-1;u>=0;u--){for(var l=0;u>=0&&0===a[u];u--)l++;if(u>=0&&l++,c=c.dblp(l),u<0)break;var d=a[u];s(0!==d),c="affine"===e.type?d>0?c.mixedAdd(o[d-1>>1]):c.mixedAdd(o[-d-1>>1].neg()):d>0?c.add(o[d-1>>1]):c.add(o[-d-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,n,r,o){var s,c,u,l=this._wnafT1,d=this._wnafT2,f=this._wnafT3,p=0;for(s=0;s<r;s++){var h=(u=t[s])._getNAFPoints(e);l[s]=h.wnd,d[s]=h.points}for(s=r-1;s>=1;s-=2){var y=s-1,b=s;if(1===l[y]&&1===l[b]){var g=[t[y],null,null,t[b]];0===t[y].y.cmp(t[b].y)?(g[1]=t[y].add(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg())):0===t[y].y.cmp(t[b].y.redNeg())?(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].add(t[b].neg())):(g[1]=t[y].toJ().mixedAdd(t[b]),g[2]=t[y].toJ().mixedAdd(t[b].neg()));var w=[-3,-1,-5,-7,0,7,5,1,3],v=a(n[y],n[b]);for(p=Math.max(v[0].length,p),f[y]=new Array(p),f[b]=new Array(p),c=0;c<p;c++){var m=0|v[0][c],I=0|v[1][c];f[y][c]=w[3*(m+1)+(I+1)],f[b][c]=0,d[y]=g}}else f[y]=i(n[y],l[y],this._bitLength),f[b]=i(n[b],l[b],this._bitLength),p=Math.max(f[y].length,p),p=Math.max(f[b].length,p)}var E=this.jpoint(null,null,null),S=this._wnafT4;for(s=p;s>=0;s--){for(var O=0;s>=0;){var A=!0;for(c=0;c<r;c++)S[c]=0|f[c][s],0!==S[c]&&(A=!1);if(!A)break;O++,s--}if(s>=0&&O++,E=E.dblp(O),s<0)break;for(c=0;c<r;c++){var T=S[c];0!==T&&(T>0?u=d[c][T-1>>1]:T<0&&(u=d[c][-T-1>>1].neg()),E="affine"===u.type?E.mixedAdd(u):E.add(u))}}for(s=0;s<r;s++)d[s]=null;return o?E:E.toP()},c.BasePoint=u,u.prototype.eq=function(){throw new Error("Not implemented")},u.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(e,t){e=o.toArray(e,t);var n=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*n)return 6===e[0]?s(e[e.length-1]%2==0):7===e[0]&&s(e[e.length-1]%2==1),this.point(e.slice(1,1+n),e.slice(1+n,1+2*n));if((2===e[0]||3===e[0])&&e.length-1===n)return this.pointFromX(e.slice(1,1+n),3===e[0]);throw new Error("Unknown point format")},u.prototype.encodeCompressed=function(e){return this.encode(e,!0)},u.prototype._encode=function(e){var t=this.curve.p.byteLength(),n=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(n):[4].concat(n,this.getY().toArray("be",t))},u.prototype.encode=function(e,t){return o.encode(this._encode(t),e)},u.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},u.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},u.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var n=[this],r=this,o=0;o<t;o+=e){for(var i=0;i<e;i++)r=r.dbl();n.push(r)}return{step:e,points:n}},u.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],n=(1<<e)-1,r=1===n?null:this.dbl(),o=1;o<n;o++)t[o]=t[o-1].add(r);return{wnd:e,points:t}},u.prototype._getBeta=function(){return null},u.prototype.dblp=function(e){for(var t=this,n=0;n<e;n++)t=t.dbl();return t}},1138:function(e,t,n){"use strict";var r=n(953),o=n(3550),i=n(5717),a=n(4918),s=r.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new o(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new o(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new o(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function u(e,t,n,r,i){a.BasePoint.call(this,e,"projective"),null===t&&null===n&&null===r?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new o(t,16),this.y=new o(n,16),this.z=r?new o(r,16):this.curve.one,this.t=i&&new o(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}i(c,a),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,n,r){return this.point(e,t,n,r)},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=this.c2.redSub(this.a.redMul(n)),i=this.one.redSub(this.c2.redMul(this.d).redMul(n)),a=r.redMul(i.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var c=s.fromRed().isOdd();return(t&&!c||!t&&c)&&(s=s.redNeg()),this.point(e,s)},c.prototype.pointFromY=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr(),r=n.redSub(this.c2),i=n.redMul(this.d).redMul(this.c2).redSub(this.a),a=r.redMul(i.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),n=e.y.redSqr(),r=t.redMul(this.a).redAdd(n),o=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(n)));return 0===r.cmp(o)},i(u,a.BasePoint),c.prototype.pointFromJSON=function(e){return u.fromJSON(this,e)},c.prototype.point=function(e,t,n,r){return new u(this,e,t,n,r)},u.fromJSON=function(e,t){return new u(e,t[0],t[1],t[2])},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},u.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr();n=n.redIAdd(n);var r=this.curve._mulA(e),o=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),i=r.redAdd(t),a=i.redSub(n),s=r.redSub(t),c=o.redMul(a),u=i.redMul(s),l=o.redMul(s),d=a.redMul(i);return this.curve.point(c,u,d,l)},u.prototype._projDbl=function(){var e,t,n,r,o,i,a=this.x.redAdd(this.y).redSqr(),s=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var u=(r=this.curve._mulA(s)).redAdd(c);this.zOne?(e=a.redSub(s).redSub(c).redMul(u.redSub(this.curve.two)),t=u.redMul(r.redSub(c)),n=u.redSqr().redSub(u).redSub(u)):(o=this.z.redSqr(),i=u.redSub(o).redISub(o),e=a.redSub(s).redISub(c).redMul(i),t=u.redMul(r.redSub(c)),n=u.redMul(i))}else r=s.redAdd(c),o=this.curve._mulC(this.z).redSqr(),i=r.redSub(o).redSub(o),e=this.curve._mulC(a.redISub(r)).redMul(i),t=this.curve._mulC(r).redMul(s.redISub(c)),n=r.redMul(i);return this.curve.point(e,t,n)},u.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},u.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),n=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),r=this.t.redMul(this.curve.dd).redMul(e.t),o=this.z.redMul(e.z.redAdd(e.z)),i=n.redSub(t),a=o.redSub(r),s=o.redAdd(r),c=n.redAdd(t),u=i.redMul(a),l=s.redMul(c),d=i.redMul(c),f=a.redMul(s);return this.curve.point(u,l,f,d)},u.prototype._projAdd=function(e){var t,n,r=this.z.redMul(e.z),o=r.redSqr(),i=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(i).redMul(a),c=o.redSub(s),u=o.redAdd(s),l=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(i).redISub(a),d=r.redMul(c).redMul(l);return this.curve.twisted?(t=r.redMul(u).redMul(a.redSub(this.curve._mulA(i))),n=c.redMul(u)):(t=r.redMul(u).redMul(a.redSub(i)),n=this.curve._mulC(c).redMul(u)),this.curve.point(d,t,n)},u.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},u.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!1)},u.prototype.jmulAdd=function(e,t,n){return this.curve._wnafMulAdd(1,[this,t],[e,n],2,!0)},u.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},u.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},u.prototype.getX=function(){return this.normalize(),this.x.fromRed()},u.prototype.getY=function(){return this.normalize(),this.y.fromRed()},u.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},u.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var n=e.clone(),r=this.curve.redN.redMul(this.z);;){if(n.iadd(this.curve.n),n.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(r),0===this.x.cmp(t))return!0}},u.prototype.toP=u.prototype.normalize,u.prototype.mixedAdd=u.prototype.add},8254:function(e,t,n){"use strict";var r=t;r.base=n(4918),r.short=n(6673),r.mont=n(2881),r.edwards=n(1138)},2881:function(e,t,n){"use strict";var r=n(3550),o=n(5717),i=n(4918),a=n(953);function s(e){i.call(this,"mont",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.b,16).toRed(this.red),this.i4=new r(4).toRed(this.red).redInvm(),this.two=new r(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,n){i.BasePoint.call(this,e,"projective"),null===t&&null===n?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new r(t,16),this.z=new r(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}o(s,i),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,n=t.redSqr(),r=n.redMul(t).redAdd(n.redMul(this.a)).redAdd(t);return 0===r.redSqrt().redSqr().cmp(r)},o(c,i.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new c(this,e,t)},s.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),n=e.redSub(t),r=e.redMul(t),o=n.redMul(t.redAdd(this.curve.a24.redMul(n)));return this.curve.point(r,o)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var n=this.x.redAdd(this.z),r=this.x.redSub(this.z),o=e.x.redAdd(e.z),i=e.x.redSub(e.z).redMul(n),a=o.redMul(r),s=t.z.redMul(i.redAdd(a).redSqr()),c=t.x.redMul(i.redISub(a).redSqr());return this.curve.point(s,c)},c.prototype.mul=function(e){for(var t=e.clone(),n=this,r=this.curve.point(null,null),o=[];0!==t.cmpn(0);t.iushrn(1))o.push(t.andln(1));for(var i=o.length-1;i>=0;i--)0===o[i]?(n=n.diffAdd(r,this),r=r.dbl()):(r=n.diffAdd(r,this),n=n.dbl());return r},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},6673:function(e,t,n){"use strict";var r=n(953),o=n(3550),i=n(5717),a=n(4918),s=r.assert;function c(e){a.call(this,"short",e),this.a=new o(e.a,16).toRed(this.red),this.b=new o(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function u(e,t,n,r){a.BasePoint.call(this,e,"affine"),null===t&&null===n?(this.x=null,this.y=null,this.inf=!0):(this.x=new o(t,16),this.y=new o(n,16),r&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function l(e,t,n,r){a.BasePoint.call(this,e,"jacobian"),null===t&&null===n&&null===r?(this.x=this.curve.one,this.y=this.curve.one,this.z=new o(0)):(this.x=new o(t,16),this.y=new o(n,16),this.z=new o(r,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}i(c,a),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,n;if(e.beta)t=new o(e.beta,16).toRed(this.red);else{var r=this._getEndoRoots(this.p);t=(t=r[0].cmp(r[1])<0?r[0]:r[1]).toRed(this.red)}if(e.lambda)n=new o(e.lambda,16);else{var i=this._getEndoRoots(this.n);0===this.g.mul(i[0]).x.cmp(this.g.x.redMul(t))?n=i[0]:(n=i[1],s(0===this.g.mul(n).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:n,basis:e.basis?e.basis.map((function(e){return{a:new o(e.a,16),b:new o(e.b,16)}})):this._getEndoBasis(n)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:o.mont(e),n=new o(2).toRed(t).redInvm(),r=n.redNeg(),i=new o(3).toRed(t).redNeg().redSqrt().redMul(n);return[r.redAdd(i).fromRed(),r.redSub(i).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,n,r,i,a,s,c,u,l,d=this.n.ushrn(Math.floor(this.n.bitLength()/2)),f=e,p=this.n.clone(),h=new o(1),y=new o(0),b=new o(0),g=new o(1),w=0;0!==f.cmpn(0);){var v=p.div(f);u=p.sub(v.mul(f)),l=b.sub(v.mul(h));var m=g.sub(v.mul(y));if(!r&&u.cmp(d)<0)t=c.neg(),n=h,r=u.neg(),i=l;else if(r&&2==++w)break;c=u,p=f,f=u,b=h,h=l,g=y,y=m}a=u.neg(),s=l;var I=r.sqr().add(i.sqr());return a.sqr().add(s.sqr()).cmp(I)>=0&&(a=t,s=n),r.negative&&(r=r.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:r,b:i},{a:a,b:s}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,n=t[0],r=t[1],o=r.b.mul(e).divRound(this.n),i=n.b.neg().mul(e).divRound(this.n),a=o.mul(n.a),s=i.mul(r.a),c=o.mul(n.b),u=i.mul(r.b);return{k1:e.sub(a).sub(s),k2:c.add(u).neg()}},c.prototype.pointFromX=function(e,t){(e=new o(e,16)).red||(e=e.toRed(this.red));var n=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),r=n.redSqrt();if(0!==r.redSqr().redSub(n).cmp(this.zero))throw new Error("invalid point");var i=r.fromRed().isOdd();return(t&&!i||!t&&i)&&(r=r.redNeg()),this.point(e,r)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,n=e.y,r=this.a.redMul(t),o=t.redSqr().redMul(t).redIAdd(r).redIAdd(this.b);return 0===n.redSqr().redISub(o).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,n){for(var r=this._endoWnafT1,o=this._endoWnafT2,i=0;i<e.length;i++){var a=this._endoSplit(t[i]),s=e[i],c=s._getBeta();a.k1.negative&&(a.k1.ineg(),s=s.neg(!0)),a.k2.negative&&(a.k2.ineg(),c=c.neg(!0)),r[2*i]=s,r[2*i+1]=c,o[2*i]=a.k1,o[2*i+1]=a.k2}for(var u=this._wnafMulAdd(1,r,o,2*i,n),l=0;l<2*i;l++)r[l]=null,o[l]=null;return u},i(u,a.BasePoint),c.prototype.point=function(e,t,n){return new u(this,e,t,n)},c.prototype.pointFromJSON=function(e,t){return u.fromJSON(this,e,t)},u.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var n=this.curve,r=function(e){return n.point(e.x.redMul(n.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(r)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(r)}}}return t}},u.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},u.fromJSON=function(e,t,n){"string"==typeof t&&(t=JSON.parse(t));var r=e.point(t[0],t[1],n);if(!t[2])return r;function o(t){return e.point(t[0],t[1],n)}var i=t[2];return r.precomputed={beta:null,doubles:i.doubles&&{step:i.doubles.step,points:[r].concat(i.doubles.points.map(o))},naf:i.naf&&{wnd:i.naf.wnd,points:[r].concat(i.naf.points.map(o))}},r},u.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},u.prototype.isInfinity=function(){return this.inf},u.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var n=t.redSqr().redISub(this.x).redISub(e.x),r=t.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,r)},u.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,n=this.x.redSqr(),r=e.redInvm(),o=n.redAdd(n).redIAdd(n).redIAdd(t).redMul(r),i=o.redSqr().redISub(this.x.redAdd(this.x)),a=o.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,a)},u.prototype.getX=function(){return this.x.fromRed()},u.prototype.getY=function(){return this.y.fromRed()},u.prototype.mul=function(e){return e=new o(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},u.prototype.mulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o):this.curve._wnafMulAdd(1,r,o,2)},u.prototype.jmulAdd=function(e,t,n){var r=[this,t],o=[e,n];return this.curve.endo?this.curve._endoWnafMulAdd(r,o,!0):this.curve._wnafMulAdd(1,r,o,2,!0)},u.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},u.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var n=this.precomputed,r=function(e){return e.neg()};t.precomputed={naf:n.naf&&{wnd:n.naf.wnd,points:n.naf.points.map(r)},doubles:n.doubles&&{step:n.doubles.step,points:n.doubles.points.map(r)}}}return t},u.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},i(l,a.BasePoint),c.prototype.jpoint=function(e,t,n){return new l(this,e,t,n)},l.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),n=this.x.redMul(t),r=this.y.redMul(t).redMul(e);return this.curve.point(n,r)},l.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},l.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),n=this.z.redSqr(),r=this.x.redMul(t),o=e.x.redMul(n),i=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(n.redMul(this.z)),s=r.redSub(o),c=i.redSub(a);if(0===s.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=s.redSqr(),l=u.redMul(s),d=r.redMul(u),f=c.redSqr().redIAdd(l).redISub(d).redISub(d),p=c.redMul(d.redISub(f)).redISub(i.redMul(l)),h=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(f,p,h)},l.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),n=this.x,r=e.x.redMul(t),o=this.y,i=e.y.redMul(t).redMul(this.z),a=n.redSub(r),s=o.redSub(i);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=a.redSqr(),u=c.redMul(a),l=n.redMul(c),d=s.redSqr().redIAdd(u).redISub(l).redISub(l),f=s.redMul(l.redISub(d)).redISub(o.redMul(u)),p=this.z.redMul(a);return this.curve.jpoint(d,f,p)},l.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var n=this;for(t=0;t<e;t++)n=n.dbl();return n}var r=this.curve.a,o=this.curve.tinv,i=this.x,a=this.y,s=this.z,c=s.redSqr().redSqr(),u=a.redAdd(a);for(t=0;t<e;t++){var l=i.redSqr(),d=u.redSqr(),f=d.redSqr(),p=l.redAdd(l).redIAdd(l).redIAdd(r.redMul(c)),h=i.redMul(d),y=p.redSqr().redISub(h.redAdd(h)),b=h.redISub(y),g=p.redMul(b);g=g.redIAdd(g).redISub(f);var w=u.redMul(s);t+1<e&&(c=c.redMul(f)),i=y,s=w,u=g}return this.curve.jpoint(i,u.redMul(o),s)},l.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},l.prototype._zeroDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r),c=s.redSqr().redISub(a).redISub(a),u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),e=c,t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.x.redSqr(),d=this.y.redSqr(),f=d.redSqr(),p=this.x.redAdd(d).redSqr().redISub(l).redISub(f);p=p.redIAdd(p);var h=l.redAdd(l).redIAdd(l),y=h.redSqr(),b=f.redIAdd(f);b=(b=b.redIAdd(b)).redIAdd(b),e=y.redISub(p).redISub(p),t=h.redMul(p.redISub(e)).redISub(b),n=(n=this.y.redMul(this.z)).redIAdd(n)}return this.curve.jpoint(e,t,n)},l.prototype._threeDbl=function(){var e,t,n;if(this.zOne){var r=this.x.redSqr(),o=this.y.redSqr(),i=o.redSqr(),a=this.x.redAdd(o).redSqr().redISub(r).redISub(i);a=a.redIAdd(a);var s=r.redAdd(r).redIAdd(r).redIAdd(this.curve.a),c=s.redSqr().redISub(a).redISub(a);e=c;var u=i.redIAdd(i);u=(u=u.redIAdd(u)).redIAdd(u),t=s.redMul(a.redISub(c)).redISub(u),n=this.y.redAdd(this.y)}else{var l=this.z.redSqr(),d=this.y.redSqr(),f=this.x.redMul(d),p=this.x.redSub(l).redMul(this.x.redAdd(l));p=p.redAdd(p).redIAdd(p);var h=f.redIAdd(f),y=(h=h.redIAdd(h)).redAdd(h);e=p.redSqr().redISub(y),n=this.y.redAdd(this.z).redSqr().redISub(d).redISub(l);var b=d.redSqr();b=(b=(b=b.redIAdd(b)).redIAdd(b)).redIAdd(b),t=p.redMul(h.redISub(e)).redISub(b)}return this.curve.jpoint(e,t,n)},l.prototype._dbl=function(){var e=this.curve.a,t=this.x,n=this.y,r=this.z,o=r.redSqr().redSqr(),i=t.redSqr(),a=n.redSqr(),s=i.redAdd(i).redIAdd(i).redIAdd(e.redMul(o)),c=t.redAdd(t),u=(c=c.redIAdd(c)).redMul(a),l=s.redSqr().redISub(u.redAdd(u)),d=u.redISub(l),f=a.redSqr();f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=s.redMul(d).redISub(f),h=n.redAdd(n).redMul(r);return this.curve.jpoint(l,p,h)},l.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),n=this.z.redSqr(),r=t.redSqr(),o=e.redAdd(e).redIAdd(e),i=o.redSqr(),a=this.x.redAdd(t).redSqr().redISub(e).redISub(r),s=(a=(a=(a=a.redIAdd(a)).redAdd(a).redIAdd(a)).redISub(i)).redSqr(),c=r.redIAdd(r);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var u=o.redIAdd(a).redSqr().redISub(i).redISub(s).redISub(c),l=t.redMul(u);l=(l=l.redIAdd(l)).redIAdd(l);var d=this.x.redMul(s).redISub(l);d=(d=d.redIAdd(d)).redIAdd(d);var f=this.y.redMul(u.redMul(c.redISub(u)).redISub(a.redMul(s)));f=(f=(f=f.redIAdd(f)).redIAdd(f)).redIAdd(f);var p=this.z.redAdd(a).redSqr().redISub(n).redISub(s);return this.curve.jpoint(d,f,p)},l.prototype.mul=function(e,t){return e=new o(e,t),this.curve._wnafMul(this,e)},l.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),n=e.z.redSqr();if(0!==this.x.redMul(n).redISub(e.x.redMul(t)).cmpn(0))return!1;var r=t.redMul(this.z),o=n.redMul(e.z);return 0===this.y.redMul(o).redISub(e.y.redMul(r)).cmpn(0)},l.prototype.eqXToP=function(e){var t=this.z.redSqr(),n=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(n))return!0;for(var r=e.clone(),o=this.curve.redN.redMul(t);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(n.redIAdd(o),0===this.x.cmp(n))return!0}},l.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},l.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},5427:function(e,t,n){"use strict";var r,o=t,i=n(3715),a=n(8254),s=n(953).assert;function c(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function u(e,t){Object.defineProperty(o,e,{configurable:!0,enumerable:!0,get:function(){var n=new c(t);return Object.defineProperty(o,e,{configurable:!0,enumerable:!0,value:n}),n}})}o.PresetCurve=c,u("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:i.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),u("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:i.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),u("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:i.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),u("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:i.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),u("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:i.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),u("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["9"]}),u("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:i.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{r=n(1037)}catch(l){r=void 0}u("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:i.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",r]})},7954:function(e,t,n){"use strict";var r=n(3550),o=n(2156),i=n(953),a=n(5427),s=n(9931),c=i.assert,u=n(1251),l=n(611);function d(e){if(!(this instanceof d))return new d(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(a,e),"Unknown curve "+e),e=a[e]),e instanceof a.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=d,d.prototype.keyPair=function(e){return new u(this,e)},d.prototype.keyFromPrivate=function(e,t){return u.fromPrivate(this,e,t)},d.prototype.keyFromPublic=function(e,t){return u.fromPublic(this,e,t)},d.prototype.genKeyPair=function(e){e||(e={});for(var t=new o({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||s(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),n=this.n.byteLength(),i=this.n.sub(new r(2));;){var a=new r(t.generate(n));if(!(a.cmp(i)>0))return a.iaddn(1),this.keyFromPrivate(a)}},d.prototype._truncateToN=function(e,t){var n=8*e.byteLength()-this.n.bitLength();return n>0&&(e=e.ushrn(n)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},d.prototype.sign=function(e,t,n,i){"object"==typeof n&&(i=n,n=null),i||(i={}),t=this.keyFromPrivate(t,n),e=this._truncateToN(new r(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),c=e.toArray("be",a),u=new o({hash:this.hash,entropy:s,nonce:c,pers:i.pers,persEnc:i.persEnc||"utf8"}),d=this.n.sub(new r(1)),f=0;;f++){var p=i.k?i.k(f):new r(u.generate(this.n.byteLength()));if(!((p=this._truncateToN(p,!0)).cmpn(1)<=0||p.cmp(d)>=0)){var h=this.g.mul(p);if(!h.isInfinity()){var y=h.getX(),b=y.umod(this.n);if(0!==b.cmpn(0)){var g=p.invm(this.n).mul(b.mul(t.getPrivate()).iadd(e));if(0!==(g=g.umod(this.n)).cmpn(0)){var w=(h.getY().isOdd()?1:0)|(0!==y.cmp(b)?2:0);return i.canonical&&g.cmp(this.nh)>0&&(g=this.n.sub(g),w^=1),new l({r:b,s:g,recoveryParam:w})}}}}}},d.prototype.verify=function(e,t,n,o){e=this._truncateToN(new r(e,16)),n=this.keyFromPublic(n,o);var i=(t=new l(t,"hex")).r,a=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,c=a.invm(this.n),u=c.mul(e).umod(this.n),d=c.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(u,n.getPublic(),d)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(u,n.getPublic(),d)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},d.prototype.recoverPubKey=function(e,t,n,o){c((3&n)===n,"The recovery param is more than two bits"),t=new l(t,o);var i=this.n,a=new r(e),s=t.r,u=t.s,d=1&n,f=n>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&f)throw new Error("Unable to find sencond key candinate");s=f?this.curve.pointFromX(s.add(this.curve.n),d):this.curve.pointFromX(s,d);var p=t.r.invm(i),h=i.sub(a).mul(p).umod(i),y=u.mul(p).umod(i);return this.g.mulAdd(h,s,y)},d.prototype.getKeyRecoveryParam=function(e,t,n,r){if(null!==(t=new l(t,r)).recoveryParam)return t.recoveryParam;for(var o=0;o<4;o++){var i;try{i=this.recoverPubKey(e,t,o)}catch(e){continue}if(i.eq(n))return o}throw new Error("Unable to find valid recovery factor")}},1251:function(e,t,n){"use strict";var r=n(3550),o=n(953).assert;function i(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=i,i.fromPublic=function(e,t,n){return t instanceof i?t:new i(e,{pub:t,pubEnc:n})},i.fromPrivate=function(e,t,n){return t instanceof i?t:new i(e,{priv:t,privEnc:n})},i.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},i.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},i.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},i.prototype._importPrivate=function(e,t){this.priv=new r(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},i.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?o(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||o(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},i.prototype.derive=function(e){return e.validate()||o(e.validate(),"public point not validated"),e.mul(this.priv).getX()},i.prototype.sign=function(e,t,n){return this.ec.sign(e,this,t,n)},i.prototype.verify=function(e,t){return this.ec.verify(e,t,this)},i.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},611:function(e,t,n){"use strict";var r=n(3550),o=n(953),i=o.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(i(e.r&&e.s,"Signature without r or s"),this.r=new r(e.r,16),this.s=new r(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function c(e,t){var n=e[t.place++];if(!(128&n))return n;var r=15&n;if(0===r||r>4)return!1;for(var o=0,i=0,a=t.place;i<r;i++,a++)o<<=8,o|=e[a],o>>>=0;return!(o<=127)&&(t.place=a,o)}function u(e){for(var t=0,n=e.length-1;!e[t]&&!(128&e[t+1])&&t<n;)t++;return 0===t?e:e.slice(t)}function l(e,t){if(t<128)e.push(t);else{var n=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|n);--n;)e.push(t>>>(n<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=o.toArray(e,t);var n=new s;if(48!==e[n.place++])return!1;var i=c(e,n);if(!1===i)return!1;if(i+n.place!==e.length)return!1;if(2!==e[n.place++])return!1;var a=c(e,n);if(!1===a)return!1;var u=e.slice(n.place,a+n.place);if(n.place+=a,2!==e[n.place++])return!1;var l=c(e,n);if(!1===l)return!1;if(e.length!==l+n.place)return!1;var d=e.slice(n.place,l+n.place);if(0===u[0]){if(!(128&u[1]))return!1;u=u.slice(1)}if(0===d[0]){if(!(128&d[1]))return!1;d=d.slice(1)}return this.r=new r(u),this.s=new r(d),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),n=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&n[0]&&(n=[0].concat(n)),t=u(t),n=u(n);!(n[0]||128&n[1]);)n=n.slice(1);var r=[2];l(r,t.length),(r=r.concat(t)).push(2),l(r,n.length);var i=r.concat(n),a=[48];return l(a,i.length),a=a.concat(i),o.encode(a,e)}},5980:function(e,t,n){"use strict";var r=n(3715),o=n(5427),i=n(953),a=i.assert,s=i.parseBytes,c=n(9087),u=n(3622);function l(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof l))return new l(e);e=o[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=r.sha512}e.exports=l,l.prototype.sign=function(e,t){e=s(e);var n=this.keyFromSecret(t),r=this.hashInt(n.messagePrefix(),e),o=this.g.mul(r),i=this.encodePoint(o),a=this.hashInt(i,n.pubBytes(),e).mul(n.priv()),c=r.add(a).umod(this.curve.n);return this.makeSignature({R:o,S:c,Rencoded:i})},l.prototype.verify=function(e,t,n){e=s(e),t=this.makeSignature(t);var r=this.keyFromPublic(n),o=this.hashInt(t.Rencoded(),r.pubBytes(),e),i=this.g.mul(t.S());return t.R().add(r.pub().mul(o)).eq(i)},l.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return i.intFromLE(e.digest()).umod(this.curve.n)},l.prototype.keyFromPublic=function(e){return c.fromPublic(this,e)},l.prototype.keyFromSecret=function(e){return c.fromSecret(this,e)},l.prototype.makeSignature=function(e){return e instanceof u?e:new u(this,e)},l.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},l.prototype.decodePoint=function(e){var t=(e=i.parseBytes(e)).length-1,n=e.slice(0,t).concat(-129&e[t]),r=0!=(128&e[t]),o=i.intFromLE(n);return this.curve.pointFromY(o,r)},l.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},l.prototype.decodeInt=function(e){return i.intFromLE(e)},l.prototype.isPoint=function(e){return e instanceof this.pointClass}},9087:function(e,t,n){"use strict";var r=n(953),o=r.assert,i=r.parseBytes,a=r.cachedProperty;function s(e,t){this.eddsa=e,this._secret=i(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=i(t.pub)}s.fromPublic=function(e,t){return t instanceof s?t:new s(e,{pub:t})},s.fromSecret=function(e,t){return t instanceof s?t:new s(e,{secret:t})},s.prototype.secret=function(){return this._secret},a(s,"pubBytes",(function(){return this.eddsa.encodePoint(this.pub())})),a(s,"pub",(function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())})),a(s,"privBytes",(function(){var e=this.eddsa,t=this.hash(),n=e.encodingLength-1,r=t.slice(0,e.encodingLength);return r[0]&=248,r[n]&=127,r[n]|=64,r})),a(s,"priv",(function(){return this.eddsa.decodeInt(this.privBytes())})),a(s,"hash",(function(){return this.eddsa.hash().update(this.secret()).digest()})),a(s,"messagePrefix",(function(){return this.hash().slice(this.eddsa.encodingLength)})),s.prototype.sign=function(e){return o(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},s.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},s.prototype.getSecret=function(e){return o(this._secret,"KeyPair is public only"),r.encode(this.secret(),e)},s.prototype.getPublic=function(e){return r.encode(this.pubBytes(),e)},e.exports=s},3622:function(e,t,n){"use strict";var r=n(3550),o=n(953),i=o.assert,a=o.cachedProperty,s=o.parseBytes;function c(e,t){this.eddsa=e,"object"!=typeof t&&(t=s(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),i(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof r&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}a(c,"S",(function(){return this.eddsa.decodeInt(this.Sencoded())})),a(c,"R",(function(){return this.eddsa.decodePoint(this.Rencoded())})),a(c,"Rencoded",(function(){return this.eddsa.encodePoint(this.R())})),a(c,"Sencoded",(function(){return this.eddsa.encodeInt(this.S())})),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return o.encode(this.toBytes(),"hex").toUpperCase()},e.exports=c},1037:function(e){e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},953:function(e,t,n){"use strict";var r=t,o=n(3550),i=n(9746),a=n(4504);r.assert=i,r.toArray=a.toArray,r.zero2=a.zero2,r.toHex=a.toHex,r.encode=a.encode,r.getNAF=function(e,t,n){var r=new Array(Math.max(e.bitLength(),n)+1);r.fill(0);for(var o=1<<t+1,i=e.clone(),a=0;a<r.length;a++){var s,c=i.andln(o-1);i.isOdd()?(s=c>(o>>1)-1?(o>>1)-c:c,i.isubn(s)):s=0,r[a]=s,i.iushrn(1)}return r},r.getJSF=function(e,t){var n=[[],[]];e=e.clone(),t=t.clone();for(var r,o=0,i=0;e.cmpn(-o)>0||t.cmpn(-i)>0;){var a,s,c=e.andln(3)+o&3,u=t.andln(3)+i&3;3===c&&(c=-1),3===u&&(u=-1),a=0==(1&c)?0:3!==(r=e.andln(7)+o&7)&&5!==r||2!==u?c:-c,n[0].push(a),s=0==(1&u)?0:3!==(r=t.andln(7)+i&7)&&5!==r||2!==c?u:-u,n[1].push(s),2*o===a+1&&(o=1-o),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return n},r.cachedProperty=function(e,t,n){var r="_"+t;e.prototype[t]=function(){return void 0!==this[r]?this[r]:this[r]=n.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new o(e,"hex","le")}},7680:function(e){function t(e){return e}e.exports=function(e,n,r){n=n||t,r=r||e;for(var o=0,i=e.length;o<i;o+=1)if(n.call(r,e[o],o))return e[o]}},3715:function(e,t,n){var r=t;r.utils=n(6436),r.common=n(5772),r.sha=n(9041),r.ripemd=n(2949),r.hmac=n(2344),r.sha1=r.sha.sha1,r.sha256=r.sha.sha256,r.sha224=r.sha.sha224,r.sha384=r.sha.sha384,r.sha512=r.sha.sha512,r.ripemd160=r.ripemd.ripemd160},5772:function(e,t,n){"use strict";var r=n(6436),o=n(9746);function i(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=i,i.prototype.update=function(e,t){if(e=r.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var n=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-n,e.length),0===this.pending.length&&(this.pending=null),e=r.join32(e,0,e.length-n,this.endian);for(var o=0;o<e.length;o+=this._delta32)this._update(e,o,o+this._delta32)}return this},i.prototype.digest=function(e){return this.update(this._pad()),o(null===this.pending),this._digest(e)},i.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,n=t-(e+this.padLength)%t,r=new Array(n+this.padLength);r[0]=128;for(var o=1;o<n;o++)r[o]=0;if(e<<=3,"big"===this.endian){for(var i=8;i<this.padLength;i++)r[o++]=0;r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=e>>>24&255,r[o++]=e>>>16&255,r[o++]=e>>>8&255,r[o++]=255&e}else for(r[o++]=255&e,r[o++]=e>>>8&255,r[o++]=e>>>16&255,r[o++]=e>>>24&255,r[o++]=0,r[o++]=0,r[o++]=0,r[o++]=0,i=8;i<this.padLength;i++)r[o++]=0;return r}},2344:function(e,t,n){"use strict";var r=n(6436),o=n(9746);function i(e,t,n){if(!(this instanceof i))return new i(e,t,n);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(r.toArray(t,n))}e.exports=i,i.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),o(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},i.prototype.update=function(e,t){return this.inner.update(e,t),this},i.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},2949:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=r.rotl32,a=r.sum32,s=r.sum32_3,c=r.sum32_4,u=o.BlockHash;function l(){if(!(this instanceof l))return new l;u.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function d(e,t,n,r){return e<=15?t^n^r:e<=31?t&n|~t&r:e<=47?(t|~n)^r:e<=63?t&r|n&~r:t^(n|~r)}function f(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function p(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}r.inherits(l,u),t.ripemd160=l,l.blockSize=512,l.outSize=160,l.hmacStrength=192,l.padLength=64,l.prototype._update=function(e,t){for(var n=this.h[0],r=this.h[1],o=this.h[2],u=this.h[3],l=this.h[4],w=n,v=r,m=o,I=u,E=l,S=0;S<80;S++){var O=a(i(c(n,d(S,r,o,u),e[h[S]+t],f(S)),b[S]),l);n=l,l=u,u=i(o,10),o=r,r=O,O=a(i(c(w,d(79-S,v,m,I),e[y[S]+t],p(S)),g[S]),E),w=E,E=I,I=i(m,10),m=v,v=O}O=s(this.h[1],o,I),this.h[1]=s(this.h[2],u,E),this.h[2]=s(this.h[3],l,w),this.h[3]=s(this.h[4],n,v),this.h[4]=s(this.h[0],r,m),this.h[0]=O},l.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"little"):r.split32(this.h,"little")};var h=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],y=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],b=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],g=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},9041:function(e,t,n){"use strict";t.sha1=n(4761),t.sha224=n(799),t.sha256=n(9344),t.sha384=n(772),t.sha512=n(5900)},4761:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=n(7038),a=r.rotl32,s=r.sum32,c=r.sum32_5,u=i.ft_1,l=o.BlockHash,d=[1518500249,1859775393,2400959708,3395469782];function f(){if(!(this instanceof f))return new f;l.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}r.inherits(f,l),e.exports=f,f.blockSize=512,f.outSize=160,f.hmacStrength=80,f.padLength=64,f.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=a(n[r-3]^n[r-8]^n[r-14]^n[r-16],1);var o=this.h[0],i=this.h[1],l=this.h[2],f=this.h[3],p=this.h[4];for(r=0;r<n.length;r++){var h=~~(r/20),y=c(a(o,5),u(h,i,l,f),p,n[r],d[h]);p=f,f=l,l=a(i,30),i=o,o=y}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],l),this.h[3]=s(this.h[3],f),this.h[4]=s(this.h[4],p)},f.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},799:function(e,t,n){"use strict";var r=n(6436),o=n(9344);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=512,i.outSize=224,i.hmacStrength=192,i.padLength=64,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,7),"big"):r.split32(this.h.slice(0,7),"big")}},9344:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=n(7038),a=n(9746),s=r.sum32,c=r.sum32_4,u=r.sum32_5,l=i.ch32,d=i.maj32,f=i.s0_256,p=i.s1_256,h=i.g0_256,y=i.g1_256,b=o.BlockHash,g=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function w(){if(!(this instanceof w))return new w;b.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=g,this.W=new Array(64)}r.inherits(w,b),e.exports=w,w.blockSize=512,w.outSize=256,w.hmacStrength=192,w.padLength=64,w.prototype._update=function(e,t){for(var n=this.W,r=0;r<16;r++)n[r]=e[t+r];for(;r<n.length;r++)n[r]=c(y(n[r-2]),n[r-7],h(n[r-15]),n[r-16]);var o=this.h[0],i=this.h[1],b=this.h[2],g=this.h[3],w=this.h[4],v=this.h[5],m=this.h[6],I=this.h[7];for(a(this.k.length===n.length),r=0;r<n.length;r++){var E=u(I,p(w),l(w,v,m),this.k[r],n[r]),S=s(f(o),d(o,i,b));I=m,m=v,v=w,w=s(g,E),g=b,b=i,i=o,o=s(E,S)}this.h[0]=s(this.h[0],o),this.h[1]=s(this.h[1],i),this.h[2]=s(this.h[2],b),this.h[3]=s(this.h[3],g),this.h[4]=s(this.h[4],w),this.h[5]=s(this.h[5],v),this.h[6]=s(this.h[6],m),this.h[7]=s(this.h[7],I)},w.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},772:function(e,t,n){"use strict";var r=n(6436),o=n(5900);function i(){if(!(this instanceof i))return new i;o.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}r.inherits(i,o),e.exports=i,i.blockSize=1024,i.outSize=384,i.hmacStrength=192,i.padLength=128,i.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h.slice(0,12),"big"):r.split32(this.h.slice(0,12),"big")}},5900:function(e,t,n){"use strict";var r=n(6436),o=n(5772),i=n(9746),a=r.rotr64_hi,s=r.rotr64_lo,c=r.shr64_hi,u=r.shr64_lo,l=r.sum64,d=r.sum64_hi,f=r.sum64_lo,p=r.sum64_4_hi,h=r.sum64_4_lo,y=r.sum64_5_hi,b=r.sum64_5_lo,g=o.BlockHash,w=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function v(){if(!(this instanceof v))return new v;g.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=w,this.W=new Array(160)}function m(e,t,n,r,o){var i=e&n^~e&o;return i<0&&(i+=4294967296),i}function I(e,t,n,r,o,i){var a=t&r^~t&i;return a<0&&(a+=4294967296),a}function E(e,t,n,r,o){var i=e&n^e&o^n&o;return i<0&&(i+=4294967296),i}function S(e,t,n,r,o,i){var a=t&r^t&i^r&i;return a<0&&(a+=4294967296),a}function O(e,t){var n=a(e,t,28)^a(t,e,2)^a(t,e,7);return n<0&&(n+=4294967296),n}function A(e,t){var n=s(e,t,28)^s(t,e,2)^s(t,e,7);return n<0&&(n+=4294967296),n}function T(e,t){var n=a(e,t,14)^a(e,t,18)^a(t,e,9);return n<0&&(n+=4294967296),n}function _(e,t){var n=s(e,t,14)^s(e,t,18)^s(t,e,9);return n<0&&(n+=4294967296),n}function k(e,t){var n=a(e,t,1)^a(e,t,8)^c(e,t,7);return n<0&&(n+=4294967296),n}function x(e,t){var n=s(e,t,1)^s(e,t,8)^u(e,t,7);return n<0&&(n+=4294967296),n}function P(e,t){var n=a(e,t,19)^a(t,e,29)^c(e,t,6);return n<0&&(n+=4294967296),n}function M(e,t){var n=s(e,t,19)^s(t,e,29)^u(e,t,6);return n<0&&(n+=4294967296),n}r.inherits(v,g),e.exports=v,v.blockSize=1024,v.outSize=512,v.hmacStrength=192,v.padLength=128,v.prototype._prepareBlock=function(e,t){for(var n=this.W,r=0;r<32;r++)n[r]=e[t+r];for(;r<n.length;r+=2){var o=P(n[r-4],n[r-3]),i=M(n[r-4],n[r-3]),a=n[r-14],s=n[r-13],c=k(n[r-30],n[r-29]),u=x(n[r-30],n[r-29]),l=n[r-32],d=n[r-31];n[r]=p(o,i,a,s,c,u,l,d),n[r+1]=h(o,i,a,s,c,u,l,d)}},v.prototype._update=function(e,t){this._prepareBlock(e,t);var n=this.W,r=this.h[0],o=this.h[1],a=this.h[2],s=this.h[3],c=this.h[4],u=this.h[5],p=this.h[6],h=this.h[7],g=this.h[8],w=this.h[9],v=this.h[10],k=this.h[11],x=this.h[12],P=this.h[13],M=this.h[14],C=this.h[15];i(this.k.length===n.length);for(var N=0;N<n.length;N+=2){var j=M,D=C,R=T(g,w),L=_(g,w),B=m(g,w,v,k,x),K=I(g,w,v,k,x,P),U=this.k[N],F=this.k[N+1],W=n[N],q=n[N+1],z=y(j,D,R,L,B,K,U,F,W,q),G=b(j,D,R,L,B,K,U,F,W,q);j=O(r,o),D=A(r,o),R=E(r,o,a,s,c),L=S(r,o,a,s,c,u);var $=d(j,D,R,L),H=f(j,D,R,L);M=x,C=P,x=v,P=k,v=g,k=w,g=d(p,h,z,G),w=f(h,h,z,G),p=c,h=u,c=a,u=s,a=r,s=o,r=d(z,G,$,H),o=f(z,G,$,H)}l(this.h,0,r,o),l(this.h,2,a,s),l(this.h,4,c,u),l(this.h,6,p,h),l(this.h,8,g,w),l(this.h,10,v,k),l(this.h,12,x,P),l(this.h,14,M,C)},v.prototype._digest=function(e){return"hex"===e?r.toHex32(this.h,"big"):r.split32(this.h,"big")}},7038:function(e,t,n){"use strict";var r=n(6436).rotr32;function o(e,t,n){return e&t^~e&n}function i(e,t,n){return e&t^e&n^t&n}function a(e,t,n){return e^t^n}t.ft_1=function(e,t,n,r){return 0===e?o(t,n,r):1===e||3===e?a(t,n,r):2===e?i(t,n,r):void 0},t.ch32=o,t.maj32=i,t.p32=a,t.s0_256=function(e){return r(e,2)^r(e,13)^r(e,22)},t.s1_256=function(e){return r(e,6)^r(e,11)^r(e,25)},t.g0_256=function(e){return r(e,7)^r(e,18)^e>>>3},t.g1_256=function(e){return r(e,17)^r(e,19)^e>>>10}},6436:function(e,t,n){"use strict";var r=n(9746),o=n(5717);function i(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=o,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),o=0;o<e.length;o+=2)n.push(parseInt(e[o]+e[o+1],16))}else for(var r=0,o=0;o<e.length;o++){var a=e.charCodeAt(o);a<128?n[r++]=a:a<2048?(n[r++]=a>>6|192,n[r++]=63&a|128):i(e,o)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++o)),n[r++]=a>>18|240,n[r++]=a>>12&63|128,n[r++]=a>>6&63|128,n[r++]=63&a|128):(n[r++]=a>>12|224,n[r++]=a>>6&63|128,n[r++]=63&a|128)}else for(o=0;o<e.length;o++)n[o]=0|e[o];return n},t.toHex=function(e){for(var t="",n=0;n<e.length;n++)t+=s(e[n].toString(16));return t},t.htonl=a,t.toHex32=function(e,t){for(var n="",r=0;r<e.length;r++){var o=e[r];"little"===t&&(o=a(o)),n+=c(o.toString(16))}return n},t.zero2=s,t.zero8=c,t.join32=function(e,t,n,o){var i=n-t;r(i%4==0);for(var a=new Array(i/4),s=0,c=t;s<a.length;s++,c+=4){var u;u="big"===o?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],a[s]=u>>>0}return a},t.split32=function(e,t){for(var n=new Array(4*e.length),r=0,o=0;r<e.length;r++,o+=4){var i=e[r];"big"===t?(n[o]=i>>>24,n[o+1]=i>>>16&255,n[o+2]=i>>>8&255,n[o+3]=255&i):(n[o+3]=i>>>24,n[o+2]=i>>>16&255,n[o+1]=i>>>8&255,n[o]=255&i)}return n},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,n){return e+t+n>>>0},t.sum32_4=function(e,t,n,r){return e+t+n+r>>>0},t.sum32_5=function(e,t,n,r,o){return e+t+n+r+o>>>0},t.sum64=function(e,t,n,r){var o=e[t],i=r+e[t+1]>>>0,a=(i<r?1:0)+n+o;e[t]=a>>>0,e[t+1]=i},t.sum64_hi=function(e,t,n,r){return(t+r>>>0<t?1:0)+e+n>>>0},t.sum64_lo=function(e,t,n,r){return t+r>>>0},t.sum64_4_hi=function(e,t,n,r,o,i,a,s){var c=0,u=t;return c+=(u=u+r>>>0)<t?1:0,c+=(u=u+i>>>0)<i?1:0,e+n+o+a+(c+=(u=u+s>>>0)<s?1:0)>>>0},t.sum64_4_lo=function(e,t,n,r,o,i,a,s){return t+r+i+s>>>0},t.sum64_5_hi=function(e,t,n,r,o,i,a,s,c,u){var l=0,d=t;return l+=(d=d+r>>>0)<t?1:0,l+=(d=d+i>>>0)<i?1:0,l+=(d=d+s>>>0)<s?1:0,e+n+o+a+c+(l+=(d=d+u>>>0)<u?1:0)>>>0},t.sum64_5_lo=function(e,t,n,r,o,i,a,s,c,u){return t+r+i+s+u>>>0},t.rotr64_hi=function(e,t,n){return(t<<32-n|e>>>n)>>>0},t.rotr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0},t.shr64_hi=function(e,t,n){return e>>>n},t.shr64_lo=function(e,t,n){return(e<<32-n|t>>>n)>>>0}},2156:function(e,t,n){"use strict";var r=n(3715),o=n(4504),i=n(9746);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=o.toArray(e.entropy,e.entropyEnc||"hex"),n=o.toArray(e.nonce,e.nonceEnc||"hex"),r=o.toArray(e.pers,e.persEnc||"hex");i(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,n,r)}e.exports=a,a.prototype._init=function(e,t,n){var r=e.concat(t).concat(n);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var o=0;o<this.V.length;o++)this.K[o]=0,this.V[o]=1;this._update(r),this._reseed=1,this.reseedInterval=281474976710656},a.prototype._hmac=function(){return new r.hmac(this.hash,this.K)},a.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},a.prototype.reseed=function(e,t,n,r){"string"!=typeof t&&(r=n,n=t,t=null),e=o.toArray(e,t),n=o.toArray(n,r),i(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(n||[])),this._reseed=1},a.prototype.generate=function(e,t,n,r){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(r=n,n=t,t=null),n&&(n=o.toArray(n,r||"hex"),this._update(n));for(var i=[];i.length<e;)this.V=this._hmac().update(this.V).digest(),i=i.concat(this.V);var a=i.slice(0,e);return this._update(n),this._reseed++,o.encode(a,t)}},5717:function(e){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var n=function(){};n.prototype=t.prototype,e.prototype=new n,e.prototype.constructor=e}}},9746:function(e){function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,n){if(e!=t)throw new Error(n||"Assertion failed: "+e+" != "+t)}},4504:function(e,t){"use strict";var n=t;function r(e){return 1===e.length?"0"+e:e}function o(e){for(var t="",n=0;n<e.length;n++)t+=r(e[n].toString(16));return t}n.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var n=[];if("string"!=typeof e){for(var r=0;r<e.length;r++)n[r]=0|e[r];return n}if("hex"===t){(e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e);for(r=0;r<e.length;r+=2)n.push(parseInt(e[r]+e[r+1],16))}else for(r=0;r<e.length;r++){var o=e.charCodeAt(r),i=o>>8,a=255&o;i?n.push(i,a):n.push(a)}return n},n.zero2=r,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},2719:function(e){var t=e.exports=function(e,n){if("function"==typeof e||n)return t.by(e,n);for(var r={object:[],function:[],string:{},number:{},boolean:{},undefined:{}},o=[],i=0;i<e.length;i++){var a=e[i],s="__proto__"===a?r.objects:r[typeof a]||r.objects;Array.isArray(s)?s.indexOf(a)<0&&(s.push(a),o.push(a)):Object.hasOwnProperty.call(s,a)||(s[a]=!0,o.push(a))}return o};t.by=function(e,t){if("function"==typeof e){var n=t;t=e,e=n}for(var r=[],o=0;o<e.length;o++){for(var i=e[o],a=!1,s=0;s<r.length;s++){var c=r[s];if(t.call(r,i,c)){a=!0;break}}a||r.push(i)}return r}},7635:function(e){"use strict";!function(t){var n=2147483647;function r(e){var t=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],n=1779033703,r=3144134277,o=1013904242,i=2773480762,a=1359893119,s=2600822924,c=528734635,u=1541459225,l=new Array(64);function d(e){for(var d=0,f=e.length;f>=64;){var p,h,y,b,g,w=n,v=r,m=o,I=i,E=a,S=s,O=c,A=u;for(h=0;h<16;h++)y=d+4*h,l[h]=(255&e[y])<<24|(255&e[y+1])<<16|(255&e[y+2])<<8|255&e[y+3];for(h=16;h<64;h++)b=((p=l[h-2])>>>17|p<<15)^(p>>>19|p<<13)^p>>>10,g=((p=l[h-15])>>>7|p<<25)^(p>>>18|p<<14)^p>>>3,l[h]=(b+l[h-7]|0)+(g+l[h-16]|0)|0;for(h=0;h<64;h++)b=(((E>>>6|E<<26)^(E>>>11|E<<21)^(E>>>25|E<<7))+(E&S^~E&O)|0)+(A+(t[h]+l[h]|0)|0)|0,g=((w>>>2|w<<30)^(w>>>13|w<<19)^(w>>>22|w<<10))+(w&v^w&m^v&m)|0,A=O,O=S,S=E,E=I+b|0,I=m,m=v,v=w,w=b+g|0;n=n+w|0,r=r+v|0,o=o+m|0,i=i+I|0,a=a+E|0,s=s+S|0,c=c+O|0,u=u+A|0,d+=64,f-=64}}d(e);var f,p=e.length%64,h=e.length/536870912|0,y=e.length<<3,b=p<56?56:120,g=e.slice(e.length-p,e.length);for(g.push(128),f=p+1;f<b;f++)g.push(0);return g.push(h>>>24&255),g.push(h>>>16&255),g.push(h>>>8&255),g.push(h>>>0&255),g.push(y>>>24&255),g.push(y>>>16&255),g.push(y>>>8&255),g.push(y>>>0&255),d(g),[n>>>24&255,n>>>16&255,n>>>8&255,n>>>0&255,r>>>24&255,r>>>16&255,r>>>8&255,r>>>0&255,o>>>24&255,o>>>16&255,o>>>8&255,o>>>0&255,i>>>24&255,i>>>16&255,i>>>8&255,i>>>0&255,a>>>24&255,a>>>16&255,a>>>8&255,a>>>0&255,s>>>24&255,s>>>16&255,s>>>8&255,s>>>0&255,c>>>24&255,c>>>16&255,c>>>8&255,c>>>0&255,u>>>24&255,u>>>16&255,u>>>8&255,u>>>0&255]}function o(e,t,n){var o;e=e.length<=64?e:r(e);var i=64+t.length+4,a=new Array(i),s=new Array(64),c=[];for(o=0;o<64;o++)a[o]=54;for(o=0;o<e.length;o++)a[o]^=e[o];for(o=0;o<t.length;o++)a[64+o]=t[o];for(o=i-4;o<i;o++)a[o]=0;for(o=0;o<64;o++)s[o]=92;for(o=0;o<e.length;o++)s[o]^=e[o];function u(){for(var e=i-1;e>=i-4;e--){if(a[e]++,a[e]<=255)return;a[e]=0}}for(;n>=32;)u(),c=c.concat(r(s.concat(r(a)))),n-=32;return n>0&&(u(),c=c.concat(r(s.concat(r(a))).slice(0,n))),c}function i(e,t,n,r,o){var i;for(u(e,16*(2*n-1),o,0,16),i=0;i<2*n;i++)c(e,16*i,o,16),s(o,r),u(o,0,e,t+16*i,16);for(i=0;i<n;i++)u(e,t+2*i*16,e,16*i,16);for(i=0;i<n;i++)u(e,t+16*(2*i+1),e,16*(i+n),16)}function a(e,t){return e<<t|e>>>32-t}function s(e,t){u(e,0,t,0,16);for(var n=8;n>0;n-=2)t[4]^=a(t[0]+t[12],7),t[8]^=a(t[4]+t[0],9),t[12]^=a(t[8]+t[4],13),t[0]^=a(t[12]+t[8],18),t[9]^=a(t[5]+t[1],7),t[13]^=a(t[9]+t[5],9),t[1]^=a(t[13]+t[9],13),t[5]^=a(t[1]+t[13],18),t[14]^=a(t[10]+t[6],7),t[2]^=a(t[14]+t[10],9),t[6]^=a(t[2]+t[14],13),t[10]^=a(t[6]+t[2],18),t[3]^=a(t[15]+t[11],7),t[7]^=a(t[3]+t[15],9),t[11]^=a(t[7]+t[3],13),t[15]^=a(t[11]+t[7],18),t[1]^=a(t[0]+t[3],7),t[2]^=a(t[1]+t[0],9),t[3]^=a(t[2]+t[1],13),t[0]^=a(t[3]+t[2],18),t[6]^=a(t[5]+t[4],7),t[7]^=a(t[6]+t[5],9),t[4]^=a(t[7]+t[6],13),t[5]^=a(t[4]+t[7],18),t[11]^=a(t[10]+t[9],7),t[8]^=a(t[11]+t[10],9),t[9]^=a(t[8]+t[11],13),t[10]^=a(t[9]+t[8],18),t[12]^=a(t[15]+t[14],7),t[13]^=a(t[12]+t[15],9),t[14]^=a(t[13]+t[12],13),t[15]^=a(t[14]+t[13],18);for(n=0;n<16;++n)e[n]+=t[n]}function c(e,t,n,r){for(var o=0;o<r;o++)n[o]^=e[t+o]}function u(e,t,n,r,o){for(;o--;)n[r++]=e[t++]}function l(e){if(!e||"number"!=typeof e.length)return!1;for(var t=0;t<e.length;t++){if("number"!=typeof e[t])return!1;var n=parseInt(e[t]);if(n!=e[t]||n<0||n>=256)return!1}return!0}function d(e,t){var n=parseInt(e);if(e!=n)throw new Error("invalid "+t);return n}e.exports=function(e,t,r,a,s,f,p){if(!p)throw new Error("missing callback");if(r=d(r,"N"),a=d(a,"r"),s=d(s,"p"),f=d(f,"dkLen"),0===r||0!=(r&r-1))throw new Error("N must be power of 2");if(r>n/128/a)throw new Error("N too large");if(a>n/128/s)throw new Error("r too large");if(!l(e))throw new Error("password must be an array or buffer");if(!l(t))throw new Error("salt must be an array or buffer");for(var h=o(e,t,128*s*a),y=new Uint32Array(32*s*a),b=0;b<y.length;b++){var g=4*b;y[b]=(255&h[g+3])<<24|(255&h[g+2])<<16|(255&h[g+1])<<8|(255&h[g+0])<<0}var w,v,m=new Uint32Array(64*a),I=new Uint32Array(32*a*r),E=32*a,S=new Uint32Array(16),O=new Uint32Array(16),A=s*r*2,T=0,_=null,k=!1,x=0,P=0,M=parseInt(1e3/a),C="undefined"!=typeof setImmediate?setImmediate:setTimeout,N=function(){if(k)return p(new Error("cancelled"),T/A);switch(x){case 0:u(y,v=32*P*a,m,0,E),x=1,w=0;case 1:(n=r-w)>M&&(n=M);for(var t=0;t<n;t++)u(m,0,I,(w+t)*E,E),i(m,E,a,S,O);if(w+=n,T+=n,(l=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=l}if(w<r)break;w=0,x=2;case 2:var n,l;for((n=r-w)>M&&(n=M),t=0;t<n;t++){var d=m[16*(2*a-1)]&r-1;c(I,d*E,m,E),i(m,E,a,S,O)}if(w+=n,T+=n,(l=parseInt(1e3*T/A))!==_){if(k=p(null,T/A))break;_=l}if(w<r)break;if(u(m,0,y,v,E),++P<s){x=0;break}for(h=[],t=0;t<y.length;t++)h.push(y[t]>>0&255),h.push(y[t]>>8&255),h.push(y[t]>>16&255),h.push(y[t]>>24&255);var b=o(e,h,f);return p(null,1,b)}C(N)};N()}}()},7716:function(e,t){"use strict";function n(e,t,n,r,o,i,a){try{var s=e[i](a),c=s.value}catch(u){return void n(u)}s.done?t(c):Promise.resolve(c).then(r,o)}function r(e){return function(){var t=this,r=arguments;return new Promise((function(o,i){var a=e.apply(t,r);function s(e){n(a,o,i,s,c,"next",e)}function c(e){n(a,o,i,s,c,"throw",e)}s(void 0)}))}}function o(){return o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o.apply(this,arguments)}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function a(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(n)return(n=n.call(e)).next.bind(n);if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return i(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?i(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s={parse:function(e){for(var t=encodeURI(e),n=new Uint8Array(t.length),r=0,o=0;o<t.length;++o){var i=t.charCodeAt(o);37===i?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=i}return n.subarray(0,r)},stringify:function(e){for(var t="",n=0;n<e.length;++n){var r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)}};function c(e){var t=e.body,n=void 0===t?"":t,o=e.headers,i=void 0===o?{}:o,a=e.status,c=void 0===a?200:a,l=Promise.resolve(n),d={headers:u(i),ok:c>=200&&c<300,status:c,arrayBuffer:function(){return r((function*(){return yield l.then((function(e){return"string"==typeof e?s.parse(e).buffer:e}))}))()},json:function(){return r((function*(){return yield d.text().then((function(e){return JSON.parse(e)}))}))()},text:function(){return r((function*(){return yield l.then((function(e){return"string"==typeof e?e:s.stringify(new Uint8Array(e))}))}))()}};return d}function u(e){var t={forEach:function(t,n){for(var r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];t.call(n,e[i],i)}},get:function(n){return t.has(n)?e[n]:null},has:function(t){return Object.prototype.hasOwnProperty.call(e,t)}};return t}t.hd=function(e){return function(){var t=r((function*(t,n){void 0===n&&(n={});var r=n,i=r.body,a=void 0===i?"":i,u=r.method,l=void 0===u?"GET":u,d=r.headers,f=void 0===d?{}:d,p=new URL(t),h=p.host,y={method:l,path:p.pathname+p.search,version:"HTTP/1.1",headers:o({},f,{host:h}),body:"string"==typeof a?s.parse(a):new Uint8Array(a)};return c(yield e(y))}));return function(e,n){return t.apply(this,arguments)}}()},t.O7=c,t.h6=function(e){for(var t={},n=0,r=Object.keys(e);n<r.length;n++){var o=r[n];t[o.toUpperCase()]=e[o]}null==t.OPTIONS&&(t.OPTIONS=function(){return{status:204,headers:i}});var i={"content-length":"0",allow:Object.keys(t).join(", ")};return function(e){var n=t[e.method];return null!=n?n(e):{status:405,headers:i}}},t.Fl=function(e,t){void 0===t&&(t=function(){return{status:404}});for(var n=[],r=0,o=Object.keys(e);r<o.length;r++){var i=o[r];n.push({regexp:new RegExp("^"+i+"$"),server:e[i]})}return function(e){for(var r,o=a(n);!(r=o()).done;){var i=r.value,s=i.regexp,c=i.server;if(s.test(e.path))return c(e)}return t(e)}},t.o3=function(e){return function(){var t=r((function*(t){var n=yield e(t),r=n.headers;return o({},n,{headers:o({},void 0===r?{}:r,{"Access-Control-Allow-Origin":"*","Access-Control-Allow-Headers":"Accept, Authorization, Content-Type","Access-Control-Allow-Methods":"DELETE, GET, OPTIONS, POST, PUT"})})}));return function(e){return t.apply(this,arguments)}}()}},8326:function(e,t,n){"use strict";e.exports=n.p+"2088bbb2041078df2819.js"},6601:function(){},9214:function(){},5352:function(e,t){"use strict";function n(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function r(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}Object.defineProperty(t,"__esModule",{value:!0});var o={chars:"0123456789ABCDEF",bits:4},i={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},a={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},s={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},u={parse:function(e,t){return n(e.toUpperCase(),o,t)},stringify:function(e,t){return r(e,o,t)}},l={parse:function(e,t){return void 0===t&&(t={}),n(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,i,t)},stringify:function(e,t){return r(e,i,t)}},d={parse:function(e,t){return n(e,a,t)},stringify:function(e,t){return r(e,a,t)}},f={parse:function(e,t){return n(e,s,t)},stringify:function(e,t){return r(e,s,t)}},p={parse:function(e,t){return n(e,c,t)},stringify:function(e,t){return r(e,c,t)}},h={parse:n,stringify:r};t.base16=u,t.base32=l,t.base32hex=d,t.base64=f,t.base64url=p,t.codec=h},8597:function(e){"use strict";e.exports={i8:"6.5.4"}}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={id:r,loaded:!1,exports:{}};return e[r].call(i.exports,i,i.exports,n),i.loaded=!0,i.exports}n.m=e,n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,{a:t}),t},n.d=function(e,t){for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.nmd=function(e){return e.paths=[],e.children||(e.children=[]),e},function(){var e;n.g.importScripts&&(e=n.g.location+"");var t=n.g.document;if(!e&&t&&(t.currentScript&&(e=t.currentScript.src),!e)){var r=t.getElementsByTagName("script");if(r.length)for(var o=r.length-1;o>-1&&!e;)e=r[o--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),n.p=e}(),n.b=document.baseURI||self.location.href,function(){"use strict";function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t){var n=function(t,n){if("object"!==e(t)||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,n||"default");if("object"!==e(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===n?String:Number)(t)}(t,"string");return"symbol"===e(n)?n:String(n)}function r(e,n,r){return(n=t(n))in e?Object.defineProperty(e,n,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[n]=r,e}var o=n(3715),i=n.n(o),a=n(2156),s=n.n(a);function c(e,t,n){var r;if(void 0===n&&(n={}),!t.codes){t.codes={};for(var o=0;o<t.chars.length;++o)t.codes[t.chars[o]]=o}if(!n.loose&&e.length*t.bits&7)throw new SyntaxError("Invalid padding");for(var i=e.length;"="===e[i-1];)if(--i,!(n.loose||(e.length-i)*t.bits&7))throw new SyntaxError("Invalid padding");for(var a=new(null!=(r=n.out)?r:Uint8Array)(i*t.bits/8|0),s=0,c=0,u=0,l=0;l<i;++l){var d=t.codes[e[l]];if(void 0===d)throw new SyntaxError("Invalid character "+e[l]);c=c<<t.bits|d,(s+=t.bits)>=8&&(s-=8,a[u++]=255&c>>s)}if(s>=t.bits||255&c<<8-s)throw new SyntaxError("Unexpected end of data");return a}function u(e,t,n){void 0===n&&(n={});for(var r=n.pad,o=void 0===r||r,i=(1<<t.bits)-1,a="",s=0,c=0,u=0;u<e.length;++u)for(c=c<<8|255&e[u],s+=8;s>t.bits;)s-=t.bits,a+=t.chars[i&c>>s];if(s&&(a+=t.chars[i&c<<t.bits-s]),o)for(;a.length*t.bits&7;)a+="=";return a}var l={chars:"0123456789ABCDEF",bits:4},d={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},f={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},p={parse:function(e,t){return c(e.toUpperCase(),l,t)},stringify:function(e,t){return u(e,l,t)}},h={parse:function(e,t){return void 0===t&&(t={}),c(t.loose?e.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):e,d,t)},stringify:function(e,t){return u(e,d,t)}},y={parse:function(e,t){return c(e,f,t)},stringify:function(e,t){return u(e,f,t)}},b=n(7716);const g=b.hd,w=b.O7,v=b.h6,m=b.Fl;b.o3;function I(){return I=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},I.apply(this,arguments)}var E="_yaob",S=1,O={};function A(e,t){Object.prototype.hasOwnProperty.call(e,E)?I(e[E],t):Object.defineProperty(e,E,{value:t})}function T(e){var t=e.prototype;if(!Object.prototype.hasOwnProperty.call(t,E)){A(t,{})}return e}function _(e){Object.prototype.hasOwnProperty.call(e,E)&&null!=e[E].localId||A(e,{localId:S++,bridges:[],listeners:{},watchers:{}});return e}function k(e){if(null==e[E])throw new TypeError("Not a bridgeable object");return _(e),e[E]}function x(e,t){null==t?t="":t+=".";for(var n=0,r=Object.getOwnPropertyNames(e);n<r.length;n++){var o=r[n],i=t+o;if(null!=O[i])throw new Error("A shared value named "+i+" already exists");O[i]=e[o],A(e[o],{shareId:i})}}function P(e,t){try{var n=N(e,t),r=j(e,n,t);return""!==n?{map:n,raw:r}:{raw:r}}catch(t){return M(e,t)}}function M(e,t){var n=N(e,t);return{map:n,raw:j(e,n,t),throw:!0}}function C(e,t,n,r){void 0===r&&(r=!1);var o=t.map,i=t.raw,a=null!=o?D(e,o,i,n,r):i;if(t.throw)throw a;return a}function N(e,t){switch(typeof t){case"boolean":case"number":case"string":return"";case"object":if(null===t)return"";if(t instanceof Date)return"d";if(t instanceof Error)return"e";if(t instanceof ArrayBuffer)return"ab";if(t instanceof Uint8Array)return"u8";if(t instanceof Map)return"M";if(t instanceof Set)return"S";if(null!=t[E])return null!=t[E].shareId?"s":"o";if(Array.isArray(t)){for(var n="",r=0;r<t.length;++r){var o=N(e,t[r]);if(""!==o&&""===n){n=[];for(var i=0;i<r;++i)n[i]=""}""!==n&&(n[r]=o)}return n}var a="";for(var s in t){var c=N(e,t[s]);""!==c&&(""===a&&(a={}),a[s]=c)}return a;case"undefined":return"u";case"function":return null!=t[E]&&null!=t[E].shareId?"s":"?";default:return"?"}}function j(e,t,n){switch(t){case"":return n;case"?":return typeof n;case"d":return n.toISOString();case"e":return function(e,t){var n=I({message:t.message,stack:t.stack},t),r=null;return t instanceof EvalError?r="EvalError":t instanceof RangeError?r="RangeError":t instanceof ReferenceError?r="ReferenceError":t instanceof SyntaxError?r="SyntaxError":t instanceof TypeError?r="TypeError":t instanceof URIError&&(r="URIError"),I({base:r},P(e,n))}(e,n);case"o":return e.getPackedId(n);case"s":return n[E].shareId;case"u":return null;case"ab":return y.stringify(new Uint8Array(n));case"u8":return y.stringify(n);case"M":return P(e,Array.from(n.entries()));case"S":return P(e,Array.from(n.values()));default:if(Array.isArray(t)){for(var r=[],o=0;o<t.length;++o)r[o]=j(e,t[o],n[o]);return r}var i={};for(var a in n)i[a]=a in t?j(e,t[a],n[a]):n[a];return i}}function D(e,t,n,r,o){switch(t){case"":return n;case"?":throw new TypeError("Unsupported value of type "+("string"==typeof n?n:"?")+" at "+r);case"d":return new Date(n);case"e":if("object"!=typeof n||null===n)throw new TypeError("Expecting an error description at "+r);return function(e,t,n){var r={EvalError:EvalError,RangeError:RangeError,ReferenceError:ReferenceError,SyntaxError:SyntaxError,TypeError:TypeError,URIError:URIError},o=new(null!=t.base&&r[t.base]||Error),i=C(e,t,n,!0);for(var a in i)o[a]=i[a];return o}(e,n,r);case"o":if(null===n)throw new TypeError("Closed bridge object at "+r);if("number"!=typeof n)throw new TypeError("Expecting a packedId at "+r);var i=e.getObject(-n);if(null==i)throw new RangeError("Invalid packedId "+n+" at "+r);return i;case"s":if("string"!=typeof n)throw new TypeError("Expecting a shareId at "+r);var a=O[n];if(null==a)throw new RangeError("Invalid shareId '"+n+"' at "+r);return a;case"u":return;case"ab":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return y.parse(n).buffer;case"u8":if("string"!=typeof n)throw new TypeError("Expecting a base64 string at "+r);return y.parse(n);case"M":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Map description at "+r);return new Map(C(e,n,r));case"S":if("object"!=typeof n||null===n)throw new TypeError("Expecting an Set description at "+r);return new Set(C(e,n,r));default:if("object"!=typeof t||null===t)throw new TypeError("Invalid type information "+t+" at "+r);if("object"!=typeof n||null===n)throw new TypeError("Expecting an array or object at "+r);if(Array.isArray(t)){if(!Array.isArray(n))throw new TypeError("Expecting an array at "+r);for(var s=[],c=0;c<t.length;++c)!0===o&&"?"===t[c]||(s[c]=D(e,t[c],n[c],r+"["+c+"]",o));return s}var u={};for(var l in n)!0===o&&"?"===t[l]||(u[l]=l in t?D(e,t[l],n[l],r+"."+l,o):n[l]);return u}}var R={};function L(e,t,n){var r=k(e),o=r.closed,i=r.listeners;return o?function(){}:(null==i[t]?i[t]=[n]:i[t].push(n),function(){i[t]=i[t].filter((function(e){return e!==n}))})}function B(e){var t=k(e),n=t.listeners.close;if(null!=n)for(var r=0;r<n.length;r++){F(e,n[r],void 0,!0)}t.closed=!0;for(var o=0,i=t.bridges;o<i.length;o++){i[o].emitClose(t.localId)}t.bridges=[],t.listeners={},t.watchers={}}function K(e,t,n){var r=k(e);if(r.closed)throw new Error("Cannot emit event on closed object");for(var o=0,i=r.bridges;o<i.length;o++){i[o].emitEvent(r.localId,t,n)}var a=r.listeners[t];if(null!=a)for(var s=0;s<a.length;s++){F(e,a[s],n,"error"!==t)}}function U(e,t){var n=k(e);if(n.closed)throw new Error("Cannot update closed object");for(var r=0,o=n.bridges;r<o.length;r++){o[r].markDirty(n.localId,t)}for(var i in null!=t&&null!=n.watchers[t]&&(n.watchers[t].data=R),n.watchers){var a=n.watchers[i];try{var s=e[i];if(s!==a.data){a.data=s;for(var c=0,u=a.fs;c<u.length;c++){F(e,u[c],a.data,!0)}}}catch(l){}}}function F(e,t,n,r){try{var o=t(n);r&&null!=o&&"function"==typeof o.then&&o.then(void 0,(function(t){return K(e,"error",t)}))}catch(i){r&&K(e,"error",i)}}var W={};function q(e,t,n){var r=!1,o={};for(var i in n)try{var a=t[i];a!==n[i]&&(r=!0,o[i]=P(e,a),n[i]=a)}catch(s){o[i]=M(e,s),n[i]=W}return{dirty:r,props:o}}function z(e,t){var n,r={},o=(n=t.localId,{localId:S++,bridges:[],listeners:{},watchers:{},remoteId:n,errors:{},props:{}});for(var i in r[E]={value:o},t.props)r[i]={enumerable:e.hideProperties.indexOf(i)<0,get:$(o,i)};for(var a=0,s=t.methods;a<s.length;a++){var c=s[a];r[c]={value:H(e,o,c)}}return Object.create(Object.prototype,r)}function G(e,t,n){var r=t[E];for(var o in n)try{r.props[o]=C(e,n[o],o),r.errors[o]=!1}catch(i){r.props[o]=i,r.errors[o]=!0}}function $(e,t){return function(){if(e.errors[t])throw e.props[t];return e.props[t]}}function H(e,t,n){return function(){if(t.closed)return Promise.reject(new TypeError("Cannot call method '"+n+"' of closed proxy"));for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];return e.emitCall(t.remoteId,n,o)}}var Y=function(){function e(e){var t=e.hideProperties,n=void 0===t?[]:t,r=e.sendMessage,o=e.throttleMs,i=void 0===o?0:o;this.hideProperties=n,this.sendMessage=r,this.throttleMs=i,this.proxies={},this.objects={},this.caches={},this.nextCallId=0,this.pendingCalls={},this.dirty={},this.message={},this.lastUpdate=0,this.sendPending=!1}var t=e.prototype;return t.close=function(e){for(var t in this.pendingCalls){this.pendingCalls[Number(t)].reject(e)}for(var n in this.proxies)B(this.proxies[Number(n)]);this.closed=!0},t.getObject=function(e){return e<0?this.proxies[-e]:this.objects[e]},t.getPackedId=function(e){var t=k(e);if(t.closed)return null;if(null!=t.remoteId&&null!=this.proxies[t.remoteId])return-t.remoteId;if(null==this.objects[t.localId]){this.objects[t.localId]=e;var n=function(e,t){for(var n={},r=Object.prototype,o=t;o!==r&&null!=o;o=Object.getPrototypeOf(o))for(var i=0,a=Object.getOwnPropertyNames(o);i<a.length;i++){var s=a[i];s===E||/^_/.test(s)||"constructor"===s||(n[s]=!0)}var c={},u=[],l={};for(var d in n)try{var f=t[d];"function"!=typeof f||null!=f[E]&&null!=f[E].shareId?(c[d]=f,l[d]=P(e,f)):u.push(d)}catch(p){c[d]=W,l[d]=M(e,p)}return{cache:c,create:{localId:k(t).localId,methods:u,props:l}}}(this,e),r=n.cache,o=n.create;this.caches[t.localId]=r,t.bridges.push(this),this.emitCreate(o,e)}return t.localId},t.markDirty=function(e,t){var n=this.caches[e];null!=t&&t in n&&(n[t]=W),this.dirty[e]={cache:n,object:this.objects[e]},this.wakeup()},t.emitClose=function(e){delete this.objects[e],delete this.caches[e],null==this.message.closed&&(this.message.closed=[]),this.message.closed.push(e),this.wakeup()},t.emitCreate=function(e,t){null==this.message.created&&(this.message.created=[]),this.message.created.push(e)},t.emitCall=function(e,t,n){var r=this,o=this.nextCallId++,i=I({callId:o,remoteId:e,name:t},P(this,n));return null==this.message.calls&&(this.message.calls=[]),this.message.calls.push(i),this.wakeup(),new Promise((function(e,n){r.pendingCalls[o]={name:t,resolve:e,reject:n}}))},t.emitEvent=function(e,t,n){var r=I({localId:e,name:t},P(this,n));null==this.message.events&&(this.message.events=[]),this.message.events.push(r),this.wakeup()},t.emitReturn=function(e,t,n){var r=I({callId:e},t?M(this,n):P(this,n));null==this.message.returns&&(this.message.returns=[]),this.message.returns.push(r),this.wakeup()},t.handleMessage=function(e){var t=this;if(e.created){for(var n=0,r=e.created;n<r.length;n++){var o=r[n];this.proxies[o.localId]=z(this,o)}for(var i=0,a=e.created;i<a.length;i++){var s=a[i];G(this,this.proxies[s.localId],s.props)}}if(e.changed){for(var c=0,u=e.changed;c<u.length;c++){var l=u[c],d=l.localId,f=l.props,p=this.proxies[d];if(null==p)throw new RangeError("Invalid localId "+d);G(this,p,f)}for(var h=0,y=e.changed;h<y.length;h++){var b=y[h];U(this.proxies[b.localId])}}if(e.events)for(var g=0,w=e.events;g<w.length;g++){var v=w[g],m=v.localId,I=v.name,E=0===m?this:this.proxies[m];if(null!=E)try{K(E,I,C(this,v,I))}catch(R){K(E,"error",R)}}if(e.calls)for(var S=function(e,n){var r=n[e],o=r.callId,i=r.remoteId,a=r.name;try{var s=t.objects[i];if(null==s)throw new TypeError("Cannot call method '"+a+"' of closed proxy (remote)");if("function"!=typeof s[a])throw new TypeError("'"+a+"' is not a function");var c=C(t,r,a+".arguments");Promise.resolve(s[a].apply(s,c)).then((function(e){return t.emitReturn(o,!1,e)}),(function(e){return t.emitReturn(o,!0,e)}))}catch(R){t.emitReturn(o,!0,R)}},O=0,A=e.calls;O<A.length;O++)S(O,A);if(e.returns)for(var T=0,_=e.returns;T<_.length;T++){var k=_[T],x=k.callId,P=this.pendingCalls[x];if(null==P)throw new RangeError("Invalid callId "+x);try{P.resolve(C(this,k,P.name+".return"))}catch(R){P.reject(R)}finally{delete this.pendingCalls[x]}}if(e.closed)for(var M=0,N=e.closed;M<N.length;M++){var j=N[M],D=this.proxies[j];if(null==D)return;delete this.proxies[j],B(D)}},t.sendNow=function(){if(!this.closed){for(var e in this.dirty){var t=Number(e),n=this.dirty[t],r=q(this,n.object,n.cache),o=r.dirty,i=r.props;if(o){var a={localId:t,props:i};null==this.message.changed&&(this.message.changed=[]),this.message.changed.push(a)}}var s=this.message;this.dirty={},this.message={},null==s.calls&&null==s.changed&&null==s.closed&&null==s.created&&null==s.events&&null==s.returns||this.sendMessage(s)}},t.wakeup=function(){var e=this;if(!this.sendPending){this.sendPending=!0;var t=this.lastUpdate+this.throttleMs-Date.now();setTimeout((function(){e.sendPending=!1,e.lastUpdate=Date.now(),e.sendNow()}),t<0?0:t)}},e}();T(Y);var V=function(){function e(e){var t=this;this._state=new Y(e),this._rootPromise=new Promise((function(e){return L(t._state,"root",e)}))}var t=e.prototype;return t.handleMessage=function(e){this._state.handleMessage(e)},t.getRoot=function(){return this._rootPromise},t.sendRoot=function(e){this._state.emitEvent(0,"root",e)},t.close=function(e){this._state.close(e)},e}();var J=function(e,t){return L(this,e,t)},X=function(e,t){return function(e,t,n){var r=k(e),o=r.closed,i=r.watchers,a=e[t];return o?function(){}:(null==i[t]?i[t]={data:a,fs:[n]}:i[t].fs.push(n),function(){i[t].fs=i[t].fs.filter((function(e){return e!==n}))})}(this,e,t)};x({onMethod:J,watchMethod:X});var Z=function(){function e(){}var t=e.prototype;return t._close=function(){B(this)},t._emit=function(e,t){return K(this,e,t)},t._update=function(e){U(this,e)},e}(),Q=Z.prototype;Q.on=J,Q.watch=X,T(Z);var ee=n(4638);n(7635);class te{getFirstWalletInfo(e){return this.allKeys.find((t=>t.type===e))}getWalletInfo(e){return this.allKeys.find((t=>t.id===e))}listWalletIds(){return this.allKeys.map((e=>e.id))}}function ne(e){const t=e.length<10,n=!/[0-9]/.test(e),r=!/[a-z]/.test(e),o=!/[A-Z]/.test(e),i=(/[0-9]/.test(e)?10:0)+(/[A-Z]/.test(e)?26:0)+(/[a-z]/.test(e)?26:0)+(/[^0-9A-Za-z]/.test(e)?30:0);return{secondsToCrack:Math.pow(i,e.length)/1e6,tooShort:t,noNumber:n,noLowerCase:r,noUpperCase:o,passed:e.length>=16||!(t||n||o||r)}}function re(e){const t=e.toLowerCase().replace(/[ \f\r\n\t\v]+/g," ").replace(/ $/,"").replace(/^ /,"");for(let n=0;n<t.length;++n){const e=t.charCodeAt(n);if(e<32||e>126)throw new Error("Bad characters in username")}return t}function oe(e){let t,n=!1;const r={next:async()=>{if(null==t&&(t=await this.$internalStreamTransactions(e)),!n){const e=await t.next();if(!e.done)return e;B(t),n=!0}return{done:!0,value:void 0}},return:async()=>(null==t||n||(B(t),n=!0),{done:!0,value:void 0}),[Symbol.asyncIterator]:()=>r};return r}function ie(e){switch(typeof e){case"function":case"object":return null==e?"null":Array.isArray(e)?"array":typeof e;case"string":return JSON.stringify(e);default:return String(e)}}function ae(e,t){return function(n){return null!=n?e(n):"function"==typeof t?t():t}}function se(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;++n)if(e===t[n])return e;var r="Expected ";1!==t.length&&(r+="one of: ");for(var o=0;o<t.length;++o)o>0&&(r+=" | "),r+=JSON.stringify(t[o]);throw r+=", got "+ie(e),new TypeError(r)}}function ce(e){if("boolean"!=typeof e)throw new TypeError("Expected a boolean, got "+ie(e));return e}function ue(e){if("number"!=typeof e)throw new TypeError("Expected a number, got "+ie(e));return e}function le(e){if("string"!=typeof e)throw new TypeError("Expected a string, got "+ie(e));return e}x(te.prototype,"AccountSync"),x({checkPasswordRules:ne}),x({fixUsername:re}),x({streamTransactions:oe},"CurrencyWalletSync");var de=se(null);se(void 0);function fe(e){return e}ae(de);function pe(e,t,n){return e instanceof Error&&(null==e.insertStepAt&&(e.message+=" at ",e.insertStepAt=e.message.length),e.message=e.message.slice(0,e.insertStepAt)+t+e.message.slice(e.insertStepAt),e.insertStepAt+=n),e}function he(e){return function(t){if(!Array.isArray(t))throw new TypeError("Expected an array, got "+ie(t));for(var n=[],r=0;r<t.length;++r)try{n[r]=e(t[r])}catch(o){throw pe(o,"["+r+"]",0)}return n}}function ye(e){if("function"==typeof e)return function(t){if("object"!=typeof t||null==t)throw new TypeError("Expected an object, got "+ie(t));for(var n={},r=Object.keys(t),o=0;o<r.length;++o){var i=r[o];if("__proto__"!==i)try{n[i]=e(t[i])}catch(a){throw pe(a,"["+JSON.stringify(i)+"]",0)}}return n};var t=Object.keys(e);function n(n){return function(r){if("object"!=typeof r||null==r)throw new TypeError("Expected an object, got "+ie(r));var o,i={};if(n){var a=Object.keys(r);for(o=0;o<a.length;++o){var s=a[o];"__proto__"!==s&&(i[s]=r[s])}}for(o=0;o<t.length;++o){var c=t[o];try{i[c]=e[c](r[c])}catch(u){throw pe(u,"."+c,0)}}return i}}var r=n(!1);return r.shape=e,r.withRest=n(!0),r}function be(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){for(var n=0;n<t.length;n++)try{return t[n](e)}catch(r){if(n+1>=t.length)throw r}}}function ge(e,t){return function(n){try{return e(n)}catch(r){return"function"==typeof t?t():t}}}function we(e,t){return function(n){return me[Ie]>0?t(n):e(n)}}function ve(e){return function(t){null==me[Ie]&&Object.defineProperty(me,Ie,{value:0,writable:!0});try{return++me[Ie],e(t)}finally{--me[Ie]}}}var me="object"==typeof globalThis&&null!=globalThis?globalThis:JSON,Ie="function"==typeof Symbol?Symbol.for("uncleaning"):"uncleaning",Ee=we((function(e){if("string"!=typeof e&&!(e instanceof Date))throw new TypeError("Expected a date string, got "+ie(e));var t=new Date(e);if(null==t.toJSON())throw new TypeError("Invalid date format, got "+ie(e));return t}),(function(e){return e.toISOString()}));const Se=we((e=>p.parse(le(e))),(e=>p.stringify(e).toLowerCase())),Oe=we((e=>h.parse(le(e),{loose:!0})),(e=>h.stringify(e,{pad:!1}))),Ae=we((e=>y.parse(le(e))),(e=>y.stringify(e))),Te=ye({voucherId:le,activates:Ee,created:Ee,ip:le,ipDescription:le,deviceDescription:ae(le)}),_e=ye({encryptionType:ue,data_base64:Ae,iv_hex:Se}),ke=ye({created:ae(Ee),data_base64:Ae,encryptionType:ue,iv_hex:Se}),xe=ye({salt_hex:Se,n:ue,r:ue,p:ue}),Pe=ye({loginRequest:ae(ye({appId:le}).withRest),publicKey:Ae,timeout:ae(ue)}).withRest,Me=ye({publicKey:Ae,box:_e}),Ce=he(Ae),Ne=ye({data:fe,challengeId:ae(le),deviceDescription:ae(le),otp:ae(le),syncToken:ae(le),voucherId:ae(le),voucherAuth:ae(Ae),loginId:ae(Ae),loginAuth:ae(Ae),userId:ae(Ae),passwordAuth:ae(Ae),pin2Id:ae(Ae),pin2Auth:ae(Ae),recovery2Id:ae(Ae),recovery2Auth:ae(Ce),loginIds:ae(he(Ae)),otpResetAuth:ae(le),did:ae(le),l1:ae(Ae),lp1:ae(Ae),lpin1:ae(Ae),lra1:ae(Ae),recoveryAuth:ae(Ae)}),je=ye({results:ae(fe),status_code:ue,message:le}),De=ye({otpTimeout:ae(ue,604800),otpKey:Oe}),Re=ye({passwordAuth:Ae,passwordAuthBox:_e,passwordAuthSnrp:xe,passwordBox:_e,passwordKeySnrp:xe}),Le=ye({pin2Id:Ae}),Be=ye({pin2Id:ae(Ae),pin2Auth:ae(Ae),pin2Box:ae(_e),pin2KeyBox:ae(_e),pin2TextBox:_e}),Ke=ye({recovery2Id:Ae}),Ue=ye({recovery2Id:Ae,recovery2Auth:Ce,recovery2Box:_e,recovery2KeyBox:_e,question2Box:_e}),Fe=ye({loginAuthBox:_e,loginAuth:Ae}),We=ye({userId:Ae,userTextBox:_e}),qe=ye({approvedVouchers:ae(he(le)),rejectedVouchers:ae(he(le))}),ze=ye({allowExisting:ae(ce,!1),keyBoxes:he(_e),newSyncKeys:ae(he(le),(()=>[]))}),Ge=ye({appId:le,loginId:Ae,parentBox:ae(_e)}),$e=ye({challengeId:le,challengeUri:le}),He=ye({challengeId:le,challengeUri:ae(le)}),Ye=ye({request:Pe,replies:he(Me)}),Ve=se(!0),Je=ye({appId:le,created:Ee,loginId:Ae,syncToken:ae(le),children:ae(he((e=>Je(e)))),parentBox:ae(_e),otpKey:ae(be(Ve,Oe)),otpResetDate:ae(Ee),otpTimeout:ae(ue),passwordAuthBox:ae(_e),passwordAuthSnrp:ae(xe),passwordBox:ae(be(Ve,_e)),passwordKeySnrp:ae(xe),pin2Box:ae(be(Ve,_e)),pin2KeyBox:ae(_e),pin2TextBox:ae(_e),question2Box:ae(_e),recovery2Box:ae(be(Ve,_e)),recovery2KeyBox:ae(_e),loginAuthBox:ae(_e),userId:ae(Ae),userTextBox:ae(_e),pendingVouchers:ae(he(Te),(()=>[])),keyBoxes:ae(he(ke)),mnemonicBox:ae(_e),rootKeyBox:ae(_e),syncKeyBox:ae(_e)}),Xe=he(ye({loginId:Ae,otpResetPending:ae(ce,!1),pendingVouchers:ae(he(Te),(()=>[])),recovery2Corrupt:ae(ce,!1)})),Ze=ye({login_id:ae(Ae),otp_reset_auth:ae(le),otp_timeout_date:ae(Ee),reason:ae(se("ip","otp"),"otp"),voucher_activates:ae(Ee),voucher_auth:ae(Ae),voucher_id:ae(le)}),Qe=ye({otpResetDate:Ee}),et=ye({wait_seconds:ae(ue)}),tt=ye({question2Box:_e}),nt=ye({loginId:Ae,passwordAuthSnrp:ae(xe),questionBox:ae(_e),questionKeySnrp:ae(xe),recoveryAuthSnrp:ae(xe)}),rt=ve(_e),ot=ve(Me),it=ve(Pe),at=ve(Ne),st=ve(je),ct=ve(De),ut=ve(Re),lt=ve(Le),dt=ve(Be),ft=ve(Ke),pt=ve(Ue),ht=ve(Fe),yt=ve(We),bt=ve(qe),gt=ve(ze),wt=ve(Ge),vt=(ve($e),ve(He),ve(Ye)),mt=ve(Je),It=ve(Xe),Et=ve(Ze),St=ve(Qe),Ot=ve(et),At=ve(tt),Tt=ve(nt),_t=ye(_e),kt=ye({loginId:Ae,voucherAuth:Ae,voucherId:le,created:Ee,activates:Ee,status:se("pending","approved","rejected"),ip:le,ipDescription:le,deviceDescription:ae(le)}),xt=ye({appId:le,created:ae(Ee,(()=>new Date)),loginId:Ae,children:ae(he((e=>xt(e))),(()=>[])),parentBox:ae(_e),parentId:()=>{},otpKey:ae(Oe),otpResetAuth:ae(le),otpResetDate:ae(Ee),otpTimeout:ae(ue),passwordAuth:ae(Ae),passwordAuthBox:ae(_e),passwordAuthSnrp:ae(xe),passwordBox:ae(_e),passwordKeySnrp:ae(xe),pin2Id:ae(Ae),pin2Auth:ae(Ae),pin2Box:ae(_e),pin2KeyBox:ae(_e),pin2TextBox:ae(_e),recovery2Id:ae(Ae),recovery2Auth:ae(Ce),question2Box:ae(_e),recovery2Box:ae(_e),recovery2KeyBox:ae(_e),loginAuth:ae(Ae),loginAuthBox:ae(_e),userId:ae(Ae),userTextBox:ae(_e),keyBoxes:ae(he(ke),(()=>[])),mnemonicBox:ae(_e),rootKeyBox:ae(_e),syncKeyBox:ae(_e),vouchers:ae(he(kt),(()=>[])),pinBox:ae(_e),pinId:ae(le),pinKeyBox:ae(_e)}),Pt=ve(xt),Mt=ve(_t);var Ct=n(8162);const Nt=n.n(Ct)()("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),jt={parse(e){return Nt.decode(e)},stringify(e){return Nt.encode(e)}},Dt={parse(e){const t=encodeURI(e),n=new Uint8Array(t.length);let r=0;for(let o=0;o<t.length;++o){const e=t.charCodeAt(o);37===e?(n[r++]=parseInt(t.slice(o+1,o+3),16),o+=2):n[r++]=e}return n.subarray(0,r)},stringify(e){let t="";for(let n=0;n<e.length;++n){const r=e[n];t+="%"+(r>>4).toString(16)+(15&r).toString(16)}return decodeURIComponent(t)}};function Rt(e){const t=new URL(e);if("http:"!==t.protocol&&"ws:"!==t.protocol||"localhost"!==t.hostname){if("https:"===t.protocol||"wss:"===t.protocol){if("localhost"===t.hostname)return;if(/^([A-Za-z0-9_-]+\.)*edge(test)?\.app$/.test(t.hostname))return}throw new Error(`Only *.edge.app or localhost are valid login domain names, not ${t.hostname}`)}}function Lt(e,t="Login requires a CAPTCHA"){if(!(this instanceof Lt))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var n;return function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Lt,configurable:!0,writable:!0})}(t),n.name="ChallengeError",n.challengeId=e.challengeId,n.challengeUri=e.challengeUri,n}function Bt(e="Cannot reach the network"){if(!(this instanceof Bt))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Bt,configurable:!0,writable:!0})}(e),t.name="NetworkError",t}function Kt(e="The application is too old. Please upgrade."){if(!(this instanceof Kt))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Kt,configurable:!0,writable:!0})}(e),t.name="ObsoleteApiError",t}function Ut(e,t="Invalid OTP token"){if(!(this instanceof Ut))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Ut,configurable:!0,writable:!0})}(t),n.name="OtpError",n.reason="otp";const r=ge(Ze)(e);if(null!=r)return null!=r.login_id&&(n.loginId=y.stringify(r.login_id)),n.resetToken=r.otp_reset_auth,n.reason=r.reason,n.resetDate=r.otp_timeout_date,n.voucherActivates=r.voucher_activates,null!=r.voucher_auth&&(n.voucherAuth=y.stringify(r.voucher_auth)),n.voucherId=r.voucher_id,n}function Ft(e,t="Invalid password"){if(!(this instanceof Ft))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var n;!function(e){n=new Error(e),Object.defineProperty(n,"constructor",{value:Ft,configurable:!0,writable:!0})}(t),n.name="PasswordError";const r=ge(et)(e);if(null!=r)return n.wait=r.wait_seconds,n}function Wt(e){if(!(this instanceof Wt))throw new TypeError("Class constructor PinDisabledError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:Wt,configurable:!0,writable:!0})}(e),t.name="PinDisabledError",t}function qt(e="Invalid username"){if(!(this instanceof qt))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var t;return function(e){t=new Error(e),Object.defineProperty(t,"constructor",{value:qt,configurable:!0,writable:!0})}(e),t.name="UsernameError",t}function zt(e){return function(t){if(t instanceof Error&&t.name===e){return t}}}zt("ChallengeError"),zt("DustSpendError");const Gt=zt("InsufficientFundsError"),$t=(zt("NetworkError"),zt("NoAmountSpecifiedError"),zt("ObsoleteApiError"),zt("OtpError")),Ht=zt("PasswordError"),Yt=zt("PinDisabledError"),Vt=zt("PendingFundsError"),Jt=(zt("SameCurrencyError"),zt("SpendToSelfError"),zt("SwapAboveLimitError")),Xt=zt("SwapBelowLimitError"),Zt=zt("SwapCurrencyError"),Qt=zt("SwapPermissionError"),en=zt("SwapAddressError"),tn=zt("UsernameError");var nn=n(8826);function rn(e,t){const n=i().hmac(i().sha256,t);return Uint8Array.from(n.update(e).digest())}function on(e){const t=i().sha256();return Uint8Array.from(t.update(e).digest())}function an(e,t){const n=e.length;if(n!==t.length)return!1;let r=0;for(let o=0;o<n;++o)r|=e[o]^t[o];return 0===r}const sn=n.n(nn)().ModeOfOperation.cbc;function cn(e,t){const n=un(e,t);return 0===n[n.length-1]?Dt.stringify(n.subarray(0,-1)):Dt.stringify(n)}function un(e,t){if(0!==e.encryptionType)throw new Error("Unknown encryption type");const n=e.iv_hex,r=e.data_base64,o=new sn(t,n).decrypt(r),i=1+o[0]+4,a=o[i-4]<<24|o[i-3]<<16|o[i-2]<<8|o[i-1],s=i+a+1,c=s+o[s-1],u=c+32;if(!an(on(o.subarray(0,c)),o.subarray(c,u)))throw new Error("Invalid checksum");if(!an(dn(u),o.subarray(u)))throw new Error("Invalid PKCS7 padding");return o.subarray(i,i+a)}function ln(e,t,n){const r=31&e.random(1)[0],o=1+r+4,i=t.length,a=o+i+1,s=31&e.random(1)[0],c=a+s,u=c+32,l=dn(u),d=new Uint8Array(u+l.length);d.set(l,u),d[0]=r,d.set(e.random(r),1),d[o-4]=i>>24&255,d[o-3]=i>>16&255,d[o-2]=i>>8&255,d[o-1]=255&i,d.set(t,o),d[a-1]=s,d.set(e.random(s),a),d.set(on(d.subarray(0,c)),c);const f=e.random(16);return{encryptionType:0,iv_hex:f,data_base64:new sn(n,f).encrypt(d)}}function dn(e){const t=new Uint8Array(16-(15&e));for(let n=0;n<t.length;++n)t[n]=t.length;return t}function fn(e,t,n){const r=function(e,t){const n=i().hmac(i().sha1,t);return Uint8Array.from(n.update(e).digest())}(function(e){const t=Math.floor(e/4294967296);return new Uint8Array([t>>24&255,t>>16&255,t>>8&255,255&t,e>>24&255,e>>16&255,e>>8&255,255&e])}(t),e),o=15&r[19],a=((127&r[o])<<24|r[o+1]<<16|r[o+2]<<8|r[o+3]).toString();return(Array(n).join("0")+a).slice(-n)}function pn(e,t=Date.now()/1e3){return fn(e,t/30,6)}function hn(...e){return[].concat(...e.filter((e=>null!=e)))}function yn(e,t){for(const n of Object.keys(t))Object.defineProperty(e,n,{writable:!0,configurable:!0,value:t[n]});return e}function bn(e,t,n=new Error(`Timeout of ${t}ms exceeded`)){return new Promise(((r,o)=>{const i=setTimeout((()=>o(n)),t);e.then((e=>{clearTimeout(i),r(e)}),(e=>{clearTimeout(i),o(e)}))}))}async function gn(e,t,n,r){const{loginServers:o}=e.props.state.login,i=Math.floor(255*Math.random());let a,s=new Error("No login servers available");for(let l=0;l<o.length;++l)try{const s=(i+l)%o.length;a=await wn(e,o[s],t,n,r);break}catch(u){s=u}if(null==a)throw s;const{status:c}=a;return function(e){const t=je(e);switch(t.status_code){case 0:return t.results;case 2:throw new qt("Account already exists on server");case 3:throw new qt("Account does not exist on server");case 4:case 5:throw new Ft(t.results);case 6:throw new Error("Invalid API key");case 8:throw new Ut(t.results);case 1e3:throw new Kt;default:{const e=ge($e)(t.results);if(null!=e)throw new Lt(e);throw new Error(`Server error: ${t.message}`)}}}(await a.json().catch((()=>{throw new Error(`Invalid reply JSON, HTTP status ${c}`)})))}function wn(e,t,n,r,o){const{state:i,io:a,log:s}=e.props,{apiKey:c,apiSecret:u}=i.login,l="GET"===n||null==o?void 0:JSON.stringify(at(o));let d=`Token ${c}`;if(null!=u){const e=`${n}\n/api${r}\n${null!=l?l:""}`,t=rn(Dt.parse(e),u);d=`HMAC ${c} ${y.stringify(t)}`}const f={body:l,method:n,headers:{"content-type":"application/json",accept:"application/json",authorization:d},corsBypass:"never"},p=Date.now(),h=`${t}/api${r}`;return bn(a.fetch(h,f),3e4).then((e=>{const t=Date.now()-p;return s(`${n} ${h} returned ${e.status} in ${t}ms`),409===e.status&&s.crash("Login API conflict error",{path:r}),e}),(e=>{const t=Date.now()-p;throw s.error(`${n} ${h} failed in ${t}ms, ${String(e)}`),new Bt(`Could not reach the auth server: ${r}`)}))}function vn(e,t){const{io:n}=e.props,{loginId:r,loginKey:o}=t,i=n.random(32),a=ln(n,i,o);return{loginId:r,server:ht({loginAuth:i,loginAuthBox:a}),serverPath:"/v2/login/secret",stash:{loginAuthBox:a}}}function mn(e,t=2e3){return e.props.output.scrypt.makeSnrp(t)}async function In(e,t,n){"string"==typeof t&&(t=Dt.parse(t));return(await e.props.output.scrypt.timeScrypt(t,n)).hash}const En={salt_hex:Uint8Array.from([181,134,95,251,159,167,179,191,228,178,56,77,71,206,131,30,226,42,74,157,92,52,199,239,125,33,70,124,199,88,248,27]),n:16384,r:1,p:1};function Sn(e){return{username:e,appId:"",loginId:new Uint8Array(0),pendingVouchers:[]}}function On(e,t){const{stashes:n}=e.props.state.login;for(const r of n)if(r.username===t)return r}function An(e,t){const{stashes:n}=e.props.state.login;for(const r of n){const e=r,n=Un(e,(e=>an(e.loginId,t)));if(null!=n)return{stashTree:e,stash:n}}throw new Error(`Cannot find stash '${y.stringify(t)}'`)}function Tn(e,t){const n=Un(e,(e=>an(e.loginId,t)));if(null!=n)return n;throw new Error(`Cannot find child stash '${y.stringify(t)}'`)}const _n={};function kn(e,t){return null==_n[t]&&(_n[t]=In(e,t,En)),_n[t]}async function xn(e,t){const n=[],r=await e.list("logins").then(ee.gQ);for(const i of r)try{n.push(Mn(JSON.parse(await e.getText(i))))}catch(o){t.error(`Could not load ${i}: ${String(o)}`)}return n}async function Pn(e,t){const{dispatch:n,io:r}=e.props,{appId:o,loginId:i}=t;if(""!==o)throw new Error("Cannot save a login without an appId.");if(null==i||32!==i.length)throw new Error("Invalid loginId");await r.disklet.setText(`logins/${jt.stringify(i)}.json`,JSON.stringify(Cn(t))),n({type:"LOGIN_STASH_SAVED",payload:t})}const Mn=ye({appId:le,created:ae(Ee),lastLogin:ae(Ee),loginId:Ae,otpKey:ae(Oe),otpResetDate:ae(Ee),otpTimeout:ae(ue),pendingVouchers:ae(he(Te),(()=>[])),voucherId:ae(le),voucherAuth:ae(Ae),loginAuthBox:ae(_e),parentBox:ae(_e),passwordAuthBox:ae(_e),passwordAuthSnrp:ae(xe),passwordBox:ae(_e),passwordKeySnrp:ae(xe),pin2Key:ae(we((e=>{const t=le(e);return"="!==e.slice(-1)?jt.parse(t):y.parse(t)}),(e=>y.stringify(e)))),pin2TextBox:ae(_e),recovery2Key:ae(Ae),userId:ae(Ae),username:ae((e=>re(le(e)))),children:ae(he((e=>Mn(e)))),keyBoxes:ae(he(ke)),mnemonicBox:ae(_e),rootKeyBox:ae(_e),syncKeyBox:ae(_e),wipChange:ae((e=>Mn(e)))}),Cn=ve(Mn);function Nn(e,t){const n=t.endsWith(".duress")?t:t+".duress";return e.appId===n?e:Un(e,(e=>e.appId===n))}function jn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Dn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?jn(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):jn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Rn(e){if(null!=e.otpKey)return pn(e.otpKey)}function Ln(e,t){const{otp:n,otpKey:r}=t;return null!=n?n:null!=r?pn(h.parse(r,{loose:!0})):null!=e.otpKey?pn(e.otpKey):void 0}function Bn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Kn(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Bn(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Bn(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Un(e,t){if(t(e))return e;const n=e;if(null!=n.children)for(const r of n.children){const e=Un(r,t);if(null!=e)return e}}function Fn(e,t,n,r){if(t(e))return n(e);const o=null!=e.children?e.children.map((e=>Fn(e,t,n,r))):[];return r(e,o)}function Wn(e,t,n){const{children:r=[]}=e,{appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,children:v=[],keyBoxes:m=[],mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O}=n,A={appId:o,created:i,loginId:a,loginAuthBox:s,userId:c,otpKey:!0===u?e.otpKey:u,otpResetDate:l,otpTimeout:d,pendingVouchers:f,parentBox:p,passwordAuthBox:h,passwordAuthSnrp:y,passwordBox:!0===b?e.passwordBox:b,passwordKeySnrp:g,pin2TextBox:w,keyBoxes:m,mnemonicBox:I,rootKeyBox:E,syncKeyBox:S,syncToken:O};null!=e.lastLogin&&(A.lastLogin=e.lastLogin),null!=e.username&&(A.username=e.username),null!=e.userId&&null==A.userId&&(A.userId=e.userId),null!=n.pin2KeyBox&&(A.pin2Key=un(n.pin2KeyBox,t)),null!=n.recovery2KeyBox&&(A.recovery2Key=un(n.recovery2KeyBox,t)),null!=n.userTextBox&&(A.username=Dt.stringify(un(n.userTextBox,t))),v.sort(((e,t)=>e.created.valueOf()-t.created.valueOf())),A.children=v.map((e=>{const{appId:n,loginId:o,parentBox:i}=e;if(null==i)throw new Error("Key integrity violation: No parentBox on child login.");const a=un(i,t),s=r.find((e=>an(e.loginId,o)));return Wn(null!=s?s:{appId:n,loginId:o,pendingVouchers:[]},a,e)}));for(const{loginId:T}of r){if(null==v.find((e=>an(e.loginId,T))))throw new Error("The server has lost children!")}return A}function qn(e,t,n){return Fn(e,(e=>e.appId===n.appId),(e=>Wn(e,t,n)),((e,t)=>Kn(Kn({},e),{},{children:t,wipChange:void 0})))}function zn(e,t){const{appId:n,created:r,lastLogin:o=new Date,loginId:i,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:f=[]}=e,p={appId:n,created:r,isRoot:null==e.parentBox,lastLogin:o,loginId:i,loginKey:t,otpKey:a,otpResetDate:s,otpTimeout:c,pendingVouchers:u,userId:l,username:d,children:[]};if(null!=e.loginAuthBox&&(p.loginAuth=un(e.loginAuthBox,t)),null!=e.passwordAuthBox&&(null==p.userId&&(p.userId=i),p.passwordAuth=un(e.passwordAuthBox,t)),null==p.loginAuth&&null==p.passwordAuth)throw new Error("No server authentication methods on login");return p.pin2Key=e.pin2Key,null!=e.pin2TextBox&&(p.pin=cn(e.pin2TextBox,t)),p.recovery2Key=e.recovery2Key,p.children=f.map((e=>{if(null==e.parentBox)throw new Error("Key integrity violation: No parentBox on child login.");return zn(e,un(e.parentBox,t))})),p}function Gn(e,t){return Fn(e,(e=>an(e.loginId,t.loginId)),(e=>zn(e,t.loginKey)),((e,t)=>{const{appId:n,lastLogin:r=new Date,loginId:o,otpKey:i,pendingVouchers:a,username:s}=e;return{appId:n,children:t,isRoot:null==e.parentBox,lastLogin:r,loginId:o,loginKey:undefined,otpKey:i,pendingVouchers:a,username:s}}))}function $n(e,t){return Fn(e,(e=>e.appId===t),(e=>e),((e,t)=>{const{appId:n,loginId:r,username:o}=e;return{appId:n,children:t,loginId:r,pendingVouchers:[],username:o}}))}async function Hn(e,t,n,r,o,i){const{now:a=new Date}=r,{deviceDescription:s}=e.props.state.login.deviceInfo,c=Kn({challengeId:r.challengeId,otp:Ln(n,r),voucherId:n.voucherId,voucherAuth:n.voucherAuth},o);null!=s&&(c.deviceDescription=s);let u=Je(await gn(e,"POST","/v2/login",c).catch((r=>{const o=$t(r);throw null!=o&&(0===n.loginId.length&&null!=o.loginId||null!=o.voucherId&&null!=o.voucherAuth)&&(null!=o.loginId&&(n.loginId=y.parse(o.loginId)),null!=o.voucherAuth&&(n.voucherId=o.voucherId,n.voucherAuth=y.parse(o.voucherAuth)),t.lastLogin=a,Pn(e,t).catch((()=>{}))),r})));const{loginId:l}=u,d=await i(u);if((t=qn(t,d,u)).lastLogin=a,await Pn(e,t),null==u.loginAuthBox){const{stash:t,stashTree:n}=An(e,l),i=vn(e,{loginId:l,loginKey:d}),a=Kn(Kn({},o),{},{otp:Ln(t,r),data:i.server});u=Je(await gn(e,"POST",i.serverPath,a)),await Pn(e,qn(n,d,u))}return{loginId:l,loginKey:d}}async function Yn(e,t,n){const{serverMethod:r="POST",serverPath:o}=n,{stashTree:i}=An(e,n.loginId),{deviceDescription:a}=e.props.state.login.deviceInfo,s=Fn(i,(e=>an(e.loginId,n.loginId)),(e=>Kn(Kn(Kn({},e),n.stash),{},{children:hn(e.children,n.stash.children),keyBoxes:hn(e.keyBoxes,n.stash.keyBoxes),wipChange:void 0})),((e,t)=>Kn(Kn({},e),{},{children:t,wipChange:void 0})));if(""!==o&&(i.wipChange=s,await Pn(e,i)),""!==o){const s=Zn(i,Xn(i,t,n.loginId));null!=a&&(s.deviceDescription=a),s.data=n.server;try{await gn(e,r,o,s)}catch(c){throw Jn(e,t).catch((()=>{})),c}}return await Pn(e,s),s}async function Vn(e,t,n){for(const r of n)null!=r&&await Yn(e,t,r)}async function Jn(e,t){const{stashTree:n,stash:r}=An(e,t.loginId),{syncToken:o}=r;if(null!=o)try{if(ce(await gn(e,"POST","/v2/sync",{loginId:r.loginId,syncToken:o})))return}catch(s){}const i=Zn(n,t),a={now:n.lastLogin};await Hn(e,n,r,a,i,(async()=>t.loginKey))}function Xn(e,t,n){var r;if(an(n,t.loginId))return t;const o=Tn(e,t.loginId),i=function e(t,r){for(const o of t){if(null==o.parentBox)continue;if(an(o.loginId,n))return{loginId:o.loginId,loginKey:un(o.parentBox,r)};const{children:t=[]}=o;if(0===t.length)continue;const i=e(t,un(o.parentBox,r));if(null!=i)return i}}(null!==(r=null==o?void 0:o.children)&&void 0!==r?r:[],t.loginKey);if(null==i)throw new Error(`Cannot decrypt child login '${y.stringify(t.loginId)}'`);return i}function Zn(e,t){const n=Tn(e,t.loginId),{loginAuthBox:r,otpKey:o,passwordAuthBox:i,syncToken:a,userId:s,voucherAuth:c,voucherId:u}=n,l=null!=o?pn(o):void 0;if(null!=r)return{loginAuth:un(r,t.loginKey),loginId:t.loginId,otp:l,syncToken:a,voucherAuth:c,voucherId:u};if(null!=i&&null!=s)return{passwordAuth:un(i,t.loginKey),userId:s,otp:l,syncToken:a,voucherAuth:c,voucherId:u};throw new Error("No server authentication methods available")}var Qn=n(1649);Qn.bS,Qn.Ei,Qn.h8,Qn.wJ,Qn.PG,Qn.SR,Qn.Th,Qn.Qw,Qn.YK,Qn.KI,Qn.Wn,Qn.tp,Qn.RQ,Qn.tE,Qn.Jj;const er=Qn.LZ;Qn.m8;function tr(e){return"Minified Redux error #"+e+"; visit https://redux.js.org/Errors?code="+e+" for the full message or use the non-minified dev environment for full errors. "}var nr="function"==typeof Symbol&&Symbol.observable||"@@observable",rr=function(){return Math.random().toString(36).substring(7).split("").join(".")},or={INIT:"@@redux/INIT"+rr(),REPLACE:"@@redux/REPLACE"+rr(),PROBE_UNKNOWN_ACTION:function(){return"@@redux/PROBE_UNKNOWN_ACTION"+rr()}};function ir(e){if("object"!=typeof e||null===e)return!1;for(var t=e;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function ar(e,t,n){var r;if("function"==typeof t&&"function"==typeof n||"function"==typeof n&&"function"==typeof arguments[3])throw new Error(tr(0));if("function"==typeof t&&void 0===n&&(n=t,t=void 0),void 0!==n){if("function"!=typeof n)throw new Error(tr(1));return n(ar)(e,t)}if("function"!=typeof e)throw new Error(tr(2));var o=e,i=t,a=[],s=a,c=!1;function u(){s===a&&(s=a.slice())}function l(){if(c)throw new Error(tr(3));return i}function d(e){if("function"!=typeof e)throw new Error(tr(4));if(c)throw new Error(tr(5));var t=!0;return u(),s.push(e),function(){if(t){if(c)throw new Error(tr(6));t=!1,u();var n=s.indexOf(e);s.splice(n,1),a=null}}}function f(e){if(!ir(e))throw new Error(tr(7));if(void 0===e.type)throw new Error(tr(8));if(c)throw new Error(tr(9));try{c=!0,i=o(i,e)}finally{c=!1}for(var t=a=s,n=0;n<t.length;n++){(0,t[n])()}return e}return f({type:or.INIT}),(r={dispatch:f,subscribe:d,getState:l,replaceReducer:function(e){if("function"!=typeof e)throw new Error(tr(10));o=e,f({type:or.REPLACE})}})[nr]=function(){var e,t=d;return(e={subscribe:function(e){if("object"!=typeof e||null===e)throw new Error(tr(11));function n(){e.next&&e.next(l())}return n(),{unsubscribe:t(n)}}})[nr]=function(){return this},e},r}function sr(e){function t(t){var n=void 0,r=void 0,o=!0,i=!1,a=!1,s=void 0,c=void 0,u=void 0;function l(){if(n){try{if(c){var e=c;s=void 0,c=void 0,u=void 0,e(((r=new Error("Pixie has been destroyed")).name="PixieShutdownError",r))}var t=n;n=void 0,t.destroy()}catch(r){d(r)}a=!0}var r}function d(e){a||t.onError(e),l()}function f(){i=!1,p()}function p(){for(;n&&o&&!i;){o=!1,i=!0;try{var e=n.update(r);e&&"function"==typeof e.then?e.then(f,d):i=!1}catch(t){d(t)}}}function h(){return s||(s=new Promise((function(e,t){u=e,c=t}))),s}var y={onError:d,onOutput:function(e){a||t.onOutput(e)},get props(){return r},nextProps:h,waitFor:function(e){return new Promise((function(t,n){return function o(){try{var i=e(r);null!=i?t(i):h().then(o,n)}catch(a){n(a)}}()}))}};try{n=function(e){return"function"==typeof e?{update:e,destroy:function(){}}:e}(e(y))}catch(b){d(b)}return{update:function(e){if(r=e,o=!0,u){var t=u;s=void 0,c=void 0,u=void 0,t(e)}p()},destroy:l}}return t.tame=!0,t.defaultOutput=e.defaultOutput,t}function cr(e){return e.tame?e:sr(e)}function ur(e,t,n){n(e)}var lr="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},dr=(function(){function e(e){this.value=e}function t(t){var n,r;function o(n,r){try{var a=t[n](r),s=a.value;s instanceof e?Promise.resolve(s.value).then((function(e){o("next",e)}),(function(e){o("throw",e)})):i(a.done?"return":"normal",a.value)}catch(c){i("throw",c)}}function i(e,t){switch(e){case"return":n.resolve({value:t,done:!0});break;case"throw":n.reject(t);break;default:n.resolve({value:t,done:!1})}(n=n.next)?o(n.key,n.arg):r=null}this._invoke=function(e,t){return new Promise((function(i,a){var s={key:e,arg:t,resolve:i,reject:a,next:null};r?r=r.next=s:(n=r=s,o(e,t))}))},"function"!=typeof t.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(t.prototype[Symbol.asyncIterator]=function(){return this}),t.prototype.next=function(e){return this._invoke("next",e)},t.prototype.throw=function(e){return this._invoke("throw",e)},t.prototype.return=function(e){return this._invoke("return",e)}}(),function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}()),fr=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};function pr(e){}function hr(e){}function yr(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:pr,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:hr;return function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:ur,n=cr(e);function r(e){var r=e.onOutput,o=void 0,i=void 0,a=function(){var e=o;o=void 0,e&&e.destroy()},s={onError:function(n){a();try{t(n,i,e.onError)}catch(n){e.onError(n)}},onOutput:r};return{update:function(e){i=e,o||(o=n(s)),o.update(e)},destroy:a}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}(function(e){var t=cr(e);function n(n){var r=n.onError,o=void 0,i=e.defaultOutput,a=void 0,s=!0,c=!1,u=function(){for(;o&&s&&!c;)s=!1,c=!0,o.update(fr({},a,{output:i})),c=!1},l={onError:r,onOutput:function(e){e!==i&&(i=e,s=!0,n.onOutput(e),u())}};return{update:function(e){a=e,s=!0,o||(o=t(l)),u()},destroy:function(){var e=o;o=void 0,e&&e.destroy()}}}return n.tame=!0,n.defaultOutput=e.defaultOutput,n}(e))({onError:t,onOutput:n})}function br(e){var t={},n=Object.keys(e),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var i;if(r){if(o>=n.length)break;i=n[o++]}else{if((o=n.next()).done)break;i=o.value}var a=i;t[a]=e[a].defaultOutput}function s(n){var r=n.onError,o={},i={},a=fr({},t),s=!1,c=function(){if(l){if(d>=u.length)return"break";f=u[d++]}else{if((d=u.next()).done)return"break";f=d.value}var t=f;if(o[t]={onError:r,onOutput:function(e){e!==a[t]&&((a=fr({},a))[t]=e,n.onOutput(a))}},i[t]=cr(e[t])(o[t]),s)return"break"},u=Object.keys(e),l=Array.isArray(u),d=0;for(u=l?u:u[Symbol.iterator]();;){var f;if("break"===c())break}return{update:function(e){var t=Object.keys(i),n=Array.isArray(t),r=0;for(t=n?t:t[Symbol.iterator]();;){var o;if(n){if(r>=t.length)break;o=t[r++]}else{if((r=t.next()).done)break;o=r.value}if(i[o].update(e),s)return}},destroy:function(){s=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}i[r].destroy()}}}}return s.tame=!0,s.defaultOutput=t,s}function gr(e,t){return function(){try{return e.apply(void 0,arguments)}catch(n){t(n)}}}function wr(e,t){if(e===t)return!0;if("object"!==(void 0===e?"undefined":lr(e)))return!1;if("object"!==(void 0===t?"undefined":lr(t)))return!1;if(!e||!t)return!1;var n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;var r=n,o=Array.isArray(r),i=0;for(r=o?r:r[Symbol.iterator]();;){var a;if(o){if(i>=r.length)break;a=r[i++]}else{if((i=r.next()).done)break;a=i.value}var s=a;if(!Object.prototype.hasOwnProperty.call(t,s)||e[s]!==t[s])return!1}return!0}function vr(e,t){var n=cr(e);function r(e){var r=e.onError,o=e.onOutput,i=void 0,a=void 0,s=!1,c=gr(t,r),u={onError:r,onOutput:o};return{update:function(e){var t=c(e);if(!s){var r=!wr(t,a);if(a=t,t){if(i||(i=n(u)),s)return;r&&i.update(t)}else i&&i.destroy(),i=void 0}},destroy:function(){s=!0,i&&i.destroy(),i=void 0}}}return r.tame=!0,r.defaultOutput=e.defaultOutput,r}function mr(e,t,n){var r=cr(e);function o(e){var o=e.onError,i={},a={},s=!1,c={},u=!1,l=!1,d=gr(t,o),f=gr(n,o),p=function(){if(s&&!u){s=!1;var t={},n=Object.keys(i),r=Array.isArray(n),o=0;for(n=r?n:n[Symbol.iterator]();;){var c;if(r){if(o>=n.length)break;c=n[o++]}else{if((o=n.next()).done)break;c=o.value}var l=c;t[l]=a[l]}a=t,e.onOutput(a)}};return{update:function(e){var t=d(e);if(!l&&t){u=!0;var n={},h=function(){if(b){if(g>=y.length)return"break";w=y[g++]}else{if((g=y.next()).done)return"break";w=g.value}var t=w,u=f(e,t);if(l)return{v:void 0};var d=!wr(u,c[t]);if(c[t]=u,u){if(!i[t]){if(i[t]=r({onError:o,onOutput:function(e){e!==a[t]&&(a[t]=e,s=!0,p())}}),l)return{v:void 0}}if(d&&i[t].update(u),l)return{v:void 0};n[t]=i[t]}};var y=t,b=Array.isArray(y),g=0;e:for(y=b?y:y[Symbol.iterator]();;){var w,v=h();if("break"===v)break e;if("object"===(void 0===v?"undefined":lr(v)))return v.v}var m=i;i=n;var I=Object.keys(m),E=Array.isArray(I),S=0;for(I=E?I:I[Symbol.iterator]();;){var O;if(E){if(S>=I.length)break;O=I[S++]}else{if((S=I.next()).done)break;O=S.value}var A=O;n[A]||(s=!0,m[A].destroy())}l||(u=!1,p())}},destroy:function(){l=!0;var e=Object.keys(i),t=Array.isArray(e),n=0;for(e=t?e:e[Symbol.iterator]();;){var r;if(t){if(n>=e.length)break;r=e[n++]}else{if((n=e.next()).done)break;r=n.value}var o=r;i[o]&&i[o].destroy()}}}}return o.tame=!0,o.defaultOutput={},o}!function(){function e(t,n){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.props=t}dr(e,[{key:"update",value:function(e,t){}},{key:"destroy",value:function(e,t){}}])}();var Ir={then:function(){}};function Er(e){const t=ve(e);return{async load(t,n){try{return e(JSON.parse(await t.getText(n)))}catch(r){}},async save(e,n,r){await e.setText(n,JSON.stringify(t(r)))}}}const Sr=e=>{if(null==e||"object"!=typeof e)throw new TypeError("Expected a JSON object");return e},Or="client.json",Ar=Er(ye({clientId:Ae,duressEnabled:ge(ce,!1),loginWaitTimestamps:ge(ye(ue),(()=>({})))})),Tr="infoCache.json",_r=ye({corePlugins:ye(Sr),syncServers:he(le)}),kr=Er(_r);function xr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Pr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xr(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xr(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Mr(e,t,n){return function(){let r="";for(let e=0;e<arguments.length;++e){const t=arguments[e];e>0&&(r+=" "),"string"==typeof t?r+=t:t instanceof Error?r+=String(t):r+=JSON.stringify(t,null,2)}e({message:r,source:n,time:new Date,type:t})}}function Cr(e,t){const{onLog:n,crashReporter:r}=e;return yn(Mr(n,"info",t),{breadcrumb(e,o){const i=new Date;null!=r?r.logBreadcrumb({message:e,metadata:o,source:t,time:i}):(e=`${e} ${JSON.stringify(o,null,2)}`,n({message:e,source:t,time:i,type:"warn"}))},crash(e,o){const i=new Date;if(null!=r)r.logCrash({error:e,metadata:o,source:t,time:i});else{const r=`${String(e)} ${JSON.stringify(o,null,2)}`;n({message:r,source:t,time:i,type:"error"})}},warn:Mr(n,"warn",t),error:Mr(n,"error",t)})}const Nr=we((e=>jt.parse(le(e))),(e=>jt.stringify(e))),jr=Er(ye({SNRP2:xe,SNRP3:ae(xe),SNRP4:ae(xe),ERQ:ae(_e)})),Dr=Er(ye({EMK_LP2:_e,EMK_LRA3:ae(_e),ESyncKey:_e,ELP1:_e})),Rr=Er(ye({TOTP:Oe})),Lr=Er(ye({pin2Key:Nr})),Br=Er(ye({recovery2Key:Nr})),Kr=Er(ye({userName:le}));function Ur(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Fr(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ur(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ur(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Wr={};let qr=!1;const zr=[],Gr=[];function $r(){qr=!0;for(const e of Gr)e()}function Hr(e,t,n={}){const{onError:r=(()=>{})}=n;let o,i=!1;function a(){o=void 0,u.started&&(i=!0,new Promise((t=>t(e()))).catch(r).then(c,c))}function s(e){i=!1,u.started&&(o=setTimeout(a,e))}function c(){s(t)}const u={started:!1,setDelay(e){t=e},start(e={}){const{wait:n}=e;u.started=!0,i||null!=o||("number"==typeof n?s(n):!0===n?s(t):a())},stop(){u.started=!1,null!=o&&(clearTimeout(o),o=void 0)}};return u}function Yr(e){return new Promise((t=>setTimeout((()=>t(e)),e)))}function Vr(e,t){const n=Jr(e,t);if(null==n)throw new Error(`Cannot find a currency plugin for wallet type ${t}`);return n}function Jr(e,t){return Object.keys(e).find((n=>e[n].currencyInfo.walletType===t))}function Xr(e,t){const{dispatch:n,state:r}=e.props,o=r.plugins.currencyTools[t];if(null!=o)return o;const i=r.plugins.currency[t].makeCurrencyTools();return n({type:"CURRENCY_TOOLS_LOADED",payload:{pluginId:t,tools:i}}),i}const Zr=ye({dataKey:Ae,syncKey:Ae}),Qr=ve(Zr);function eo(e){const{io:t}=e.props;return{dataKey:t.random(32),syncKey:t.random(20)}}function to(e,t,n){const r={delete(e){return n.delete(e)},async getData(e){const r=await n.getText(e);return un(_e(JSON.parse(r)),t)},async getText(e){const r=await n.getText(e);return cn(_e(JSON.parse(r)),t)},list(e){return n.list(e)},setData(r,o){return n.setText(r,JSON.stringify(rt(ln(e,Uint8Array.from(o),t))))},setText(e,t){return this.setData(e,Dt.parse(t))}};return _(r),r}function no(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}const ro=100;function oo(e,t){return(0,ee.HN)(e.disklet,"local/"+jt.stringify(y.parse(t)))}function io(e,t){const{dataKey:n,syncKey:r}=t,o=(0,ee.HN)(e.disklet,"repos/"+jt.stringify(on(on(r)))),i=(0,ee.HN)(o,"changes"),a=(0,ee.HN)(o,"data");return{dataKey:n,syncKey:r,baseDisklet:o,changesDisklet:i,dataDisklet:a,disklet:to(e,n,(0,ee.Cl)(i,a))}}function ao(e){const t={lastSync:0,lastHash:void 0};return e.baseDisklet.getText("status.json").then((e=>function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?no(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):no(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({lastSync:0},JSON.parse(e)))).catch((()=>t))}async function so(e,t){await Promise.all(Object.keys(t).map((n=>{const r=t[n];return null!=r?e.setText(n,JSON.stringify(rt(r))):e.delete(n)})))}async function co(e,t,n){const{changesDisklet:r,dataDisklet:o,syncKey:i}=t,a=await uo(r).then((e=>Promise.all(e.map((async e=>({path:e,box:_e(JSON.parse(await r.getText(e)))})))))),s=p.stringify(i).toLowerCase(),c=await(()=>{if(0===a.length)return e.readRepo(s,n.lastHash);const t={};for(const e of a)t[e.path]=rt(e.box);return e.updateRepo(s,n.lastHash,{changes:t})})(),{hash:u}=c,l={};for(const f of Object.keys(null!==(d=c.changes)&&void 0!==d?d:{})){var d;const e=c.changes[f];l[f]=null==e?null:_e(e)}return await so(o,l),await Promise.all(a.map((e=>r.delete(e.path)))),n.lastSync=Date.now()/1e3,null!=u&&(n.lastHash=u),await t.baseDisklet.setText("status.json",JSON.stringify(n)),{status:n,changes:l}}async function uo(e,t="",n=ro){const r=await e.list(t),o=Object.keys(r).filter((e=>"file"===r[e])),i=Object.keys(r).filter((e=>"folder"===r[e]));for(const a of i){if(o.length>=n)break;const t=n-o.length,r=await uo(e,a,t);o.push(...r.slice(0,t))}return o}function lo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}const fo=3e4;async function po(e,t){const{dispatch:n,io:r,onError:o}=e.props,i=io(r,Zr(t.keys)),a=oo(r,t.id);_(a);const s=await ao(i);n({type:"STORAGE_WALLET_ADDED",payload:{id:t.id,initialState:{localDisklet:a,paths:i,status:s,lastChanges:[]}}});const c=ho(e,t.id);s.lastSync>0?c.catch((n=>{const{syncKey:r}=t.keys,{lastHash:i}=s;e.props.log.error(`Could not sync ${String(r)} with last hash ${String(i)}: ${String(n)}`),o(n)})):await c}function ho(e,t){const{dispatch:n,syncClient:o,state:i}=e.props,{paths:a,status:s}=i.storageWallets[t];return co(o,a,function(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?lo(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):lo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},s)).then((({changes:e,status:r})=>(n({type:"STORAGE_WALLET_SYNCED",payload:{id:t,changes:Object.keys(e),status:r}}),Object.keys(e))))}async function yo(e){try{return{ok:!0,result:await e}}catch(t){return{ok:!1,error:t}}}function bo(e,t){return e.storageWallets[t].paths.disklet}function go(e,t){return e.storageWallets[t].localDisklet}function wo(e,t,n){const r=e.storageWallets[t].paths.dataKey;return jt.stringify(rn(Dt.parse(n),r))}const vo=ye({multiplier:le,name:le,symbol:ae(le)}),mo=ye({currencyCode:le,denominations:he(vo),displayName:le,networkLocation:ae(Sr)}),Io=ye({enabled:ae(ce,!0)}).withRest,Eo=ye({SortIndex:ae(ue,0),Archived:ae(ce,!1),BitcoinSeed:Se,MK:Se,SyncKey:Se}).withRest,So=ye({id:le,archived:ae(ce),deleted:ae(ce),hidden:ae(ce),migratedFromWalletId:ae(le),sortIndex:ae(ue)}),Oo=ye({userSettings:ae(ye(Sr),(()=>({}))),swapSettings:ae(ye(Io),(()=>({})))}).withRest,Ao=ye({customTokens:he(ye({contractAddress:le,currencyCode:le,currencyName:le,denomination:le,denominations:he(vo),isVisible:ae(ce,!0),multiplier:le,walletType:ae(le,"wallet:ethereum")}))});function To(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function _o(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?To(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):To(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const ko=Er(ye({customTokens:ye(ye(mo))})),xo=Er(Ao),Po="CustomTokens.json",Mo="Settings.json",Co=ge(ye({contractAddress:le}));async function No(e,t,n){const r=await Xr(e,t);if(null!=r.getTokenId)return await r.getTokenId(n);const o=function(e,t){for(const n of Object.keys(e.props.state.currency.wallets)){const r=e.props.output.currency.wallets[n];if(null!=(null==r?void 0:r.engine)&&e.props.state.currency.wallets[n].pluginId===t)return r.engine}}(e,t);if(null==o)throw new Error("A wallet must exist before adding tokens to a legacy currency plugin");if(null==o.addCustomToken)throw new Error(`${t} doesn't support tokens`);const i=Lo(n);if(null==i)throw new Error("A token must have a contract address to be added to a legacy currency plugin");return await o.addCustomToken(_o(_o({},i),n)),jo(i.contractAddress)}function jo(e){return e.toLowerCase().replace(/^0x/,"")}function Do(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=Co(o);return{currencyCode:t,currencyName:n,denominations:r,contractAddress:null==i?void 0:i.contractAddress}}function Ro(e={}){const t=[];for(const n of Object.keys(e))t.push(Do(e[n]));return t}function Lo(e){const{currencyCode:t,displayName:n,denominations:r,networkLocation:o}=e,i=Co(o);if(null!=i)return{currencyCode:t,currencyName:n,multiplier:r[0].multiplier,contractAddress:i.contractAddress}}async function Bo(e,t){const{dispatch:n,state:r}=e.props;await Promise.all(Object.keys(r.plugins.currency).map((async e=>{var o;const i=r.plugins.currency[e],a=null==i.getBuiltinTokens?function(e){const t={};for(const n of e){const{contractAddress:e}=n;null!=e&&(t[jo(e)]={currencyCode:n.currencyCode,denominations:n.denominations,displayName:n.currencyName,networkLocation:{contractAddress:n.contractAddress}})}return t}(null!==(o=i.currencyInfo.metaTokens)&&void 0!==o?o:[]):await i.getBuiltinTokens();n({type:"ACCOUNT_BUILTIN_TOKENS_LOADED",payload:{accountId:t,pluginId:e,tokens:a}})})))}async function Ko(e,t){const{dispatch:n,state:r}=e.props,{accountWalletInfo:o}=r.accounts[t],i=bo(r,o.id),a=await ko.load(i,Po);if(null!=a){const{customTokens:e}=a;n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:e}})}else{const r=await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=bo(n,r.id),i=await xo.load(o,Mo);if(null==i)return{};const a={};for(const s of i.customTokens){if(!s.isVisible)continue;const e=Jr(n.plugins.currency,s.walletType);if(null==e)continue;null==a[e]&&(a[e]={});const t=jo(s.contractAddress);a[e][t]={currencyCode:s.currencyCode,denominations:s.denominations,displayName:s.currencyName,networkLocation:{contractAddress:s.contractAddress}}}return a}(e,t);n({type:"ACCOUNT_CUSTOM_TOKENS_LOADED",payload:{accountId:t,customTokens:r}})}}var Uo=n(7591);function Fo(e){var t;const{currencyInfo:n,allTokens:r}=e;let o=e.tokenId;void 0===o&&null!=e.currencyCode&&e.currencyCode!==n.currencyCode&&(o=Object.keys(r).find((t=>r[t].currencyCode===e.currencyCode)));const{currencyCode:i}=null==o?n:r[o];return{currencyCode:i,tokenId:null!==(t=o)&&void 0!==t?t:null}}function Wo(e){return null!=e.networkFee&&void 0===e.networkFee.tokenId&&(e.networkFee.tokenId=null),e}const qo=e=>{null!=e.networkFees&&0!==e.networkFees.length||(e.networkFees=[{tokenId:e.tokenId,nativeAmount:e.networkFee}],null!=e.parentNetworkFee&&e.networkFees.push({tokenId:null,nativeAmount:e.parentNetworkFee}))};function zo(e,t,n){for(const r of e.denominations)if(r.name===n)return r.multiplier;for(const r of Object.keys(t)){const e=t[r];for(const t of e.denominations)if(t.name===n)return t.multiplier}return"1"}function Go(e,t){return e.waitFor((e=>{if(null==e.state.currency.wallets[t])throw new Error(`Wallet id ${t} does not exist in this account`);const{engineFailure:n}=e.state.currency.wallets[t];if(null!=n)throw n;if(null!=e.output.currency.wallets[t])return e.output.currency.wallets[t].walletApi}))}const $o=ye({id:le,keys:Sr,type:le}),Ho=ve($o);function Yo(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Vo(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yo(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yo(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Jo(e,t){return e.find((e=>e.type===t))}function Xo(e){return""===e?"account-repo:co.airbitz.wallet":`account-repo:${e}`}function Zo(e,t,n){const r=rn(Dt.parse(e),null!=n?n:Zr(t).dataKey);return{id:y.stringify(r),type:e,keys:t}}function Qo(e,t,n,r=!1){e.props.log.breadcrumb("makeKeysKit",{});const{io:o}=e.props,i=n.map((e=>Vo({created:new Date},ln(o,Dt.parse(JSON.stringify(Ho(e))),t.loginKey)))),a=[];for(const s of n){const e=ge(Zr)(s.keys);null!=e&&a.push(p.stringify(e.syncKey).toLowerCase())}return{loginId:t.loginId,server:gt({allowExisting:r,keyBoxes:i,newSyncKeys:a}),serverPath:"/v2/login/keys",stash:{keyBoxes:i}}}function ei(e){const t=[],n=new Map;for(const r of e){const{id:e,keys:o,type:i}=r;if(null==e||32!==y.parse(e).length)throw new Error(`Key integrity violation: invalid id ${e}`);const a=n.get(e);if(null!=a){const n=t[a];if(n.type!==i)throw new Error(`Key integrity violation for ${e}: type ${i} does not match ${n.type}`);for(const t of Object.keys(o))if(null!=n.keys[t]&&n.keys[t]!==o[t])throw new Error(`Key integrity violation for ${e}: ${t} keys do not match`);t[a]={id:e,keys:Vo(Vo({},n.keys),o),type:i}}else n.set(e,t.length),t.push(r)}return t}function ti(e,t,n=new Map){const{appId:r,keyBoxes:o=[]}=e,i=[],{mnemonicBox:a,rootKeyBox:s}=e;if(null!=a&&null!=s){const e=un(s,t),n={mnemonic:cn(a,rn(e,Dt.parse("infoKey"))),rootKey:y.stringify(e)};i.push(Zo("wallet:bitid",n,e))}if(null!=e.syncKeyBox){const n=un(e.syncKeyBox,t),o=Xo(r),a=Qr({dataKey:t,syncKey:n});i.push(Zo(o,a,t))}const c=o.map((e=>{const r=$o(JSON.parse(cn(e,t))),o=(i=e.created,a=n.get(r.id),null==i?a:null==a?i:new Date(Math.min(i.valueOf(),a.valueOf())));var i,a;return null!=o&&n.set(r.id,o),r}));return ei([...i,...c]).map((e=>ni(e)))}function ni(e){const{id:t,keys:n,type:r}=e,o={"wallet:bitcoin-bip44":{format:"bip44",coinType:0},"wallet:bitcoin-bip49":{format:"bip49",coinType:0},"wallet:bitcoincash-bip32":{format:"bip32"},"wallet:bitcoincash-bip44":{format:"bip44",coinType:145},"wallet:bitcoincash-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip44-testnet":{format:"bip44",coinType:1},"wallet:bitcoin-bip49-testnet":{format:"bip49",coinType:1},"wallet:dash-bip44":{format:"bip44",coinType:5},"wallet:dogecoin-bip44":{format:"bip44",coinType:3},"wallet:litecoin-bip44":{format:"bip44",coinType:2},"wallet:litecoin-bip49":{format:"bip49",coinType:2},"wallet:feathercoin-bip49":{format:"bip49",coinType:8},"wallet:feathercoin-bip44":{format:"bip44",coinType:8},"wallet:qtum-bip44":{format:"bip44",coinType:2301},"wallet:ufo-bip49":{format:"bip49",coinType:202},"wallet:ufo-bip84":{format:"bip84",coinType:202},"wallet:zcoin-bip44":{format:"bip44",coinType:136},"wallet:bitcoin-testnet":{format:"bip32"},"wallet:bitcoin":{format:"bip32"},"wallet:bitcoincash-testnet":{format:"bip32"},"wallet:litecoin":{format:"bip32",coinType:2},"wallet:zcoin":{format:"bip32",coinType:136}};return null!=o[r]?{id:t,keys:Vo(Vo({},o[r]),n),type:r.replace(/-bip[0-9]+/,"")}:e}async function ri(e,t,n){const{importText:r,keyOptions:o,keys:i}=n;function a(n,r){return null!=r&&(n=Vo(Vo({},n),{},{imported:r})),ni(Zo(t,Vo(Vo({},Qr(eo(e))),n)))}if(null!=i)return a(i);const s=Vr(e.props.state.plugins.currency,t),c=await Xr(e,s);if(null!=r){if(null==c.importPrivateKey)throw new Error("This wallet does not support importing keys");return a(await c.importPrivateKey(r,o),!0)}return a(await c.createPrivateKey(t,o),!1)}async function oi(e,t,n,r){const{enabledTokenIds:o,fiatCurrencyCode:i,migratedFromWalletId:a,name:s}=r,c=await Go(e,n);return null!=a&&await hi(e,t,{[n]:{migratedFromWalletId:a}}),null!=s&&await c.renameWallet(s),null!=i&&await c.setFiatCurrencyCode(i),null!=o&&o.length>0&&await c.changeEnabledTokenIds(o),c}function ii(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ai(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ii(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ii(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const si=Er(Eo),ci=Er(So),ui=Er(Oo),li=Oo({}),di="PluginSettings.json";function fi(e,t){for(const n of Object.keys(t))if(e[n]!==t[n])return!0;return!1}async function pi(e,t){const n=e.props.state.accounts[t],{accountWalletInfo:r,accountWalletInfos:o}=n,i=await Promise.all(o.map((t=>async function(e){const t=[],n={},r=(0,ee.gQ)(await e.list("Wallets"));return await Promise.all(r.map((async r=>{const o=await si.load(e,r);if(null==o)return;const i=Zo("wallet:bitcoin",ai(ai({},Qr({dataKey:o.MK,syncKey:o.SyncKey})),{},{bitcoinKey:y.stringify(o.BitcoinSeed),format:"bip32"}),o.MK);t.push(i),n[i.id]={archived:o.Archived,deleted:!1,hidden:!1,migratedFromWalletId:void 0,sortIndex:o.SortIndex}}))),{walletInfos:t,walletStates:n}}(bo(e.props.state,t.id))))),a=await async function(e){const t={},n=(0,ee.gQ)(await e.list("Keys"));return await Promise.all(n.map((async n=>{const r=await ci.load(e,n);if(null==r)return;const{id:o,archived:i,deleted:a,hidden:s,migratedFromWalletId:c,sortIndex:u}=r;t[o]={archived:i,deleted:a,hidden:s,sortIndex:u,migratedFromWalletId:c}}))),t}(bo(e.props.state,r.id)),s=[];for(const l of i)s.push(...l.walletInfos);const c=i.map((e=>e.walletStates)),u=Object.assign({},...c,a);e.props.dispatch({type:"ACCOUNT_KEYS_LOADED",payload:{accountId:t,legacyWalletInfos:s,walletStates:u}})}async function hi(e,t,n){const{accountWalletInfo:r,walletStates:o}=e.props.state.accounts[t],i=bo(e.props.state,r.id),a={};for(const c of Object.keys(n))null==o[c]?a[c]=n[c]:fi(o[c],n[c])&&(a[c]=ai(ai({},o[c]),n[c]));const s=Object.keys(a);s.length<1||(await Promise.all(s.map((async t=>{const{archived:n,deleted:o,hidden:s,migratedFromWalletId:c,sortIndex:u}=a[t],l=wo(e.props.state,r.id,t);await ci.save(i,`Keys/${l}.json`,{archived:n,deleted:o,hidden:s,id:t,migratedFromWalletId:c,sortIndex:u})}))),e.props.dispatch({type:"ACCOUNT_CHANGED_WALLET_STATES",payload:{accountId:t,walletStates:ai(ai({},o),a)}}))}async function yi(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=bo(e.props.state,i.id),s=null!==(o=await ui.load(a,di))&&void 0!==o?o:li;await ui.save(a,di,ai(ai({},s),{},{userSettings:ai(ai({},e.props.state.accounts[t].userSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,userSettings:ai({},r)}})}async function bi(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=bo(e.props.state,n.id),o=await ui.load(r,di),{userSettings:i,swapSettings:a}=null!=o?o:{userSettings:{},swapSettings:{}};e.props.dispatch({type:"ACCOUNT_PLUGIN_SETTINGS_LOADED",payload:{accountId:t,userSettings:i,swapSettings:a}})}function gi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wi(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gi(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gi(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function vi(e,t){const{id:n,type:r,keys:o}=e,i=ge(Zr)(o);if(null==i)throw new Error(`Wallet ${n} is not a splittable type`);const{dataKey:a,syncKey:s}=i,c=Ii(rn(Dt.parse(r),a),rn(Dt.parse(t),a)),u=Ii(y.parse(n),c),l=Ii(s,c.subarray(0,s.length)),d=r.replace(/wallet:/,"").replace("-",""),f=t.replace(/wallet:/,"").replace("-",""),p=Qr({dataKey:a,syncKey:l});for(const h of Object.keys(o)){const e=h===d+"Key"?f+"Key":h;null==p[e]&&(p[e]=o[h])}return{id:y.stringify(u),keys:p,type:t}}async function mi(e,t,n,r,o){const i=e.props.state.accounts[t],{allWalletInfosFull:a,sessionKey:s}=i,c=e.props.state.plugins.currency,u=new Map;for(const h of r){const{walletType:e}=h;if(null==Jr(c,h.walletType))throw new Error(`Cannot find plugin for wallet type "${e}"`);if(u.has(e))throw new Error(`Duplicate wallet type "${e}"`);u.set(e,vi(n,e))}if("wallet:bitcoincash"===n.type&&u.has("wallet:bitcoinsv")){var l;const t=null===(l=e.props.output)||void 0===l||null===(l=l.currency)||void 0===l||null===(l=l.wallets[n.id])||void 0===l?void 0:l.walletApi;if(null==t)throw new Error(`Cannot find wallet ${n.id}`);await async function(e){const t={currencyCode:"BCH",tokenId:null},n=wi(wi({},t),{},{spendTargets:[{nativeAmount:"10000",otherParams:{script:{type:"replayProtection"}},publicAddress:""}],metadata:{},networkFeeOption:"high"}),r=await e.makeSpend(n),o=await e.signTx(r),i=await e.broadcastTx(o);await e.saveTx(i);const{publicAddress:a}=await e.getReceiveAddress(t),s=wi(wi({},t),{},{metadata:{name:"Replay Protection Tx",notes:"This transaction is to protect your BCH wallet from unintentionally spending BSV funds. Please wait for the transaction to confirm before making additional transactions using this BCH wallet."},networkFeeOption:"high",spendTargets:[{publicAddress:a,nativeAmount:"0"}]}),c=await e.getMaxSpendable(s);s.spendTargets[0].nativeAmount=c;const u=await e.makeSpend(s),l=await e.signTx(u),d=await e.broadcastTx(l);await e.saveTx(d)}(t)}const d=[],f=[];for(const h of u.values()){const e=a.find((e=>e.id===h.id));if(null==e)f.push(h);else if(e.archived||e.deleted)d.push(e);else if(o&&("wallet:bitcoincash"!==n.type||"wallet:bitcoinsv"!==h.type))throw new Error(`This wallet has already been split (${h.type})`)}if(d.length>0){const n={};let r=!1;for(const e of d)(e.archived||e.deleted)&&(r=!0,n[e.id]={archived:!1,deleted:!1,migratedFromWalletId:e.migratedFromWalletId});r&&await hi(e,t,n)}if(f.length>0){const t=Qo(e,s,f,!0);await Yn(e,s,t)}const p=await Promise.all(r.map((async t=>{const n=u.get(t.walletType);if(null==n)throw new Error(`Missing wallet info for ${t.walletType}`);return await yo(async function(e,t,n){const r=await Go(e,t);null!=(null==n?void 0:n.name)&&await r.renameWallet(n.name).catch((t=>e.props.onError(t)));null!=(null==n?void 0:n.fiatCurrencyCode)&&await r.setFiatCurrencyCode(n.fiatCurrencyCode).catch((t=>e.props.onError(t)));return r}(e,n.id,null!=f.find((e=>e.type===t.walletType))?t:void 0))})));return p}function Ii(e,t){if(e.length!==t.length)throw new Error(`Array lengths do not match: ${e.length}, ${t.length}`);const n=new Uint8Array(e.length);for(let r=0;r<e.length;++r)n[r]=e[r]^t[r];return n}function Ei(e,t){const{id:n,type:r,keys:o}=t;return{id:n,type:r,keys:o,get disklet(){return bo(e.props.state,n)},get localDisklet(){return go(e.props.state,n)},async sync(){await ho(e,n)}}}const Si={"[object Float32Array]":!0,"[object Float64Array]":!0,"[object Int16Array]":!0,"[object Int32Array]":!0,"[object Int8Array]":!0,"[object Uint16Array]":!0,"[object Uint32Array]":!0,"[object Uint8Array]":!0,"[object Uint8ClampedArray]":!0};function Oi(e,t){if(e===t)return!0;if("object"!=typeof e)return!1;if("object"!=typeof t)return!1;const n=Object.prototype.toString.call(e);return n===Object.prototype.toString.call(t)&&function(e,t,n){if("[object Object]"===n){if(Object.getPrototypeOf(e)!==Object.getPrototypeOf(t))return!1;const n=Object.getOwnPropertyNames(e);if(n.length!==Object.getOwnPropertyNames(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Oi(e[r],t[r]))return!1;return!0}if("[object Array]"===n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!Oi(e[n],t[n]))return!1;return!0}if("[object Date]"===n)return e.getTime()===t.getTime();if("[object Map]"===n)return function(e,t){if(e.size!==t.size)return!1;for(const[n,r]of e)if(!t.has(n)||t.get(n)!==r)return!1;return!0}(e,t);if(Si[n]){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(e[n]!==t[n])return!1;return!0}return!1}(e,t,n)}let Ai=500,Ti=3;const _i=[];let ki;function xi(e){_i.length<=0&&Pi();let t=!1;for(const n of _i)if(n.id===e.id&&n.action===e.action){n.updateFunc=e.updateFunc,t=!0;break}t||_i.push(e)}function Pi(){ki=setTimeout((()=>{const e=Math.min(Ti,_i.length);for(let t=0;t<e;t++){const e=_i.shift();null!=e&&e.updateFunc()}_i.length>0&&Pi()}),Ai)}function Mi(e,t){var n,r,o,i,a,s;const c={exchangeAmount:{}},{exchangeAmount:u={}}=c,l=null!==(n=e.exchangeAmount)&&void 0!==n?n:{},d=null!==(r=t.exchangeAmount)&&void 0!==r?r:{};for(const f of Object.keys(l))null!==d[f]&&(u[f]=l[f]);for(const f of Object.keys(d)){const e=d[f];null!=e&&(u[f]=e)}return null!==t.bizId&&(c.bizId=null!==(o=t.bizId)&&void 0!==o?o:e.bizId),null!==t.category&&(c.category=null!==(i=t.category)&&void 0!==i?i:e.category),null!==t.name&&(c.name=null!==(a=t.name)&&void 0!==a?a:e.name),null!==t.notes&&(c.notes=null!==(s=t.notes)&&void 0!==s?s:e.notes),c}const Ci=ye({bizId:ae(ue),category:ae(le),exchangeAmount:ae(ye(ue)),name:ae(le),notes:ae(le)}),Ni=be(le,de),ji=se("high","standard","low"),Di=ye({orderId:ae(le),orderUri:ae(le),isEstimate:ce,plugin:ye({pluginId:le,displayName:le,supportEmail:ae(le)}),payoutAddress:le,payoutCurrencyCode:le,payoutTokenId:ae(Ni),payoutNativeAmount:le,payoutWalletId:le,refundAddress:ae(le)});function Ri(e){const t=le(e);if(!/^\d+$/.test(t))throw new Error("Expected an integer string");return t}const Li=ye({pluginId:le,tokenId:Ni,nativeAmount:ae(Ri)}),Bi=ye({fiatCurrencyCode:le,fiatAmount:le}),Ki=ye({pluginId:le,displayName:le,isDex:ae(ce),orderUri:ae(le),supportEmail:le}),Ui=be(ye({actionType:se("swap"),swapInfo:Ki,orderId:ae(le),orderUri:ae(le),isEstimate:ae(ce),canBePartial:ae(ce),fromAsset:Li,toAsset:Li,payoutWalletId:le,payoutAddress:le,refundAddress:ae(le)}),ye({actionType:se("stake"),pluginId:le,stakeAssets:he(Li)}),ye({actionType:se("fiat"),orderId:le,orderUri:ae(le),isEstimate:ce,fiatPlugin:ye({providerId:le,providerDisplayName:le,supportEmail:ae(le)}),payinAddress:ae(le),payoutAddress:ae(le),fiatAsset:Bi,cryptoAsset:Li}),ye({actionType:se("tokenApproval"),tokenApproved:Li,tokenContractAddress:le,contractAddress:le}),ye({actionType:se("giftCard"),orderId:le,orderUri:ae(le),productId:ae(le),quoteId:ae(le),provider:ye({providerId:le,displayName:le,supportEmail:ae(le)}),card:ye({name:le,imageUrl:ae(le),fiatAmount:le,fiatCurrencyCode:le}),redemption:ae(ye({code:ae(le),url:ae(le)}))})),Fi=ye({assetActionType:se("claim","claimOrder","stake","stakeNetworkFee","stakeOrder","unstake","unstakeNetworkFee","unstakeOrder","swap","swapNetworkFee","swapOrderPost","swapOrderFill","swapOrderCancel","buy","sell","sellNetworkFee","tokenApproval","transfer","transferNetworkFee","giftCard")}),Wi=he(le),qi=ye({enabledTokenIds:he(le),detectedTokenIds:he(le)}),zi=ye({assetAction:ae(Fi),metadata:e=>{const t=Ci(e),{exchangeAmount:n={}}=t;for(const r of Object.keys(n))String(n[r]).includes("e")&&delete n[r];return t},nativeAmount:ae(le),providerFeeSent:ae(le)}),Gi=ye({txid:le,internal:ce,creationDate:ue,currencies:function(e){const t=ye(e);return we((e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(t,n[t]);return r}),(e=>{const n={};return e.forEach(((e,t)=>{n[t]=e})),t(n)}))}(zi),tokens:ae(function(e){const t=ye(e);return we((e=>{const n=t(e),r=new Map;for(const t of Object.keys(n))r.set(""===t?null:t,n[t]);return r}),(e=>{const n={};return e.forEach(((e,t)=>{n[null==t?"":t]=e})),t(n)}))}(zi),(()=>new Map)),deviceDescription:ae(le),feeRateRequested:ae(be(ji,Sr)),feeRateUsed:ae(Sr),payees:ae(he(ye({address:le,amount:le,currency:le,tag:ae(le)}))),savedAction:ae(Ui),secret:ae(le),swap:ae(Di)}),$i=ye({airbitzFeeWanted:ue,meta:ye({amountFeeAirBitzSatoshi:ue,balance:ue,fee:ue,amountCurrency:ue,bizId:ue,category:le,name:le,notes:le,attributes:ue,amountSatoshi:ue,amountFeeMinersSatoshi:ue,airbitzFee:ue}),ntxid:le,state:ye({creationDate:ue,internal:ce,malleableTxId:le})}),Hi=ye({seq:ue,address:le,state:ye({recycleable:ae(ce,!0),creationDate:ae(ue,0)}),meta:ye({amountSatoshi:ae(ue,0)}).withRest}),Yi=ye(ye({timestamp:ue,txidHash:le})),Vi=ye({walletInfo:ye({id:le,keys:Sr,type:le})}),Ji=ye({checkpoint:ae(le),subscribedAddresses:ae(he(ye({address:le,checkpoint:ae(le)})),(()=>[]))}),Xi=ye({fiat:ae(le),num:ae(ue)}),Zi=ye({walletName:be(le,de)});var Qi=n(3546);function ea(e){for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}const ta=En;function na(e,t){return e+t}async function ra(e,t,n,r){return await async function(e,t,n,r){const{now:o=new Date}=r,{passwordBox:i,passwordKeySnrp:a,username:s}=t;if(null==i||null==a||null==s)throw new Error("Missing data for offline password login");const c=na(s,n),u=await In(e,c,a),l={loginId:t.loginId,loginKey:un(i,u)};t.lastLogin=o,Pn(e,t).catch((()=>{}));const{log:d}=e.props;return Jn(e,l).catch((e=>d.error(e))),l}(e,t,n,r).catch((()=>async function(e,t,n,r){const{username:o}=t;if(null==o)throw new Error("Password login requires a username");const i=na(o,n),[a,s]=await Promise.all([kn(e,o),In(e,i,ta)]),c={userId:a,passwordAuth:s};return await Hn(e,t,t,r,c,(async t=>{const{passwordBox:n,passwordKeySnrp:r}=t;if(null==n||!0===n||null==r)throw new Error("Missing data for online password login");return un(n,await In(e,i,r))}))}(e,t,n,r)))}async function oa(e,t,n,r){const o=na(n,r),{io:i}=e.props,[{passwordKeySnrp:a,passwordBox:s},{passwordAuth:c,passwordAuthBox:u}]=await Promise.all([mn(e).then((async n=>{const r=await In(e,o,n);return{passwordKeySnrp:n,passwordBox:ln(i,t.loginKey,r)}})),In(e,o,ta).then((e=>({passwordAuth:e,passwordAuthBox:ln(i,e,t.loginKey)})))]);return{loginId:t.loginId,server:ut({passwordAuth:c,passwordAuthSnrp:ta,passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}),serverPath:"/v2/login/password",stash:{passwordKeySnrp:a,passwordBox:s,passwordAuthBox:u}}}function ia(e,t){return rn(null==t?Uint8Array.from([0]):Dt.parse(t),e)}function aa(e,t){return rn(Dt.parse(t),e)}function sa(e,t){if(null!=e.pin2Key)return e;const n=Un(e,(e=>e.appId===t));return null!=(null==n?void 0:n.pin2Key)?n:void 0}async function ca(e,t,n,r,o){if(null==n.pin2Key)throw new Wt("PIN login is not enabled for this account on this device");const{pin2Key:i}=n,a={pin2Id:ia(i,t.username),pin2Auth:aa(i,r)};return await Hn(e,t,n,o,a,(async e=>{if(null==e.pin2Box||!0===e.pin2Box)throw new Error("Missing data for PIN v2 login");return un(e.pin2Box,i)}))}async function ua(e,t,n){const r=e.props.state.accounts[t],o=r.activeAppId.endsWith(".duress"),{loginTree:i,login:a,sessionKey:s}=r,{username:c}=r.stashTree;let{pin:u,enableLogin:l,forDuressAccount:d=!1}=n;if(null==l&&(l=null!=i.pin2Key||null!=u&&null==i.pin),null==u&&(u=a.pin),o&&!d)return await Vn(e,s,da(e,i,c,l,!0)),void(null!=u&&await Vn(e,s,la(e,i,c,u,!0,!0)));if(null==u){if(l)throw new Error("Please change your PIN in the settings area above before enabling.");return void(await Vn(e,s,pa(i,d||o)))}const f=la(e,i,c,u,l,d||o);await Vn(e,s,f)}function la(e,t,n,r,o,i){const a=[];i===t.appId.endsWith(".duress")&&a.push(fa(e,t,n,r,o));for(const s of t.children)a.push(...la(e,s,n,r,o,i));return a}function da(e,t,n,r,o){const i=[];o===t.appId.endsWith(".duress")&&i.push(function(e,t){const{loginId:n}=e;return{loginId:n,server:void 0,serverPath:"",stash:{fakePinDisabled:!t}}}(t,r));for(const a of t.children)i.push(...da(e,a,n,r,o));return i}function fa(e,t,n,r,o){const{io:i}=e.props,a=ln(i,Dt.parse(r),t.loginKey);if(o){const{loginId:e,loginKey:o,pin2Key:s=i.random(32)}=t,c=ln(i,o,s),u=ln(i,s,o);return{loginId:e,server:dt({pin2Id:ia(s,n),pin2Auth:aa(s,r),pin2Box:c,pin2KeyBox:u,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:s,pin2TextBox:a}}}return{loginId:t.loginId,server:dt({pin2Id:void 0,pin2Auth:void 0,pin2Box:void 0,pin2KeyBox:void 0,pin2TextBox:a}),serverPath:"/v2/login/pin2",stash:{pin2Key:void 0,pin2TextBox:a}}}function pa(e,t){const n=[];null!=t&&t!==e.appId.endsWith(".duress")||n.push(function(e){return{loginId:e.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/pin2",stash:{pin2Key:void 0}}}(e));for(const r of e.children)n.push(...pa(r,t));return n}function ha(e,t){return rn(Dt.parse(t),e)}function ya(e,t){return t.map((t=>rn(Dt.parse(t),e)))}async function ba(e,t,n,r){const o=e.props.state.accounts[t],{loginTree:i,sessionKey:a}=o,{username:s}=o.stashTree;if(null==s)throw new Error("Recovery login requires a username");const c=function(e,t,n,r,o){const{io:i}=e.props;if(!Array.isArray(r))throw new TypeError("Questions must be an array of strings");if(!Array.isArray(o))throw new TypeError("Answers must be an array of strings");const{loginId:a,loginKey:s,recovery2Key:c=i.random(32)}=t,u=ln(i,Dt.parse(JSON.stringify(wa(r))),c),l=ln(i,s,c),d=ln(i,c,s);return{loginId:a,server:pt({recovery2Id:ha(c,n),recovery2Auth:ya(c,o),recovery2Box:l,recovery2KeyBox:d,question2Box:u}),serverPath:"/v2/login/recovery2",stash:{recovery2Key:c}}}(e,i,s,n,r);await Yn(e,a,c)}const ga=he(le),wa=ve(ga);function va(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ma(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?va(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):va(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function Ia(e,t,n){var r,o,i,a;const{password:s,username:c}=n,{isRoot:u,loginId:l,passwordAuth:d}=t;if(null!=d&&null==s)throw new Error("A password is required to change the username");const f=function(e,t){const{loginId:n,pin2Key:r}=e;if(null!=r)return{loginId:n,server:lt({pin2Id:ia(r,t)}),serverPath:"",stash:{}}}(t,c),p=function(e,t){const{loginId:n,recovery2Key:r}=e;if(null!=r)return{loginId:n,server:ft({recovery2Id:ha(r,t)}),serverPath:"",stash:{}}}(t,c);let h,y;if(null!=s&&(h=await oa(e,t,c,s)),u&&(y=await Ea(e,t,c)),null!=h||null!=f||null!=p||null!=y)return{loginId:l,server:ma(ma(ma(ma({},null===(r=h)||void 0===r?void 0:r.server),null==f?void 0:f.server),null==p?void 0:p.server),null===(o=y)||void 0===o?void 0:o.server),serverPath:"/v2/login/username",stash:ma(ma(ma(ma({},null===(i=h)||void 0===i?void 0:i.stash),null==f?void 0:f.stash),null==p?void 0:p.stash),null===(a=y)||void 0===a?void 0:a.stash)}}async function Ea(e,t,n){const{io:r}=e.props,{loginId:o,loginKey:i}=t,a=await kn(e,n);return{loginId:o,server:yt({userId:a,userTextBox:ln(r,Dt.parse(n),i)}),serverPath:"",stash:{userId:a,username:n}}}function Sa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Oa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Sa(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Sa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function Aa(e,t,n,r){var o,i,a,s,c,u,l,d;const{keyInfo:f,password:p,pin:h,username:y}=r,{io:b}=e.props;e.props.log.breadcrumb("makeCreateKit",{});const g=null==t,w=b.random(32),v=b.random(32),m={loginId:w,loginKey:v},I={appId:n,lastLogin:new Date,loginId:w,loginKey:v,isRoot:g,pendingVouchers:[],children:[]},E=vn(e,I);let S,O,A,T,_;null!=f&&(S=Qo(e,m,[f])),null!=t&&(O=ln(b,v,t.loginKey)),null!=p&&null!=y&&(A=await oa(e,I,y,p)),null!=h&&(T=fa(e,I,y,h,!0)),g&&null!=y&&(_=await Ea(e,I,y));return{kit:{loginId:w,server:Oa(Oa(Oa(Oa(Oa(Oa({},wt({appId:n,loginId:w,parentBox:O})),null===(o=S)||void 0===o?void 0:o.server),null===(i=A)||void 0===i?void 0:i.server),null===(a=T)||void 0===a?void 0:a.server),E.server),null===(s=_)||void 0===s?void 0:s.server),serverPath:"/v2/login/create",stash:Oa(Oa(Oa(Oa(Oa({appId:n,loginId:w,parentBox:O},null===(c=S)||void 0===c?void 0:c.stash),null===(u=A)||void 0===u?void 0:u.stash),null===(l=T)||void 0===l?void 0:l.stash),E.stash),null===(d=_)||void 0===d?void 0:d.stash)},sessionKey:m}}async function Ta(e,t,n,r){const{log:o}=e.props,i=Un(t,(e=>e.appId===r));if(null==i)return e.props.log.breadcrumb("createChildLogin",{}),await async function(e,t,n,r){let o;null!=t.pin2TextBox&&(o=cn(t.pin2TextBox,n.loginKey));const{kit:i}=await Aa(e,n,r,{keyInfo:Zo(Xo(r),Qr(eo(e))),pin:o,username:t.username}),a={loginId:n.loginId,server:i.server,serverPath:i.serverPath,stash:{children:[i.stash]}};return await Yn(e,n,a)}(e,t,n,r);const a=Xn(t,n,i.loginId),s=ti(i,a.loginKey);o.warn(`Login: decrypted keys for user ${y.stringify(t.loginId)}`);const c=Xo(r);if(null==Jo(s,c)){e.props.log.breadcrumb("createAccountRepo",{});const t=Qo(e,a,[Zo(c,Qr(eo(e)))]);return await Yn(e,n,t)}return t}async function _a(e,t,n,r){const{pauseWallets:o=!1}=r,i=!0===r.duressMode?e.props.state.login.contextAppId+".duress":e.props.state.login.contextAppId,{log:a}=e.props;e.props.log.breadcrumb("makeAccount",{});const{stashTree:s}=An(e,t.loginId);return await Ta(e,s,t,i),a.warn("Login: account exists for appId"),e.props.dispatch({type:"LOGIN",payload:{appId:i,loginType:n,pauseWallets:o,rootLoginId:s.loginId,sessionKey:t}}),await function(e,t){const n=e.waitFor((e=>{const n=e.state.accounts[t];if(null!=n.loadFailure)throw n.loadFailure;const r=e.output.accounts[t];if(null!=(null==r?void 0:r.accountApi))return r.accountApi}));return n}(e,e.props.state.lastAccountId)}var ka=n(6266);function xa(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Pa(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?xa(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xa(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ma=new(0,n.n(ka)().ec)("secp256k1");function Ca(e,t){const n=e.derive(Ma.keyFromPublic(t).getPublic()).toArray("be");return rn(Uint8Array.from([0,0,0,1,...n]),Dt.parse("dataKey"))}function Na(e,t){const{publicKey:n}=t,r=Ca(e,n);return JSON.parse(cn(t.box,r))}function ja(e,t,n){const r=Ma.genKeyPair({entropy:e.random(32)}),o=Ca(r,t);return{publicKey:Uint8Array.from(r.getPublic().encodeCompressed()),box:ln(e,Dt.parse(JSON.stringify(n)),o)}}async function Da(e,t,n=1e3){const{io:r}=e.props,{timeout:o=600}=t,i=Ma.genKeyPair({entropy:r.random(32)}),a=Uint8Array.from(i.getPublic().encodeCompressed()),s=jt.stringify(on(on(a)).slice(0,10)),c={data:it(Pa(Pa({},t),{},{publicKey:a,timeout:o}))};await gn(e,"PUT",`/v2/lobby/${s}`,c);const[u,l]=(d={},[function(e,t){var n=d[e];return null==n&&(n=d[e]=function(){var e=[],t=!1;function n(){t&&(t=!1,e=e.slice())}return[function(t){n(),e.push(t);var r=!0;return function(){r&&(r=!1,n(),e.splice(e.indexOf(t),1))}},function(n){t=!0;for(var r=e,o=0;o<r.length;++o)r[o](n);t=!1}]}()),n[0](t)},function(e,t){var n=d[e];null!=n&&n[1](t)}]);var d;const f=[],p=Hr((async()=>{const t=Ye(await gn(e,"GET","/v2/lobby/"+s));for(;f.length<t.replies.length;){const e=t.replies[f.length],n=Na(i,e);l("reply",n),f.push(n)}}),n,{onError(e){l("error",e)}});return p.start({wait:!1}),{close:()=>p.stop(),lobbyId:s,on:u,replies:f}}async function Ra(e,t){const n=Ye(await gn(e,"GET","/v2/lobby/"+t)),{publicKey:r}=n.request,o=on(on(r)),i=jt.parse(t);if(!an(i,o.subarray(0,i.length)))throw new Error("Lobby ECDH integrity error");return n.request}async function La(e,t,n,r){const{io:o}=e.props,{publicKey:i}=n,a={data:ot(ja(o,i,r))};await gn(e,"POST","/v2/lobby/"+t,a)}const Ba=ye({appId:le,loginKey:Ae,loginStash:Mn});async function Ka(e,t,n={}){function r(e){for(const t of a)t();s.state="error",s.error=e,U(s),B(s)}async function o(r){for(const e of a)e();const o=Ba(r),{username:i}=o.loginStash;s.state="started",s.username=i,U(s);const c=await async function(e,t,n,r){const{now:o=new Date}=r,{loginKey:i,loginStash:a}=t;e.props.log.breadcrumb("unpackAccount",{});const s=Un(a,(e=>e.appId===n));if(null==s)throw new Error(`Cannot find requested appId: "${n}"`);try{const t=An(e,s.loginId);s.voucherId=t.stash.voucherId,s.voucherAuth=t.stash.voucherAuth}catch(u){}a.lastLogin=o,await Pn(e,a);const c={loginId:s.loginId,loginKey:i};return await Jn(e,c),await _a(e,c,"edgeLogin",r)}(e,o,t,n);s.state="done",s.account=c,U(s),B(s)}const i=await Da(e,{loginRequest:{appId:t}}),a=[i.close,i.on("error",(function(e){s.error=e,U(s)})),i.on("reply",(e=>{o(e).catch(r)}))],s={id:i.lobbyId,cancelRequest:async function(){for(const e of a)e();s.state="closed",U(s),B(s)},watch:X,state:"pending",account:void 0,error:void 0,username:void 0};return _(s)}const Ua=ve(Ba),Fa=ye({appName:le,darkImageUrl:ae(le),lightImageUrl:ae(le),imageUrl:ae(le)});async function Wa(e,t){try{const[n]=ea(e.props.state.infoServers),r=`${n}/v1/appIdInfo/${t}`,o=await e.props.io.fetch(r,{corsBypass:"never"});if(404===o.status)return{appName:t};if(!o.ok)throw new Error(`Fetching ${r} returned ${o.status}`);const i=Fa(await o.json());return null==i.lightImageUrl&&(i.lightImageUrl=i.imageUrl),null==i.darkImageUrl&&(i.darkImageUrl=i.imageUrl),i}catch(n){return e.props.onError(n),{appName:t}}}async function qa(e,t,n){const r=await Ra(e,n);let o;null!=r.loginRequest&&(o=await async function(e,t,n,r,o){e.props.log.breadcrumb("unpackLoginRequest",{});const i=await Wa(e,o),a={appId:o,displayName:i.appName,displayImageDarkUrl:i.darkImageUrl,displayImageLightUrl:i.lightImageUrl,approve(){return async function(e,t,n,r,o){const{sessionKey:i}=e.props.state.accounts[t];e.props.log.breadcrumb("approveLoginRequest",{}),await Jn(e,i);const{stashTree:a}=An(e,i.loginId),s=await Ta(e,a,i,n),c=Un(s,(e=>e.appId===n));if(null==c)throw new Error("Failed to create the requested login object");const u=Xn(s,i,c.loginId),l=Ua({appId:n,loginKey:u.loginKey,loginStash:$n(s,n)});let d;await La(e,r,o,l);const f=e.props.output.accounts[t].accountApi;null!=f&&f.on("close",(()=>{null!=d&&clearTimeout(d)})),d=setTimeout((()=>{d=void 0,Jn(e,i).then((()=>{d=setTimeout((()=>{d=void 0,Jn(e,i).catch((t=>e.props.onError(t)))}),2e4)})).catch((t=>e.props.onError(t)))}),1e4)}(e,t,o,n,r)},async close(){B(a)}};return _(a),a}(e,t,n,r,r.loginRequest.appId));const i={loginRequest:o};return _(i),i}function za(e){const t={};for(const n of Object.keys(e)){t[e[n].currencyCode]=n}return t}function Ga(e={},t={},n,r){const o=[];for(const a of r){var i;const n=null!==(i=t[a])&&void 0!==i?i:e[a];null!=n&&o.push(n.currencyCode)}return o}function $a(e,t=[]){const n=new Set(t),r=[];for(const o of e)n.has(o)||(n.add(o),r.push(o));return r}function Ha(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ya(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ha(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ha(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Va="Currency.json",Ja="fixedLegacyFileNames.json",Xa="EnabledTokens.json",Za="seenTxCheckpoint.json",Qa="Tokens.json",es="WalletName.json",ts=Er(Hi),ns=Er(Yi),rs=Er(Wi),os=Er($i),is=Er(Ji),as=Er(qi),ss=Er(Gi),cs=Er(Xi),us=Er(Zi);function ls(e,t,n,r){var o;const i=e.currency.wallets[t].fileNames,a=wo(e,t,n),{creationDate:s=Math.min(r,Date.now()/1e3)}=null!==(o=i[a])&&void 0!==o?o:{},c=`${s.toFixed(0)}-${a}.json`;return{creationDate:s,fileName:c,txidHash:a}}async function ds(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await cs.load(o,Va);let a="iso:USD";if(null!=i)if(null!=i.fiat)a=i.fiat;else if(null!=i.num){const e=(0,Qi.Rx)(`000${i.num}`.slice(-3));null!=e&&(a=`iso:${e.code}`)}t({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:a,walletId:r}})}async function fs(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await us.load(o,es);let a=null;if(null==i||null==i.walletName){const{appIds:t=[]}=e.props.walletState.walletInfo,n=t.find((e=>""!==e));if(null!=n){const{appName:t}=await Wa(yu(e),n);a=t}}else a=i.walletName;t({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:"string"==typeof a?a:null,walletId:r}})}async function ps(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await as.load(o,Qa);if(null!=i){const n=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${n} loaded modern file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:Ya({walletId:e.props.walletId},i)})}const a=await rs.load(o,Xa);if(null!=a){const{accountId:n,currencyInfo:o,pluginId:i}=e.props.walletState,s=e.props.state.accounts[n],c=function(e={},t={},n,r){const o=za(e),i=za(t),a=[];for(const c of r){var s;const e=null!==(s=i[c])&&void 0!==s?s:o[c];null!=e&&a.push(e)}return a}(s.builtinTokens[i],s.customTokens[i],0,a),u=r.slice(0,2);return e.props.log.warn(`enabledTokenIds: ${u} loaded legacy file`),void t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:c}})}const s=r.slice(0,2);e.props.log.warn(`enabledTokenIds: ${s} loaded neither file`),t({type:"CURRENCY_WALLET_LOADED_TOKEN_FILE",payload:{walletId:e.props.walletId,detectedTokenIds:[],enabledTokenIds:[]}})}async function hs(e,t){const{dispatch:n,walletId:r}=e.props,o=bo(e.props.state,r),i=e.props.walletState.currencyInfo.currencyCode,a=e.props.walletState.fileNames,s=e.props.walletState.fiat,c={};return await Promise.all(t.map((async e=>{if(null==a[e])return;const t=`Transactions/${a[e].fileName}`,n=await os.load(o,t);null!=n&&(c[e]=function(e,t,n){const r={creationDate:e.state.creationDate,currencies:new Map,tokens:new Map,internal:e.state.internal,txid:e.state.malleableTxId},o={};return o[n]=e.meta.amountCurrency,r.currencies.set(t,{metadata:{bizId:e.meta.bizId,category:e.meta.category,exchangeAmount:o,name:e.meta.name,notes:e.meta.notes},providerFeeSent:e.meta.amountFeeAirBitzSatoshi.toFixed()}),r}(n,i,s))}))),await Promise.all(t.map((async e=>{if(null==a[e])return;const t=`transaction/${a[e].fileName}`,n=await ss.load(o,t);null!=n&&(c[e]=n)}))),n({type:"CURRENCY_WALLET_FILES_LOADED",payload:{files:c,walletId:r}}),c}async function ys(e){const{dispatch:t,state:n,walletId:r}=e.props,o=bo(n,r),i=await async function(e,t,n){var r;const o=go(e,t),i=null!==(r=await ns.load(o,Ja))&&void 0!==r?r:{},a=(0,ee.gQ)(await n.list()),s={},c=[];for(let l=0;l<a.length;l++){const e=a[l],t=i[e];if(null!=t){const{timestamp:n,txidHash:r}=t;s[r]={creationDate:n,fileName:e}}else c.push(e)}const u=c.map((async r=>{const o=await os.load(n,r);if(null==o)return;const{creationDate:a,malleableTxId:c}=o.state,u=r,l=wo(e,t,c);s[l]={creationDate:a,fileName:u},i[u]={timestamp:a,txidHash:l}}));return u.length>0&&(await Promise.all(u),await ns.save(o,Ja,i).catch((()=>{}))),s}(n,r,(0,ee.HN)(o,"Transactions")),a=await(0,ee.HN)(o,"transaction").list();for(const s of(0,ee.gQ)(a)){const e=s.split(".json")[0].split("-"),[t,n]=e,r=parseInt(t);(null==i[n]||r<i[n].creationDate)&&(i[n]={creationDate:r,fileName:s})}t({type:"CURRENCY_WALLET_FILE_NAMES_LOADED",payload:{txFileNames:i,walletId:r}})}async function bs(e){var t;const{state:n,walletId:r}=e.props,o=bo(n,r),i=[],a=(0,ee.gQ)(await o.list("Addresses"));await Promise.all(a.map((async e=>{const t=await ts.load(o,e);null!=t&&(""===t.address||t.state.recycleable||i.push(t.address))})));const s=null===(t=e.props.walletOutput)||void 0===t?void 0:t.engine;null!=s&&await s.addGapLimitAddresses(i)}async function gs(e,t,n,r,o,i,a){var s,c;const{dispatch:u,state:l,walletId:d}=e.props,f=bo(l,d),{accountId:p,currencyInfo:h,pluginId:y}=e.props.walletState,b=e.props.state.accounts[p].allTokens[y],{currencyCode:g}=null==n?h:b[n],w=e.props.walletState.txs[t];if(null==w)throw new Error(`Setting metatdata for missing tx ${t}`);const{creationDate:v,fileName:m,txidHash:I}=ls(l,d,w.txid,w.date),E=await ss.load(f,`transaction/${m}`),S=Ya(Ya({},E),{},{creationDate:v,currencies:new Map(null!==(s=null==E?void 0:E.currencies)&&void 0!==s?s:[]),internal:!0,tokens:new Map(null!==(c=null==E?void 0:E.tokens)&&void 0!==c?c:[]),txid:t}),O=Ya(Ya({metadata:{}},S.currencies.get(g)),S.tokens.get(n));var A;(S.tokens.set(n,O),S.currencies.delete(g),null!=o)&&(O.metadata=Mi(null!==(A=O.metadata)&&void 0!==A?A:{},o));null!=i&&(O.assetAction=i),null!=a&&(S.savedAction=a),u({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:v,fileName:m,json:S,txid:t,txidHash:I,walletId:d}}),await ss.save(f,"transaction/"+m,S);const T=ac(e,w,S,n);r.onTransactions([{isNew:!1,transaction:T}])}async function ws(e,t){var n;const{dispatch:r,state:o,walletId:i}=e.props,{creationDate:a,fileName:s,txidHash:c}=ls(o,i,t.txid,t.date),u={txid:t.txid,internal:!0,creationDate:a,currencies:new Map,feeRateUsed:t.feeRateUsed,tokens:new Map,savedAction:t.savedAction,swap:t.swapData};return u.tokens.set(t.tokenId,{assetAction:t.assetAction,metadata:null!==(n=t.metadata)&&void 0!==n?n:{},nativeAmount:t.nativeAmount}),null!=t.networkFeeOption&&(u.feeRateRequested="custom"===t.networkFeeOption?t.requestedCustomFee:t.networkFeeOption),null!=t.spendTargets&&(u.payees=t.spendTargets.map((e=>({currency:e.currencyCode,address:e.publicAddress,amount:e.nativeAmount,tag:e.memo}))),null!=t.deviceDescription&&(u.deviceDescription=t.deviceDescription)),"string"==typeof t.txSecret&&(u.secret=t.txSecret),r({type:"CURRENCY_WALLET_FILE_CHANGED",payload:{creationDate:a,fileName:s,json:u,txid:t.txid,txidHash:c,walletId:i}}),{fileName:s,txFile:u}}async function vs(e,t,n){var r;const{dispatch:o,state:i,walletId:a}=e.props,s=bo(i,a),c=await is.load(s,Za),u={checkpoint:t,subscribedAddresses:null!==(r=null!=n?n:(null!=c?c:{checkpoint:void 0,subscribedAddresses:[]}).subscribedAddresses)&&void 0!==r?r:[]};null!=t&&o({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:t,walletId:a}}),await is.save(s,Za,u)}var ms="redux-keto wrapper";function Is(e,t,n){for(var r=Object.create(null),o=function(){var e=a[i],o=t(e);Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var t=this,r=t[ms];if(r.running[e]){var i=new ReferenceError("Reducer '"+e+"' depends on its own result");throw i.name="ReduxKetoCircularReferenceError",i}r.running[e]=!0;try{var a=o(r.state[e],r.action,n(r.next,t,e),n(r.prev,r.state,e));if(void 0===a)throw new TypeError("Reducer '"+e+"' returned undefined");return Object.defineProperty(t,e,{configurable:!0,enumerable:!0,writable:!1,value:a}),a}finally{r.running[e]=!1}}})},i=0,a=e;i<a.length;i+=1)o();return r}function Es(e,t,n,r,o){var i=Object.create(e);return Object.defineProperty(i,ms,{configurable:!0,enumerable:!1,writable:!1,value:{state:t,action:n,next:r,prev:o,running:{}}}),i}function Ss(e,t){if(void 0===e&&(e={}),null===t||null==t[ms])return t;for(var n=Object.keys(Object.getPrototypeOf(t)),r=Object.keys(e).length===n.length,o=0,i=n;o<i.length;o+=1){var a=i[o];Object.defineProperty(t,a,{configurable:!1,enumerable:!0,writable:!1,value:Ss(e[a],t[a])}),t[a]!==e[a]&&(r=!1)}return r?e:(delete t[ms],t)}function Os(e,t,n){return void 0!==e?e:t}function As(e,t){if(void 0===t&&(t=Os),"object"!=typeof e||null===e)throw new TypeError("The reducer map must be an object.");for(var n=Object.keys(e),r=0,o=n;r<o.length;r+=1){var i=o[r];if("function"!=typeof e[i])throw new TypeError("Reducers must be functions.")}for(var a=Is(n,(function(t){return e[t]}),t),s={},c=0,u=n;c<u.length;c+=1){var l=u[c];s[l]=e[l].defaultState}function d(e,t,n,r){void 0===e&&(e=s);var o=Es(a,e,t,n,r);return void 0===n?Ss(e,o):o}return d.defaultState=s,d}function Ts(e,t){return e}function _s(e){return e}function ks(e,t,n){void 0===t&&(t=Ts),void 0===n&&(n=_s);var r=e.defaultState;function o(o,i,a,s){void 0===o&&(o=r);var c=t(i,a),u=n(a),l=n(s);if(!c)return o;var d=e(o,c,u,l);return void 0===a?Ss(o,d):d}return o.defaultState=r,o}function xs(e,t,n){return{id:n,root:void 0!==e?e:t,get self(){return t[n]}}}var Ps={};function Ms(e,t,n){function r(r,o,i,a){void 0===r&&(r=Ps);var s=t(i),c=Es(r===Ps||s!==t(a)?Is(s,(function(t){return e}),n):Object.getPrototypeOf(r),r,o,i,a);return void 0===i?Ss(r,c):c}return void 0===n&&(n=xs),r.defaultState=Ps,r}function Cs(){for(var e=arguments,t=arguments.length-1,n=arguments[t],r=[];t-- >0;)r[t]=e[t];if("function"!=typeof n)throw new TypeError("The reducer must be a function");for(var o=0,i=r;o<i.length;o+=1){if("function"!=typeof i[o])throw new TypeError("Each argument filter must be a function")}return function(e,t,o,i){void 0===e&&(e=n.defaultState);for(var a=void 0!==e,s=[],c=0;c<r.length;++c)s[c]=r[c](o),a&&s[c]!==r[c](i)&&(a=!1);return a?e:n.apply(void 0,s)}}function Ns(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function js(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ns(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ns(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ds=[],Rs={totalRatio:0},Ls=As({accountId(e,t,n){if(null!=e)return e;for(const r of Object.keys(n.root.accounts)){const e=n.root.accounts[r];for(const t of Object.keys(e.walletInfos))if(t===n.id)return r}throw new Error(`Cannot find account for walletId ${n.id}`)},allEnabledTokenIds:Cs((e=>e.root.accounts[e.self.accountId].alwaysEnabledTokenIds[e.self.pluginId]),(e=>e.self.enabledTokenIds),((e=[],t=[])=>$a([...e,...t]))),pluginId:Cs((e=>e.root.login.walletInfos[e.id].type),(e=>e.root.plugins.currency),((e,t)=>Vr(t,e))),paused(e,t,n){return null==e?n.root.accounts[n.self.accountId].pauseWallets:"CURRENCY_WALLET_CHANGED_PAUSED"===t.type?t.payload.paused:e},currencyInfo(e,t,n){if(null!=e)return e;const{pluginId:r}=n.self;return n.root.plugins.currency[r].currencyInfo},detectedTokenIds:Fs(((e=Ds,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.detectedTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{detectedTokenIds:n}=t.payload;return $a([...e,...n])}return"CURRENCY_ENGINE_CLEARED"===t.type?[]:e})),enabledTokenIds:Fs(((e=Ds,t)=>{if("CURRENCY_WALLET_LOADED_TOKEN_FILE"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_WALLET_ENABLED_TOKENS_CHANGED"===t.type)return t.payload.enabledTokenIds;if("CURRENCY_ENGINE_DETECTED_TOKENS"===t.type){const{enablingTokenIds:n}=t.payload;return $a([...e,...n])}return e})),changeServiceSubscriptions(e=[],t){if("CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS"===t.type){return[...e.filter((e=>!t.payload.subscriptions.some((t=>t.address===e.address)))),...t.payload.subscriptions]}return"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES"===t.type?t.payload.subscribedAddresses:e},tokenFileDirty(e=!1,t,n,r){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":case"CURRENCY_WALLET_SAVED_TOKEN_FILE":return!1;case"CURRENCY_ENGINE_CLEARED":case"CURRENCY_ENGINE_DETECTED_TOKENS":case"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED":return n.self.detectedTokenIds!==r.self.detectedTokenIds||n.self.enabledTokenIds!==r.self.enabledTokenIds;default:return e}},tokenFileLoaded(e=!1,t){switch(t.type){case"CURRENCY_WALLET_LOADED_TOKEN_FILE":return!0;case"CURRENCY_ENGINE_CLEARED":return!1;default:return e}},engineFailure(e=null,t){if("CURRENCY_ENGINE_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},engineStarted(e=!1,t){return"CURRENCY_ENGINE_STARTED"===t.type||"CURRENCY_ENGINE_STOPPED"!==t.type&&e},fiat(e="",t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type?t.payload.fiatCurrencyCode:e},fiatLoaded(e=!1,t){return"CURRENCY_WALLET_FIAT_CHANGED"===t.type||e},files(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_CHANGED":{const{json:n,txidHash:r}=t.payload,o=js({},e);return o[r]=n,o}case"CURRENCY_WALLET_FILES_LOADED":{const{files:n}=t.payload;return js(js({},e),n)}}return e},fileNames(e={},t){switch(t.type){case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload;return js(js({},e),n)}case"CURRENCY_WALLET_FILE_CHANGED":{const{fileName:n,creationDate:r,txidHash:o}=t.payload;return(null==e[o]||r<e[o].creationDate)&&(e[o]={creationDate:r,fileName:n}),e}}return e},syncStatus(e=Rs,t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_SYNC_STATUS":return t.payload.status;case"CURRENCY_ENGINE_CLEARED":return Rs}return e},balanceMap(e=new Map,t){if("CURRENCY_ENGINE_CHANGED_BALANCE"===t.type){const{balance:n,tokenId:r}=t.payload,o=new Map(e);return o.set(r,n),o}return e},balances:Cs((e=>e.self.balanceMap),(e=>e.self.currencyInfo),(e=>e.root.accounts[e.self.accountId].allTokens[e.self.pluginId]),((e,t,n)=>{const r={};for(const o of e.keys()){const i=e.get(o),{currencyCode:a}=null==o?t:n[o];null!=i&&(r[a]=i)}return r})),height(e=0,t){return"CURRENCY_ENGINE_CHANGED_HEIGHT"===t.type?t.payload.height:e},name(e=null,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type?t.payload.name:e},nameLoaded(e=!1,t){return"CURRENCY_WALLET_NAME_CHANGED"===t.type||e},seenTxCheckpoint(e=null,t){return"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED"===t.type?t.payload.checkpoint:e},sortedTxidHashes:Cs((e=>e.self.txidHashes),(e=>Object.keys(e).sort(((t,n)=>e[t].date>e[n].date?-1:e[t].date<e[n].date?1:0)))),stakingStatus(e={stakedAmounts:[]},t){return"CURRENCY_ENGINE_CHANGED_STAKING"===t.type?t.payload.stakingStatus:e},txidHashes(e={},t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_TXS":return Bs(e,t.payload.txidHashes);case"CURRENCY_WALLET_FILE_NAMES_LOADED":{const{txFileNames:n}=t.payload,r={};for(const e of Object.keys(n))r[e]={date:n[e].creationDate};return Bs(e,r)}}return e},txs(e={},t,n){switch(t.type){case"CHANGE_MERGE_TX":{const{tx:n}=t.payload,r=js({},e);return r[n.txid]=n,r}case"CURRENCY_ENGINE_CHANGED_TXS":{const{txs:n}=t.payload,r=js({},e);for(const e of n)r[e.txid]=Us(e,r[e.txid]);return r}case"CURRENCY_ENGINE_CLEARED":return{}}return e},unactivatedTokenIds(e=[],t){switch(t.type){case"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS":return t.payload.unactivatedTokenIds;case"CURRENCY_ENGINE_CLEARED":return[]}return e},gotTxs(e=new Set,t){switch(t.type){case"CURRENCY_ENGINE_GOT_TXS":{const{tokenId:n}=t.payload,r=new Set(e);return r.add(n),r}case"CURRENCY_ENGINE_CLEARED":return new Set;default:return e}},walletInfo(e,t,n){return n.root.login.walletInfos[n.id]},publicWalletInfo(e=null,t){return"CURRENCY_WALLET_PUBLIC_INFO"===t.type?t.payload.walletInfo:e}});function Bs(e,t){const n=js({},e);for(const o of Object.keys(t)){var r;const e=n[o],i=t[o];n[o]=null==e?i:{date:Math.min(i.date,e.date),txid:null!==(r=i.txid)&&void 0!==r?r:e.txid}}return n}const Ks=ks(Ls,((e,t)=>/^CURRENCY_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"walletId"in e.payload&&e.payload.walletId===t.id?e:{type:"UPDATE_NEXT"}));function Us(e,t){var n,r,o,i;const{confirmations:a="unconfirmed",isSend:s=(0,Uo.lt)(e.nativeAmount,"0"),tokenId:c=null}=e,u={blockHeight:e.blockHeight,chainAction:e.chainAction,chainAssetAction:new Map(null!==(n=null==t?void 0:t.chainAssetAction)&&void 0!==n?n:[]),confirmations:a,date:e.date,isSend:s,memos:e.memos,nativeAmount:new Map(null!==(r=null==t?void 0:t.nativeAmount)&&void 0!==r?r:[]),networkFee:new Map(null!==(o=null==t?void 0:t.networkFee)&&void 0!==o?o:[]),otherParams:e.otherParams,ourReceiveAddresses:e.ourReceiveAddresses,signedTx:e.signedTx,txid:e.txid};return u.nativeAmount.set(c,e.nativeAmount),u.networkFee.set(c,null!==(i=e.networkFee)&&void 0!==i?i:"0"),null!=e.feeRateUsed&&(u.feeRateUsed=e.feeRateUsed),null!=e.parentNetworkFee&&u.networkFee.set(null,String(e.parentNetworkFee)),null!=e.chainAssetAction&&u.chainAssetAction.set(c,e.chainAssetAction),u}function Fs(e){return(t,n)=>{const r=e(t,n);return r===t?t:(r.sort(((e,t)=>e===t?0:e>t?1:-1)),null!=t&&Oi(r,t)?t:r)}}let Ws=5e3;function qs(e,t){const{log:n,walletId:r}=e.props;let o=!1,i=0,a=[];return e=>{if(o)n(`throttledTxCallback delay, walletId: ${r}`),a.push(...e);else{const s=Date.now();s-i>Ws?(i=s,t(e)):(n(`throttledTxCallback delay, walletId: ${r}`),o=!0,a=e,setTimeout((()=>{i=Date.now(),t(a),o=!1,a=[]}),Ws))}}}function zs(e){const{walletId:t}=e.props;"narfavJN4rp9ZzYigcRj1i0vrU2OAGGp4+KksAksj54="===t&&(Ws=25,Ti=99,Ai=1);const n=qs(e,(t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&K(e.props.walletOutput.walletApi,"transactionsChanged",t)})),r=qs(e,(t=>{var n;null!=(null===(n=e.props.walletOutput)||void 0===n?void 0:n.walletApi)&&K(e.props.walletOutput.walletApi,"newTransactions",t)})),o={onAddressesChecked(n){xi({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:{totalRatio:n},walletId:t}})}})},onNewTokens(n){xi({id:t,action:"onNewTokens",updateFunc:()=>{const{detectedTokenIds:r,enabledTokenIds:o}=e.props.walletState,i=$a(n,[...r,...o]),a=pc(n,r),s=pc(r,n),c=t.slice(0,2);if(e.props.log.warn(`enabledTokenIds: ${c} engine detected tokens, add [${a}], remove [${s}]`),e.props.dispatch({type:"CURRENCY_ENGINE_DETECTED_TOKENS",payload:{detectedTokenIds:n,enablingTokenIds:i,walletId:t}}),i.length>0){var u;const t=null===(u=e.props)||void 0===u||null===(u=u.walletOutput)||void 0===u?void 0:u.walletApi;null!=t&&K(t,"enabledDetectedTokens",i)}}})},onUnactivatedTokenIdsChanged(n){xi({id:t,action:"onUnactivatedTokenIdsChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_UNACTIVATED_TOKEN_IDS",payload:{unactivatedTokenIds:n,walletId:t}})}})},onBalanceChanged(t,n){const{accountId:r,currencyInfo:i,pluginId:a}=e.props.walletState,s=e.props.state.accounts[r].allTokens[a];if(t===i.currencyCode)o.onTokenBalanceChanged(null,n);else{const{tokenId:e}=Fo({allTokens:s,currencyInfo:i,currencyCode:t});null!=e&&o.onTokenBalanceChanged(e,n)}},onTokenBalanceChanged(n,r){const o=ge(Ri)(r);null!=o?xi({id:`${t}==${String(n)}`,action:"onTokenBalanceChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:o,tokenId:n,walletId:t}})}}):e.props.onError(new Error(`Plugin sent bogus balance for ${String(n)}: "${r}"`))},onBlockHeightChanged(r){xi({id:t,action:"onBlockHeightChanged",updateFunc:()=>{const{txs:o,files:i}=e.props.walletState,a=[];for(const n of Object.keys(o)){const s=o[n];if($s(s.confirmations)){const n=wo(e.props.state,t,s.txid),o=ac(e,s,i[n],null,r);a.push(o)}}a.length>0&&n(a),e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:r,walletId:t}})}})},onSeenTxCheckpoint(t){vs(e,t).catch((t=>e.props.onError(t)))},onStakingStatusChanged(n){xi({id:t,action:"onStakingStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:n,walletId:t}})}})},onSubscribeAddresses(n){var r;const o=n.map((e=>"string"==typeof e?{address:e,checkpoint:void 0}:e));vs(e,null!==(r=e.props.walletState.seenTxCheckpoint)&&void 0!==r?r:void 0,o).catch((t=>e.props.onError(t)));const i=o.map((({address:e,checkpoint:t})=>({address:e,status:"subscribing",checkpoint:t})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:i,walletId:t}})},onSyncStatusChanged(n){xi({id:t,action:"onSyncStatusChanged",updateFunc:()=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_SYNC_STATUS",payload:{status:n,walletId:t}})}})},onTransactions(o){const{accountId:i,currencyInfo:a,pluginId:s}=e.props.walletState,c=e.props.state.accounts[i].allTokens[s];if(null==o||0===o.length)return;const u=[];for(const t of o){const n=t.transaction;if(qo(n),"string"!=typeof n.txid||"number"!=typeof n.date||"string"!=typeof n.networkFee||"number"!=typeof n.blockHeight||"string"!=typeof n.nativeAmount||"object"!=typeof n.ourReceiveAddresses)return void e.props.onError(new Error(`Plugin sent bogus tx: ${JSON.stringify(n,null,2)}`));if(null==n.isSend&&(n.isSend=(0,Uo.lt)(n.nativeAmount,"0")),null==n.memos&&(n.memos=[]),void 0===n.tokenId){const{tokenId:e}=Fo({allTokens:c,currencyInfo:a,currencyCode:n.currencyCode});n.tokenId=null!=e?e:null}u.push(n)}const{state:l}=e.props,{txs:d}=e.props.walletState,f={},p=[],h=[];for(const n of o){const{isNew:r,transaction:o}=n,{txid:i}=o,a=Us(o,d[i]);if(Oi(a,d[i])&&null==o.metadata)continue;const s=wo(l,t,i);null==e.props.walletState.fileNames[s]&&ws(e,o).catch((t=>e.props.onError(t)));const{files:c}=e.props.walletState,u=ac(e,a,c[s],o.tokenId);r?h.push(u):p.push(u),f[s]={date:u.date,txid:i}}e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_TXS",payload:{txs:u,walletId:t,txidHashes:f}}),p.length>0&&n(p),h.length>0&&r(h)},onTransactionsChanged(e){o.onTransactions(e.map((e=>({isNew:!1,transaction:e}))))},onAddressChanged(){null!=e.props.walletOutput.walletApi&&K(e.props.walletOutput.walletApi,"addressChanged",void 0)},onWcNewContractCall(t){null!=e.props.walletOutput.walletApi&&K(e.props.walletOutput.walletApi,"wcNewContractCall",t)},onTxidsChanged(){}};return o}function Gs(e){const{walletId:t}=e.props;let n;async function r(r){const o=function(e,t){return e.storageWallets[t].lastChanges}(r.state,t);o!==n&&(n=o,await async function(e,t){(t.includes(Qa)||t.includes(Xa))&&await ps(e),t.includes(Va)&&await ds(e),t.includes(es)&&await fs(e),await ys(e),await bs(e)}(e,o))}!function t(){e.nextProps().then(r).then(t,(n=>{var r;(r=n)instanceof Error&&"PixieShutdownError"===r.name||(e.props.onError(n),t())}))}()}const $s=e=>"number"!=typeof e&&"confirmed"!==e&&"dropped"!==e&&"failed"!==e,Hs=(e,t,n=1)=>{if(e.blockHeight>0){const r=1+t-e.blockHeight;return r<=0?"syncing":r>=n?"confirmed":r}return e.blockHeight<0?"dropped":"unconfirmed"};function Ys(e,t=new Date(0),n=new Date){return 1e3*e.date>=t.valueOf()&&1e3*e.date<n.valueOf()}function Vs(e,t,n){var r;const o=e.props.state.currency;if(null==n||""===n)return!0;let i=n.toLowerCase().replace(".","").replace(",","");for(let c=0;c<i.length;c++)if("0"!==i[c]){i=i.substring(c);break}function a(e){return null!=e&&("string"==typeof e||"number"==typeof e)&&!!e.toString().toLowerCase().replace(".","").replace(",","").includes(i)}if(a(t.nativeAmount))return!0;if(null!=t.metadata){const{category:e="",name:n="",notes:r="",exchangeAmount:i={}}=t.metadata,s=null!=t.walletId?o.wallets[t.walletId]:void 0;if(a(e)||a(n)||a(r)||null!=s&&a(i[s.fiat]))return!0}if(null!=t.swapData){const{displayName:e="",pluginId:n=""}=t.swapData.plugin;if(a(e)||a(n))return!0}const s=null!==(r=t.savedAction)&&void 0!==r?r:t.chainAction;if(null!=s&&"swap"===s.actionType){const{pluginId:e}=s.toAsset,{pluginId:t}=s.fromAsset,{displayName:n,supportEmail:r}=s.swapInfo;if(a(t)||a(e)||a(n)||a(r))return!0}if(null!=t.spendTargets)for(const c of t.spendTargets){const{publicAddress:e="",memo:t=""}=c;if(a(e)||a(t))return!0}if(t.ourReceiveAddresses.length>0)for(const c of t.ourReceiveAddresses)if(a(c))return!0;return!!a(t.txid)}function Js(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Xs(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Js(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Js(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Zs(e,t){var n,r;const o=[],{memoType:i}=t;if("hex"===i||"number"===i||"text"===i)for(const c of e.spendTargets){var a;null!=c.memo?o.push({type:i,value:c.memo}):null!=c.uniqueIdentifier?o.push({type:i,value:c.uniqueIdentifier}):"string"==typeof(null===(a=c.otherParams)||void 0===a?void 0:a.uniqueIdentifier)&&o.push({type:i,value:c.otherParams.uniqueIdentifier})}for(const c of o)"hex"===c.type&&(c.value=c.value.replace(/^0x/i,""));const s=Xs(Xs({},e),{},{spendTargets:e.spendTargets.map((e=>Xs(Xs({},e),{},{memo:void 0,uniqueIdentifier:void 0}))),memos:null!==(n=e.memos)&&void 0!==n?n:o});if(1===(null===(r=s.memos)||void 0===r?void 0:r.length)&&s.spendTargets.length>=1){const[e]=s.memos;if(e.type===t.memoType){const[t]=s.spendTargets;t.memo=e.value,t.uniqueIdentifier=e.value,t.otherParams=Xs(Xs({},t.otherParams),{},{uniqueIdenfitifer:e.value})}}return s}function Qs(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function ec(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Qs(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Qs(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const tc=async(e,t,n,r,o)=>{var i;e=Zs(e,t.currencyInfo);const a=Fo({allTokens:r,currencyInfo:t.currencyInfo,tokenId:e.tokenId}),s=null!==(i=t.currencyInfo.unsafeMakeSpend)&&void 0!==i&&i;if("function"==typeof n.getMaxSpendable){const t=s?o.keys:void 0;return await n.getMaxSpendable(ec(ec({},e),a),{privateKeys:t})}const{networkFeeOption:c,customNetworkFee:u}=e,l=n.getBalance(a),d=e.spendTargets.map((e=>ec(ec({},e),{},{nativeAmount:"0"})));return await function t(r,i){const l=(0,Uo.sub)(i,r);if((0,Uo.lte)(l,"1"))return Promise.resolve(r);const f=(0,Uo.add)(r,(0,Uo.div)(l,"2"));d[0].nativeAmount=f;const p=s?o.keys:void 0;return n.makeSpend(ec(ec({},a),{},{spendTargets:d,networkFeeOption:c,customNetworkFee:u,memos:e.memos,otherParams:e.otherParams}),{privateKeys:p}).then((()=>t(f,i))).catch((()=>t(r,f)))}("0",(0,Uo.add)(l,"1"))};function nc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function rc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?nc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):nc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const oc={bizId:0,category:"",exchangeAmount:{},name:"",notes:""};function ic(e,t,n,r){const o=yu(e),{accountId:i,pluginId:a,walletInfo:s}=e.props.walletState,c=e.props.state.plugins.currency[a],{unsafeBroadcastTx:u=!1,unsafeMakeSpend:l=!1}=c.currencyInfo,d=Ei(o,s),f=zs(e),p={};if(null!=t.otherMethods)for(const y of Object.keys(t.otherMethods)){const e=t.otherMethods[y];"function"==typeof e&&(p[y]=e)}if(null!=t.otherMethodsWithKeys)for(const y of Object.keys(t.otherMethodsWithKeys)){const e=t.otherMethodsWithKeys[y];"function"==typeof e&&(p[y]=(...t)=>e(s.keys,...t))}_(p);const h={on:J,watch:X,get created(){return s.created},get disklet(){return d.disklet},get id(){return d.id},get localDisklet(){return d.localDisklet},publicWalletInfo:r,async sync(){await d.sync()},get type(){return d.type},get name(){return e.props.walletState.name},async renameWallet(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=bo(r,o);await us.save(i,es,{walletName:t}),n({type:"CURRENCY_WALLET_NAME_CHANGED",payload:{name:t,walletId:o}})}(e,t)},get fiatCurrencyCode(){return e.props.walletState.fiat},async setFiatCurrencyCode(t){await async function(e,t){const{dispatch:n,state:r,walletId:o}=e.props,i=bo(r,o);if(!/^iso:/.test(t))throw new TypeError("Fiat currency codes must start with `iso:`");await cs.save(i,Va,{fiat:t,num:void 0}),n({type:"CURRENCY_WALLET_FIAT_CHANGED",payload:{fiatCurrencyCode:t,walletId:o}})}(e,t)},get currencyConfig(){const{accountApi:t}=e.props.output.accounts[i];return t.currencyConfig[a]},get currencyInfo(){return c.currencyInfo},async denominationToNative(t,n){const r=zo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Uo.mul)(t,r)},async nativeToDenomination(t,n){const r=zo(c.currencyInfo,e.props.state.accounts[i].allTokens[a],n);return(0,Uo.div)(t,r,r.length)},get balances(){return e.props.walletState.balances},get balanceMap(){return e.props.walletState.balanceMap},get blockHeight(){const{skipBlockHeight:t}=e.props.state;return t?0:e.props.walletState.height},get syncRatio(){return e.props.walletState.syncStatus.totalRatio},get syncStatus(){return e.props.walletState.syncStatus},get unactivatedTokenIds(){return e.props.walletState.unactivatedTokenIds},async changePaused(t){e.props.dispatch({type:"CURRENCY_WALLET_CHANGED_PAUSED",payload:{walletId:e.props.walletId,paused:t}})},get paused(){return e.props.walletState.paused},async changeEnabledTokenIds(t){var n;const{dispatch:r,walletId:o,walletState:i}=e.props,{accountId:a,pluginId:s}=i,c=null!==(n=e.props.state.accounts[a].allTokens[s])&&void 0!==n?n:{},u=$a(t).filter((e=>null!=c[e])),l=o.slice(0,2);e.props.log.warn(`enabledTokenIds: ${l} changeEnabledTokenIds`),r({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:o,enabledTokenIds:u}})},get detectedTokenIds(){return e.props.walletState.detectedTokenIds},get enabledTokenIds(){return e.props.walletState.enabledTokenIds},async getNumTransactions(n){const r=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId});return t.getNumTransactions(r)},async $internalStreamTransactions(n){const{afterDate:r,batchSize:i=10,beforeDate:a,firstBatchSize:s=i,searchString:c,spamThreshold:u="0",tokenId:l=null}=n,{currencyCode:d}=null==l?this.currencyInfo:this.currencyConfig.allTokens[l],p={currencyCode:d,tokenId:l};let h=e.props.walletState;if(!h.gotTxs.has(l)){const n=await t.getTransactions(p);f.onTransactionsChanged(n),e.props.dispatch({type:"CURRENCY_ENGINE_GOT_TXS",payload:{walletId:e.props.walletId,tokenId:l}}),h=e.props.walletState}const{files:y,sortedTxidHashes:b,txidHashes:g,txs:w}=h;let v=0,m=!0,I=0;return _({async next(){const t=m?s:i,n=[];for(;v<b.length&&n.length<t;){var d,f;if(v>=I){const n=b.slice(I,I+t).filter((e=>null==y[e])),r=await hs(e,n);Object.assign(y,r),I+=t}const i=b[v++],s=y[i],p=null!==(d=null==s?void 0:s.txid)&&void 0!==d?d:null===(f=g[i])||void 0===f?void 0:f.txid;if(null==p)continue;const h=w[p],m=null==h?void 0:h.nativeAmount.get(l),E=null==h?void 0:h.networkFee.get(l);if(null==h||null==m||null==E)continue;const S=ac(e,h,s,l);if(qo(S),!Vs(o,S,c))continue;if(!Ys(S,r,a))continue;!(h.isSend||null!=S.assetAction||null!=S.chainAction||null!=S.chainAssetAction||null!=S.savedAction)&&(0,Uo.lt)((0,Uo.abs)(m),u)||n.push(S)}return m=!1,{done:0===n.length,value:n}}})},async getTransactions(t){const{endDate:n,startDate:r,searchString:o,spamThreshold:s}=t,u=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:t.tokenId}),l=await h.$internalStreamTransactions(rc(rc({},u),{},{afterDate:r,beforeDate:n,searchString:o,spamThreshold:s})),d=[];for(;;){const e=await l.next();if(e.done)return d;d.push(...e.value)}},streamTransactions:oe,async getAddresses(n){if(null!=t.getAddresses)return await t.getAddresses(n);{const r=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),o=await t.getFreshAddress(rc(rc({},r),{},{forceIndex:n.forceIndex})),{publicAddress:s,legacyAddress:u,segwitAddress:l,nativeBalance:d,legacyNativeBalance:f,segwitNativeBalance:p}=o,h=[{addressType:"publicAddress",publicAddress:s,nativeBalance:d}];return null!=l&&h.unshift({addressType:"segwitAddress",publicAddress:l,nativeBalance:p}),null!=u&&h.push({addressType:"legacyAddress",publicAddress:u,nativeBalance:f}),h}},async getReceiveAddress(e){var t;const n=await this.getAddresses(e);if(n.length<1)throw new Error("No addresses available");const r=null!==(t=n.find((e=>"publicAddress"===e.addressType)))&&void 0!==t?t:n[0],o={publicAddress:r.publicAddress,nativeBalance:r.nativeBalance,metadata:oc,nativeAmount:"0"},i=n.find((e=>"segwitAddress"===e.addressType));null!=i&&(o.segwitAddress=i.publicAddress,o.segwitNativeBalance=i.nativeBalance);const a=n.find((e=>"legacyAddress"===e.addressType));return null!=a&&(o.legacyAddress=a.publicAddress,o.legacyNativeBalance=a.nativeBalance),o},async lockReceiveAddress(e){},async saveReceiveAddress(e){},async broadcastTx(e){const n=u?s.keys:void 0;return await t.broadcastTx(e,{privateKeys:n})},async getMaxSpendable(n){return await tc(n,c,t,e.props.state.accounts[i].allTokens[a],s)},async getPaymentProtocolInfo(e){if(null==t.getPaymentProtocolInfo)throw new Error("'getPaymentProtocolInfo' is not implemented on wallets of this type");return await t.getPaymentProtocolInfo(e)},async makeSpend(n){n=Zs(n,c.currencyInfo);const{assetAction:r,customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p="standard",noUnconfirmed:h=!1,otherParams:y,pendingTxs:b,rbfTxid:g,savedAction:w,skipChecks:v,spendTargets:m=[],swapData:I}=n,E=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,tokenId:n.tokenId}),S=[],O=[];for(const e of m){const{memo:t,publicAddress:n,nativeAmount:r="0",otherParams:o={}}=e;null!=n&&(S.push({memo:t,nativeAmount:r,otherParams:o,publicAddress:n,uniqueIdentifier:t}),O.push({currencyCode:E.currencyCode,memo:t,nativeAmount:r,publicAddress:n,uniqueIdentifier:t}))}if(null!=n.privateKeys)throw new TypeError("Only sweepPrivateKeys takes private keys");const A=l?s.keys:void 0,T=await t.makeSpend(rc(rc({},E),{},{customNetworkFee:o,enableRbf:u,memos:d,metadata:f,networkFeeOption:p,noUnconfirmed:h,otherParams:y,pendingTxs:b,rbfTxid:g,skipChecks:v,spendTargets:S}),{privateKeys:A});return qo(T),T.networkFeeOption=p,T.requestedCustomFee=o,T.spendTargets=O,T.currencyCode=E.currencyCode,T.tokenId=E.tokenId,null!=f&&(T.metadata=f),null!=I&&(T.swapData=Di(I)),null!=w&&(T.savedAction=Ui(w)),null!=r&&(T.assetAction=Fi(r)),null!=e.props.state.login.deviceInfo.deviceDescription&&(T.deviceDescription=e.props.state.login.deviceInfo.deviceDescription),T},async saveTx(n){if(null==e.props.walletState.txs[n.txid]){const{fileName:t,txFile:r}=await ws(e,n);await async function(e,t,n){const{state:r,walletId:o}=e.props,i=bo(r,o);await ss.save(i,"transaction/"+t,n)}(e,t,r),f.onTransactions([{isNew:!0,transaction:n}])}else await gs(e,n.txid,n.tokenId,f);await t.saveTx(n)},async saveTxAction(t){const{txid:n,tokenId:r,assetAction:o,savedAction:i}=t;await gs(e,n,r,f,void 0,o,i)},async saveTxMetadata(t){const{txid:n,tokenId:r,metadata:o}=t;await gs(e,n,r,f,o)},async signBytes(e,n={}){const r=s.keys;if(null!=t.signBytes)return await t.signBytes(e,r,n);if("bitcoin"===a&&null!=t.signMessage)return await t.signMessage(y.stringify(e),r,n);throw new Error(`${a} doesn't support signBytes`)},async signMessage(e,n={}){if(null==t.signMessage)throw new Error(`${a} doesn't support signing messages`);const r=s.keys;return await t.signMessage(e,r,n)},async signTx(e){const n=s.keys;return await t.signTx(e,n)},async sweepPrivateKeys(e){if(null==t.sweepPrivateKeys)throw new Error("Sweeping this currency is not supported.");return await t.sweepPrivateKeys(e)},async accelerate(e){return null==t.accelerate?null:await t.accelerate(e)},get stakingStatus(){return e.props.walletState.stakingStatus},async dumpData(){return await t.dumpData()},async resyncBlockchain(){const n=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${n} resyncBlockchain`),o.props.dispatch({type:"CURRENCY_ENGINE_CLEARED",payload:{walletId:e.props.walletId}}),await t.resyncBlockchain(),K(h,"transactionsRemoved",void 0)},async split(e){return await mi(o,i,s,e,!1)},async encodeUri(t){return await n.encodeUri(t,Ro(e.props.state.accounts[i].customTokens[a]))},async parseUri(t,r){const o=await n.parseUri(t,r,Ro(e.props.state.accounts[i].customTokens[a]));if(void 0===o.tokenId){var s;const{tokenId:t=null}=Fo({allTokens:e.props.state.accounts[i].allTokens[a],currencyInfo:c.currencyInfo,currencyCode:null!==(s=o.currencyCode)&&void 0!==s?s:r});o.tokenId=t}return o},otherMethods:p};return _(h)}function ac(e,t,n,r,o){var i,a,s;const c=e.props.walletId,{accountId:u,currencyInfo:l,pluginId:d}=e.props.walletState,f=e.props.state.accounts[u].allTokens[d],{currencyCode:p}=null==r?l:f[r],h=l.currencyCode,y=null!=o?o:e.props.walletState.height,b=$s(t.confirmations)?Hs(t,y,l.requiredConfirmations):t.confirmations,g={chainAction:t.chainAction,chainAssetAction:t.chainAssetAction.get(r),blockHeight:t.blockHeight,confirmations:b,currencyCode:p,feeRateUsed:t.feeRateUsed,date:t.date,isSend:t.isSend,memos:t.memos,metadata:{},nativeAmount:null!==(i=t.nativeAmount.get(r))&&void 0!==i?i:"0",networkFee:null!==(a=t.networkFee.get(r))&&void 0!==a?a:"0",networkFees:[],otherParams:rc({},t.otherParams),ourReceiveAddresses:t.ourReceiveAddresses,parentNetworkFee:h===p?void 0:null!==(s=t.networkFee.get(null))&&void 0!==s?s:"0",signedTx:t.signedTx,tokenId:r,txid:t.txid,walletId:c};if(null!=n){var w,v,m,I,E,S,O,A,T;n.creationDate<g.date&&(g.date=n.creationDate),g.metadata=Mi(null!==(w=null!==(v=null===(m=n.tokens.get(null))||void 0===m?void 0:m.metadata)&&void 0!==v?v:null===(I=n.currencies.get(h))||void 0===I?void 0:I.metadata)&&void 0!==w?w:{},null!==(E=null!==(S=null===(O=n.tokens.get(r))||void 0===O?void 0:O.metadata)&&void 0!==S?S:null===(A=n.currencies.get(p))||void 0===A?void 0:A.metadata)&&void 0!==E?E:{}),null!=n.feeRateRequested&&("string"==typeof n.feeRateRequested?g.networkFeeOption=n.feeRateRequested:(g.networkFeeOption="custom",g.requestedCustomFee=n.feeRateRequested)),null==g.feeRateUsed&&(g.feeRateUsed=n.feeRateUsed),null!=n.payees&&(g.spendTargets=n.payees.map((e=>({currencyCode:e.currency,memo:e.tag,nativeAmount:e.amount,publicAddress:e.address,uniqueIdentifier:e.tag}))));const e=null===(T=n.tokens.get(r))||void 0===T?void 0:T.assetAction;null!=e&&(g.assetAction=e),null!=n.savedAction&&(g.savedAction=n.savedAction),null!=n.swap&&(g.swapData=n.swap),null!=n.secret&&(g.txSecret=n.secret),null!=n.deviceDescription&&(g.deviceDescription=n.deviceDescription)}return g}function sc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function cc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?sc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const uc="publicKey.json",lc=Er(Vi),dc=br({engine:e=>async()=>{const{state:t,walletId:n,walletState:r}=e.props,{accountId:o,pluginId:i,walletInfo:a}=r,s=t.plugins.currency[i],{currencyCode:c}=s.currencyInfo;try{var u,l;const t=yu(e);await po(t,a);const{state:r}=e.props,d=go(r,a.id),f=function(e,t,n){return to(n,e.storageWallets[t].paths.dataKey,e.storageWallets[t].localDisklet)}(r,a.id,e.props.io);await ys(e);const p=await Xr(t,i),h=await fc(a,d,p);e.props.dispatch({type:"CURRENCY_WALLET_PUBLIC_INFO",payload:{walletInfo:h,walletId:n}});const{checkpoint:y,subscribedAddresses:b}=await async function(e){var t;const{dispatch:n,state:r,walletId:o}=e.props,i=bo(r,o),a=await is.load(i,Za),s=null!=a?a:{checkpoint:void 0,subscribedAddresses:[]},c=s.checkpoint,u=null!==(t=s.subscribedAddresses)&&void 0!==t?t:[];if(null!=c&&n({type:"CURRENCY_ENGINE_SEEN_TX_CHECKPOINT_CHANGED",payload:{checkpoint:c,walletId:o}}),u.length>0){const e=u.map((({address:e,checkpoint:t})=>({address:e,checkpoint:t,status:"subscribing"})));n({type:"CURRENCY_WALLET_LOADED_SUBSCRIBED_ADDRESSES",payload:{subscribedAddresses:e,walletId:o}})}return{checkpoint:c,subscribedAddresses:u}}(e);await ps(e);const g=r.accounts[o],w=await s.makeCurrencyEngine(h,{callbacks:zs(e),seenTxCheckpoint:y,subscribedAddresses:b,log:Cr(e.props.logBackend,`${i}-${a.id.slice(0,2)}`),walletLocalDisklet:d,walletLocalEncryptedDisklet:f,customTokens:null!==(u=g.customTokens[i])&&void 0!==u?u:{},enabledTokenIds:e.props.walletState.allEnabledTokenIds,userSettings:null!==(l=g.userSettings[i])&&void 0!==l?l:{}});e.onOutput(w);const v={currencyCode:c,tokenId:null},m=ge(Ri)(w.getBalance(v));null!=m&&e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_BALANCE",payload:{balance:m,tokenId:null,walletId:n}});const I=w.getBlockHeight();e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_HEIGHT",payload:{height:I,walletId:n}}),null!=w.getStakingStatus&&await w.getStakingStatus().then((t=>{e.props.dispatch({type:"CURRENCY_ENGINE_CHANGED_STAKING",payload:{stakingStatus:t,walletId:n}})}),(t=>e.props.onError(t))),await ds(e),await fs(e),await bs(e)}catch(d){e.props.onError(d),e.props.dispatch({type:"CURRENCY_ENGINE_FAILED",payload:{error:d,walletId:n}})}return Gs(e),await Ir},walletApi:e=>async()=>{const{walletOutput:t,walletState:n}=e.props;if(null==t)return;const{engine:r}=t,{nameLoaded:o,pluginId:i,publicWalletInfo:a}=n;if(null==r||null==a||!o)return;const s=await Xr(yu(e),i),c=ic(e,r,s,a);return e.onOutput(c),await Ir},engineStarted:vr((e=>{let t;return{update(){const{log:n,walletId:r,walletOutput:o,walletState:i}=e.props;if(null==o)return;const{engine:a,walletApi:s}=o;null!=s&&i.fiatLoaded&&!i.engineStarted&&null!=a&&null==t&&(n(`${r} startEngine`),e.props.dispatch({type:"CURRENCY_ENGINE_STARTED",payload:{walletId:r}}),t=Promise.resolve().then((()=>a.startEngine())).then((()=>{e.onOutput(!0)})).catch((t=>e.props.onError(t))))},destroy(){const{log:n,walletId:r,walletOutput:o}=e.props;if(null==o)return;const{engine:i}=o;null!=i&&null!=t&&(n(`${r} killEngine`),t.then((()=>i.killEngine())).catch((t=>e.props.onError(t))).then((()=>{e.onOutput(!1),e.props.dispatch({type:"CURRENCY_ENGINE_STOPPED",payload:{walletId:r}})})).catch((()=>{})))}}}),(e=>e.state.paused||e.walletState.paused?void 0:e)),syncNetworkUpdate:vr((e=>({async update(e){if(null==e.walletOutput)return;const{engine:t,engineStarted:n}=e.walletOutput;if(null==(null==t?void 0:t.syncNetwork)||!n)return;const{walletState:r}=e,{currencyInfo:o,walletInfo:i,publicWalletInfo:a}=r,s=!0===o.unsafeSyncNetwork&&null!=a?i.keys:void 0;for(const c of r.changeServiceSubscriptions)await t.syncNetwork({privateKeys:s,subscribeParam:{address:c.address,checkpoint:c.checkpoint,needsSync:"syncing"===c.status}});e.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{subscriptions:r.changeServiceSubscriptions.map((e=>cc(cc({},e),{},{status:"listening"}))),walletId:e.walletId}})},destroy(){}})),(e=>!e.state.paused&&!e.walletState.paused&&e.walletState.engineStarted&&e.walletState.changeServiceSubscriptions.some((e=>"syncing"===e.status||"synced"===e.status))?e:void 0)),syncNetworkTask:vr((e=>{const t=Hr((async()=>{if(null==e.props.walletOutput)return;const{engine:n,engineStarted:r}=e.props.walletOutput;if(null==(null==n?void 0:n.syncNetwork)||!r)return void t.stop();const{walletState:o}=e.props,{currencyInfo:i,walletInfo:a,publicWalletInfo:s}=o,c=!0===i.unsafeSyncNetwork&&null!=s?a.keys:void 0,u=await n.syncNetwork({privateKeys:c});t.setDelay(u)}),1e4,{onError:t=>{e.props.log.error(t)}});return{update(e){if(null==e.walletOutput)return;const{engine:n,engineStarted:r}=e.walletOutput;null==(null==n?void 0:n.syncNetwork)||!r||null!=t&&t.started||t.start({wait:!1})},destroy(){null!=t&&t.stop()}}}),(e=>e.state.paused||e.walletState.paused||!e.walletState.engineStarted||!0===e.walletState.currencyInfo.usesChangeServer&&!e.walletState.changeServiceSubscriptions.some((e=>"avoiding"===e.status||"reconnecting"===e.status||"resubscribing"===e.status||"subscribingSlowly"===e.status))?void 0:e)),syncTimer:vr((e=>{const t=Hr((async function(){const{walletId:t}=e.props;await ho(yu(e),t)}),fo);return{update(){const{state:n,walletId:r,walletOutput:o}=e.props;null!=o&&null!=n.storageWallets[r]&&n.storageWallets[r].status.lastSync>0&&t.start({wait:fo*(1+Math.random())})},destroy(){t.stop()}}}),(e=>e.state.paused||e.walletState.paused?void 0:e)),tokenSaver(e){let t=Ds;return async function(){const{detectedTokenIds:n,enabledTokenIds:r,tokenFileDirty:o,tokenFileLoaded:i}=e.props.walletState;if(o&&i){const o=pc(r,t),i=pc(t,r),a=e.props.walletId.slice(0,2);e.props.log.warn(`enabledTokenIds: ${a} write to disk, add [${o}], remove [${i}]`),await async function(e,t,n){const{state:r,walletId:o}=e.props,i=bo(r,o);await as.save(i,Qa,{detectedTokenIds:t,enabledTokenIds:n})}(e,n,r).catch((t=>e.props.onError(t))),e.props.dispatch({type:"CURRENCY_WALLET_SAVED_TOKEN_FILE",payload:{walletId:e.props.walletId}}),await Yr(100)}t=r}},watcher(e){let t,n={},r={},o=Ds;return async()=>{var i,a;const{state:s,walletState:c,walletOutput:u}=e.props;if(null==c||null==u)return;const{engine:l,walletApi:d}=u,{accountId:f,pluginId:p}=c,h=s.accounts[f];t!==c&&null!=d&&U(d),t=c;const y=null!==(i=h.userSettings[p])&&void 0!==i?i:n;n!==y&&null!=l&&await l.changeUserSettings(y),n=y;const b=null!==(a=h.customTokens[p])&&void 0!==a?a:r;if(r!==b&&null!=l)if(null!=l.changeCustomTokens)await l.changeCustomTokens(b);else if(null!=l.addCustomToken)for(const t of Object.keys(b)){const n=b[t];if(n===r[t])continue;const o=Lo(n);null!=o&&await l.addCustomToken(cc(cc({},o),n)).catch((t=>e.props.onError(t)))}r=b;const{allEnabledTokenIds:g}=c;if(o!==g&&null!=l)if(null!=l.changeEnabledTokenIds)await l.changeEnabledTokenIds(g).catch((t=>e.props.onError(t)));else if(null!=l.disableTokens&&null!=l.enableTokens){const t=Ga(h.builtinTokens[p],h.customTokens[p],c.currencyInfo,$a(o,g)),n=Ga(h.builtinTokens[p],h.customTokens[p],c.currencyInfo,$a(g,o));await l.disableTokens(t).catch((t=>e.props.onError(t))),await l.enableTokens(n).catch((t=>e.props.onError(t)))}o=g}}});async function fc(e,t,n){const r=await lc.load(t,uc);if(null!=r&&(null==n.checkPublicKey||await n.checkPublicKey(r.walletInfo.keys)))return r.walletInfo;let o={};try{o=await n.derivePublicKey(e)}catch(a){}const i={id:e.id,type:e.type,keys:o};return Object.keys(o).length>0&&await lc.save(t,uc,{walletInfo:i}),i}function pc(e,t){const n=new Set(t);return e.filter((e=>!n.has(e))).join(", ")}async function hc(e,t,n){const{stashTree:r}=An(e,t.loginId),{deviceDescription:o}=e.props.state.login.deviceInfo,i=Zn(r,t);null!=o&&(i.deviceDescription=o),i.data=bt(n);const a=await gn(e,"POST","/v2/login/vouchers",i),s=qn(r,t.loginKey,Je(a));return await Pn(e,s)}function yc(e,t){if(null==e)return{};var n,r,o=function(e,t){if(null==e)return{};var n,r,o={},i=Object.keys(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||(o[n]=e[n]);return o}(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(r=0;r<i.length;r++)n=i[r],t.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(o[n]=e[n])}return o}const bc=["fromWallet","toWallet"];function gc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function wc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?gc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function vc(e,t,n,r={}){const{disabled:o={},noResponseMs:i,preferPluginId:a,promoCodes:s={},slowResponseMs:c=2e4}=r,{log:u,state:l}=e.props,d=l.accounts[t],{swapSettings:f,userSettings:p}=d,h=l.plugins.swap;u.warn("Requesting swap quotes for: ",wc(wc({},n),{},{fromWallet:n.fromWallet.id,toWallet:n.toWallet.id}),{preferPluginId:a,promoCodes:s});const y=new Set,b=[];for(const m of Object.keys(h)){var g,w;const{enabled:e=!0}=null!=f[m]?f[m]:{};e&&!o[m]&&(y.add(m),b.push(h[m].fetchSwapQuote(n,p[m],{infoPayload:null!==(g=null===(w=l.infoCache.corePlugins)||void 0===w?void 0:w[m])&&void 0!==g?g:{},promoCode:s[m]}).then((e=>{var t;Wo(e);const n=null!==(t=e.request)&&void 0!==t?t:{},{fromWallet:r,toWallet:o}=n,i=yc(n,bc),a=wc(wc({},e),{},{request:i});return y.delete(m),u.warn(`${m} gave swap quote:`,a),e}),(e=>{throw y.delete(m),u.warn(`${m} gave swap error: ${String(e)}`),Ic(e)&&u.crash(`Unknown swap error: ${String(e)}`,{error:e,swapPluginId:m,request:{fromToken:String(n.fromTokenId),fromWalletType:n.fromWallet.type,toToken:String(n.toTokenId),toWalletType:n.toWallet.type,quoteFor:n.quoteFor}}),e}))))}const v=function(e,t){return new Promise(((n,r)=>{let o=!1;const i=[],a=[];let s=setTimeout((()=>{s=void 0,i.length>0&&(o=!0,n({results:i,errors:a}))}),t);function c(){const t=i.length+a.length===e.length;t&&null!=s&&clearTimeout(s),(t||null==s&&i.length>0)&&(o=!0,i.length>0?n({results:i,errors:a}):r(a))}c();for(const t of e)t.then((e=>{o||(i.push(e),c())}),(e=>{o||(a.push(e),c())}))}))}(b,c).then((({results:e,errors:t})=>{for(const n of y)u.warn(`${n} gave swap timeout`);const o=function(e,t){const{preferPluginId:n,preferType:r,promoCodes:o}=t;return e.sort(((e,t)=>{if("transfer"===e.pluginId)return-1;if("transfer"===t.pluginId)return 1;if(e.pluginId===n)return-1;if(t.pluginId===n)return 1;if(null!=r){const n=!0===e.swapInfo.isDex&&"DEX"===r||!0!==e.swapInfo.isDex&&"CEX"===r,o=!0===t.swapInfo.isDex&&"DEX"===r||!0!==t.swapInfo.isDex&&"CEX"===r;if(n&&!o)return-1;if(!n&&o)return 1}if(null!=o){const n=null!=o[e.pluginId],r=null!=o[t.pluginId];if(n&&!r)return-1;if(!n&&r)return 1}const{isEstimate:i=!0}=e,{isEstimate:a=!0}=t;if(!i&&a)return-1;if(i&&!a)return 1;const s=Number(e.toNativeAmount)/Number(e.fromNativeAmount),c=Number(t.toNativeAmount)/Number(t.fromNativeAmount);return s>c?-1:c>s?1:0}))}(e,r);return u.warn(`${b.length} swap quotes requested, ${e.length} resolved, ${t.length} failed, sorted ${o.map((e=>e.pluginId)).join(", ")}.`),e.map((e=>function(e,t,n){var r,o;const i=_({canBePartial:n.canBePartial,expirationDate:n.expirationDate,fromNativeAmount:n.fromNativeAmount,isEstimate:n.isEstimate,maxFulfillmentSeconds:n.maxFulfillmentSeconds,networkFee:n.networkFee,pluginId:n.pluginId,request:null!==(r=n.request)&&void 0!==r?r:t,swapInfo:null!==(o=n.swapInfo)&&void 0!==o?o:e[n.pluginId].swapInfo,toNativeAmount:n.toNativeAmount,minReceiveAmount:n.minReceiveAmount,async approve(e){return await n.approve(e)},async close(){await n.close(),B(i)}});return i}(h,n,e)))}),(e=>{throw u.warn(`All ${b.length} swap quotes rejected.`),function(e){return e.reduce(((e,t)=>{const n=mc(e)-mc(t);if(n>0)return e;if(n<0)return t;const r=Xt(e),o=Xt(t);if(null!=r&&null!=o)return(0,Uo.lt)(r.nativeMin,o.nativeMin)?r:o;const i=Jt(e),a=Jt(t);return null!=i&&null!=a?(0,Uo.gt)(i.nativeMax,a.nativeMax)?i:a:e}))}(e)}));return null==i?await v:await bn(v,i)}function mc(e){return null==e?0:null!=Gt(e)||null!=Vt(e)?6:null!=Xt(e)?5:null!=Jt(e)?4:null!=en(e)?3.5:null!=Qt(e)?3:null!=Zt(e)?2:1}function Ic(e){return!(mc(e)>1)}const Ec=Er(ye({name:le})),Sc=Er(ye({key:le,data:le}));function Oc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Ac(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Oc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Oc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}let Tc=0;const _c=async(e,t,n,r={})=>{var o;const{keys:i}=r;if(null==i)throw new Error("No keys provided");const a="memorywallet-"+Tc++,s={id:a,type:n,keys:i},c=await Xr(e,t.currencyInfo.pluginId),u=await c.derivePublicKey(s);s.keys=Ac(Ac({},u),s.keys);const l=Cr(e.props.logBackend,`${a}-${n}`);let d=new Map,f=[],p={totalRatio:0},h=!1;const y=Hr((async()=>{await Yr(1e3),h&&(U(O),h=!1)}),0),b=e.props.state.plugins.currency[t.currencyInfo.pluginId],g={onAddressChanged:()=>{},onAddressesChecked(e){g.onSyncStatusChanged({totalRatio:e})},onNewTokens:e=>{const t=e.sort(((e,t)=>e.localeCompare(t)));if(f.length!==t.length)return f=t,void(h=!0);for(let n=0;n<t.length;n++)if(f[n]!==t[n])return f=t,void(h=!0)},onSeenTxCheckpoint:()=>{},onStakingStatusChanged:()=>{},onSubscribeAddresses:()=>{},onSyncStatusChanged(e){1!==p.totalRatio&&1===e.totalRatio&&(p=e,h=!0)},onTokenBalanceChanged:(e,t)=>{d.get(e)!==t&&(d=new Map(d),d.set(e,t),h=!0)},onTransactions:()=>{},onTransactionsChanged:()=>{},onTxidsChanged:()=>{},onUnactivatedTokenIdsChanged:()=>{},onWcNewContractCall:()=>{},onBlockHeightChanged:()=>{},onBalanceChanged:()=>{}},w=await b.makeCurrencyEngine(s,{callbacks:g,customTokens:Ac({},t.customTokens),enabledTokenIds:[...Object.keys(t.allTokens)],lightMode:!0,log:l,userSettings:Ac({},null!==(o=t.userSettings)&&void 0!==o?o:{}),walletLocalDisklet:(0,ee.Wh)(),walletLocalEncryptedDisklet:(0,ee.Wh)()}),{unsafeBroadcastTx:v=!1,unsafeMakeSpend:m=!1,unsafeSyncNetwork:I=!1}=b.currencyInfo,E=Ac({},i);let S;if(null!=w.syncNetwork){const t=async()=>{if(null!=w.syncNetwork){const e=await w.syncNetwork({privateKeys:I?{privateKeys:i}:void 0});S.setDelay(e)}else S.stop()};S=Hr(t,1e4,{onError:t=>{e.props.log.error(t)}}),S.start({wait:!1})}const O=_({watch:X,get balanceMap(){return d},get detectedTokenIds(){return f},get syncRatio(){return p.totalRatio},get syncStatus(){return p},async changeEnabledTokenIds(e){null!=w.changeEnabledTokenIds&&await w.changeEnabledTokenIds(e)},async startEngine(){var e;await w.startEngine(),null===(e=S)||void 0===e||e.start({wait:!1})},async getMaxSpendable(e){return await tc(e,b,w,t.allTokens,s)},async makeSpend(e){return await w.makeSpend(e,m?E:void 0)},async signTx(e){return await w.signTx(e,E)},async broadcastTx(e){return await w.broadcastTx(e,v?E:void 0)},async saveTx(){},async close(){var e;l.warn("killing memory wallet"),null===(e=S)||void 0===e||e.stop(),B(O),await w.killEngine()}});return y.start({wait:!1}),O};function kc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function xc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Pc={},Mc=[];class Cc extends Z{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n;const{otherMethods:r}=e.props.state.plugins.currency[n];null!=r?(_(r),this.otherMethods=r):this.otherMethods={}}get currencyInfo(){return this._ai.props.state.plugins.currency[this._pluginId].currencyInfo}get allTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].allTokens[n]}get builtinTokens(){const{state:e}=this._ai.props,{_accountId:t,_pluginId:n}=this;return e.accounts[t].builtinTokens[n]}get customTokens(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].customTokens[r])&&void 0!==e?e:Pc}async getTokenDetails(e){const{_ai:t,_pluginId:n}=this,r=await Xr(t,n);return null==r.getTokenDetails?[]:await r.getTokenDetails(e)}async getTokenId(e){const{_ai:t,_pluginId:n}=this;return await No(t,n,e)}async addCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this,o=await No(n,r,e);return n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:t,pluginId:r,tokenId:o,token:e}}),o}async changeCustomToken(e,t){const{_accountId:n,_ai:r,_pluginId:o}=this;if(null==r.props.state.accounts[n].customTokens[o][e])throw new Error(`There is no token with id "${e}"`);const i=await No(r,o,t);if(r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_ADDED",payload:{accountId:n,pluginId:o,tokenId:i,token:t}}),i!==e){const{wallets:t}=r.props.state.currency;for(const a of Object.keys(t)){const s=t[a];if(s.accountId!==n||s.pluginId!==o||!s.enabledTokenIds.includes(e))continue;const c=a.slice(0,2);r.props.log.warn(`enabledTokenIds: ${c} changeCustomToken edited id`),r.props.dispatch({type:"CURRENCY_WALLET_ENABLED_TOKENS_CHANGED",payload:{walletId:a,enabledTokenIds:$a([...s.enabledTokenIds,i],[e])}})}r.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:n,pluginId:o,tokenId:e}})}}async removeCustomToken(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_CUSTOM_TOKEN_REMOVED",payload:{accountId:t,pluginId:r,tokenId:e}})}get alwaysEnabledTokenIds(){var e;const{state:t}=this._ai.props,{_accountId:n,_pluginId:r}=this;return null!==(e=t.accounts[n].alwaysEnabledTokenIds[r])&&void 0!==e?e:Mc}async changeAlwaysEnabledTokenIds(e){const{_accountId:t,_ai:n,_pluginId:r}=this;n.props.dispatch({type:"ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED",payload:{accountId:t,pluginId:r,tokenIds:e}})}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeUserSettings(e){await yi(this._ai,this._accountId,this._pluginId,e)}async importKey(e,t={}){const n=await Xr(this._ai,this._pluginId);if(null==n.importPrivateKey)throw new Error("This wallet does not support importing keys");return xc(xc({},await n.importPrivateKey(e,t.keyOptions)),{},{imported:!0})}}class Nc extends Z{constructor(e,t,n){super(),this._ai=e,this._accountId=t,this._pluginId=n}get enabled(){const{swapSettings:e}=this._ai.props.state.accounts[this._accountId],{enabled:t=!0}=null!=e[this._pluginId]?e[this._pluginId]:{};return t}get needsActivation(){var e,t;const n=this._ai.props.state.plugins.swap[this._pluginId];if(null==n.checkSettings)return!1;const r=null!==(e=this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId])&&void 0!==e?e:{};return null!==(t=n.checkSettings(r).needsActivation)&&void 0!==t&&t}get swapInfo(){return this._ai.props.state.plugins.swap[this._pluginId].swapInfo}get userSettings(){return this._ai.props.state.accounts[this._accountId].userSettings[this._pluginId]}async changeEnabled(e){const t=this._ai.props.state.accounts[this._accountId];return await async function(e,t,n,r){var o;const{accountWalletInfo:i}=e.props.state.accounts[t],a=bo(e.props.state,i.id),s=null!==(o=await ui.load(a,di))&&void 0!==o?o:li;await ui.save(a,di,ai(ai({},s),{},{swapSettings:ai(ai({},e.props.state.accounts[t].swapSettings),{},{[n]:r})})),e.props.dispatch({type:"ACCOUNT_SWAP_SETTINGS_CHANGED",payload:{accountId:t,pluginId:n,swapSettings:r}})}(this._ai,this._accountId,this._pluginId,xc(xc({},t.swapSettings[this._pluginId]),{},{enabled:e}))}async changeUserSettings(e){await yi(this._ai,this._accountId,this._pluginId,e)}}function jc(e,t){let n=e.props.state.accounts[t];const r=()=>{const r=e.props.state.accounts[t];return null!=r&&(n=r),n},{accountWalletInfo:o,loginType:i}=r(),a={};for(const p of Object.keys(e.props.state.plugins.currency)){const n=new Cc(e,t,p);a[p]=n}const s={};for(const p of Object.keys(e.props.state.plugins.swap)){const n=new Nc(e,t,p);s[p]=n}const c=function(e,t){const{accountWalletInfo:n}=e.props.state.accounts[t],r=bo(e.props.state,n.id),o=t=>wo(e.props.state,n.id,t),i=e=>`Plugins/${o(e)}`,a=(e,t)=>`${i(e)}/${o(t)}.json`,s={async deleteItem(e,t){await r.delete(a(e,t))},async deleteStore(e){await r.delete(i(e))},async listItemIds(e){const t=[],n=(0,ee.gQ)(await r.list(i(e)));return await Promise.all(n.map((async e=>{const n=await Sc.load(r,e);null!=n&&t.push(n.key)}))),t},async listStoreIds(){const e=[],t=(0,ee.ji)(await r.list("Plugins"));return await Promise.all(t.map((async t=>{const n=await Ec.load(r,`${t}/Name.json`);null!=n&&e.push(n.name)}))),e},async getItem(e,t){const n=await Sc.load(r,a(e,t));if(null==n)throw new Error(`No item named "${t}"`);return n.data},async setItem(e,t,n){const o=`${i(e)}/Name.json`,s=await Ec.load(r,o);if(null==s)await Ec.save(r,o,{name:e});else if(s.name!==e)throw new Error(`Warning: folder name doesn't match for ${e}`);await Sc.save(r,a(e,t),{key:t,data:n})}};return _(s),s}(e,t),u=Ei(e,o);function l(){if(e.props.state.hideKeys)throw new Error("Not available when `hideKeys` is enabled")}let d=!1;const f={on:J,watch:X,get id(){return u.id},get type(){return u.type},get disklet(){return l(),u.disklet},get localDisklet(){return l(),u.localDisklet},async sync(){await u.sync()},get appId(){return r().login.appId},get created(){return r().login.created},async getLoginKey(){return l(),jt.stringify(r().login.loginKey)},get lastLogin(){return r().login.lastLogin},get loggedIn(){return null!=e.props.state.accounts[t]},get recoveryKey(){l();const{login:e}=r();return null!=e.recovery2Key?jt.stringify(e.recovery2Key):void 0},get rootLoginId(){l();const{loginTree:e}=r();return jt.stringify(e.loginId)},get username(){const{loginTree:e}=r();return e.username},get canDuressLogin(){const{activeAppId:t}=r();if(e.props.state.clientInfo.duressEnabled)return d;const n=t.endsWith(".duress")?t:t+".duress",o=Un(r().loginTree,(e=>e.appId===n));return null!=(null==o?void 0:o.pin2Key)},get isDuressAccount(){const{activeAppId:e}=r();return e.endsWith(".duress")},get currencyConfig(){return a},get swapConfig(){return s},get dataStore(){return c},get edgeLogin(){const{loginTree:e}=r();return null==e.loginKey},keyLogin:"keyLogin"===i,newAccount:"newAccount"===i,passwordLogin:"passwordLogin"===i,pinLogin:"pinLogin"===i,recoveryLogin:"recoveryLogin"===i,async changePassword(n){l(),this.isDuressAccount||await async function(e,t,n){const r=e.props.state.accounts[t],{loginTree:o,sessionKey:i}=r,{username:a}=r.stashTree;if(null==a)throw new Error("Password login requires a username");const s=await oa(e,o,a,n);await Yn(e,i,s)}(e,t,n)},async changePin(n){l(),e.props.log.breadcrumb("EdgeAccount.changePin",{});const{forDuressAccount:o=!1}=n,{activeAppId:i}=r(),a=i.endsWith(".duress")?i:i+".duress";var s;if(this.isDuressAccount&&o)return d=null!==(s=n.enableLogin)&&void 0!==s?s:null!=n.pin,e.props.dispatch({type:"UPDATE_NEXT"}),"";o&&await Ta(e,r().stashTree,r().sessionKey,a),await ua(e,t,n);const c=o?Un(r().login,(e=>e.appId===a)):r().login;if(null==c)throw new Error("Failed to find account.");return null!=c.pin2Key?jt.stringify(c.pin2Key):""},async changeRecovery(n,o){if(l(),this.isDuressAccount)return"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa";await ba(e,t,n,o);const{loginTree:i}=r();if(null==i.recovery2Key)throw new Error("Missing recoveryKey");return jt.stringify(i.recovery2Key)},async changeUsername(n){l(),n.username=re(n.username),await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=await Promise.all(function t(r){const o=[Ia(e,r,n)];for(const e of r.children)o.push(...t(e));return o}(r));await Vn(e,r,o)}(e,t,n)},async checkPassword(t){l();const{loginTree:n,stashTree:o}=r(),{loginKey:i}=n;return await async function(e,t,n,r){if(null!=r){const{passwordAuthBox:o,username:i}=t;if(null==o||null==i)return!1;const a=un(o,r),s=na(i,n),c=await In(e,s,ta);for(let e=0;e<a.length;++e)if(c[e]!==a[e])return!1;return!0}{const{passwordBox:r,passwordKeySnrp:i,username:a}=t;if(null==r||null==i||null==a)throw new Error("Missing data for offline password login");const s=na(a,n),c=await In(e,s,i);try{return un(r,c),!0}catch(o){return!1}}}(e,o,t,i)},async checkPin(t,n={}){l();const{login:o,loginTree:i}=r();return null!=o.pin&&null==n.forDuressAccount?t===o.pin:await async function(e,t,n,r){const{loginId:o,username:i}=t;if(null==i)return!1;const a=!0===r?t.appId+".duress":t.appId;if(e.props.state.clientInfo.duressEnabled)return!1;const{stashTree:s}=An(e,o),c=!0===r?Nn(s,a):sa(s,a);if(null==c||null==c.pin2Key)throw new Wt("No PIN set locally for this account");const{pin2Key:u}=c,l={pin2Id:ia(u,i),pin2Auth:aa(u,n),otp:Rn(t)};return await gn(e,"POST","/v2/login",l).then((e=>!0),(e=>!1))}(e,i,t,n.forDuressAccount)},async getPin(){var e;const{login:t,loginTree:n}=r();return null!==(e=t.pin)&&void 0!==e?e:n.pin},async deletePassword(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/password",stash:{passwordAuthSnrp:void 0,passwordBox:void 0,passwordKeySnrp:void 0}};null!=n.loginAuth&&(o.stash.passwordAuthBox=void 0),await Yn(e,r,o)}(e,t)},async deletePin(){l();const n=e.props.state.clientInfo.duressEnabled;await async function(e,t,n){const{loginTree:r}=e.props.state.accounts[t],o=pa(r,n);await Vn(e,r,o)}(e,t,n)},async deleteRecovery(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={login:{recovery2Key:void 0},loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/recovery2",stash:{recovery2Key:void 0}};await Yn(e,r,o)}(e,t)},get otpKey(){l();const{loginTree:e}=r();return null!=e.otpKey?h.stringify(e.otpKey,{pad:!1}):void 0},get otpResetDate(){l();const{loginTree:e}=r();return e.otpResetDate},async cancelOtpReset(){l(),await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],{otpTimeout:o,otpKey:i}=n;if(null==o||null==i)throw new Error("Cannot cancel 2FA reset: 2FA is not enabled.");const a={loginId:n.loginId,server:ct({otpTimeout:o,otpKey:i}),serverPath:"/v2/login/otp",stash:{otpResetDate:void 0}};await Yn(e,r,a)}(e,t)},async enableOtp(n=604800){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t],r=e.props.io.random(10);await Pn(e,Dn(Dn({},n),{},{otpKey:r}))}(e,t);await async function(e,t,n){const{loginTree:r,sessionKey:o}=e.props.state.accounts[t],{otpKey:i=e.props.io.random(10)}=r,a={loginId:r.loginId,server:ct({otpKey:i,otpTimeout:n}),serverPath:"/v2/login/otp",stash:{otpKey:i,otpResetDate:void 0,otpTimeout:n}};await Yn(e,o,a)}(e,t,n)},async disableOtp(){if(l(),this.isDuressAccount)return await async function(e,t){const{stashTree:n}=e.props.state.accounts[t];await Pn(e,Dn(Dn({},n),{},{otpKey:void 0}))}(e,t);await async function(e,t){const{loginTree:n,sessionKey:r}=e.props.state.accounts[t],o={loginId:n.loginId,server:void 0,serverMethod:"DELETE",serverPath:"/v2/login/otp",stash:{otpKey:void 0,otpResetDate:void 0,otpTimeout:void 0}};await Yn(e,r,o)}(e,t)},async repairOtp(n){l(),await async function(e,t,n){if(null==e.props.state.accounts[t])return;const{login:r}=e.props.state.accounts[t],{userId:o,passwordAuth:i}=r,{stashTree:a,stash:s}=An(e,r.loginId);if(null==i||null==o)throw new Error("Cannot repair OTP: There is no password on this account");const c={userId:o,passwordAuth:i,otp:pn(n)},u={now:a.lastLogin};await Hn(e,a,s,u,c,(async()=>r.loginKey))}(e,t,h.parse(n,{loose:!0}))},get pendingVouchers(){const{login:e}=r();return e.pendingVouchers},async approveVoucher(t){const{loginTree:n}=r();return await hc(e,n,{approvedVouchers:[t]})},async rejectVoucher(t){const{loginTree:n}=r();return await hc(e,n,{rejectedVouchers:[t]})},async fetchLobby(n){return e.props.log.breadcrumb("EdgeAccount.fetchLobby",{}),l(),await qa(e,t,n)},async deleteRemoteAccount(){const{loginTree:t}=r();this.isDuressAccount||await async function(e,t){const{stashTree:n}=An(e,t.loginId),{deviceDescription:r}=e.props.state.login.deviceInfo,o=Zn(n,t);null!=r&&(o.deviceDescription=r),await gn(e,"POST","/v2/login/delete",o)}(e,t)},async logout(){e.props.dispatch({type:"LOGOUT",payload:{accountId:t}})},get allKeys(){return e.props.state.accounts[t].allWalletInfosClean},async changeWalletStates(n){await hi(e,t,n)},async createWallet(t,n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.createWallet",{});const s=await ri(e,t,{keys:n}),c=Xn(a,i,o.loginId);return await Yn(e,i,Qo(e,c,[s])),s.id},getFirstWalletInfo:te.prototype.getFirstWalletInfo,getWalletInfo:te.prototype.getWalletInfo,listWalletIds:te.prototype.listWalletIds,async splitWalletInfo(n,o){var i,a;const{allWalletInfosFull:s}=r(),c=s.find((e=>e.id===n));if(null==c)throw new Error(`Invalid wallet id ${n}`);const u=null===(i=e.props.output)||void 0===i||null===(i=i.currency)||void 0===i||null===(i=i.wallets[c.id])||void 0===i?void 0:i.walletApi;if("wallet:bitcoin"===c.type&&"bip49"===c.keys.format&&"wallet:bitcoincash"===o)throw new Error("Cannot split segwit-format Bitcoin wallets to Bitcoin Cash");const[l]=await mi(e,t,c,[{walletType:o,name:null!==(a=null==u?void 0:u.name)&&void 0!==a?a:void 0,fiatCurrencyCode:null==u?void 0:u.fiatCurrencyCode}],!0);if(l.ok)return l.result.id;throw l.error},async listSplittableWalletTypes(n){return await async function(e,t,n){const{allWalletInfosFull:r}=e.props.state.accounts[t],o=r.find((e=>e.id===n));if(null==o)throw new Error(`Invalid wallet id ${n}`);const i=Jr(e.props.state.plugins.currency,o.type);if(null==i)return[];const a=await Xr(e,i);return null==a.getSplittableTypes?[]:(await a.getSplittableTypes(o)).filter((e=>{const t=vi(o,e),n=r.find((e=>e.id===t.id));return null==n||n.archived||n.deleted}))}(e,t,n)},async getDisplayPrivateKey(n){const r=Dc(e,t,n),o=Vr(e.props.state.plugins.currency,r.type),i=await Xr(e,o);if(null!=i.getDisplayPrivateKey)return await i.getDisplayPrivateKey(r);const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPrivateSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPrivateSeed(r.keys);if(null==s)throw new Error("The engine failed to return a key");return s},async getDisplayPublicKey(n){const r=Dc(e,t,n),o=Vr(e.props.state.plugins.currency,r.type),i=await Xr(e,o);if(null!=i.getDisplayPublicKey){const t=oo(e.props.io,n),o=await fc(r,t,i);return await i.getDisplayPublicKey(o)}const{engine:a}=e.props.output.currency.wallets[n];if(null==a||null==a.getDisplayPublicSeed)throw new Error("Wallet has not yet loaded");const s=await a.getDisplayPublicSeed();if(null==s)throw new Error("The engine failed to return a key");return s},async getRawPrivateKey(n){return Dc(e,t,n).keys},async getRawPublicKey(n){const r=Dc(e,t,n),o=Vr(e.props.state.plugins.currency,r.type),i=await Xr(e,o),a=oo(e.props.io,n);return(await fc(r,a,i)).keys},get activeWalletIds(){return e.props.state.accounts[t].activeWalletIds},get archivedWalletIds(){return e.props.state.accounts[t].archivedWalletIds},get hiddenWalletIds(){return e.props.state.accounts[t].hiddenWalletIds},get currencyWallets(){return e.props.output.accounts[t].currencyWallets},get currencyWalletErrors(){return e.props.state.accounts[t].currencyWalletErrors},async createCurrencyWallet(n,o={}){const{login:i,sessionKey:a,stashTree:s}=r();e.props.log.breadcrumb("EdgeAccount.createCurrencyWallet",{});const c=await ri(e,n,o),u=Xn(s,a,i.loginId);return await Yn(e,a,Qo(e,u,[c])),await oi(e,t,c.id,o)},async makeMemoryWallet(t,n={}){const r=Object.values(a).find((e=>e.currencyInfo.walletType===t));if(null==r)throw new Error("Invalid walletType");return await _c(e,r,t,n)},async createCurrencyWallets(n){const{login:o,sessionKey:i,stashTree:a}=r();e.props.log.breadcrumb("EdgeAccount.makeMemoryWallet",{});const s=await Promise.all(n.map((async t=>await ri(e,t.walletType,t)))),c=Xn(a,i,o.loginId);return await Yn(e,i,Qo(e,c,s)),await Promise.all(s.map((async(r,o)=>await yo(oi(e,t,r.id,n[o])))))},async waitForCurrencyWallet(e){return await new Promise(((t,n)=>{const r=()=>{const r=this.currencyWallets[e];null!=r&&(t(r),o());const i=this.currencyWalletErrors[e];null!=i&&(n(i),o())},o=()=>{for(const e of i)e()},i=[this.watch("currencyWallets",r),this.watch("currencyWalletErrors",r)];r()}))},async waitForAllWallets(){return await new Promise(((e,t)=>{const n=()=>{if(null==this.activeWalletIds.find((e=>null==this.currencyWallets[e]&&null==this.currencyWalletErrors[e]))){for(const e of r)e();e()}},r=[this.watch("activeWalletIds",n),this.watch("currencyWallets",n),this.watch("currencyWalletErrors",n)];n()}))},async getActivationAssets({activateWalletId:n,activateTokenIds:r}){const{currencyWallets:o}=e.props.output.accounts[t],i=e.props.output.currency.wallets[n],{engine:a}=i;if(null==a)throw new Error(`Invalid wallet: ${n} not found`);if(null==a.engineGetActivationAssets)throw new Error(`getActivationAssets unsupported by walletId ${n}`);const s=await a.engineGetActivationAssets({currencyWallets:o,activateTokenIds:r});return s.assetOptions.forEach((e=>{var t;return e.tokenId=null!==(t=e.tokenId)&&void 0!==t?t:null})),s},async activateWallet(n){var r;const{activateWalletId:o,activateTokenIds:i,paymentInfo:a}=n,{currencyWallets:s}=e.props.output.accounts[t],c=e.props.output.currency.wallets[o],{engine:u}=c;if(null==u)throw new Error(`Invalid wallet: ${o} not found`);if(null==u.engineActivateWallet)throw new Error(`activateWallet unsupported by walletId ${o}`);const l=null!==(r=null==a?void 0:a.walletId)&&void 0!==r?r:"",d=s[l];if(null==d)throw new Error(`No wallet for walletId ${l}`);const f=await u.engineActivateWallet({activateTokenIds:i,paymentInfo:null!=a?{wallet:d,tokenId:a.tokenId}:void 0,paymentTokenId:null==a?void 0:a.tokenId,paymentWallet:d});return void 0===f.networkFee.tokenId&&(f.networkFee.tokenId=null),_(f)},async fetchSwapQuote(n,r){const[o,...i]=await vc(e,t,n,r);for(const e of i)e.close().catch((()=>{}));if(null==o)throw new Error("No swap providers enabled");return o},async fetchSwapQuotes(n,r){return await vc(e,t,n,r)}};return _(f),f}function Dc(e,t,n){const r=e.props.state.accounts[t].allWalletInfosFull.find((e=>e.id===n));if(null==r)throw new Error(`Invalid wallet: ${n} not found`);return r}function Rc(e){var t=function(e,t){if("object"!=typeof e||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var r=n.call(e,t||"default");if("object"!=typeof r)return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function Lc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Bc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Kc={},Uc={loginId:new Uint8Array,loginKey:new Uint8Array},Fc=As({accountWalletInfo:Cs((e=>e.self.activeAppId),(e=>e.self.allWalletInfosFull),((e,t)=>{const n=Xo(e),r=Jo(t,n);if(null==r)throw new Error(`Cannot find a "${n}" repo`);return r})),accountWalletInfos:Cs((e=>e.self.activeAppId),(e=>e.self.allWalletInfosFull),((e,t)=>{const n=[Xo(e)];return""===e&&n.push("account:repo:co.airbitz.wallet",""),t.filter((e=>n.includes(e.type)))})),allWalletInfosFull:Cs((e=>e.self.stashTree),(e=>e.self.login),(e=>e.self.legacyWalletInfos),(e=>e.self.walletStates),((e,t,n,r)=>function(e,t,n,r){const o=new Map,i=new Map,a=[...n],s=Tn(e,t.loginId);for(const c of n){a.push(c);const e=i.get(c.id);null!=e?e.push(s.appId):i.set(c.id,[s.appId])}return function e(t,n){const r=ti(t,n,o);for(const o of r){a.push(o);const e=i.get(o.id);null!=e?e.push(t.appId):i.set(o.id,[t.appId])}for(const o of null!==(s=t.children)&&void 0!==s?s:[]){var s;null!=o.parentBox&&e(o,un(o.parentBox,n))}}(s,t.loginKey),ei(a).map((e=>{var t,n,s;return Vo(Vo({appId:(s=null!==(t=i.get(e.id))&&void 0!==t?t:[],s[s.length-1]),appIds:null!==(n=i.get(e.id))&&void 0!==n?n:[],archived:!1,created:o.get(e.id),deleted:!1,hidden:!1,sortIndex:a.length,imported:e.keys.imported},r[e.id]),e)}))}(e,t,n,r))),allWalletInfosClean:Cs((e=>e.self.allWalletInfosFull),(e=>e.map((e=>Bc(Bc({},e),{},{keys:{}}))))),currencyWalletErrors(e={},t,n,r){var o;const{activeWalletIds:i}=n.self,a=n.root.currency.wallets;let s=i!==(null===(o=r.self)||void 0===o?void 0:o.activeWalletIds);const c={};for(const u of i){const t=a[u].engineFailure;null!=t&&(c[u]=t),c[u]!==e[u]&&(s=!0)}return s?c:e},currencyWalletIds:Cs((e=>e.self.walletInfos),(e=>e.root.plugins.currency),((e,t)=>Object.keys(e).filter((n=>{const r=e[n],o=Jr(t,r.type);return!r.deleted&&null!=o})).sort(((t,n)=>{const r=e[t],o=e[n];return r.sortIndex-o.sortIndex})))),activeWalletIds:Cs((e=>e.self.walletInfos),(e=>e.self.currencyWalletIds),(e=>e.self.keysLoaded),((e,t,n)=>n?t.filter((t=>!e[t].archived)):[])),archivedWalletIds:Cs((e=>e.self.walletInfos),(e=>e.self.currencyWalletIds),(e=>e.self.keysLoaded),((e,t,n)=>n?t.filter((t=>e[t].archived)):[])),hiddenWalletIds:Cs((e=>e.self.walletInfos),(e=>e.self.currencyWalletIds),(e=>e.self.keysLoaded),((e,t,n)=>n?t.filter((t=>e[t].hidden)):[])),keysLoaded(e=!1,t){return"ACCOUNT_KEYS_LOADED"===t.type||e},legacyWalletInfos(e=[],t){return"ACCOUNT_KEYS_LOADED"===t.type?t.payload.legacyWalletInfos:e},walletInfos:Cs((e=>e.self.allWalletInfosFull),(e=>{const t={};for(const n of e)t[n.id]=n;return t})),walletStates(e={},t){return"ACCOUNT_CHANGED_WALLET_STATES"===t.type||"ACCOUNT_KEYS_LOADED"===t.type?t.payload.walletStates:e},pauseWallets(e=!1,t){return"LOGIN"===t.type?t.payload.pauseWallets:e},activeAppId:(e="",t)=>"LOGIN"===t.type?t.payload.appId:e,loadFailure(e=null,t){if("ACCOUNT_LOAD_FAILED"===t.type){const{error:e}=t.payload;return e instanceof Error?e:new Error(String(e))}return e},login:Cs((e=>e.self.activeAppId),(e=>e.self.loginTree),((e,t)=>{const n=Un(t,(t=>t.appId===e));if(null==n)throw new Error(`Internal error: cannot find login for ${e}`);return n})),loginTree:Cs((e=>e.self.stashTree),(e=>e.self.sessionKey),((e,t)=>Gn(e,t))),loginType(e="newAccount",t){return"LOGIN"===t.type?t.payload.loginType:e},rootLoginId(e=new Uint8Array(0),t){return"LOGIN"===t.type?t.payload.rootLoginId:e},sessionKey(e=Uc,t){return"LOGIN"===t.type?t.payload.sessionKey:e},stashTree:Cs((e=>e.self.rootLoginId),(e=>e.root.login.stashes),((e,t)=>{for(const n of t)if(an(n.loginId,e))return n;throw new Error("There is no stash")})),allTokens(e={},t,n,r){const{builtinTokens:o,customTokens:i}=n.self;if(null==r.self||o!==r.self.builtinTokens||i!==r.self.customTokens){const t=Bc({},e);for(const e of Object.keys(n.root.plugins.currency))null!=r.self&&o[e]===r.self.builtinTokens[e]&&i[e]===r.self.customTokens[e]||(t[e]=Bc(Bc({},i[e]),o[e]));return t}return e},builtinTokens(e={},t){if("ACCOUNT_BUILTIN_TOKENS_LOADED"===t.type){const{pluginId:n,tokens:r}=t.payload;return Bc(Bc({},e),{},{[n]:r})}return e},customTokens(e=Kc,t){switch(t.type){case"ACCOUNT_CUSTOM_TOKENS_LOADED":{const{customTokens:e}=t.payload;return e}case"ACCOUNT_CUSTOM_TOKEN_ADDED":{var n;const{pluginId:r,tokenId:o,token:i}=t.payload,a=null!==(n=e[r])&&void 0!==n?n:{};if(Oi(a[o],i))return e;const s=Bc(Bc({},a),{},{[o]:i});return Bc(Bc({},e),{},{[r]:s})}case"ACCOUNT_CUSTOM_TOKEN_REMOVED":{var r;const{pluginId:n,tokenId:o}=t.payload,i=null!==(r=e[n])&&void 0!==r?r:{};if(null==i[o])return e;const{[o]:a}=i,s=yc(i,[o].map(Rc));return Bc(Bc({},e),{},{[n]:s})}}return e},alwaysEnabledTokenIds(e={},t){if("ACCOUNT_ALWAYS_ENABLED_TOKENS_CHANGED"===t.type){const{pluginId:n,tokenIds:r}=t.payload;return Bc(Bc({},e),{},{[n]:r})}return e},swapSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.swapSettings;case"ACCOUNT_SWAP_SETTINGS_CHANGED":{const{pluginId:n,swapSettings:r}=t.payload,o=Bc({},e);return o[n]=r,o}}return e},userSettings(e={},t){switch(t.type){case"ACCOUNT_PLUGIN_SETTINGS_CHANGED":{const{pluginId:n,userSettings:r}=t.payload,o=Bc({},e);return o[n]=r,o}case"ACCOUNT_PLUGIN_SETTINGS_LOADED":return t.payload.userSettings}return e}}),Wc=ks(Fc,((e,t)=>/^ACCOUNT_/.test(e.type)&&"payload"in e&&"object"==typeof e.payload&&"accountId"in e.payload&&e.payload.accountId===t.id||"LOGIN"===e.type&&t.root.lastAccountId===t.id?e:{type:"UPDATE_NEXT"}));function qc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function zc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?qc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):qc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Gc=br({accountApi(e){return{destroy(){e.props.state={accounts:{}};const{accountOutput:t}=e.props;if(null==t)return;const{accountApi:n}=t;if(null==n)return;U(n),B(n),B(n.dataStore);const{currencyConfig:r,swapConfig:o}=n;for(const e of Object.keys(r))B(r[e]);for(const e of Object.keys(o))B(o[e])},async update(){const t=yu(e),{accountId:n,accountState:r,log:o}=e.props,{accountWalletInfos:i}=r;try{await async function(e){await e.waitFor((e=>{const{init:t,locked:n}=e.state.plugins;if(!n)return;const{currency:r,swap:o}=e.state.plugins,i=[];for(const a of Object.keys(t))!1!==t[a]&&null!=t[a]&&null==r[a]&&null==o[a]&&i.push(a);if(i.length>0)throw new Error("The following plugins are missing or failed to load: "+i.join(", "));return!0}))}(t),await Bo(t,n),o.warn("Login: currency plugins exist"),await Promise.all(i.map((e=>po(t,e)))),o.warn("Login: synced account repos"),await async function(){await Promise.all([pi(t,n),Ko(t,n),bi(t,n)])}(),o.warn("Login: loaded files"),e.onOutput(jc(t,n)),o.warn("Login: complete")}catch(a){e.props.dispatch({type:"ACCOUNT_LOAD_FAILED",payload:{accountId:n,error:a}})}return await Ir}}},syncTimer:vr((e=>{const t=Hr((async function(){const t=yu(e),{accountId:n,accountState:r}=e.props,{accountWalletInfos:o}=r;if(null==e.props.state.accounts[n])return;const i=await Promise.all(o.map((e=>ho(t,e.id)))),a=[];for(const e of i)a.push(...e);a.length>0&&await Promise.all([bi(t,n),pi(t,n)])}),fo),n=Hr((async function(){const t=yu(e),{accountId:n}=e.props;if(null==e.props.state.accounts[n])return;const{sessionKey:r}=e.props.state.accounts[n];await Jn(t,r)}),fo,{onError(t){const n=$t(t);null!=n&&e.props.onError(n)}});return{update(){var r;if(null==(null===(r=e.props.accountOutput)||void 0===r?void 0:r.accountApi))return;const{accountId:o}=e.props,{stashTree:i}=e.props.state.accounts[o],a=null!=i.wipChange?5e3:fo;t.setDelay(fo),n.setDelay(a),t.start({wait:fo*(1+Math.random())}),n.start({wait:a*(1+Math.random())})},destroy(){t.stop(),n.stop()}}}),(e=>e.state.paused?void 0:e)),tokenSaver(e){let t=Kc;return async function(){const{accountId:n,accountState:r}=e.props,{customTokens:o}=r;o!==t&&t!==Kc&&(await async function(e,t){const{state:n}=e.props,{accountWalletInfo:r}=n.accounts[t],o=bo(n,r.id),{customTokens:i}=e.props.state.accounts[t],a=await ko.load(o,Po);await ko.save(o,Po,_o(_o({},a),{},{customTokens:i}))}(yu(e),n).catch((t=>e.props.onError(t))),await Yr(100)),t=o}},watcher(e){let t;return()=>{const{accountState:n,accountOutput:r}=e.props;if(null==n||null==r)return;const{accountApi:o}=r;if(null!=o&&U(o),t!==n&&(t=n,null!=o)){const{currencyConfig:e,swapConfig:t}=o;for(const n of Object.keys(e))U(e[n]);for(const n of Object.keys(t))U(t[n])}}},currencyWallets(e){let t;return()=>{const{accountOutput:n,accountState:r}=e.props,{activeWalletIds:o}=r;let i=t!==o;t=o;let a={};null!=(null==n?void 0:n.currencyWallets)&&(a=n.currencyWallets);const s={},{wallets:c}=e.props.output.currency;for(const e of o){var u;const t=null===(u=c[e])||void 0===u?void 0:u.walletApi;t!==a[e]&&(i=!0),null!=t&&(s[e]=t)}i&&e.onOutput(s)}}}),$c=mr(Gc,(e=>e.state.accountIds),((e,t)=>zc(zc({},e),{},{accountId:t,accountState:e.state.accounts[t],accountOutput:e.output.accounts[t]}))),Hc=["loginId"];function Yc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Vc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Yc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Yc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class Jc extends Z{constructor(e){super(),this._lobby=e,this._cleanups=[e.close,e.on("reply",(e=>U(this,"replies"))),e.on("error",(e=>K(this,"error",e)))]}get lobbyId(){return this._lobby.lobbyId}get replies(){return this._lobby.replies}close(){this._cleanups.forEach((e=>e())),B(this)}}class Xc extends Z{constructor(e){super(),this._ai=e}authRequest(e,t,n){return gn(this._ai,e,t,n)}hashUsername(e){return kn(this._ai,e)}async makeLobby(e,t=1e3){const n=await Da(this._ai,e,t);return new Jc(n)}fetchLobbyRequest(e){return Ra(this._ai,e)}async sendLobbyReply(e,t,n){await La(this._ai,e,t,n)}async syncRepo(e){const{io:t,syncClient:n}=this._ai.props,r=io(t,{dataKey:new Uint8Array(0),syncKey:e});return await co(n,r,{lastSync:0,lastHash:void 0})}async getRepoDisklet(e,t){const{io:n}=this._ai.props,r=io(n,{dataKey:t,syncKey:e});return _(r.disklet),r.disklet}}function Zc(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Qc(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Zc(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zc(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function eu(e){const t=e.props.state.login.contextAppId,n=jt.stringify(e.props.state.clientInfo.clientId),r=new Xc(e);let o;const i={on:J,watch:X,appId:t,clientId:n,async close(){e.props.close()},$internalStuff:r,fixUsername:re,get localUsers(){return e.props.state.login.localUsers},async forgetAccount(t){const n=jt.parse(t);for(const r of e.props.state.accountIds){if(an(e.props.state.accounts[r].stashTree.loginId,n))throw new Error("Cannot remove logged-in user")}await async function(e,t){const{dispatch:n,io:r}=e.props,o=await r.disklet.list("logins").then(ee.gQ);for(const a of o)try{an(Mn(JSON.parse(await r.disklet.getText(a))).loginId,t)&&await r.disklet.delete(a)}catch(i){}n({type:"LOGIN_STASH_DELETED",payload:t})}(e,n)},async fetchChallenge(){const t=await gn(e,"POST","/v2/captcha/create",{}),{challengeId:n,challengeUri:r}=$e(t);return{challengeId:n,challengeUri:r}},async usernameAvailable(t,n={}){const{challengeId:r}=n;return t=re(t),await async function(e,t,n){const r={challengeId:n,userId:await kn(e,t)};return await gn(e,"POST","/v2/login",r).then((e=>!1)).catch((e=>{if(null!=tn(e))return!0;throw e}))}(e,t,r)},async createAccount(t){e.props.log.breadcrumb("EdgeContext.createAccount",{}),null!=t.username&&(t.username=re(t.username));const n=await async function(e,t,n){const{challengeId:r,now:o=new Date}=t;e.props.log.breadcrumb("createLogin",{});const{kit:i,sessionKey:a}=await Aa(e,void 0,"",n),s={challengeId:r,data:i.server};return await gn(e,"POST",i.serverPath,s),i.stash.lastLogin=o,await Pn(e,i.stash),a}(e,t,t);return await _a(e,n,"newAccount",t)},async loginWithKey(n,r,o={}){const{now:i=new Date,useLoginId:a=!1}=o,s=e.props.state.clientInfo.duressEnabled,c=a?An(e,jt.parse(n)).stashTree:On(e,re(n));if(null==c)throw new Error("User does not exist on this device");const u=Un(c,(e=>e.appId===t));if(null==u)throw new Error(`Cannot find requested appId: "${t}"`);const l=t+".duress",d=Un(c,(e=>e.appId===l));let f;try{f={loginId:u.loginId,loginKey:jt.parse(r)},Zn(c,f)}catch(p){if(!(p instanceof Error&&"Invalid checksum"===p.message))throw p;if(null==d)throw p;f={loginId:d.loginId,loginKey:jt.parse(r)},Zn(c,f)}return c.lastLogin=i,Pn(e,c).catch((()=>{})),Jn(e,f).catch((t=>e.props.onError(t))),await _a(e,f,"keyLogin",Qc(Qc({},o),{},{duressMode:s&&null!=(null==d?void 0:d.pin2Key)}))},async loginWithPassword(n,r,o={}){var i;e.props.log.breadcrumb("EdgeContext.loginWithPassword",{}),n=re(n);const a=null!==(i=On(e,n))&&void 0!==i?i:Sn(n),s=await ra(e,a,r,o);if(e.props.state.clientInfo.duressEnabled){const r=t+".duress",i=On(e,n);if(null==i)throw new Error("Missing stash after login with password");const a=Un(i,(e=>e.appId===r));if(null!=(null==a?void 0:a.pin2Key)){const t=Xn(i,s,a.loginId);return await _a(e,t,"passwordLogin",Qc(Qc({},o),{},{duressMode:!0}))}}return await _a(e,s,"passwordLogin",o)},checkPasswordRules:ne,async loginWithPIN(n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithPIN",{});const{useLoginId:i=!1}=o,a=i?An(e,jt.parse(n)).stashTree:On(e,re(n));if(null==a)throw new Error("User does not exist on this device");const s=sa(a,t),c=t+".duress",u=Un(a,(e=>e.appId===c));async function l(t,n){const i=null!=t.wipChange?await ca(e,t.wipChange,n,r,o).catch((async()=>await ca(e,t,n,r,o))):await ca(e,t,n,r,o);return await _a(e,i,"pinLogin",o)}async function d(t,n){if(!0===n.fakePinDisabled)throw new Wt("PIN login is not enabled for this account on this device");const i=await ca(e,t,n,r,o);return await _a(e,i,"pinLogin",Qc(Qc({},o),{},{duressMode:!0}))}if(null==s){if(null==u)throw new Wt("PIN login is not enabled for this account on this device");return await d(a,u)}if(null==(null==u?void 0:u.pin2Key))return await l(a,s);const f=e.props.state.clientInfo.duressEnabled,p=jt.stringify(s.loginId),h=e.props.state.clientInfo.loginWaitTimestamps[p];if(null!=h&&h>Date.now())throw new Ft({wait_seconds:Math.ceil((h-Date.now())/1e3)});try{return f?await d(a,u):await l(a,s)}catch(b){if(null==Ht(b))throw b;try{const t=f?await l(a,s):await d(a,u);return f?await async function(){await Ar.save(e.props.io.disklet,Or,Qc(Qc({},e.props.state.clientInfo),{},{duressEnabled:!1})),e.props.dispatch({type:"LOGIN_DURESS_MODE_DISABLED"})}():await async function(){await Ar.save(e.props.io.disklet,Or,Qc(Qc({},e.props.state.clientInfo),{},{duressEnabled:!0})),e.props.dispatch({type:"LOGIN_DURESS_MODE_ENABLED"})}(),t}catch(g){var y;const t=[Ht(g),Ht(b)].reduce(((e,t)=>{var n,r;return(null!==(n=null==e?void 0:e.wait)&&void 0!==n?n:0)>(null!==(r=null==t?void 0:t.wait)&&void 0!==r?r:0)?e:t})),n=1e3*(null!==(y=null==t?void 0:t.wait)&&void 0!==y?y:0);if(null!=t&&n>0){const r=Date.now()+n;throw await async function(t,n){await Ar.save(e.props.io.disklet,Or,Qc(Qc({},e.props.state.clientInfo),{},{loginWaitTimestamps:Qc(Qc({},e.props.state.clientInfo.loginWaitTimestamps),{},{[t]:n})})),e.props.dispatch({type:"LOGIN_WAIT_TIMESTAMP_UPDATED",payload:{loginId:t,timestamp:n}})}(p,r),t}if(null!=Yt(g))throw b;throw g}}},async loginWithRecovery2(t,n,r,o={}){e.props.log.breadcrumb("EdgeContext.loginWithRecovery2",{}),n=re(n);const i=On(e,n),a=await async function(e,t,n,r,o){const{username:i}=t;if(null==i)throw new Error("Recovery login requires a username");const a={recovery2Id:ha(n,i),recovery2Auth:ya(n,r)};return await Hn(e,t,t,o,a,(async e=>{if(null==e.recovery2Box||!0===e.recovery2Box)throw new Error("Missing data for recovery v2 login");return un(e.recovery2Box,n)}))}(e,null!=i?i:Sn(n),jt.parse(t),r,o);return await _a(e,a,"recoveryLogin",o)},async fetchRecovery2Questions(t,n){return n=re(n),await async function(e,t,n){const r={recovery2Id:ha(t,n)},o=await gn(e,"POST","/v2/login",r),{question2Box:i}=tt(o);if(null==i)throw new Error("Login has no recovery questions");return ga(JSON.parse(cn(i,t)))}(e,jt.parse(t),n)},async requestEdgeLogin(n){return e.props.log.breadcrumb("EdgeContext.requestEdgeLogin",{}),await Ka(e,t,n)},async requestOtpReset(t,n){return t=re(t),await async function(e,t,n){const r={userId:await kn(e,t),otpResetAuth:n},o=await gn(e,"DELETE","/v2/login/otp",r),{otpResetDate:i}=Qe(o);return i}(e,t,n)},async fetchLoginMessages(){return await async function(e){const{stashes:t}=e.props.state.login,n={},r=[];for(const s of t){const{loginId:e,username:t}=s;null!=t&&(n[y.stringify(e)]=t,r.push(e))}const o={loginIds:r},i=await gn(e,"POST","/v2/messages",o),a=[];for(const s of Xe(i)){const{loginId:e}=s,t=yc(s,Hc),r=y.stringify(e),o=n[r];null!=o&&a.push(Vc(Vc({},t),{},{loginId:r,username:o}))}return a}(e)},get paused(){return e.props.state.paused},async changePaused(t,n={}){const{secondsDelay:r=0}=n;null!=o&&(clearTimeout(o),o=void 0),e.props.state.paused!==t&&(0===r?e.props.dispatch({type:"PAUSE",payload:t}):o=setTimeout((()=>{o=void 0,e.props.dispatch({type:"PAUSE",payload:t})}),1e3*r))},get logSettings(){return e.props.state.logSettings},async changeLogSettings(t){const n=Qc(Qc({},e.props.state.logSettings),t);e.props.dispatch({type:"CHANGE_LOG_SETTINGS",payload:n})}};return _(i),i}const tu=br({api(e){return{destroy(){B(e.props.output.context.api)},update(){return e.onOutput(eu(e)),Ir}}},watcher(e){let t,n,r;return()=>{t===e.props.state.login.localUsers&&n===e.props.state.paused&&r===e.props.state.logSettings||(t=e.props.state.login.localUsers,n=e.props.state.paused,r=e.props.state.logSettings,null!=e.props.output.context.api&&U(e.props.output.context.api))}},infoFetcher:vr((e=>{const t=Hr((async function(){const{dispatch:t,io:n}=e.props,{contextAppId:r,deviceInfo:o}=e.props.state.login,{appVersion:i,osType:a,osVersion:s}=o,[c]=ea(e.props.state.infoServers);let u;if(null!=a&&null!=s&&null!=i){const e=new URLSearchParams;e.set("appId",""!==r?r:"edge"),e.set("os",a),e.set("osVersion",s),e.set("appVersion",i),u=`${c}/v2/coreRollup?${e.toString()}`}else u=`${c}/v1/coreRollup`;const l=await fetch(u,{headers:{accept:"application/json"}});if(!l.ok)return;const d=await l.json(),f=_r(d);t({type:"INFO_CACHE_FETCHED",payload:f}),await kr.save(n.disklet,Tr,f)}),6e5,{onError(t){e.props.onError(t)}});return{update(){t.started||t.start()},destroy(){t.stop()}}}),(e=>e.state.paused?void 0:e))});function nu(e,t){if("object"!=typeof e||"object"!=typeof t||null==e||null==t)return e===t;const n=Array.isArray(e);if(n!==Array.isArray(t))return!1;if(n){if(e.length!==t.length)return!1;for(let n=0;n<e.length;++n)if(!nu(e[n],t[n]))return!1;return!0}const r=Object.getOwnPropertyNames(e).filter((t=>void 0!==e[t])),o=Object.getOwnPropertyNames(t).filter((e=>void 0!==t[e]));if(r.length!==o.length)return!1;for(const i of r){if(!Object.prototype.hasOwnProperty.call(t,i))return!1;if(!nu(e[i],t[i]))return!1}return!0}function ru(e,t,n,r,o,i){const{handleError:a,handleSend:s,localMethods:c}=i,u=ve(n),l=ve(r),d=async(e,t,n=null)=>{const r=l({jsonrpc:"2.0",result:void 0,error:{code:e,message:t,data:void 0},id:n});return await s(JSON.stringify(r))};let f=0;const p=new Map,h=new Map,y={};for(const b of Object.keys(t)){const{asParams:n,asResult:r}=t[b],i=ve(n);y[b]=null==r?e=>{const t=u({jsonrpc:"2.0",method:b,params:i(e)});s(JSON.stringify(t)).catch(a)}:t=>{const n=f++,c=new Promise(((e,t)=>{p.set(n,{asResult:r,resolve:e,reject:t})}));o&&null!=e[b]&&null==e[b].asResult&&h.set(n,b);const l=u({jsonrpc:"2.0",method:b,params:i(t),id:n});return s(JSON.stringify(l)).catch(a),c}}return{handleClose:function(){for(const e of p.values())e.reject(new Error("JSON-RPC connection closed"))},handleMessage:function(t){let o;try{o=JSON.parse(t)}catch(f){return void d(-32700,`Parse error: ${ou(f)}`).catch(a)}const i=ge(n)(o),u=ge(r)(o);if(null!=i){const t=e[i.method];if(null==t)return void d(-32601,`Method not found: ${i.method}`).catch(a);if(null!=t.asResult&&null==i.id)return void d(-32600,"Invalid JSON-RPC request: missing id").catch(a);if(null==t.asResult&&null!=i.id)return void d(-32600,"Invalid JSON-RPC request: notification has an id").catch(a);let n;try{n=t.asParams(i.params)}catch(f){return void d(-32602,`Invalid params: ${ou(f)}`).catch(a)}const r=c[i.method](n);if(null!=t.asResult&&null!=(null==r?void 0:r.then)){const e=ve(t.asResult);r.then((t=>{var n;const r=l({jsonrpc:"2.0",result:e(t),error:void 0,id:null!==(n=i.id)&&void 0!==n?n:null});s(JSON.stringify(r)).catch(a)}),(e=>{d(1,ou(e),i.id).catch(a)}))}}else if(null!=u){const{error:t,id:n,result:r}=u;if("number"!=typeof n)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);const o=p.get(n);if(null==o){const t=h.get(n);if(null==t)return void d(-32603,`Cannot find id ${String(n)}`,n).catch(a);let o;try{o=e[t].asParams(r)}catch(f){return void d(-32602,`Invalid params: ${ou(f)}`).catch(a)}return void c[t](o)}if(p.delete(n),null!=t)o.reject(new Error(t.message));else{const{asResult:e}=o;let t;try{t=e(r)}catch(f){o.reject(f)}o.resolve(t)}}else d(-32600,"Invalid JSON-RPC request / response").catch(a)},remoteMethods:y}}function ou(e){return e instanceof Error?e.message:String(e)}const iu=e=>{if(null===e)return e;if("string"==typeof e)return e;if("number"==typeof e&&Number.isInteger(e))return e;throw new TypeError("Expected a string or an integer")},au=ye({jsonrpc:se("2.0"),method:le,params:fe,id:ae(iu)}),su=ye({jsonrpc:se("2.0"),result:fe,error:ae(ye({code:ue,message:le,data:fe})),id:iu}),cu=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){if(!Array.isArray(e))throw new TypeError("Expected an array, got "+ie(e));for(var n=[],r=0;r<t.length;++r)try{n[r]=t[r](e[r])}catch(o){throw pe(o,"["+r+"]")}return n}}(le,le,ae(le)),uu=se(-1,0,1,2),lu=function(e){const{serverMethods:t,clientMethods:n,asCall:r=au,asReturn:o=su,allowMultipleReturns:i=!1}=e;return{makeServerCodec(e){return ru(t,n,r,o,i,e)},makeClientCodec(e){return ru(n,t,r,o,i,e)}}}({serverMethods:{subscribe:{asParams:he(cu),asResult:he(uu)},unsubscribe:{asParams:he(cu),asResult:se(void 0)}},clientMethods:{update:{asParams:cu},subLost:{asParams:cu}}});function du(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?du(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):du(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const pu=br({wallets:mr(dc,(e=>e.state.currency.currencyWalletIds),((e,t)=>fu(fu({},e),{},{walletId:t,walletState:e.state.currency.wallets[t],walletOutput:e.output.currency.wallets[t]}))),pluginUpdater(e){let t;return async()=>{const{infoCache:n,plugins:r}=e.props.state;if(t!==n){if(null!=t)for(const e of Object.keys(r.currency)){var o,i,a,s;const c=r.currency[e],u=null!==(o=null===(i=n.corePlugins)||void 0===i?void 0:i[e])&&void 0!==o?o:{},l=null!==(a=null===(s=t.corePlugins)||void 0===s?void 0:s[e])&&void 0!==a?a:{};null==c.updateInfoPayload||nu(l,u)||await c.updateInfoPayload(u)}t=n}}},changeServiceManager(e){let t,n;return{async update(){var r,o;const{wallets:i}=e.props.state.currency;if(i===t)return;t=i;let{changeService:a,changeServiceConnected:s=!1}=null!==(r=e.props.output.currency.changeServiceManager)&&void 0!==r?r:{};const c=Object.entries(i).filter((([,e])=>e.changeServiceSubscriptions.some((e=>"avoiding"!==e.status))));if(null==a&&c.length>0){const t=e.props.state.changeServers[0];a=function(e,t){let n,r,o=!1;!function s(){n=new WebSocket(e),n.binaryType="arraybuffer",n.addEventListener("message",(e=>{i.handleMessage(e.data)})),n.addEventListener("close",(()=>{a.connected=!1,i.handleClose(),t.handleDisconnect(),r=setTimeout((()=>{o||s()}),5e3)})),n.addEventListener("error",(e=>{console.error("changeServer websocket error:",e),n.close()})),n.addEventListener("open",(()=>{a.connected=!0,t.handleConnect()}))}();const i=lu.makeClientCodec({handleError(e){console.error("changeServer error:",e),n.close()},async handleSend(e){n.send(e)},localMethods:{update(e){t.handleChange(e)},subLost(e){t.handleSubLost(e)}}}),a={async subscribe(e){return await i.remoteMethods.subscribe(e)},async unsubscribe(e){await i.remoteMethods.unsubscribe(e)},close(){o=!0,null!=r&&(clearTimeout(r),r=void 0),n.close()},connected:!1};return a}(t,{handleChange([t,n,r]){const o=Object.entries(e.props.state.currency.wallets).filter((([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some((e=>e.address===n))));for(const[i,a]of o){const t=a.changeServiceSubscriptions.filter((e=>e.address===n&&"listening"===e.status)).map((e=>fu(fu({},e),{},{status:"syncing",checkpoint:r})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:i,subscriptions:t}})}},handleConnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter((e=>"reconnecting"===e.status)).map((e=>fu(fu({},e),{},{status:"subscribing"})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!0})},handleDisconnect(){const t=Object.entries(e.props.state.currency.wallets);for(const[n,r]of t){const t=r.changeServiceSubscriptions.filter((e=>"avoiding"!==e.status)).map((e=>fu(fu({},e),{},{status:"reconnecting"})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:t}})}e.onOutput({changeService:a,changeServiceConnected:!1})},handleSubLost([t,n]){const r=Object.entries(e.props.state.currency.wallets).filter((([,e])=>e.currencyInfo.pluginId===t&&e.changeServiceSubscriptions.some((e=>e.address===n))&&e.changeServiceSubscriptions.some((e=>"avoiding"!==e.status))));for(const[o,i]of r){const t=i.changeServiceSubscriptions.filter((e=>"avoiding"!==e.status)).map((e=>fu(fu({},e),{},{status:"subscribing"})));e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:o,subscriptions:t}})}}}),e.onOutput({changeService:a,changeServiceConnected:!1})}if(null!=a&&0===c.length&&(a.close(),a=void 0,e.onOutput({changeService:a,changeServiceConnected:!1})),!0===(null===(o=a)||void 0===o?void 0:o.connected)&&s){const t=c.filter((([,e])=>e.changeServiceSubscriptions.some((e=>"subscribing"===e.status||"resubscribing"===e.status)))),r=[],o=[];for(const[e,n]of t){if(n.paused)continue;const t=n.changeServiceSubscriptions.map((e=>[n.currencyInfo.pluginId,e.address,e.checkpoint]));if(0===t.length)continue;let i=o[o.length-1];(null==i||i.length+t.length>100)&&(o.push([]),i=o[o.length-1]),i.push(...t);for(let o=0;o<t.length;o++)r[r.length]={walletId:e,wallet:n}}n=setTimeout((()=>{n=void 0;const t=new Set(r.map((e=>e.walletId)));for(const n of t){const t=e.props.state.currency.wallets[n];if(null==t)continue;const r=t.changeServiceSubscriptions.filter((e=>"subscribing"===e.status)).map((e=>fu(fu({},e),{},{status:"subscribingSlowly"})));r.length>0&&e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:r}})}}),15e3);const i=[];try{for(const t of o){const n=await a.subscribe(t).catch((n=>(e.props.log(`Failed to subscribe: ${String(n)}`),t.map((()=>0)))));i.push(...n)}}finally{clearTimeout(n),n=void 0}const s=new Map;for(let n=0;n<i.length;n++){const t=i[n],{walletId:o}=r[n],a=e.props.state.currency.wallets[o];if(null==a)continue;let c;switch(t){case-1:c="avoiding";break;case 0:c="resubscribing";break;case 1:c="synced";break;case 2:c="syncing"}const u=a.changeServiceSubscriptions.filter((e=>"subscribing"===e.status||"subscribingSlowly"===e.status||"resubscribing"===e.status)).map((e=>fu(fu({},e),{},{status:c})));s.set(o,u)}const u=Array.from(s.entries());for(const[n,a]of u)e.props.dispatch({type:"CURRENCY_ENGINE_UPDATE_CHANGE_SERVICE_SUBSCRIPTIONS",payload:{walletId:n,subscriptions:a}})}},destroy(){null!=n&&clearTimeout(n)}}}});const hu=br({makeSnrp:e=>()=>{const{io:t,log:n}=e.props;let r;return e.onOutput((async function(o){null==r&&(r=e.props.output.scrypt.timeScrypt(Dt.parse("1reallyJunkiePasswordToCheck"),{salt_hex:p.parse("b5865ffb9fa7b3bfe4b2384d47ce831ee22a4a9d5c34c7ef7d21467cc758f81b"),n:16384,r:8,p:1}).then((e=>e.time)));const i=await r,a=function(e,t,n){const r={salt_hex:e,n:16384,r:8,p:1};if(0===t)return r.n=131072,r.r=8,r.p=64,r;let o=t;const i=t/8;let a=(n-o)/i;a=a>0?a:0,a>0&&(a=0),a=Math.floor(a),r.r=8+a,o+=a*i;let s=14,c=(n-o)/o;c=c>0?c:0,c>3&&(c=3),c=Math.floor(c),s+=c>=0?c:0,o+=c*o,r.n=Math.pow(2,s);let u=(n-o)/o;return u=u>0?u:0,u>64&&(u=64),u=Math.floor(u),r.p=u>=1?u:1,o+=u*o,r}(t.random(32),i,o);return n(`snrp for ${o}ms target: ${a.n} ${a.r} ${a.p} based on ${i}ms benchmark`),a})),Ir},timeScrypt:e=>()=>{const{io:t,log:n}=e.props,r="undefined"!=typeof window&&null!=window.performance&&"function"==typeof window.performance.now?()=>window.performance.now():()=>Date.now();return e.onOutput(function(e){let t=Promise.resolve();return function(...n){const r=()=>e.apply(this,n),o=t.then(r,r);return t=o,o}}((function(e,o,i=32){const a=o.salt_hex,s=r();return n(`starting scrypt n=${o.n} r=${o.r} p=${o.p}`),t.scrypt(e,a,o.n,o.r,o.p,i).then((e=>{const t=r()-s;return n(`finished scrypt n=${o.n} r=${o.r} p=${o.p} in ${t}ms`),{hash:e,time:t}}))}))),Ir}}),yu=e=>e,bu=br({accounts:$c,context:tu,currency:pu,scrypt:hu}),gu=As({currencyWalletIds(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].activeWalletIds}const r=[];for(const o of n.accountIds)r.push(...n.accounts[o].activeWalletIds);return r},wallets:Ms(Ks,(e=>e.currency.currencyWalletIds))}),wu=As({apiKey(e="",t){return"INIT"===t.type?t.payload.apiKey:e},apiSecret(e=null,t){var n;return"INIT"===t.type?null!==(n=t.payload.apiSecret)&&void 0!==n?n:null:e},contextAppId(e="",t){return"INIT"===t.type?t.payload.appId:e},deviceInfo(e={},t){if("INIT"===t.type){const{appVersion:e,deviceDescription:n,osType:r,osVersion:o}=t.payload;return{deviceDescription:null!=n?n:void 0,osType:r,osVersion:o,appVersion:e}}return e},localUsers:Cs((e=>e.login.contextAppId),(e=>e.login.stashes),(e=>e.clientInfo),((e,t,n)=>t.map((function(t){const{lastLogin:r,loginId:o,recovery2Key:i,username:a}=t,s=Un(t,(t=>t.appId===e)),c=null!=s&&(null!=s.passwordAuthBox||null!=s.loginAuthBox),u=n.duressEnabled?Nn(t,e):void 0,l=null!=(null==u?void 0:u.pin2Key)&&!0===(null==u?void 0:u.fakePinDisabled),d=sa(t,e),f=!l&&null!=(null==d?void 0:d.pin2Key);return{keyLoginEnabled:c,lastLogin:r,loginId:jt.stringify(o),pinLoginEnabled:f,recovery2Key:null!=i?jt.stringify(i):void 0,username:a,voucherId:null!=s?s.voucherId:void 0}})))),loginServers(e=[],t){return"INIT"===t.type?t.payload.loginServers:e},stashes(e=[],t){switch(t.type){case"INIT":return t.payload.stashes;case"LOGIN_STASH_DELETED":{const n=t.payload;return e.filter((e=>!an(e.loginId,n)))}case"LOGIN_STASH_SAVED":{const n=t.payload,r=e.filter((e=>!an(e.loginId,n.loginId)));return r.unshift(n),r}}return e},walletInfos(e,t,n){if(1===n.accountIds.length){const e=n.accountIds[0];return n.accounts[e].walletInfos}const r={};for(const o of n.accountIds){const e=n.accounts[o];for(const t of Object.keys(e.walletInfos)){const n=e.walletInfos[t];r[t]=n}}return r}});function vu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function mu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?vu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):vu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Iu={init:{},locked:!1,currency:{},swap:{},currencyTools:{}};function Eu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Su(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Eu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Eu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Ou=function(e){for(var t=Object.keys(e),n={},r=0;r<t.length;r++){var o=t[r];0,"function"==typeof e[o]&&(n[o]=e[o])}var i,a=Object.keys(n);try{!function(e){Object.keys(e).forEach((function(t){var n=e[t];if(void 0===n(void 0,{type:or.INIT}))throw new Error(tr(12));if(void 0===n(void 0,{type:or.PROBE_UNKNOWN_ACTION()}))throw new Error(tr(13))}))}(n)}catch(s){i=s}return function(e,t){if(void 0===e&&(e={}),i)throw i;for(var r=!1,o={},s=0;s<a.length;s++){var c=a[s],u=n[c],l=e[c],d=u(l,t);if(void 0===d){t&&t.type;throw new Error(tr(14))}o[c]=d,r=r||d!==l}return(r=r||a.length!==Object.keys(e).length)?o:e}}({lastChanges(e=[],t){if("STORAGE_WALLET_SYNCED"===t.type){const{changes:n}=t.payload;return n.length>0?n:e}return e},localDisklet(e=null){return e},paths(e=null){return e},status(e={lastSync:0,lastHash:void 0},t){return"STORAGE_WALLET_SYNCED"===t.type?t.payload.status:e}});function Au(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Tu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Au(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Au(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const _u={sources:{},defaultLogLevel:"warn"},ku={clientId:new Uint8Array(0),duressEnabled:!1,loginWaitTimestamps:{}},xu=As({accountCount(e=0,t){return"LOGIN"===t.type?e+1:e},accountIds(e=[],t,n){switch(t.type){case"LOGIN":return[...e,n.lastAccountId];case"LOGOUT":{const{accountId:n}=t.payload,r=e.filter((e=>e!==n));if(r.length===e.length)throw new Error(`Login ${n} does not exist`);return r}case"CLOSE":return[]}return e},accounts:Ms(Wc,(e=>e.accountIds)),changeServers(e=[],t){return"INIT"===t.type?t.payload.changeServers:e},clientInfo(e=ku,t){switch(t.type){case"INIT":return t.payload.clientInfo;case"LOGIN_DURESS_MODE_DISABLED":return Tu(Tu({},e),{},{duressEnabled:!1});case"LOGIN_DURESS_MODE_ENABLED":return Tu(Tu({},e),{},{duressEnabled:!0});case"LOGIN_WAIT_TIMESTAMP_UPDATED":return Tu(Tu({},e),{},{loginWaitTimestamps:Tu(Tu({},e.loginWaitTimestamps),{},{[t.payload.loginId]:t.payload.timestamp})})}return e},hideKeys(e=!0,t){return"INIT"===t.type?t.payload.hideKeys:e},infoCache(e={},t){switch(t.type){case"INIT":return t.payload.infoCache;case"INFO_CACHE_FETCHED":return t.payload}return e},infoServers(e=[],t){return"INIT"===t.type?t.payload.infoServers:e},lastAccountId(e,t,n){return`login${n.accountCount}`},logSettings(e=_u,t){switch(t.type){case"INIT":return t.payload.logSettings;case"CHANGE_LOG_SETTINGS":return t.payload}return e},paused(e=!1,t){return"PAUSE"===t.type?t.payload:e},ready(e=!1,t){return"INIT"===t.type||e},skipBlockHeight(e=!1,t){return"INIT"===t.type?t.payload.skipBlockHeight:e},syncServers(e=[],t){return"INIT"===t.type?t.payload.syncServers:e},currency:gu,login:wu,plugins:(e=Iu,t)=>{switch(t.type){case"CORE_PLUGINS_ADDED":{const n=mu(mu({},e),{},{currency:mu({},e.currency),swap:mu({},e.swap)});for(const e of Object.keys(t.payload)){const r=t.payload[e];null!=r?("currencyInfo"in r&&(null==r.currencyInfo.chainDisplayName&&(r.currencyInfo.chainDisplayName=r.currencyInfo.displayName),null==r.currencyInfo.assetDisplayName&&(r.currencyInfo.assetDisplayName=r.currencyInfo.displayName),n.currency[e]=r),"swapInfo"in r&&(n.swap[e]=r)):n.init=mu(mu({},n.init),{},{[e]:!1})}return n}case"CORE_PLUGINS_LOCKED":return mu(mu({},e),{},{locked:!0});case"CURRENCY_TOOLS_LOADED":{const n=mu({},e.currencyTools);return n[t.payload.pluginId]=t.payload.tools,mu(mu({},e),{},{currencyTools:n})}case"INIT":return mu(mu({},e),{},{init:t.payload.pluginsInit})}return e},storageWallets:function(e={},t){switch(t.type){case"STORAGE_WALLET_ADDED":{const{id:n,initialState:r}=t.payload,o=Su({},e);return o[n]=Ou(r,{type:"UPDATE_NEXT"}),o}case"STORAGE_WALLET_SYNCED":{const{id:n}=t.payload;if(null!=e[n]){const r=Su({},e);return r[n]=Ou(e[n],t),r}return e}}return e}});function Pu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Mu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Pu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}let Cu=[];const Nu="object"==typeof window&&null!=window.__REDUX_DEVTOOLS_EXTENSION__?window.__REDUX_DEVTOOLS_EXTENSION__({name:"core"}):void 0;async function ju(e,t,n){const{io:r}=e,{airbitzSupport:o=!1,apiSecret:i,appId:a="",appVersion:s,authServer:c,deviceDescription:u=null,changeServer:l,hideKeys:d=!1,infoServer:f,loginServer:p,osType:h,osVersion:y,plugins:b={},skipBlockHeight:g=!1,syncServer:w}=n;let{apiKey:v}=n;null!=v&&""!==v||(v="4248c1bf41e53b840a5fdb2c872dd3ade525e66d");const m=Du(c,["https://login1.edge.app","https://login2.edge.app"]),I=Du(l,["wss://change1.edge.app","wss://change2.edge.app"]),E=Du(f,["https://info1.edge.app","https://info2.edge.app"]),S=Du(p,m.map((e=>e.replace(/\/api$/,"")))),O=Du(w,["https://sync-us1.edge.app","https://sync-us2.edge.app","https://sync-us3.edge.app","https://sync-us4.edge.app","https://sync-us5.edge.app","https://sync-us6.edge.app","https://sync-eu.edge.app"]),A=Mu(Mu({},_u),n.logSettings);I.map((e=>Rt(e))),E.map((e=>Rt(e))),S.map((e=>Rt(e))),O.map((e=>Rt(e)));const T=ar(xu,Nu);var _,k;k=()=>{const e=T.getState();return e.ready?e.logSettings:A};const x=Cr(t=Pr(Pr({},_=t),{},{onLog:function(e){const{sources:t,defaultLogLevel:n}=k(),r=null!=t[e.source]?t[e.source]:n;switch(e.type){case"info":"info"===r&&_.onLog(e);break;case"warn":"info"!==r&&"warn"!==r||_.onLog(e);break;case"error":"silent"!==r&&_.onLog(e)}}}),"edge-core");let[P,M={},C]=await Promise.all([Ar.load(r.disklet,Or),kr.load(r.disklet,Tr),xn(r.disklet,x)]);if(o){const e=new Set;for(const{username:n}of C)null!=n&&e.add(n);const t=await async function(e,t){const n=[],r=await e.disklet.list("Accounts").then(ee.ji);for(const o of r){const r=(0,ee.HN)(e.disklet,o),[i,a,s,c,u,l]=await Promise.all([await jr.load(r,"CarePackage.json"),await Dr.load(r,"LoginPackage.json"),await Rr.load(r,"OtpKey.json"),await Lr.load(r,"Pin2Key.json"),await Br.load(r,"Recovery2Key.json"),await Kr.load(r,"UserName.json")]);if(null==l)continue;const d=re(l.userName);if(t.has(d))continue;const f={appId:"",loginId:await e.scrypt(Dt.parse(d),En.salt_hex,En.n,En.r,En.p,32),pendingVouchers:[],username:d};null!=i&&null!=a&&(f.passwordKeySnrp=i.SNRP2,f.passwordBox=a.EMK_LP2,f.syncKeyBox=a.ESyncKey,f.passwordAuthBox=a.ELP1),null!=s&&(f.otpKey=s.TOTP),null!=c&&(f.pin2Key=c.pin2Key),null!=u&&(f.recovery2Key=u.recovery2Key),n.push(f)}return n}(r,e);C.push(...t)}null==P&&(P={clientId:r.random(16),duressEnabled:!1,loginWaitTimestamps:{}},await Ar.save(r.disklet,Or,P)),T.dispatch({type:"INIT",payload:{apiKey:v,apiSecret:i,appId:a,appVersion:s,osType:h,osVersion:y,changeServers:I,loginServers:S,infoCache:M,infoServers:E,syncServers:O,clientInfo:P,deviceDescription:u,hideKeys:d,logSettings:A,pluginsInit:b,skipBlockHeight:g,stashes:C}});const N=function(e,t,n,r,o){const{io:i,nativeIo:a}=e,s=Fr(Fr({},i),{},{console:console});function c(e){const c={};for(const o of Object.keys(e)){const f=e[o],p=Cr(n,o),h=r[o];if(!1!==h&&null!=h)try{if("function"==typeof f){var u,l;const e={infoPayload:null!==(u=null===(l=t.corePlugins)||void 0===l?void 0:l[o])&&void 0!==u?u:{},initOptions:"object"==typeof h?h:{},io:s,log:p,nativeIo:a,pluginDisklet:(0,ee.HN)(i.disklet,"plugins/"+o)};c[o]=f(e)}else{if("object"!=typeof f||null==f)throw new TypeError("Plugins must be functions or objects, got "+typeof f);c[o]=f}}catch(d){p.error(d)}}o({type:"CORE_PLUGINS_ADDED",payload:c})}function u(){o({type:"CORE_PLUGINS_LOCKED",payload:r})}return c(Wr),qr&&u(),zr.push(c),Gr.push(u),()=>{zr.filter((e=>e!==c)),Gr.filter((e=>e!==u))}}(e,M,t,b,T.dispatch),j=er({log:x,fetch:(e,t)=>r.fetch(e,Mu(Mu({},t),{},{corsBypass:"never"})),edgeServers:{infoServers:E,syncServers:O}}),D={output:{}},R=function(e,t,n,r){var o=yr(t,n,r);o.update({dispatch:e.dispatch,output:void 0,state:e.getState()});var i=e.subscribe((function(){o.update({dispatch:e.dispatch,output:void 0,state:e.getState()})}));return function(){i(),o.destroy()}}(T,vr(bu,(e=>Mu(Mu({},e),{},{close(){R(),N(),T.dispatch({type:"CLOSE"})},io:r,log:x,logBackend:t,onError:e=>{var t;null!=(null===(t=D.output.context)||void 0===t?void 0:t.api)&&K(D.output.context.api,"error",e)},syncClient:j}))),(e=>x.error(e)),(e=>D.output=e)),L=D.output.context.api;return Cu.push(L),L}function Du(e,t){return"string"==typeof e?[e]:null!=e&&e.length>0?e:t}const Ru=["children"];function Lu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Bu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Lu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Lu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}class Ku{constructor(){this.lobbies=new Map,this.logins=[],this.repos=new Map}getLoginById(e){return this.logins.find((t=>an(t.loginId,e)))}getLoginByUserId(e){return this.logins.find((t=>null==t.userId?an(t.loginId,e):an(t.userId,e)))}getLoginByPin2Id(e){return this.logins.find((t=>null!=t.pin2Id&&an(t.pin2Id,e)))}getLoginByRecovery2Id(e){return this.logins.find((t=>null!=t.recovery2Id&&an(t.recovery2Id,e)))}getLoginsByParent(e){return this.logins.filter((t=>t.parentId===e.loginId))}insertLogin(e){this.logins.push(e)}setupLogin(e){const{children:t}=e,n=yc(e,Ru);this.insertLogin(n);for(const r of t)r.parentId=e.loginId,this.setupLogin(r)}setupRepo(e,t){this.repos.set(e,t)}dumpLogin(e){const t=e=>Bu(Bu({},e),{},{children:this.getLoginsByParent(e).map((e=>t(e)))});return t(e)}}function Uu(e,t){const n=e.getLoginsByParent(t).map((t=>Uu(e,t)));return{appId:t.appId,created:t.created,loginId:t.loginId,children:n,parentBox:t.parentBox,passwordAuthBox:t.passwordAuthBox,passwordAuthSnrp:t.passwordAuthSnrp,passwordBox:t.passwordBox,passwordKeySnrp:t.passwordKeySnrp,pin2Box:t.pin2Box,pin2KeyBox:t.pin2KeyBox,pin2TextBox:t.pin2TextBox,question2Box:t.question2Box,recovery2Box:t.recovery2Box,recovery2KeyBox:t.recovery2KeyBox,otpKey:t.otpKey,otpResetDate:t.otpResetDate,otpTimeout:t.otpTimeout,pendingVouchers:Fu(t),loginAuthBox:t.loginAuthBox,userId:t.userId,userTextBox:t.userTextBox,keyBoxes:t.keyBoxes,mnemonicBox:t.mnemonicBox,rootKeyBox:t.rootKeyBox,syncKeyBox:t.syncKeyBox}}function Fu(e){return e.vouchers.filter((e=>"pending"===e.status)).map((e=>({activates:e.activates,created:e.created,deviceDescription:e.deviceDescription,ip:e.ip,ipDescription:e.ipDescription,voucherId:e.voucherId})))}function Wu(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function qu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Wu(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wu(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const zu={success:{code:0,httpStatus:200,message:"Success"},error:{code:1,httpStatus:503,message:"Error"},accountExists:{code:2,httpStatus:401,message:"Account already exists"},noAccount:{code:3,httpStatus:401,message:"No account"},invalidPassword:{code:4,httpStatus:401,message:"Invalid Password"},invalidAnswers:{code:5,httpStatus:401,message:"Invalid Answers"},invalidApiKey:{code:6,httpStatus:401,message:"Invalid API Key"},invalidOtp:{code:8,httpStatus:401,message:"Invalid OTP"},conflict:{code:10,httpStatus:409,message:"Conflicting change"},obsolete:{code:1e3,httpStatus:410,message:"Obsolete API"},created:{code:0,httpStatus:201,message:"Account created"},invalidRequest:{code:1,httpStatus:401,message:"Invalid request"},notFound:{code:1,httpStatus:404,message:"Not found"},noLobby:{code:3,httpStatus:404,message:"Not found"},invalidAppId:{code:10,httpStatus:401,message:"A login with the same appId already exists"}};function Gu(e,t){try{return[e(t),{status:200}]}catch(n){return[void 0,Hu(zu.invalidRequest,`Invalid request: ${String(n)}`)]}}function $u(e,t={}){const{status:n=200,headers:r={}}=t;return{status:n,headers:qu({"content-type":"application/json"},r),body:JSON.stringify(e)}}function Hu(e=zu.success,t=e.message){const{code:n,httpStatus:r}=e;return $u(st({status_code:n,message:t}),{status:r})}function Yu(e,t=zu.success,n=t.message){const{code:r,httpStatus:o}=t;return $u(st({status_code:r,message:n,results:e}),{status:o})}function Vu(e){return Yu(Ot({wait_seconds:e}),zu.invalidPassword)}function Ju(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function Xu(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?Ju(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ju(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const Zu=e=>async t=>{const{json:n}=t,[r,o]=Gu(Ne,n);return null==r?o:await e(Xu(Xu({},t),{},{body:r,payload:r.data}))},Qu=e=>async t=>{const{body:n,login:r}=t,{otp:o,voucherAuth:i,voucherId:a}=n,{otpKey:s}=r;if(null==s)return await e(t);if(null!=o&&function(e,t,n={}){const{now:r=Date.now()/1e3,spread:o=1}=n,i=r/30;if(t===fn(e,i,6))return!0;for(let a=1;a<=o;++a){if(t===fn(e,i-a,6))return!0;if(t===fn(e,i+a,6))return!0}return!1}(s,o,{spread:2}))return await e(t);if(null!=i&&null!=a){const n=r.vouchers.find((e=>e.voucherId===a));if(null!=n&&"approved"===n.status&&an(i,n.voucherAuth))return await e(t)}r.otpResetAuth="Super secret reset token";const c={activates:new Date("2020-01-01T00:00:00Z"),created:new Date("2020-01-08T00:00:00Z"),deviceDescription:"A phone",ip:"localhost",ipDescription:"here",loginId:r.loginId,status:"pending",voucherAuth:Uint8Array.from([170,187]),voucherId:`voucher-${r.vouchers.length}`};return r.vouchers.push(c),function(e,t={}){const{reason:n="otp",voucher:r}=t;return Yu(Et({login_id:e.loginId,otp_reset_auth:e.otpResetAuth,otp_timeout_date:e.otpResetDate,reason:n,voucher_auth:null==r?void 0:r.voucherAuth,voucher_activates:null==r?void 0:r.activates,voucher_id:null==r?void 0:r.voucherId}),zu.invalidOtp)}(r,{voucher:c})},el=e=>Hu(zu.invalidRequest),tl=(e,t=el)=>n=>{const{db:r,body:o}=n,{loginAuth:i,loginId:a,passwordAuth:s,pin2Auth:c,pin2Id:u,recovery2Auth:l,recovery2Id:d,userId:f}=o;if(null!=a&&null!=i){const t=r.getLoginById(a);return null==t?Hu(zu.noAccount):null!=t.loginAuth&&an(i,t.loginAuth)?Qu(e)(Xu(Xu({},n),{},{login:t})):Vu(0)}if(null!=f&&null!=s){const t=r.getLoginByUserId(f);return null==t?Hu(zu.noAccount):null!=t.passwordAuth&&an(s,t.passwordAuth)?Qu(e)(Xu(Xu({},n),{},{login:t})):Vu(0)}if(null!=u&&null!=c){const t=r.getLoginByPin2Id(u);return null==t?Hu(zu.noAccount):null!=t.pin2Auth&&an(c,t.pin2Auth)?Qu(e)(Xu(Xu({},n),{},{login:t})):Vu(0)}if(null!=d&&null!=l){const t=r.getLoginByRecovery2Id(d);if(null==t)return Hu(zu.noAccount);const o=t.recovery2Auth,i=l;if(null==o||i.length!==o.length)return Vu(0);for(let e=0;e<i.length;++e)if(!an(i[e],o[e]))return Vu(0);return Qu(e)(Xu(Xu({},n),{},{login:t}))}return t(n)},nl=tl((e=>{const{db:t,login:n}=e;return Yu(mt(Uu(t,n)))}),(e=>{const{db:t,json:n}=e,r=Ne(n),{userId:o,passwordAuth:i,recovery2Id:a,recovery2Auth:s}=r;if(null!=o&&null==i){const e=t.getLoginByUserId(o);if(null==e)return Hu(zu.noAccount);const{loginId:n,passwordAuthSnrp:r=En}=e;return Yu(Tt({loginId:n,passwordAuthSnrp:r}))}if(null!=a&&null==s){const e=t.getLoginByRecovery2Id(a);if(null==e)return Hu(zu.noAccount);const{question2Box:n}=e;return null==n?Hu(zu.noAccount):Yu(At({question2Box:n}))}return Hu(zu.invalidRequest)}));function rl(e,t){const{db:n,json:r}=e,o=new Date,[i,a]=Gu(Ne,r);if(null==i)return a;const[s,c]=Gu(Ge,i.data);if(null==s)return c;const[u,l]=Gu(Fe,i.data);if(null==u)return l;if(null!=n.getLoginById(s.loginId))return Hu(zu.accountExists);const d=ge(ze,(()=>({allowExisting:!1,newSyncKeys:[],keyBoxes:[]})))(i.data);for(const p of d.newSyncKeys)n.repos.set(p,{});const f=Xu(Xu(Xu(Xu(Xu(Xu(Xu({},s),u),{},{created:o,keyBoxes:d.keyBoxes.map((e=>Xu(Xu({},e),{},{created:o}))),vouchers:[]},ge(De)(i.data)),ge(Re)(i.data)),ge(Be)(i.data)),ge(Ue)(i.data)),ge(We)(i.data));if(null!=t){if(null!=n.getLoginsByParent(t).find((e=>e.appId===s.appId)))return Hu(zu.invalidAppId);f.parentId=t.loginId}return n.insertLogin(f),Hu(zu.created,"Account created")}const ol=tl((e=>rl(e,e.login)),(e=>rl(e))),il=tl((e=>{const{db:t,login:n,payload:r}=e,o=new Date,[i,a]=Gu(ze,r);if(null==i)return a;for(const s of i.newSyncKeys)t.repos.set(s,{});return n.keyBoxes=hn(n.keyBoxes,i.keyBoxes.map((e=>Xu(Xu({},e),{},{created:o})))),Hu()})),al=tl((e=>{const{login:t,payload:n}=e,[r,o]=Gu(De,n);return null==r?o:(t.otpKey=r.otpKey,t.otpTimeout=r.otpTimeout,t.otpResetDate=void 0,Hu())})),sl=tl((e=>{const{login:t}=e;return t.otpKey=void 0,t.otpResetAuth=void 0,t.otpResetDate=void 0,t.otpTimeout=void 0,Hu()}),(e=>{const{db:t,json:n}=e,r=Ne(n);if(null==r.userId||null==r.otpResetAuth)return Hu(zu.invalidRequest);const o=t.getLoginByUserId(r.userId);if(null==o)return Hu(zu.noAccount);if(r.otpResetAuth!==o.otpResetAuth)return Vu(0);const{otpKey:i,otpTimeout:a}=o;return null==i||null==a?Hu(zu.invalidRequest,"OTP not setup for this account."):(null==o.otpResetDate&&(o.otpResetDate=new Date(Date.now()+1e3*a)),Yu(St({otpResetDate:o.otpResetDate})))})),cl=tl((e=>{const{login:t}=e;return t.passwordAuth=void 0,t.passwordAuthBox=void 0,t.passwordAuthSnrp=void 0,t.passwordBox=void 0,t.passwordKeySnrp=void 0,Hu()})),ul=tl((e=>{const{login:t,payload:n}=e,[r,o]=Gu(Re,n);return null==r?o:(t.passwordAuth=r.passwordAuth,t.passwordAuthBox=r.passwordAuthBox,t.passwordAuthSnrp=r.passwordAuthSnrp,t.passwordBox=r.passwordBox,t.passwordKeySnrp=r.passwordKeySnrp,Hu())})),ll=tl((e=>{const{login:t}=e;return t.pin2Auth=void 0,t.pin2Box=void 0,t.pin2Id=void 0,t.pin2KeyBox=void 0,t.pin2TextBox=void 0,Hu()})),dl=tl((e=>{const{login:t,payload:n}=e,[r,o]=Gu(Be,n);return null==r?o:(t.pin2Auth=r.pin2Auth,t.pin2Box=r.pin2Box,t.pin2Id=r.pin2Id,t.pin2KeyBox=r.pin2KeyBox,t.pin2TextBox=r.pin2TextBox,Hu())})),fl=tl((e=>{const{login:t}=e;return t.question2Box=void 0,t.recovery2Auth=void 0,t.recovery2Box=void 0,t.recovery2Id=void 0,t.recovery2KeyBox=void 0,Hu()})),pl=tl((e=>{const{login:t,payload:n}=e,[r,o]=Gu(Ue,n);return null==r?o:(t.question2Box=r.question2Box,t.recovery2Auth=r.recovery2Auth,t.recovery2Box=r.recovery2Box,t.recovery2Id=r.recovery2Id,t.recovery2KeyBox=r.recovery2KeyBox,Hu())})),hl=tl((e=>{const{db:t,login:n,payload:r}=e,[o,i]=Gu(Fe,r);return null==o?i:null!=n.loginAuth?Hu(zu.conflict,"The secret-key login is already configured"):(n.loginAuth=o.loginAuth,n.loginAuthBox=o.loginAuthBox,Yu(mt(Uu(t,n))))})),yl=tl((async e=>{const{db:t,login:n,payload:r}=e,o=ge(Re)(r),i=ge(Le)(r),a=ge(Ke)(r),s=ge(We)(r);if(null!=n.passwordAuth&&null==o)return Hu(zu.invalidRequest,"Missing password payload");if(null!=n.pin2Auth&&null==i)return Hu(zu.invalidRequest,"Missing pin2Id payload");if(null!=n.recovery2Auth&&null==a)return Hu(zu.invalidRequest,"Missing recovery2Id payload");if(null==n.parentBox&&null==s)return Hu(zu.invalidRequest,"Missing username payload");if(null!=o&&(n.passwordAuth=o.passwordAuth,n.passwordAuthBox=o.passwordAuthBox,n.passwordAuthSnrp=o.passwordAuthSnrp,n.passwordBox=o.passwordBox,n.passwordKeySnrp=o.passwordKeySnrp),null!=i){if(null==n.pin2Auth)return Hu(zu.invalidRequest,"Login lacks pin2");if(null!=t.getLoginByPin2Id(i.pin2Id))return Hu(zu.conflict);n.pin2Id=i.pin2Id}if(null!=a){if(null==n.recovery2Auth)return Hu(zu.invalidRequest,"Login lacks recovery2");if(null!=t.getLoginByRecovery2Id(a.recovery2Id))return Hu(zu.conflict);n.recovery2Id=a.recovery2Id}if(null!=s){if(null!=n.parentBox)return Hu(zu.invalidRequest,"Only top-level logins can have usernames");if(null!=t.getLoginByUserId(s.userId))return Hu(zu.conflict);n.userId=s.userId,n.userTextBox=s.userTextBox}return Yu(mt(Uu(t,n)))})),bl=tl((async e=>{const{db:t,login:n,payload:r}=e,[o,i]=Gu(qe,r);if(null==o)return i;const{approvedVouchers:a=[],rejectedVouchers:s=[]}=o,c={};for(const u of a)c[u]="approved";for(const u of s)c[u]="rejected";for(const u of n.vouchers)null!=c[u.voucherId]&&(u.status=c[u.voucherId]);return Yu(mt(Uu(t,n)))})),gl=e=>Hu(zu.noLobby,`Cannot find lobby ${e.lobbyId}`),wl=(e,t=gl)=>n=>{const{db:r,path:o}=n,i=o.split("/")[4],a=r.lobbies.get(i);return null!=a?e(Xu(Xu({},n),{},{lobby:a,lobbyId:i})):t(Xu(Xu({},n),{},{lobbyId:i}))},vl=wl((e=>Hu(zu.accountExists,`Lobby ${e.lobbyId} already exists.`)),(e=>{const{db:t,json:n,lobbyId:r}=e,[o,i]=Gu(Ne,n);if(null==o)return i;const[a,s]=Gu(Pe,o.data);if(null==a)return s;const{timeout:c=600}=a,u=new Date(Date.now()+1e3*c).toISOString();return t.lobbies.set(r,{request:a,replies:[],expires:u}),Hu()})),ml=wl((e=>{const{json:t,lobby:n}=e,[r,o]=Gu(Ne,t);if(null==r)return o;const[i,a]=Gu(Me,r.data);return null==i?a:(n.replies.push(i),Hu())})),Il=wl((e=>{const{lobby:t}=e;return Yu(vt(t))})),El=wl((e=>{const{db:t,lobbyId:n}=e;return t.lobbies.delete(n),Hu()})),Sl=e=>t=>{const{db:n,path:r}=t,o=r.split("/")[4],i=n.repos.get(o);return null==i?$u({msg:"Hash not found"},{status:404}):e(Xu(Xu({},t),{},{repo:i}))},Ol=Sl((e=>{const{repo:t}=e;return $u({changes:Mt(t)})})),Al=Sl((e=>{const{json:t,repo:n}=e,{changes:r}=Tl(t);for(const o of Object.keys(r))n[o]=r[o];return $u({changes:Mt(n),hash:"1111111111111111111111111111111111111111"})})),Tl=ye({changes:ye(_e)}),_l=m({"/api/v2/login/?":v({GET:Zu(nl),POST:Zu(nl)}),"/api/v2/login/create/?":v({POST:Zu(ol),PUT:Zu(ol)}),"/api/v2/login/keys/?":v({POST:Zu(il)}),"/api/v2/login/otp/?":v({DELETE:Zu(sl),POST:Zu(al),PUT:Zu(al)}),"/api/v2/login/password/?":v({DELETE:Zu(cl),POST:Zu(ul),PUT:Zu(ul)}),"/api/v2/login/pin2/?":v({DELETE:Zu(ll),POST:Zu(dl),PUT:Zu(dl)}),"/api/v2/login/recovery2/?":v({DELETE:Zu(fl),POST:Zu(pl),PUT:Zu(pl)}),"/api/v2/login/secret/?":v({POST:Zu(hl)}),"/api/v2/login/username/?":v({POST:Zu(yl)}),"/api/v2/login/vouchers/?":v({POST:Zu(bl)}),"/api/v2/messages/?":v({POST:Zu((e=>{const{db:t,json:n}=e,[r,o]=Gu(Ne,n);if(null==r)return o;const{loginIds:i}=r;if(null==i)return Hu(zu.invalidRequest);const a=[];for(const s of i){const e=t.getLoginById(s);null!=e&&a.push({loginId:s,otpResetPending:null!=e.otpResetDate,pendingVouchers:Fu(e),recovery2Corrupt:!1})}return Yu(It(a))}))}),"/api/v2/lobby/[^/]+/?":v({DELETE:Zu(El),GET:Zu(Il),POST:Zu(ml),PUT:Zu(vl)}),"/api/v2/store/[^/]+/?":v({GET:Ol,POST:Al}),"/v1/edgeServers":v({GET:e=>$u({infoServers:["https://info-fake1.edge.app"],syncServers:["https://sync-fake1.edge.app","https://sync-fake2.edge.app","https://sync-fake3.edge.app"]})})},(e=>Hu(zu.notFound,`Unknown API endpoint ${e.path}`)));function kl(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function xl(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?kl(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):kl(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}async function Pl(e,t){const{lastLogin:n,server:r}=t,o=y.parse(t.loginId),i=y.parse(t.loginKey),a=qn({appId:"",lastLogin:n,loginId:o,pendingVouchers:[],username:null==t.username?void 0:re(t.username)},i,Je(r)),s=`logins/${jt.stringify(o)}.json`;await e.disklet.setText(s,JSON.stringify(Cn(a))).catch((()=>{}))}async function Ml(e,t,n){const r=io(e,{dataKey:new Uint8Array(0),syncKey:t});await so(r.dataDisklet,n),await r.baseDisklet.setText("status.json",JSON.stringify({lastSync:1,lastHash:null}))}function Cl(e,t,n){const{io:r,nativeIo:o}=e,i=new Ku,a=function(e){const t=yn((n=>{if(t.offline)throw new Error("Fake network error");const r=n.body.byteLength>0?JSON.parse(Dt.stringify(new Uint8Array(n.body))):{};return _l(Xu(Xu({},n),{},{db:e,json:r}))}),{offline:!1});return t}(i);for(const u of n){i.setupLogin(xt(u.server));for(const e of Object.keys(u.repos))i.setupRepo(e,_t(u.repos[e]))}const s=[],c={async close(){await Promise.all(s.map((e=>e.close()))),B(c)},async makeEdgeContext(e){const{allowNetworkAccess:i=!1,cleanDevice:c=!1,extraFiles:u={}}=e,l=g(a),d=i?(e,t)=>{try{Rt(e)}catch(n){return r.fetch(e,t)}return l(e,t)}:l,f=xl(xl({},r),{},{disklet:(0,ee.Wh)(),fetch:d});if(!c)for(const t of n){await Pl(f,t);for(const e of Object.keys(t.repos))await Ml(f,p.parse(e),_t(t.repos[e]))}if(null!=u)for(const t of Object.keys(u))await f.disklet.setText(t,u[t]);const h=await ju({io:f,nativeIo:o},t,xl({},e));return s.push(h),h},async goOffline(e=!0){a.offline=e},async dumpFakeUser(e){if(""!==e.appId)throw new Error("Only root logins are dumpable.");const t=jt.parse(e.rootLoginId),n=jt.parse(await e.getLoginKey()),r=i.getLoginById(t);if(null==r)throw new Error(`Cannot find user ${e.rootLoginId}`);const o=[];for(const i of e.allKeys){const t=await e.getRawPrivateKey(i.id);null!=t.syncKey&&o.push(p.stringify(y.parse(t.syncKey)).toLowerCase())}const a={};for(const s of o){const e=i.repos.get(s);null!=e&&(a[s]=Mt(e))}return{lastLogin:e.lastLogin,loginId:y.stringify(t),loginKey:y.stringify(n),repos:a,server:Pt(i.dumpLogin(r)),username:e.username}}};return _(c),c}function Nl(e){return function(t){return new Worker(e,t)}}var jl=Nl(new URL(n(8326),n.b));const Dl=Symbol("Comlink.proxy"),Rl=Symbol("Comlink.endpoint"),Ll=Symbol("Comlink.releaseProxy"),Bl=Symbol("Comlink.finalizer"),Kl=Symbol("Comlink.thrown"),Ul=e=>"object"==typeof e&&null!==e||"function"==typeof e,Fl=new Map([["proxy",{canHandle:e=>Ul(e)&&e[Dl],serialize(e){const{port1:t,port2:n}=new MessageChannel;return Wl(e,t),[n,[n]]},deserialize(e){return e.start(),zl(e)}}],["throw",{canHandle:e=>Ul(e)&&Kl in e,serialize({value:e}){let t;return t=e instanceof Error?{isError:!0,value:{message:e.message,name:e.name,stack:e.stack}}:{isError:!1,value:e},[t,[]]},deserialize(e){if(e.isError)throw Object.assign(new Error(e.value.message),e.value);throw e.value}}]]);function Wl(e,t=globalThis,n=["*"]){t.addEventListener("message",(function r(o){if(!o||!o.data)return;if(!function(e,t){for(const n of e){if(t===n||"*"===n)return!0;if(n instanceof RegExp&&n.test(t))return!0}return!1}(n,o.origin))return void console.warn(`Invalid origin '${o.origin}' for comlink proxy`);const{id:i,type:a,path:s}=Object.assign({path:[]},o.data),c=(o.data.argumentList||[]).map(Ql);let u;try{const t=s.slice(0,-1).reduce(((e,t)=>e[t]),e),n=s.reduce(((e,t)=>e[t]),e);switch(a){case"GET":u=n;break;case"SET":t[s.slice(-1)[0]]=Ql(o.data.value),u=!0;break;case"APPLY":u=n.apply(t,c);break;case"CONSTRUCT":u=function(e){return Object.assign(e,{[Dl]:!0})}(new n(...c));break;case"ENDPOINT":{const{port1:t,port2:n}=new MessageChannel;Wl(e,n),u=function(e,t){return Xl.set(e,t),e}(t,[t])}break;case"RELEASE":u=void 0;break;default:return}}catch(l){u={value:l,[Kl]:0}}Promise.resolve(u).catch((e=>({value:e,[Kl]:0}))).then((n=>{const[o,s]=Zl(n);t.postMessage(Object.assign(Object.assign({},o),{id:i}),s),"RELEASE"===a&&(t.removeEventListener("message",r),ql(t),Bl in e&&"function"==typeof e[Bl]&&e[Bl]())})).catch((e=>{const[n,r]=Zl({value:new TypeError("Unserializable return value"),[Kl]:0});t.postMessage(Object.assign(Object.assign({},n),{id:i}),r)}))})),t.start&&t.start()}function ql(e){(function(e){return"MessagePort"===e.constructor.name})(e)&&e.close()}function zl(e,t){const n=new Map;return e.addEventListener("message",(function(e){const{data:t}=e;if(!t||!t.id)return;const r=n.get(t.id);if(r)try{r(t)}finally{n.delete(t.id)}})),Vl(e,n,[],t)}function Gl(e){if(e)throw new Error("Proxy has been released and is not useable")}function $l(e){return ed(e,new Map,{type:"RELEASE"}).then((()=>{ql(e)}))}const Hl=new WeakMap,Yl="FinalizationRegistry"in globalThis&&new FinalizationRegistry((e=>{const t=(Hl.get(e)||0)-1;Hl.set(e,t),0===t&&$l(e)}));function Vl(e,t,n=[],r=function(){}){let o=!1;const i=new Proxy(r,{get(r,a){if(Gl(o),a===Ll)return()=>{!function(e){Yl&&Yl.unregister(e)}(i),$l(e),t.clear(),o=!0};if("then"===a){if(0===n.length)return{then:()=>i};const r=ed(e,t,{type:"GET",path:n.map((e=>e.toString()))}).then(Ql);return r.then.bind(r)}return Vl(e,t,[...n,a])},set(r,i,a){Gl(o);const[s,c]=Zl(a);return ed(e,t,{type:"SET",path:[...n,i].map((e=>e.toString())),value:s},c).then(Ql)},apply(r,i,a){Gl(o);const s=n[n.length-1];if(s===Rl)return ed(e,t,{type:"ENDPOINT"}).then(Ql);if("bind"===s)return Vl(e,t,n.slice(0,-1));const[c,u]=Jl(a);return ed(e,t,{type:"APPLY",path:n.map((e=>e.toString())),argumentList:c},u).then(Ql)},construct(r,i){Gl(o);const[a,s]=Jl(i);return ed(e,t,{type:"CONSTRUCT",path:n.map((e=>e.toString())),argumentList:a},s).then(Ql)}});return function(e,t){const n=(Hl.get(t)||0)+1;Hl.set(t,n),Yl&&Yl.register(e,t,e)}(i,e),i}function Jl(e){const t=e.map(Zl);return[t.map((e=>e[0])),(n=t.map((e=>e[1])),Array.prototype.concat.apply([],n))];var n}const Xl=new WeakMap;function Zl(e){for(const[t,n]of Fl)if(n.canHandle(e)){const[r,o]=n.serialize(e);return[{type:"HANDLER",name:t,value:r},o]}return[{type:"RAW",value:e},Xl.get(e)||[]]}function Ql(e){switch(e.type){case"HANDLER":return Fl.get(e.name).deserialize(e.value);case"RAW":return e.value}}function ed(e,t,n,r){return new Promise((o=>{const i=new Array(4).fill(0).map((()=>Math.floor(Math.random()*Number.MAX_SAFE_INTEGER).toString(16))).join("-");t.set(i,o),e.start&&e.start(),e.postMessage(Object.assign({id:i},n),r)}))}var td;!function(e){e.Loaded="Loaded"}(td||(td={}));const nd=async()=>{const e=zl(await(async()=>new Promise(((e,t)=>{const n=new jl({type:"module"});n.addEventListener("error",t),n.addEventListener("message",(r=>{n.removeEventListener("error",t),r.data?.kind===td.Loaded?e(n):t(r)}),{once:!0})})))());return{setupMixFetch:e.setupMixFetch,mixFetch:async(t,n)=>{const r=await e.mixFetch(t,n);if(!r)throw new Error("No response received");console.log({workerResponse:r});const{headers:o,status:i,statusText:a}=r,s=(e=>{const t=new Headers;return Object.keys(e).forEach((n=>{t.append(n,e[n])})),t})(o);if(r.body.blobUrl){const e=await(await fetch(r.body.blobUrl)).blob(),t=await e.arrayBuffer();return new Response(t,{headers:s,status:i,statusText:a})}const c=Object.values(r.body)[0];return new Response(c,{headers:s,status:i,statusText:a})},disconnectMixFetch:e.disconnectMixFetch}},rd=async e=>{if(!window)throw new Error("`window` is not defined");return window.__mixFetchGlobal||(window.__mixFetchGlobal=await nd(),await window.__mixFetchGlobal.setupMixFetch(e),window.onunload=async()=>{window.__mixFetchGlobal&&await window.__mixFetchGlobal.disconnectMixFetch()}),window.__mixFetchGlobal},od=async(e,t,n)=>(await rd({mixFetchOverride:{requestTimeoutMs:6e4},...n})).mixFetch(e,t),id={preferredGateway:"5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8",preferredNetworkRequester:"5x6q9UfVHs5AohKMUqeivj7a556kVVy7QwoKige8xHxh.6CFoB3kJaDbYz6oafPJxNxNjzahpT2NtgtytcSyN9EvF@5rXcNe2a44vXisK3uqLHCzpzvEwcnsijDMU7hg4fcYk8",forceTls:!0,mixFetchOverride:{requestTimeoutMs:3e5}};let ad=null;const sd=new Map;async function cd(e,t){var n;const r=function(e){try{const t=new URL(e),n=""!==t.port?t.port:"https:"===t.protocol?"443":"80";return`${t.hostname}:${n}`}catch(t){return e}}(e),o=(null!==(n=sd.get(r))&&void 0!==n?n:Promise.resolve()).catch((()=>{})).then((async()=>await od(e,t,id))).finally((()=>{sd.get(r)===o&&sd.delete(r)}));return sd.set(r,o),await o}const ud=["allKeys","displayPrivateSeed","displayPublicSeed","keys","otpKey","loginKey","publicWalletInfo","recoveryKey"];function ld(e){const t=function(){const e={resolve(){},reject(){}};let t=0;if("undefined"!=typeof Map){const n=new Map;return{add(e){const r=++t;return n.set(r,e),r},grab(t){const r=n.get(t);return null==r?e:(n.delete(t),r)}}}const n={};return{add(e){const r=++t;return n[String(r)]=e,r},grab(t){const r=n[String(t)];return null==r?e:(delete n[String(t)],r)}}}();return{call(n,...r){return new Promise(((o,i)=>{e(t.add({resolve:o,reject:i}),n,r)}))},resolve(e,n){t.grab(e).resolve(n)},reject(e,n){t.grab(e).reject(new Error(n))}}}function dd(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function fd(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?dd(Object(n),!0).forEach((function(t){r(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):dd(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}const pd=new Map,[hd,yd]=null!=window.edgeCore?[ld(((e,t,n)=>{window.edgeCore.call(e,t,JSON.stringify(n))})),new V({hideProperties:ud,sendMessage(e){window.edgeCore.postMessage(JSON.stringify(e))},throttleMs:50})]:[ld(((e,t,n)=>{window.webkit.messageHandlers.edgeCore.postMessage([e,t,n])})),new V({hideProperties:ud,sendMessage(e){window.webkit.messageHandlers.edgeCore.postMessage([0,"postMessage",[JSON.stringify(e)]])},throttleMs:50})];function bd(e){const{head:t}=window.document;if(null==t||0===e.length)return void $r();let n=0;const r=()=>{++n>=e.length&&$r()};for(const o of e){const e=document.createElement("script");e.addEventListener("error",r),e.addEventListener("load",r),e.charset="utf-8",e.defer=!0,e.src=o,t.appendChild(e)}}async function gd(e){const t=Cr(e,"react-native-io"),n=new(s())({hash:i().sha256,entropy:y.parse(await hd.call("randomBytes",32))}),r=async(e,t={})=>{const{method:n="GET",headers:r={},body:o}=t,i=await hd.call("fetch",e,n,r,o instanceof ArrayBuffer?y.stringify(new Uint8Array(o)):o,o instanceof ArrayBuffer);return w({status:i.status,headers:i.headers,body:i.bodyIsBase64?y.parse(i.body):i.body})},o={disklet:{delete(e){return hd.call("diskletDelete",wd(e))},async getData(e){const t=await hd.call("diskletGetData",wd(e));return y.parse(t)},getText(e){return hd.call("diskletGetText",wd(e))},list(e=""){return hd.call("diskletList",wd(e))},setData(e,t){return hd.call("diskletSetData",wd(e),y.stringify(t))},setText(e,t){return hd.call("diskletSetText",wd(e),t)}},random:e=>n.generate(e),async scrypt(e,t,n,r,o,i){const a=await hd.call("scrypt",y.stringify(e),y.stringify(t),n,r,o,i);return y.parse(a)},async fetch(e,n){var o;const{corsBypass:i="auto",privacy:a="none"}=null!=n?n:{};if("nym"===a){await async function(e){return null==ad&&(e("Initializing mixFetch..."),ad=rd(id).then((t=>(e("mixFetch initialized successfully"),t))).catch((t=>{throw ad=null,e.error("mixFetch initialization failed:",t),t}))),await ad}(t);return await cd(e,fd(fd({},n),{},{mode:"unsafe-ignore-cors"}))}if("always"===i)return await r(e,n);if("never"===i)return await window.fetch(e,n);const{protocol:s,host:c,pathname:u}=new URL(e),l=`${s}//${c}${u}`,d=null!==(o=pd.get(l))&&void 0!==o?o:{windowSuccess:!1,nativeSuccess:!1};if(pd.has(l)||pd.set(l,d),!d.nativeSuccess)try{const t=await window.fetch(e,n);return d.windowSuccess=!0,t}catch(p){if(d.windowSuccess)throw p}const f=await r(e,n);return d.nativeSuccess=!0,f},async fetchCors(e,t={}){return await o.fetch(e,t)}};return o}function wd(e){if(/^\//.test(e))throw new Error("Absolute paths are not supported");const t=e.split("/");let n=0,r=0;for(;n<t.length;){const e=t[n++];if(".."===e?r--:"."!==e&&""!==e&&(t[r++]=e),r<0)throw new Error("Path would escape folder")}return t.slice(0,r).join("/")}window.addEdgeCorePlugins=function(e){if(qr)throw new Error("The Edge core plugin list has already been locked");for(const t of Object.keys(e))Wr[t]=e[t];for(const t of zr)t(e)},window.nativeBridge=hd,window.reactBridge=yd;const vd=_({async makeEdgeContext(e,t,n,r){bd(n);const o=await gd(t);return await ju({io:o,nativeIo:e},t,r)},async makeFakeEdgeWorld(e,t,n,r=[]){bd(n);return Cl({io:await gd(t),nativeIo:e},t,r)}});yd.sendRoot(vd)}()}();
|