-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathwaxjs.js
1 lines (1 loc) · 59.7 KB
/
waxjs.js
1
var waxjs=function(t){var e={};function n(r){if(e[r])return e[r].exports;var i=e[r]={i:r,l:!1,exports:{}};return t[r].call(i.exports,i,i.exports,n),i.l=!0,i.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},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 r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)n.d(r,i,function(e){return t[e]}.bind(null,i));return r},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=3)}([function(t,e,n){"use strict";var r=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a},i=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(r(arguments[e]));return t},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var a=n(6).RIPEMD160.hash,s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";var c=function(){for(var t=Array(256).fill(-1),e=0;e<s.length;++e)t[s.charCodeAt(e)]=e;return t}();var l,f=function(){for(var t=Array(256).fill(-1),e=0;e<u.length;++e)t[u.charCodeAt(e)]=e;return t["=".charCodeAt(0)]=0,t}();function h(t){return 0!=(128&t[t.length-1])}function p(t){for(var e=1,n=0;n<t.length;++n){var r=(255&~t[n])+e;t[n]=r,e=r>>8}}function d(t,e){for(var n=new Uint8Array(t),r=0;r<e.length;++r){var i=e.charCodeAt(r);if(i<"0".charCodeAt(0)||i>"9".charCodeAt(0))throw new Error("invalid number");for(var o=i-"0".charCodeAt(0),a=0;a<t;++a){var s=10*n[a]+o;n[a]=s,o=s>>8}if(o)throw new Error("number is out of range")}return n}function y(t,e){void 0===e&&(e=1);for(var n=Array(e).fill("0".charCodeAt(0)),r=t.length-1;r>=0;--r){for(var o=t[r],a=0;a<n.length;++a){var s=(n[a]-"0".charCodeAt(0)<<8)+o;n[a]="0".charCodeAt(0)+s%10,o=s/10|0}for(;o;)n.push("0".charCodeAt(0)+o%10),o=o/10|0}return n.reverse(),String.fromCharCode.apply(String,i(n))}function v(t,e){for(var n=new Uint8Array(t),r=0;r<e.length;++r){var i=c[e.charCodeAt(r)];if(i<0)throw new Error("invalid base-58 value");for(var o=0;o<t;++o){var a=58*n[o]+i;n[o]=a,i=a>>8}if(i)throw new Error("base-58 value is out of range")}return n.reverse(),n}function g(t,e){var n,r,a,u;void 0===e&&(e=1);var l=[];try{for(var f=o(t),h=f.next();!h.done;h=f.next()){for(var p=h.value,d=0;d<l.length;++d){var y=(c[l[d]]<<8)+p;l[d]=s.charCodeAt(y%58),p=y/58|0}for(;p;)l.push(s.charCodeAt(p%58)),p=p/58|0}}catch(t){n={error:t}}finally{try{h&&!h.done&&(r=f.return)&&r.call(f)}finally{if(n)throw n.error}}try{for(var v=o(t),g=v.next();!g.done;g=v.next()){if(g.value)break;l.push("1".charCodeAt(0))}}catch(t){a={error:t}}finally{try{g&&!g.done&&(u=v.return)&&u.call(v)}finally{if(a)throw a.error}}return l.reverse(),String.fromCharCode.apply(String,i(l))}function b(t,e){for(var n=new Uint8Array(t.length+e.length),r=0;r<t.length;++r)n[r]=t[r];for(r=0;r<e.length;++r)n[t.length+r]=e.charCodeAt(r);return a(n)}function m(t,e,n,r){var i=v(n+4,t),o={type:e,data:new Uint8Array(i.buffer,0,n)},a=new Uint8Array(b(o.data,r));if(a[0]!==i[n+0]||a[1]!==i[n+1]||a[2]!==i[n+2]||a[3]!==i[n+3])throw new Error("checksum doesn't match");return o}function w(t,e,n){for(var r=new Uint8Array(b(t.data,e)),i=new Uint8Array(t.data.length+4),o=0;o<t.data.length;++o)i[o]=t.data[o];for(o=0;o<4;++o)i[o+t.data.length]=r[o];return n+g(i)}function _(t){if("string"!=typeof t)throw new Error("expected string containing public key");if("EOS"===t.substr(0,3)){for(var n=v(e.publicKeyDataSize+4,t.substr(3)),r={type:l.k1,data:new Uint8Array(e.publicKeyDataSize)},i=0;i<e.publicKeyDataSize;++i)r.data[i]=n[i];var o=new Uint8Array(a(r.data));if(o[0]!==n[e.publicKeyDataSize]||o[1]!==n[34]||o[2]!==n[35]||o[3]!==n[36])throw new Error("checksum doesn't match");return r}if("PUB_K1_"===t.substr(0,7))return m(t.substr(7),l.k1,e.publicKeyDataSize,"K1");if("PUB_R1_"===t.substr(0,7))return m(t.substr(7),l.r1,e.publicKeyDataSize,"R1");throw new Error("unrecognized public key format")}function A(t){if(t.type===l.k1&&t.data.length===e.publicKeyDataSize)return w(t,"K1","PUB_K1_");if(t.type===l.r1&&t.data.length===e.publicKeyDataSize)return w(t,"R1","PUB_R1_");throw new Error("unrecognized public key format")}function x(t){return"EOS"===t.substr(0,3)?A(_(t)):t}e.isNegative=h,e.negate=p,e.decimalToBinary=d,e.signedDecimalToBinary=function(t,e){var n="-"===e[0];n&&(e=e.substr(1));var r=d(t,e);if(n){if(p(r),!h(r))throw new Error("number is out of range")}else if(h(r))throw new Error("number is out of range");return r},e.binaryToDecimal=y,e.signedBinaryToDecimal=function(t,e){if(void 0===e&&(e=1),h(t)){var n=t.slice();return p(n),"-"+y(n,e)}return y(t,e)},e.base58ToBinary=v,e.binaryToBase58=g,e.base64ToBinary=function(t){var e=t.length;if(1==(3&e)&&"="===t[e-1]&&(e-=1),0!=(3&e))throw new Error("base-64 value is not padded correctly");var n=e>>2,r=3*n;e>0&&"="===t[e-1]&&("="===t[e-2]?r-=2:r-=1);for(var i=new Uint8Array(r),o=0;o<n;++o){var a=f[t.charCodeAt(4*o+0)],s=f[t.charCodeAt(4*o+1)],u=f[t.charCodeAt(4*o+2)],c=f[t.charCodeAt(4*o+3)];i[3*o+0]=a<<2|s>>4,3*o+1<r&&(i[3*o+1]=(15&s)<<4|u>>2),3*o+2<r&&(i[3*o+2]=(3&u)<<6|c)}return i},function(t){t[t.k1=0]="k1",t[t.r1=1]="r1"}(l=e.KeyType||(e.KeyType={})),e.publicKeyDataSize=33,e.privateKeyDataSize=32,e.signatureDataSize=65,e.stringToPublicKey=_,e.publicKeyToString=A,e.convertLegacyPublicKey=x,e.convertLegacyPublicKeys=function(t){return t.map(x)},e.stringToPrivateKey=function(t){if("string"!=typeof t)throw new Error("expected string containing private key");if("PVT_R1_"===t.substr(0,7))return m(t.substr(7),l.r1,e.privateKeyDataSize,"R1");throw new Error("unrecognized private key format")},e.privateKeyToString=function(t){if(t.type===l.r1)return w(t,"R1","PVT_R1_");throw new Error("unrecognized private key format")},e.stringToSignature=function(t){if("string"!=typeof t)throw new Error("expected string containing signature");if("SIG_K1_"===t.substr(0,7))return m(t.substr(7),l.k1,e.signatureDataSize,"K1");if("SIG_R1_"===t.substr(0,7))return m(t.substr(7),l.r1,e.signatureDataSize,"R1");throw new Error("unrecognized signature format")},e.signatureToString=function(t){if(t.type===l.k1)return w(t,"K1","SIG_K1_");if(t.type===l.r1)return w(t,"R1","SIG_R1_");throw new Error("unrecognized signature format")}},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a},o=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(i(arguments[e]));return t},a=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var s=n(0),u=function(t){void 0===t&&(t={}),this.skippedBinaryExtension=!1,this.options=t};e.SerializerState=u;var c=function(){function t(t){var e=void 0===t?{}:t,n=e.textEncoder,r=e.textDecoder,i=e.array;this.readPos=0,this.array=i||new Uint8Array(1024),this.length=i?i.length:0,this.textEncoder=n||new TextEncoder,this.textDecoder=r||new TextDecoder("utf-8",{fatal:!0})}return t.prototype.reserve=function(t){if(!(this.length+t<=this.array.length)){for(var e=this.array.length;this.length+t>e;)e=Math.ceil(1.5*e);var n=new Uint8Array(e);n.set(this.array),this.array=n}},t.prototype.haveReadData=function(){return this.readPos<this.length},t.prototype.restartRead=function(){this.readPos=0},t.prototype.asUint8Array=function(){return new Uint8Array(this.array.buffer,this.array.byteOffset,this.length)},t.prototype.pushArray=function(t){this.reserve(t.length),this.array.set(t,this.length),this.length+=t.length},t.prototype.push=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.pushArray(t)},t.prototype.get=function(){if(this.readPos<this.length)return this.array[this.readPos++];throw new Error("Read past end of buffer")},t.prototype.pushUint8ArrayChecked=function(t,e){if(t.length!==e)throw new Error("Binary data has incorrect size");this.pushArray(t)},t.prototype.getUint8Array=function(t){if(this.readPos+t>this.length)throw new Error("Read past end of buffer");var e=new Uint8Array(this.array.buffer,this.array.byteOffset+this.readPos,t);return this.readPos+=t,e},t.prototype.pushUint16=function(t){this.push(t>>0&255,t>>8&255)},t.prototype.getUint16=function(){var t=0;return t|=this.get()<<0,t|=this.get()<<8},t.prototype.pushUint32=function(t){this.push(t>>0&255,t>>8&255,t>>16&255,t>>24&255)},t.prototype.getUint32=function(){var t=0;return t|=this.get()<<0,t|=this.get()<<8,t|=this.get()<<16,(t|=this.get()<<24)>>>0},t.prototype.pushNumberAsUint64=function(t){this.pushUint32(t>>>0),this.pushUint32(Math.floor(t/4294967296)>>>0)},t.prototype.getUint64AsNumber=function(){var t=this.getUint32();return 4294967296*(this.getUint32()>>>0)+(t>>>0)},t.prototype.pushVaruint32=function(t){for(;;){if(!(t>>>7)){this.push(t);break}this.push(128|127&t),t>>>=7}},t.prototype.getVaruint32=function(){for(var t=0,e=0;;){var n=this.get();if(t|=(127&n)<<e,e+=7,!(128&n))break}return t>>>0},t.prototype.pushVarint32=function(t){this.pushVaruint32(t<<1^t>>31)},t.prototype.getVarint32=function(){var t=this.getVaruint32();return 1&t?~t>>1|2147483648:t>>>1},t.prototype.pushFloat32=function(t){this.pushArray(new Uint8Array(new Float32Array([t]).buffer))},t.prototype.getFloat32=function(){return new Float32Array(this.getUint8Array(4).slice().buffer)[0]},t.prototype.pushFloat64=function(t){this.pushArray(new Uint8Array(new Float64Array([t]).buffer))},t.prototype.getFloat64=function(){return new Float64Array(this.getUint8Array(8).slice().buffer)[0]},t.prototype.pushName=function(t){if("string"!=typeof t)throw new Error("Expected string containing name");function e(t){return t>="a".charCodeAt(0)&&t<="z".charCodeAt(0)?t-"a".charCodeAt(0)+6:t>="1".charCodeAt(0)&&t<="5".charCodeAt(0)?t-"1".charCodeAt(0)+1:0}for(var n=new Uint8Array(8),r=63,i=0;i<t.length;++i){var o=e(t.charCodeAt(i));r<5&&(o<<=1);for(var a=4;a>=0;--a)r>=0&&(n[Math.floor(r/8)]|=(o>>a&1)<<r%8,--r)}this.pushArray(n)},t.prototype.getName=function(){for(var t=this.getUint8Array(8),e="",n=63;n>=0;){for(var r=0,i=0;i<5;++i)n>=0&&(r=r<<1|t[Math.floor(n/8)]>>n%8&1,--n);e+=r>=6?String.fromCharCode(r+"a".charCodeAt(0)-6):r>=1?String.fromCharCode(r+"1".charCodeAt(0)-1):"."}for(;e.endsWith(".");)e=e.substr(0,e.length-1);return e},t.prototype.pushBytes=function(t){this.pushVaruint32(t.length),this.pushArray(t)},t.prototype.getBytes=function(){return this.getUint8Array(this.getVaruint32())},t.prototype.pushString=function(t){this.pushBytes(this.textEncoder.encode(t))},t.prototype.getString=function(){return this.textDecoder.decode(this.getBytes())},t.prototype.pushSymbolCode=function(t){if("string"!=typeof t)throw new Error("Expected string containing symbol_code");var e=[];for(e.push.apply(e,o(this.textEncoder.encode(t)));e.length<8;)e.push(0);this.pushArray(e.slice(0,8))},t.prototype.getSymbolCode=function(){var t,e=this.getUint8Array(8);for(t=0;t<e.length&&e[t];++t);return this.textDecoder.decode(new Uint8Array(e.buffer,e.byteOffset,t))},t.prototype.pushSymbol=function(t){var e=t.name,n=[255&t.precision];for(n.push.apply(n,o(this.textEncoder.encode(e)));n.length<8;)n.push(0);this.pushArray(n.slice(0,8))},t.prototype.getSymbol=function(){var t,e=this.get(),n=this.getUint8Array(7);for(t=0;t<n.length&&n[t];++t);return{name:this.textDecoder.decode(new Uint8Array(n.buffer,n.byteOffset,t)),precision:e}},t.prototype.pushAsset=function(t){if("string"!=typeof t)throw new Error("Expected string containing asset");var e=0,n="",r=0;"-"===(t=t.trim())[e]&&(n+="-",++e);for(var i=!1;e<t.length&&t.charCodeAt(e)>="0".charCodeAt(0)&&t.charCodeAt(e)<="9".charCodeAt(0);)i=!0,n+=t[e],++e;if(!i)throw new Error("Asset must begin with a number");if("."===t[e])for(++e;e<t.length&&t.charCodeAt(e)>="0".charCodeAt(0)&&t.charCodeAt(e)<="9".charCodeAt(0);)n+=t[e],++r,++e;var o=t.substr(e).trim();this.pushArray(s.signedDecimalToBinary(8,n)),this.pushSymbol({name:o,precision:r})},t.prototype.getAsset=function(){var t=this.getUint8Array(8),e=this.getSymbol(),n=e.name,r=e.precision,i=s.signedBinaryToDecimal(t,r+1);return r&&(i=i.substr(0,i.length-r)+"."+i.substr(i.length-r)),i+" "+n},t.prototype.pushPublicKey=function(t){var e=s.stringToPublicKey(t);this.push(e.type),this.pushArray(e.data)},t.prototype.getPublicKey=function(){var t=this.get(),e=this.getUint8Array(s.publicKeyDataSize);return s.publicKeyToString({type:t,data:e})},t.prototype.pushPrivateKey=function(t){var e=s.stringToPrivateKey(t);this.push(e.type),this.pushArray(e.data)},t.prototype.getPrivateKey=function(){var t=this.get(),e=this.getUint8Array(s.privateKeyDataSize);return s.privateKeyToString({type:t,data:e})},t.prototype.pushSignature=function(t){var e=s.stringToSignature(t);this.push(e.type),this.pushArray(e.data)},t.prototype.getSignature=function(){var t=this.get(),e=this.getUint8Array(s.signatureDataSize);return s.signatureToString({type:t,data:e})},t}();function l(t){var e=Date.parse(t);if(Number.isNaN(e))throw new Error("Invalid time format");return e}function f(t){return Math.round(1e3*l(t+"Z"))}function h(t){var e=new Date(t/1e3).toISOString();return e.substr(0,e.length-1)}function p(t){return Math.round(l(t+"Z")/1e3)}function d(t){var e=new Date(1e3*t).toISOString();return e.substr(0,e.length-1)}function y(t){return Math.round((l(t+"Z")-9466848e5)/500)}function v(t){var e=new Date(500*t+9466848e5).toISOString();return e.substr(0,e.length-1)}function g(t){if("string"!=typeof t)throw new Error("Expected string containing symbol");var e=t.match(/^([0-9]+),([A-Z]+)$/);if(!e)throw new Error("Invalid symbol");return{name:e[2],precision:+e[1]}}function b(t){var e=t.name;return t.precision+","+e}function m(t){var e,n,r="";try{for(var i=a(t),o=i.next();!o.done;o=i.next()){r+=("00"+o.value.toString(16)).slice(-2)}}catch(t){e={error:t}}finally{try{o&&!o.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r.toUpperCase()}function w(t){if("string"!=typeof t)throw new Error("Expected string containing hex digits");if(t.length%2)throw new Error("Odd number of hex digits");for(var e=t.length/2,n=new Uint8Array(e),r=0;r<e;++r){var i=parseInt(t.substr(2*r,2),16);if(Number.isNaN(i))throw new Error("Expected hex string");n[r]=i}return n}function _(t,e){throw new Error("Don't know how to serialize "+this.name)}function A(t){throw new Error("Don't know how to deserialize "+this.name)}function x(t,e,n,r){var i,o;if(void 0===n&&(n=new u),void 0===r&&(r=!0),"object"!=typeof e)throw new Error("expected object containing data: "+JSON.stringify(e));this.base&&this.base.serialize(t,e,n,r);try{for(var s=a(this.fields),c=s.next();!c.done;c=s.next()){var l=c.value;if(l.name in e){if(n.skippedBinaryExtension)throw new Error("unexpected "+this.name+"."+l.name);l.type.serialize(t,e[l.name],n,r&&l===this.fields[this.fields.length-1])}else{if(!r||!l.type.extensionOf)throw new Error("missing "+this.name+"."+l.name+" (type="+l.type.name+")");n.skippedBinaryExtension=!0}}}catch(t){i={error:t}}finally{try{c&&!c.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}function z(t,e,n){var r,i,o;void 0===e&&(e=new u),void 0===n&&(n=!0),o=this.base?this.base.deserialize(t,e,n):{};try{for(var s=a(this.fields),c=s.next();!c.done;c=s.next()){var l=c.value;n&&l.type.extensionOf&&!t.haveReadData()?e.skippedBinaryExtension=!0:o[l.name]=l.type.deserialize(t,e,n)}}catch(t){r={error:t}}finally{try{c&&!c.done&&(i=s.return)&&i.call(s)}finally{if(r)throw r.error}}return o}function S(t,e,n,r){if(!Array.isArray(e)||2!==e.length||"string"!=typeof e[0])throw new Error('expected variant: ["type", value]');var i=this.fields.findIndex((function(t){return t.name===e[0]}));if(i<0)throw new Error('type "'+e[0]+'" is not valid for variant');t.pushVaruint32(i),this.fields[i].type.serialize(t,e[1],n,r)}function E(t,e,n){var r=t.getVaruint32();if(r>=this.fields.length)throw new Error("type index "+r+" is not valid for variant");var i=this.fields[r];return[i.name,i.type.deserialize(t,e,n)]}function k(t,e,n,r){var i,o;t.pushVaruint32(e.length);try{for(var s=a(e),u=s.next();!u.done;u=s.next()){var c=u.value;this.arrayOf.serialize(t,c,n,!1)}}catch(t){i={error:t}}finally{try{u&&!u.done&&(o=s.return)&&o.call(s)}finally{if(i)throw i.error}}}function T(t,e,n){for(var r=t.getVaruint32(),i=[],o=0;o<r;++o)i.push(this.arrayOf.deserialize(t,e,!1));return i}function U(t,e,n,r){null==e?t.push(0):(t.push(1),this.optionalOf.serialize(t,e,n,r))}function P(t,e,n){return t.get()?this.optionalOf.deserialize(t,e,n):null}function O(t,e,n,r){this.extensionOf.serialize(t,e,n,r)}function C(t,e,n){return this.extensionOf.deserialize(t,e,n)}function D(t){return r({name:"<missing name>",aliasOfName:"",arrayOf:null,optionalOf:null,extensionOf:null,baseName:"",base:null,fields:[],serialize:_,deserialize:A},t)}function K(t,e){if(Number.isNaN(+t)||Number.isNaN(+e)||"number"!=typeof t&&"string"!=typeof t)throw new Error("Expected number");if(+t!=+e)throw new Error("Number is out of range");return+t}function R(t,e){var n=t.get(e);if(n&&n.aliasOfName)return R(t,n.aliasOfName);if(n)return n;if(e.endsWith("[]"))return D({name:e,arrayOf:R(t,e.substr(0,e.length-2)),serialize:k,deserialize:T});if(e.endsWith("?"))return D({name:e,optionalOf:R(t,e.substr(0,e.length-1)),serialize:U,deserialize:P});if(e.endsWith("$"))return D({name:e,extensionOf:R(t,e.substr(0,e.length-1)),serialize:O,deserialize:C});throw new Error("Unknown type: "+e)}function N(t,e,n,r,i,o){var a=t.actions.get(n);if(!a)throw new Error("Unknown action "+n+" in contract "+e);var s=new c({textEncoder:i,textDecoder:o});return a.serialize(s,r),m(s.asUint8Array())}function j(t,e,n,r,i,o){var a=t.actions.get(n);if("string"==typeof r&&(r=w(r)),!a)throw new Error("Unknown action "+n+" in contract "+e);var s=new c({textDecoder:o,textEncoder:i});return s.pushArray(r),a.deserialize(s)}e.SerialBuffer=c,e.supportedAbiVersion=function(t){return t.startsWith("eosio::abi/1.")},e.dateToTimePoint=f,e.timePointToDate=h,e.dateToTimePointSec=p,e.timePointSecToDate=d,e.dateToBlockTimestamp=y,e.blockTimestampToDate=v,e.stringToSymbol=g,e.symbolToString=b,e.arrayToHex=m,e.hexToUint8Array=w,e.createInitialTypes=function(){var t=new Map(Object.entries({bool:D({name:"bool",serialize:function(t,e){if("boolean"!=typeof e)throw new Error("Expected true or false");t.push(e?1:0)},deserialize:function(t){return!!t.get()}}),uint8:D({name:"uint8",serialize:function(t,e){t.push(K(e,255&e))},deserialize:function(t){return t.get()}}),int8:D({name:"int8",serialize:function(t,e){t.push(K(e,e<<24>>24))},deserialize:function(t){return t.get()<<24>>24}}),uint16:D({name:"uint16",serialize:function(t,e){t.pushUint16(K(e,65535&e))},deserialize:function(t){return t.getUint16()}}),int16:D({name:"int16",serialize:function(t,e){t.pushUint16(K(e,e<<16>>16))},deserialize:function(t){return t.getUint16()<<16>>16}}),uint32:D({name:"uint32",serialize:function(t,e){t.pushUint32(K(e,e>>>0))},deserialize:function(t){return t.getUint32()}}),uint64:D({name:"uint64",serialize:function(t,e){t.pushArray(s.decimalToBinary(8,""+e))},deserialize:function(t){return s.binaryToDecimal(t.getUint8Array(8))}}),int64:D({name:"int64",serialize:function(t,e){t.pushArray(s.signedDecimalToBinary(8,""+e))},deserialize:function(t){return s.signedBinaryToDecimal(t.getUint8Array(8))}}),int32:D({name:"int32",serialize:function(t,e){t.pushUint32(K(e,0|e))},deserialize:function(t){return 0|t.getUint32()}}),varuint32:D({name:"varuint32",serialize:function(t,e){t.pushVaruint32(K(e,e>>>0))},deserialize:function(t){return t.getVaruint32()}}),varint32:D({name:"varint32",serialize:function(t,e){t.pushVarint32(K(e,0|e))},deserialize:function(t){return t.getVarint32()}}),uint128:D({name:"uint128",serialize:function(t,e){t.pushArray(s.decimalToBinary(16,""+e))},deserialize:function(t){return s.binaryToDecimal(t.getUint8Array(16))}}),int128:D({name:"int128",serialize:function(t,e){t.pushArray(s.signedDecimalToBinary(16,""+e))},deserialize:function(t){return s.signedBinaryToDecimal(t.getUint8Array(16))}}),float32:D({name:"float32",serialize:function(t,e){t.pushFloat32(e)},deserialize:function(t){return t.getFloat32()}}),float64:D({name:"float64",serialize:function(t,e){t.pushFloat64(e)},deserialize:function(t){return t.getFloat64()}}),float128:D({name:"float128",serialize:function(t,e){t.pushUint8ArrayChecked(w(e),16)},deserialize:function(t){return m(t.getUint8Array(16))}}),bytes:D({name:"bytes",serialize:function(t,e){e instanceof Uint8Array||Array.isArray(e)?t.pushBytes(e):t.pushBytes(w(e))},deserialize:function(t,e){return e&&e.options.bytesAsUint8Array?t.getBytes():m(t.getBytes())}}),string:D({name:"string",serialize:function(t,e){t.pushString(e)},deserialize:function(t){return t.getString()}}),name:D({name:"name",serialize:function(t,e){t.pushName(e)},deserialize:function(t){return t.getName()}}),time_point:D({name:"time_point",serialize:function(t,e){t.pushNumberAsUint64(f(e))},deserialize:function(t){return h(t.getUint64AsNumber())}}),time_point_sec:D({name:"time_point_sec",serialize:function(t,e){t.pushUint32(p(e))},deserialize:function(t){return d(t.getUint32())}}),block_timestamp_type:D({name:"block_timestamp_type",serialize:function(t,e){t.pushUint32(y(e))},deserialize:function(t){return v(t.getUint32())}}),symbol_code:D({name:"symbol_code",serialize:function(t,e){t.pushSymbolCode(e)},deserialize:function(t){return t.getSymbolCode()}}),symbol:D({name:"symbol",serialize:function(t,e){t.pushSymbol(g(e))},deserialize:function(t){return b(t.getSymbol())}}),asset:D({name:"asset",serialize:function(t,e){t.pushAsset(e)},deserialize:function(t){return t.getAsset()}}),checksum160:D({name:"checksum160",serialize:function(t,e){t.pushUint8ArrayChecked(w(e),20)},deserialize:function(t){return m(t.getUint8Array(20))}}),checksum256:D({name:"checksum256",serialize:function(t,e){t.pushUint8ArrayChecked(w(e),32)},deserialize:function(t){return m(t.getUint8Array(32))}}),checksum512:D({name:"checksum512",serialize:function(t,e){t.pushUint8ArrayChecked(w(e),64)},deserialize:function(t){return m(t.getUint8Array(64))}}),public_key:D({name:"public_key",serialize:function(t,e){t.pushPublicKey(e)},deserialize:function(t){return t.getPublicKey()}}),private_key:D({name:"private_key",serialize:function(t,e){t.pushPrivateKey(e)},deserialize:function(t){return t.getPrivateKey()}}),signature:D({name:"signature",serialize:function(t,e){t.pushSignature(e)},deserialize:function(t){return t.getSignature()}})}));return t.set("extended_asset",D({name:"extended_asset",baseName:"",fields:[{name:"quantity",typeName:"asset",type:t.get("asset")},{name:"contract",typeName:"name",type:t.get("name")}],serialize:x,deserialize:z})),t},e.getType=R,e.getTypesFromAbi=function(t,e){var n,r,o,s,u,c,l,f,h,p,d=new Map(t);if(e.types)try{for(var y=a(e.types),v=y.next();!v.done;v=y.next()){var g=v.value,b=g.new_type_name,m=g.type;d.set(b,D({name:b,aliasOfName:m}))}}catch(t){n={error:t}}finally{try{v&&!v.done&&(r=y.return)&&r.call(y)}finally{if(n)throw n.error}}if(e.structs)try{for(var w=a(e.structs),_=w.next();!_.done;_=w.next()){var A=_.value,k=A.name,T=A.base,U=A.fields;d.set(k,D({name:k,baseName:T,fields:U.map((function(t){return{name:t.name,typeName:t.type,type:null}})),serialize:x,deserialize:z}))}}catch(t){o={error:t}}finally{try{_&&!_.done&&(s=w.return)&&s.call(w)}finally{if(o)throw o.error}}if(e.variants)try{for(var P=a(e.variants),O=P.next();!O.done;O=P.next()){var C=O.value,K=C.name,N=C.types;d.set(K,D({name:K,fields:N.map((function(t){return{name:t,typeName:t,type:null}})),serialize:S,deserialize:E}))}}catch(t){u={error:t}}finally{try{O&&!O.done&&(c=P.return)&&c.call(P)}finally{if(u)throw u.error}}try{for(var j=a(d),B=j.next();!B.done;B=j.next()){var V=i(B.value,2);V[0];(m=V[1]).baseName&&(m.base=R(d,m.baseName));try{for(var M=a(m.fields),I=M.next();!I.done;I=M.next()){var L=I.value;L.type=R(d,L.typeName)}}catch(t){h={error:t}}finally{try{I&&!I.done&&(p=M.return)&&p.call(M)}finally{if(h)throw h.error}}}}catch(t){l={error:t}}finally{try{B&&!B.done&&(f=j.return)&&f.call(j)}finally{if(l)throw l.error}}return d},e.transactionHeader=function(t,e){return{expiration:d(p(t.timestamp)+e),ref_block_num:65535&t.block_num,ref_block_prefix:t.ref_block_prefix}},e.serializeActionData=N,e.serializeAction=function(t,e,n,r,i,o,a){return{account:e,name:n,authorization:r,data:N(t,e,n,i,o,a)}},e.deserializeActionData=j,e.deserializeAction=function(t,e,n,r,i,o,a){return{account:e,name:n,authorization:r,data:j(t,e,n,i,o,a)}}},function(t,e,n){"use strict";var r,i=this&&this.__extends||(r=function(t,e){return(r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,e)},function(t,e){function n(){this.constructor=t}r(t,e),t.prototype=null===e?Object.create(e):(n.prototype=e.prototype,new n)});Object.defineProperty(e,"__esModule",{value:!0});var o=function(t){function e(n){var r=this;return r=n.error&&n.error.details&&n.error.details.length&&n.error.details[0].message?t.call(this,n.error.details[0].message)||this:n.processed&&n.processed.except&&n.processed.except.message?t.call(this,n.processed.except.message)||this:t.call(this,n.message)||this,Object.setPrototypeOf(r,e.prototype),r.json=n,r}return i(e,t),e}(Error);e.RpcError=o},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(e,"__esModule",{value:!0});var o=n(4),a=n(13),s=function(){function t(t,e,n,r,i,s){if(void 0===e&&(e=null),void 0===n&&(n=null),void 0===r&&(r=!0),void 0===i&&(i="https://all-access.wax.io"),void 0===s&&(s="https://api-idm.wax.io/v1/accounts/auto-accept/"),this.waxSigningURL=i,this.waxAutoSigningURL=s,this.waxEventSource=new a.WaxEventSource(i),this.rpc=new o.JsonRpc(t),e&&Array.isArray(n)){var u={userAccount:e,pubKeys:n,verified:!0};this.receiveLogin({data:u})}else r&&this.loginViaEndpoint()}return t.prototype.login=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){return this.userAccount&&Array.isArray(this.pubKeys)?[2,this.userAccount]:[2,this.loginViaWindow()]}))}))},t.prototype.isAutoLoginAvailable=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return this.userAccount&&Array.isArray(this.pubKeys)?[2,!0]:[3,1];case 1:return t.trys.push([1,3,,4]),[4,this.loginViaEndpoint()];case 2:return t.sent(),[2,!0];case 3:return t.sent(),[2,!1];case 4:return[2,!1]}}))}))},t.prototype.loginViaWindow=function(){return r(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.waxEventSource.openEventSource(this.waxSigningURL+"/cloud-wallet/login/")];case 1:return t=e.sent(),[2,this.waxEventSource.onceEvent(t,this.waxSigningURL,this.receiveLogin.bind(this))]}}))}))},t.prototype.loginViaEndpoint=function(){return r(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:return[4,fetch(this.waxAutoSigningURL+"login",{credentials:"include",method:"get"})];case 1:if(!(t=n.sent()).ok)throw new Error("Login Endpoint Error "+t.status+" "+t.statusText);return[4,t.json()];case 2:if((e=n.sent()).processed&&e.processed.except)throw new Error(e);return[2,this.receiveLogin({data:e})]}}))}))},t.prototype.canAutoLogin=function(){return"true"===localStorage.getItem("autoLogin")&&this.isChrome()},t.prototype.receiveLogin=function(t){return r(this,void 0,void 0,(function(){var e,n,a,s,u,c,l,f,h,p=this;return i(this,(function(d){if(e=t.data,n=e.verified,a=e.userAccount,s=e.pubKeys,u=e.whitelistedContracts,c=e.autoLogin,!n)throw new Error("User declined to share their user account");if(null==a||null==s)throw new Error("User does not have a blockchain account");return localStorage.setItem("autoLogin",c),this.whitelistedContracts=u||[],this.userAccount=a,this.pubKeys=s,l={getAvailableKeys:function(){return p.pubKeys},sign:function(t){return r(p,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e={serializedTransaction:t.serializedTransaction},[4,this.signing(t.serializedTransaction)];case 1:return[2,(e.signatures=n.sent(),e)]}}))}))}},this.api=new o.Api({rpc:this.rpc,signatureProvider:l}),f=this.api.transact.bind(this.api),h=this.waxSigningURL+"/cloud-wallet/signing/",this.api.transact=function(t,e){return r(p,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.canAutoSign(t)];case 1:return r.sent()?[3,3]:(n=this,[4,window.open(h,"WaxPopup","height=800,width=600")]);case 2:n.signingWindow=r.sent(),r.label=3;case 3:return[4,f(t,e)];case 4:return[2,r.sent()]}}))}))},[2,this.userAccount]}))}))},t.prototype.canAutoSign=function(t){return r(this,void 0,void 0,(function(){var e,n=this;return i(this,(function(r){switch(r.label){case 0:return t.actions?(e=t,[3,3]):[3,1];case 1:return[4,this.api.deserializeTransactionWithActions(t)];case 2:e=r.sent(),r.label=3;case 3:return[2,!e.actions.find((function(t){return!n.isWhitelisted(t)}))]}}))}))},t.prototype.isWhitelisted=function(t){return!!this.whitelistedContracts.find((function(e){return e.contract===t.account&&("eosio.token"!==t.account||"transfer"!==t.name||e.recipients.includes(t.data.to))}))},t.prototype.signing=function(t){return r(this,void 0,void 0,(function(){var e=this;return i(this,(function(n){switch(n.label){case 0:return[4,this.canAutoSign(t)];case 1:return n.sent()?[2,this.signViaEndpoint(t).catch((function(){return e.signViaWindow(void 0,t)}))]:[2,this.signViaWindow(this.signingWindow,t)]}}))}))},t.prototype.signViaEndpoint=function(t){return r(this,void 0,void 0,(function(){var e,n,r;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,fetch(this.waxAutoSigningURL+"signing",{body:JSON.stringify({transaction:Object.values(t)}),credentials:"include",headers:{"Content-Type":"application/json"},method:"POST"})];case 1:if(!(e=i.sent()).ok)throw new Error("Signing Endpoint Error "+e.status+" "+e.statusText);return[4,e.json()];case 2:if((n=i.sent()).processed&&n.processed.except)throw new Error(n);return[2,this.receiveSignatures({data:n})];case 3:throw r=i.sent(),this.whitelistedContracts=[],r;case 4:return[2]}}))}))},t.prototype.signViaWindow=function(t,e){return r(this,void 0,void 0,(function(){var n;return i(this,(function(r){switch(r.label){case 0:return[4,this.waxEventSource.openEventSource(this.waxSigningURL+"/cloud-wallet/signing/",{type:"TRANSACTION",transaction:e},t)];case 1:return n=r.sent(),[2,this.waxEventSource.onceEvent(n,this.waxSigningURL,this.receiveSignatures.bind(this))]}}))}))},t.prototype.receiveSignatures=function(t){return r(this,void 0,void 0,(function(){var e,n,r,o;return i(this,(function(i){if("TX_SIGNED"===t.data.type){if(e=t.data,n=e.verified,r=e.signatures,o=e.whitelistedContracts,!n||null==r)throw new Error("User declined to sign the transaction");return this.whitelistedContracts=o||[],[2,r]}return[2]}))}))},t.prototype.isChrome=function(){return/Chrome/.test(navigator.userAgent)&&/Google Inc/.test(navigator.vendor)},t}();e.WaxJS=s},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=n(5);e.Api=r.Api;var i=n(9);e.ApiInterfaces=i;var o=n(10);e.JsonRpc=o.JsonRpc;var a=n(0);e.Numeric=a;var s=n(12);e.RpcInterfaces=s;var u=n(2);e.RpcError=u.RpcError;var c=n(1);e.Serialize=c},function(t,e,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var i in e=arguments[n])Object.prototype.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t}).apply(this,arguments)},i=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(a,s)}u((r=r.apply(t,e||[])).next())}))},o=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},a=this&&this.__rest||function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(t);i<r.length;i++)e.indexOf(r[i])<0&&(n[r[i]]=t[r[i]])}return n},s=this&&this.__read||function(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,i,o=n.call(t),a=[];try{for(;(void 0===e||e-- >0)&&!(r=o.next()).done;)a.push(r.value)}catch(t){i={error:t}}finally{try{r&&!r.done&&(n=o.return)&&n.call(o)}finally{if(i)throw i.error}}return a},u=this&&this.__spread||function(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(s(arguments[e]));return t},c=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var l=n(1),f=n(7),h=n(8),p=function(){function t(t){this.contracts=new Map,this.cachedAbis=new Map,this.rpc=t.rpc,this.authorityProvider=t.authorityProvider||t.rpc,this.abiProvider=t.abiProvider||t.rpc,this.signatureProvider=t.signatureProvider,this.chainId=t.chainId,this.textEncoder=t.textEncoder,this.textDecoder=t.textDecoder,this.abiTypes=l.getTypesFromAbi(l.createInitialTypes(),f),this.transactionTypes=l.getTypesFromAbi(l.createInitialTypes(),h)}return t.prototype.rawAbiToJson=function(t){var e=new l.SerialBuffer({textEncoder:this.textEncoder,textDecoder:this.textDecoder,array:t});if(!l.supportedAbiVersion(e.getString()))throw new Error("Unsupported abi version");return e.restartRead(),this.abiTypes.get("abi_def").deserialize(e)},t.prototype.getCachedAbi=function(t,e){return void 0===e&&(e=!1),i(this,void 0,void 0,(function(){var n,r,i,a;return o(this,(function(o){switch(o.label){case 0:if(!e&&this.cachedAbis.get(t))return[2,this.cachedAbis.get(t)];o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this.abiProvider.getRawAbi(t)];case 2:return r=o.sent().abi,i=this.rawAbiToJson(r),n={rawAbi:r,abi:i},[3,4];case 3:throw(a=o.sent()).message="fetching abi for "+t+": "+a.message,a;case 4:if(!n)throw new Error("Missing abi for "+t);return this.cachedAbis.set(t,n),[2,n]}}))}))},t.prototype.getAbi=function(t,e){return void 0===e&&(e=!1),i(this,void 0,void 0,(function(){return o(this,(function(n){switch(n.label){case 0:return[4,this.getCachedAbi(t,e)];case 1:return[2,n.sent().abi]}}))}))},t.prototype.getTransactionAbis=function(t,e){return void 0===e&&(e=!1),i(this,void 0,void 0,(function(){var n,r,a,s=this;return o(this,(function(c){return n=t.actions.map((function(t){return t.account})),r=new Set(n),a=u(r).map((function(t){return i(s,void 0,void 0,(function(){var n;return o(this,(function(r){switch(r.label){case 0:return n={accountName:t},[4,this.getCachedAbi(t,e)];case 1:return[2,(n.abi=r.sent().rawAbi,n)]}}))}))})),[2,Promise.all(a)]}))}))},t.prototype.getContract=function(t,e){return void 0===e&&(e=!1),i(this,void 0,void 0,(function(){var n,r,i,a,s,u,f,h,p,d,y;return o(this,(function(o){switch(o.label){case 0:return!e&&this.contracts.get(t)?[2,this.contracts.get(t)]:[4,this.getAbi(t,e)];case 1:i=o.sent(),a=l.getTypesFromAbi(l.createInitialTypes(),i),s=new Map;try{for(u=c(i.actions),f=u.next();!f.done;f=u.next())h=f.value,p=h.name,d=h.type,s.set(p,l.getType(a,d))}catch(t){n={error:t}}finally{try{f&&!f.done&&(r=u.return)&&r.call(u)}finally{if(n)throw n.error}}return y={types:a,actions:s},this.contracts.set(t,y),[2,y]}}))}))},t.prototype.serialize=function(t,e,n){this.transactionTypes.get(e).serialize(t,n)},t.prototype.deserialize=function(t,e){return this.transactionTypes.get(e).deserialize(t)},t.prototype.serializeTransaction=function(t){var e=new l.SerialBuffer({textEncoder:this.textEncoder,textDecoder:this.textDecoder});return this.serialize(e,"transaction",r({max_net_usage_words:0,max_cpu_usage_ms:0,delay_sec:0,context_free_actions:[],actions:[],transaction_extensions:[]},t)),e.asUint8Array()},t.prototype.deserializeTransaction=function(t){var e=new l.SerialBuffer({textEncoder:this.textEncoder,textDecoder:this.textDecoder});return e.pushArray(t),this.deserialize(e,"transaction")},t.prototype.serializeActions=function(t){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(n){switch(n.label){case 0:return[4,Promise.all(t.map((function(t){var n=t.account,r=t.name,a=t.authorization,s=t.data;return i(e,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this.getContract(n)];case 1:return t=e.sent(),[2,l.serializeAction(t,n,r,a,s,this.textEncoder,this.textDecoder)]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.deserializeActions=function(t){return i(this,void 0,void 0,(function(){var e=this;return o(this,(function(n){switch(n.label){case 0:return[4,Promise.all(t.map((function(t){var n=t.account,r=t.name,a=t.authorization,s=t.data;return i(e,void 0,void 0,(function(){var t;return o(this,(function(e){switch(e.label){case 0:return[4,this.getContract(n)];case 1:return t=e.sent(),[2,l.deserializeAction(t,n,r,a,s,this.textEncoder,this.textDecoder)]}}))}))})))];case 1:return[2,n.sent()]}}))}))},t.prototype.deserializeTransactionWithActions=function(t){return i(this,void 0,void 0,(function(){var e,n;return o(this,(function(i){switch(i.label){case 0:return"string"==typeof t&&(t=l.hexToUint8Array(t)),e=this.deserializeTransaction(t),[4,this.deserializeActions(e.actions)];case 1:return n=i.sent(),[2,r({},e,{actions:n})]}}))}))},t.prototype.transact=function(t,e){var n=void 0===e?{}:e,a=n.broadcast,s=void 0===a||a,u=n.sign,c=void 0===u||u,f=n.blocksBehind,h=n.expireSeconds;return i(this,void 0,void 0,(function(){var e,n,i,a,u,p,d,y,v;return o(this,(function(o){switch(o.label){case 0:return this.chainId?[3,2]:[4,this.rpc.get_info()];case 1:e=o.sent(),this.chainId=e.chain_id,o.label=2;case 2:return"number"==typeof f&&h?e?[3,4]:[4,this.rpc.get_info()]:[3,6];case 3:e=o.sent(),o.label=4;case 4:return[4,this.rpc.get_block(e.head_block_num-f)];case 5:n=o.sent(),t=r({},l.transactionHeader(n,h),t),o.label=6;case 6:if(!this.hasRequiredTaposFields(t))throw new Error("Required configuration or TAPOS fields are not present");return[4,this.getTransactionAbis(t)];case 7:return i=o.sent(),a=[{},t],u={},[4,this.serializeActions(t.actions)];case 8:return t=r.apply(void 0,a.concat([(u.actions=o.sent(),u)])),p=this.serializeTransaction(t),d={serializedTransaction:p,signatures:[]},c?[4,this.signatureProvider.getAvailableKeys()]:[3,12];case 9:return y=o.sent(),[4,this.authorityProvider.getRequiredKeys({transaction:t,availableKeys:y})];case 10:return v=o.sent(),[4,this.signatureProvider.sign({chainId:this.chainId,requiredKeys:v,serializedTransaction:p,abis:i})];case 11:d=o.sent(),o.label=12;case 12:return s?[2,this.pushSignedTransaction(d)]:[2,d]}}))}))},t.prototype.pushSignedTransaction=function(t){var e=t.signatures,n=t.serializedTransaction;return i(this,void 0,void 0,(function(){return o(this,(function(t){return[2,this.rpc.push_transaction({signatures:e,serializedTransaction:n})]}))}))},t.prototype.hasRequiredTaposFields=function(t){var e=t.expiration,n=t.ref_block_num,r=t.ref_block_prefix;a(t,["expiration","ref_block_num","ref_block_prefix"]);return!!(e&&n&&r)},t}();e.Api=p},function(t,e,n){"use strict";var r=function(t,e){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return function(t,e){var n=[],r=!0,i=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(r=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);r=!0);}catch(t){i=!0,o=t}finally{try{!r&&s.return&&s.return()}finally{if(i)throw o}}return n}(t,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")},i=function(){function t(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}return function(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),e}}();var o=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return i(t,null,[{key:"get_n_pad_bytes",value:function(t){return 64-(t+8&63)}},{key:"pad",value:function(e){var n,i,o=e.byteLength,a=t.get_n_pad_bytes(o),s=(n=o,i=536870912,[Math.floor(n/i),n%i]).map((function(t,e){return e?8*t:t})),u=r(s,2),c=u[0],l=u[1],f=new Uint8Array(o+a+8);f.set(new Uint8Array(e),0);var h=new DataView(f.buffer);return h.setUint8(o,128),h.setUint32(o+a,l,!0),h.setUint32(o+a+4,c,!0),f.buffer}},{key:"f",value:function(t,e,n,r){return 0<=t&&t<=15?e^n^r:16<=t&&t<=31?e&n|~e&r:32<=t&&t<=47?(e|~n)^r:48<=t&&t<=63?e&r|n&~r:64<=t&&t<=79?e^(n|~r):void 0}},{key:"K",value:function(t){return 0<=t&&t<=15?0:16<=t&&t<=31?1518500249:32<=t&&t<=47?1859775393:48<=t&&t<=63?2400959708:64<=t&&t<=79?2840853838:void 0}},{key:"KP",value:function(t){return 0<=t&&t<=15?1352829926:16<=t&&t<=31?1548603684:32<=t&&t<=47?1836072691:48<=t&&t<=63?2053994217:64<=t&&t<=79?0:void 0}},{key:"add_modulo32",value:function(){return 0|Array.from(arguments).reduce((function(t,e){return t+e}),0)}},{key:"rol32",value:function(t,e){return t<<e|t>>>32-e}},{key:"hash",value:function(e){for(var n=t.pad(e),r=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],i=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],o=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],a=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],s=n.byteLength/64,u=new Array(s).fill(void 0).map((function(t,e){return function(t){return new DataView(n,64*e,64).getUint32(4*t,!0)}})),c=[1732584193,4023233417,2562383102,271733878,3285377520],l=0;l<s;++l){for(var f=c[0],h=c[1],p=c[2],d=c[3],y=c[4],v=f,g=h,b=p,m=d,w=y,_=0;_<80;++_){var A=t.add_modulo32(t.rol32(t.add_modulo32(f,t.f(_,h,p,d),u[l](r[_]),t.K(_)),o[_]),y);f=y,y=d,d=t.rol32(p,10),p=h,h=A,A=t.add_modulo32(t.rol32(t.add_modulo32(v,t.f(79-_,g,b,m),u[l](i[_]),t.KP(_)),a[_]),w),v=w,w=m,m=t.rol32(b,10),b=g,g=A}var x=t.add_modulo32(c[1],p,m);c[1]=t.add_modulo32(c[2],d,w),c[2]=t.add_modulo32(c[3],y,v),c[3]=t.add_modulo32(c[4],f,g),c[4]=t.add_modulo32(c[0],h,b),c[0]=x}var z=new ArrayBuffer(20),S=new DataView(z);return c.forEach((function(t,e){return S.setUint32(4*e,t,!0)})),z}}]),t}();t.exports={RIPEMD160:o}},function(t){t.exports=JSON.parse('{"version":"eosio::abi/1.1","structs":[{"name":"extensions_entry","base":"","fields":[{"name":"tag","type":"uint16"},{"name":"value","type":"bytes"}]},{"name":"type_def","base":"","fields":[{"name":"new_type_name","type":"string"},{"name":"type","type":"string"}]},{"name":"field_def","base":"","fields":[{"name":"name","type":"string"},{"name":"type","type":"string"}]},{"name":"struct_def","base":"","fields":[{"name":"name","type":"string"},{"name":"base","type":"string"},{"name":"fields","type":"field_def[]"}]},{"name":"action_def","base":"","fields":[{"name":"name","type":"name"},{"name":"type","type":"string"},{"name":"ricardian_contract","type":"string"}]},{"name":"table_def","base":"","fields":[{"name":"name","type":"name"},{"name":"index_type","type":"string"},{"name":"key_names","type":"string[]"},{"name":"key_types","type":"string[]"},{"name":"type","type":"string"}]},{"name":"clause_pair","base":"","fields":[{"name":"id","type":"string"},{"name":"body","type":"string"}]},{"name":"error_message","base":"","fields":[{"name":"error_code","type":"uint64"},{"name":"error_msg","type":"string"}]},{"name":"variant_def","base":"","fields":[{"name":"name","type":"string"},{"name":"types","type":"string[]"}]},{"name":"abi_def","base":"","fields":[{"name":"version","type":"string"},{"name":"types","type":"type_def[]"},{"name":"structs","type":"struct_def[]"},{"name":"actions","type":"action_def[]"},{"name":"tables","type":"table_def[]"},{"name":"ricardian_clauses","type":"clause_pair[]"},{"name":"error_messages","type":"error_message[]"},{"name":"abi_extensions","type":"extensions_entry[]"},{"name":"variants","type":"variant_def[]$"}]}]}')},function(t){t.exports=JSON.parse('{"version":"eosio::abi/1.0","types":[{"new_type_name":"account_name","type":"name"},{"new_type_name":"action_name","type":"name"},{"new_type_name":"permission_name","type":"name"}],"structs":[{"name":"permission_level","base":"","fields":[{"name":"actor","type":"account_name"},{"name":"permission","type":"permission_name"}]},{"name":"action","base":"","fields":[{"name":"account","type":"account_name"},{"name":"name","type":"action_name"},{"name":"authorization","type":"permission_level[]"},{"name":"data","type":"bytes"}]},{"name":"extension","base":"","fields":[{"name":"type","type":"uint16"},{"name":"data","type":"bytes"}]},{"name":"transaction_header","base":"","fields":[{"name":"expiration","type":"time_point_sec"},{"name":"ref_block_num","type":"uint16"},{"name":"ref_block_prefix","type":"uint32"},{"name":"max_net_usage_words","type":"varuint32"},{"name":"max_cpu_usage_ms","type":"uint8"},{"name":"delay_sec","type":"varuint32"}]},{"name":"transaction","base":"transaction_header","fields":[{"name":"context_free_actions","type":"action[]"},{"name":"actions","type":"action[]"},{"name":"transaction_extensions","type":"extension[]"}]}]}')},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";(function(t){var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){t.done?i(t.value):new n((function(e){e(t.value)})).then(a,s)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}},o=this&&this.__values||function(t){var e="function"==typeof Symbol&&t[Symbol.iterator],n=0;return e?e.call(t):{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}}};Object.defineProperty(e,"__esModule",{value:!0});var a=n(0),s=n(2);function u(t){var e,n,r="";try{for(var i=o(t),a=i.next();!a.done;a=i.next()){r+=("00"+a.value.toString(16)).slice(-2)}}catch(t){e={error:t}}finally{try{a&&!a.done&&(n=i.return)&&n.call(i)}finally{if(e)throw e.error}}return r}var c=function(){function e(e,n){void 0===n&&(n={}),this.endpoint=e,n.fetch?this.fetchBuiltin=n.fetch:this.fetchBuiltin=t.fetch}return e.prototype.fetch=function(t,e){return r(this,void 0,void 0,(function(){var n,r,o;return i(this,(function(i){switch(i.label){case 0:return i.trys.push([0,3,,4]),[4,(0,this.fetchBuiltin)(this.endpoint+t,{body:JSON.stringify(e),method:"POST"})];case 1:return[4,(n=i.sent()).json()];case 2:if((r=i.sent()).processed&&r.processed.except)throw new s.RpcError(r);return[3,4];case 3:throw(o=i.sent()).isFetchError=!0,o;case 4:if(!n.ok)throw new s.RpcError(r);return[2,r]}}))}))},e.prototype.get_abi=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/chain/get_abi",{account_name:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.get_account=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/chain/get_account",{account_name:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.get_block_header_state=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/chain/get_block_header_state",{block_num_or_id:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.get_block=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/chain/get_block",{block_num_or_id:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.get_code=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/chain/get_code",{account_name:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.get_currency_balance=function(t,e,n){return void 0===n&&(n=null),r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.fetch("/v1/chain/get_currency_balance",{code:t,account:e,symbol:n})];case 1:return[2,r.sent()]}}))}))},e.prototype.get_currency_stats=function(t,e){return r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.fetch("/v1/chain/get_currency_stats",{code:t,symbol:e})];case 1:return[2,n.sent()]}}))}))},e.prototype.get_info=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch("/v1/chain/get_info",{})];case 1:return[2,t.sent()]}}))}))},e.prototype.get_producer_schedule=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch("/v1/chain/get_producer_schedule",{})];case 1:return[2,t.sent()]}}))}))},e.prototype.get_producers=function(t,e,n){return void 0===t&&(t=!0),void 0===e&&(e=""),void 0===n&&(n=50),r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.fetch("/v1/chain/get_producers",{json:t,lower_bound:e,limit:n})];case 1:return[2,r.sent()]}}))}))},e.prototype.get_raw_code_and_abi=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/chain/get_raw_code_and_abi",{account_name:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.getRawAbi=function(t){return r(this,void 0,void 0,(function(){var e,n;return i(this,(function(r){switch(r.label){case 0:return[4,this.get_raw_code_and_abi(t)];case 1:return e=r.sent(),n=a.base64ToBinary(e.abi),[2,{accountName:e.account_name,abi:n}]}}))}))},e.prototype.get_table_rows=function(t){var e=t.json,n=void 0===e||e,o=t.code,a=t.scope,s=t.table,u=t.table_key,c=void 0===u?"":u,l=t.lower_bound,f=void 0===l?"":l,h=t.upper_bound,p=void 0===h?"":h,d=t.index_position,y=void 0===d?1:d,v=t.key_type,g=void 0===v?"":v,b=t.limit,m=void 0===b?10:b,w=t.reverse,_=void 0!==w&&w,A=t.show_payer,x=void 0!==A&&A;return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch("/v1/chain/get_table_rows",{json:n,code:o,scope:a,table:s,table_key:c,lower_bound:f,upper_bound:p,index_position:y,key_type:g,limit:m,reverse:_,show_payer:x})];case 1:return[2,t.sent()]}}))}))},e.prototype.get_table_by_scope=function(t){var e=t.code,n=t.table,o=t.lower_bound,a=void 0===o?"":o,s=t.upper_bound,u=void 0===s?"":s,c=t.limit,l=void 0===c?10:c;return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch("/v1/chain/get_table_by_scope",{code:e,table:n,lower_bound:a,upper_bound:u,limit:l})];case 1:return[2,t.sent()]}}))}))},e.prototype.getRequiredKeys=function(t){return r(this,void 0,void 0,(function(){var e;return i(this,(function(n){switch(n.label){case 0:return e=a.convertLegacyPublicKeys,[4,this.fetch("/v1/chain/get_required_keys",{transaction:t.transaction,available_keys:t.availableKeys})];case 1:return[2,e.apply(void 0,[n.sent().required_keys])]}}))}))},e.prototype.push_transaction=function(t){var e=t.signatures,n=t.serializedTransaction;return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch("/v1/chain/push_transaction",{signatures:e,compression:0,packed_context_free_data:"",packed_trx:u(n)})];case 1:return[2,t.sent()]}}))}))},e.prototype.db_size_get=function(){return r(this,void 0,void 0,(function(){return i(this,(function(t){switch(t.label){case 0:return[4,this.fetch("/v1/db_size/get",{})];case 1:return[2,t.sent()]}}))}))},e.prototype.history_get_actions=function(t,e,n){return void 0===e&&(e=null),void 0===n&&(n=null),r(this,void 0,void 0,(function(){return i(this,(function(r){switch(r.label){case 0:return[4,this.fetch("/v1/history/get_actions",{account_name:t,pos:e,offset:n})];case 1:return[2,r.sent()]}}))}))},e.prototype.history_get_transaction=function(t,e){return void 0===e&&(e=null),r(this,void 0,void 0,(function(){return i(this,(function(n){switch(n.label){case 0:return[4,this.fetch("/v1/history/get_transaction",{id:t,block_num_hint:e})];case 1:return[2,n.sent()]}}))}))},e.prototype.history_get_key_accounts=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/history/get_key_accounts",{public_key:t})];case 1:return[2,e.sent()]}}))}))},e.prototype.history_get_controlled_accounts=function(t){return r(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.fetch("/v1/history/get_controlled_accounts",{controlling_account:t})];case 1:return[2,e.sent()]}}))}))},e}();e.JsonRpc=c}).call(this,n(11))},function(t,e){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(t){"object"==typeof window&&(n=window)}t.exports=n},function(t,e,n){"use strict";Object.defineProperty(e,"__esModule",{value:!0})},function(t,e,n){"use strict";var r=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,o){function a(t){try{u(r.next(t))}catch(t){o(t)}}function s(t){try{u(r.throw(t))}catch(t){o(t)}}function u(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}u((r=r.apply(t,e||[])).next())}))},i=this&&this.__generator||function(t,e){var n,r,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(i=2&o[0]?r.return:o[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,o[1])).done)return i;switch(r=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,r=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]<i[3])){a.label=o[1];break}if(6===o[0]&&a.label<i[1]){a.label=i[1],i=o;break}if(i&&a.label<i[2]){a.label=i[2],a.ops.push(o);break}i[2]&&a.ops.pop(),a.trys.pop();continue}o=e.call(t,a)}catch(t){o=[6,t],r=0}finally{n=i=0}if(5&o[0])throw o[1];return{value:o[0]?o[1]:void 0,done:!0}}([o,s])}}};Object.defineProperty(e,"__esModule",{value:!0});var o=function(){function t(t){void 0===t&&(t="http://localhost:3000"),this.waxSigningURL=t,this.timeout=function(){return new Promise((function(t,e){var n=setTimeout((function(){clearTimeout(n),e(new Error("Timeout"))}),2e3)}))},this.openEventSource=this.openEventSource.bind(this),this.onceEvent=this.onceEvent.bind(this)}return t.prototype.openEventSource=function(t,e,n){return r(this,void 0,void 0,(function(){var o,a,s,u,c=this;return i(this,(function(l){switch(l.label){case 0:return n?(a=n,[3,3]):[3,1];case 1:return[4,window.open(t,"WaxPopup","height=800,width=600")];case 2:a=l.sent(),l.label=3;case 3:if(!(o=a))throw new Error("Unable to open a popup window");return void 0===e?[2,o]:(s=function(t){return r(c,void 0,void 0,(function(){return i(this,(function(n){return"READY"===t.data.type&&o.postMessage(e,this.waxSigningURL),[2]}))}))},u=this.onceEvent(o,this.waxSigningURL,s),[4,Promise.race([u,this.timeout()]).catch((function(t){if("Timeout"!==t.message)throw t;o.postMessage(e,c.waxSigningURL)}))]);case 4:return l.sent(),[2,o]}}))}))},t.prototype.onceEvent=function(t,e,n){return r(this,void 0,void 0,(function(){return i(this,(function(o){return[2,new Promise((function(o,a){window.addEventListener("message",(function s(u){return r(this,void 0,void 0,(function(){var r,c;return i(this,(function(i){switch(i.label){case 0:if(u.origin!==e&&a(new Error("Invalid origin")),u.source!==t)return[2];if("object"!=typeof u.data)return[2];i.label=1;case 1:return i.trys.push([1,3,,4]),[4,n(u)];case 2:return r=i.sent(),o(r),[3,4];case 3:return c=i.sent(),a(c),[3,4];case 4:return window.removeEventListener("message",s,!1),[2]}}))}))}),!1)}))]}))}))},t}();e.WaxEventSource=o}]);