-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathspi-client-js.js
4 lines (4 loc) · 228 KB
/
spi-client-js.js
1
2
3
4
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n=e();for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=9)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}t.exports=function(t,e,i){return e&&n(t.prototype,e),i&&n(t,i),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){t.exports=n(6)},function(t,e){function n(t,e,n,i,r,s,o){try{var a=t[s](o),u=a.value}catch(t){return void n(t)}a.done?e(u):Promise.resolve(u).then(i,r)}t.exports=function(t){return function(){var e=this,i=arguments;return new Promise((function(r,s){var o=t.apply(e,i);function a(t){n(o,r,s,a,u,"next",t)}function u(t){n(o,r,s,a,u,"throw",t)}a(void 0)}))}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){
/*! MIT License. Copyright 2015-2018 Richard Moore <[email protected]>. See LICENSE.txt. */
!function(e){"use strict";function n(t){return parseInt(t)===t}function i(t){if(!n(t.length))return!1;for(var e=0;e<t.length;e++)if(!n(t[e])||t[e]<0||t[e]>255)return!1;return!0}function r(t,e){if(t.buffer&&"Uint8Array"===t.name)return e&&(t=t.slice?t.slice():Array.prototype.slice.call(t)),t;if(Array.isArray(t)){if(!i(t))throw new Error("Array contains invalid value: "+t);return new Uint8Array(t)}if(n(t.length)&&i(t))return new Uint8Array(t);throw new Error("unsupported array-like object")}function s(t){return new Uint8Array(t)}function o(t,e,n,i,r){null==i&&null==r||(t=t.slice?t.slice(i,r):Array.prototype.slice.call(t,i,r)),e.set(t,n)}var a,u={toBytes:function(t){var e=[],n=0;for(t=encodeURI(t);n<t.length;){var i=t.charCodeAt(n++);37===i?(e.push(parseInt(t.substr(n,2),16)),n+=2):e.push(i)}return r(e)},fromBytes:function(t){for(var e=[],n=0;n<t.length;){var i=t[n];i<128?(e.push(String.fromCharCode(i)),n++):i>191&&i<224?(e.push(String.fromCharCode((31&i)<<6|63&t[n+1])),n+=2):(e.push(String.fromCharCode((15&i)<<12|(63&t[n+1])<<6|63&t[n+2])),n+=3)}return e.join("")}},h=(a="0123456789abcdef",{toBytes:function(t){for(var e=[],n=0;n<t.length;n+=2)e.push(parseInt(t.substr(n,2),16));return e},fromBytes:function(t){for(var e=[],n=0;n<t.length;n++){var i=t[n];e.push(a[(240&i)>>4]+a[15&i])}return e.join("")}}),l={16:10,24:12,32:14},c=[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],d=[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],f=[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],p=[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],m=[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],g=[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],_=[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],v=[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],w=[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],y=[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],C=[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],S=[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],T=[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],P=[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],R=[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 E(t){for(var e=[],n=0;n<t.length;n+=4)e.push(t[n]<<24|t[n+1]<<16|t[n+2]<<8|t[n+3]);return e}var b=function(t){if(!(this instanceof b))throw Error("AES must be instanitated with `new`");Object.defineProperty(this,"key",{value:r(t,!0)}),this._prepare()};b.prototype._prepare=function(){var t=l[this.key.length];if(null==t)throw new Error("invalid key size (must be 16, 24 or 32 bytes)");this._Ke=[],this._Kd=[];for(var e=0;e<=t;e++)this._Ke.push([0,0,0,0]),this._Kd.push([0,0,0,0]);var n,i=4*(t+1),r=this.key.length/4,s=E(this.key);for(e=0;e<r;e++)n=e>>2,this._Ke[n][e%4]=s[e],this._Kd[t-n][e%4]=s[e];for(var o,a=0,u=r;u<i;){if(o=s[r-1],s[0]^=d[o>>16&255]<<24^d[o>>8&255]<<16^d[255&o]<<8^d[o>>24&255]^c[a]<<24,a+=1,8!=r)for(e=1;e<r;e++)s[e]^=s[e-1];else{for(e=1;e<r/2;e++)s[e]^=s[e-1];o=s[r/2-1],s[r/2]^=d[255&o]^d[o>>8&255]<<8^d[o>>16&255]<<16^d[o>>24&255]<<24;for(e=r/2+1;e<r;e++)s[e]^=s[e-1]}for(e=0;e<r&&u<i;)h=u>>2,f=u%4,this._Ke[h][f]=s[e],this._Kd[t-h][f]=s[e++],u++}for(var h=1;h<t;h++)for(var f=0;f<4;f++)o=this._Kd[h][f],this._Kd[h][f]=S[o>>24&255]^T[o>>16&255]^P[o>>8&255]^R[255&o]},b.prototype.encrypt=function(t){if(16!=t.length)throw new Error("invalid plaintext size (must be 16 bytes)");for(var e=this._Ke.length-1,n=[0,0,0,0],i=E(t),r=0;r<4;r++)i[r]^=this._Ke[0][r];for(var o=1;o<e;o++){for(r=0;r<4;r++)n[r]=p[i[r]>>24&255]^m[i[(r+1)%4]>>16&255]^g[i[(r+2)%4]>>8&255]^_[255&i[(r+3)%4]]^this._Ke[o][r];i=n.slice()}var a,u=s(16);for(r=0;r<4;r++)a=this._Ke[e][r],u[4*r]=255&(d[i[r]>>24&255]^a>>24),u[4*r+1]=255&(d[i[(r+1)%4]>>16&255]^a>>16),u[4*r+2]=255&(d[i[(r+2)%4]>>8&255]^a>>8),u[4*r+3]=255&(d[255&i[(r+3)%4]]^a);return u},b.prototype.decrypt=function(t){if(16!=t.length)throw new Error("invalid ciphertext size (must be 16 bytes)");for(var e=this._Kd.length-1,n=[0,0,0,0],i=E(t),r=0;r<4;r++)i[r]^=this._Kd[0][r];for(var o=1;o<e;o++){for(r=0;r<4;r++)n[r]=v[i[r]>>24&255]^w[i[(r+3)%4]>>16&255]^y[i[(r+2)%4]>>8&255]^C[255&i[(r+1)%4]]^this._Kd[o][r];i=n.slice()}var a,u=s(16);for(r=0;r<4;r++)a=this._Kd[e][r],u[4*r]=255&(f[i[r]>>24&255]^a>>24),u[4*r+1]=255&(f[i[(r+3)%4]>>16&255]^a>>16),u[4*r+2]=255&(f[i[(r+2)%4]>>8&255]^a>>8),u[4*r+3]=255&(f[255&i[(r+1)%4]]^a);return u};var M=function(t){if(!(this instanceof M))throw Error("AES must be instanitated with `new`");this.description="Electronic Code Block",this.name="ecb",this._aes=new b(t)};M.prototype.encrypt=function(t){if((t=r(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=s(t.length),n=s(16),i=0;i<t.length;i+=16)o(t,n,0,i,i+16),o(n=this._aes.encrypt(n),e,i);return e},M.prototype.decrypt=function(t){if((t=r(t)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var e=s(t.length),n=s(16),i=0;i<t.length;i+=16)o(t,n,0,i,i+16),o(n=this._aes.decrypt(n),e,i);return e};var k=function(t,e){if(!(this instanceof k))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Block Chaining",this.name="cbc",e){if(16!=e.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else e=s(16);this._lastCipherblock=r(e,!0),this._aes=new b(t)};k.prototype.encrypt=function(t){if((t=r(t)).length%16!=0)throw new Error("invalid plaintext size (must be multiple of 16 bytes)");for(var e=s(t.length),n=s(16),i=0;i<t.length;i+=16){o(t,n,0,i,i+16);for(var a=0;a<16;a++)n[a]^=this._lastCipherblock[a];this._lastCipherblock=this._aes.encrypt(n),o(this._lastCipherblock,e,i)}return e},k.prototype.decrypt=function(t){if((t=r(t)).length%16!=0)throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");for(var e=s(t.length),n=s(16),i=0;i<t.length;i+=16){o(t,n,0,i,i+16),n=this._aes.decrypt(n);for(var a=0;a<16;a++)e[i+a]=n[a]^this._lastCipherblock[a];o(t,this._lastCipherblock,0,i,i+16)}return e};var A=function(t,e,n){if(!(this instanceof A))throw Error("AES must be instanitated with `new`");if(this.description="Cipher Feedback",this.name="cfb",e){if(16!=e.length)throw new Error("invalid initialation vector size (must be 16 size)")}else e=s(16);n||(n=1),this.segmentSize=n,this._shiftRegister=r(e,!0),this._aes=new b(t)};A.prototype.encrypt=function(t){if(t.length%this.segmentSize!=0)throw new Error("invalid plaintext size (must be segmentSize bytes)");for(var e,n=r(t,!0),i=0;i<n.length;i+=this.segmentSize){e=this._aes.encrypt(this._shiftRegister);for(var s=0;s<this.segmentSize;s++)n[i+s]^=e[s];o(this._shiftRegister,this._shiftRegister,0,this.segmentSize),o(n,this._shiftRegister,16-this.segmentSize,i,i+this.segmentSize)}return n},A.prototype.decrypt=function(t){if(t.length%this.segmentSize!=0)throw new Error("invalid ciphertext size (must be segmentSize bytes)");for(var e,n=r(t,!0),i=0;i<n.length;i+=this.segmentSize){e=this._aes.encrypt(this._shiftRegister);for(var s=0;s<this.segmentSize;s++)n[i+s]^=e[s];o(this._shiftRegister,this._shiftRegister,0,this.segmentSize),o(t,this._shiftRegister,16-this.segmentSize,i,i+this.segmentSize)}return n};var I=function(t,e){if(!(this instanceof I))throw Error("AES must be instanitated with `new`");if(this.description="Output Feedback",this.name="ofb",e){if(16!=e.length)throw new Error("invalid initialation vector size (must be 16 bytes)")}else e=s(16);this._lastPrecipher=r(e,!0),this._lastPrecipherIndex=16,this._aes=new b(t)};I.prototype.encrypt=function(t){for(var e=r(t,!0),n=0;n<e.length;n++)16===this._lastPrecipherIndex&&(this._lastPrecipher=this._aes.encrypt(this._lastPrecipher),this._lastPrecipherIndex=0),e[n]^=this._lastPrecipher[this._lastPrecipherIndex++];return e},I.prototype.decrypt=I.prototype.encrypt;var F=function(t){if(!(this instanceof F))throw Error("Counter must be instanitated with `new`");0===t||t||(t=1),"number"==typeof t?(this._counter=s(16),this.setValue(t)):this.setBytes(t)};F.prototype.setValue=function(t){if("number"!=typeof t||parseInt(t)!=t)throw new Error("invalid counter value (must be an integer)");if(t>Number.MAX_SAFE_INTEGER)throw new Error("integer value out of safe range");for(var e=15;e>=0;--e)this._counter[e]=t%256,t=parseInt(t/256)},F.prototype.setBytes=function(t){if(16!=(t=r(t,!0)).length)throw new Error("invalid counter bytes size (must be 16 bytes)");this._counter=t},F.prototype.increment=function(){for(var t=15;t>=0;t--){if(255!==this._counter[t]){this._counter[t]++;break}this._counter[t]=0}};var D=function(t,e){if(!(this instanceof D))throw Error("AES must be instanitated with `new`");this.description="Counter",this.name="ctr",e instanceof F||(e=new F(e)),this._counter=e,this._remainingCounter=null,this._remainingCounterIndex=16,this._aes=new b(t)};D.prototype.encrypt=function(t){for(var e=r(t,!0),n=0;n<e.length;n++)16===this._remainingCounterIndex&&(this._remainingCounter=this._aes.encrypt(this._counter._counter),this._remainingCounterIndex=0,this._counter.increment()),e[n]^=this._remainingCounter[this._remainingCounterIndex++];return e},D.prototype.decrypt=D.prototype.encrypt;var x={AES:b,Counter:F,ModeOfOperation:{ecb:M,cbc:k,cfb:A,ofb:I,ctr:D},utils:{hex:h,utf8:u},padding:{pkcs7:{pad:function(t){var e=16-(t=r(t,!0)).length%16,n=s(t.length+e);o(t,n);for(var i=t.length;i<n.length;i++)n[i]=e;return n},strip:function(t){if((t=r(t,!0)).length<16)throw new Error("PKCS#7 invalid length");var e=t[t.length-1];if(e>16)throw new Error("PKCS#7 padding byte out of range");for(var n=t.length-e,i=0;i<e;i++)if(t[n+i]!==e)throw new Error("PKCS#7 invalid padding byte");var a=s(n);return o(t,a,0,0,n),a}}},_arrayTest:{coerceArray:r,createArray:s,copyArray:o}};t.exports=x}()},function(t,e,n){(function(t){!function(t,e){"use strict";function i(t,e){if(!t)throw new Error(e||"Assertion failed")}function r(t,e){t.super_=e;var n=function(){};n.prototype=e.prototype,t.prototype=new n,t.prototype.constructor=t}function s(t,e,n){if(s.isBN(t))return t;this.negative=0,this.words=null,this.length=0,this.red=null,null!==t&&("le"!==e&&"be"!==e||(n=e,e=10),this._init(t||0,e||10,n||"be"))}var o;"object"==typeof t?t.exports=s:e.BN=s,s.BN=s,s.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:n(8).Buffer}catch(t){}function a(t,e){var n=t.charCodeAt(e);return n>=48&&n<=57?n-48:n>=65&&n<=70?n-55:n>=97&&n<=102?n-87:void i(!1,"Invalid character in "+t)}function u(t,e,n){var i=a(t,n);return n-1>=e&&(i|=a(t,n-1)<<4),i}function h(t,e,n,r){for(var s=0,o=0,a=Math.min(t.length,n),u=e;u<a;u++){var h=t.charCodeAt(u)-48;s*=r,o=h>=49?h-49+10:h>=17?h-17+10:h,i(h>=0&&o<r,"Invalid character"),s+=o}return s}function l(t,e){t.words=e.words,t.length=e.length,t.negative=e.negative,t.red=e.red}if(s.isBN=function(t){return t instanceof s||null!==t&&"object"==typeof t&&t.constructor.wordSize===s.wordSize&&Array.isArray(t.words)},s.max=function(t,e){return t.cmp(e)>0?t:e},s.min=function(t,e){return t.cmp(e)<0?t:e},s.prototype._init=function(t,e,n){if("number"==typeof t)return this._initNumber(t,e,n);if("object"==typeof t)return this._initArray(t,e,n);"hex"===e&&(e=16),i(e===(0|e)&&e>=2&&e<=36);var r=0;"-"===(t=t.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r<t.length&&(16===e?this._parseHex(t,r,n):(this._parseBase(t,e,r),"le"===n&&this._initArray(this.toArray(),e,n)))},s.prototype._initNumber=function(t,e,n){t<0&&(this.negative=1,t=-t),t<67108864?(this.words=[67108863&t],this.length=1):t<4503599627370496?(this.words=[67108863&t,t/67108864&67108863],this.length=2):(i(t<9007199254740992),this.words=[67108863&t,t/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),e,n)},s.prototype._initArray=function(t,e,n){if(i("number"==typeof t.length),t.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(t.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var s,o,a=0;if("be"===n)for(r=t.length-1,s=0;r>=0;r-=3)o=t[r]|t[r-1]<<8|t[r-2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);else if("le"===n)for(r=0,s=0;r<t.length;r+=3)o=t[r]|t[r+1]<<8|t[r+2]<<16,this.words[s]|=o<<a&67108863,this.words[s+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,s++);return this._strip()},s.prototype._parseHex=function(t,e,n){this.length=Math.ceil((t.length-e)/6),this.words=new Array(this.length);for(var i=0;i<this.length;i++)this.words[i]=0;var r,s=0,o=0;if("be"===n)for(i=t.length-1;i>=e;i-=2)r=u(t,e,i)<<s,this.words[o]|=67108863&r,s>=18?(s-=18,o+=1,this.words[o]|=r>>>26):s+=8;else for(i=(t.length-e)%2==0?e+1:e;i<t.length;i+=2)r=u(t,e,i)<<s,this.words[o]|=67108863&r,s>=18?(s-=18,o+=1,this.words[o]|=r>>>26):s+=8;this._strip()},s.prototype._parseBase=function(t,e,n){this.words=[0],this.length=1;for(var i=0,r=1;r<=67108863;r*=e)i++;i--,r=r/e|0;for(var s=t.length-n,o=s%i,a=Math.min(s,s-o)+n,u=0,l=n;l<a;l+=i)u=h(t,l,l+i,e),this.imuln(r),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u);if(0!==o){var c=1;for(u=h(t,l,t.length,e),l=0;l<o;l++)c*=e;this.imuln(c),this.words[0]+u<67108864?this.words[0]+=u:this._iaddn(u)}this._strip()},s.prototype.copy=function(t){t.words=new Array(this.length);for(var e=0;e<this.length;e++)t.words[e]=this.words[e];t.length=this.length,t.negative=this.negative,t.red=this.red},s.prototype._move=function(t){l(t,this)},s.prototype.clone=function(){var t=new s(null);return this.copy(t),t},s.prototype._expand=function(t){for(;this.length<t;)this.words[this.length++]=0;return this},s.prototype._strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},s.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{s.prototype[Symbol.for("nodejs.util.inspect.custom")]=c}catch(t){s.prototype.inspect=c}else s.prototype.inspect=c;function c(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"}var d=["","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"],f=[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],p=[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];s.prototype.toString=function(t,e){var n;if(e=0|e||1,16===(t=t||10)||"hex"===t){n="";for(var r=0,s=0,o=0;o<this.length;o++){var a=this.words[o],u=(16777215&(a<<r|s)).toString(16);n=0!==(s=a>>>24-r&16777215)||o!==this.length-1?d[6-u.length]+u+n:u+n,(r+=2)>=26&&(r-=26,o--)}for(0!==s&&(n=s.toString(16)+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(t===(0|t)&&t>=2&&t<=36){var h=f[t],l=p[t];n="";var c=this.clone();for(c.negative=0;!c.isZero();){var m=c.modrn(l).toString(t);n=(c=c.idivn(l)).isZero()?m+n:d[h-m.length]+m+n}for(this.isZero()&&(n="0"+n);n.length%e!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}i(!1,"Base should be between 2 and 36")},s.prototype.toNumber=function(){var t=this.words[0];return 2===this.length?t+=67108864*this.words[1]:3===this.length&&1===this.words[2]?t+=4503599627370496+67108864*this.words[1]:this.length>2&&i(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-t:t},s.prototype.toJSON=function(){return this.toString(16,2)},o&&(s.prototype.toBuffer=function(t,e){return this.toArrayLike(o,t,e)}),s.prototype.toArray=function(t,e){return this.toArrayLike(Array,t,e)};function m(t,e,n){n.negative=e.negative^t.negative;var i=t.length+e.length|0;n.length=i,i=i-1|0;var r=0|t.words[0],s=0|e.words[0],o=r*s,a=67108863&o,u=o/67108864|0;n.words[0]=a;for(var h=1;h<i;h++){for(var l=u>>>26,c=67108863&u,d=Math.min(h,e.length-1),f=Math.max(0,h-t.length+1);f<=d;f++){var p=h-f|0;l+=(o=(r=0|t.words[p])*(s=0|e.words[f])+c)/67108864|0,c=67108863&o}n.words[h]=0|c,u=0|l}return 0!==u?n.words[h]=0|u:n.length--,n._strip()}s.prototype.toArrayLike=function(t,e,n){this._strip();var r=this.byteLength(),s=n||Math.max(1,r);i(r<=s,"byte array longer than desired length"),i(s>0,"Requested array length <= 0");var o=function(t,e){return t.allocUnsafe?t.allocUnsafe(e):new t(e)}(t,s);return this["_toArrayLike"+("le"===e?"LE":"BE")](o,r),o},s.prototype._toArrayLikeLE=function(t,e){for(var n=0,i=0,r=0,s=0;r<this.length;r++){var o=this.words[r]<<s|i;t[n++]=255&o,n<t.length&&(t[n++]=o>>8&255),n<t.length&&(t[n++]=o>>16&255),6===s?(n<t.length&&(t[n++]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(n<t.length)for(t[n++]=i;n<t.length;)t[n++]=0},s.prototype._toArrayLikeBE=function(t,e){for(var n=t.length-1,i=0,r=0,s=0;r<this.length;r++){var o=this.words[r]<<s|i;t[n--]=255&o,n>=0&&(t[n--]=o>>8&255),n>=0&&(t[n--]=o>>16&255),6===s?(n>=0&&(t[n--]=o>>24&255),i=0,s=0):(i=o>>>24,s+=2)}if(n>=0)for(t[n--]=i;n>=0;)t[n--]=0},Math.clz32?s.prototype._countBits=function(t){return 32-Math.clz32(t)}:s.prototype._countBits=function(t){var e=t,n=0;return e>=4096&&(n+=13,e>>>=13),e>=64&&(n+=7,e>>>=7),e>=8&&(n+=4,e>>>=4),e>=2&&(n+=2,e>>>=2),n+e},s.prototype._zeroBits=function(t){if(0===t)return 26;var e=t,n=0;return 0==(8191&e)&&(n+=13,e>>>=13),0==(127&e)&&(n+=7,e>>>=7),0==(15&e)&&(n+=4,e>>>=4),0==(3&e)&&(n+=2,e>>>=2),0==(1&e)&&n++,n},s.prototype.bitLength=function(){var t=this.words[this.length-1],e=this._countBits(t);return 26*(this.length-1)+e},s.prototype.zeroBits=function(){if(this.isZero())return 0;for(var t=0,e=0;e<this.length;e++){var n=this._zeroBits(this.words[e]);if(t+=n,26!==n)break}return t},s.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},s.prototype.toTwos=function(t){return 0!==this.negative?this.abs().inotn(t).iaddn(1):this.clone()},s.prototype.fromTwos=function(t){return this.testn(t-1)?this.notn(t).iaddn(1).ineg():this.clone()},s.prototype.isNeg=function(){return 0!==this.negative},s.prototype.neg=function(){return this.clone().ineg()},s.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},s.prototype.iuor=function(t){for(;this.length<t.length;)this.words[this.length++]=0;for(var e=0;e<t.length;e++)this.words[e]=this.words[e]|t.words[e];return this._strip()},s.prototype.ior=function(t){return i(0==(this.negative|t.negative)),this.iuor(t)},s.prototype.or=function(t){return this.length>t.length?this.clone().ior(t):t.clone().ior(this)},s.prototype.uor=function(t){return this.length>t.length?this.clone().iuor(t):t.clone().iuor(this)},s.prototype.iuand=function(t){var e;e=this.length>t.length?t:this;for(var n=0;n<e.length;n++)this.words[n]=this.words[n]&t.words[n];return this.length=e.length,this._strip()},s.prototype.iand=function(t){return i(0==(this.negative|t.negative)),this.iuand(t)},s.prototype.and=function(t){return this.length>t.length?this.clone().iand(t):t.clone().iand(this)},s.prototype.uand=function(t){return this.length>t.length?this.clone().iuand(t):t.clone().iuand(this)},s.prototype.iuxor=function(t){var e,n;this.length>t.length?(e=this,n=t):(e=t,n=this);for(var i=0;i<n.length;i++)this.words[i]=e.words[i]^n.words[i];if(this!==e)for(;i<e.length;i++)this.words[i]=e.words[i];return this.length=e.length,this._strip()},s.prototype.ixor=function(t){return i(0==(this.negative|t.negative)),this.iuxor(t)},s.prototype.xor=function(t){return this.length>t.length?this.clone().ixor(t):t.clone().ixor(this)},s.prototype.uxor=function(t){return this.length>t.length?this.clone().iuxor(t):t.clone().iuxor(this)},s.prototype.inotn=function(t){i("number"==typeof t&&t>=0);var e=0|Math.ceil(t/26),n=t%26;this._expand(e),n>0&&e--;for(var r=0;r<e;r++)this.words[r]=67108863&~this.words[r];return n>0&&(this.words[r]=~this.words[r]&67108863>>26-n),this._strip()},s.prototype.notn=function(t){return this.clone().inotn(t)},s.prototype.setn=function(t,e){i("number"==typeof t&&t>=0);var n=t/26|0,r=t%26;return this._expand(n+1),this.words[n]=e?this.words[n]|1<<r:this.words[n]&~(1<<r),this._strip()},s.prototype.iadd=function(t){var e,n,i;if(0!==this.negative&&0===t.negative)return this.negative=0,e=this.isub(t),this.negative^=1,this._normSign();if(0===this.negative&&0!==t.negative)return t.negative=0,e=this.isub(t),t.negative=1,e._normSign();this.length>t.length?(n=this,i=t):(n=t,i=this);for(var r=0,s=0;s<i.length;s++)e=(0|n.words[s])+(0|i.words[s])+r,this.words[s]=67108863&e,r=e>>>26;for(;0!==r&&s<n.length;s++)e=(0|n.words[s])+r,this.words[s]=67108863&e,r=e>>>26;if(this.length=n.length,0!==r)this.words[this.length]=r,this.length++;else if(n!==this)for(;s<n.length;s++)this.words[s]=n.words[s];return this},s.prototype.add=function(t){var e;return 0!==t.negative&&0===this.negative?(t.negative=0,e=this.sub(t),t.negative^=1,e):0===t.negative&&0!==this.negative?(this.negative=0,e=t.sub(this),this.negative=1,e):this.length>t.length?this.clone().iadd(t):t.clone().iadd(this)},s.prototype.isub=function(t){if(0!==t.negative){t.negative=0;var e=this.iadd(t);return t.negative=1,e._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(t),this.negative=1,this._normSign();var n,i,r=this.cmp(t);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(n=this,i=t):(n=t,i=this);for(var s=0,o=0;o<i.length;o++)s=(e=(0|n.words[o])-(0|i.words[o])+s)>>26,this.words[o]=67108863&e;for(;0!==s&&o<n.length;o++)s=(e=(0|n.words[o])+s)>>26,this.words[o]=67108863&e;if(0===s&&o<n.length&&n!==this)for(;o<n.length;o++)this.words[o]=n.words[o];return this.length=Math.max(this.length,o),n!==this&&(this.negative=1),this._strip()},s.prototype.sub=function(t){return this.clone().isub(t)};var g=function(t,e,n){var i,r,s,o=t.words,a=e.words,u=n.words,h=0,l=0|o[0],c=8191&l,d=l>>>13,f=0|o[1],p=8191&f,m=f>>>13,g=0|o[2],_=8191&g,v=g>>>13,w=0|o[3],y=8191&w,C=w>>>13,S=0|o[4],T=8191&S,P=S>>>13,R=0|o[5],E=8191&R,b=R>>>13,M=0|o[6],k=8191&M,A=M>>>13,I=0|o[7],F=8191&I,D=I>>>13,x=0|o[8],O=8191&x,G=x>>>13,N=0|o[9],B=8191&N,L=N>>>13,q=0|a[0],U=8191&q,K=q>>>13,H=0|a[1],Y=8191&H,W=H>>>13,V=0|a[2],j=8191&V,z=V>>>13,Z=0|a[3],J=8191&Z,X=Z>>>13,$=0|a[4],Q=8191&$,tt=$>>>13,et=0|a[5],nt=8191&et,it=et>>>13,rt=0|a[6],st=8191&rt,ot=rt>>>13,at=0|a[7],ut=8191&at,ht=at>>>13,lt=0|a[8],ct=8191<,dt=lt>>>13,ft=0|a[9],pt=8191&ft,mt=ft>>>13;n.negative=t.negative^e.negative,n.length=19;var gt=(h+(i=Math.imul(c,U))|0)+((8191&(r=(r=Math.imul(c,K))+Math.imul(d,U)|0))<<13)|0;h=((s=Math.imul(d,K))+(r>>>13)|0)+(gt>>>26)|0,gt&=67108863,i=Math.imul(p,U),r=(r=Math.imul(p,K))+Math.imul(m,U)|0,s=Math.imul(m,K);var _t=(h+(i=i+Math.imul(c,Y)|0)|0)+((8191&(r=(r=r+Math.imul(c,W)|0)+Math.imul(d,Y)|0))<<13)|0;h=((s=s+Math.imul(d,W)|0)+(r>>>13)|0)+(_t>>>26)|0,_t&=67108863,i=Math.imul(_,U),r=(r=Math.imul(_,K))+Math.imul(v,U)|0,s=Math.imul(v,K),i=i+Math.imul(p,Y)|0,r=(r=r+Math.imul(p,W)|0)+Math.imul(m,Y)|0,s=s+Math.imul(m,W)|0;var vt=(h+(i=i+Math.imul(c,j)|0)|0)+((8191&(r=(r=r+Math.imul(c,z)|0)+Math.imul(d,j)|0))<<13)|0;h=((s=s+Math.imul(d,z)|0)+(r>>>13)|0)+(vt>>>26)|0,vt&=67108863,i=Math.imul(y,U),r=(r=Math.imul(y,K))+Math.imul(C,U)|0,s=Math.imul(C,K),i=i+Math.imul(_,Y)|0,r=(r=r+Math.imul(_,W)|0)+Math.imul(v,Y)|0,s=s+Math.imul(v,W)|0,i=i+Math.imul(p,j)|0,r=(r=r+Math.imul(p,z)|0)+Math.imul(m,j)|0,s=s+Math.imul(m,z)|0;var wt=(h+(i=i+Math.imul(c,J)|0)|0)+((8191&(r=(r=r+Math.imul(c,X)|0)+Math.imul(d,J)|0))<<13)|0;h=((s=s+Math.imul(d,X)|0)+(r>>>13)|0)+(wt>>>26)|0,wt&=67108863,i=Math.imul(T,U),r=(r=Math.imul(T,K))+Math.imul(P,U)|0,s=Math.imul(P,K),i=i+Math.imul(y,Y)|0,r=(r=r+Math.imul(y,W)|0)+Math.imul(C,Y)|0,s=s+Math.imul(C,W)|0,i=i+Math.imul(_,j)|0,r=(r=r+Math.imul(_,z)|0)+Math.imul(v,j)|0,s=s+Math.imul(v,z)|0,i=i+Math.imul(p,J)|0,r=(r=r+Math.imul(p,X)|0)+Math.imul(m,J)|0,s=s+Math.imul(m,X)|0;var yt=(h+(i=i+Math.imul(c,Q)|0)|0)+((8191&(r=(r=r+Math.imul(c,tt)|0)+Math.imul(d,Q)|0))<<13)|0;h=((s=s+Math.imul(d,tt)|0)+(r>>>13)|0)+(yt>>>26)|0,yt&=67108863,i=Math.imul(E,U),r=(r=Math.imul(E,K))+Math.imul(b,U)|0,s=Math.imul(b,K),i=i+Math.imul(T,Y)|0,r=(r=r+Math.imul(T,W)|0)+Math.imul(P,Y)|0,s=s+Math.imul(P,W)|0,i=i+Math.imul(y,j)|0,r=(r=r+Math.imul(y,z)|0)+Math.imul(C,j)|0,s=s+Math.imul(C,z)|0,i=i+Math.imul(_,J)|0,r=(r=r+Math.imul(_,X)|0)+Math.imul(v,J)|0,s=s+Math.imul(v,X)|0,i=i+Math.imul(p,Q)|0,r=(r=r+Math.imul(p,tt)|0)+Math.imul(m,Q)|0,s=s+Math.imul(m,tt)|0;var Ct=(h+(i=i+Math.imul(c,nt)|0)|0)+((8191&(r=(r=r+Math.imul(c,it)|0)+Math.imul(d,nt)|0))<<13)|0;h=((s=s+Math.imul(d,it)|0)+(r>>>13)|0)+(Ct>>>26)|0,Ct&=67108863,i=Math.imul(k,U),r=(r=Math.imul(k,K))+Math.imul(A,U)|0,s=Math.imul(A,K),i=i+Math.imul(E,Y)|0,r=(r=r+Math.imul(E,W)|0)+Math.imul(b,Y)|0,s=s+Math.imul(b,W)|0,i=i+Math.imul(T,j)|0,r=(r=r+Math.imul(T,z)|0)+Math.imul(P,j)|0,s=s+Math.imul(P,z)|0,i=i+Math.imul(y,J)|0,r=(r=r+Math.imul(y,X)|0)+Math.imul(C,J)|0,s=s+Math.imul(C,X)|0,i=i+Math.imul(_,Q)|0,r=(r=r+Math.imul(_,tt)|0)+Math.imul(v,Q)|0,s=s+Math.imul(v,tt)|0,i=i+Math.imul(p,nt)|0,r=(r=r+Math.imul(p,it)|0)+Math.imul(m,nt)|0,s=s+Math.imul(m,it)|0;var St=(h+(i=i+Math.imul(c,st)|0)|0)+((8191&(r=(r=r+Math.imul(c,ot)|0)+Math.imul(d,st)|0))<<13)|0;h=((s=s+Math.imul(d,ot)|0)+(r>>>13)|0)+(St>>>26)|0,St&=67108863,i=Math.imul(F,U),r=(r=Math.imul(F,K))+Math.imul(D,U)|0,s=Math.imul(D,K),i=i+Math.imul(k,Y)|0,r=(r=r+Math.imul(k,W)|0)+Math.imul(A,Y)|0,s=s+Math.imul(A,W)|0,i=i+Math.imul(E,j)|0,r=(r=r+Math.imul(E,z)|0)+Math.imul(b,j)|0,s=s+Math.imul(b,z)|0,i=i+Math.imul(T,J)|0,r=(r=r+Math.imul(T,X)|0)+Math.imul(P,J)|0,s=s+Math.imul(P,X)|0,i=i+Math.imul(y,Q)|0,r=(r=r+Math.imul(y,tt)|0)+Math.imul(C,Q)|0,s=s+Math.imul(C,tt)|0,i=i+Math.imul(_,nt)|0,r=(r=r+Math.imul(_,it)|0)+Math.imul(v,nt)|0,s=s+Math.imul(v,it)|0,i=i+Math.imul(p,st)|0,r=(r=r+Math.imul(p,ot)|0)+Math.imul(m,st)|0,s=s+Math.imul(m,ot)|0;var Tt=(h+(i=i+Math.imul(c,ut)|0)|0)+((8191&(r=(r=r+Math.imul(c,ht)|0)+Math.imul(d,ut)|0))<<13)|0;h=((s=s+Math.imul(d,ht)|0)+(r>>>13)|0)+(Tt>>>26)|0,Tt&=67108863,i=Math.imul(O,U),r=(r=Math.imul(O,K))+Math.imul(G,U)|0,s=Math.imul(G,K),i=i+Math.imul(F,Y)|0,r=(r=r+Math.imul(F,W)|0)+Math.imul(D,Y)|0,s=s+Math.imul(D,W)|0,i=i+Math.imul(k,j)|0,r=(r=r+Math.imul(k,z)|0)+Math.imul(A,j)|0,s=s+Math.imul(A,z)|0,i=i+Math.imul(E,J)|0,r=(r=r+Math.imul(E,X)|0)+Math.imul(b,J)|0,s=s+Math.imul(b,X)|0,i=i+Math.imul(T,Q)|0,r=(r=r+Math.imul(T,tt)|0)+Math.imul(P,Q)|0,s=s+Math.imul(P,tt)|0,i=i+Math.imul(y,nt)|0,r=(r=r+Math.imul(y,it)|0)+Math.imul(C,nt)|0,s=s+Math.imul(C,it)|0,i=i+Math.imul(_,st)|0,r=(r=r+Math.imul(_,ot)|0)+Math.imul(v,st)|0,s=s+Math.imul(v,ot)|0,i=i+Math.imul(p,ut)|0,r=(r=r+Math.imul(p,ht)|0)+Math.imul(m,ut)|0,s=s+Math.imul(m,ht)|0;var Pt=(h+(i=i+Math.imul(c,ct)|0)|0)+((8191&(r=(r=r+Math.imul(c,dt)|0)+Math.imul(d,ct)|0))<<13)|0;h=((s=s+Math.imul(d,dt)|0)+(r>>>13)|0)+(Pt>>>26)|0,Pt&=67108863,i=Math.imul(B,U),r=(r=Math.imul(B,K))+Math.imul(L,U)|0,s=Math.imul(L,K),i=i+Math.imul(O,Y)|0,r=(r=r+Math.imul(O,W)|0)+Math.imul(G,Y)|0,s=s+Math.imul(G,W)|0,i=i+Math.imul(F,j)|0,r=(r=r+Math.imul(F,z)|0)+Math.imul(D,j)|0,s=s+Math.imul(D,z)|0,i=i+Math.imul(k,J)|0,r=(r=r+Math.imul(k,X)|0)+Math.imul(A,J)|0,s=s+Math.imul(A,X)|0,i=i+Math.imul(E,Q)|0,r=(r=r+Math.imul(E,tt)|0)+Math.imul(b,Q)|0,s=s+Math.imul(b,tt)|0,i=i+Math.imul(T,nt)|0,r=(r=r+Math.imul(T,it)|0)+Math.imul(P,nt)|0,s=s+Math.imul(P,it)|0,i=i+Math.imul(y,st)|0,r=(r=r+Math.imul(y,ot)|0)+Math.imul(C,st)|0,s=s+Math.imul(C,ot)|0,i=i+Math.imul(_,ut)|0,r=(r=r+Math.imul(_,ht)|0)+Math.imul(v,ut)|0,s=s+Math.imul(v,ht)|0,i=i+Math.imul(p,ct)|0,r=(r=r+Math.imul(p,dt)|0)+Math.imul(m,ct)|0,s=s+Math.imul(m,dt)|0;var Rt=(h+(i=i+Math.imul(c,pt)|0)|0)+((8191&(r=(r=r+Math.imul(c,mt)|0)+Math.imul(d,pt)|0))<<13)|0;h=((s=s+Math.imul(d,mt)|0)+(r>>>13)|0)+(Rt>>>26)|0,Rt&=67108863,i=Math.imul(B,Y),r=(r=Math.imul(B,W))+Math.imul(L,Y)|0,s=Math.imul(L,W),i=i+Math.imul(O,j)|0,r=(r=r+Math.imul(O,z)|0)+Math.imul(G,j)|0,s=s+Math.imul(G,z)|0,i=i+Math.imul(F,J)|0,r=(r=r+Math.imul(F,X)|0)+Math.imul(D,J)|0,s=s+Math.imul(D,X)|0,i=i+Math.imul(k,Q)|0,r=(r=r+Math.imul(k,tt)|0)+Math.imul(A,Q)|0,s=s+Math.imul(A,tt)|0,i=i+Math.imul(E,nt)|0,r=(r=r+Math.imul(E,it)|0)+Math.imul(b,nt)|0,s=s+Math.imul(b,it)|0,i=i+Math.imul(T,st)|0,r=(r=r+Math.imul(T,ot)|0)+Math.imul(P,st)|0,s=s+Math.imul(P,ot)|0,i=i+Math.imul(y,ut)|0,r=(r=r+Math.imul(y,ht)|0)+Math.imul(C,ut)|0,s=s+Math.imul(C,ht)|0,i=i+Math.imul(_,ct)|0,r=(r=r+Math.imul(_,dt)|0)+Math.imul(v,ct)|0,s=s+Math.imul(v,dt)|0;var Et=(h+(i=i+Math.imul(p,pt)|0)|0)+((8191&(r=(r=r+Math.imul(p,mt)|0)+Math.imul(m,pt)|0))<<13)|0;h=((s=s+Math.imul(m,mt)|0)+(r>>>13)|0)+(Et>>>26)|0,Et&=67108863,i=Math.imul(B,j),r=(r=Math.imul(B,z))+Math.imul(L,j)|0,s=Math.imul(L,z),i=i+Math.imul(O,J)|0,r=(r=r+Math.imul(O,X)|0)+Math.imul(G,J)|0,s=s+Math.imul(G,X)|0,i=i+Math.imul(F,Q)|0,r=(r=r+Math.imul(F,tt)|0)+Math.imul(D,Q)|0,s=s+Math.imul(D,tt)|0,i=i+Math.imul(k,nt)|0,r=(r=r+Math.imul(k,it)|0)+Math.imul(A,nt)|0,s=s+Math.imul(A,it)|0,i=i+Math.imul(E,st)|0,r=(r=r+Math.imul(E,ot)|0)+Math.imul(b,st)|0,s=s+Math.imul(b,ot)|0,i=i+Math.imul(T,ut)|0,r=(r=r+Math.imul(T,ht)|0)+Math.imul(P,ut)|0,s=s+Math.imul(P,ht)|0,i=i+Math.imul(y,ct)|0,r=(r=r+Math.imul(y,dt)|0)+Math.imul(C,ct)|0,s=s+Math.imul(C,dt)|0;var bt=(h+(i=i+Math.imul(_,pt)|0)|0)+((8191&(r=(r=r+Math.imul(_,mt)|0)+Math.imul(v,pt)|0))<<13)|0;h=((s=s+Math.imul(v,mt)|0)+(r>>>13)|0)+(bt>>>26)|0,bt&=67108863,i=Math.imul(B,J),r=(r=Math.imul(B,X))+Math.imul(L,J)|0,s=Math.imul(L,X),i=i+Math.imul(O,Q)|0,r=(r=r+Math.imul(O,tt)|0)+Math.imul(G,Q)|0,s=s+Math.imul(G,tt)|0,i=i+Math.imul(F,nt)|0,r=(r=r+Math.imul(F,it)|0)+Math.imul(D,nt)|0,s=s+Math.imul(D,it)|0,i=i+Math.imul(k,st)|0,r=(r=r+Math.imul(k,ot)|0)+Math.imul(A,st)|0,s=s+Math.imul(A,ot)|0,i=i+Math.imul(E,ut)|0,r=(r=r+Math.imul(E,ht)|0)+Math.imul(b,ut)|0,s=s+Math.imul(b,ht)|0,i=i+Math.imul(T,ct)|0,r=(r=r+Math.imul(T,dt)|0)+Math.imul(P,ct)|0,s=s+Math.imul(P,dt)|0;var Mt=(h+(i=i+Math.imul(y,pt)|0)|0)+((8191&(r=(r=r+Math.imul(y,mt)|0)+Math.imul(C,pt)|0))<<13)|0;h=((s=s+Math.imul(C,mt)|0)+(r>>>13)|0)+(Mt>>>26)|0,Mt&=67108863,i=Math.imul(B,Q),r=(r=Math.imul(B,tt))+Math.imul(L,Q)|0,s=Math.imul(L,tt),i=i+Math.imul(O,nt)|0,r=(r=r+Math.imul(O,it)|0)+Math.imul(G,nt)|0,s=s+Math.imul(G,it)|0,i=i+Math.imul(F,st)|0,r=(r=r+Math.imul(F,ot)|0)+Math.imul(D,st)|0,s=s+Math.imul(D,ot)|0,i=i+Math.imul(k,ut)|0,r=(r=r+Math.imul(k,ht)|0)+Math.imul(A,ut)|0,s=s+Math.imul(A,ht)|0,i=i+Math.imul(E,ct)|0,r=(r=r+Math.imul(E,dt)|0)+Math.imul(b,ct)|0,s=s+Math.imul(b,dt)|0;var kt=(h+(i=i+Math.imul(T,pt)|0)|0)+((8191&(r=(r=r+Math.imul(T,mt)|0)+Math.imul(P,pt)|0))<<13)|0;h=((s=s+Math.imul(P,mt)|0)+(r>>>13)|0)+(kt>>>26)|0,kt&=67108863,i=Math.imul(B,nt),r=(r=Math.imul(B,it))+Math.imul(L,nt)|0,s=Math.imul(L,it),i=i+Math.imul(O,st)|0,r=(r=r+Math.imul(O,ot)|0)+Math.imul(G,st)|0,s=s+Math.imul(G,ot)|0,i=i+Math.imul(F,ut)|0,r=(r=r+Math.imul(F,ht)|0)+Math.imul(D,ut)|0,s=s+Math.imul(D,ht)|0,i=i+Math.imul(k,ct)|0,r=(r=r+Math.imul(k,dt)|0)+Math.imul(A,ct)|0,s=s+Math.imul(A,dt)|0;var At=(h+(i=i+Math.imul(E,pt)|0)|0)+((8191&(r=(r=r+Math.imul(E,mt)|0)+Math.imul(b,pt)|0))<<13)|0;h=((s=s+Math.imul(b,mt)|0)+(r>>>13)|0)+(At>>>26)|0,At&=67108863,i=Math.imul(B,st),r=(r=Math.imul(B,ot))+Math.imul(L,st)|0,s=Math.imul(L,ot),i=i+Math.imul(O,ut)|0,r=(r=r+Math.imul(O,ht)|0)+Math.imul(G,ut)|0,s=s+Math.imul(G,ht)|0,i=i+Math.imul(F,ct)|0,r=(r=r+Math.imul(F,dt)|0)+Math.imul(D,ct)|0,s=s+Math.imul(D,dt)|0;var It=(h+(i=i+Math.imul(k,pt)|0)|0)+((8191&(r=(r=r+Math.imul(k,mt)|0)+Math.imul(A,pt)|0))<<13)|0;h=((s=s+Math.imul(A,mt)|0)+(r>>>13)|0)+(It>>>26)|0,It&=67108863,i=Math.imul(B,ut),r=(r=Math.imul(B,ht))+Math.imul(L,ut)|0,s=Math.imul(L,ht),i=i+Math.imul(O,ct)|0,r=(r=r+Math.imul(O,dt)|0)+Math.imul(G,ct)|0,s=s+Math.imul(G,dt)|0;var Ft=(h+(i=i+Math.imul(F,pt)|0)|0)+((8191&(r=(r=r+Math.imul(F,mt)|0)+Math.imul(D,pt)|0))<<13)|0;h=((s=s+Math.imul(D,mt)|0)+(r>>>13)|0)+(Ft>>>26)|0,Ft&=67108863,i=Math.imul(B,ct),r=(r=Math.imul(B,dt))+Math.imul(L,ct)|0,s=Math.imul(L,dt);var Dt=(h+(i=i+Math.imul(O,pt)|0)|0)+((8191&(r=(r=r+Math.imul(O,mt)|0)+Math.imul(G,pt)|0))<<13)|0;h=((s=s+Math.imul(G,mt)|0)+(r>>>13)|0)+(Dt>>>26)|0,Dt&=67108863;var xt=(h+(i=Math.imul(B,pt))|0)+((8191&(r=(r=Math.imul(B,mt))+Math.imul(L,pt)|0))<<13)|0;return h=((s=Math.imul(L,mt))+(r>>>13)|0)+(xt>>>26)|0,xt&=67108863,u[0]=gt,u[1]=_t,u[2]=vt,u[3]=wt,u[4]=yt,u[5]=Ct,u[6]=St,u[7]=Tt,u[8]=Pt,u[9]=Rt,u[10]=Et,u[11]=bt,u[12]=Mt,u[13]=kt,u[14]=At,u[15]=It,u[16]=Ft,u[17]=Dt,u[18]=xt,0!==h&&(u[19]=h,n.length++),n};function _(t,e,n){n.negative=e.negative^t.negative,n.length=t.length+e.length;for(var i=0,r=0,s=0;s<n.length-1;s++){var o=r;r=0;for(var a=67108863&i,u=Math.min(s,e.length-1),h=Math.max(0,s-t.length+1);h<=u;h++){var l=s-h,c=(0|t.words[l])*(0|e.words[h]),d=67108863&c;a=67108863&(d=d+a|0),r+=(o=(o=o+(c/67108864|0)|0)+(d>>>26)|0)>>>26,o&=67108863}n.words[s]=a,i=o,o=r}return 0!==i?n.words[s]=i:n.length--,n._strip()}function v(t,e,n){return _(t,e,n)}function w(t,e){this.x=t,this.y=e}Math.imul||(g=m),s.prototype.mulTo=function(t,e){var n=this.length+t.length;return 10===this.length&&10===t.length?g(this,t,e):n<63?m(this,t,e):n<1024?_(this,t,e):v(this,t,e)},w.prototype.makeRBT=function(t){for(var e=new Array(t),n=s.prototype._countBits(t)-1,i=0;i<t;i++)e[i]=this.revBin(i,n,t);return e},w.prototype.revBin=function(t,e,n){if(0===t||t===n-1)return t;for(var i=0,r=0;r<e;r++)i|=(1&t)<<e-r-1,t>>=1;return i},w.prototype.permute=function(t,e,n,i,r,s){for(var o=0;o<s;o++)i[o]=e[t[o]],r[o]=n[t[o]]},w.prototype.transform=function(t,e,n,i,r,s){this.permute(s,t,e,n,i,r);for(var o=1;o<r;o<<=1)for(var a=o<<1,u=Math.cos(2*Math.PI/a),h=Math.sin(2*Math.PI/a),l=0;l<r;l+=a)for(var c=u,d=h,f=0;f<o;f++){var p=n[l+f],m=i[l+f],g=n[l+f+o],_=i[l+f+o],v=c*g-d*_;_=c*_+d*g,g=v,n[l+f]=p+g,i[l+f]=m+_,n[l+f+o]=p-g,i[l+f+o]=m-_,f!==a&&(v=u*c-h*d,d=u*d+h*c,c=v)}},w.prototype.guessLen13b=function(t,e){var n=1|Math.max(e,t),i=1&n,r=0;for(n=n/2|0;n;n>>>=1)r++;return 1<<r+1+i},w.prototype.conjugate=function(t,e,n){if(!(n<=1))for(var i=0;i<n/2;i++){var r=t[i];t[i]=t[n-i-1],t[n-i-1]=r,r=e[i],e[i]=-e[n-i-1],e[n-i-1]=-r}},w.prototype.normalize13b=function(t,e){for(var n=0,i=0;i<e/2;i++){var r=8192*Math.round(t[2*i+1]/e)+Math.round(t[2*i]/e)+n;t[i]=67108863&r,n=r<67108864?0:r/67108864|0}return t},w.prototype.convert13b=function(t,e,n,r){for(var s=0,o=0;o<e;o++)s+=0|t[o],n[2*o]=8191&s,s>>>=13,n[2*o+1]=8191&s,s>>>=13;for(o=2*e;o<r;++o)n[o]=0;i(0===s),i(0==(-8192&s))},w.prototype.stub=function(t){for(var e=new Array(t),n=0;n<t;n++)e[n]=0;return e},w.prototype.mulp=function(t,e,n){var i=2*this.guessLen13b(t.length,e.length),r=this.makeRBT(i),s=this.stub(i),o=new Array(i),a=new Array(i),u=new Array(i),h=new Array(i),l=new Array(i),c=new Array(i),d=n.words;d.length=i,this.convert13b(t.words,t.length,o,i),this.convert13b(e.words,e.length,h,i),this.transform(o,s,a,u,i,r),this.transform(h,s,l,c,i,r);for(var f=0;f<i;f++){var p=a[f]*l[f]-u[f]*c[f];u[f]=a[f]*c[f]+u[f]*l[f],a[f]=p}return this.conjugate(a,u,i),this.transform(a,u,d,s,i,r),this.conjugate(d,s,i),this.normalize13b(d,i),n.negative=t.negative^e.negative,n.length=t.length+e.length,n._strip()},s.prototype.mul=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),this.mulTo(t,e)},s.prototype.mulf=function(t){var e=new s(null);return e.words=new Array(this.length+t.length),v(this,t,e)},s.prototype.imul=function(t){return this.clone().mulTo(t,this)},s.prototype.imuln=function(t){var e=t<0;e&&(t=-t),i("number"==typeof t),i(t<67108864);for(var n=0,r=0;r<this.length;r++){var s=(0|this.words[r])*t,o=(67108863&s)+(67108863&n);n>>=26,n+=s/67108864|0,n+=o>>>26,this.words[r]=67108863&o}return 0!==n&&(this.words[r]=n,this.length++),e?this.ineg():this},s.prototype.muln=function(t){return this.clone().imuln(t)},s.prototype.sqr=function(){return this.mul(this)},s.prototype.isqr=function(){return this.imul(this.clone())},s.prototype.pow=function(t){var e=function(t){for(var e=new Array(t.bitLength()),n=0;n<e.length;n++){var i=n/26|0,r=n%26;e[n]=t.words[i]>>>r&1}return e}(t);if(0===e.length)return new s(1);for(var n=this,i=0;i<e.length&&0===e[i];i++,n=n.sqr());if(++i<e.length)for(var r=n.sqr();i<e.length;i++,r=r.sqr())0!==e[i]&&(n=n.mul(r));return n},s.prototype.iushln=function(t){i("number"==typeof t&&t>=0);var e,n=t%26,r=(t-n)/26,s=67108863>>>26-n<<26-n;if(0!==n){var o=0;for(e=0;e<this.length;e++){var a=this.words[e]&s,u=(0|this.words[e])-a<<n;this.words[e]=u|o,o=a>>>26-n}o&&(this.words[e]=o,this.length++)}if(0!==r){for(e=this.length-1;e>=0;e--)this.words[e+r]=this.words[e];for(e=0;e<r;e++)this.words[e]=0;this.length+=r}return this._strip()},s.prototype.ishln=function(t){return i(0===this.negative),this.iushln(t)},s.prototype.iushrn=function(t,e,n){var r;i("number"==typeof t&&t>=0),r=e?(e-e%26)/26:0;var s=t%26,o=Math.min((t-s)/26,this.length),a=67108863^67108863>>>s<<s,u=n;if(r-=o,r=Math.max(0,r),u){for(var h=0;h<o;h++)u.words[h]=this.words[h];u.length=o}if(0===o);else if(this.length>o)for(this.length-=o,h=0;h<this.length;h++)this.words[h]=this.words[h+o];else this.words[0]=0,this.length=1;var l=0;for(h=this.length-1;h>=0&&(0!==l||h>=r);h--){var c=0|this.words[h];this.words[h]=l<<26-s|c>>>s,l=c&a}return u&&0!==l&&(u.words[u.length++]=l),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},s.prototype.ishrn=function(t,e,n){return i(0===this.negative),this.iushrn(t,e,n)},s.prototype.shln=function(t){return this.clone().ishln(t)},s.prototype.ushln=function(t){return this.clone().iushln(t)},s.prototype.shrn=function(t){return this.clone().ishrn(t)},s.prototype.ushrn=function(t){return this.clone().iushrn(t)},s.prototype.testn=function(t){i("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26,r=1<<e;return!(this.length<=n)&&!!(this.words[n]&r)},s.prototype.imaskn=function(t){i("number"==typeof t&&t>=0);var e=t%26,n=(t-e)/26;if(i(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==e&&n++,this.length=Math.min(n,this.length),0!==e){var r=67108863^67108863>>>e<<e;this.words[this.length-1]&=r}return this._strip()},s.prototype.maskn=function(t){return this.clone().imaskn(t)},s.prototype.iaddn=function(t){return i("number"==typeof t),i(t<67108864),t<0?this.isubn(-t):0!==this.negative?1===this.length&&(0|this.words[0])<=t?(this.words[0]=t-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(t),this.negative=1,this):this._iaddn(t)},s.prototype._iaddn=function(t){this.words[0]+=t;for(var e=0;e<this.length&&this.words[e]>=67108864;e++)this.words[e]-=67108864,e===this.length-1?this.words[e+1]=1:this.words[e+1]++;return this.length=Math.max(this.length,e+1),this},s.prototype.isubn=function(t){if(i("number"==typeof t),i(t<67108864),t<0)return this.iaddn(-t);if(0!==this.negative)return this.negative=0,this.iaddn(t),this.negative=1,this;if(this.words[0]-=t,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var e=0;e<this.length&&this.words[e]<0;e++)this.words[e]+=67108864,this.words[e+1]-=1;return this._strip()},s.prototype.addn=function(t){return this.clone().iaddn(t)},s.prototype.subn=function(t){return this.clone().isubn(t)},s.prototype.iabs=function(){return this.negative=0,this},s.prototype.abs=function(){return this.clone().iabs()},s.prototype._ishlnsubmul=function(t,e,n){var r,s,o=t.length+n;this._expand(o);var a=0;for(r=0;r<t.length;r++){s=(0|this.words[r+n])+a;var u=(0|t.words[r])*e;a=((s-=67108863&u)>>26)-(u/67108864|0),this.words[r+n]=67108863&s}for(;r<this.length-n;r++)a=(s=(0|this.words[r+n])+a)>>26,this.words[r+n]=67108863&s;if(0===a)return this._strip();for(i(-1===a),a=0,r=0;r<this.length;r++)a=(s=-(0|this.words[r])+a)>>26,this.words[r]=67108863&s;return this.negative=1,this._strip()},s.prototype._wordDiv=function(t,e){var n=(this.length,t.length),i=this.clone(),r=t,o=0|r.words[r.length-1];0!==(n=26-this._countBits(o))&&(r=r.ushln(n),i.iushln(n),o=0|r.words[r.length-1]);var a,u=i.length-r.length;if("mod"!==e){(a=new s(null)).length=u+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var l=i.clone()._ishlnsubmul(r,1,u);0===l.negative&&(i=l,a&&(a.words[u]=1));for(var c=u-1;c>=0;c--){var d=67108864*(0|i.words[r.length+c])+(0|i.words[r.length+c-1]);for(d=Math.min(d/o|0,67108863),i._ishlnsubmul(r,d,c);0!==i.negative;)d--,i.negative=0,i._ishlnsubmul(r,1,c),i.isZero()||(i.negative^=1);a&&(a.words[c]=d)}return a&&a._strip(),i._strip(),"div"!==e&&0!==n&&i.iushrn(n),{div:a||null,mod:i}},s.prototype.divmod=function(t,e,n){return i(!t.isZero()),this.isZero()?{div:new s(0),mod:new s(0)}:0!==this.negative&&0===t.negative?(a=this.neg().divmod(t,e),"mod"!==e&&(r=a.div.neg()),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.iadd(t)),{div:r,mod:o}):0===this.negative&&0!==t.negative?(a=this.divmod(t.neg(),e),"mod"!==e&&(r=a.div.neg()),{div:r,mod:a.mod}):0!=(this.negative&t.negative)?(a=this.neg().divmod(t.neg(),e),"div"!==e&&(o=a.mod.neg(),n&&0!==o.negative&&o.isub(t)),{div:a.div,mod:o}):t.length>this.length||this.cmp(t)<0?{div:new s(0),mod:this}:1===t.length?"div"===e?{div:this.divn(t.words[0]),mod:null}:"mod"===e?{div:null,mod:new s(this.modrn(t.words[0]))}:{div:this.divn(t.words[0]),mod:new s(this.modrn(t.words[0]))}:this._wordDiv(t,e);var r,o,a},s.prototype.div=function(t){return this.divmod(t,"div",!1).div},s.prototype.mod=function(t){return this.divmod(t,"mod",!1).mod},s.prototype.umod=function(t){return this.divmod(t,"mod",!0).mod},s.prototype.divRound=function(t){var e=this.divmod(t);if(e.mod.isZero())return e.div;var n=0!==e.div.negative?e.mod.isub(t):e.mod,i=t.ushrn(1),r=t.andln(1),s=n.cmp(i);return s<0||1===r&&0===s?e.div:0!==e.div.negative?e.div.isubn(1):e.div.iaddn(1)},s.prototype.modrn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var n=(1<<26)%t,r=0,s=this.length-1;s>=0;s--)r=(n*r+(0|this.words[s]))%t;return e?-r:r},s.prototype.modn=function(t){return this.modrn(t)},s.prototype.idivn=function(t){var e=t<0;e&&(t=-t),i(t<=67108863);for(var n=0,r=this.length-1;r>=0;r--){var s=(0|this.words[r])+67108864*n;this.words[r]=s/t|0,n=s%t}return this._strip(),e?this.ineg():this},s.prototype.divn=function(t){return this.clone().idivn(t)},s.prototype.egcd=function(t){i(0===t.negative),i(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var r=new s(1),o=new s(0),a=new s(0),u=new s(1),h=0;e.isEven()&&n.isEven();)e.iushrn(1),n.iushrn(1),++h;for(var l=n.clone(),c=e.clone();!e.isZero();){for(var d=0,f=1;0==(e.words[0]&f)&&d<26;++d,f<<=1);if(d>0)for(e.iushrn(d);d-- >0;)(r.isOdd()||o.isOdd())&&(r.iadd(l),o.isub(c)),r.iushrn(1),o.iushrn(1);for(var p=0,m=1;0==(n.words[0]&m)&&p<26;++p,m<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(a.isOdd()||u.isOdd())&&(a.iadd(l),u.isub(c)),a.iushrn(1),u.iushrn(1);e.cmp(n)>=0?(e.isub(n),r.isub(a),o.isub(u)):(n.isub(e),a.isub(r),u.isub(o))}return{a:a,b:u,gcd:n.iushln(h)}},s.prototype._invmp=function(t){i(0===t.negative),i(!t.isZero());var e=this,n=t.clone();e=0!==e.negative?e.umod(t):e.clone();for(var r,o=new s(1),a=new s(0),u=n.clone();e.cmpn(1)>0&&n.cmpn(1)>0;){for(var h=0,l=1;0==(e.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(e.iushrn(h);h-- >0;)o.isOdd()&&o.iadd(u),o.iushrn(1);for(var c=0,d=1;0==(n.words[0]&d)&&c<26;++c,d<<=1);if(c>0)for(n.iushrn(c);c-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);e.cmp(n)>=0?(e.isub(n),o.isub(a)):(n.isub(e),a.isub(o))}return(r=0===e.cmpn(1)?o:a).cmpn(0)<0&&r.iadd(t),r},s.prototype.gcd=function(t){if(this.isZero())return t.abs();if(t.isZero())return this.abs();var e=this.clone(),n=t.clone();e.negative=0,n.negative=0;for(var i=0;e.isEven()&&n.isEven();i++)e.iushrn(1),n.iushrn(1);for(;;){for(;e.isEven();)e.iushrn(1);for(;n.isEven();)n.iushrn(1);var r=e.cmp(n);if(r<0){var s=e;e=n,n=s}else if(0===r||0===n.cmpn(1))break;e.isub(n)}return n.iushln(i)},s.prototype.invm=function(t){return this.egcd(t).a.umod(t)},s.prototype.isEven=function(){return 0==(1&this.words[0])},s.prototype.isOdd=function(){return 1==(1&this.words[0])},s.prototype.andln=function(t){return this.words[0]&t},s.prototype.bincn=function(t){i("number"==typeof t);var e=t%26,n=(t-e)/26,r=1<<e;if(this.length<=n)return this._expand(n+1),this.words[n]|=r,this;for(var s=r,o=n;0!==s&&o<this.length;o++){var a=0|this.words[o];s=(a+=s)>>>26,a&=67108863,this.words[o]=a}return 0!==s&&(this.words[o]=s,this.length++),this},s.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},s.prototype.cmpn=function(t){var e,n=t<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this._strip(),this.length>1)e=1;else{n&&(t=-t),i(t<=67108863,"Number is too big");var r=0|this.words[0];e=r===t?0:r<t?-1:1}return 0!==this.negative?0|-e:e},s.prototype.cmp=function(t){if(0!==this.negative&&0===t.negative)return-1;if(0===this.negative&&0!==t.negative)return 1;var e=this.ucmp(t);return 0!==this.negative?0|-e:e},s.prototype.ucmp=function(t){if(this.length>t.length)return 1;if(this.length<t.length)return-1;for(var e=0,n=this.length-1;n>=0;n--){var i=0|this.words[n],r=0|t.words[n];if(i!==r){i<r?e=-1:i>r&&(e=1);break}}return e},s.prototype.gtn=function(t){return 1===this.cmpn(t)},s.prototype.gt=function(t){return 1===this.cmp(t)},s.prototype.gten=function(t){return this.cmpn(t)>=0},s.prototype.gte=function(t){return this.cmp(t)>=0},s.prototype.ltn=function(t){return-1===this.cmpn(t)},s.prototype.lt=function(t){return-1===this.cmp(t)},s.prototype.lten=function(t){return this.cmpn(t)<=0},s.prototype.lte=function(t){return this.cmp(t)<=0},s.prototype.eqn=function(t){return 0===this.cmpn(t)},s.prototype.eq=function(t){return 0===this.cmp(t)},s.red=function(t){return new E(t)},s.prototype.toRed=function(t){return i(!this.red,"Already a number in reduction context"),i(0===this.negative,"red works only with positives"),t.convertTo(this)._forceRed(t)},s.prototype.fromRed=function(){return i(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},s.prototype._forceRed=function(t){return this.red=t,this},s.prototype.forceRed=function(t){return i(!this.red,"Already a number in reduction context"),this._forceRed(t)},s.prototype.redAdd=function(t){return i(this.red,"redAdd works only with red numbers"),this.red.add(this,t)},s.prototype.redIAdd=function(t){return i(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,t)},s.prototype.redSub=function(t){return i(this.red,"redSub works only with red numbers"),this.red.sub(this,t)},s.prototype.redISub=function(t){return i(this.red,"redISub works only with red numbers"),this.red.isub(this,t)},s.prototype.redShl=function(t){return i(this.red,"redShl works only with red numbers"),this.red.shl(this,t)},s.prototype.redMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.mul(this,t)},s.prototype.redIMul=function(t){return i(this.red,"redMul works only with red numbers"),this.red._verify2(this,t),this.red.imul(this,t)},s.prototype.redSqr=function(){return i(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},s.prototype.redISqr=function(){return i(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},s.prototype.redSqrt=function(){return i(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},s.prototype.redInvm=function(){return i(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},s.prototype.redNeg=function(){return i(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},s.prototype.redPow=function(t){return i(this.red&&!t.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,t)};var y={k256:null,p224:null,p192:null,p25519:null};function C(t,e){this.name=t,this.p=new s(e,16),this.n=this.p.bitLength(),this.k=new s(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function S(){C.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function T(){C.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function P(){C.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function R(){C.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(t){if("string"==typeof t){var e=s._prime(t);this.m=e.p,this.prime=e}else i(t.gtn(1),"modulus must be greater than 1"),this.m=t,this.prime=null}function b(t){E.call(this,t),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new s(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)}C.prototype._tmp=function(){var t=new s(null);return t.words=new Array(Math.ceil(this.n/13)),t},C.prototype.ireduce=function(t){var e,n=t;do{this.split(n,this.tmp),e=(n=(n=this.imulK(n)).iadd(this.tmp)).bitLength()}while(e>this.n);var i=e<this.n?-1:n.ucmp(this.p);return 0===i?(n.words[0]=0,n.length=1):i>0?n.isub(this.p):void 0!==n.strip?n.strip():n._strip(),n},C.prototype.split=function(t,e){t.iushrn(this.n,0,e)},C.prototype.imulK=function(t){return t.imul(this.k)},r(S,C),S.prototype.split=function(t,e){for(var n=Math.min(t.length,9),i=0;i<n;i++)e.words[i]=t.words[i];if(e.length=n,t.length<=9)return t.words[0]=0,void(t.length=1);var r=t.words[9];for(e.words[e.length++]=4194303&r,i=10;i<t.length;i++){var s=0|t.words[i];t.words[i-10]=(4194303&s)<<4|r>>>22,r=s}r>>>=22,t.words[i-10]=r,0===r&&t.length>10?t.length-=10:t.length-=9},S.prototype.imulK=function(t){t.words[t.length]=0,t.words[t.length+1]=0,t.length+=2;for(var e=0,n=0;n<t.length;n++){var i=0|t.words[n];e+=977*i,t.words[n]=67108863&e,e=64*i+(e/67108864|0)}return 0===t.words[t.length-1]&&(t.length--,0===t.words[t.length-1]&&t.length--),t},r(T,C),r(P,C),r(R,C),R.prototype.imulK=function(t){for(var e=0,n=0;n<t.length;n++){var i=19*(0|t.words[n])+e,r=67108863&i;i>>>=26,t.words[n]=r,e=i}return 0!==e&&(t.words[t.length++]=e),t},s._prime=function(t){if(y[t])return y[t];var e;if("k256"===t)e=new S;else if("p224"===t)e=new T;else if("p192"===t)e=new P;else{if("p25519"!==t)throw new Error("Unknown prime "+t);e=new R}return y[t]=e,e},E.prototype._verify1=function(t){i(0===t.negative,"red works only with positives"),i(t.red,"red works only with red numbers")},E.prototype._verify2=function(t,e){i(0==(t.negative|e.negative),"red works only with positives"),i(t.red&&t.red===e.red,"red works only with red numbers")},E.prototype.imod=function(t){return this.prime?this.prime.ireduce(t)._forceRed(this):(l(t,t.umod(this.m)._forceRed(this)),t)},E.prototype.neg=function(t){return t.isZero()?t.clone():this.m.sub(t)._forceRed(this)},E.prototype.add=function(t,e){this._verify2(t,e);var n=t.add(e);return n.cmp(this.m)>=0&&n.isub(this.m),n._forceRed(this)},E.prototype.iadd=function(t,e){this._verify2(t,e);var n=t.iadd(e);return n.cmp(this.m)>=0&&n.isub(this.m),n},E.prototype.sub=function(t,e){this._verify2(t,e);var n=t.sub(e);return n.cmpn(0)<0&&n.iadd(this.m),n._forceRed(this)},E.prototype.isub=function(t,e){this._verify2(t,e);var n=t.isub(e);return n.cmpn(0)<0&&n.iadd(this.m),n},E.prototype.shl=function(t,e){return this._verify1(t),this.imod(t.ushln(e))},E.prototype.imul=function(t,e){return this._verify2(t,e),this.imod(t.imul(e))},E.prototype.mul=function(t,e){return this._verify2(t,e),this.imod(t.mul(e))},E.prototype.isqr=function(t){return this.imul(t,t.clone())},E.prototype.sqr=function(t){return this.mul(t,t)},E.prototype.sqrt=function(t){if(t.isZero())return t.clone();var e=this.m.andln(3);if(i(e%2==1),3===e){var n=this.m.add(new s(1)).iushrn(2);return this.pow(t,n)}for(var r=this.m.subn(1),o=0;!r.isZero()&&0===r.andln(1);)o++,r.iushrn(1);i(!r.isZero());var a=new s(1).toRed(this),u=a.redNeg(),h=this.m.subn(1).iushrn(1),l=this.m.bitLength();for(l=new s(2*l*l).toRed(this);0!==this.pow(l,h).cmp(u);)l.redIAdd(u);for(var c=this.pow(l,r),d=this.pow(t,r.addn(1).iushrn(1)),f=this.pow(t,r),p=o;0!==f.cmp(a);){for(var m=f,g=0;0!==m.cmp(a);g++)m=m.redSqr();i(g<p);var _=this.pow(c,new s(1).iushln(p-g-1));d=d.redMul(_),c=_.redSqr(),f=f.redMul(c),p=g}return d},E.prototype.invm=function(t){var e=t._invmp(this.m);return 0!==e.negative?(e.negative=0,this.imod(e).redNeg()):this.imod(e)},E.prototype.pow=function(t,e){if(e.isZero())return new s(1).toRed(this);if(0===e.cmpn(1))return t.clone();var n=new Array(16);n[0]=new s(1).toRed(this),n[1]=t;for(var i=2;i<n.length;i++)n[i]=this.mul(n[i-1],t);var r=n[0],o=0,a=0,u=e.bitLength()%26;for(0===u&&(u=26),i=e.length-1;i>=0;i--){for(var h=e.words[i],l=u-1;l>=0;l--){var c=h>>l&1;r!==n[0]&&(r=this.sqr(r)),0!==c||0!==o?(o<<=1,o|=c,(4===++a||0===i&&0===l)&&(r=this.mul(r,n[o]),a=0,o=0)):a=0}u=26}return r},E.prototype.convertTo=function(t){var e=t.umod(this.m);return e===t?e.clone():e},E.prototype.convertFrom=function(t){var e=t.clone();return e.red=null,e},s.mont=function(t){return new b(t)},r(b,E),b.prototype.convertTo=function(t){return this.imod(t.ushln(this.shift))},b.prototype.convertFrom=function(t){var e=this.imod(t.mul(this.rinv));return e.red=null,e},b.prototype.imul=function(t,e){if(t.isZero()||e.isZero())return t.words[0]=0,t.length=1,t;var n=t.imul(e),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),s=r;return r.cmp(this.m)>=0?s=r.isub(this.m):r.cmpn(0)<0&&(s=r.iadd(this.m)),s._forceRed(this)},b.prototype.mul=function(t,e){if(t.isZero()||e.isZero())return new s(0)._forceRed(this);var n=t.mul(e),i=n.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=n.isub(i).iushrn(this.shift),o=r;return r.cmp(this.m)>=0?o=r.isub(this.m):r.cmpn(0)<0&&(o=r.iadd(this.m)),o._forceRed(this)},b.prototype.invm=function(t){return this.imod(t._invmp(this.m).mul(this.r2))._forceRed(this)}}(t,this)}).call(this,n(7)(t))},function(t,e,n){var i=function(t){"use strict";var e=Object.prototype,n=e.hasOwnProperty,i="function"==typeof Symbol?Symbol:{},r=i.iterator||"@@iterator",s=i.asyncIterator||"@@asyncIterator",o=i.toStringTag||"@@toStringTag";function a(t,e,n){return Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{a({},"")}catch(t){a=function(t,e,n){return t[e]=n}}function u(t,e,n,i){var r=e&&e.prototype instanceof c?e:c,s=Object.create(r.prototype),o=new T(i||[]);return s._invoke=function(t,e,n){var i="suspendedStart";return function(r,s){if("executing"===i)throw new Error("Generator is already running");if("completed"===i){if("throw"===r)throw s;return R()}for(n.method=r,n.arg=s;;){var o=n.delegate;if(o){var a=y(o,n);if(a){if(a===l)continue;return a}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===i)throw i="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i="executing";var u=h(t,e,n);if("normal"===u.type){if(i=n.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:n.done}}"throw"===u.type&&(i="completed",n.method="throw",n.arg=u.arg)}}}(t,n,o),s}function h(t,e,n){try{return{type:"normal",arg:t.call(e,n)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var l={};function c(){}function d(){}function f(){}var p={};a(p,r,(function(){return this}));var m=Object.getPrototypeOf,g=m&&m(m(P([])));g&&g!==e&&n.call(g,r)&&(p=g);var _=f.prototype=c.prototype=Object.create(p);function v(t){["next","throw","return"].forEach((function(e){a(t,e,(function(t){return this._invoke(e,t)}))}))}function w(t,e){var i;this._invoke=function(r,s){function o(){return new e((function(i,o){!function i(r,s,o,a){var u=h(t[r],t,s);if("throw"!==u.type){var l=u.arg,c=l.value;return c&&"object"==typeof c&&n.call(c,"__await")?e.resolve(c.__await).then((function(t){i("next",t,o,a)}),(function(t){i("throw",t,o,a)})):e.resolve(c).then((function(t){l.value=t,o(l)}),(function(t){return i("throw",t,o,a)}))}a(u.arg)}(r,s,i,o)}))}return i=i?i.then(o,o):o()}}function y(t,e){var n=t.iterator[e.method];if(void 0===n){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,y(t,e),"throw"===e.method))return l;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var i=h(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,l;var r=i.arg;return r?r.done?(e[t.resultName]=r.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,l):r:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,l)}function C(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function S(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(C,this),this.reset(!0)}function P(t){if(t){var e=t[r];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var i=-1,s=function e(){for(;++i<t.length;)if(n.call(t,i))return e.value=t[i],e.done=!1,e;return e.value=void 0,e.done=!0,e};return s.next=s}}return{next:R}}function R(){return{value:void 0,done:!0}}return d.prototype=f,a(_,"constructor",f),a(f,"constructor",d),d.displayName=a(f,o,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,f):(t.__proto__=f,a(t,o,"GeneratorFunction")),t.prototype=Object.create(_),t},t.awrap=function(t){return{__await:t}},v(w.prototype),a(w.prototype,s,(function(){return this})),t.AsyncIterator=w,t.async=function(e,n,i,r,s){void 0===s&&(s=Promise);var o=new w(u(e,n,i,r),s);return t.isGeneratorFunction(n)?o:o.next().then((function(t){return t.done?t.value:o.next()}))},v(_),a(_,o,"Generator"),a(_,r,(function(){return this})),a(_,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=[];for(var n in t)e.push(n);return e.reverse(),function n(){for(;e.length;){var i=e.pop();if(i in t)return n.value=i,n.done=!1,n}return n.done=!0,n}},t.values=P,T.prototype={constructor:T,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(S),!t)for(var e in this)"t"===e.charAt(0)&&n.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function i(n,i){return o.type="throw",o.arg=t,e.next=n,i&&(e.method="next",e.arg=void 0),!!i}for(var r=this.tryEntries.length-1;r>=0;--r){var s=this.tryEntries[r],o=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var a=n.call(s,"catchLoc"),u=n.call(s,"finallyLoc");if(a&&u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(a){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var i=this.tryEntries.length-1;i>=0;--i){var r=this.tryEntries[i];if(r.tryLoc<=this.prev&&n.call(r,"finallyLoc")&&this.prev<r.finallyLoc){var s=r;break}}s&&("break"===t||"continue"===t)&&s.tryLoc<=e&&e<=s.finallyLoc&&(s=null);var o=s?s.completion:{};return o.type=t,o.arg=e,s?(this.method="next",this.next=s.finallyLoc,l):this.complete(o)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),l},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.finallyLoc===t)return this.complete(n.completion,n.afterLoc),S(n),l}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var n=this.tryEntries[e];if(n.tryLoc===t){var i=n.completion;if("throw"===i.type){var r=i.arg;S(n)}return r}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,n){return this.delegate={iterator:P(t),resultName:e,nextLoc:n},"next"===this.method&&(this.arg=void 0),l}},t}(t.exports);try{regeneratorRuntime=i}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},function(t,e){t.exports=function(t){return t.webpackPolyfill||(t.deprecate=function(){},t.paths=[],t.children||(t.children=[]),Object.defineProperty(t,"loaded",{enumerable:!0,get:function(){return t.l}}),Object.defineProperty(t,"id",{enumerable:!0,get:function(){return t.i}}),t.webpackPolyfill=1),t}},function(t,e){},function(t,e,n){"use strict";n.r(e),n.d(e,"Spi",(function(){return qi})),n.d(e,"Logger",(function(){return Ui})),n.d(e,"Secrets",(function(){return ze})),n.d(e,"SuccessState",(function(){return Ee})),n.d(e,"TransactionOptions",(function(){return Be})),n.d(e,"TransactionType",(function(){return Fe})),n.d(e,"SpiFlow",(function(){return Ae})),n.d(e,"SpiStatus",(function(){return ke})),n.d(e,"TransactionFlowState",(function(){return Oe})),n.d(e,"PrintingResponse",(function(){return bi})),n.d(e,"RefundResponse",(function(){return _n})),n.d(e,"PurchaseResponse",(function(){return hn})),n.d(e,"GetLastTransactionResponse",(function(){return mn})),n.d(e,"MotoPurchaseResponse",(function(){return Sn})),n.d(e,"TransactionUpdate",(function(){return Rn})),n.d(e,"TerminalStatusResponse",(function(){return Di})),n.d(e,"TerminalBattery",(function(){return xi})),n.d(e,"TerminalConfigurationRequest",(function(){return Oi})),n.d(e,"TerminalConfigurationResponse",(function(){return Gi})),n.d(e,"CashoutOnlyResponse",(function(){return ai})),n.d(e,"Settlement",(function(){return hi})),n.d(e,"RequestIdHelper",(function(){return qe})),n.d(e,"DeviceAddressResponseCode",(function(){return Ci})),n.d(e,"ReversalResponse",(function(){return ki})),n.d(e,"BillStatusResponse",(function(){return En})),n.d(e,"BillRetrievalResult",(function(){return bn})),n.d(e,"GetOpenTablesResponse",(function(){return In})),n.d(e,"OpenTablesEntry",(function(){return Fn})),n.d(e,"BillPaymentFlowEndedResponse",(function(){return Dn})),n.d(e,"AccountVerifyResponse",(function(){return Xn})),n.d(e,"PreauthResponse",(function(){return ri}));var i=n(3),r=n.n(i),s=n(0),o=n.n(s),a=n(1),u=n.n(a),h=n(2),l=n.n(h),c=function(){function t(){o()(this,t),this.PosVendorId=null,this.PosVersion=null,this.LibraryLanguage=null,this.LibraryVersion=null,this.PosRefId=null,this.SerialNumber=null,this.Event=null,this.TxType=null,this.TxResult=null,this.TxStartTime=null,this.TxEndTime=null,this.DurationMs=null,this.CurrentFlow=null,this.CurrentTxFlowState=null,this.CurrentStatus=null}return u()(t,[{key:"ToMessage",value:function(){return{pos_vendor_id:this.PosVendorId,pos_version:this.PosVersion,library_language:this.LibraryLanguage,library_version:this.LibraryVersion,pos_ref_id:this.PosRefId,serial_number:this.SerialNumber,event:this.Event,tx_type:this.TxType,tx_result:this.TxResult,tx_start_ts_ms:this.TxStartTime,tx_end_ts_ms:this.TxEndTime,duration_ms:this.DurationMs,current_flow:this.CurrentFlow,current_tx_flow_state:this.CurrentTxFlowState,current_status:this.CurrentStatus}}}]),t}(),d=function(){function t(){o()(this,t)}var e;return u()(t,null,[{key:"ReportTransaction",value:(e=r()(l.a.mark((function t(e){var n,i,r,s,o,a,u,h=arguments;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=h.length>1&&void 0!==h[1]?h[1]:"spi-sample-pos1",i=h.length>2?h[2]:void 0,r=h.length>3?h[3]:void 0,s=r?"https://spi-analytics-api-sb.".concat(i,".mspenv.io/v1/report-transaction"):"https://spi-analytics-api.".concat(i,".mspenv.io/v1/report-transaction"),o=e.ToMessage(),t.next=7,fetch(s,{method:"POST",headers:{"ASM-MSP-DEVICE-ADDRESS-API-KEY":n,"Content-Type":"application/json"},body:JSON.stringify(o)});case 7:if((a=t.sent).ok){t.next=13;break}return t.next=11,a.json();case 11:throw u=t.sent,Error("Status code ".concat(a.status," received from ").concat(s," - Error ").concat(u.error&&u.error.message));case 13:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})}]),t}();const f="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";function p(t,e,n,i){let r,s,o;const a=e||[0],u=(n=n||0)>>>3,h=-1===i?3:0;for(r=0;r<t.length;r+=1)o=r+u,s=o>>>2,a.length<=s&&a.push(0),a[s]|=t[r]<<8*(h+i*(o%4));return{value:a,binLen:8*t.length+n}}function m(t,e,n){switch(e){case"UTF8":case"UTF16BE":case"UTF16LE":break;default:throw new Error("encoding must be UTF8, UTF16BE, or UTF16LE")}switch(t){case"HEX":return function(t,e,i){return function(t,e,n,i){let r,s,o,a;if(0!=t.length%2)throw new Error("String of HEX type must be in byte increments");const u=e||[0],h=(n=n||0)>>>3,l=-1===i?3:0;for(r=0;r<t.length;r+=2){if(s=parseInt(t.substr(r,2),16),isNaN(s))throw new Error("String of HEX type contains invalid characters");for(a=(r>>>1)+h,o=a>>>2;u.length<=o;)u.push(0);u[o]|=s<<8*(l+i*(a%4))}return{value:u,binLen:4*t.length+n}}(t,e,i,n)};case"TEXT":return function(t,i,r){return function(t,e,n,i,r){let s,o,a,u,h,l,c,d,f=0;const p=n||[0],m=(i=i||0)>>>3;if("UTF8"===e)for(c=-1===r?3:0,a=0;a<t.length;a+=1)for(s=t.charCodeAt(a),o=[],128>s?o.push(s):2048>s?(o.push(192|s>>>6),o.push(128|63&s)):55296>s||57344<=s?o.push(224|s>>>12,128|s>>>6&63,128|63&s):(a+=1,s=65536+((1023&s)<<10|1023&t.charCodeAt(a)),o.push(240|s>>>18,128|s>>>12&63,128|s>>>6&63,128|63&s)),u=0;u<o.length;u+=1){for(l=f+m,h=l>>>2;p.length<=h;)p.push(0);p[h]|=o[u]<<8*(c+r*(l%4)),f+=1}else for(c=-1===r?2:0,d="UTF16LE"===e&&1!==r||"UTF16LE"!==e&&1===r,a=0;a<t.length;a+=1){for(s=t.charCodeAt(a),!0===d&&(u=255&s,s=u<<8|s>>>8),l=f+m,h=l>>>2;p.length<=h;)p.push(0);p[h]|=s<<8*(c+r*(l%4)),f+=2}return{value:p,binLen:8*f+i}}(t,e,i,r,n)};case"B64":return function(t,e,i){return function(t,e,n,i){let r,s,o,a,u,h,l,c=0;const d=e||[0],p=(n=n||0)>>>3,m=-1===i?3:0,g=t.indexOf("=");if(-1===t.search(/^[a-zA-Z0-9=+/]+$/))throw new Error("Invalid character in base-64 string");if(t=t.replace(/=/g,""),-1!==g&&g<t.length)throw new Error("Invalid '=' found in base-64 string");for(s=0;s<t.length;s+=4){for(u=t.substr(s,4),a=0,o=0;o<u.length;o+=1)r=f.indexOf(u.charAt(o)),a|=r<<18-6*o;for(o=0;o<u.length-1;o+=1){for(l=c+p,h=l>>>2;d.length<=h;)d.push(0);d[h]|=(a>>>16-8*o&255)<<8*(m+i*(l%4)),c+=1}}return{value:d,binLen:8*c+n}}(t,e,i,n)};case"BYTES":return function(t,e,i){return function(t,e,n,i){let r,s,o,a;const u=e||[0],h=(n=n||0)>>>3,l=-1===i?3:0;for(s=0;s<t.length;s+=1)r=t.charCodeAt(s),a=s+h,o=a>>>2,u.length<=o&&u.push(0),u[o]|=r<<8*(l+i*(a%4));return{value:u,binLen:8*t.length+n}}(t,e,i,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t,e,i){return function(t,e,n,i){return p(new Uint8Array(t),e,n,i)}(t,e,i,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t,e,i){return p(t,e,i,n)};default:throw new Error("format must be HEX, TEXT, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}function g(t,e,n,i){switch(t){case"HEX":return function(t){return function(t,e,n,i){let r,s,o="";const a=e/8,u=-1===n?3:0;for(r=0;r<a;r+=1)s=t[r>>>2]>>>8*(u+n*(r%4)),o+="0123456789abcdef".charAt(s>>>4&15)+"0123456789abcdef".charAt(15&s);return i.outputUpper?o.toUpperCase():o}(t,e,n,i)};case"B64":return function(t){return function(t,e,n,i){let r,s,o,a,u,h="";const l=e/8,c=-1===n?3:0;for(r=0;r<l;r+=3)for(a=r+1<l?t[r+1>>>2]:0,u=r+2<l?t[r+2>>>2]:0,o=(t[r>>>2]>>>8*(c+n*(r%4))&255)<<16|(a>>>8*(c+n*((r+1)%4))&255)<<8|u>>>8*(c+n*((r+2)%4))&255,s=0;s<4;s+=1)h+=8*r+6*s<=e?f.charAt(o>>>6*(3-s)&63):i.b64Pad;return h}(t,e,n,i)};case"BYTES":return function(t){return function(t,e,n){let i,r,s="";const o=e/8,a=-1===n?3:0;for(i=0;i<o;i+=1)r=t[i>>>2]>>>8*(a+n*(i%4))&255,s+=String.fromCharCode(r);return s}(t,e,n)};case"ARRAYBUFFER":try{new ArrayBuffer(0)}catch(t){throw new Error("ARRAYBUFFER not supported by this environment")}return function(t){return function(t,e,n){let i;const r=e/8,s=new ArrayBuffer(r),o=new Uint8Array(s),a=-1===n?3:0;for(i=0;i<r;i+=1)o[i]=t[i>>>2]>>>8*(a+n*(i%4))&255;return s}(t,e,n)};case"UINT8ARRAY":try{new Uint8Array(0)}catch(t){throw new Error("UINT8ARRAY not supported by this environment")}return function(t){return function(t,e,n){let i;const r=e/8,s=-1===n?3:0,o=new Uint8Array(r);for(i=0;i<r;i+=1)o[i]=t[i>>>2]>>>8*(s+n*(i%4))&255;return o}(t,e,n)};default:throw new Error("format must be HEX, B64, BYTES, ARRAYBUFFER, or UINT8ARRAY")}}const _=[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],v=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428],w=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],y="Chosen SHA variant is not supported";function C(t,e){let n,i;const r=t.binLen>>>3,s=e.binLen>>>3,o=r<<3,a=4-r<<3;if(r%4!=0){for(n=0;n<s;n+=4)i=r+n>>>2,t.value[i]|=e.value[n>>>2]<<o,t.value.push(0),t.value[i+1]|=e.value[n>>>2]>>>a;return(t.value.length<<2)-4>=s+r&&t.value.pop(),{value:t.value,binLen:t.binLen+e.binLen}}return{value:t.value.concat(e.value),binLen:t.binLen+e.binLen}}function S(t){const e={outputUpper:!1,b64Pad:"=",outputLen:-1},n=t||{},i="Output length must be a multiple of 8";if(e.outputUpper=n.outputUpper||!1,n.b64Pad&&(e.b64Pad=n.b64Pad),n.outputLen){if(n.outputLen%8!=0)throw new Error(i);e.outputLen=n.outputLen}else if(n.shakeLen){if(n.shakeLen%8!=0)throw new Error(i);e.outputLen=n.shakeLen}if("boolean"!=typeof e.outputUpper)throw new Error("Invalid outputUpper formatting option");if("string"!=typeof e.b64Pad)throw new Error("Invalid b64Pad formatting option");return e}function T(t,e,n,i){const r=t+" must include a value and format";if(!e){if(!i)throw new Error(r);return i}if(void 0===e.value||!e.format)throw new Error(r);return m(e.format,e.encoding||"UTF8",n)(e.value)}class P{constructor(t,e,n){const i=n||{};if(this.t=e,this.i=i.encoding||"UTF8",this.numRounds=i.numRounds||1,isNaN(this.numRounds)||this.numRounds!==parseInt(this.numRounds,10)||1>this.numRounds)throw new Error("numRounds must a integer >= 1");this.s=t,this.o=[],this.h=0,this.u=!1,this.l=0,this.A=!1,this.H=[],this.S=[]}update(t){let e,n=0;const i=this.p>>>5,r=this.m(t,this.o,this.h),s=r.binLen,o=r.value,a=s>>>5;for(e=0;e<a;e+=i)n+this.p<=s&&(this.C=this.R(o.slice(e,e+i),this.C),n+=this.p);this.l+=n,this.o=o.slice(n>>>5),this.h=s%this.p,this.u=!0}getHash(t,e){let n,i,r=this.U;const s=S(e);if(this.v){if(-1===s.outputLen)throw new Error("Output length must be specified in options");r=s.outputLen}const o=g(t,r,this.K,s);if(this.A&&this.T)return o(this.T(s));for(i=this.F(this.o.slice(),this.h,this.l,this.g(this.C),r),n=1;n<this.numRounds;n+=1)this.v&&r%32!=0&&(i[i.length-1]&=16777215>>>24-r%32),i=this.F(i,r,0,this.B(this.s),r);return o(i)}setHMACKey(t,e,n){if(!this.L)throw new Error("Variant does not support HMAC");if(this.u)throw new Error("Cannot set MAC key after calling update");const i=m(e,(n||{}).encoding||"UTF8",this.K);this.M(i(t))}M(t){const e=this.p>>>3,n=e/4-1;let i;if(1!==this.numRounds)throw new Error("Cannot set numRounds with MAC");if(this.A)throw new Error("MAC key already set");for(e<t.binLen/8&&(t.value=this.F(t.value,t.binLen,0,this.B(this.s),this.U));t.value.length<=n;)t.value.push(0);for(i=0;i<=n;i+=1)this.H[i]=909522486^t.value[i],this.S[i]=1549556828^t.value[i];this.C=this.R(this.H,this.C),this.l=this.p,this.A=!0}getHMAC(t,e){const n=S(e);return g(t,this.U,this.K,n)(this.k())}k(){let t;if(!this.A)throw new Error("Cannot call getHMAC without first setting MAC key");const e=this.F(this.o.slice(),this.h,this.l,this.g(this.C),this.U);return t=this.R(this.S,this.B(this.s)),t=this.F(e,this.U,this.p,t,this.U),t}}function R(t,e){return t<<e|t>>>32-e}function E(t,e){return t>>>e|t<<32-e}function b(t,e){return t>>>e}function M(t,e,n){return t^e^n}function k(t,e,n){return t&e^~t&n}function A(t,e,n){return t&e^t&n^e&n}function I(t){return E(t,2)^E(t,13)^E(t,22)}function F(t,e){const n=(65535&t)+(65535&e);return(65535&(t>>>16)+(e>>>16)+(n>>>16))<<16|65535&n}function D(t,e,n,i){const r=(65535&t)+(65535&e)+(65535&n)+(65535&i);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(i>>>16)+(r>>>16))<<16|65535&r}function x(t,e,n,i,r){const s=(65535&t)+(65535&e)+(65535&n)+(65535&i)+(65535&r);return(65535&(t>>>16)+(e>>>16)+(n>>>16)+(i>>>16)+(r>>>16)+(s>>>16))<<16|65535&s}function O(t){return E(t,7)^E(t,18)^b(t,3)}function G(t){return E(t,6)^E(t,11)^E(t,25)}function N(t){return[1732584193,4023233417,2562383102,271733878,3285377520]}function B(t,e){let n,i,r,s,o,a,u;const h=[];for(n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],u=0;u<80;u+=1)h[u]=u<16?t[u]:R(h[u-3]^h[u-8]^h[u-14]^h[u-16],1),a=u<20?x(R(n,5),k(i,r,s),o,1518500249,h[u]):u<40?x(R(n,5),M(i,r,s),o,1859775393,h[u]):u<60?x(R(n,5),A(i,r,s),o,2400959708,h[u]):x(R(n,5),M(i,r,s),o,3395469782,h[u]),o=s,s=r,r=R(i,30),i=n,n=a;return e[0]=F(n,e[0]),e[1]=F(i,e[1]),e[2]=F(r,e[2]),e[3]=F(s,e[3]),e[4]=F(o,e[4]),e}function L(t,e,n,i){let r;const s=15+(e+65>>>9<<4),o=e+n;for(;t.length<=s;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[s]=4294967295&o,t[s-1]=o/4294967296|0,r=0;r<t.length;r+=16)i=B(t.slice(r,r+16),i);return i}class q extends P{constructor(t,e,n){if("SHA-1"!==t)throw new Error(y);super(t,e,n);const i=n||{};this.L=!0,this.T=this.k,this.K=-1,this.m=m(this.t,this.i,this.K),this.R=B,this.g=function(t){return t.slice()},this.B=N,this.F=L,this.C=[1732584193,4023233417,2562383102,271733878,3285377520],this.p=512,this.U=160,this.v=!1,i.hmacKey&&this.M(T("hmacKey",i.hmacKey,this.K))}}function U(t){let e;return e="SHA-224"==t?v.slice():w.slice(),e}function K(t,e){let n,i,r,s,o,a,u,h,l,c,d;const f=[];for(n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],u=e[6],h=e[7],d=0;d<64;d+=1)f[d]=d<16?t[d]:D(E(p=f[d-2],17)^E(p,19)^b(p,10),f[d-7],O(f[d-15]),f[d-16]),l=x(h,G(o),k(o,a,u),_[d],f[d]),c=F(I(n),A(n,i,r)),h=u,u=a,a=o,o=F(s,l),s=r,r=i,i=n,n=F(l,c);var p;return e[0]=F(n,e[0]),e[1]=F(i,e[1]),e[2]=F(r,e[2]),e[3]=F(s,e[3]),e[4]=F(o,e[4]),e[5]=F(a,e[5]),e[6]=F(u,e[6]),e[7]=F(h,e[7]),e}class H extends P{constructor(t,e,n){if("SHA-224"!==t&&"SHA-256"!==t)throw new Error(y);super(t,e,n);const i=n||{};this.T=this.k,this.L=!0,this.K=-1,this.m=m(this.t,this.i,this.K),this.R=K,this.g=function(t){return t.slice()},this.B=U,this.F=function(e,n,i,r){return function(t,e,n,i,r){let s,o;const a=15+(e+65>>>9<<4),u=e+n;for(;t.length<=a;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[a]=4294967295&u,t[a-1]=u/4294967296|0,s=0;s<t.length;s+=16)i=K(t.slice(s,s+16),i);return o="SHA-224"===r?[i[0],i[1],i[2],i[3],i[4],i[5],i[6]]:i,o}(e,n,i,r,t)},this.C=U(t),this.p=512,this.U="SHA-224"===t?224:256,this.v=!1,i.hmacKey&&this.M(T("hmacKey",i.hmacKey,this.K))}}class Y{constructor(t,e){this.Y=t,this.N=e}}function W(t,e){let n;return e>32?(n=64-e,new Y(t.N<<e|t.Y>>>n,t.Y<<e|t.N>>>n)):0!==e?(n=32-e,new Y(t.Y<<e|t.N>>>n,t.N<<e|t.Y>>>n)):t}function V(t,e){let n;return e<32?(n=32-e,new Y(t.Y>>>e|t.N<<n,t.N>>>e|t.Y<<n)):(n=64-e,new Y(t.N>>>e|t.Y<<n,t.Y>>>e|t.N<<n))}function j(t,e){return new Y(t.Y>>>e,t.N>>>e|t.Y<<32-e)}function z(t,e,n){return new Y(t.Y&e.Y^t.Y&n.Y^e.Y&n.Y,t.N&e.N^t.N&n.N^e.N&n.N)}function Z(t){const e=V(t,28),n=V(t,34),i=V(t,39);return new Y(e.Y^n.Y^i.Y,e.N^n.N^i.N)}function J(t,e){let n,i;n=(65535&t.N)+(65535&e.N),i=(t.N>>>16)+(e.N>>>16)+(n>>>16);const r=(65535&i)<<16|65535&n;return n=(65535&t.Y)+(65535&e.Y)+(i>>>16),i=(t.Y>>>16)+(e.Y>>>16)+(n>>>16),new Y((65535&i)<<16|65535&n,r)}function X(t,e,n,i){let r,s;r=(65535&t.N)+(65535&e.N)+(65535&n.N)+(65535&i.N),s=(t.N>>>16)+(e.N>>>16)+(n.N>>>16)+(i.N>>>16)+(r>>>16);const o=(65535&s)<<16|65535&r;return r=(65535&t.Y)+(65535&e.Y)+(65535&n.Y)+(65535&i.Y)+(s>>>16),s=(t.Y>>>16)+(e.Y>>>16)+(n.Y>>>16)+(i.Y>>>16)+(r>>>16),new Y((65535&s)<<16|65535&r,o)}function $(t,e,n,i,r){let s,o;s=(65535&t.N)+(65535&e.N)+(65535&n.N)+(65535&i.N)+(65535&r.N),o=(t.N>>>16)+(e.N>>>16)+(n.N>>>16)+(i.N>>>16)+(r.N>>>16)+(s>>>16);const a=(65535&o)<<16|65535&s;return s=(65535&t.Y)+(65535&e.Y)+(65535&n.Y)+(65535&i.Y)+(65535&r.Y)+(o>>>16),o=(t.Y>>>16)+(e.Y>>>16)+(n.Y>>>16)+(i.Y>>>16)+(r.Y>>>16)+(s>>>16),new Y((65535&o)<<16|65535&s,a)}function Q(t,e){return new Y(t.Y^e.Y,t.N^e.N)}function tt(t){const e=V(t,19),n=V(t,61),i=j(t,6);return new Y(e.Y^n.Y^i.Y,e.N^n.N^i.N)}function et(t){const e=V(t,1),n=V(t,8),i=j(t,7);return new Y(e.Y^n.Y^i.Y,e.N^n.N^i.N)}function nt(t){const e=V(t,14),n=V(t,18),i=V(t,41);return new Y(e.Y^n.Y^i.Y,e.N^n.N^i.N)}const it=[new Y(_[0],3609767458),new Y(_[1],602891725),new Y(_[2],3964484399),new Y(_[3],2173295548),new Y(_[4],4081628472),new Y(_[5],3053834265),new Y(_[6],2937671579),new Y(_[7],3664609560),new Y(_[8],2734883394),new Y(_[9],1164996542),new Y(_[10],1323610764),new Y(_[11],3590304994),new Y(_[12],4068182383),new Y(_[13],991336113),new Y(_[14],633803317),new Y(_[15],3479774868),new Y(_[16],2666613458),new Y(_[17],944711139),new Y(_[18],2341262773),new Y(_[19],2007800933),new Y(_[20],1495990901),new Y(_[21],1856431235),new Y(_[22],3175218132),new Y(_[23],2198950837),new Y(_[24],3999719339),new Y(_[25],766784016),new Y(_[26],2566594879),new Y(_[27],3203337956),new Y(_[28],1034457026),new Y(_[29],2466948901),new Y(_[30],3758326383),new Y(_[31],168717936),new Y(_[32],1188179964),new Y(_[33],1546045734),new Y(_[34],1522805485),new Y(_[35],2643833823),new Y(_[36],2343527390),new Y(_[37],1014477480),new Y(_[38],1206759142),new Y(_[39],344077627),new Y(_[40],1290863460),new Y(_[41],3158454273),new Y(_[42],3505952657),new Y(_[43],106217008),new Y(_[44],3606008344),new Y(_[45],1432725776),new Y(_[46],1467031594),new Y(_[47],851169720),new Y(_[48],3100823752),new Y(_[49],1363258195),new Y(_[50],3750685593),new Y(_[51],3785050280),new Y(_[52],3318307427),new Y(_[53],3812723403),new Y(_[54],2003034995),new Y(_[55],3602036899),new Y(_[56],1575990012),new Y(_[57],1125592928),new Y(_[58],2716904306),new Y(_[59],442776044),new Y(_[60],593698344),new Y(_[61],3733110249),new Y(_[62],2999351573),new Y(_[63],3815920427),new Y(3391569614,3928383900),new Y(3515267271,566280711),new Y(3940187606,3454069534),new Y(4118630271,4000239992),new Y(116418474,1914138554),new Y(174292421,2731055270),new Y(289380356,3203993006),new Y(460393269,320620315),new Y(685471733,587496836),new Y(852142971,1086792851),new Y(1017036298,365543100),new Y(1126000580,2618297676),new Y(1288033470,3409855158),new Y(1501505948,4234509866),new Y(1607167915,987167468),new Y(1816402316,1246189591)];function rt(t){return"SHA-384"===t?[new Y(3418070365,v[0]),new Y(1654270250,v[1]),new Y(2438529370,v[2]),new Y(355462360,v[3]),new Y(1731405415,v[4]),new Y(41048885895,v[5]),new Y(3675008525,v[6]),new Y(1203062813,v[7])]:[new Y(w[0],4089235720),new Y(w[1],2227873595),new Y(w[2],4271175723),new Y(w[3],1595750129),new Y(w[4],2917565137),new Y(w[5],725511199),new Y(w[6],4215389547),new Y(w[7],327033209)]}function st(t,e){let n,i,r,s,o,a,u,h,l,c,d,f;const p=[];for(n=e[0],i=e[1],r=e[2],s=e[3],o=e[4],a=e[5],u=e[6],h=e[7],d=0;d<80;d+=1)d<16?(f=2*d,p[d]=new Y(t[f],t[f+1])):p[d]=X(tt(p[d-2]),p[d-7],et(p[d-15]),p[d-16]),l=$(h,nt(o),(g=a,_=u,new Y((m=o).Y&g.Y^~m.Y&_.Y,m.N&g.N^~m.N&_.N)),it[d],p[d]),c=J(Z(n),z(n,i,r)),h=u,u=a,a=o,o=J(s,l),s=r,r=i,i=n,n=J(l,c);var m,g,_;return e[0]=J(n,e[0]),e[1]=J(i,e[1]),e[2]=J(r,e[2]),e[3]=J(s,e[3]),e[4]=J(o,e[4]),e[5]=J(a,e[5]),e[6]=J(u,e[6]),e[7]=J(h,e[7]),e}class ot extends P{constructor(t,e,n){if("SHA-384"!==t&&"SHA-512"!==t)throw new Error(y);super(t,e,n);const i=n||{};this.T=this.k,this.L=!0,this.K=-1,this.m=m(this.t,this.i,this.K),this.R=st,this.g=function(t){return t.slice()},this.B=rt,this.F=function(e,n,i,r){return function(t,e,n,i,r){let s,o;const a=31+(e+129>>>10<<5),u=e+n;for(;t.length<=a;)t.push(0);for(t[e>>>5]|=128<<24-e%32,t[a]=4294967295&u,t[a-1]=u/4294967296|0,s=0;s<t.length;s+=32)i=st(t.slice(s,s+32),i);return o="SHA-384"===r?[(i=i)[0].Y,i[0].N,i[1].Y,i[1].N,i[2].Y,i[2].N,i[3].Y,i[3].N,i[4].Y,i[4].N,i[5].Y,i[5].N]:[i[0].Y,i[0].N,i[1].Y,i[1].N,i[2].Y,i[2].N,i[3].Y,i[3].N,i[4].Y,i[4].N,i[5].Y,i[5].N,i[6].Y,i[6].N,i[7].Y,i[7].N],o}(e,n,i,r,t)},this.C=rt(t),this.p=1024,this.U="SHA-384"===t?384:512,this.v=!1,i.hmacKey&&this.M(T("hmacKey",i.hmacKey,this.K))}}const at=[new Y(0,1),new Y(0,32898),new Y(2147483648,32906),new Y(2147483648,2147516416),new Y(0,32907),new Y(0,2147483649),new Y(2147483648,2147516545),new Y(2147483648,32777),new Y(0,138),new Y(0,136),new Y(0,2147516425),new Y(0,2147483658),new Y(0,2147516555),new Y(2147483648,139),new Y(2147483648,32905),new Y(2147483648,32771),new Y(2147483648,32770),new Y(2147483648,128),new Y(0,32778),new Y(2147483648,2147483658),new Y(2147483648,2147516545),new Y(2147483648,32896),new Y(0,2147483649),new Y(2147483648,2147516424)],ut=[[0,36,3,41,18],[1,44,10,45,2],[62,6,43,15,61],[28,55,25,21,56],[27,20,39,8,14]];function ht(t){let e;const n=[];for(e=0;e<5;e+=1)n[e]=[new Y(0,0),new Y(0,0),new Y(0,0),new Y(0,0),new Y(0,0)];return n}function lt(t){let e;const n=[];for(e=0;e<5;e+=1)n[e]=t[e].slice();return n}function ct(t,e){let n,i,r,s;const o=[],a=[];if(null!==t)for(i=0;i<t.length;i+=2)e[(i>>>1)%5][(i>>>1)/5|0]=Q(e[(i>>>1)%5][(i>>>1)/5|0],new Y(t[i+1],t[i]));for(n=0;n<24;n+=1){for(s=ht(),i=0;i<5;i+=1)o[i]=(u=e[i][0],h=e[i][1],l=e[i][2],c=e[i][3],d=e[i][4],new Y(u.Y^h.Y^l.Y^c.Y^d.Y,u.N^h.N^l.N^c.N^d.N));for(i=0;i<5;i+=1)a[i]=Q(o[(i+4)%5],W(o[(i+1)%5],1));for(i=0;i<5;i+=1)for(r=0;r<5;r+=1)e[i][r]=Q(e[i][r],a[i]);for(i=0;i<5;i+=1)for(r=0;r<5;r+=1)s[r][(2*i+3*r)%5]=W(e[i][r],ut[i][r]);for(i=0;i<5;i+=1)for(r=0;r<5;r+=1)e[i][r]=Q(s[i][r],new Y(~s[(i+1)%5][r].Y&s[(i+2)%5][r].Y,~s[(i+1)%5][r].N&s[(i+2)%5][r].N));e[0][0]=Q(e[0][0],at[n])}var u,h,l,c,d;return e}function dt(t){let e,n,i=0;const r=[0,0],s=[4294967295&t,t/4294967296&2097151];for(e=6;e>=0;e--)n=s[e>>2]>>>8*e&255,0===n&&0===i||(r[i+1>>2]|=n<<8*(i+1),i+=1);return i=0!==i?i:1,r[0]|=i,{value:i+1>4?r:[r[0]],binLen:8+8*i}}function ft(t){return C(dt(t.binLen),t)}function pt(t,e){let n,i=dt(e);i=C(i,t);const r=e>>>2,s=(r-i.value.length%r)%r;for(n=0;n<s;n++)i.value.push(0);return i.value}class mt extends P{constructor(t,e,n){let i=6,r=0;super(t,e,n);const s=n||{};if(1!==this.numRounds){if(s.kmacKey||s.hmacKey)throw new Error("Cannot set numRounds with MAC");if("CSHAKE128"===this.s||"CSHAKE256"===this.s)throw new Error("Cannot set numRounds for CSHAKE variants")}switch(this.K=1,this.m=m(this.t,this.i,this.K),this.R=ct,this.g=lt,this.B=ht,this.C=ht(),this.v=!1,t){case"SHA3-224":this.p=r=1152,this.U=224,this.L=!0,this.T=this.k;break;case"SHA3-256":this.p=r=1088,this.U=256,this.L=!0,this.T=this.k;break;case"SHA3-384":this.p=r=832,this.U=384,this.L=!0,this.T=this.k;break;case"SHA3-512":this.p=r=576,this.U=512,this.L=!0,this.T=this.k;break;case"SHAKE128":i=31,this.p=r=1344,this.U=-1,this.v=!0,this.L=!1,this.T=null;break;case"SHAKE256":i=31,this.p=r=1088,this.U=-1,this.v=!0,this.L=!1,this.T=null;break;case"KMAC128":i=4,this.p=r=1344,this.I(n),this.U=-1,this.v=!0,this.L=!1,this.T=this.X;break;case"KMAC256":i=4,this.p=r=1088,this.I(n),this.U=-1,this.v=!0,this.L=!1,this.T=this.X;break;case"CSHAKE128":this.p=r=1344,i=this._(n),this.U=-1,this.v=!0,this.L=!1,this.T=null;break;case"CSHAKE256":this.p=r=1088,i=this._(n),this.U=-1,this.v=!0,this.L=!1,this.T=null;break;default:throw new Error(y)}this.F=function(t,e,n,s,o){return function(t,e,n,i,r,s,o){let a,u,h=0;const l=[],c=r>>>5,d=e>>>5;for(a=0;a<d&&e>=r;a+=c)i=ct(t.slice(a,a+c),i),e-=r;for(t=t.slice(a),e%=r;t.length<c;)t.push(0);for(a=e>>>3,t[a>>2]^=s<<a%4*8,t[c-1]^=2147483648,i=ct(t,i);32*l.length<o&&(u=i[h%5][h/5|0],l.push(u.N),!(32*l.length>=o));)l.push(u.Y),h+=1,0==64*h%r&&(ct(null,i),h=0);return l}(t,e,0,s,r,i,o)},s.hmacKey&&this.M(T("hmacKey",s.hmacKey,this.K))}_(t,e){const n=function(t){const e=t||{};return{funcName:T("funcName",e.funcName,1,{value:[],binLen:0}),customization:T("Customization",e.customization,1,{value:[],binLen:0})}}(t||{});e&&(n.funcName=e);const i=C(ft(n.funcName),ft(n.customization));if(0!==n.customization.binLen||0!==n.funcName.binLen){const t=pt(i,this.p>>>3);for(let e=0;e<t.length;e+=this.p>>>5)this.C=this.R(t.slice(e,e+(this.p>>>5)),this.C),this.l+=this.p;return 4}return 31}I(t){const e=function(t){const e=t||{};return{kmacKey:T("kmacKey",e.kmacKey,1),funcName:{value:[1128353099],binLen:32},customization:T("Customization",e.customization,1,{value:[],binLen:0})}}(t||{});this._(t,e.funcName);const n=pt(ft(e.kmacKey),this.p>>>3);for(let t=0;t<n.length;t+=this.p>>>5)this.C=this.R(n.slice(t,t+(this.p>>>5)),this.C),this.l+=this.p;this.A=!0}X(t){const e=C({value:this.o.slice(),binLen:this.h},function(t){let e,n,i=0;const r=[0,0],s=[4294967295&t,t/4294967296&2097151];for(e=6;e>=0;e--)n=s[e>>2]>>>8*e&255,0===n&&0===i||(r[i>>2]|=n<<8*i,i+=1);return i=0!==i?i:1,r[i>>2]|=i<<8*i,{value:i+1>4?r:[r[0]],binLen:8+8*i}}(t.outputLen));return this.F(e.value,e.binLen,this.l,this.g(this.C),t.outputLen)}}var gt=class{constructor(t,e,n){if("SHA-1"==t)this.O=new q(t,e,n);else if("SHA-224"==t||"SHA-256"==t)this.O=new H(t,e,n);else if("SHA-384"==t||"SHA-512"==t)this.O=new ot(t,e,n);else{if("SHA3-224"!=t&&"SHA3-256"!=t&&"SHA3-384"!=t&&"SHA3-512"!=t&&"SHAKE128"!=t&&"SHAKE256"!=t&&"CSHAKE128"!=t&&"CSHAKE256"!=t&&"KMAC128"!=t&&"KMAC256"!=t)throw new Error(y);this.O=new mt(t,e,n)}}update(t){this.O.update(t)}getHash(t,e){return this.O.getHash(t,e)}setHMACKey(t,e,n){this.O.setHMACKey(t,e,n)}getHMAC(t,e){return this.O.getHMAC(t,e)}},_t=n(4),vt=n.n(_t),wt=function(){function t(){o()(this,t)}return u()(t,null,[{key:"AesEncrypt",value:function(t,e){var n=vt.a.utils.hex.toBytes(t),i=vt.a.padding.pkcs7.pad(vt.a.utils.utf8.toBytes(e)),r=new vt.a.ModeOfOperation.cbc(n,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).encrypt(i);return vt.a.utils.hex.fromBytes(r)}},{key:"AesDecrypt",value:function(t,e){var n=vt.a.utils.hex.toBytes(t),i=vt.a.utils.hex.toBytes(e),r=new vt.a.ModeOfOperation.cbc(n,[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]).decrypt(i);return vt.a.utils.utf8.fromBytes(vt.a.padding.pkcs7.strip(r))}},{key:"HmacSignature",value:function(t,e){var n=new gt("SHA-256","TEXT");return n.setHMACKey(t,"HEX"),n.update(e),n.getHMAC("HEX")}},{key:"GenerateHash",value:function(t){var e=new gt("SHA-256","HEX");return e.update(t),e.getHash("HEX")}}]),t}(),yt="pair_request",Ct="key_request",St="key_response",Tt="key_check",Pt="pair_response",Rt="drop_keys",Et="ping",bt="pong",Mt="purchase",kt="purchase_response",At="cancel_transaction",It="cancel_response",Ft="get_last_transaction",Dt="last_transaction",xt="get_transaction",Ot="get_transaction_response",Gt="reverse_transaction",Nt="reverse_transaction_response",Bt="refund",Lt="refund_response",qt="signature_required",Ut="signature_decline",Kt="signature_accept",Ht="authorisation_code_required",Yt="authorisation_code_advice",Wt="cash",Vt="cash_response",jt="moto_purchase",zt="moto_purchase_response",Zt="settle",Jt="settle_response",Xt="settlement_enquiry",$t="settlement_enquiry_response",Qt="set_pos_info",te="set_pos_info_response",ee="request_use_next_keys",ne="response_use_next_keys",ie="error",re="_INVALID_SIGNATURE_",se="get_table_config",oe="set_table_config",ae="get_bill_details",ue="bill_details",he="bill_payment",le="get_open_tables",ce="open_tables",de="bill_payment_flow_ended",fe="bill_payment_flow_ended_ack",pe="print",me="print_response",ge="txn_update_message",_e="get_terminal_status",ve="terminal_status",we="get_terminal_configuration",ye="terminal_configuration",Ce="battery_level_changed",Se="purchase_zip",Te="purchase_zip_response",Pe="refund_zip",Re="refund_zip_response",Ee={Unknown:"Unknown",Success:"Success",Failed:"Failed"},be=function(){function t(e,n){o()(this,t),this.PosId=e,this.Secrets=n,this.ConnId=null,this.PosCounter=null}return u()(t,[{key:"ResetConnection",value:function(){this.min=100,this.max=99999,this.SetConnectionId(""),this.PosCounter=Math.floor(Math.random()*(this.max-this.min+1)+this.min)}},{key:"SetConnectionId",value:function(t){null!==t&&(this.ConnId=t)}}]),t}(),Me=function(){function t(e,n,i,r){o()(this,t),this.Id=e,this.EventName=n,this.Data=i,this.DateTimeStamp="",this.PosCounter="",this.ConnId="",this.PosId="",this.IncommingHmac="",this._needsEncryption=r,this.DecryptedJson=""}return u()(t,[{key:"GetSuccessState",value:function(){return this.Data&&void 0!==this.Data.success?this.Data.success?Ee.Success:Ee.Failed:Ee.Unknown}},{key:"GetError",value:function(){return this.Data.error_reason?this.Data.error_reason:""}},{key:"GetErrorDetail",value:function(){return this.Data.error_detail}},{key:"ToJson",value:function(t){this.DateTimeStamp=(new Date).toISOString(),this.PosCounter=t.PosCounter++,this.ConnId=t.ConnId,this.PosId=t.PosId;var e={message:{id:this.Id,event:this.EventName,data:this.Data,datetime:this.DateTimeStamp,pos_counter:this.PosCounter,pos_id:this.PosId,conn_id:this.ConnId}};if(this.DecryptedJson=JSON.stringify(e),!this._needsEncryption)return this.DecryptedJson;var n=wt.AesEncrypt(t.Secrets.EncKey,this.DecryptedJson),i={enc:n,hmac:wt.HmacSignature(t.Secrets.HmacKey,n).toUpperCase(),pos_id:t.PosId};return JSON.stringify(i)}}],[{key:"ParseBankDate",value:function(t){return 8!==t.length?null:new Date("".concat(t.substr(4,4),"-").concat(t.substr(2,2),"-").concat(t.substr(0,2)))}},{key:"ParseBankDateTimeStr",value:function(t,e){return new Date("".concat(t.substr(0,2)," ").concat(t.substr(2,3)," ").concat(t.substr(5,2)," ").concat(e))}},{key:"FromJson",value:function(e,n){var i=JSON.parse(e);if(null!=i.message){var r=new t(i.message.id,i.message.event,i.message.data,!1);return r.DecryptedJson=e,r}if(null==n)return new t("UNKNOWN","NOSECRETS",null,!1);if(wt.HmacSignature(n.HmacKey,i.enc).toUpperCase()!=i.hmac)return new t("_",re,null,!1);var s=wt.AesDecrypt(n.EncKey,i.enc);try{var o=JSON.parse(s),a=new t(o.message.id,o.message.event,o.message.data,!0);return a.DateTimeStamp=o.message.datetime,a.PosId=o.message.pos_id,a.IncomingHmac=i.hmac,a.DecryptedJson=s,a.ConnId=o.message.conn_id,a}catch(e){return new t("UNKNOWN","UNPARSEABLE",{msg:s},!1)}}}]),t}(),ke={PairedConnected:"PairedConnected",PairedConnecting:"PairedConnecting",Unpaired:"Unpaired"},Ae={Pairing:"Pairing",Transaction:"Transaction",Idle:"Idle"},Ie=function t(e){o()(this,t),this.Message=null,this.AwaitingCheckFromEftpos=null,this.AwaitingCheckFromPos=null,this.ConfirmationCode=null,this.Finished=null,this.Successful=null,e&&Object.assign(this,e)},Fe={AccountVerify:"AccountVerify",CashoutOnly:"CashoutOnly",GetTransaction:"GetTransaction",GetLastTransaction:"GetLastTransaction",MOTO:"MOTO",Preauth:"Preauth",Purchase:"Purchase",Refund:"Refund",Reversal:"Reversal",Settle:"Settle",SettlementEnquiry:"SettlementEnquiry",ZipPurchase:"ZipPurchase",ZipRefund:"ZipRefund"},De=function t(e,n){o()(this,t),this.Initiated=e,this.Message=n},xe=function t(e,n){o()(this,t),this.Valid=e,this.Message=n},Oe=function(){function t(e,n,i,r,s){o()(this,t),this.PosRefId=e,this.Id=e,this.Type=n,this.DisplayMessage=s,this.AmountCents=i,this.RequestSent=!1,this.RequestTime=null,this.LastStateRequestTime=null,this.GtRequestId=null,this.AttemptingToCancel=null,this.AwaitingSignatureCheck=!1,this.AwaitingPhoneForAuth=null,this.Finished=!1,this.Success=Ee.Unknown,this.Response=null,this.SignatureRequiredMessage=null,this.PhoneForAuthRequiredMessage=null,this.CancelAttemptTime=null,this.Request=r,this.AwaitingGtResponse=null,this.CompletedTime=null}return u()(t,[{key:"Sent",value:function(t){this.RequestSent=!0,this.RequestTime=Date.now(),this.LastStateRequestTime=Date.now(),this.DisplayMessage=t}},{key:"Cancelling",value:function(t){this.AttemptingToCancel=!0,this.CancelAttemptTime=Date.now(),this.DisplayMessage=t}},{key:"CancelFailed",value:function(t){this.AttemptingToCancel=!1,this.DisplayMessage=t}},{key:"CallingGt",value:function(t){this.AwaitingGtResponse=!0,this.LastStateRequestTime=Date.now(),this.GtRequestId=t}},{key:"GotGtResponse",value:function(){this.AwaitingGtResponse=!1}},{key:"Failed",value:function(t,e){this.Success=Ee.Failed,this.Finished=!0,this.Response=t,this.DisplayMessage=e,this.CompletedTime=Date.now()}},{key:"SignatureRequired",value:function(t,e){this.SignatureRequiredMessage=t,this.AwaitingSignatureCheck=!0,this.DisplayMessage=e}},{key:"SignatureResponded",value:function(t){this.AwaitingSignatureCheck=!1,this.DisplayMessage=t}},{key:"PhoneForAuthRequired",value:function(t,e){this.PhoneForAuthRequiredMessage=t,this.AwaitingPhoneForAuth=!0,this.DisplayMessage=e}},{key:"AuthCodeSent",value:function(t){this.AwaitingPhoneForAuth=!1,this.DisplayMessage=t}},{key:"Completed",value:function(t,e,n){this.Success=t,this.Response=e,this.Finished=!0,this.AttemptingToCancel=!1,this.AwaitingGtResponse=!1,this.AwaitingSignatureCheck=!1,this.AwaitingPhoneForAuth=!1,this.DisplayMessage=n,this.CompletedTime=Date.now()}},{key:"UnknownCompleted",value:function(t){this.Success=Ee.Unknown,this.Response=null,this.Finished=!0,this.AttemptingToCancel=!1,this.AwaitingGtResponse=!1,this.AwaitingSignatureCheck=!1,this.AwaitingPhoneForAuth=!1,this.DisplayMessage=t,this.CompletedTime=Date.now()}}]),t}(),Ge=function t(e,n){o()(this,t),this.ValidFormat=e,this.Message=n},Ne=function(){function t(){o()(this,t),this.PrintMerchantCopy=!1,this.PromptForCustomerCopyOnEftpos=!1,this.SignatureFlowOnEftpos=!1,this.EnabledPrintMerchantCopy=!1,this.EnabledPromptForCustomerCopyOnEftpos=!1,this.EnabledSignatureFlowOnEftpos=!1}return u()(t,[{key:"AddReceiptConfig",value:function(t){return this.PromptForCustomerCopyOnEftpos&&this.EnabledPromptForCustomerCopyOnEftpos&&(t.prompt_for_customer_copy=this.PromptForCustomerCopyOnEftpos),this.SignatureFlowOnEftpos&&this.EnabledSignatureFlowOnEftpos&&(t.print_for_signature_required_transactions=this.SignatureFlowOnEftpos),this.PrintMerchantCopy&&this.EnabledPrintMerchantCopy&&(t.print_merchant_copy=this.PrintMerchantCopy),t}},{key:"ToString",value:function(){return"PromptForCustomerCopyOnEftpos:".concat(this.PromptForCustomerCopyOnEftpos," SignatureFlowOnEftpos:").concat(this.SignatureFlowOnEftpos," PrintMerchantCopy: ").concat(this.PrintMerchantCopy)}}]),t}(),Be=function(){function t(){o()(this,t),this._customerReceiptHeader="",this._customerReceiptFooter="",this._merchantReceiptHeader="",this._merchantReceiptFooter=""}return u()(t,[{key:"SetCustomerReceiptHeader",value:function(t){this._customerReceiptHeader=t}},{key:"SetCustomerReceiptFooter",value:function(t){this._customerReceiptFooter=t}},{key:"SetMerchantReceiptHeader",value:function(t){this._merchantReceiptHeader=t}},{key:"SetMerchantReceiptFooter",value:function(t){this._merchantReceiptFooter=t}},{key:"AddOptions",value:function(t){return t.customer_receipt_header=this._customerReceiptHeader,t.customer_receipt_footer=this._customerReceiptFooter,t.merchant_receipt_header=this._merchantReceiptHeader,t.merchant_receipt_footer=this._merchantReceiptFooter,t}}]),t}(),Le=1,qe=function(){function t(){o()(this,t)}return u()(t,null,[{key:"Id",value:function(t){return t+Le++}}]),t}(),Ue=function(){function t(){o()(this,t)}return u()(t,[{key:"ToMessage",value:function(){return new Me(qe.Id("pr"),yt,{padding:!0},!1)}}]),t}(),Ke=function t(e){o()(this,t),this.RequestId=e.Id,this.Aenc=e.Data.enc.A,this.Ahmac=e.Data.hmac.A},He=function(){function t(e,n,i){o()(this,t),this.RequestId=e,this.Benc=n,this.Bhmac=i}return u()(t,[{key:"ToMessage",value:function(){var t={enc:{B:this.Benc},hmac:{B:this.Bhmac}};return new Me(this.RequestId,St,t,!1)}}]),t}(),Ye=function t(e){o()(this,t),this.ConfirmationCode=e.IncomingHmac.substring(0,6)},We=function t(e){o()(this,t),this.Success=e.Data.success},Ve=function t(e,n){o()(this,t),this.Secrets=e,this.KeyResponse=n},je=function(){function t(){o()(this,t)}return u()(t,[{key:"ToMessage",value:function(){return new Me(qe.Id("drpkys"),Rt,null,!0)}}]),t}(),ze=function(){function t(e,n){o()(this,t),this.EncKey=e,this.HmacKey=n}return u()(t,null,[{key:"save",value:function(t,e){localStorage.setItem("EncKey",t),localStorage.setItem("HmacKey",e)}},{key:"restore",value:function(){return new t(localStorage.getItem("EncKey"),localStorage.getItem("HmacKey"))}},{key:"isSaved",value:function(){return localStorage.getItem("EncKey")&&localStorage.getItem("HmacKey")}},{key:"Reset",value:function(){localStorage.removeItem("EncKey"),localStorage.removeItem("HmacKey")}}]),t}(),Ze=n(5),Je=n.n(Ze),Xe=function(){function t(){o()(this,t)}return u()(t,[{key:"RandomPrivateKey",value:function(t){var e=new Je.a(t,16),n=Math.floor(1e3*Math.random()+1),i=e.shrn(n),r=new Je.a(2);return-1==i.cmp(r)?r:i}},{key:"PublicKey",value:function(t,e,n){var i=new Je.a(n,16),r=new Je.a(e,16),s=Je.a.mont(new Je.a(t,16));return r.toRed(s).redPow(i).fromRed().toString(16)}},{key:"Secret",value:function(t,e,n){var i=new Je.a(e,16),r=new Je.a(n,16),s=Je.a.mont(new Je.a(t,16));return i.toRed(s).redPow(r).fromRed().toString(16).toUpperCase()}}]),t}(),$e="FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AACAA68FFFFFFFFFFFFFFFF",Qe=function(){function t(){o()(this,t)}return u()(t,[{key:"GenerateSecretsAndKeyResponse",value:function(t){var e=this._calculateMyPublicKeyAndSecret(t.Aenc),n=e.MyPublicKey,i=e.SharedSecretKey,r=this._calculateMyPublicKeyAndSecret(t.Ahmac),s=r.MyPublicKey,o=r.SharedSecretKey,a=new ze(i,o),u=new He(t.RequestId,n,s);return new Ve(a,u)}},{key:"_calculateMyPublicKeyAndSecret",value:function(t){var e=new Xe,n=e.RandomPrivateKey($e),i=e.PublicKey($e,2,n),r=e.Secret($e,t,n),s=this.DHSecretToSPISecret(r);return new tn(i,s)}},{key:"DHSecretToSPISecret",value:function(t){return t.length%2==1&&(t="0"+t),t=t.padStart(512,"0"),wt.GenerateHash(t)}}],[{key:"NewPairRequest",value:function(){return new Ue}}]),t}(),tn=function t(e,n){o()(this,t),this.MyPublicKey=e,this.SharedSecretKey=n},en="Disconnected",nn="Connecting",rn="Connected",sn=function t(e){o()(this,t),this.ConnectionState=e},on=function t(e){o()(this,t),this.Message=e},an=function(){function t(e){if(o()(this,t),this.Address=null,this.Connected=!1,this.State=en,this.SpiProtocol="spi.2.9.0",this._spi=e,this._ws=null,this._conectionTimeout=null,"undefined"==typeof WebSocket)throw new Error("Environment does not support WebSockets")}return u()(t,[{key:"_cancelConnectionTimeout",value:function(){this._conectionTimeout&&(clearTimeout(this._conectionTimeout),this._connectionTimeout=null)}},{key:"Connect",value:function(t){var e=this;if(this.State!==rn&&this.State!==nn){this.State=nn,this._ws=new WebSocket(this.Address,this.SpiProtocol),this._ws.onopen=function(){return e.pollWebSocketConnection()},this._ws.onmessage=function(t){return e.onMessageReceived(t)},this._ws.onclose=function(){return e.onClosed()},this._ws.onerror=function(t){return e.onError(t)};this._conectionTimeout=setTimeout((function(){e._ws&&e.State===nn&&e.Disconnect()}),4e3),this._spi._eventBus.dispatchEvent(new CustomEvent("ConnectionStatusChanged",{detail:new sn(nn)}))}}},{key:"Disconnect",value:function(){this.State!=en&&(this._ws&&this._ws.readyState!=this._ws.CLOSED&&this._ws.close(),this._ws&&(this._ws.onopen=null,this._ws.onmessage=null,this._ws.onclose=null,this._ws.onerror=null),this.onClosed())}},{key:"Send",value:function(t){this._ws.send(t)}},{key:"onOpened",value:function(){this._cancelConnectionTimeout(),this.State=rn,this.Connected=!0,this._spi._eventBus.dispatchEvent(new CustomEvent("ConnectionStatusChanged",{detail:new sn(rn)}))}},{key:"onClosed",value:function(){this._cancelConnectionTimeout(),!1===this.Connected&&this.State===en||(this.Connected=!1,this.State=en,this._ws=null,this._spi._eventBus.dispatchEvent(new CustomEvent("ConnectionStatusChanged",{detail:new sn(en)})))}},{key:"pollWebSocketConnection",value:function(){var t=this,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return this._ws.readyState===this._ws.OPEN?(this.onOpened(),!0):e<20?(e++,void setTimeout((function(){return t.pollWebSocketConnection(e)}),200)):(this.Disconnect(),!1)}},{key:"onMessageReceived",value:function(t){this._spi._eventBus.dispatchEvent(new CustomEvent("MessageReceived",{detail:new on(t.data)}))}},{key:"onError",value:function(t){this._cancelConnectionTimeout(),this._spi._eventBus.dispatchEvent(new CustomEvent("ErrorReceived",{detail:new on(t)}))}}]),t}(),un=function(){function t(e,n){o()(this,t),this.PosRefId=n,this.PurchaseAmount=e,this.TipAmount=0,this.CashoutAmount=0,this.PromptForCashout=!1,this.SurchargeAmount=0,this.Config=new Ne,this.Options=new Be,this.Id=n,this.AmountCents=e}return u()(t,[{key:"AmountSummary",value:function(){var t=((this.PurchaseAmount||0)/100).toFixed(2),e=((this.TipAmount||0)/100).toFixed(2),n=((this.CashoutAmount||0)/100).toFixed(2);return"Purchase: ".concat(t,"; Tip: ").concat(e,"; Cashout: ").concat(n,";")}},{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,purchase_amount:this.PurchaseAmount,tip_amount:this.TipAmount,cash_amount:this.CashoutAmount,prompt_for_cashout:this.PromptForCashout,surcharge_amount:this.SurchargeAmount};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prchs"),Mt,t,!0)}}]),t}(),hn=function(){function t(e){o()(this,t),this._m=e,this.RequestId=e.Id,this.PosRefId=e.Data.pos_ref_id,this.SchemeName=e.Data.scheme_name,this.SchemeAppName=e.Data.scheme_name,this.Success=e.GetSuccessState()==Ee.Success}return u()(t,[{key:"GetRRN",value:function(){return this._m.Data.rrn}},{key:"GetPurchaseAmount",value:function(){return this._m.Data.purchase_amount}},{key:"GetTipAmount",value:function(){return this._m.Data.tip_amount||0}},{key:"GetSurchargeAmount",value:function(){return this._m.Data.surcharge_amount||0}},{key:"GetCashoutAmount",value:function(){return this._m.Data.cash_amount}},{key:"GetBankNonCashAmount",value:function(){return this._m.Data.bank_noncash_amount}},{key:"GetBankCashAmount",value:function(){return this._m.Data.bank_cash_amount}},{key:"GetCustomerReceipt",value:function(){return this._m.Data.customer_receipt||""}},{key:"GetMerchantReceipt",value:function(){return this._m.Data.merchant_receipt||""}},{key:"GetResponseText",value:function(){return this._m.Data.host_response_text||""}},{key:"GetResponseCode",value:function(){return this._m.Data.host_response_code}},{key:"GetTerminalReferenceId",value:function(){return this._m.Data.terminal_ref_id}},{key:"GetCardEntry",value:function(){return this._m.Data.card_entry}},{key:"GetAccountType",value:function(){return this._m.Data.account_type}},{key:"GetAuthCode",value:function(){return this._m.Data.auth_code}},{key:"GetBankDate",value:function(){return this._m.Data.bank_date}},{key:"GetBankTime",value:function(){return this._m.Data.bank_time}},{key:"GetMaskedPan",value:function(){return this._m.Data.masked_pan}},{key:"GetTerminalId",value:function(){return this._m.Data.terminal_id}},{key:"WasMerchantReceiptPrinted",value:function(){return this._m.Data.merchant_receipt_printed}},{key:"WasCustomerReceiptPrinted",value:function(){return this._m.Data.customer_receipt_printed}},{key:"GetSettlementDate",value:function(){var t=this._m.Data.bank_settlement_date;return t?Me.ParseBankDate(t):null}},{key:"GetResponseValue",value:function(t){return this._m.Data[t]}},{key:"ToPaymentSummary",value:function(){return{account_type:this.GetAccountType(),auth_code:this.GetAuthCode(),bank_date:this.GetBankDate(),bank_time:this.GetBankTime(),host_response_code:this.GetResponseCode(),host_response_text:this.GetResponseText(),masked_pan:this.GetMaskedPan(),purchase_amount:this.GetPurchaseAmount(),rrn:this.GetRRN(),scheme_name:this.SchemeName,terminal_id:this.GetTerminalId(),terminal_ref_id:this.GetTerminalReferenceId(),tip_amount:this.GetTipAmount(),surcharge_amount:this.GetSurchargeAmount()}}}]),t}(),ln=function(){function t(){o()(this,t)}return u()(t,[{key:"ToMessage",value:function(){return new Me(qe.Id("ctx"),At,null,!0)}}]),t}(),cn=function(){function t(e){o()(this,t),this._m=e,this.PosRefId=this._m.Data.pos_ref_id,this.Success=this._m.GetSuccessState()==Ee.Success}return u()(t,[{key:"GetErrorReason",value:function(){return this._m.Data.error_reason}},{key:"GetErrorDetail",value:function(){return this._m.Data.error_detail}},{key:"WasTxnPastPointOfNoReturn",value:function(){return this._m.GetError().startsWith("TXN_PAST_POINT_OF_NO_RETURN")}},{key:"GetResponseValueWithAttribute",value:function(t){return this._m.Data[t]}}]),t}(),dn=function(){function t(e){o()(this,t),this.PosRefId=e}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId};return new Me(qe.Id("gt"),xt,t,!0)}}]),t}(),fn=function(){function t(e){o()(this,t),this._m=e,this.Success=!1}return u()(t,[{key:"GetPosRefId",value:function(){return this._m.Data.pos_ref_id}},{key:"GetError",value:function(){var t=this._m.Data.error_reason;return t||null}},{key:"GetTxMessage",value:function(){var t=this._m.Data.tx;return t?new Me(this._m.Id,"gt",t,!1):null}},{key:"PosRefIdNotFound",value:function(){return null!==this._m.GetError()&&this._m.GetError().startsWith("POS_REF_ID_NOT_FOUND")}},{key:"PosRefIdInvalid",value:function(){return null!==this._m.GetError()&&this._m.GetError().startsWith("INVALID_ARGUMENTS")}},{key:"PosRefIdMissing",value:function(){return null!==this._m.GetError()&&this._m.GetError().startsWith("MISSING_ARGUMENTS")}},{key:"WasRetrievedSuccessfully",value:function(){return this._m.GetSuccessState()===Ee.Success}},{key:"IsTransactionInProgress",value:function(){return this._m.GetError().startsWith("TRANSACTION_IN_PROGRESS")}},{key:"IsWaitingForSignatureResponse",value:function(){return this._m.GetError().startsWith("TRANSACTION_IN_PROGRESS_AWAITING_SIGNATURE")}},{key:"IsWaitingForAuthCode",value:function(){return this._m.GetError().startsWith("TRANSACTION_IN_PROGRESS_AWAITING_PHONE_AUTH_CODE")}},{key:"IsSomethingElseBlocking",value:function(){return this._m.GetError().startsWith("OPERATION_IN_PROGRESS")}},{key:"CopyMerchantReceiptToCustomerReceipt",value:function(){var t=this._m.Data.customer_receipt,e=this._m.Data.merchant_receipt;""!==e&&""===t&&(this._m.Data.customer_receipt=e)}}]),t}(),pn=function(){function t(){o()(this,t)}return u()(t,[{key:"ToMessage",value:function(){return new Me(qe.Id("glt"),Ft,null,!0)}}]),t}(),mn=function(){function t(e){o()(this,t),this._m=e}return u()(t,[{key:"WasRetrievedSuccessfully",value:function(){return!!this.GetResponseCode()}},{key:"WasOperationInProgressError",value:function(){return this._m.GetError().startsWith("OPERATION_IN_PROGRESS")}},{key:"IsWaitingForSignatureResponse",value:function(){return this._m.GetError().startsWith("OPERATION_IN_PROGRESS_AWAITING_SIGNATURE")}},{key:"IsWaitingForAuthCode",value:function(){return this._m.GetError().startsWith("OPERATION_IN_PROGRESS_AWAITING_PHONE_AUTH_CODE")}},{key:"IsStillInProgress",value:function(t){return this.WasOperationInProgressError()&&(this.GetPosRefId()==t||null==this.GetPosRefId())}},{key:"GetSuccessState",value:function(){return this._m.GetSuccessState()}},{key:"WasSuccessfulTx",value:function(){return this._m.GetSuccessState()==Ee.Success}},{key:"GetTxType",value:function(){return this._m.Data.transaction_type}},{key:"GetPosRefId",value:function(){return this._m.Data.pos_ref_id}},{key:"GetBankNonCashAmount",value:function(){return this._m.Data.bank_noncash_amount}},{key:"GetSchemeApp",value:function(){return this._m.Data.scheme_name}},{key:"GetSchemeName",value:function(){return this._m.Data.scheme_name}},{key:"GetAmount",value:function(){return this._m.Data.amount_purchase}},{key:"GetTransactionAmount",value:function(){return this._m.Data.amount_transaction_type}},{key:"GetBankDateTimeString",value:function(){return this._m.Data.bank_date+this._m.Data.bank_time}},{key:"GetRRN",value:function(){return this._m.Data.rrn}},{key:"GetResponseText",value:function(){return this._m.Data.host_response_text||""}},{key:"GetResponseCode",value:function(){return this._m.Data.host_response_code}},{key:"CopyMerchantReceiptToCustomerReceipt",value:function(){var t=this._m.Data.customer_receipt,e=this._m.Data.merchant_receipt;""==e||t||(this._m.Data.customer_receipt=e)}}]),t}(),gn=function(){function t(e,n,i){o()(this,t),this.AmountCents=e,this.Id=qe.Id("refund"),this.PosRefId=n,this.SuppressMerchantPassword=i,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={refund_amount:this.AmountCents,pos_ref_id:this.PosRefId,suppress_merchant_password:this.SuppressMerchantPassword};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("refund"),Bt,t,!0)}}]),t}(),_n=function(){function t(e){o()(this,t),this._m=e,this.RequestId=e.Id,this.PosRefId=e.Data.pos_ref_id,this.SchemeName=e.Data.scheme_name,this.SchemeAppName=e.Data.scheme_name,this.Success=e.GetSuccessState()==Ee.Success}return u()(t,[{key:"GetRefundAmount",value:function(){return this._m.Data.refund_amount}},{key:"GetRRN",value:function(){return this._m.Data.rrn}},{key:"GetCustomerReceipt",value:function(){return this._m.Data.customer_receipt||""}},{key:"GetMerchantReceipt",value:function(){return this._m.Data.merchant_receipt}},{key:"GetResponseText",value:function(){return this._m.Data.host_response_text||""}},{key:"GetResponseCode",value:function(){return this._m.Data.host_response_code||""}},{key:"GetTerminalReferenceId",value:function(){return this._m.Data.terminal_ref_id||""}},{key:"GetCardEntry",value:function(){return this._m.Data.card_entry||""}},{key:"GetAccountType",value:function(){return this._m.Data.account_type||""}},{key:"GetAuthCode",value:function(){return this._m.Data.auth_code||""}},{key:"GetBankDate",value:function(){return this._m.Data.bank_date||""}},{key:"GetBankTime",value:function(){return this._m.Data.bank_time||""}},{key:"GetMaskedPan",value:function(){return this._m.Data.masked_pan||""}},{key:"GetTerminalId",value:function(){return this._m.Data.terminal_id||""}},{key:"WasMerchantReceiptPrinted",value:function(){return this._m.Data.merchant_receipt_printed}},{key:"WasCustomerReceiptPrinted",value:function(){return this._m.Data.customer_receipt_printed}},{key:"GetSettlementDate",value:function(){var t=this._m.Data.bank_settlement_date;return t?Me.ParseBankDate(t):null}},{key:"GetResponseValue",value:function(t){return this._m.Data[t]}}]),t}(),vn=function(){function t(e){o()(this,t),this.RequestId=e.Id,this.PosRefId=e.Data.pos_ref_id,this._receiptToSign=e.Data.merchant_receipt}return u()(t,[{key:"SignatureRequired",value:function(t,e,n){this.RequestId=e,this.PosRefId=t,this._receiptToSign=n}},{key:"GetMerchantReceipt",value:function(){return this._receiptToSign}}]),t}(),wn=function(){function t(e){o()(this,t),this.PosRefId=e}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId};return new Me(qe.Id("sigdec"),Ut,t,!0)}}]),t}(),yn=function(){function t(e){o()(this,t),this.PosRefId=e}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId};return new Me(qe.Id("sigacc"),Kt,t,!0)}}]),t}(),Cn=function(){function t(e,n,i,r){o()(this,t),this.PosRefId=n,this.PurchaseAmount=e,this.SurchargeAmount=i,this.SuppressMerchantPassword=r,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,purchase_amount:this.PurchaseAmount,surcharge_amount:this.SurchargeAmount,suppress_merchant_password:this.SuppressMerchantPassword};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("moto"),jt,t,!0)}}]),t}(),Sn=function t(e){o()(this,t),this.PurchaseResponse=new hn(e),this.PosRefId=hn.PosRefId},Tn=function(){function t(){o()(this,t);for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];if(4===n.length)this.PosRefId=n[0],this.RequestId=n[1],this._phoneNumber=n[2],this._merchantId=n[3];else{if(1!==n.length)throw new Error("Invalid call sig for Phone auth required class");this.RequestId=n[0].Id,this.PosRefId=n[0].Data.pos_ref_id,this._phoneNumber=n[0].Data.auth_centre_phone_number,this._merchantId=n[0].Data.merchant_id}}return u()(t,[{key:"GetPhoneNumber",value:function(){return this._phoneNumber}},{key:"GetMerchantId",value:function(){return this._merchantId}}]),t}(),Pn=function(){function t(e,n){o()(this,t),this.PosRefId=e,this.AuthCode=n}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,auth_code:this.AuthCode};return new Me(qe.Id("authad"),Yt,t,!0)}}]),t}(),Rn=function(){function t(e){o()(this,t),this.DisplayMessageCode=e.Data.display_message_code,this.DisplayMessageText=e.Data.display_message_text}return u()(t,[{key:"GetDisplayMessageCode",value:function(){return this.DisplayMessageCode}},{key:"GetDisplayMessageText",value:function(){return this.DisplayMessageText}}]),t}(),En=function(){function t(){o()(this,t),this.Result=null,this.BillId=null,this.TableId=null,this.OperatorId=null,this.TotalAmount=0,this.OutstandingAmount=0,this.BillData=""}return u()(t,[{key:"getBillPaymentHistory",value:function(){if(!this.BillData)return[];return JSON.parse(this.BillData).map((function(t){return new kn(t.payment_type,t.payment_summary)}))}},{key:"ToMessage",value:function(t){var e={success:this.Result==bn.SUCCESS};return this.BillId&&(e.bill_id=this.BillId),this.TableId&&(e.table_id=this.TableId),this.Result==bn.SUCCESS?(e.bill_total_amount=this.TotalAmount,e.bill_outstanding_amount=this.OutstandingAmount,e.bill_payment_history=this.getBillPaymentHistory()):(e.error_reason=this.Result.toString(),e.error_detail=this.Result.toString()),new Me(t,ue,e,!0)}}],[{key:"ToBillData",value:function(t){return t.length<1?"":JSON.stringify(t)}}]),t}(),bn={SUCCESS:"SUCCESS",INVALID_TABLE_ID:"INVALID_TABLE_ID",INVALID_BILL_ID:"INVALID_BILL_ID",INVALID_OPERATOR_ID:"INVALID_OPERATOR_ID"},Mn=function t(e){o()(this,t),this._incomingAdvice=e,this.BillId=this._incomingAdvice.Data.bill_id,this.TableId=this._incomingAdvice.Data.table_id,this.OperatorId=this._incomingAdvice.Data.operator_id,this.PaymentFlowStarted=null;var n=this._incomingAdvice.Data.payment_type;this.PaymentType=n;var i=new Me(e.Id,"payment_details",e.Data.payment_details,!1);this.PurchaseResponse=new hn(i),this.PurchaseAmount=this.PurchaseResponse.GetPurchaseAmount(),this.TipAmount=this.PurchaseResponse.GetTipAmount(),this.SurchargeAmount=this.PurchaseResponse.GetSurchargeAmount()},kn=function(){function t(e,n){o()(this,t),this.PaymentType=e,this.PaymentSummary=n}return u()(t,[{key:"toJSON",value:function(){return{payment_type:this.PaymentType,payment_summary:this.PaymentSummary}}},{key:"GetTerminalRefId",value:function(){return this.PaymentSummary.terminal_ref_id}}]),t}(),An=function(){function t(){o()(this,t),this.PayAtTableEnabled=!1,this.OperatorIdEnabled=!1,this.SplitByAmountEnabled=!1,this.EqualSplitEnabled=!1,this.TableRetrievalEnabled=!1,this.TippingEnabled=!1,this.SummaryReportEnabled=!1,this.LabelPayButton="",this.LabelOperatorId="",this.LabelTableId="",this.AllowedOperatorIds=[]}return u()(t,[{key:"ToMessage",value:function(t){var e={pay_at_table_enabled:this.PayAtTableEnabled,operator_id_enabled:this.OperatorIdEnabled,split_by_amount_enabled:this.SplitByAmountEnabled,equal_split_enabled:this.EqualSplitEnabled,tipping_enabled:this.TippingEnabled,summary_report_enabled:this.SummaryReportEnabled,pay_button_label:this.LabelPayButton,operator_id_label:this.LabelOperatorId,table_id_label:this.LabelTableId,operator_id_list:this.AllowedOperatorIds,table_retrieval_enabled:this.TableRetrievalEnabled};return new Me(t,oe,e,!0)}}],[{key:"FeatureDisableMessage",value:function(t){return new Me(t,oe,{pay_at_table_enabled:!1},!0)}}]),t}(),In=function(){function t(){o()(this,t),this.TableData=null}return u()(t,[{key:"GetOpenTables",value:function(){return this.TableData?JSON.parse(this.TableData):[]}},{key:"ToMessage",value:function(t){var e={tables:this.GetOpenTables()};return new Me(t,ce,e,!0)}}]),t}(),Fn=function(){function t(){o()(this,t),this.TableId=null,this.Label=null,this.BillOutstandingAmount=null}return u()(t,[{key:"toJSON",value:function(){return{table_id:this.TableId,label:this.Label,bill_outstanding_amount:this.BillOutstandingAmount}}}]),t}(),Dn=function t(e){o()(this,t),this.BillId=e.Data.bill_id,this.BillOutstandingAmount=e.Data.bill_outstanding_amount,this.BillTotalAmount=e.Data.bill_total_amount,this.OperatorId=e.Data.operator_id,this.TableId=e.Data.table_id,this.CardTotalCount=e.Data.card_total_count,this.CardTotalAmount=e.Data.card_total_amount,this.CashTotalCount=e.Data.cash_total_count,this.CashTotalAmount=e.Data.cash_total_amount},xn=function(){function t(e){o()(this,t),this.BillId=e,this.Id=""}return u()(t,[{key:"ToMessage",value:function(){var t={bill_id:this.BillId};return new Me(qe.Id("authad"),fe,t,!0)}}]),t}(),On=function(){function t(e){o()(this,t),this._spi=e,this._log=console,this.Config=new An}return u()(t,[{key:"GetBillStatus",value:function(t,e,n,i){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"BillPaymentReceived",value:function(t,e){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"GetOpenTables",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"BillPaymentFlowEnded",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"PushPayAtTableConfig",value:function(){this._spi.CurrentStatus===ke.PairedConnected&&this._spi._send(this.Config.ToMessage(qe.Id("patconf")))}},{key:"_handleGetBillDetailsRequest",value:function(t){var e=this,n=t.Data.operator_id,i=t.Data.table_id,r=t.Data.payment_flow_started;return Promise.resolve(this.GetBillStatus("",i,n,r)).then((function(n){n.TableId=i,n.TotalAmount<=0&&(e._log.info("Table has 0 total amount. not sending it to eftpos."),n.Result=bn.INVALID_TABLE_ID),e._spi._send(n.ToMessage(t.Id))}))}},{key:"_handleBillPaymentAdvice",value:function(t){var e=this,n=new Mn(t);return Promise.resolve(this.GetBillStatus(n.BillId,n.TableId,n.OperatorId,n.PaymentFlowStarted)).then((function(i){i.Result!=bn.SUCCESS&&(e._log.warn("Could not retrieve Bill Status for Payment Advice. Sending Error to Eftpos."),e._spi._send(i.ToMessage(t.Id)));var r=i.getBillPaymentHistory();if(r.find((function(t){return t.GetTerminalRefId()==n.PurchaseResponse.GetTerminalReferenceId()})))return e._log.warn("Had already received this bill_paymemnt advice from eftpos. Ignoring."),void e._spi._send(i.ToMessage(t.Id));var s=r;s.push(new kn(n.PaymentType.toLowerCase(),n.PurchaseResponse.ToPaymentSummary()));var o=En.ToBillData(s);Promise.resolve(e.BillPaymentReceived(n,o)).then((function(r){r.BillId=n.BillId,r.TableId=n.TableId,r.Result!=bn.SUCCESS?(e._log.warn("POS Errored when being Advised of Payment. Letting EFTPOS know, and sending existing bill data."),r.BillData=i.BillData):r.BillData=o,e._spi._send(r.ToMessage(t.Id))}))}))}},{key:"_handleGetTableConfig",value:function(t){this._spi._send(this.Config.ToMessage(t.Id))}},{key:"_handleGetOpenTablesRequest",value:function(t){var e=t.Data.operator_id,n="function"==typeof this.GetOpenTables?this.GetOpenTables(e):null;n&&n.TableData&&n.TableData.length||(n=new In,this._log.info("There is no open table.")),this._spi._send(n.ToMessage(t.Id))}},{key:"_handleBillPaymentFlowEnded",value:function(t){if(this.BillPaymentFlowEnded(t),this._spi.CurrentStatus===ke.PairedConnected){var e=new Dn(t);this._spi._send(new xn(e.BillId).ToMessage())}}}]),t}(),Gn="account_verify",Nn="account_verify_response",Bn="preauth",Ln="preauth_response",qn="preauth_topup",Un="preauth_topup_response",Kn="preauth_extend",Hn="preauth_extend_response",Yn="preauth_partial_cancellation",Wn="preauth_partial_cancellation_response",Vn="preauth_cancellation",jn="preauth_cancellation_response",zn="completion",Zn="completion_response",Jn=function(){function t(e){o()(this,t),this.PosRefId=e}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId};return new Me(qe.Id("prav"),Gn,t,!0)}}]),t}(),Xn=function t(e){o()(this,t),this.Details=new hn(e),this.PosRefId=this.Details.PosRefId,this._m=e},$n=function(){function t(e,n){o()(this,t),this.PosRefId=n,this.PreauthAmount=e,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,preauth_amount:this.PreauthAmount};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prac"),Bn,t,!0)}}]),t}(),Qn=function(){function t(e,n,i){o()(this,t),this.PreauthId=e,this.TopupAmount=n,this.PosRefId=i,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,preauth_id:this.PreauthId,topup_amount:this.TopupAmount};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prtu"),qn,t,!0)}}]),t}(),ti=function(){function t(e,n,i){o()(this,t),this.PreauthId=e,this.PartialCancellationAmount=n,this.PosRefId=i,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,preauth_id:this.PreauthId,preauth_cancel_amount:this.PartialCancellationAmount};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prpc"),Yn,t,!0)}}]),t}(),ei=function(){function t(e,n){o()(this,t),this.PreauthId=e,this.PosRefId=n,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,preauth_id:this.PreauthId};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prext"),Kn,t,!0)}}]),t}(),ni=function(){function t(e,n){o()(this,t),this.PreauthId=e,this.PosRefId=n,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,preauth_id:this.PreauthId};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prac"),Vn,t,!0)}}]),t}(),ii=function(){function t(e,n,i,r){o()(this,t),this.PreauthId=e,this.CompletionAmount=n,this.PosRefId=i,this.SurchargeAmount=r,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,preauth_id:this.PreauthId,completion_amount:this.CompletionAmount,surcharge_amount:this.SurchargeAmount};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("prac"),zn,t,!0)}}]),t}(),ri=function(){function t(e){o()(this,t),this.PreauthId=e.Data.preauth_id,this.Details=new hn(e),this.PosRefId=this.Details.PosRefId,this._m=e}return u()(t,[{key:"GetBalanceAmount",value:function(){switch(this._m.Data.transaction_type){case"PRE-AUTH":return this._m.Data.preauth_amount;case"TOPUP":case"CANCEL":case"PRE-AUTH EXT":return this._m.Data.balance_amount;case"PCOMP":case"PRE-AUTH CANCEL":default:return 0}}},{key:"GetPreviousBalanceAmount",value:function(){switch(this._m.Data.transaction_type){case"PRE-AUTH":return 0;case"TOPUP":case"CANCEL":case"PRE-AUTH EXT":return this._m.Data.existing_preauth_amount;case"PCOMP":return this._m.Data.completion_amount;case"PRE-AUTH CANCEL":return this._m.Data.preauth_amount;default:return 0}}},{key:"GetCompletionAmount",value:function(){switch(this._m.Data.transaction_type){case"PCOMP":return this._m.Data.completion_amount;default:return 0}}},{key:"GetSurchargeAmount",value:function(){switch(this._m.Data.transaction_type){case"PCOMP":return this._m.Data.surcharge_amount;default:return 0}}},{key:"WasMerchantReceiptPrinted",value:function(){return this._m.Data.merchant_receipt_printed}},{key:"WasCustomerReceiptPrinted",value:function(){return this._m.Data.customer_receipt_printed}}]),t}(),si=function(){function t(e){o()(this,t),this._spi=e,this._log=console,this.Config=new Ne}return u()(t,[{key:"InitiateAccountVerifyTx",value:function(t){var e=new Jn(t).ToMessage(),n=new Oe(t,Fe.AccountVerify,0,e,"Waiting for EFTPOS connection to make account verify request");return this._initiatePreauthTx(n,"Asked EFTPOS to verify account")}},{key:"InitiateOpenTx",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Be,i=Object.assign(new $n(e,t),{Config:this.Config,Options:n}).ToMessage(),r=new Oe(t,Fe.Preauth,e,i,"Waiting for EFTPOS connection to make preauth request for ".concat((e/100).toFixed(2))),s="Asked EFTPOS to create preauth for ".concat((e/100).toFixed(2));return this._initiatePreauthTx(r,s)}},{key:"InitiateTopupTx",value:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Be,r=Object.assign(new Qn(e,n,t),{Config:this.Config,Options:i}).ToMessage(),s=new Oe(t,Fe.Preauth,n,r,"Waiting for EFTPOS connection to make preauth topup request for ".concat((n/100).toFixed(2))),o="Asked EFTPOS to make preauth topup for ".concat((n/100).toFixed(2));return this._initiatePreauthTx(s,o)}},{key:"InitiatePartialCancellationTx",value:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Be,r=Object.assign(new ti(e,n,t),{Config:this.Config,Options:i}).ToMessage(),s=new Oe(t,Fe.Preauth,n,r,"Waiting for EFTPOS connection to make preauth partial cancellation request for ".concat((n/100).toFixed(2))),o="Asked EFTPOS to make preauth partial cancellation for ".concat((n/100).toFixed(2));return this._initiatePreauthTx(s,o)}},{key:"InitiateExtendTx",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Be,i=Object.assign(new ei(e,t),{Config:this.Config,Options:n}).ToMessage(),r=new Oe(t,Fe.Preauth,0,i,"Waiting for EFTPOS connection to make preauth Extend request"),s="Asked EFTPOS to make preauth Extend request";return this._initiatePreauthTx(r,s)}},{key:"InitiateCompletionTx",value:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:0,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new Be,s=Object.assign(new ii(e,n,t),{Config:this.Config,SurchargeAmount:i,Options:r}).ToMessage(),o=new Oe(t,Fe.Preauth,n,s,"Waiting for EFTPOS connection to make preauth completion request for ".concat((n/100).toFixed(2))),a="Asked EFTPOS to make preauth completion for ".concat((n/100).toFixed(2));return this._initiatePreauthTx(o,a)}},{key:"InitiateCancelTx",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:new Be,i=Object.assign(new ni(e,t),{Config:this.Config,Options:n}).ToMessage(),r=new Oe(t,Fe.Preauth,0,i,"Waiting for EFTPOS connection to make preauth cancellation request"),s="Asked EFTPOS to make preauth cancellation request";return this._initiatePreauthTx(r,s)}},{key:"_initiatePreauthTx",value:function(t,e){return this._spi.CurrentStatus==ke.Unpaired?new De(!1,"Not Paired"):this._spi.CurrentFlow!=Ae.Idle?new De(!1,"Not Idle"):(this._spi.CurrentFlow=Ae.Transaction,this._spi.CurrentTxFlowState=t,this._spi._send(t.Request)&&this._spi.CurrentTxFlowState.Sent(e),this._spi._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this._spi.CurrentTxFlowState})),new De(!0,"Preauth Initiated"))}},{key:"_handlePreauthMessage",value:function(t){switch(t.EventName){case Nn:this._handleAccountVerifyResponse(t);break;case Ln:case Un:case Wn:case Hn:case Zn:case jn:this._handlePreauthResponse(t);break;default:this._log.info("I don't Understand Preauth Event: ".concat(t.EventName,", ").concat(t.Data,". Perhaps I have not implemented it yet."))}}},{key:"_handleAccountVerifyResponse",value:function(t){var e=t.Data.pos_ref_id,n=this._spi.CurrentTxFlowState;this._spi.CurrentFlow!=Ae.Transaction||n.Finished||!n.PosRefId===e?this._log.info("Received Account Verify response but I was not waiting for one. Incoming Pos Ref ID: ".concat(e)):(n.Completed(t.GetSuccessState(),t,"Account Verify Transaction Ended."),this._spi._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this._spi.CurrentTxFlowState})))}},{key:"_handlePreauthResponse",value:function(t){var e=t.Data.pos_ref_id,n=this._spi.CurrentTxFlowState;this._spi.CurrentFlow!=Ae.Transaction||n.Finished||!n.PosRefId===e?this._log.info("Received Preauth response but I was not waiting for one. Incoming Pos Ref ID: ".concat(e)):(n.Completed(t.GetSuccessState(),t,"Preauth Transaction Ended."),this._spi._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this._spi.CurrentTxFlowState})))}}],[{key:"IsPreauthEvent",value:function(t){return 0===t.lastIndexOf("preauth",0)||t==Zn||t==zn||t==Gn||t==Nn}}]),t}(),oi=function(){function t(e,n){o()(this,t),this.PosRefId=n,this.CashoutAmount=e,this.SurchargeAmount=null,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,cash_amount:this.CashoutAmount,surcharge_amount:this.SurchargeAmount};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!0,this.Config.EnabledSignatureFlowOnEftpos=!0,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("cshout"),Wt,t,!0)}}]),t}(),ai=function(){function t(e){o()(this,t),this._m=e,this.RequestId=e.Id,this.PosRefId=e.Data.pos_ref_id,this.SchemeName=e.Data.scheme_name,this.Success=e.GetSuccessState()==Ee.Success}return u()(t,[{key:"GetRRN",value:function(){return this._m.Data.rrn}},{key:"GetCashoutAmount",value:function(){return this._m.Data.cash_amount}},{key:"GetBankNonCashAmount",value:function(){return this._m.Data.bank_noncash_amount}},{key:"GetBankCashAmount",value:function(){return this._m.Data.bank_cash_amount}},{key:"GetCustomerReceipt",value:function(){return this._m.Data.customer_receipt}},{key:"GetMerchantReceipt",value:function(){return this._m.Data.merchant_receipt}},{key:"GetResponseText",value:function(){return this._m.Data.host_response_text}},{key:"GetResponseCode",value:function(){return this._m.Data.host_response_code}},{key:"GetTerminalReferenceId",value:function(){return this._m.Data.terminal_ref_id}},{key:"GetAccountType",value:function(){return this._m.Data.account_type}},{key:"GetAuthCode",value:function(){return this._m.Data.auth_code}},{key:"GetBankDate",value:function(){return this._m.Data.bank_date}},{key:"GetBankTime",value:function(){return this._m.Data.bank_time}},{key:"GetMaskedPan",value:function(){return this._m.Data.masked_pan}},{key:"GetTerminalId",value:function(){return this._m.Data.terminal_id}},{key:"WasMerchantReceiptPrinted",value:function(){return this._m.Data.merchant_receipt_printed}},{key:"WasCustomerReceiptPrinted",value:function(){return this._m.Data.customer_receipt_printed}},{key:"GetSurchargeAmount",value:function(){return this._m.Data.surcharge_amount}},{key:"GetResponseValue",value:function(t){return this._m.Data[t]}}]),t}(),ui=function(){function t(e){o()(this,t),this.Id=e,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!1,this.Config.EnabledSignatureFlowOnEftpos=!1,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(this.Id,Zt,t,!0)}}]),t}(),hi=function(){function t(e){o()(this,t),this.RequestId=e.Id,this._m=e,this.Success=e.GetSuccessState()==Ee.Success}return u()(t,[{key:"GetSettleByAcquirerCount",value:function(){return this._m.Data.accumulated_settle_by_acquirer_count}},{key:"GetSettleByAcquirerValue",value:function(){return this._m.Data.accumulated_settle_by_acquirer_value}},{key:"GetTotalCount",value:function(){return this._m.Data.accumulated_total_count}},{key:"GetTotalValue",value:function(){return this._m.Data.accumulated_total_value}},{key:"GetPeriodStartTime",value:function(){var t=this._m.Data.settlement_period_start_time,e=this._m.Data.settlement_period_start_date;return Me.ParseBankDateTimeStr(e,t)}},{key:"GetPeriodEndTime",value:function(){var t=this._m.Data.settlement_period_end_time,e=this._m.Data.settlement_period_end_date;return Me.ParseBankDateTimeStr(e,t)}},{key:"GetTriggeredTime",value:function(){var t=this._m.Data.settlement_triggered_time,e=this._m.Data.settlement_triggered_date;return Me.ParseBankDateTimeStr(e,t)}},{key:"GetResponseText",value:function(){return this._m.Data.host_response_text}},{key:"GetReceipt",value:function(){return this._m.Data.merchant_receipt}},{key:"GetTransactionRange",value:function(){return this._m.Data.transaction_range}},{key:"GetTerminalId",value:function(){return this._m.Data.terminal_id}},{key:"WasMerchantReceiptPrinted",value:function(){return this._m.Data.merchant_receipt_printed}},{key:"GetSchemeSettlementEntries",value:function(){var t=this._m.Data.schemes;return t?t.map((function(t){return new li(t)})):[]}}]),t}(),li=function(){function t(){o()(this,t);for(var e=arguments.length,n=new Array(e),i=0;i<e;i++)n[i]=arguments[i];1===n.length?(this.SchemeName=n[0].scheme_name,this.SettleByAcquirer="yes"==n[0].settle_by_acquirer.toLowerCase(),this.TotalValue=parseInt(n[0].total_value,10),this.TotalCount=parseInt(n[0].total_count,10)):4===n.length&&(this.SchemeName=n[0],this.SettleByAcquirer=n[1],this.TotalCount=n[2],this.TotalValue=n[3])}return u()(t,[{key:"ToString",value:function(){return"SchemeName: ".concat(this.SchemeName,", SettleByAcquirer: ").concat(this.SettleByAcquirer,", TotalCount: ").concat(this.TotalCount,", TotalValue: ").concat(this.TotalValue)}}]),t}(),ci=function(){function t(e){o()(this,t),this.Id=e,this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={};return this.Config.EnabledPrintMerchantCopy=!0,this.Config.EnabledPromptForCustomerCopyOnEftpos=!1,this.Config.EnabledSignatureFlowOnEftpos=!1,this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(this.Id,Xt,t,!0)}}]),t}(),di=function(){function t(e,n,i,r,s,a){o()(this,t),this._version=e,this._vendorId=n,this._libraryLanguage=r,this._libraryVersion=s,this._spiceVersion=i,this._otherInfo=a}return u()(t,[{key:"toMessage",value:function(){var t={pos_version:this._version,pos_vendor_id:this._vendorId,library_language:this._libraryLanguage,library_version:this._libraryVersion,spice_version:this._spiceVersion,other_info:Object.assign({},this._otherInfo,{spice_version:this._spiceVersion})};return new Me(qe.Id("prav"),Qt,t,!0)}}]),t}(),fi=function(){function t(e){o()(this,t),this._success=e.GetSuccessState()==Ee.Success,this._m=e}return u()(t,[{key:"isSuccess",value:function(){return this._success}},{key:"getErrorReason",value:function(){return this._m.Data.error_reason}},{key:"getErrorDetail",value:function(){return this._m.Data.error_detail}},{key:"getResponseValueWithAttribute",value:function(t){return this._m.Data[t]}}]),t}(),pi=function(){function t(){o()(this,t)}return u()(t,null,[{key:"GetAppDeviceInfo",value:function(){var t={};return t.device_system=navigator.userAgent,t}}]),t}(),mi=function(){function t(){o()(this,t)}return u()(t,null,[{key:"CreatePurchaseRequest",value:function(t,e){return new un(t,e)}},{key:"CreatePurchaseRequestV2",value:function(t,e,n,i,r,s){return Object.assign(new un(e,t),{CashoutAmount:i,TipAmount:n,PromptForCashout:r,SurchargeAmount:s})}},{key:"CreateRefundRequest",value:function(t,e,n){return new gn(t,e,n)}}]),t}(),gi=function(){function t(){o()(this,t)}return u()(t,null,[{key:"PerformKeyRolling",value:function(t,e){var n=new Me(t.Id,ne,{status:"confirmed"},!0),i=new ze(wt.GenerateHash(e.EncKey).toUpperCase(),wt.GenerateHash(e.HmacKey).toUpperCase());return new _i(n,i)}}]),t}(),_i=function t(e,n){o()(this,t),this.KeyRollingConfirmation=e,this.NewSecrets=n},vi=function(){function t(){o()(this,t)}return u()(t,null,[{key:"GeneratePongResponse",value:function(t){return new Me(t.Id,bt,null,!0)}}]),t}(),wi=function(){function t(){o()(this,t)}return u()(t,null,[{key:"GeneratePingRequest",value:function(){return new Me(qe.Id("ping"),Et,null,!0)}}]),t}(),yi=function(){function t(e){o()(this,t),this.UseSecureWebSockets=e,this.ip=null,this.fqdn=null,this.LastUpdated=null,this.DeviceAddressResponseCode=null,this.ResponseStatusDescription=null,this.ResponseMessage=null}return u()(t,[{key:"Address",get:function(){return this.UseSecureWebSockets?this.fqdn:this.ip},set:function(t){this.UseSecureWebSockets?this.fqdn=t:this.ip=t}}]),t}(),Ci={SUCCESS:"SUCCESS",INVALID_SERIAL_NUMBER:"INVALID_SERIAL_NUMBER",ADDRESS_NOT_CHANGED:"ADDRESS_NOT_CHANGED",SERIAL_NUMBER_NOT_CHANGED:"SERIAL_NUMBER_NOT_CHANGED",DEVICE_SERVICE_ERROR:"DEVICE_SERVICE_ERROR"},Si=404,Ti=200,Pi=function(){function t(){o()(this,t)}var e;return u()(t,[{key:"RetrieveDeviceAddress",value:(e=r()(l.a.mark((function t(e){var n,i,r,s,o,a,u,h=arguments;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=h.length>1&&void 0!==h[1]?h[1]:"spi-sample-pos1",i=h.length>2?h[2]:void 0,r=h.length>3?h[3]:void 0,s=h.length>4?h[4]:void 0,o=8e3,a=r?"fqdn":"ip",u=s?"https://device-address-api-sb.".concat(i,".mspenv.io/v1/").concat(e,"/").concat(a):"https://device-address-api.".concat(i,".mspenv.io/v1/").concat(e,"/").concat(a),t.abrupt("return",Promise.race([fetch(u,{method:"GET",headers:{"ASM-MSP-DEVICE-ADDRESS-API-KEY":n}}),new Promise((function(t,e){return setTimeout((function(){return e(new Error("Timeout while trying to retrieve IP address"))}),o)}))]));case 8:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})}]),t}(),Ri=function(){function t(){o()(this,t)}return u()(t,null,[{key:"GenerateDeviceAddressStatus",value:function(t,e,n){var i=new yi(n);return t.StatusCode===Si?(i.DeviceAddressResponseCode=Ci.INVALID_SERIAL_NUMBER,i):t&&null===t.Data||t.StatusCode!==Ti?(i.DeviceAddressResponseCode=Ci.DEVICE_SERVICE_ERROR,i):t.Data.Address===e.replace(/^w[s]?s:\/\//,"")?(i.DeviceAddressResponseCode=Ci.ADDRESS_NOT_CHANGED,i):(i.DeviceAddressResponseCode=Ci.SUCCESS,i.ResponseStatusDescription=t.StatusDescription,i.Address=t.Data.fqdn||t.Data.ip,i.LastUpdated=t.Data.last_updated,i)}}]),t}(),Ei=function(){function t(e,n){o()(this,t),this._key=e,this._payload=n}return u()(t,[{key:"toMessage",value:function(){var t={key:this._key,payload:this._payload};return new Me(qe.Id("print"),pe,t,!0)}}]),t}(),bi=function(){function t(e){o()(this,t),this._success=e.GetSuccessState()==Ee.Success,this._m=e}return u()(t,[{key:"isSuccess",value:function(){return this._success}},{key:"getErrorReason",value:function(){return this._m.Data.error_reason}},{key:"getErrorDetail",value:function(){return this._m.Data.error_detail}},{key:"getResponseValueWithAttribute",value:function(t){return this._m.Data[t]}}]),t}(),Mi=function(){function t(e){o()(this,t),this.PosRefId=e}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId};return new Me(qe.Id("rev"),Gt,t,!0)}}]),t}(),ki=function(){function t(e){o()(this,t),this._m=e,this.PosRefId=e.Data.pos_ref_id,this.Success=e.GetSuccessState()===Ee.Success}return u()(t,[{key:"GetErrorReason",value:function(){return this._m.Data.error_reason}},{key:"GetErrorDetail",value:function(){return this._m.Data.error_detail}}]),t}(),Ai=function(){function t(){o()(this,t)}var e;return u()(t,null,[{key:"RetrieveTenantsList",value:(e=r()(l.a.mark((function t(e,n,i){var r,s,o;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r="https://spi.integration.mspenv.io/tenants?country-code=".concat(i,"&pos-vendor-id=").concat(e,"&apikey=").concat(n),t.next=3,fetch(r);case 3:return s=t.sent,t.prev=4,t.next=7,s.json();case 7:return o=t.sent,t.abrupt("return",o);case 11:throw t.prev=11,t.t0=t.catch(4),new Error("No JSON returned");case 14:case"end":return t.stop()}}),t,null,[[4,11]])}))),function(t,n,i){return e.apply(this,arguments)})}]),t}(),Ii=function(){function t(){o()(this,t)}return u()(t,null,[{key:"IsPrinterAvailable",value:function(t){return!["E355","CM5"].includes(t)}}]),t}(),Fi=function(){function t(){o()(this,t)}return u()(t,[{key:"ToMessage",value:function(){return new Me(qe.Id("trmnl"),_e,{},!0)}}]),t}(),Di=function(){function t(e){o()(this,t),this._m=e}return u()(t,[{key:"GetStatus",value:function(){return this._m.Data.status}},{key:"GetBatteryLevel",value:function(){return parseInt(this._m.Data.battery_level,10)}},{key:"IsCharging",value:function(){return!!this._m.Data.charging}}]),t}(),xi=function t(e){o()(this,t),this.BatteryLevel=parseInt(e.Data.battery_level,10)},Oi=function(){function t(){o()(this,t)}return u()(t,[{key:"ToMessage",value:function(){return new Me(qe.Id("trmnl"),we,{},!0)}}]),t}(),Gi=function(){function t(e){o()(this,t),this._success=e.GetSuccessState()===Ee.Success,this._m=e}return u()(t,[{key:"isSuccess",value:function(){return this._success}},{key:"GetCommsSelected",value:function(){return this._m.Data.comms_selected}},{key:"GetMerchantId",value:function(){return this._m.Data.merchant_id}},{key:"GetPAVersion",value:function(){return this._m.Data.pa_version}},{key:"GetPaymentInterfaceVersion",value:function(){return this._m.Data.payment_interface_version}},{key:"GetPluginVersion",value:function(){return this._m.Data.plugin_version}},{key:"GetSerialNumber",value:function(){return this._m.Data.serial_number}},{key:"GetTerminalId",value:function(){return this._m.Data.terminal_id}},{key:"GetTerminalModel",value:function(){return this._m.Data.terminal_model}}]),t}(),Ni=function(){function t(){o()(this,t)}return u()(t,null,[{key:"CreateTransactionReportEnvelope",value:function(t,e,n,i,r){return Object.assign(new c,{PosVendorId:t,PosVersion:e,LibraryLanguage:n,LibraryVersion:i,SerialNumber:r})}}]),t}(),Bi=function(){function t(e,n){o()(this,t),this.PosRefId=n,this.PurchaseAmount=e,this.StoreCode="",this.Description="",this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"AmountSummary",value:function(){return"Purchase: ".concat((this.PurchaseAmount/100).toFixed(2))}},{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,purchase_amount:this.PurchaseAmount,zip_data:{store_code:this.StoreCode},basket:{description:this.Description}};return this.Config=Object.assign(this.Config,{EnabledPrintMerchantCopy:!0,EnabledPromptForCustomerCopyOnEftpos:!0,EnabledSignatureFlowOnEftpos:!1}),this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("zprchs"),Se,t,!0)}}]),t}(),Li=function(){function t(e,n){o()(this,t),this.PosRefId=n,this.RefundAmount=e,this.OriginalReceiptNumber="",this.Config=new Ne,this.Options=new Be}return u()(t,[{key:"ToMessage",value:function(){var t={pos_ref_id:this.PosRefId,refund_amount:this.RefundAmount,zip_data:{original_receipt_number:this.OriginalReceiptNumber}};return this.Config=Object.assign(this.Config,{EnabledPrintMerchantCopy:!0,EnabledPromptForCustomerCopyOnEftpos:!0,EnabledSignatureFlowOnEftpos:!1}),this.Config.AddReceiptConfig(t),this.Options.AddOptions(t),new Me(qe.Id("zrefund"),Pe,t,!0)}}]),t}(),qi=function(){function t(e,n,i,r){o()(this,t),this._posId=e,this._serialNumber=n,this._secrets=r,this._previousSecrets=null,this._secretsRetryAttempts=0,this._maxSecretsRetryAttempts=4,this._forceSecureWebSockets=this._isSecureConnection(),this._eftposAddress="".concat(this._isSecureConnection()?"wss":"ws","://").concat(i),this._eventBus=document,this._log=console,this.Config=new Ne,this._conn=new an(this),this.CurrentDeviceStatus=null,this._deviceApiKey=null,this._tenantCode=null,this._terminalModel=null,this._inTestMode=!1,this._autoAddressResolutionEnabled=this._isSecureConnection(),this._spiMessageStamp=new be(this._posId,this._secrets),this._hasSetInfo=null,this._posVendorId=null,this._posVersion=null,this._libraryLanguage="js",this._spiceVersion=null,this._transactionReport=new c,this._mostRecentPingSent=null,this._mostRecentPongReceived=null,this._missedPongsCount=0,this._retriesSinceLastDeviceAddressResolution=0,this._mostRecentLoginResponse=null,this._pongTimeout=5e3,this._pingFrequency=18e3,this._readyToTransact=null,this._periodicPingThread=null,this._transactionMonitoringThread=null,this._txMonitorCheckFrequency=1e3,this._checkOnTxFrequency=2e4,this._maxWaitForCancelTx=1e4,this._sleepBeforeReconnectMs=3e3,this._missedPongsToDisconnect=2,this._retriesBeforeResolvingDeviceAddress=3,this._retriesSinceLastPairing=0,this._retriesBeforePairing=3,this._regexItemsForEftposAddress=/^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}(\:[0-9]{1,5})?$/,this._regexItemsForFqdnEftposAddress=/^[a-zA-Z0-9\.-]+$/,this._regexItemsForPosId=/^[a-zA-Z0-9]*$/,this.CurrentFlow=null,this.CurrentPairingFlowState=null,this.CurrentTxFlowState=null}var e,n,i,s;return u()(t,[{key:"CurrentStatus",get:function(){return this._currentStatus},set:function(t){this._currentStatus!==t&&(this._currentStatus=t,this._eventBus.dispatchEvent(new CustomEvent("StatusChanged",{detail:t})))}},{key:"EnablePayAtTable",value:function(){return this._spiPat=new On(this),this._spiPat}},{key:"DisablePayAtTable",value:function(){return this._spiPat=new On(this),this._spiPat.Config.PayAtTableEnabled=!1,this._spiPat}},{key:"EnablePreauth",value:function(){return this._spiPreauth=new si(this),this._spiPreauth}},{key:"Start",value:function(){if(!this._posVendorId||!this._posVersion)throw this._log.warn("Missing POS vendor ID and version. posVendorId and posVersion are required before starting"),new Error("Missing POS vendor ID and version. posVendorId and posVersion are required before starting");this._isPosIdValid(this._posId)||(this._posId="",this._log.warn("Invalid parameter, please correct them before pairing")),this._isEftposAddressValid(this._eftposAddress)||(this._eftposAddress="",this._log.warn("Invalid parameter, please correct them before pairing")),this._resetConn(),this._startTransactionMonitoringThread(),this.CurrentFlow=Ae.Idle,null!=this._secrets?(this._log.info("Starting in Paired State"),this._currentStatus=ke.PairedConnecting,this._conn.Connect()):(this._log.info("Starting in Unpaired State"),this._currentStatus=ke.Unpaired)}},{key:"SetEventBus",value:function(t){return!(!t||"function"!=typeof t.addEventListener||"function"!=typeof t.removeEventListener||"function"!=typeof t.dispatchEvent)&&(this._eventBus=t,!0)}},{key:"SetAcquirerCode",value:function(t){this.SetTenantCode(t)}},{key:"SetTenantCode",value:function(t){return this._tenantCode=t,!0}},{key:"SetDeviceApiKey",value:function(t){return this._deviceApiKey=t,!0}},{key:"SetSerialNumber",value:function(t){var e=this._serialNumber;return this._serialNumber=t,this.HasSerialNumberChanged(e)?this._autoResolveEftposAddress():(null===this.CurrentDeviceStatus&&(this.CurrentDeviceStatus=new yi(this._forceSecureWebSockets)),this.CurrentDeviceStatus.DeviceAddressResponseCode=Ci.SERIAL_NUMBER_NOT_CHANGED,this._eventBus.dispatchEvent(new CustomEvent("DeviceAddressChanged",{detail:this.CurrentDeviceStatus}))),!0}},{key:"SetAutoAddressResolution",value:function(t){var e=this._autoAddressResolutionEnabled;return this._autoAddressResolutionEnabled=t,t&&!e&&this._autoResolveEftposAddress(),!0}},{key:"SetTestMode",value:function(t){return t===this._inTestMode||(this._inTestMode=t,this._autoResolveEftposAddress()),!0}},{key:"SetSecureWebSockets",value:function(t){this._forceSecureWebSockets=t,this._autoResolveEftposAddress()}},{key:"SetPosId",value:function(t){return this.CurrentStatus==ke.Unpaired&&(this._posId="",this._isPosIdValid(t)?(this._posId=t,this._spiMessageStamp.PosId=t,!0):(this._log.info("Pos Id set to null"),!1))}},{key:"SetEftposAddress",value:function(t){return this.CurrentStatus!==ke.PairedConnected&&(this._eftposAddress="",this._isEftposAddressValid(t)?(this._eftposAddress="".concat(this._isSecureConnection()?"wss":"ws","://").concat(t),this._conn.Address=this._getConnectionAddress(this._eftposAddress,this._tenantCode,this._posId),!0):(this._log.info("Eftpos Address set to null"),!1))}},{key:"SetPosInfo",value:function(t,e){this._posVendorId=t,this._posVersion=e}},{key:"SetAdaptorPosInfo",value:function(){return this.CurrentStatus!=ke.Unpaired&&(this._callSetPosInfo(),!0)}},{key:"SetAdaptorInfo",value:function(t){this._spiceVersion=t}},{key:"AckFlowEndedAndBackToIdle",value:function(){return this.CurrentFlow==Ae.Idle||(this.CurrentFlow==Ae.Pairing&&this.CurrentPairingFlowState.Finished||!(this.CurrentFlow!=Ae.Transaction||!this.CurrentTxFlowState.Finished))&&(this.CurrentFlow=Ae.Idle,!0)}},{key:"Pair",value:function(){return this._log.info("Trying to pair ...."),this.CurrentStatus!=ke.Unpaired?(this._log.warn("Tried to Pair, but we're already paired. Stop pairing."),!1):this._isPosIdValid(this._posId)&&this._isEftposAddressValid(this._eftposAddress)?(this.CurrentFlow=Ae.Pairing,this.CurrentPairingFlowState=new Ie({Successful:!1,Finished:!1,Message:"Connecting...",AwaitingCheckFromEftpos:!1,AwaitingCheckFromPos:!1,ConfirmationCode:""}),this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState})),this._conn.Connect(),!0):(this._log.warn("Invalid Pos Id or Eftpos address, stop pairing."),!1)}},{key:"PairingConfirmCode",value:function(){this.CurrentPairingFlowState.AwaitingCheckFromPos&&(this.CurrentPairingFlowState.AwaitingCheckFromPos=!1,this.CurrentPairingFlowState.AwaitingCheckFromEftpos?(this._log.info("Pair Code Confirmed from POS side, but am still waiting for confirmation from Eftpos."),this.CurrentPairingFlowState.Message="Click YES on EFTPOS if code is: "+this.CurrentPairingFlowState.ConfirmationCode,this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}))):(this._log.info("Pair Code Confirmed from POS side, and was already confirmed from Eftpos side. Pairing finalised."),this._onPairingSuccess()))}},{key:"PairingCancel",value:function(){this.CurrentFlow!=Ae.Pairing||this.CurrentPairingFlowState.Finished||(this.CurrentPairingFlowState.AwaitingCheckFromPos&&!this.CurrentPairingFlowState.AwaitingCheckFromEftpos&&this._send((new je).ToMessage()),this._onPairingFailed())}},{key:"Unpair",value:function(){return this.CurrentStatus!=ke.Unpaired&&(this.CurrentFlow==Ae.Idle&&(this._send((new je).ToMessage()),this._doUnpair(),!0))}},{key:"InitiatePurchaseTx",value:function(t,e){if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var n=mi.CreatePurchaseRequest(e,t);n.Config=this.Config;var i=n.ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.Purchase,e,i,"Waiting for EFTPOS connection to make payment request for ".concat(e/100)),this._send(i)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to accept payment for ".concat(e/100)),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Purchase Initiated")}},{key:"InitiatePurchaseTxV2",value:function(t,e,n,i,r){var s=arguments.length>5&&void 0!==arguments[5]?arguments[5]:new Be,o=arguments.length>6&&void 0!==arguments[6]?arguments[6]:0;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");if(n>0&&(i>0||r))return new De(!1,"Cannot Accept Tips and Cashout at the same time.");var a=s;if(!Ii.IsPrinterAvailable(this._terminalModel)&&this._isPrintingConfigEnabled()&&(a=new Be,this.Config.PromptForCustomerCopyOnEftpos=!1,this.Config.PrintMerchantCopy=!1,this.Config.SignatureFlowOnEftpos=!1,this._log.warn("Printing is enabled on a terminal without printer. Printing options will now be disabled.")),this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");this.CurrentFlow=Ae.Transaction;var u=mi.CreatePurchaseRequestV2(t,e,n,i,r,o);u.Config=this.Config,u.Options=a;var h=u.ToMessage();return this.CurrentTxFlowState=new Oe(t,Fe.Purchase,e,h,"Waiting for EFTPOS connection to make payment request. ".concat(u.AmountSummary())),this._send(h)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to accept payment for ".concat(u.AmountSummary())),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Purchase Initiated")}},{key:"InitiateRefundTx",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");var r=i;if(!Ii.IsPrinterAvailable(this._terminalModel)&&this._isPrintingConfigEnabled()&&(r=new Be,this.Config.PromptForCustomerCopyOnEftpos=!1,this.Config.PrintMerchantCopy=!1,this.Config.SignatureFlowOnEftpos=!1,this._log.warn("Printing is enabled on a terminal without printer. Printing options will now be disabled.")),this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var s=mi.CreateRefundRequest(e,t,n);s.Config=this.Config,s.Options=r;var o=s.ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.Refund,e,o,"Waiting for EFTPOS connection to make refund request for ".concat((e/100).toFixed(2))),this._send(o)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to refund ".concat((e/100).toFixed(2))),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Refund Initiated")}},{key:"AcceptSignature",value:function(t){if(this.CurrentFlow!=Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.AwaitingSignatureCheck)return this._log.info("Asked to accept signature but I was not waiting for one."),new xe(!1,"Asked to accept signature but I was not waiting for one.");this.CurrentTxFlowState.SignatureResponded(t?"Accepting Signature...":"Declining Signature...");this.CurrentTxFlowState.SignatureRequiredMessage;return this._send(t?new yn(this.CurrentTxFlowState.PosRefId).ToMessage():new wn(this.CurrentTxFlowState.PosRefId).ToMessage()),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new xe(!0,"")}},{key:"SubmitAuthCode",value:function(t){return 6!=t.length?new Ge(!1,"Not a 6-digit code."):this.CurrentFlow!=Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.AwaitingPhoneForAuth?(this._log.info("Asked to send auth code but I was not waiting for one."),new Ge(!1,"Was not waiting for one.")):(this.CurrentTxFlowState.AuthCodeSent("Submitting Auth Code ".concat(t)),this._send(new Pn(this.CurrentTxFlowState.PosRefId,t).ToMessage()),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new Ge(!0,"Valid Code."))}},{key:"CancelTransaction",value:function(){if(this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished)return this._log.info("Asked to cancel transaction but I was not in the middle of one."),new xe(!1,"Asked to cancel transaction but I was not in the middle of one.");if(this.CurrentTxFlowState.RequestSent){var t=new ln;this.CurrentTxFlowState.Cancelling("Attempting to Cancel Transaction..."),this._send(t.ToMessage())}else this.CurrentTxFlowState.Failed(null,"Transaction Cancelled. Request Had not even been sent yet.");return this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport(),new xe(!0,"")}},{key:"InitiateCashoutOnlyTx",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");var r=i;if(!Ii.IsPrinterAvailable(this._terminalModel)&&this._isPrintingConfigEnabled()&&(r=new Be,this.Config.PromptForCustomerCopyOnEftpos=!1,this.Config.PrintMerchantCopy=!1,this.Config.SignatureFlowOnEftpos=!1,this._log.warn("Printing is enabled on a terminal without printer. Printing options will now be disabled.")),this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var s=Object.assign(new oi(e,t),{SurchargeAmount:n,Options:r,Config:this.Config}).ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.CashoutOnly,e,s,"Waiting for EFTPOS connection to send cashout request for ".concat((e/100).toFixed(2))),this._send(s)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to do cashout for ".concat((e/100).toFixed(2))),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Cashout Initiated")}},{key:"InitiateMotoPurchaseTx",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0,i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");var s=r;if(!Ii.IsPrinterAvailable(this._terminalModel)&&this._isPrintingConfigEnabled()&&(s=new Be,this.Config.PromptForCustomerCopyOnEftpos=!1,this.Config.PrintMerchantCopy=!1,this.Config.SignatureFlowOnEftpos=!1,this._log.warn("Printing is enabled on a terminal without printer. Printing options will now be disabled.")),this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var o=Object.assign(new Cn(e,t),{SurchargeAmount:n,SuppressMerchantPassword:i,Config:this.Config,Options:s}).ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.MOTO,e,o,"Waiting for EFTPOS connection to send MOTO request for ".concat((e/100).toFixed(2))),this._send(o)&&this.CurrentTxFlowState.Sent("Asked EFTPOS do MOTO for ".concat((e/100).toFixed(2))),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"MOTO Initiated")}},{key:"InitiateSettleTx",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");var n=e;if(!Ii.IsPrinterAvailable(this._terminalModel)&&this._isPrintingConfigEnabled()&&(n=new Be,this.Config.PromptForCustomerCopyOnEftpos=!1,this.Config.PrintMerchantCopy=!1,this.Config.SignatureFlowOnEftpos=!1,this._log.warn("Printing is enabled on a terminal without printer. Printing options will now be disabled.")),this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var i=Object.assign(new ui(qe.Id("settle")),{Config:this.Config,Options:n}).ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.Settle,0,i,"Waiting for EFTPOS connection to make a settle request"),this._send(i)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to settle."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Settle Initiated")}},{key:"InitiateSettlementEnquiry",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var n=Object.assign(new ci(qe.Id("stlenq")),{Config:this.Config,Options:e}).ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.SettlementEnquiry,0,n,"Waiting for EFTPOS connection to make a settlement enquiry"),this._send(n)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to make a settlement enquiry."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Settle Initiated")}},{key:"InitiateGetLastTx",value:function(){if(this.CurrentStatus===ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!==Ae.Idle)return new De(!1,"Not Idle");this.CurrentFlow=Ae.Transaction;var t=(new pn).ToMessage(),e=t.Id;return this.CurrentTxFlowState=new Oe(e,Fe.GetLastTransaction,0,t,"Waiting for EFTPOS connection to make a Get-Last-Transaction request."),this._send(t)&&this.CurrentTxFlowState.Sent("Asked EFTPOS for last transaction."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"GLT Initiated")}},{key:"InitiateGetTx",value:function(t){if(this.CurrentStatus===ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!==Ae.Idle)return new De(!1,"Not Idle");var e=new dn(t).ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.GetTransaction,0,e,"Waiting for EFTPOS connection to make a Get Transaction request."),this.CurrentTxFlowState.CallingGt(e.Id),this._send(e)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to Get Transaction ".concat(t,".")),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"GT Initiated")}},{key:"InitiateRecovery",value:function(t,e){if(this.CurrentStatus===ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!==Ae.Idle)return new De(!1,"Not Idle");this.CurrentFlow=Ae.Transaction;var n=new dn(t).ToMessage();return this.CurrentTxFlowState=new Oe(t,e,0,n,"Waiting for EFTPOS connection to attempt recovery."),this.CurrentTxFlowState.CallingGt(n.Id),this._send(n)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to recover state."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Recovery Initiated")}},{key:"InitiateReversal",value:function(t){if(this.CurrentStatus===ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!==Ae.Idle)return new De(!1,"Not Idle");this.CurrentFlow=Ae.Transaction;var e=new Mi(t).ToMessage();return this.CurrentTxFlowState=new Oe(t,Fe.Reversal,0,e,"Waiting for EFTPOS to make a reversal request"),this._send(e)&&this.CurrentTxFlowState.Sent("Asked EFTPOS reversal"),new De(!0,"Reversal Initiated")}},{key:"InitiateZipRefundTx",value:function(t,e,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");var r=Object.assign(new Li(e,t),{Config:this.Config,Options:i,OriginalReceiptNumber:n}),s=r.ToMessage();return this.CurrentFlow=Ae.Transaction,this.CurrentTxFlowState=new Oe(t,Fe.ZipRefund,e,s,"Waiting for EFTPOS connection to make Zip refund request for ".concat(e/100)),this._send(s)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to refund ".concat(e/100)),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Zip Refund Initiated")}},{key:"InitiateZipPurchaseTx",value:function(t,e,n,i){var r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new Be;if(this.CurrentStatus==ke.Unpaired)return new De(!1,"Not Paired");if(this.CurrentFlow!=Ae.Idle)return new De(!1,"Not Idle");this.CurrentFlow=Ae.Transaction;var s=Object.assign(new Bi(e,t),{Config:this.Config,Options:r,Description:n,StoreCode:i}),o=s.ToMessage();return this.CurrentTxFlowState=new Oe(t,Fe.ZipPurchase,e,o,"Waiting for EFTPOS connection to make Zip payment request. ".concat(s.AmountSummary())),this._send(o)&&this.CurrentTxFlowState.Sent("Asked EFTPOS to accept Zip payment for ".concat(s.AmountSummary())),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),new De(!0,"Zip Purchase Initiated")}},{key:"PrintReceipt",value:function(t,e){this.CurrentStatus===ke.PairedConnected&&this._send(new Ei(t,e).toMessage())}},{key:"GetTerminalStatus",value:function(){this.CurrentStatus===ke.PairedConnected&&this._send((new Fi).ToMessage())}},{key:"GetTerminalConfiguration",value:function(){this.CurrentStatus===ke.PairedConnected&&this._send((new Oi).ToMessage())}},{key:"GetTerminalAddress",value:(s=r()(l.a.mark((function t(){var e,n,i,r;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=new Pi,t.prev=1,t.next=4,e.RetrieveDeviceAddress(this._serialNumber,this._deviceApiKey,this._tenantCode,this._isSecureConnection(),this._inTestMode);case 4:return i=t.sent,t.next=7,i.json();case 7:r=t.sent,n=Ri.GenerateDeviceAddressStatus({Data:r,StatusCode:i.status,StatusDescription:i.statusText},this._eftposAddress,this._forceSecureWebSockets),t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),n=Ri.GenerateDeviceAddressStatus({Data:{},StatusCode:null,StatusDescription:t.t0.message},this._eftposAddress,this._forceSecureWebSockets);case 14:return t.abrupt("return",n.Address);case 15:case"end":return t.stop()}}),t,this,[[1,11]])}))),function(){return s.apply(this,arguments)})},{key:"_handleKeyRequest",value:function(t){this.CurrentPairingFlowState.Message="Negotiating Pairing...",this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}));var e=(new Qe).GenerateSecretsAndKeyResponse(new Ke(t));this._secrets=e.Secrets,this._spiMessageStamp.Secrets=this._secrets,this._send(e.KeyResponse.ToMessage())}},{key:"_handleKeyCheck",value:function(t){var e=new Ye(t);this.CurrentPairingFlowState.ConfirmationCode=e.ConfirmationCode,this.CurrentPairingFlowState.AwaitingCheckFromEftpos=!0,this.CurrentPairingFlowState.AwaitingCheckFromPos=!0,this.CurrentPairingFlowState.Message="Confirm that the following Code is showing on the Terminal",this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}))}},{key:"_handlePairResponse",value:function(t){var e=new We(t);this.CurrentPairingFlowState.AwaitingCheckFromEftpos=!1,e.Success?(this.CurrentPairingFlowState.AwaitingCheckFromPos&&(this._log.info("Confirming pairing from library."),this.PairingConfirmCode()),this._log.info("Got Pair Confirm from Eftpos, and already had confirm from POS. Now just waiting for first pong."),this._onPairingSuccess(),this._startPeriodicPing()):this._onPairingFailed()}},{key:"_handleDropKeysAdvice",value:function(t){this._log.info("Eftpos was Unpaired. I shall unpair from my end as well."),this._doUnpair()}},{key:"_onPairingSuccess",value:function(){this.CurrentPairingFlowState.Successful=!0,this.CurrentPairingFlowState.Finished=!0,this.CurrentPairingFlowState.Message="Pairing Successful!",this.CurrentStatus=ke.PairedConnected,this._eventBus.dispatchEvent(new CustomEvent("SecretsChanged",{detail:this._secrets})),this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}))}},{key:"_onPairingFailed",value:function(){this._secrets=null,this._spiMessageStamp.Secrets=null,this.CurrentStatus=ke.Unpaired,this.CurrentPairingFlowState.Message="Pairing Failed",this.CurrentPairingFlowState.Finished=!0,this.CurrentPairingFlowState.Successful=!1,this.CurrentPairingFlowState.AwaitingCheckFromPos=!1,this._conn.Disconnect(),this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}))}},{key:"_doUnpair",value:function(){this.CurrentStatus=ke.Unpaired,this._conn.Disconnect(),this._secrets=null,this._spiMessageStamp.Secrets=null,this._hasSetInfo=null,this._eventBus.dispatchEvent(new CustomEvent("SecretsChanged",{detail:this._secrets}))}},{key:"_handleKeyRollingRequest",value:function(t){this._previousSecrets=this._secrets;var e=gi.PerformKeyRolling(t,this._secrets);this._secrets=e.NewSecrets,this._spiMessageStamp.Secrets=this._secrets,this._send(e.KeyRollingConfirmation),this._eventBus.dispatchEvent(new CustomEvent("SecretsChanged",{detail:this._secrets}))}},{key:"_handleInvalidHmacSignature",value:function(){if(!this._previousSecrets||this._secretsRetryAttempts>=this._maxSecretsRetryAttempts)return this._previousSecrets=null,this._secretsRetryAttempts=0,void this._log.info("I could not verify message from Eftpos. You might have to Un-pair Eftpos and then reconnect.");var t=this._secrets;this._secrets=this._previousSecrets,this._spiMessageStamp.Secrets=this._previousSecrets,this._previousSecrets=t,this._secretsRetryAttempts+=1,this._eventBus.dispatchEvent(new CustomEvent("SecretsChanged",{detail:this._secrets})),this._log.info("I could not verify message from Eftpos. Swapping stored secrets and re-attempting connection")}},{key:"_handleSignatureRequired",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!=Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId==e?this._log.info("Received Signature Required but I was not waiting for one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.SignatureRequired(new vn(t),"Ask Customer to Sign the Receipt"),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})))}},{key:"_handleAuthCodeRequired",value:function(t){var e=t.Data.pos_ref_id;if(this.CurrentFlow!=Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId==e)_log.info("Received Auth Code Required but I was not waiting for one. Incoming Pos Ref ID: ".concat(e));else{var n=new Tn(t),i="Auth Code Required. Call ".concat(n.GetPhoneNumber()," and quote merchant id ").concat(n.GetMerchantId());this.CurrentTxFlowState.PhoneForAuthRequired(n,i),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState}))}}},{key:"_handlePurchaseResponse",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Purchase response but I was not waiting for one. Incoming Pos Ref ID: ".concat(e,'"')):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Purchase Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleCashoutOnlyResponse",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Cashout Response but I was not waiting for one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Cashout Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleMotoPurchaseResponse",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Moto Response but I was not waiting for one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Moto Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleRefundResponse",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished|!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Refund response but I was not waiting for this one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Refund Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleSettleResponse",value:function(t){this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished?this._log.info("Received Settle response but I was not waiting for one. ".concat(t.DecryptedJson)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Settle Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleSettlementEnquiryResponse",value:function(t){this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished?this._log.info("Received Settlement Enquiry response but I was not waiting for one. ".concat(t.DecryptedJson)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Settlement Enquiry Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleReversalTransaction",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Reversal response but I was not waiting for this one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Reversal Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleErrorEvent",value:function(t){this.CurrentFlow===Ae.Transaction&&!this.CurrentTxFlowState.Finished&&this.CurrentTxFlowState.AttemptingToCancel&&"NO_TRANSACTION"===t.GetError()?(this._log.info("Was trying to cancel a transaction but there is nothing to cancel. Calling GT to see what's up"),this._callGetTransaction(this.CurrentTxFlowState.PosRefId)):this._log.info("Received Error Event But Don't know what to do with it. ".concat(t.DecryptedJson))}},{key:"_handleGetTransactionResponse",value:function(t){var e=this.CurrentTxFlowState;if(this.CurrentFlow!==Ae.Transaction||e.Finished)this._log.info("Received gt response but we were not in the middle of a tx. ignoring.");else if(e.AwaitingGtResponse)if(e.GtRequestId===t.Id){this._log.info("Got Transaction."),e.GotGtResponse();var n=new fn(t);if(n.WasRetrievedSuccessfully()){var i=n.GetTxMessage();if(null===i)return void this._log.info("GTR-09: Unexpected Response in Get Transaction. Missing TX payload... stay waiting");n.CopyMerchantReceiptToCustomerReceipt(),e.Type===Fe.GetTransaction?(this._log.info("GTR-10: Retrieved Transaction as asked directly by the user."),e.Completed(i.GetSuccessState(),i,"Transaction Retrieved for ".concat(n.GetPosRefId(),"."))):(this._log.info("GTR-11: Retrieved transaction during recovery."),e.Completed(i.GetSuccessState(),i,"Transaction Recovered for ".concat(n.GetPosRefId(),".")))}else if(n.IsWaitingForSignatureResponse()){if(e.AwaitingSignatureCheck)return void this._log.info("Waiting for Signature response ... stay waiting.");this._log.info("GTR-01: Eftpos is waiting for us to send it signature accept/decline, but we were not aware of this. The user can only really decline at this stage as there is no receipt to print for signing."),e.SignatureRequired(new vn(t).SignatureRequired(e.PosRefId,t.Id,"MISSING RECEIPT\n DECLINE AND TRY AGAIN."),"Recovered in Signature Required but we don't have receipt. You may Decline then Retry.")}else if(n.IsWaitingForAuthCode()&&!e.AwaitingPhoneForAuth)this._log.info("GTR-02: Eftpos is waiting for us to send it auth code, but we were not aware of this. We can only cancel the transaction at this stage as we don't have enough information to recover from this."),e.PhoneForAuthRequired(new Tn(e.PosRefId,t.Id,"UNKNOWN","UNKNOWN"),"Recovered mid Phone-For-Auth but don't have details. You may Cancel then Retry.");else{if(n.IsTransactionInProgress())return void this._log.info("GTR-03: Transaction is currently in progress... stay waiting.");if(n.PosRefIdNotFound())this._log.info("GTR-04: Get transaction failed, PosRefId is not found."),e.Completed(Ee.Failed,t,"PosRefId not found for ".concat(n.GetPosRefId(),"."));else if(n.PosRefIdInvalid())this._log.info("GTR-05: Get transaction failed, PosRefId is invalid."),e.Completed(Ee.Failed,t,"PosRefId invalid for ".concat(n.GetPosRefId(),"."));else if(n.PosRefIdMissing())this._log.info("GTR-06: Get transaction failed, PosRefId is missing."),e.Completed(Ee.Failed,t,"PosRefId is missing for ".concat(n.GetPosRefId(),"."));else{if(n.IsSomethingElseBlocking())return void this._log.info("GTR-07: Terminal is Blocked by something else... stay waiting.");this._log.info("GTR-08: Unexpected Response in Get Transaction - Received posRefId:".concat(n.GetPosRefId()," Error:").concat(t.GetError(),".")),e.Completed(Ee.Failed,t,"Get Transaction failed, ".concat(t.GetError(),"."))}}this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:e}))}else this._log.info("received a gt response but the message id does not match the gt request that we sent. strange. ignoring.");else this._log.info("received a gt response but we had not asked for one within this transaction. Perhaps leftover from previous one. ignoring.")}},{key:"_handleGetLastTransactionResponse",value:function(t){var e=this.CurrentTxFlowState;if(this.CurrentFlow!==Ae.Transaction||e.Finished||e.Type!==Fe.GetLastTransaction)this._log.info("Received glt response but we were not expecting one. ignoring.");else{this._log.info("Got Last Transaction Response..");var n=new mn(t);n.WasRetrievedSuccessfully()?(this._log.info("Retrieved Last Transaction as asked directly by the user."),n.CopyMerchantReceiptToCustomerReceipt(),e.Completed(t.GetSuccessState(),t,"Last Transaction Retrieved")):(this._log.info("Error in Response for Get Last Transaction - Received posRefId:".concat(n.GetPosRefId()," Error:").concat(t.GetError(),". UnknownCompleted.")),e.UnknownCompleted("Failed to Retrieve Last Transaction")),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:e})),this._sendTransactionReport()}}},{key:"_handleCancelTransactionResponse",value:function(t){var e=t.Data.pos_ref_id,n=this.CurrentTxFlowState,i=new cn(t);this.CurrentFlow===Ae.Transaction&&!n.Finished&&!n.PosRefId!==e||i.WasTxnPastPointOfNoReturn()?i.Success||(this._log.warn("Failed to cancel transaction: reason="+i.GetErrorReason()+", detail="+i.GetErrorDetail()),n.CancelFailed("Failed to cancel transaction: "+i.GetErrorDetail()+". Check EFTPOS."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:n})),this._sendTransactionReport()):this._log.info("Received Cancel Required but I was not waiting for one. Incoming Pos Ref ID: ".concat(e))}},{key:"_handleSetPosInfoResponse",value:function(t){var e=new fi(t);e.isSuccess()?(this._hasSetInfo=!0,this._log.info("Setting POS info successful")):this._log.warn("Setting POS info failed: reason="+e.getErrorReason()+", detail="+e.getErrorDetail())}},{key:"_startTransactionMonitoringThread",value:function(){var t=this,e=!1,n=this.CurrentTxFlowState;if(this.CurrentFlow===Ae.Transaction&&!n.Finished){var i=n;i.AttemptingToCancel&&Date.now()>i.CancelAttemptTime+this._maxWaitForCancelTx?(this._log.info("Been too long waiting for transaction to cancel."),n.UnknownCompleted("Waited long enough for Cancel Transaction result. Check EFTPOS. "),e=!0):i.RequestSent&&Date.now()>i.LastStateRequestTime+this._checkOnTxFrequency&&(n.Type===Fe.GetLastTransaction?(n.LastStateRequestTime=Date.Now(),this._send((new pn).ToMessage()),this._log.info("Been to long waiting for GLT response. Sending another GLT. Last checked at ".concat(i.LastStateRequestTime,"..."))):(this._log.info("Checking on our transaction. Last checked at ".concat(i.LastStateRequestTime,"...")),this._callGetTransaction(n.PosRefId)))}e&&this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._transactionMonitoringThread=setTimeout((function(){return t._startTransactionMonitoringThread()}),this._txMonitorCheckFrequency)}},{key:"PrintingResponse",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"TerminalStatusResponse",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"TerminalConfigurationResponse",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"BatteryLevelChanged",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"TransactionUpdateMessage",value:function(t){throw new Error("Method not implemented. Please overwrite this method in your POS")}},{key:"_handlePrintingResponse",value:function(t){"function"==typeof this.PrintingResponse&&this.PrintingResponse(t)}},{key:"_handleTransactionUpdateMessage",value:function(t){"function"==typeof this.TransactionUpdateMessage&&this.TransactionUpdateMessage(t)}},{key:"_handleTerminalStatusResponse",value:function(t){"function"==typeof this.TerminalStatusResponse&&this.TerminalStatusResponse(t)}},{key:"_handleTerminalConfigurationResponse",value:function(t){var e=new Gi(t);e.isSuccess()&&(this._serialNumber=e.GetSerialNumber(),this._terminalModel=e.GetTerminalModel()),"function"==typeof this.TerminalStatusResponse&&this.TerminalConfigurationResponse(t)}},{key:"_handleBatteryLevelChanged",value:function(t){"function"==typeof this.BatteryLevelChanged&&this.BatteryLevelChanged(t)}},{key:"_isPrintingConfigEnabled",value:function(){return!!(this.Config.PromptForCustomerCopyOnEftpos||this.Config.PrintMerchantCopy||this.Config.SignatureFlowOnEftpos)}},{key:"_handleZipPurchaseResponse",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Zip Purchase response but I was not waiting for one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Zip Purchase Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_handleZipRefundResponse",value:function(t){var e=t.Data.pos_ref_id;this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished||!this.CurrentTxFlowState.PosRefId===e?this._log.info("Received Zip Refund response but I was not waiting for this one. Incoming Pos Ref ID: ".concat(e)):(this.CurrentTxFlowState.Completed(t.GetSuccessState(),t,"Zip Refund Transaction Ended."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})),this._sendTransactionReport())}},{key:"_resetConn",value:function(){var t=this;this._conn=new an(this),(this._isUsingHttps()||this._forceSecureWebSockets)&&(this._log.info("Secure connection detected."),this._eftposAddress=this._eftposAddress.replace("ws://","wss://"),this._autoResolveEftposAddress()),this._conn.Address=this._getConnectionAddress(this._eftposAddress,this._tenantCode,this._posId),this._eventBus.addEventListener("ConnectionStatusChanged",(function(e){return t._onSpiConnectionStatusChanged(e.detail)})),this._eventBus.addEventListener("MessageReceived",(function(e){return t._onSpiMessageReceived(e.detail)})),this._eventBus.addEventListener("ErrorReceived",(function(e){return t._onWsErrorReceived(e.detail)}))}},{key:"_onSpiConnectionStatusChanged",value:function(t){var e=this;switch(t.ConnectionState){case nn:this._log.info("I'm Connecting to the Eftpos at ".concat(this._eftposAddress,"..."));break;case rn:if(this._retriesSinceLastDeviceAddressResolution=0,this._spiMessageStamp.ResetConnection(),this.CurrentFlow==Ae.Pairing&&this.CurrentStatus==ke.Unpaired){this._previousSecrets=null,this._secretsRetryAttempts=0,this.CurrentPairingFlowState.Message="Requesting to Pair...",this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}));var n=Qe.NewPairRequest();this._send(n.ToMessage())}else this._log.info("I'm Connected to ".concat(this._eftposAddress,"...")),this._spiMessageStamp.Secrets=this._secrets,this._startPeriodicPing();break;case en:if(this._log.info("I'm disconnected from ".concat(this._eftposAddress,"...")),this._mostRecentPingSent=null,this._mostRecentPongReceived=null,this._missedPongsCount=0,this._stopPeriodicPing(),this._spiMessageStamp.ResetConnection(),this.CurrentStatus!=ke.Unpaired){if(this.CurrentStatus=ke.PairedConnecting,this.CurrentFlow!=Ae.Transaction||this.CurrentTxFlowState.Finished||this._log.info("Lost connection in the middle of a transaction..."),this.CurrentFlow===Ae.Transaction&&this.CurrentTxFlowState&&this.CurrentTxFlowState.Type===Fe.Reversal&&(this.CurrentTxFlowState.Completed(Ee.Failed,null,"We were in the middle of a reversal when a disconnection happened, let's fail the reversal."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState}))),null==this._conn)return;this._autoAddressResolutionEnabled&&(this._retriesSinceLastDeviceAddressResolution>=this._retriesBeforeResolvingDeviceAddress?(this._autoResolveEftposAddress(),this._retriesSinceLastDeviceAddressResolution=0):this._retriesSinceLastDeviceAddressResolution+=1),this._log.info("Will try to reconnect in ".concat(this._sleepBeforeReconnectMs,"ms...")),setTimeout((function(){e.CurrentStatus!=ke.Unpaired&&e._conn&&e._conn.Connect()}),this._sleepBeforeReconnectMs)}else if(this.CurrentFlow==Ae.Pairing){if(this.CurrentPairingFlowState.Finished)return;if(this._retriesSinceLastPairing>=this._retriesBeforePairing)return this._retriesSinceLastPairing=0,this._log.warn("Lost Connection during pairing."),this._onPairingFailed(),void this._eventBus.dispatchEvent(new CustomEvent("PairingFlowStateChanged",{detail:this.CurrentPairingFlowState}));this._log.info("Will try to re-pair in ".concat(this._sleepBeforeReconnectMs,"ms ...")),setTimeout((function(){e.CurrentStatus!=ke.PairedConnected&&e._conn&&e._conn.Connect(),e._retriesSinceLastPairing+=1}),this._sleepBeforeReconnectMs)}break;default:throw new Error("Unknown state: "+t)}}},{key:"_startPeriodicPing",value:function(){var t=this;this._stopPeriodicPing(),this._periodicPingThread=setInterval((function(){return t._periodicPing()}),this._pingFrequency),this._periodicPing()}},{key:"_periodicPing",value:function(){var t=this;this._conn.Connected&&null!==this._secrets?(this._doPing(),setTimeout((function(){if(null!==t._mostRecentPingSent&&(null===t._mostRecentPongReceived||t._mostRecentPongReceived.Id!==t._mostRecentPingSent.Id)){if(t._missedPongsCount+=1,t._log.info("Eftpos didn't reply to my Ping. Missed Count: ".concat(t._missedPongsCount,"/").concat(t._missedPongsToDisconnect,".")),t._missedPongsCount<t._missedPongsToDisconnect)return t._log.info("Trying another ping..."),void t._startPeriodicPing();t._log.info("Disconnecting..."),t._conn.Disconnect(),t._stopPeriodicPing()}t._missedPongsCount=0}),this._pongTimeout)):(this._stopPeriodicPing(),this._log.info("Cancelling periodic ping as were disconnected or not paired"))}},{key:"_onReadyToTransact",value:function(){this._log.info("On Ready To Transact!"),this.CurrentStatus=ke.PairedConnected,this.CurrentFlow!==Ae.Transaction||this.CurrentTxFlowState.Finished?(this._hasSetInfo||(this._callSetPosInfo(),this._transactionReport=Ni.CreateTransactionReportEnvelope(this._posVendorId,this._posVersion,this._libraryLanguage,t.GetVersion(),this._serialNumber)),this._spiPat&&this._spiPat.PushPayAtTableConfig(),this.GetTerminalConfiguration()):this.CurrentTxFlowState.RequestSent?this._callGetTransaction(this.CurrentTxFlowState.PosRefId):(this._send(this.CurrentTxFlowState.Request),this.CurrentTxFlowState.Sent("Sending Request Now..."),this._eventBus.dispatchEvent(new CustomEvent("TxFlowStateChanged",{detail:this.CurrentTxFlowState})))}},{key:"_callSetPosInfo",value:function(){var t=new di(this._posVersion,this._posVendorId,this._spiceVersion,this._libraryLanguage,"2.9.1",pi.GetAppDeviceInfo());this._send(t.toMessage())}},{key:"_stopPeriodicPing",value:function(){this._periodicPingThread&&(clearInterval(this._periodicPingThread),this._periodicPingThread=null)}},{key:"_doPing",value:function(){var t=wi.GeneratePingRequest();this._mostRecentPingSent=t,this._send(t),this._mostRecentPingSentTime=Date.now()}},{key:"_handleIncomingPong",value:function(t){null==this._mostRecentPongReceived&&(this._spiMessageStamp.SetConnectionId(t.ConnId),this.CurrentStatus!=ke.Unpaired?(this._log.info("First pong of connection and in paired state."),this._onReadyToTransact()):this._log.info("First pong of connection but pairing process not finalised yet.")),this._mostRecentPongReceived=t,this._eventBus.dispatchEvent(new CustomEvent("SpiPong",{detail:t})),this._log.debug("PongLatency:".concat(Date.now()-this._mostRecentPingSentTime))}},{key:"_handleIncomingPing",value:function(t){var e=vi.GeneratePongResponse(t);this._send(e)}},{key:"_callGetTransaction",value:function(t){var e=new dn(t).ToMessage();this.CurrentTxFlowState.CallingGt(e.Id),this._send(e)}},{key:"_onSpiMessageReceived",value:function(t){var e=Me.FromJson(t.Message,this._secrets);if(this._log.info("Received:"+e.DecryptedJson),si.IsPreauthEvent(e.EventName))this._spiPreauth._handlePreauthMessage(e);else switch(e.EventName){case Ct:this._handleKeyRequest(e);break;case Tt:this._handleKeyCheck(e);break;case Pt:this._handlePairResponse(e);break;case Rt:this._handleDropKeysAdvice(e);break;case kt:this._handlePurchaseResponse(e);break;case Lt:this._handleRefundResponse(e);break;case Vt:this._handleCashoutOnlyResponse(e);break;case zt:this._handleMotoPurchaseResponse(e);break;case qt:this._handleSignatureRequired(e);break;case Ht:this._handleAuthCodeRequired(e);break;case Ot:this._handleGetTransactionResponse(e);break;case Dt:this._handleGetLastTransactionResponse(e);break;case Jt:this._handleSettleResponse(e);break;case $t:this._handleSettlementEnquiryResponse(e);break;case Nt:this._handleReversalTransaction(e);break;case Et:this._handleIncomingPing(e);break;case bt:this._handleIncomingPong(e);break;case ee:this._handleKeyRollingRequest(e);break;case It:this._handleCancelTransactionResponse(e);break;case te:this._handleSetPosInfoResponse(e);break;case se:if(null==this._spiPat){this._send(An.FeatureDisableMessage(qe.Id("patconf")));break}this._spiPat._handleGetTableConfig(e);break;case ae:this._spiPat._handleGetBillDetailsRequest(e);break;case he:this._spiPat._handleBillPaymentAdvice(e);break;case le:this._spiPat._handleGetOpenTablesRequest(e);break;case de:this._spiPat._handleBillPaymentFlowEnded(e);break;case me:this._handlePrintingResponse(e);break;case ge:this._handleTransactionUpdateMessage(e);break;case ve:this._handleTerminalStatusResponse(e);break;case ye:this._handleTerminalConfigurationResponse(e);break;case Ce:this._handleBatteryLevelChanged(e);break;case Te:this._handleZipPurchaseResponse(e);break;case Re:this._handleZipRefundResponse(e);break;case ie:this._handleErrorEvent(e);break;case re:this._handleInvalidHmacSignature(e);break;default:this._log.info("I don't Understand Event: ".concat(e.EventName,", ").concat(e.Data,". Perhaps I have not implemented it yet."))}}},{key:"_onWsErrorReceived",value:function(t){this._log.warn("Received WS Error",t.Message)}},{key:"_send",value:function(t){var e=t.ToJson(this._spiMessageStamp);return this._conn.Connected?(this._log.info("Sending: "+t.DecryptedJson),this._conn.Send(e),!0):(this._log.info("Asked to send, but not connected: "+t.DecryptedJson),!1)}},{key:"_isPosIdValid",value:function(t){return t?t.length>16?(this._log.warn("Pos Id is greater than 16 characters"),!1):!!t.match(this._regexItemsForPosId)||(this._log.warn("Pos Id cannot include special characters"),!1):(this._log.warn("Pos Id cannot be null or empty"),!1)}},{key:"_isEftposAddressValid",value:function(t){if(!t)return this._log.warn("The Eftpos address cannot be null or empty"),!1;var e=t.replace(/^w[s]?s:\/\//,"");return!(!this._isSecureConnection()&&!e.match(this._regexItemsForEftposAddress)||this._isSecureConnection()&&!e.match(this._regexItemsForFqdnEftposAddress))||(this._log.warn("The Eftpos address is not in the right format"),!1)}},{key:"HasSerialNumberChanged",value:function(t){return this._serialNumber!=t}},{key:"_autoResolveEftposAddress",value:(i=r()(l.a.mark((function t(){var e,n,i,r,s;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this._autoAddressResolutionEnabled){t.next=2;break}return t.abrupt("return");case 2:if(this._serialNumber&&this._deviceApiKey){t.next=5;break}return this._log.warn("Missing serialNumber and/or deviceApiKey. Need to set them before for Auto Address to work."),t.abrupt("return");case 5:return e=this._isSecureConnection(),n=new Pi,t.prev=7,t.next=10,n.RetrieveDeviceAddress(this._serialNumber,this._deviceApiKey,this._tenantCode,e,this._inTestMode);case 10:return r=t.sent,t.next=13,r.json();case 13:s=t.sent,i=Ri.GenerateDeviceAddressStatus({Data:s,StatusCode:r.status,StatusDescription:r.statusText},this._eftposAddress,this._forceSecureWebSockets),t.next=21;break;case 17:t.prev=17,t.t0=t.catch(7),this._log.warn("An error occurred communicating with the device address services",t.t0),i=Ri.GenerateDeviceAddressStatus({Data:{},StatusCode:null,StatusDescription:t.t0.message},this._eftposAddress,this._forceSecureWebSockets);case 21:if(this.CurrentDeviceStatus=i,i.DeviceAddressResponseCode!==Ci.DEVICE_SERVICE_ERROR){t.next=27;break}return this._log.warn("Could not communicate with device address service."),t.abrupt("return");case 27:if(i.DeviceAddressResponseCode!==Ci.INVALID_SERIAL_NUMBER){t.next=32;break}return this._log.warn("Could not resolve address, invalid serial number."),t.abrupt("return");case 32:if(i.DeviceAddressResponseCode!==Ci.ADDRESS_NOT_CHANGED){t.next=36;break}return this._log.warn("Address resolved, but device address has not changed."),this._eventBus.dispatchEvent(new CustomEvent("DeviceAddressChanged",{detail:this.CurrentDeviceStatus})),t.abrupt("return");case 36:this._eftposAddress="".concat(e?"wss":"ws","://").concat(i.Address),this._conn.Address=this._getConnectionAddress(this._eftposAddress,this._tenantCode,this._posId),this._log.info("Address resolved to ".concat(i.Address)),this._eventBus.dispatchEvent(new CustomEvent("DeviceAddressChanged",{detail:this.CurrentDeviceStatus}));case 40:case"end":return t.stop()}}),t,this,[[7,17]])}))),function(){return i.apply(this,arguments)})},{key:"_sendTransactionReport",value:(n=r()(l.a.mark((function t(){var e,n;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return e=this.CurrentTxFlowState,(n=this._transactionReport).TxType=e.Type,n.TxResult=e.Success,n.TxStartTime=e.RequestTime,n.TxEndTime=e.RequestTime,n.DurationMs=e.CompletedTime-e.RequestTime,n.CurrentFlow=this.CurrentFlow,n.CurrentTxFlowState=e.Type,n.CurrentStatus=this.CurrentStatus,n.PosRefId=e.PosRefId,n.Event="Waiting for Signature: ".concat(e.AwaitingSignatureCheck,", Attemtping to Cancel: ").concat(e.AttemptingToCancel,", Finished: ").concat(e.Finished),n.SerialNumber=this._serialNumber,t.prev=13,t.next=16,d.ReportTransaction(n,this._deviceApiKey,this._tenantCode,this._inTestMode);case 16:t.next=22;break;case 18:t.prev=18,t.t0=t.catch(13),this._log.error(t.t0),this._log.warn("Error reporting to analytics service.");case 22:case"end":return t.stop()}}),t,this,[[13,18]])}))),function(){return n.apply(this,arguments)})},{key:"_isUsingHttps",value:function(){return"https:"==document.location.protocol}},{key:"_isSecureConnection",value:function(){return this._isUsingHttps()||this._forceSecureWebSockets}},{key:"_getConnectionAddress",value:function(t,e,n){var i;if(""===t||null!==e&&"wbc"===e.toLowerCase())i=t;else{var r=t.split(":");i=r[0]+":"+r[1]+("ws"===r[0]?":8080":":8443")}return"".concat(i,"?posId=").concat(n)}}],[{key:"GetVersion",value:function(){return"2.9.1"}},{key:"GetAvailableTenants",value:(e=r()(l.a.mark((function t(e,n,i){var r,s;return l.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,Ai.RetrieveTenantsList(e,n,i);case 3:return r=t.sent,s=r.data,t.abrupt("return",{Data:s});case 8:return t.prev=8,t.t0=t.catch(0),t.abrupt("return",{Data:[]});case 11:case"end":return t.stop()}}),t,null,[[0,8]])}))),function(t,n,i){return e.apply(this,arguments)})}]),t}(),Ui=function(){function t(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"\n";o()(this,t),this.buffer=[],this.element=e,this.lineSeperator=n}return u()(t,[{key:"Info",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];this.buffer.push(e.join(" ")),this._render()}},{key:"Debug",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];this.buffer.push(e.join(" ")),this._render()}},{key:"Warn",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];this.buffer.push(e.join(" ")),this._render()}},{key:"Error",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];this.buffer.push(e.join(" ")),this._render()}},{key:"Console",value:function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];console.log(e.join(" "))}},{key:"_render",value:function(){this.element.innerText=this.buffer.join(this.lineSeperator),this.element.scrollTop=this.element.scrollHeight}},{key:"Clear",value:function(){this.buffer=[],this._render()}}]),t}()}])}));
//# sourceMappingURL=spi-client-js.js.map