diff --git a/packages/suite-data/files/connect/iframe.html b/packages/suite-data/files/connect/iframe.html index fb9732899ed..eefbf1a0820 100644 --- a/packages/suite-data/files/connect/iframe.html +++ b/packages/suite-data/files/connect/iframe.html @@ -23,7 +23,7 @@ const iframeScript = document.createElement('script'); iframeScript.setAttribute('type', 'text/javascript'); - iframeScript.setAttribute('src', './js/iframe.72b8aee3a4feb990067e.js'); + iframeScript.setAttribute('src', './js/iframe.8971db8994d47a835970.js'); iframeScript.setAttribute('async', 'false'); document.body.appendChild(iframeScript); diff --git a/packages/suite-data/files/connect/js/iframe.72b8aee3a4feb990067e.js b/packages/suite-data/files/connect/js/iframe.8971db8994d47a835970.js similarity index 55% rename from packages/suite-data/files/connect/js/iframe.72b8aee3a4feb990067e.js rename to packages/suite-data/files/connect/js/iframe.8971db8994d47a835970.js index aa167a05a02..20f99171859 100644 --- a/packages/suite-data/files/connect/js/iframe.72b8aee3a4feb990067e.js +++ b/packages/suite-data/files/connect/js/iframe.8971db8994d47a835970.js @@ -1,13 +1,13 @@ -!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="./",r(r.s=231)}([function(e,t){e.exports=function(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){e.exports=r(233)},function(e,t){function r(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}}},function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getFirmwareRange=t.validateCoinPath=t.validateParams=void 0;var i=n(r(29)),o=r(6),a=r(12),s=r(48),u=n(r(32)),f=function(e){return o.ERRORS.TypedError("Method_InvalidParameter",e)};t.validateParams=function(e,t){t.forEach((function(t){if(Object.prototype.hasOwnProperty.call(e,t.name)){var r=e[t.name];if(t.type)if("array"===t.type){if(!Array.isArray(r))throw f('Parameter "'+t.name+'" has invalid type. "'+t.type+'" expected.');if(!t.allowEmpty&&r.length<1)throw f('Parameter "'+t.name+'" is empty.')}else if("amount"===t.type){if("string"!=typeof r)throw f('Parameter "'+t.name+'" has invalid type. "string" expected.');try{if(new i.default(r).toFixed(0)!==r)throw new Error("")}catch(e){throw f('Parameter "'+t.name+'" has invalid value "'+r+'". Integer representation expected.')}}else if("buffer"===t.type){if(void 0===r||"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r))throw f('Parameter "'+t.name+'" has invalid type. "buffer" expected.')}else if(typeof r!==t.type)throw f('Parameter "'+t.name+'" has invalid type. "'+t.type+'" expected.')}else if(t.obligatory)throw f('Parameter "'+t.name+'" is missing.')}))};t.validateCoinPath=function(e,t){if(e&&e.slip44!==(0,a.fromHardened)(t[1]))throw f('Parameters "path" and "coin" do not match.')};t.getFirmwareRange=function(e,t,r){var n=JSON.parse(JSON.stringify(r));t&&(t.support&&"string"==typeof t.support.trezor1?(0,s.versionCompare)(t.support.trezor1,n[1].min)>0&&(n[1].min=t.support.trezor1):n[1].min="0",t.support&&"string"==typeof t.support.trezor2?(0,s.versionCompare)(t.support.trezor2,n[2].min)>0&&(n[2].min=t.support.trezor2):n[2].min="0");var i=t?t.type:null,o=t?t.shortcut.toLowerCase():null,a=u.default.getConfig().supportedFirmware,f=a.find((function(e){return e.coinType===i||Array.isArray(e.coin)&&e.coin.includes(o)||"string"==typeof e.coin&&e.coin===o}))||a.find((function(t){return!t.coinType&&!t.coin&&t.excludedMethods&&t.excludedMethods.includes(e)}));if(f){if(f.excludedMethods&&!f.excludedMethods.includes(e))return n;var c=f.min,l=f.max;c&&(("0"===n[1].min||(0,s.versionCompare)(n[1].min,c[0])<0)&&(n[1].min=c[0]),("0"===n[2].min||(0,s.versionCompare)(n[2].min,c[1])<0)&&(n[2].min=c[1])),l&&(("0"===n[1].max||(0,s.versionCompare)(n[1].max,l[0])<0)&&(n[1].max=l[0]),("0"===n[2].max||(0,s.versionCompare)(n[2].max,l[1])<0)&&(n[2].max=l[1]))}return n}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=(n(r(58)),n(r(32))),s=r(6),u=r(216),f=r(48),c=r(13),l=function(){function e(e){var t=this,r=e.payload;this.name=r.method,this.responseID=e.id||0,this.devicePath=r.device?r.device.path:null,this.deviceInstance=r.device?r.device.instance:0,this.deviceState=r.device?r.device.state:null,this.hasExpectedDeviceState=!!r.device&&Object.prototype.hasOwnProperty.call(r.device,"state"),this.keepSession="boolean"==typeof r.keepSession&&r.keepSession,this.skipFinalReload="boolean"==typeof r.skipFinalReload&&r.skipFinalReload,this.skipFirmwareCheck=!1,this.overridePreviousCall="boolean"==typeof r.override&&r.override,this.overridden=!1,this.useEmptyPassphrase="boolean"==typeof r.useEmptyPassphrase&&r.useEmptyPassphrase,this.allowSeedlessDevice="boolean"==typeof r.allowSeedlessDevice&&r.allowSeedlessDevice,this.allowDeviceMode=[],this.requireDeviceMode=[],this.allowSeedlessDevice&&(this.allowDeviceMode=[s.UI.SEEDLESS]),this.debugLink=!1,this.network="Bitcoin",Object.keys(s.NETWORK.TYPES).forEach((function(e){t.name.startsWith(e)&&(t.network=s.NETWORK.TYPES[e])})),this.firmwareRange={1:{min:"1.0.0",max:"0"},2:{min:"2.0.0",max:"0"}},this.requiredPermissions=[],this.useDevice=!0,this.useDeviceState=!0,this.useUi=!0}var t=e.prototype;return t.setDevice=function(e){this.device=e,this.devicePath=e.getDevicePath()},t.run=function(){var e=(0,o.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",new Promise((function(e){return e({})})));case 1:case"end":return e.stop()}}),e)})));return function(){return e.apply(this,arguments)}}(),t.requestPermissions=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(s.UI.RECEIVE_PERMISSION,this.device),this.postMessage((0,c.UiMessage)(s.UI.REQUEST_PERMISSION,{permissions:this.requiredPermissions,device:this.device.toMessageObject()})),e.next=6,t.promise;case 6:if(r=e.sent,!(n=r.payload).granted){e.next=11;break}return this.savePermissions(!n.remember),e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.checkPermissions=function(){var e=this,t=(0,u.load)(u.PERMISSIONS_KEY),r=[].concat(this.requiredPermissions);if(t&&Array.isArray(t)){var n=t.filter((function(e){return e.origin===a.default.getSettings("origin")}));n.length>0&&(r=r.filter((function(t){return!n.find((function(r){return r.type===t&&r.device===e.device.features.device_id}))})))}this.requiredPermissions=r},t.savePermissions=function(e){var t=this;void 0===e&&(e=!1);var r=(0,u.load)(u.PERMISSIONS_KEY,e);r&&Array.isArray(r)||(r=JSON.parse("[]"));var n=this.requiredPermissions.map((function(e){return{origin:a.default.getSettings("origin"),type:e,device:t.device.features.device_id}})),i=!1;this.requiredPermissions.indexOf("read")>=0&&(r.filter((function(e){return e.origin===a.default.getSettings("origin")&&"read"===e.type&&e.device===t.device.features.device_id})).length<1&&(i=!0));var o=r.filter((function(e){return e.origin===a.default.getSettings("origin")}));o.length>0&&(n=n.filter((function(e){return!o.find((function(t){return t.type===e.type&&t.device===e.device}))}))),(0,u.save)(u.PERMISSIONS_KEY,r.concat(n),e),i&&this.postMessage((0,c.DeviceMessage)(s.DEVICE.CONNECT,this.device.toMessageObject()))},t.checkFirmwareRange=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n,o,a,u;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.skipFirmwareCheck){e.next=2;break}return e.abrupt("return",null);case 2:if((r=this.device).features){e.next=5;break}return e.abrupt("return",null);case 5:if(n=r.getVersion(),o=n[0],a=this.firmwareRange[o],"none"!==r.firmwareStatus){e.next=10;break}return e.abrupt("return",s.UI.FIRMWARE_NOT_INSTALLED);case 10:if("0"!==a.min){e.next=12;break}return e.abrupt("return",s.UI.FIRMWARE_NOT_SUPPORTED);case 12:if(!("required"===r.firmwareStatus||(0,f.versionCompare)(n,a.min)<0)){e.next=14;break}return e.abrupt("return",s.UI.FIRMWARE_OLD);case 14:if(!("0"!==a.max&&(0,f.versionCompare)(n,a.max)>0)){e.next=28;break}if(!t){e.next=27;break}return e.next=18,this.getPopupPromise().promise;case 18:return u=this.createUiPromise(s.UI.RECEIVE_CONFIRMATION,r),this.postMessage((0,c.UiMessage)(s.UI.FIRMWARE_NOT_COMPATIBLE,r.toMessageObject())),e.next=22,u.promise;case 22:if(e.sent.payload){e.next=25;break}throw s.ERRORS.TypedError("Method_PermissionsNotGranted");case 25:e.next=28;break;case 27:return e.abrupt("return",s.UI.FIRMWARE_NOT_COMPATIBLE);case 28:return e.abrupt("return",null);case 29:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getCustomMessages=function(){return null},t.dispose=function(){},e}();t.default=l},function(e,t,r){"use strict";var n=r(14);t.__esModule=!0,t.CARDANO=t.UI=t.TRANSPORT=t.POPUP=t.NETWORK=t.IFRAME=t.ERRORS=t.DEVICE=t.BLOCKCHAIN=t.BLOCKCHAIN_EVENT=t.RESPONSE_EVENT=t.TRANSPORT_EVENT=t.DEVICE_EVENT=t.UI_EVENT=t.CORE_EVENT=void 0;var i=n(r(234));t.BLOCKCHAIN=i;var o=n(r(79));t.DEVICE=o;var a=n(r(235));t.ERRORS=a;var s=n(r(123));t.IFRAME=s;var u=n(r(241));t.NETWORK=u;var f=n(r(124));t.POPUP=f;var c=n(r(125));t.TRANSPORT=c;var l=n(r(20));t.UI=l;var h=n(r(80));t.CARDANO=h;t.CORE_EVENT="CORE_EVENT";t.UI_EVENT="UI_EVENT";t.DEVICE_EVENT="DEVICE_EVENT";t.TRANSPORT_EVENT="TRANSPORT_EVENT";t.RESPONSE_EVENT="RESPONSE_EVENT";t.BLOCKCHAIN_EVENT="BLOCKCHAIN_EVENT"},function(e,t,r){ +!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="./",r(r.s=230)}([function(e,t){e.exports=function(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){e.exports=r(232)},function(e,t){function r(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}}},function(e,t){e.exports=function(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getFirmwareRange=t.validateCoinPath=t.validateParams=void 0;var i=n(r(29)),o=r(6),a=r(12),s=r(48),u=n(r(32)),f=function(e){return o.ERRORS.TypedError("Method_InvalidParameter",e)};t.validateParams=function(e,t){t.forEach((function(t){if(Object.prototype.hasOwnProperty.call(e,t.name)){var r=e[t.name];if(t.type)if("array"===t.type){if(!Array.isArray(r))throw f('Parameter "'+t.name+'" has invalid type. "'+t.type+'" expected.');if(!t.allowEmpty&&r.length<1)throw f('Parameter "'+t.name+'" is empty.')}else if("amount"===t.type){if("string"!=typeof r)throw f('Parameter "'+t.name+'" has invalid type. "string" expected.');try{if(new i.default(r).toFixed(0)!==r)throw new Error("")}catch(e){throw f('Parameter "'+t.name+'" has invalid value "'+r+'". Integer representation expected.')}}else if("buffer"===t.type){if(void 0===r||"function"==typeof r.constructor.isBuffer&&r.constructor.isBuffer(r))throw f('Parameter "'+t.name+'" has invalid type. "buffer" expected.')}else if(typeof r!==t.type)throw f('Parameter "'+t.name+'" has invalid type. "'+t.type+'" expected.')}else if(t.obligatory)throw f('Parameter "'+t.name+'" is missing.')}))};t.validateCoinPath=function(e,t){if(e&&e.slip44!==(0,a.fromHardened)(t[1]))throw f('Parameters "path" and "coin" do not match.')};t.getFirmwareRange=function(e,t,r){var n=JSON.parse(JSON.stringify(r));t&&(t.support&&"string"==typeof t.support.trezor1?(0,s.versionCompare)(t.support.trezor1,n[1].min)>0&&(n[1].min=t.support.trezor1):n[1].min="0",t.support&&"string"==typeof t.support.trezor2?(0,s.versionCompare)(t.support.trezor2,n[2].min)>0&&(n[2].min=t.support.trezor2):n[2].min="0");var i=t?t.type:null,o=t?t.shortcut.toLowerCase():null,a=u.default.getConfig().supportedFirmware,f=a.find((function(e){return e.coinType===i||Array.isArray(e.coin)&&e.coin.includes(o)||"string"==typeof e.coin&&e.coin===o}))||a.find((function(t){return!t.coinType&&!t.coin&&t.excludedMethods&&t.excludedMethods.includes(e)}));if(f){if(f.excludedMethods&&!f.excludedMethods.includes(e))return n;var c=f.min,l=f.max;c&&(("0"===n[1].min||(0,s.versionCompare)(n[1].min,c[0])<0)&&(n[1].min=c[0]),("0"===n[2].min||(0,s.versionCompare)(n[2].min,c[1])<0)&&(n[2].min=c[1])),l&&(("0"===n[1].max||(0,s.versionCompare)(n[1].max,l[0])<0)&&(n[1].max=l[0]),("0"===n[2].max||(0,s.versionCompare)(n[2].max,l[1])<0)&&(n[2].max=l[1]))}return n}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(32)),s=r(6),u=r(214),f=r(48),c=r(13),l=function(){function e(e){var t=this,r=e.payload;this.name=r.method,this.responseID=e.id||0,this.devicePath=r.device?r.device.path:null,this.deviceInstance=r.device?r.device.instance:0,this.deviceState=r.device?r.device.state:null,this.hasExpectedDeviceState=!!r.device&&Object.prototype.hasOwnProperty.call(r.device,"state"),this.keepSession="boolean"==typeof r.keepSession&&r.keepSession,this.skipFinalReload="boolean"==typeof r.skipFinalReload&&r.skipFinalReload,this.skipFirmwareCheck=!1,this.overridePreviousCall="boolean"==typeof r.override&&r.override,this.overridden=!1,this.useEmptyPassphrase="boolean"==typeof r.useEmptyPassphrase&&r.useEmptyPassphrase,this.allowSeedlessDevice="boolean"==typeof r.allowSeedlessDevice&&r.allowSeedlessDevice,this.allowDeviceMode=[],this.requireDeviceMode=[],this.allowSeedlessDevice&&(this.allowDeviceMode=[s.UI.SEEDLESS]),this.debugLink=!1,this.network="Bitcoin",Object.keys(s.NETWORK.TYPES).forEach((function(e){t.name.startsWith(e)&&(t.network=s.NETWORK.TYPES[e])})),this.firmwareRange={1:{min:"1.0.0",max:"0"},2:{min:"2.0.0",max:"0"}},this.requiredPermissions=[],this.useDevice=!0,this.useDeviceState=!0,this.useUi=!0}var t=e.prototype;return t.setDevice=function(e){this.device=e,this.devicePath=e.getDevicePath()},t.run=function(){return new Promise((function(e){return e({})}))},t.requestPermissions=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(s.UI.RECEIVE_PERMISSION,this.device),this.postMessage((0,c.UiMessage)(s.UI.REQUEST_PERMISSION,{permissions:this.requiredPermissions,device:this.device.toMessageObject()})),e.next=6,t.promise;case 6:if(r=e.sent,!(n=r.payload).granted){e.next=11;break}return this.savePermissions(!n.remember),e.abrupt("return",!0);case 11:return e.abrupt("return",!1);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.checkPermissions=function(){var e=this,t=(0,u.load)(u.PERMISSIONS_KEY),r=[].concat(this.requiredPermissions);if(t&&Array.isArray(t)){var n=t.filter((function(e){return e.origin===a.default.getSettings("origin")}));n.length>0&&(r=r.filter((function(t){return!n.find((function(r){return r.type===t&&r.device===e.device.features.device_id}))})))}this.requiredPermissions=r},t.savePermissions=function(e){var t=this;void 0===e&&(e=!1);var r=(0,u.load)(u.PERMISSIONS_KEY,e);r&&Array.isArray(r)||(r=JSON.parse("[]"));var n=this.requiredPermissions.map((function(e){return{origin:a.default.getSettings("origin"),type:e,device:t.device.features.device_id}})),i=!1;this.requiredPermissions.indexOf("read")>=0&&(r.filter((function(e){return e.origin===a.default.getSettings("origin")&&"read"===e.type&&e.device===t.device.features.device_id})).length<1&&(i=!0));var o=r.filter((function(e){return e.origin===a.default.getSettings("origin")}));o.length>0&&(n=n.filter((function(e){return!o.find((function(t){return t.type===e.type&&t.device===e.device}))}))),(0,u.save)(u.PERMISSIONS_KEY,r.concat(n),e),i&&this.postMessage((0,c.DeviceMessage)(s.DEVICE.CONNECT,this.device.toMessageObject()))},t.checkFirmwareRange=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n,o,a,u;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.skipFirmwareCheck){e.next=2;break}return e.abrupt("return",null);case 2:if((r=this.device).features){e.next=5;break}return e.abrupt("return",null);case 5:if(n=r.getVersion(),o=n[0],a=this.firmwareRange[o],"none"!==r.firmwareStatus){e.next=10;break}return e.abrupt("return",s.UI.FIRMWARE_NOT_INSTALLED);case 10:if("0"!==a.min){e.next=12;break}return e.abrupt("return",s.UI.FIRMWARE_NOT_SUPPORTED);case 12:if(!("required"===r.firmwareStatus||(0,f.versionCompare)(n,a.min)<0)){e.next=14;break}return e.abrupt("return",s.UI.FIRMWARE_OLD);case 14:if(!("0"!==a.max&&(0,f.versionCompare)(n,a.max)>0)){e.next=28;break}if(!t){e.next=27;break}return e.next=18,this.getPopupPromise().promise;case 18:return u=this.createUiPromise(s.UI.RECEIVE_CONFIRMATION,r),this.postMessage((0,c.UiMessage)(s.UI.FIRMWARE_NOT_COMPATIBLE,r.toMessageObject())),e.next=22,u.promise;case 22:if(e.sent.payload){e.next=25;break}throw s.ERRORS.TypedError("Method_PermissionsNotGranted");case 25:e.next=28;break;case 27:return e.abrupt("return",s.UI.FIRMWARE_NOT_COMPATIBLE);case 28:return e.abrupt("return",null);case 29:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.getCustomMessages=function(){return null},t.dispose=function(){},e}();t.default=l},function(e,t,r){"use strict";var n=r(14);t.__esModule=!0,t.CARDANO=t.UI=t.TRANSPORT=t.POPUP=t.NETWORK=t.IFRAME=t.ERRORS=t.DEVICE=t.BLOCKCHAIN=t.BLOCKCHAIN_EVENT=t.RESPONSE_EVENT=t.TRANSPORT_EVENT=t.DEVICE_EVENT=t.UI_EVENT=t.CORE_EVENT=void 0;var i=n(r(233));t.BLOCKCHAIN=i;var o=n(r(78));t.DEVICE=o;var a=n(r(234));t.ERRORS=a;var s=n(r(122));t.IFRAME=s;var u=n(r(240));t.NETWORK=u;var f=n(r(123));t.POPUP=f;var c=n(r(124));t.TRANSPORT=c;var l=n(r(20));t.UI=l;var h=n(r(79));t.CARDANO=h;t.CORE_EVENT="CORE_EVENT";t.UI_EVENT="UI_EVENT";t.DEVICE_EVENT="DEVICE_EVENT";t.TRANSPORT_EVENT="TRANSPORT_EVENT";t.RESPONSE_EVENT="RESPONSE_EVENT";t.BLOCKCHAIN_EVENT="BLOCKCHAIN_EVENT"},function(e,t,r){ /*! safe-buffer. MIT License. Feross Aboukhadijeh */ -var n=r(9),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.cloneCoinInfo=p,t.getCoinInfoByCapability=t.getAllNetworks=t.getUniqueNetworks=t.parseCoinsJson=t.getCoinName=t.getCoinInfo=t.getCoinInfoByHash=t.fixCoinInfoNetwork=t.getBech32Network=t.getSegwitNetwork=t.getMiscNetwork=t.getEthereumNetwork=t.getBitcoinNetwork=void 0;var i=n(r(11)),o=r(6),a=r(12);function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0?{type:"blockbook",url:r.blockbook}:void 0;l.push({type:"bitcoin",blockchainLink:s,blocktime:Math.round(r.blocktime_seconds/60),cashAddrPrefix:r.cashaddr_prefix,label:r.coin_label,name:r.coin_name,shortcut:n,curveName:r.curve_name,defaultFees:r.default_fee_b,dustLimit:r.dust_limit,forceBip143:r.force_bip143,forkid:r.fork_id,hashGenesisBlock:r.hash_genesis_block,maxAddressLength:r.max_address_length,maxFeeSatoshiKb:r.maxfee_kb,minAddressLength:r.min_address_length,minFeeSatoshiKb:r.minfee_kb,segwit:r.segwit,slip44:r.slip44,support:r.support,xPubMagic:r.xpub_magic,xPubMagicSegwitNative:r.xpub_magic_segwit_native,xPubMagicSegwit:r.xpub_magic_segwit_p2sh,network:a,isBitcoin:i,hasTimestamp:o,maxFee:Math.round(r.maxfee_kb/1e3),minFee:Math.round(r.minfee_kb/1e3),blocks:Math.round(r.blocktime_seconds/60),decimals:r.decimals})}))}(t[e]);case"eth":return function(e){var t=e;Object.keys(t).forEach((function(e){var r=t[e],n=Array.isArray(r.blockbook)&&r.blockbook.length>0?{type:"blockbook",url:r.blockbook}:void 0;h.push({type:"ethereum",blockchainLink:n,blocktime:-1,chain:r.chain,chainId:r.chain_id,defaultFees:[{label:"normal",feePerUnit:"5000000000",feeLimit:"21000"}],minFee:1,maxFee:1e4,label:r.name,name:r.name,shortcut:r.shortcut,rskip60:r.rskip60,slip44:r.slip44,support:r.support,network:void 0,decimals:16})}))}(t[e]);case"misc":return _(t[e]);case"nem":return _(t[e],"nem")}}))};var E=function(e){return e.reduce((function(e,t){return!t||e.find((function(e){return e.shortcut===t.shortcut}))?e:e.concat(t)}),[])};t.getUniqueNetworks=E;t.getAllNetworks=function(){return[].concat(l).concat(h).concat(d)};t.getCoinInfoByCapability=function(e){var t=e.reduce((function(e,t){if("Capability_Bitcoin"===t)return e.concat(w("Bitcoin")).concat(w("Testnet"));if("Capability_Bitcoin_like"===t)return e.concat(l);if("Capability_Binance"===t)return e.concat(w("BNB"));if("Capability_Ethereum"===t)return e.concat(h);if("Capability_Ripple"===t)return e.concat(w("xrp")).concat(w("txrp"));var r=t.split("_")[1];return"string"==typeof r?e.concat(w(r)):e}),[]);return E(t)}},function(e,t,r){"use strict";(function(e){ +var n=r(9),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=o),o.prototype=Object.create(Buffer.prototype),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.cloneCoinInfo=p,t.getCoinInfoByCapability=t.getAllNetworks=t.getUniqueNetworks=t.parseCoinsJson=t.getCoinName=t.getCoinInfo=t.getCoinInfoByHash=t.fixCoinInfoNetwork=t.getBech32Network=t.getSegwitNetwork=t.getMiscNetwork=t.getEthereumNetwork=t.getBitcoinNetwork=void 0;var i=n(r(11)),o=r(6),a=r(12);function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return u(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return u(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0?{type:"blockbook",url:r.blockbook}:void 0;l.push({type:"bitcoin",blockchainLink:s,blocktime:Math.round(r.blocktime_seconds/60),cashAddrPrefix:r.cashaddr_prefix,label:r.coin_label,name:r.coin_name,shortcut:n,curveName:r.curve_name,defaultFees:r.default_fee_b,dustLimit:r.dust_limit,forceBip143:r.force_bip143,forkid:r.fork_id,hashGenesisBlock:r.hash_genesis_block,maxAddressLength:r.max_address_length,maxFeeSatoshiKb:r.maxfee_kb,minAddressLength:r.min_address_length,minFeeSatoshiKb:r.minfee_kb,segwit:r.segwit,slip44:r.slip44,support:r.support,xPubMagic:r.xpub_magic,xPubMagicSegwitNative:r.xpub_magic_segwit_native,xPubMagicSegwit:r.xpub_magic_segwit_p2sh,network:a,isBitcoin:i,hasTimestamp:o,maxFee:Math.round(r.maxfee_kb/1e3),minFee:Math.round(r.minfee_kb/1e3),blocks:Math.round(r.blocktime_seconds/60),decimals:r.decimals})}))}(t[e]);case"eth":return function(e){var t=e;Object.keys(t).forEach((function(e){var r=t[e],n=Array.isArray(r.blockbook)&&r.blockbook.length>0?{type:"blockbook",url:r.blockbook}:void 0;h.push({type:"ethereum",blockchainLink:n,blocktime:-1,chain:r.chain,chainId:r.chain_id,defaultFees:[{label:"normal",feePerUnit:"5000000000",feeLimit:"21000"}],minFee:1,maxFee:1e4,label:r.name,name:r.name,shortcut:r.shortcut,rskip60:r.rskip60,slip44:r.slip44,support:r.support,network:void 0,decimals:16})}))}(t[e]);case"misc":return _(t[e]);case"nem":return _(t[e],"nem")}}))};var E=function(e){return e.reduce((function(e,t){return!t||e.find((function(e){return e.shortcut===t.shortcut}))?e:e.concat(t)}),[])};t.getUniqueNetworks=E;t.getAllNetworks=function(){return[].concat(l).concat(h).concat(d)};t.getCoinInfoByCapability=function(e){var t=e.reduce((function(e,t){if("Capability_Bitcoin"===t)return e.concat(w("Bitcoin")).concat(w("Testnet"));if("Capability_Bitcoin_like"===t)return e.concat(l);if("Capability_Binance"===t)return e.concat(w("BNB"));if("Capability_Ethereum"===t)return e.concat(h);if("Capability_Ripple"===t)return e.concat(w("xrp")).concat(w("txrp"));var r=t.split("_")[1];return"string"==typeof r?e.concat(w(r)):e}),[]);return E(t)}},function(e,t,r){"use strict";(function(e){ /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT */ -var n=r(246),i=r(247),o=r(131);function a(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function d(e,t){if(Buffer.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,r);case"utf8":case"utf-8":return I(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function g(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function I(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},Buffer.prototype.compare=function(e,t,r,n,i){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=e.slice(t,r),c=0;ci)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,r,n,i,o){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function R(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function C(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function N(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(e,t,r,n,o){return o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,o){return o||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},Buffer.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return t||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return t||T(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Buffer.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){t||T(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){t||T(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return t||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return t||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),i.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||x(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):C(this,e,t,!0),t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):C(this,e,t,!0),t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return B(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return B(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(24))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},function(e,t,r){"use strict";t.__esModule=!0,t.getLabel=t.getPublicKeyLabel=t.getAccountLabel=t.getIndexFromPath=t.getPathFromIndex=t.getSerializedPath=t.validatePath=t.getOutputScriptType=t.getScriptType=t.isBech32Path=t.isSegwitPath=t.isMultisigPath=t.getHDPath=t.fromHardened=t.toHardened=t.HD_HARDENED=void 0;var n=r(8),i=r(6);t.HD_HARDENED=2147483648;var o=function(e){return(2147483648|e)>>>0};t.toHardened=o;var a=function(e){return(2147483647&e)>>>0};t.fromHardened=a;var s=i.ERRORS.TypedError("Method_InvalidParameter","Not a valid path"),u=i.ERRORS.TypedError("Method_InvalidParameter","Path cannot contain negative values"),f=function(e){var t=e.toLowerCase().split("/");if("m"!==t[0])throw s;return t.filter((function(e){return"m"!==e&&""!==e})).map((function(e){var t=!1;"'"===e.substr(e.length-1)&&(t=!0,e=e.substr(0,e.length-1));var r=parseInt(e);if(isNaN(r))throw s;if(r<0)throw u;return t&&(r=o(r)),r}))};t.getHDPath=f;t.isMultisigPath=function(e){return Array.isArray(e)&&e[0]===o(48)};t.isSegwitPath=function(e){return Array.isArray(e)&&e[0]===o(49)};t.isBech32Path=function(e){return Array.isArray(e)&&e[0]===o(84)};t.getScriptType=function(e){if(!Array.isArray(e)||e.length<1)return"SPENDADDRESS";switch(a(e[0])){case 48:return"SPENDMULTISIG";case 49:return"SPENDP2SHWITNESS";case 84:return"SPENDWITNESS";default:return"SPENDADDRESS"}};t.getOutputScriptType=function(e){if(!Array.isArray(e)||e.length<1)return"PAYTOADDRESS";if(49===e[0])return"PAYTOP2SHWITNESS";switch(a(e[0])){case 48:return"PAYTOMULTISIG";case 49:return"PAYTOP2SHWITNESS";case 84:return"PAYTOWITNESS";default:return"PAYTOADDRESS"}};t.validatePath=function(e,t,r){var n;if(void 0===t&&(t=0),void 0===r&&(r=!1),"string"==typeof e?n=f(e):Array.isArray(e)&&(n=e.map((function(e){var t=parseInt(e);if(isNaN(t))throw s;if(t<0)throw u;return t}))),!n)throw s;if(t>0&&n.lengthaccount #"+i+""};t.getPublicKeyLabel=function(e,t){var r=!1,i="Unknown coin";t?(i=t.label,r=t.segwit):i=(0,n.getCoinName)(e);var o=a(e[0]),s=e.length>=3?a(e[2]):-1,u=s+1,f="Export public key",c="";if(45342===o){var l=a(e[1]);u=(s=a(e[3]))+1,f="Export Copay ID of",48===l?c="multisig":44===l&&(c="legacy")}else c=48===o?i+" multisig":44===o&&r?i+" legacy":84===o&&r?i+" native segwit":i;return u>0?f+" of "+c+" account #"+u+"":f};t.getLabel=function(e,t){return t?e.replace("#NETWORK",t.label):e.replace("#NETWORK","")}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.BlockchainMessage=t.ResponseMessage=t.TransportMessage=t.DeviceMessage=t.UiMessage=void 0;var i=n(r(11)),o=r(6);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;tt.maxLength)&&((void 0===t.length||r.length===t.length)&&r.every((function(t,r){try{return h(e,t,n)}catch(e){throw u(e,r)}}))))))}return e=l(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=l(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&h(t,o,n)}catch(e){throw u(e,o,"key")}try{var a=r[o];h(e,a,n)}catch(e){throw u(e,o)}}return!0}return e=l(e),t&&(t=l(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=l(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t){h(t[n],e[n],r)}}catch(e){throw u(e,n)}if(r)for(n in e)if(!t[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(l);function t(t,r){return e.some((function(e){try{return h(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(l);function t(t,r){return e.every((function(e){try{return h(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===f(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(l);function t(t,r){return!i.Nil(t)&&(!i.Nil(t.length)&&((!r||t.length===e.length)&&e.every((function(e,n){try{return h(e,t[n],r)}catch(e){throw u(e,n)}}))))}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function l(e){if(i.String(e))return"?"===e[0]?c.maybe(e.slice(1)):i[e]||c.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(e[0])}return c.object(e)}return i.Function(e)?e:c.value(e)}function h(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new a(n||e,t)}return h(l(e),t,r)}for(var d in c.oneOf=c.anyOf,i)h[d]=i[d];for(d in c)h[d]=c[d];var p=r(364);for(d in p)h[d]=p[d];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,e.exports=h},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var u,f=[],c=!1,l=-1;function h(){c&&u&&(c=!1,u.length?f=u.concat(f):l=-1,f.length&&d())}function d(){if(!c){var e=s(h);c=!0;for(var t=f.length;t;){for(u=f,f=[];++l1)for(var r=1;r=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function s(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,u=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var u=["","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],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?u[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var h=f[e],d=c[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?y+r:u[h-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==Buffer),this.toArrayLike(Buffer,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,y=d>>>13,g=0|a[2],m=8191&g,b=g>>>13,v=0|a[3],w=8191&v,_=v>>>13,E=0|a[4],S=8191&E,A=E>>>13,I=0|a[5],O=8191&I,P=I>>>13,M=0|a[6],k=8191&M,T=M>>>13,x=0|a[7],R=8191&x,C=x>>>13,N=0|a[8],B=8191&N,D=N>>>13,U=0|a[9],j=8191&U,L=U>>>13,F=0|s[0],H=8191&F,q=F>>>13,V=0|s[1],K=8191&V,z=V>>>13,G=0|s[2],Q=8191&G,W=G>>>13,Y=0|s[3],Z=8191&Y,J=Y>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,H))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,H)|0))<<13)|0;f=((o=Math.imul(h,q))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(y,H)|0,o=Math.imul(y,q);var me=(f+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,z)|0)+Math.imul(h,K)|0))<<13)|0;f=((o=o+Math.imul(h,z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(b,H)|0,o=Math.imul(b,q),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,z)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,z)|0;var be=(f+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,Q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,z)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,W)|0;var ve=(f+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(A,H)|0,o=Math.imul(A,q),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,z)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,J)|0;var we=(f+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,H),i=(i=Math.imul(O,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,z)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,q))+Math.imul(T,H)|0,o=Math.imul(T,q),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,z)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0;var Se=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,q))+Math.imul(D,H)|0,o=Math.imul(D,q),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,z)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,z)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,H),i=(i=Math.imul(j,q))+Math.imul(L,H)|0,o=Math.imul(L,q),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,z)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,z)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Ie=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ye)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,z))+Math.imul(L,K)|0,o=Math.imul(L,z),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Oe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;f=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,W))+Math.imul(L,Q)|0,o=Math.imul(L,W),n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(T,re)|0,o=o+Math.imul(T,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var Pe=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,J))+Math.imul(L,Z)|0,o=Math.imul(L,J),n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,fe)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var Me=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,ee))+Math.imul(L,$)|0,o=Math.imul(L,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var ke=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,ye)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(P,pe)|0))<<13)|0;f=((o=o+Math.imul(P,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(T,pe)|0))<<13)|0;f=((o=o+Math.imul(T,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(L,le)|0,o=Math.imul(L,he);var Ce=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ye)|0)+Math.imul(D,pe)|0))<<13)|0;f=((o=o+Math.imul(D,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ne=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ye))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ye))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Se,u[8]=Ae,u[9]=Ie,u[10]=Oe,u[11]=Pe,u[12]=Me,u[13]=ke,u[14]=Te,u[15]=xe,u[16]=Re,u[17]=Ce,u[18]=Ne,0!==f&&(u[19]=f,r.length++),r};function d(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(h=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?h(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):d(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new _(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var y={k256:null,p224:null,p192:null,p25519:null};function g(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){g.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){g.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){g.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){g.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}g.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},g.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},g.prototype.split=function(e,t){e.iushrn(this.n,0,t)},g.prototype.imulK=function(e){return e.imul(this.k)},i(m,g),m.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},m.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(y[e])return y[e];var t;if("k256"===e)t=new m;else if("p224"===e)t=new b;else if("p192"===e)t=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return y[e]=t,t},_.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var y=d,g=0;0!==y.cmp(s);g++)y=y.redSqr();n(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,_),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(66)(e))},function(e,t,r){var Buffer=r(7).Buffer,n=r(105),i=r(187),o=r(15),a=r(22),s=r(189),u=r(26),f=r(365),c=u.OP_RESERVED;function l(e){return a.Buffer(e)||function(e){return a.Number(e)&&(e===u.OP_0||e>=u.OP_1&&e<=u.OP_16||e===u.OP_1NEGATE)}(e)}function h(e){return a.Array(e)&&e.every(l)}function d(e){return 0===e.length?u.OP_0:1===e.length?e[0]>=1&&e[0]<=16?c+e[0]:129===e[0]?u.OP_1NEGATE:void 0:void 0}function p(e){if(Buffer.isBuffer(e))return e;o(a.Array,e);var t=e.reduce((function(e,t){return Buffer.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+i.encodingLength(t.length)+t.length:e+1}),0),r=Buffer.allocUnsafe(t),n=0;if(e.forEach((function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,n),void(n+=1);n+=i.encode(r,e.length,n),e.copy(r,n),n+=e.length}else r.writeUInt8(e,n),n+=1})),n!==r.length)throw new Error("Could not decode chunks");return r}function y(e){if(a.Array(e))return e;o(a.Buffer,e);for(var t=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var s=i.decode(e,r);if(null===s)return[];if((r+=s.size)+s.number>e.length)return[];var f=e.slice(r,r+s.number);r+=s.number;var c=d(f);void 0!==c?t.push(c):t.push(f)}else t.push(n),r+=1}return t}function g(e){var t=-193&e;return t>0&&t<4}e.exports={compile:p,decompile:y,fromASM:function(e){return o(a.String,e),p(e.split(" ").map((function(e){return void 0!==u[e]?u[e]:(o(a.Hex,e),Buffer.from(e,"hex"))})))},toASM:function(e){return Buffer.isBuffer(e)&&(e=y(e)),e.map((function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return f[e]})).join(" ")},toStack:function(e){return e=y(e),o(h,e),e.map((function(e){return Buffer.isBuffer(e)?e:e===u.OP_0?Buffer.allocUnsafe(0):s.encode(e-c)}))},number:r(189),isCanonicalPubKey:function(e){if(!Buffer.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!Buffer.isBuffer(e)&&(!!g(e[e.length-1])&&n.check(e.slice(0,-1)))},isPushOnly:h,isDefinedHashType:g}},function(e,t,r){"use strict";t.__esModule=!0,t.IFRAME_FAILURE=t.ADDRESS_VALIDATION=t.BUNDLE_PROGRESS=t.LOGIN_CHALLENGE_RESPONSE=t.LOGIN_CHALLENGE_REQUEST=t.CUSTOM_MESSAGE_RESPONSE=t.CUSTOM_MESSAGE_REQUEST=t.CHANGE_SETTINGS=t.RECEIVE_WORD=t.RECEIVE_FEE=t.RECEIVE_ACCOUNT=t.CHANGE_ACCOUNT=t.RECEIVE_DEVICE=t.RECEIVE_PASSPHRASE=t.RECEIVE_PIN=t.RECEIVE_CONFIRMATION=t.RECEIVE_PERMISSION=t.REQUEST_WORD=t.REQUEST_BUTTON=t.INSUFFICIENT_FUNDS=t.UPDATE_CUSTOM_FEE=t.SELECT_FEE=t.SELECT_ACCOUNT=t.SELECT_DEVICE=t.SET_OPERATION=t.LOADING=t.CONNECT=t.INVALID_PASSPHRASE_ACTION=t.INVALID_PASSPHRASE=t.REQUEST_PASSPHRASE_ON_DEVICE=t.REQUEST_PASSPHRASE=t.INVALID_PIN=t.REQUEST_PIN=t.REQUEST_CONFIRMATION=t.REQUEST_PERMISSION=t.CLOSE_UI_WINDOW=t.REQUEST_UI_WINDOW=t.DEVICE_NEEDS_BACKUP=t.FIRMWARE_PROGRESS=t.FIRMWARE_NOT_INSTALLED=t.FIRMWARE_NOT_COMPATIBLE=t.FIRMWARE_NOT_SUPPORTED=t.FIRMWARE_OUTDATED=t.FIRMWARE_OLD=t.SEEDLESS=t.INITIALIZE=t.REQUIRE_MODE=t.NOT_IN_BOOTLOADER=t.BOOTLOADER=t.TRANSPORT=void 0;t.TRANSPORT="ui-no_transport";t.BOOTLOADER="ui-device_bootloader_mode";t.NOT_IN_BOOTLOADER="ui-device_not_in_bootloader_mode";t.REQUIRE_MODE="ui-device_require_mode";t.INITIALIZE="ui-device_not_initialized";t.SEEDLESS="ui-device_seedless";t.FIRMWARE_OLD="ui-device_firmware_old";t.FIRMWARE_OUTDATED="ui-device_firmware_outdated";t.FIRMWARE_NOT_SUPPORTED="ui-device_firmware_unsupported";t.FIRMWARE_NOT_COMPATIBLE="ui-device_firmware_not_compatible";t.FIRMWARE_NOT_INSTALLED="ui-device_firmware_not_installed";t.FIRMWARE_PROGRESS="ui-firmware-progress";t.DEVICE_NEEDS_BACKUP="ui-device_needs_backup";t.REQUEST_UI_WINDOW="ui-request_window";t.CLOSE_UI_WINDOW="ui-close_window";t.REQUEST_PERMISSION="ui-request_permission";t.REQUEST_CONFIRMATION="ui-request_confirmation";t.REQUEST_PIN="ui-request_pin";t.INVALID_PIN="ui-invalid_pin";t.REQUEST_PASSPHRASE="ui-request_passphrase";t.REQUEST_PASSPHRASE_ON_DEVICE="ui-request_passphrase_on_device";t.INVALID_PASSPHRASE="ui-invalid_passphrase";t.INVALID_PASSPHRASE_ACTION="ui-invalid_passphrase_action";t.CONNECT="ui-connect";t.LOADING="ui-loading";t.SET_OPERATION="ui-set_operation";t.SELECT_DEVICE="ui-select_device";t.SELECT_ACCOUNT="ui-select_account";t.SELECT_FEE="ui-select_fee";t.UPDATE_CUSTOM_FEE="ui-update_custom_fee";t.INSUFFICIENT_FUNDS="ui-insufficient_funds";t.REQUEST_BUTTON="ui-button";t.REQUEST_WORD="ui-request_word";t.RECEIVE_PERMISSION="ui-receive_permission";t.RECEIVE_CONFIRMATION="ui-receive_confirmation";t.RECEIVE_PIN="ui-receive_pin";t.RECEIVE_PASSPHRASE="ui-receive_passphrase";t.RECEIVE_DEVICE="ui-receive_device";t.CHANGE_ACCOUNT="ui-change_account";t.RECEIVE_ACCOUNT="ui-receive_account";t.RECEIVE_FEE="ui-receive_fee";t.RECEIVE_WORD="ui-receive_word";t.CHANGE_SETTINGS="ui-change_settings";t.CUSTOM_MESSAGE_REQUEST="ui-custom_request";t.CUSTOM_MESSAGE_RESPONSE="ui-custom_response";t.LOGIN_CHALLENGE_REQUEST="ui-login_challenge_request";t.LOGIN_CHALLENGE_RESPONSE="ui-login_challenge_response";t.BUNDLE_PROGRESS="ui-bundle_progress";t.ADDRESS_VALIDATION="ui-address_validation";t.IFRAME_FAILURE="ui-iframe_failure"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(182),i=r(71),o=r(57);t.create=function(e,t){return t.check=r,t.assert=r,t._innerValidate=function(r,n){return n.has(r,t)?{success:!0,value:r}:e(r,n)},t.validate=function(e){return t._innerValidate(e,(r=new WeakMap,{has:function(e,t){var n=r.get(e),i=n&&n.get(t)||!1;return function(e,t){if(null!==e&&"object"==typeof e){var n=r.get(e);r.set(e,n?n.set(t,!0):(new WeakMap).set(t,!0))}}(e,t),i}}));var r},t.guard=function(e){return t.validate(e).success},t.Or=function(e){return n.Union(t,e)},t.And=function(e){return n.Intersect(t,e)},t.withConstraint=function(e,r){return n.Constraint(t,e,r)},t.withGuard=function(e,r){return n.Constraint(t,e,r)},t.withBrand=function(e){return n.Brand(e,t)},t.reflect=t,t.toString=function(){return"Runtype<"+i.default(t)+">"},t;function r(e){var r=t.validate(e);if(r.success)return r.value;throw new o.ValidationError(r.message,r.key)}},t.innerValidate=function(e,t,r){return e._innerValidate(t,r)}},function(e,t,r){var n=r(15),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var a=n.quacksLike("BigInteger"),s=n.quacksLike("Point"),u=n.compile({r:a,s:a}),f=n.oneOf(n.UInt8,n.UInt16),c=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:f,scriptHash:f,wif:n.UInt8}),l={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:s,ECSignature:u,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:c,Satoshi:function(e){return n.UInt53(e)&&e<=21e14},UInt31:function(e){return n.UInt32(e)&&e<=i},NetworkVersion:f};for(var h in n)l[h]=n[h];e.exports=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.initBlockchain=t.isBackendSupported=t.setCustomBackend=t.find=t.remove=t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=n(r(455)),u=r(13),f=r(6),c=r(215);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t12e5,a=r.filter((function(e){return"string"!=typeof u.feeForBlock})),!o&&a.length,e.next=8,this.link.estimateFee(t);case 8:s=e.sent,r.forEach((function(e,t){u.feeForBlock[e]=s[t]})),this.feeTimestamp=n;case 11:return e.abrupt("return",this.link.estimateFee(t));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.subscribe=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return 0===this.link.listenerCount("block")&&this.link.on("block",(function(e){n.postMessage((0,u.BlockchainMessage)(f.BLOCKCHAIN.BLOCK,h({coin:n.coinInfo},e)))})),0===this.link.listenerCount("notification")&&this.link.on("notification",(function(e){n.postMessage((0,u.BlockchainMessage)(f.BLOCKCHAIN.NOTIFICATION,{coin:n.coinInfo,notification:e}))})),e.next=4,this.link.subscribe({type:"block"});case 4:if(r=e.sent,t){e.next=7;break}return e.abrupt("return",r);case 7:return e.abrupt("return",this.link.subscribe({type:"accounts",accounts:t}));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.subscribeFiatRates=function(){var e=(0,o.default)(i.default.mark((function e(t){var r=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return 0===this.link.listenerCount("fiatRates")&&this.link.on("fiatRates",(function(e){var t=e.rates;r.postMessage((0,u.BlockchainMessage)(f.BLOCKCHAIN.FIAT_RATES_UPDATE,{coin:r.coinInfo,rates:t}))})),e.abrupt("return",this.link.subscribe({type:"fiatRates"}));case 2:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unsubscribe=function(){var e=(0,o.default)(i.default.mark((function e(t){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=7;break}return this.link.removeAllListeners("block"),this.link.removeAllListeners("fiatRates"),this.link.removeAllListeners("notification"),e.next=6,this.link.unsubscribe({type:"fiatRates"});case 6:return e.abrupt("return",this.link.unsubscribe({type:"block"}));case 7:return e.abrupt("return",this.link.unsubscribe({type:"accounts",accounts:t}));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unsubscribeFiatRates=function(){var e=(0,o.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.link.removeAllListeners("fiatRates"),e.abrupt("return",this.link.unsubscribe({type:"fiatRates"}));case 2:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.pushTransaction=function(){var e=(0,o.default)(i.default.mark((function e(t){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.link.pushTransaction(t);case 2:return e.abrupt("return",e.sent);case 3:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.disconnect=function(){var e=(0,o.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:this.link.removeAllListeners(),this.link.disconnect(),this.onError(f.ERRORS.TypedError("Backend_Disconnected"));case 3:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();t.default=d;var p=[],y={},g={},m=function(e){var t=p.indexOf(e);t>=0&&p.splice(t,1)};t.remove=m;var b=function(e){for(var t=0;t0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=h.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var f=u.length,c=g(u,f);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):y.call(e,t)},s.prototype.listenerCount=y,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e){e.exports=JSON.parse('{"OP_FALSE":0,"OP_0":0,"OP_PUSHDATA1":76,"OP_PUSHDATA2":77,"OP_PUSHDATA4":78,"OP_1NEGATE":79,"OP_RESERVED":80,"OP_TRUE":81,"OP_1":81,"OP_2":82,"OP_3":83,"OP_4":84,"OP_5":85,"OP_6":86,"OP_7":87,"OP_8":88,"OP_9":89,"OP_10":90,"OP_11":91,"OP_12":92,"OP_13":93,"OP_14":94,"OP_15":95,"OP_16":96,"OP_NOP":97,"OP_VER":98,"OP_IF":99,"OP_NOTIF":100,"OP_VERIF":101,"OP_VERNOTIF":102,"OP_ELSE":103,"OP_ENDIF":104,"OP_VERIFY":105,"OP_RETURN":106,"OP_TOALTSTACK":107,"OP_FROMALTSTACK":108,"OP_2DROP":109,"OP_2DUP":110,"OP_3DUP":111,"OP_2OVER":112,"OP_2ROT":113,"OP_2SWAP":114,"OP_IFDUP":115,"OP_DEPTH":116,"OP_DROP":117,"OP_DUP":118,"OP_NIP":119,"OP_OVER":120,"OP_PICK":121,"OP_ROLL":122,"OP_ROT":123,"OP_SWAP":124,"OP_TUCK":125,"OP_CAT":126,"OP_SUBSTR":127,"OP_LEFT":128,"OP_RIGHT":129,"OP_SIZE":130,"OP_INVERT":131,"OP_AND":132,"OP_OR":133,"OP_XOR":134,"OP_EQUAL":135,"OP_EQUALVERIFY":136,"OP_RESERVED1":137,"OP_RESERVED2":138,"OP_1ADD":139,"OP_1SUB":140,"OP_2MUL":141,"OP_2DIV":142,"OP_NEGATE":143,"OP_ABS":144,"OP_NOT":145,"OP_0NOTEQUAL":146,"OP_ADD":147,"OP_SUB":148,"OP_MUL":149,"OP_DIV":150,"OP_MOD":151,"OP_LSHIFT":152,"OP_RSHIFT":153,"OP_BOOLAND":154,"OP_BOOLOR":155,"OP_NUMEQUAL":156,"OP_NUMEQUALVERIFY":157,"OP_NUMNOTEQUAL":158,"OP_LESSTHAN":159,"OP_GREATERTHAN":160,"OP_LESSTHANOREQUAL":161,"OP_GREATERTHANOREQUAL":162,"OP_MIN":163,"OP_MAX":164,"OP_WITHIN":165,"OP_RIPEMD160":166,"OP_SHA1":167,"OP_SHA256":168,"OP_HASH160":169,"OP_HASH256":170,"OP_CODESEPARATOR":171,"OP_CHECKSIG":172,"OP_CHECKSIGVERIFY":173,"OP_CHECKMULTISIG":174,"OP_CHECKMULTISIGVERIFY":175,"OP_NOP1":176,"OP_NOP2":177,"OP_CHECKLOCKTIMEVERIFY":177,"OP_NOP3":178,"OP_CHECKSEQUENCEVERIFY":178,"OP_NOP4":179,"OP_NOP5":180,"OP_NOP6":181,"OP_NOP7":182,"OP_NOP8":183,"OP_NOP9":184,"OP_NOP10":185,"OP_PUBKEYHASH":253,"OP_PUBKEY":254,"OP_INVALIDOPCODE":255}')},function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=r,r.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";var n=t,i=r(18),o=r(27),a=r(167);n.assert=o,n.toArray=a.toArray,n.zero2=a.zero2,n.toHex=a.toHex,n.encode=a.encode,n.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,n[a]=s,o.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n=0,i=0;e.cmpn(-n)>0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,r){var n;!function(i){"use strict";var o,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,u=Math.floor,f="[BigNumber Error] ",c=f+"Number primitive has more than 15 significant digits: ",l=1e14,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function y(e){for(var t,r,n=1,i=e.length,o=e[0]+"";nf^r?1:-1;for(s=(u=i.length)<(f=o.length)?u:f,a=0;ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1}function m(e,t,r,n){if(er||e!==u(e))throw Error(f+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return p(e.e/14)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else tC?y.c=y.e=null:e.e=10;l/=10,f++);return void(f>C?y.c=y.e=null:(y.e=f,y.c=[e]))}p=String(e)}else{if(!a.test(p=String(e)))return i(y,p,h);y.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(f=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(f<0&&(f=l),f+=+p.slice(l+1),p=p.substring(0,l)):f<0&&(f=p.length)}else{if(m(t,2,j.length,"Base"),10==t)return V(y=new L(e),M+y.e+1,k);if(p=String(e),h="number"==typeof e){if(0*e!=0)return i(y,p,h,t);if(y.s=1/e<0?(p=p.slice(1),-1):1,L.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(c+e)}else y.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=j.slice(0,t),f=l=0,d=p.length;lf){f=d;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,f=0;continue}return i(y,String(e),h,t)}h=!1,(f=(p=n(p,t,10,y.s)).indexOf("."))>-1?p=p.replace(".",""):f=p.length}for(l=0;48===p.charCodeAt(l);l++);for(d=p.length;48===p.charCodeAt(--d););if(p=p.slice(l,++d)){if(d-=l,h&&L.DEBUG&&d>15&&(e>9007199254740991||e!==u(e)))throw Error(c+y.s*e);if((f=f-l-1)>C)y.c=y.e=null;else if(f=x)?v(u,a):w(u,a,"0");else if(o=(e=V(new L(e),t,r)).e,s=(u=y(e.c)).length,1==n||2==n&&(t<=o||o<=T)){for(;ss){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-s)>0)for(o+1==s&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function H(e,t){for(var r,n=1,i=new L(e[0]);n=10;i/=10,n++);return(r=n+14*r-1)>C?e.c=e.e=null:r=10;f/=10,i++);if((o=t-i)<0)o+=14,a=t,p=(c=y[d=0])/g[i-a-1]%10|0;else if((d=s((o+1)/14))>=y.length){if(!n)break e;for(;y.length<=d;y.push(0));c=p=0,i=1,a=(o%=14)-14+1}else{for(c=f=y[d],i=1;f>=10;f/=10,i++);p=(a=(o%=14)-14+i)<0?0:c/g[i-a-1]%10|0}if(n=n||t<0||null!=y[d+1]||(a<0?c:c%g[i-a-1]),n=r<4?(p||n)&&(0==r||r==(e.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(o>0?a>0?c/g[i-a]:0:y[d-1])%10&1||r==(e.s<0?8:7)),t<1||!y[0])return y.length=0,n?(t-=e.e+1,y[0]=g[(14-t%14)%14],e.e=-t||0):y[0]=e.e=0,e;if(0==o?(y.length=d,f=1,d--):(y.length=d+1,f=g[14-o],y[d]=a>0?u(c/g[i-a]%g[a])*f:0),n)for(;;){if(0==d){for(o=1,a=y[0];a>=10;a/=10,o++);for(a=y[0]+=f,f=1;a>=10;a/=10,f++);o!=f&&(e.e++,y[0]==l&&(y[0]=1));break}if(y[d]+=f,y[d]!=l)break;y[d--]=0,f=1}for(o=y.length;0===y[--o];y.pop());}e.e>C?e.c=e.e=null:e.e=x?v(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return L.clone=e,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(f+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(r=e[t],0,d,t),M=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(r=e[t],0,8,t),k=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(m(r[0],-d,0,t),m(r[1],0,d,t),T=r[0],x=r[1]):(m(r,-d,d,t),T=-(x=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)m(r[0],-d,-1,t),m(r[1],1,d,t),R=r[0],C=r[1];else{if(m(r,-d,d,t),!r)throw Error(f+t+" cannot be zero: "+r);R=-(C=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(f+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw N=!r,Error(f+"crypto unavailable");N=r}else N=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(r=e[t],0,9,t),B=r),e.hasOwnProperty(t="POW_PRECISION")&&(m(r=e[t],0,d,t),D=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(f+t+" not an object: "+r);U=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(f+t+" invalid: "+r);j=r}}return{DECIMAL_PLACES:M,ROUNDING_MODE:k,EXPONENTIAL_AT:[T,x],RANGE:[R,C],CRYPTO:N,MODULO_MODE:B,POW_PRECISION:D,FORMAT:U,ALPHABET:j}},L.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!L.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-d&&i<=d&&i===u(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t=l||r!==u(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(f+"Invalid BigNumber: "+e)},L.maximum=L.max=function(){return H(arguments,O.lt)},L.minimum=L.min=function(){return H(arguments,O.gt)},L.random=(o=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,a,c=0,l=[],p=new L(P);if(null==e?e=M:m(e,0,d),i=s(e/14),N)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));c>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[c]=r[0],t[c+1]=r[1]):(l.push(a%1e14),c+=2);c=i/2}else{if(!crypto.randomBytes)throw N=!1,Error(f+"crypto unavailable");for(t=crypto.randomBytes(i*=7);c=9e15?crypto.randomBytes(7).copy(t,c):(l.push(a%1e14),c+=7);c=i/7}if(!N)for(;c=10;a/=10,c++);c<14&&(n-=14-c)}return p.e=n,p.c=l,p}),L.sum=function(){for(var e=1,t=arguments,r=new L(t[0]);er-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/r|0,a[i]%=r)}return a.reverse()}return function(t,n,i,o,a){var s,u,f,c,l,h,d,p,g=t.indexOf("."),m=M,b=k;for(g>=0&&(c=D,D=0,t=t.replace(".",""),h=(p=new L(n)).pow(t.length-g),D=c,p.c=e(w(y(h.c),h.e,"0"),10,i,"0123456789"),p.e=p.c.length),f=c=(d=e(t,n,i,a?(s=j,"0123456789"):(s="0123456789",j))).length;0==d[--c];d.pop());if(!d[0])return s.charAt(0);if(g<0?--f:(h.c=d,h.e=f,h.s=o,d=(h=r(h,p,m,b,i)).c,l=h.r,f=h.e),g=d[u=f+m+1],c=i/2,l=l||u<0||null!=d[u+1],l=b<4?(null!=g||l)&&(0==b||b==(h.s<0?3:2)):g>c||g==c&&(4==b||l||6==b&&1&d[u-1]||b==(h.s<0?8:7)),u<1||!d[0])t=l?w(s.charAt(1),-m,s.charAt(0)):s.charAt(0);else{if(d.length=u,l)for(--i;++d[--u]>i;)d[u]=0,u||(++f,d=[1].concat(d));for(c=d.length;!d[--c];);for(g=0,t="";g<=c;t+=s.charAt(d[g++]));t=w(t,f,s.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,o,a,s=0,u=e.length,f=t%1e7,c=t/1e7|0;for(e=e.slice();u--;)s=((i=f*(o=e[u]%1e7)+(n=c*o+(a=e[u]/1e7|0)*f)%1e7*1e7+s)/r|0)+(n/1e7|0)+c*a,e[u]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,o,a,s){var f,c,h,d,y,g,m,b,v,w,_,E,S,A,I,O,P,M=n.s==i.s?1:-1,k=n.c,T=i.c;if(!(k&&k[0]&&T&&T[0]))return new L(n.s&&i.s&&(k?!T||k[0]!=T[0]:T)?k&&0==k[0]||!T?0*M:M/0:NaN);for(v=(b=new L(M)).c=[],M=o+(c=n.e-i.e)+1,s||(s=l,c=p(n.e/14)-p(i.e/14),M=M/14|0),h=0;T[h]==(k[h]||0);h++);if(T[h]>(k[h]||0)&&c--,M<0)v.push(1),d=!0;else{for(A=k.length,O=T.length,h=0,M+=2,(y=u(s/(T[0]+1)))>1&&(T=e(T,y,s),k=e(k,y,s),O=T.length,A=k.length),S=O,_=(w=k.slice(0,O)).length;_=s/2&&I++;do{if(y=0,(f=t(T,w,O,_))<0){if(E=w[0],O!=_&&(E=E*s+(w[1]||0)),(y=u(E/I))>1)for(y>=s&&(y=s-1),m=(g=e(T,y,s)).length,_=w.length;1==t(g,w,m,_);)y--,r(g,O=10;M/=10,h++);V(b,o+(b.e=h+14*c-1)+1,a,d)}else b.e=c,b.r=+d;return b}}(),_=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,S=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,I=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(I,"");if(A.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(_,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,o=o.replace(E,"$1").replace(S,"0.$1")),t!=o))return new L(o,i);if(L.DEBUG)throw Error(f+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},O.absoluteValue=O.abs=function(){var e=new L(this);return e.s<0&&(e.s=1),e},O.comparedTo=function(e,t){return g(this,new L(e,t))},O.decimalPlaces=O.dp=function(e,t){var r,n,i,o=this;if(null!=e)return m(e,0,d),null==t?t=k:m(t,0,8),V(new L(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=14*((i=r.length-1)-p(this.e/14)),i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},O.dividedBy=O.div=function(e,t){return r(this,new L(e,t),M,k)},O.dividedToIntegerBy=O.idiv=function(e,t){return r(this,new L(e,t),0,1)},O.exponentiatedBy=O.pow=function(e,t){var r,n,i,o,a,c,l,h,d=this;if((e=new L(e)).c&&!e.isInteger())throw Error(f+"Exponent not an integer: "+K(e));if(null!=t&&(t=new L(t)),a=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return h=new L(Math.pow(+K(d),a?2-b(e):+K(e))),t?h.mod(t):h;if(c=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new L(NaN);(n=!c&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||a&&d.c[1]>=24e7:d.c[0]<8e13||a&&d.c[0]<=9999975e7)))return o=d.s<0&&b(e)?-0:0,d.e>-1&&(o=1/o),new L(c?1/o:o);D&&(o=s(D/14+2))}for(a?(r=new L(.5),c&&(e.s=1),l=b(e)):l=(i=Math.abs(+K(e)))%2,h=new L(P);;){if(l){if(!(h=h.times(d)).c)break;o?h.c.length>o&&(h.c.length=o):n&&(h=h.mod(t))}if(i){if(0===(i=u(i/2)))break;l=i%2}else if(V(e=e.times(r),e.e+1,1),e.e>14)l=b(e);else{if(0===(i=+K(e)))break;l=i%2}d=d.times(d),o?d.c&&d.c.length>o&&(d.c.length=o):n&&(d=d.mod(t))}return n?h:(c&&(h=P.div(h)),t?h.mod(t):o?V(h,D,k,void 0):h)},O.integerValue=function(e){var t=new L(this);return null==e?e=k:m(e,0,8),V(t,t.e+1,e)},O.isEqualTo=O.eq=function(e,t){return 0===g(this,new L(e,t))},O.isFinite=function(){return!!this.c},O.isGreaterThan=O.gt=function(e,t){return g(this,new L(e,t))>0},O.isGreaterThanOrEqualTo=O.gte=function(e,t){return 1===(t=g(this,new L(e,t)))||0===t},O.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},O.isLessThan=O.lt=function(e,t){return g(this,new L(e,t))<0},O.isLessThanOrEqualTo=O.lte=function(e,t){return-1===(t=g(this,new L(e,t)))||0===t},O.isNaN=function(){return!this.s},O.isNegative=function(){return this.s<0},O.isPositive=function(){return this.s>0},O.isZero=function(){return!!this.c&&0==this.c[0]},O.minus=function(e,t){var r,n,i,o,a=this,s=a.s;if(t=(e=new L(e,t)).s,!s||!t)return new L(NaN);if(s!=t)return e.s=-t,a.plus(e);var u=a.e/14,f=e.e/14,c=a.c,h=e.c;if(!u||!f){if(!c||!h)return c?(e.s=-t,e):new L(h?a:NaN);if(!c[0]||!h[0])return h[0]?(e.s=-t,e):new L(c[0]?a:3==k?-0:0)}if(u=p(u),f=p(f),c=c.slice(),s=u-f){for((o=s<0)?(s=-s,i=c):(f=u,i=h),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=c.length)<(t=h.length))?s:t,s=t=0;t0)for(;t--;c[r++]=0);for(t=l-1;n>s;){if(c[--n]=0;){for(r=0,d=w[i]%1e7,y=w[i]/1e7|0,o=i+(a=u);o>i;)r=((f=d*(f=v[--a]%1e7)+(s=y*f+(c=v[a]/1e7|0)*d)%1e7*1e7+g[o]+r)/m|0)+(s/1e7|0)+y*c,g[o--]=f%m;g[o]=r}return r?++n:g.splice(0,1),q(e,g,n)},O.negated=function(){var e=new L(this);return e.s=-e.s||null,e},O.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new L(e,t)).s,!i||!t)return new L(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/14,a=e.e/14,s=n.c,u=e.c;if(!o||!a){if(!s||!u)return new L(i/0);if(!s[0]||!u[0])return u[0]?e:new L(s[0]?n:0*i)}if(o=p(o),a=p(a),s=s.slice(),i=o-a){for(i>0?(a=o,r=u):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(t=u.length)<0&&(r=u,u=s,s=r,t=i),i=0;t;)i=(s[--t]=s[t]+u[t]+i)/l|0,s[t]=l===s[t]?0:s[t]%l;return i&&(s=[i].concat(s),++a),q(e,s,a)},O.precision=O.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return m(e,1,d),null==t?t=k:m(t,0,8),V(new L(o),e,t);if(!(r=o.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},O.shiftedBy=function(e){return m(e,-9007199254740991,9007199254740991),this.times("1e"+e)},O.squareRoot=O.sqrt=function(){var e,t,n,i,o,a=this,s=a.c,u=a.s,f=a.e,c=M+4,l=new L("0.5");if(1!==u||!s||!s[0])return new L(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(u=Math.sqrt(+K(a)))||u==1/0?(((t=y(s)).length+f)%2==0&&(t+="0"),u=Math.sqrt(+t),f=p((f+1)/2)-(f<0||f%2),n=new L(t=u==1/0?"5e"+f:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+f)):n=new L(u+""),n.c[0])for((u=(f=n.e)+c)<3&&(u=0);;)if(o=n,n=l.times(o.plus(r(a,o,c,1))),y(o.c).slice(0,u)===(t=y(n.c)).slice(0,u)){if(n.e0&&y>0){for(o=y%s||s,l=p.substr(0,o);o0&&(l+=c+p.slice(o)),d&&(l="-"+l)}n=h?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?h.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):h):l}return(r.prefix||"")+n+(r.suffix||"")},O.toFraction=function(e){var t,n,i,o,a,s,u,c,l,d,p,g,m=this,b=m.c;if(null!=e&&(!(u=new L(e)).isInteger()&&(u.c||1!==u.s)||u.lt(P)))throw Error(f+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+K(u));if(!b)return new L(m);for(t=new L(P),l=n=new L(P),i=c=new L(P),g=y(b),a=t.e=g.length-m.e-1,t.c[0]=h[(s=a%14)<0?14+s:s],e=!e||u.comparedTo(t)>0?a>0?t:l:u,s=C,C=1/0,u=new L(g),c.c[0]=0;d=r(u,t,0,1),1!=(o=n.plus(d.times(i))).comparedTo(e);)n=i,i=o,l=c.plus(d.times(o=l)),c=o,t=u.minus(d.times(o=t)),u=o;return o=r(e.minus(n),i,0,1),c=c.plus(o.times(l)),n=n.plus(o.times(i)),c.s=l.s=m.s,p=r(l,i,a*=2,k).minus(m).abs().comparedTo(r(c,n,a,k).minus(m).abs())<1?[l,i]:[c,n],C=s,p},O.toNumber=function(){return+K(this)},O.toPrecision=function(e,t){return null!=e&&m(e,1,d),F(this,e,t,2)},O.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=T||o>=x?v(y(r.c),o):w(y(r.c),o,"0"):10===e?t=w(y((r=V(new L(r),M+o+1,k)).c),r.e,"0"):(m(e,2,j.length,"Base"),t=n(w(y(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},O.valueOf=O.toJSON=function(){return K(this)},O._isBigNumber=!0,null!=t&&L.set(t),L}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";var n=r(27),i=r(10);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function u(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){var n=r(19),i=r(107);for(var o in i)n[o]=i[o];e.exports={bufferutils:r(111),Block:r(388),ECPair:r(114),ECSignature:r(73),HDNode:r(406),Transaction:r(113),TransactionBuilder:r(407),address:r(115),coins:r(59),crypto:r(51),networks:r(40),opcodes:r(26),script:n}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=r(127),u=r(126),f=r(8),c=r(81),l=r(104),h=n(r(360)),d=r(48);function p(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return y(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return y(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function y(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0&&(0,d.versionCompare)(e,i)<=0}));return this.messages[r?r.name:"default"]},e.isWhitelisted=function(e){if(!this.config)return null;var t=(0,h.default)(e);if(t&&"string"==typeof t.host){var r=t.host.split(".");return r.length>2&&(t.host=r.slice(r.length-2,r.length).join(".")),this.config.whitelist.find((function(r){return r.origin===e||r.origin===t.host}))}},e.isManagementAllowed=function(){var e=this;if(this.config){var t=(0,h.default)(this.settings.origin);if(t&&"string"==typeof t.host){var r=t.host.split(".");return r.length>2&&(t.host=r.slice(r.length-2,r.length).join(".")),this.config.management.find((function(r){return r.origin===e.settings.origin||r.origin===t.host}))}}},e.getPriority=function(e){return e?e.priority:u.DEFAULT_PRIORITY},e.getHostLabel=function(e){return this.config.knownHosts.find((function(t){return t.origin===e}))},e.getSettings=function(e){return this.settings?"string"==typeof e?this.settings[e]:this.settings:null},e.getDebugSettings=function(e){return!1},e.getConfig=function(){return this.config},e}();t.default=g,(0,a.default)(g,"assets",{}),(0,a.default)(g,"messages",{})},function(e,t,r){"use strict";(function(Buffer){var e=r(0);t.__esModule=!0,t.messageToHex=t.stripHexPrefix=t.hasHexPrefix=t.btckb2satoshib=t.formatTime=t.formatAmountOld=t.formatAmount=void 0;var n=e(r(29));t.formatAmount=function(e,t){return new n.default(e).div(Math.pow(10,t.decimals)).toString(10)+" "+t.shortcut};t.formatAmountOld=function(e,t){var r=e/1e8;return r.toString()+" "+t.shortcut};t.formatTime=function(e){if(!e||e<=0)return"No time estimate";var t=Math.floor(e/60),r=e%60,n="";return 0!==t&&(n+=t+" hour",t>1&&(n+="s"),n+=" "),0!==r&&(n+=r+" minutes"),n};t.btckb2satoshib=function(e){return new n.default(e).times(1e5).toFixed(0,n.default.ROUND_HALF_UP)};var i=function(e){return"0x"===e.slice(0,2).toLowerCase()};t.hasHexPrefix=i;var o=function(e){return i(e)?e.slice(2):e};t.stripHexPrefix=o;t.messageToHex=function(e){var t,r,n;if("string"!=typeof(r=e)||!r.match(/^(0x|0X)?[0-9A-Fa-f]*$/)||n&&r.length!==2+2*n)t=Buffer.from(e);else{var i=o(e);i.length%2!=0&&(i="0"+i),t=Buffer.from(i,"hex")}return t.toString("hex")}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";(function(t,n){var Buffer=r(7).Buffer,i=t.crypto||t.msCrypto;i&&i.getRandomValues?e.exports=function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=Buffer.allocUnsafe(e);if(e>0)if(e>65536)for(var o=0;o>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function s(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";var n=r(62),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=l;var o=Object.create(r(53));o.inherits=r(10);var a=r(141),s=r(91);o.inherits(l,a);for(var u=i(s.prototype),f=0;f=t.length&&r()}))})),function(){t.forEach((function(e){return e.dispose()}))}}))}},{key:"filterError",value:function(e){return e.filter((function(e){return!(e instanceof Error)}))}}]),a(e,[{key:"awaitFirst",value:function(){var e=this;return new Promise((function(t,r){var n=function(){},i=function r(i){e.values.detach(r),e.finish.detach(n),t(i)};n=function(){e.values.detach(i),e.finish.detach(n),r(new Error("No first value."))},e.values.attach(i),e.finish.attach(n)}))}},{key:"awaitFinish",value:function(){var e=this;return new Promise((function(t){e.finish.attach((function(e,r){r(),t()}))}))}},{key:"map",value:function(t){var r=this;return new e((function(e,n){return r.values.attach((function(r){e(t(r))})),r.finish.attach(n),r.dispose}))}},{key:"mapPromise",value:function(t){var r=this;return new e((function(e,n){var i=Promise.resolve(),o=!1;return r.values.attach((function(r){var n=i,a=function(){try{return t(r)}catch(e){return Promise.reject(e)}}();i=a.then((function(t){return n.then((function(){o||e(t)}))}),(function(t){return n.then((function(){o||e(t)}))}))})),r.finish.attach((function(){i.then((function(){o||n()}))})),function(){o=!0,r.dispose()}}))}},{key:"filter",value:function(t){var r=this;return new e((function(e,n){return r.values.attach((function(r){t(r)&&e(r)})),r.finish.attach(n),r.dispose}))}},{key:"reduce",value:function(e,t){var r=this;return new Promise((function(n){var i=t,o=function(t){i=e(i,t)};r.values.attach(o),r.finish.attach((function(e,t){n(i),t(),r.values.detach(o)}))}))}}]),e}();t.Stream=l;var h=function(){function e(){i(this,e)}return a(e,null,[{key:"fromStreamAndPromise",value:function(t,r){r.catch((function(){}));var i=new e;i.stream=t;var o=(0,n.deferred)();return i.dispose=function(e){o.reject(e),o.promise.catch((function(){})),t.dispose()},t.awaitFinish().then((function(){o.resolve()})),i.ending=o.promise.then((function(){return r})),i.ending.catch((function(){})),i}},{key:"fromPromise",value:function(t){var r=new e,n=!1;r.stream=l.fromPromise(t.then((function(e){if(n)throw new Error("disposed");return e.stream})),!0),r.ending=t.then((function(e){return e.ending})),r.ending.catch((function(){}));var i=null;return t.then((function(e){i=e})),r.dispose=function(e){n=!0,null!=i&&i.dispose(e)},r}}]),e}();t.StreamWithEnding=h},function(e,t,r){"use strict";var n={};function i(e,t,r){r||(r=Error);var i=function(e){var r,n;function i(r,n,i){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,i))||this}return n=e,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=e,n[e]=i}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=f;var i=r(133),o=r(137);r(10)(f,i);for(var a=n(o.prototype),s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},function(e,t,r){"use strict";var n={};function i(e,t,r){r||(r=Error);var i=function(e){var r,n;function i(r,n,i){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,i))||this}return n=e,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=e,n[e]=i}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=f;var i=r(161),o=r(165);r(10)(f,i);for(var a=n(o.prototype),s=0;s3)return!1;if(0===e[0])return!1;for(var t=0;tc[l])return 1;if(c[l]>f[l])return-1}return 0}},function(e,t,r){"use strict";t.__esModule=!0,t.getLog=t.enableLogByPrefix=t.enableLog=t.initLog=void 0;var n={DescriptorStream:"color: #77ab59",DeviceList:"color: #36802d",Device:"color: #bada55",Core:"color: #c9df8a",IFrame:"color: #FFFFFF; background: #f4a742;",Popup:"color: #f48a00"},i=function(){function e(e,t){this.prefix=e,this.enabled=t,this.messages=[],this.css=n[e]||"color: #000000; background: #FFFFFF;"}var t=e.prototype;return t.addMessage=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i100&&this.messages.shift()},t.log=function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,r){if(Number.isNaN(e))return new i.default(NaN);var n=f(r.value);return n.isNaN()?t?new i.default(0).plus(e):new i.default(NaN):n.plus(e)}),new i.default(0))}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=e*t,o=r.baseFee||0;if(o&&t&&(r.floorBaseFee?o*=parseInt((o+i)/o,10):o+=i),r.dustOutputFee)for(var a=0;a=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o0&&this.emit(l.DEVICE.ACQUIRED),o=this.commands&&!this.commands.disposed,n||o?n===this.activitySessionID?(w.debug("ACQUIRED BY MYSELF"),this.deferredActions[l.DEVICE.ACQUIRE]&&this.deferredActions[l.DEVICE.ACQUIRE].resolve()):(w.debug("ACQUIRED BY OTHER"),this.interruptionFromOutside()):(r===this.activitySessionID?(w.debug("RELEASED BY MYSELF"),this.deferredActions[l.DEVICE.RELEASE]&&(this.deferredActions[l.DEVICE.RELEASE].resolve(),delete this.deferredActions[l.DEVICE.RELEASE]),this.activitySessionID=null):(w.debug("RELEASED BY OTHER APP"),this.featuresNeedsReload=!0),this.keepSession=!1),this.originalDescriptor=t;case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.disconnect=function(){w.debug("DISCONNECT CLEANUP!"),this.deferredActions[l.DEVICE.RELEASE]&&(this.deferredActions[l.DEVICE.RELEASE].resolve(),delete this.deferredActions[l.DEVICE.RELEASE]),this.interruptionFromUser(l.ERRORS.TypedError("Device_Disconnected")),this.runPromise=null},r.isBootloader=function(){return this.features&&!!this.features.bootloader_mode},r.isInitialized=function(){return this.features&&!!this.features.initialized},r.isSeedless=function(){return this.features&&!!this.features.no_backup},r.isInconsistent=function(){return this.inconsistent},r.getVersion=function(){return this.features?[this.features.major_version,this.features.minor_version,this.features.patch_version]:[]},r.atLeast=function(e){if(!this.features)return!1;var t="string"==typeof e?e:e[this.features.major_version-1];return(0,m.versionCompare)(this.getVersion(),t)>=0},r.isUsed=function(){return"string"==typeof this.originalDescriptor.session},r.isUsedHere=function(){return this.isUsed()&&this.originalDescriptor.session===this.activitySessionID},r.isUsedElsewhere=function(){return this.isUsed()&&!this.isUsedHere()},r.isRunning=function(){return!!this.runPromise},r.isLoaded=function(){return this.loaded},r.waitForFirstRun=function(){return this.firstRunPromise.promise},r.getDevicePath=function(){return this.originalDescriptor.path},r.needAuthentication=function(){if(this.isUnacquired()||this.isUsedElsewhere()||this.featuresNeedsReload)return!0;if(this.features.bootloader_mode||!this.features.initialized)return!0;var e=!this.features.pin_protection||!!this.features.unlocked,t=!this.features.passphrase_protection||this.features.passphrase_cached;return e&&t},r.isT1=function(){return!!this.features&&1===this.features.major_version},r.hasUnexpectedMode=function(e,t){if(this.features){if(this.isBootloader()&&!e.includes(l.UI.BOOTLOADER))return l.UI.BOOTLOADER;if(!this.isInitialized()&&!e.includes(l.UI.INITIALIZE))return l.UI.INITIALIZE;if(this.isSeedless()&&!e.includes(l.UI.SEEDLESS))return l.UI.SEEDLESS;if(!this.isBootloader()&&t.includes(l.UI.BOOTLOADER))return l.UI.NOT_IN_BOOTLOADER}return null},r.onBeforeUnload=function(){if(this.isUsedHere()&&this.activitySessionID)try{this.commands&&this.commands.cancel(),this.transport.release(this.activitySessionID,!0,!1)}catch(e){}},r.getMode=function(){return this.features.bootloader_mode?"bootloader":this.features.initialized?this.features.no_backup?"seedless":"normal":"initialize"},r.toMessageObject=function(){if(this.originalDescriptor.path===l.DEVICE.UNREADABLE)return{type:"unreadable",path:this.originalDescriptor.path,label:"Unreadable device"};if(this.isUnacquired())return{type:"unacquired",path:this.originalDescriptor.path,label:"Unacquired device"};var e=""!==this.features.label&&this.features.label?this.features.label:"My Trezor";return{type:"acquired",id:this.features.device_id||null,path:this.originalDescriptor.path,label:e,state:this.getExternalState(),status:this.isUsedElsewhere()?"occupied":this.featuresNeedsReload?"used":"available",mode:this.getMode(),firmware:this.firmwareStatus,firmwareRelease:this.firmwareRelease,features:this.features,unavailableCapabilities:this.unavailableCapabilities}},r._getNetworkTypeState=function(){return this.networkTypeState[this.instance]},r._setNetworkTypeState=function(e){"string"!=typeof e?delete this.networkTypeState[this.instance]:this.networkTypeState[this.instance]=e},r._altModeChange=function(e){var t=this._isAltModeNetworkType(this._getNetworkTypeState()),r=this._isAltModeNetworkType(e);return this._setNetworkTypeState(e),t!==r},r._isAltModeNetworkType=function(e){return[l.NETWORK.TYPES.cardano].includes(e)},r.legacyForceRelease=function(){var e=(0,o.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUsedHere()){e.next=7;break}return e.next=3,this.acquire();case 3:return e.next=5,this.getFeatures();case 5:return e.next=7,this.release();case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(f.default);t.default=E},function(e,t,r){const n=r(15),i={BCH:"bch",BSV:"bsv",BTC:"btc",BTG:"btg",LTC:"ltc",ZEC:"zec",TAZ:"taz",DASH:"dash",CAPRICOIN:"cpc",PEERCOIN:"ppc",PEERCOINTEST:"tppc",KMD:"kmd",isBitcoin:function(e){return n.value(i.BTC)(e.coin)},isBitcoinCash:function(e){return n.value(i.BCH)(e.coin)},isBitcoinSV:function(e){return n.value(i.BSV)(e.coin)},isBitcoinGold:function(e){return n.value(i.BTG)(e.coin)},isDash:function(e){return n.value(i.DASH)(e.coin)},isLitecoin:function(e){return n.value(i.LTC)(e.coin)},isZcash:function(e){return n.value(i.ZEC)(e.coin)},isTaz:function(e){return n.value(i.TAZ)(e.coin)},isKomodo:function(e){return n.value(i.KMD)(e.coin)},isZcashType:function(e){return this.isZcash(e)||this.isKomodo(e)||this.isTaz(e)},isCapricoin:function(e){return n.value(i.CAPRICOIN)(e.coin)},isPeercoin:function(e){return n.value(i.PEERCOIN)(e.coin)||n.value(i.PEERCOINTEST)(e.coin)},hasTimestamp:function(e){return this.isCapricoin(e)||this.isPeercoin(e)}};i.isValidCoin=n.oneOf(i.isBitcoin,i.isBitcoinCash,i.isBitcoinSV,i.isBitcoinGold,i.isLitecoin,i.isZcash,i.isKomodo,i.isZcashType,i.isCapricoin,i.isPeercoin),e.exports=i},function(e,t,r){"use strict";var n=r(35),i=r(395);e.exports=i((function(e){var t=n("sha256").update(e).digest();return n("sha256").update(t).digest()}))},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getNetworkLabel=t.toChecksumAddress=void 0;var i=n(r(411)),o=r(33);t.toChecksumAddress=function(e,t){if((0,o.hasHexPrefix)(e))return e;var r=(0,o.stripHexPrefix)(e);t&&t.rskip60&&(r=t.chainId+"0x"+e);for(var n=(0,i.default)("keccak256").update(r).digest("hex"),a="0x",s=0;s=8?a+=e[s].toUpperCase():a+=e[s];return a};t.getNetworkLabel=function(e,t){if(t){var r=t.name.toLowerCase().indexOf("testnet")>=0?"Testnet":t.name;return e.replace("#NETWORK",r)}return e.replace("#NETWORK","")}},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,n)}));case 4:return t.nextTick((function(){e.call(null,r,n,i)}));default:for(o=new Array(s-1),a=0;ar)?t=("rmd160"===e?new s:u(e)).update(t).digest():t.length>>24]^c[p>>>16&255]^l[y>>>8&255]^h[255&g]^t[m++],a=f[p>>>24]^c[y>>>16&255]^l[g>>>8&255]^h[255&d]^t[m++],s=f[y>>>24]^c[g>>>16&255]^l[d>>>8&255]^h[255&p]^t[m++],u=f[g>>>24]^c[d>>>16&255]^l[p>>>8&255]^h[255&y]^t[m++],d=o,p=a,y=s,g=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[y>>>8&255]<<8|n[255&g])^t[m++],a=(n[p>>>24]<<24|n[y>>>16&255]<<16|n[g>>>8&255]<<8|n[255&d])^t[m++],s=(n[y>>>24]<<24|n[g>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[g>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&y])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var f=s^s<<1^s<<2^s<<3^s<<4;f=f>>>8^255&f^99,r[a]=f,n[f]=a;var c=e[a],l=e[c],h=e[l],d=257*e[f]^16843008*f;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*h^65537*l^257*c^16843008*a,o[0][f]=d<<24|d>>>8,o[1][f]=d<<16|d>>>16,o[2][f]=d<<8|d>>>24,o[3][f]=d,0===a?a=s=1:(a=c^e[e[e[h^c]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(e){this._key=n(e),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,u=s.SBOX[u>>>24]<<24|s.SBOX[u>>>16&255]<<16|s.SBOX[u>>>8&255]<<8|s.SBOX[255&u],u^=a[o/t|0]<<24):t>6&&o%t==4&&(u=s.SBOX[u>>>24]<<24|s.SBOX[u>>>16&255]<<16|s.SBOX[u>>>8&255]<<8|s.SBOX[255&u]),i[o]=i[o-t]^u}for(var f=[],c=0;c>>24]]^s.INV_SUB_MIX[1][s.SBOX[h>>>16&255]]^s.INV_SUB_MIX[2][s.SBOX[h>>>8&255]]^s.INV_SUB_MIX[3][s.SBOX[255&h]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=f},u.prototype.encryptBlockRaw=function(e){return o(e=n(e),this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},u.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},u.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=o(e,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},function(e,t,r){var Buffer=r(7).Buffer,n=r(83);e.exports=function(e,t,r,i){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),t&&(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,a=Buffer.alloc(o),s=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var f=new n;f.update(u),f.update(e),t&&f.update(t),u=f.digest();var c=0;if(o>0){var l=a.length-o;c=Math.min(o,u.length),u.copy(a,l,0,c),o-=c}if(c0){var h=s.length-i,d=Math.min(i,u.length-c);u.copy(s,h,c,c+d),i-=d}}return u.fill(0),{key:a,iv:s}}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";var n=t;n.version=r(305).version,n.utils=r(28),n.rand=r(95),n.curve=r(168),n.curves=r(98),n.ec=r(316),n.eddsa=r(320)},function(e,t,r){"use strict";var n=r(18),i=r(28),o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function f(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1,this._bitLength),i=(1<=u;t--)f=(f<<1)+n[t];a.push(f)}for(var c=this.jpoint(null,null,null),l=this.jpoint(null,null,null),h=i;h>0;h--){for(u=0;u=0;f--){for(t=0;f>=0&&0===a[f];f--)t++;if(f>=0&&t++,u=u.dblp(t),f<0)break;var c=a[f];s(0!==c),u="affine"===e.type?c>0?u.mixedAdd(i[c-1>>1]):u.mixedAdd(i[-c-1>>1].neg()):c>0?u.add(i[c-1>>1]):u.add(i[-c-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,f=this._wnafT3,c=0,l=0;l=1;l-=2){var d=l-1,p=l;if(1===s[d]&&1===s[p]){var y=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(y[1]=t[d].add(t[p]),y[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(y[1]=t[d].toJ().mixedAdd(t[p]),y[2]=t[d].add(t[p].neg())):(y[1]=t[d].toJ().mixedAdd(t[p]),y[2]=t[d].toJ().mixedAdd(t[p].neg()));var g=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);c=Math.max(m[0].length,c),f[d]=new Array(c),f[p]=new Array(c);for(var b=0;b=0;l--){for(var S=0;l>=0;){var A=!0;for(b=0;b=0&&S++,_=_.dblp(S),l<0)break;for(b=0;b0?I=u[b][O-1>>1]:O<0&&(I=u[b][-O-1>>1].neg()),_="affine"===I.type?_.mixedAdd(I):_.add(I))}}for(l=0;l=Math.ceil((e.bitLength()+1)/t.step)},f.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i";case"brand":return n(e,t)(r.entity)}}finally{t.delete(r)}throw Error("impossible")}};function i(e){return e.isReadonly?"readonly ":""}t.default=n(!1,new Set)},function(e,t,r){"use strict";var Buffer=r(7).Buffer;function n(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function i(e){return n(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,o){if(n(t),r||(r=Buffer.allocUnsafe(i(t))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return o||(o=0),t<253?(r.writeUInt8(t,o),e.bytes=1):t<=65535?(r.writeUInt8(253,o),r.writeUInt16LE(t,o+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,o),r.writeUInt32LE(t,o+1),e.bytes=5):(r.writeUInt8(255,o),r.writeUInt32LE(t>>>0,o+1),r.writeUInt32LE(t/4294967296|0,o+5),e.bytes=9),r},decode:function e(t,r){if(!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=t.readUInt8(r);if(i<253)return e.bytes=1,i;if(253===i)return e.bytes=3,t.readUInt16LE(r+1);if(254===i)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var o=t.readUInt32LE(r+1),a=4294967296*t.readUInt32LE(r+5)+o;return n(a),a},encodingLength:i}},function(e,t,r){(function(Buffer){var t=r(105),n=r(15),i=r(22),BigInteger=r(37);function o(e,t){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=e,this.s=t}o.parseCompact=function(e){n(i.BufferN(65),e);var t=e.readUInt8(0)-27;if(t!==(7&t))throw new Error("Invalid signature parameter");return{compressed:!!(4&t),i:3&t,signature:o.fromRSBuffer(e.slice(1))}},o.fromRSBuffer=function(e){return n(i.BufferN(64),e),new o(BigInteger.fromBuffer(e.slice(0,32)),BigInteger.fromBuffer(e.slice(32,64)))},o.fromDER=function(e){var r=t.decode(e);return new o(BigInteger.fromDERInteger(r.r),BigInteger.fromDERInteger(r.s))},o.parseScriptSignature=function(e){var t=e.readUInt8(e.length-1),r=-193&t;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);return{signature:o.fromDER(e.slice(0,-1)),hashType:t}},o.prototype.toCompact=function(e,t){t&&(e+=4),e+=27;var r=Buffer.alloc(65);return r.writeUInt8(e,0),this.toRSBuffer(r,1),r},o.prototype.toDER=function(){var e=Buffer.from(this.r.toDERInteger()),r=Buffer.from(this.s.toDERInteger());return t.encode(e,r)},o.prototype.toRSBuffer=function(e,t){return e=e||Buffer.alloc(64),this.r.toBuffer(32).copy(e,t),this.s.toBuffer(32).copy(e,t+32),e},o.prototype.toScriptSignature=function(e){var t=-193&e;if(t<=0||t>=4)throw new Error("Invalid hashType "+e);var r=Buffer.alloc(1);return r.writeUInt8(e,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this,r(9).Buffer)},function(e,t,r){var Point=r(196),n=r(197),i=r(398);e.exports={Curve:n,Point,getCurveByName:i}},function(e,t,r){"use strict";var n=r(431);e.exports=Function.prototype.bind||n},function(e,t,r){"use strict";function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r1e3?"".concat(e.substring(0,1e3),"..."):e}))),[")"]));var s=i.apply(this,arguments);return s.then((function(e){return r&&(null==e?console.log("[trezor-link] Done ".concat(o,".").concat(t)):console.log("[trezor-link] Done ".concat(o,".").concat(t,", result "),e)),e}),(function(e){throw r&&console.error("[trezor-link] Error in ".concat(o,".").concat(t),e),e}))},r}},function(e,t,r){ +var n=r(245),i=r(246),o=r(130);function a(){return Buffer.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function s(e,t){if(a()=a())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a().toString(16)+" bytes");return 0|e}function d(e,t){if(Buffer.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return L(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return F(e).length;default:if(n)return L(e).length;t=(""+t).toLowerCase(),n=!0}}function p(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return M(this,t,r);case"utf8":case"utf-8":return I(this,t,r);case"ascii":return O(this,t,r);case"latin1":case"binary":return P(this,t,r);case"base64":return A(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function g(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function y(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=Buffer.from(t,n)),Buffer.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,Buffer.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var o,a=1,s=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;a=2,s/=2,u/=2,r/=2}function f(e,t){return 1===a?e[t]:e.readUInt16BE(t*a)}if(i){var c=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var l=!0,h=0;hi&&(n=i):n=i;var o=t.length;if(o%2!=0)throw new TypeError("Invalid hex string");n>o/2&&(n=o/2);for(var a=0;a>8,i=r%256,o.push(i),o.push(n);return o}(t,e.length-r),e,r,n)}function A(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function I(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i239?4:f>223?3:f>191?2:1;if(i+l<=r)switch(l){case 1:f<128&&(c=f);break;case 2:128==(192&(o=e[i+1]))&&(u=(31&f)<<6|63&o)>127&&(c=u);break;case 3:o=e[i+1],a=e[i+2],128==(192&o)&&128==(192&a)&&(u=(15&f)<<12|(63&o)<<6|63&a)>2047&&(u<55296||u>57343)&&(c=u);break;case 4:o=e[i+1],a=e[i+2],s=e[i+3],128==(192&o)&&128==(192&a)&&128==(192&s)&&(u=(15&f)<<18|(63&o)<<12|(63&a)<<6|63&s)>65535&&u<1114112&&(c=u)}null===c?(c=65533,l=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=l}return function(e){var t=e.length;if(t<=4096)return String.fromCharCode.apply(String,e);var r="",n=0;for(;n0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),""},Buffer.prototype.compare=function(e,t,r,n,i){if(!Buffer.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(t>>>=0),s=Math.min(o,a),u=this.slice(n,i),f=e.slice(t,r),c=0;ci)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return b(this,e,t,r);case"utf8":case"utf-8":return v(this,e,t,r);case"ascii":return w(this,e,t,r);case"latin1":case"binary":return _(this,e,t,r);case"base64":return E(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},Buffer.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function O(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;in)&&(r=n);for(var i="",o=t;or)throw new RangeError("Trying to access beyond buffer length")}function x(e,t,r,n,i,o){if(!Buffer.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function R(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,o=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function C(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,o=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function N(e,t,r,n,i,o){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function B(e,t,r,n,o){return o||N(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function D(e,t,r,n,o){return o||N(e,0,r,8),i.write(e,t,r,n,52,8),r+8}Buffer.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t0&&(i*=256);)n+=this[e+--t]*i;return n},Buffer.prototype.readUInt8=function(e,t){return t||T(e,1,this.length),this[e]},Buffer.prototype.readUInt16LE=function(e,t){return t||T(e,2,this.length),this[e]|this[e+1]<<8},Buffer.prototype.readUInt16BE=function(e,t){return t||T(e,2,this.length),this[e]<<8|this[e+1]},Buffer.prototype.readUInt32LE=function(e,t){return t||T(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer.prototype.readUInt32BE=function(e,t){return t||T(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=this[e],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||T(e,t,this.length);for(var n=t,i=1,o=this[e+--n];n>0&&(i*=256);)o+=this[e+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*t)),o},Buffer.prototype.readInt8=function(e,t){return t||T(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer.prototype.readInt16LE=function(e,t){t||T(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt16BE=function(e,t){t||T(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer.prototype.readInt32LE=function(e,t){return t||T(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer.prototype.readInt32BE=function(e,t){return t||T(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer.prototype.readFloatLE=function(e,t){return t||T(e,4,this.length),i.read(this,e,!0,23,4)},Buffer.prototype.readFloatBE=function(e,t){return t||T(e,4,this.length),i.read(this,e,!1,23,4)},Buffer.prototype.readDoubleLE=function(e,t){return t||T(e,8,this.length),i.read(this,e,!0,52,8)},Buffer.prototype.readDoubleBE=function(e,t){return t||T(e,8,this.length),i.read(this,e,!1,52,8)},Buffer.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||x(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[t]=255&e;++o=0&&(o*=256);)this[t+i]=e/o&255;return t+r},Buffer.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,1,255,0),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Buffer.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},Buffer.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,65535,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},Buffer.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):C(this,e,t,!0),t+4},Buffer.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,4294967295,0),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},Buffer.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var o=0,a=1,s=0;for(this[t]=255&e;++o>0)-s&255;return t+r},Buffer.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);x(this,e,t,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[t+o]=255&e;--o>=0&&(a*=256);)e<0&&0===s&&0!==this[t+o+1]&&(s=1),this[t+o]=(e/a>>0)-s&255;return t+r},Buffer.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,1,127,-128),Buffer.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):R(this,e,t,!0),t+2},Buffer.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,2,32767,-32768),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):R(this,e,t,!1),t+2},Buffer.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,2147483647,-2147483648),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):C(this,e,t,!0),t+4},Buffer.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||x(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Buffer.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):C(this,e,t,!1),t+4},Buffer.prototype.writeFloatLE=function(e,t,r){return B(this,e,t,!0,r)},Buffer.prototype.writeFloatBE=function(e,t,r){return B(this,e,t,!1,r)},Buffer.prototype.writeDoubleLE=function(e,t,r){return D(this,e,t,!0,r)},Buffer.prototype.writeDoubleBE=function(e,t,r){return D(this,e,t,!1,r)},Buffer.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t=0;--i)e[i+t]=this[i+r];else if(o<1e3||!Buffer.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(o=t;o55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(t-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;o.push(r)}else if(r<2048){if((t-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function F(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(U,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function H(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}}).call(this,r(24))},function(e,t){"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}}},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}},function(e,t,r){"use strict";t.__esModule=!0,t.getLabel=t.fixPath=t.getIndexFromPath=t.getPathFromIndex=t.getSerializedPath=t.validatePath=t.getOutputScriptType=t.getScriptType=t.isBech32Path=t.isSegwitPath=t.isMultisigPath=t.getHDPath=t.fromHardened=t.toHardened=t.HD_HARDENED=void 0;var n=r(6);t.HD_HARDENED=2147483648;var i=function(e){return(2147483648|e)>>>0};t.toHardened=i;var o=function(e){return(2147483647&e)>>>0};t.fromHardened=o;var a=n.ERRORS.TypedError("Method_InvalidParameter","Not a valid path"),s=n.ERRORS.TypedError("Method_InvalidParameter","Path cannot contain negative values"),u=function(e){var t=e.toLowerCase().split("/");if("m"!==t[0])throw a;return t.filter((function(e){return"m"!==e&&""!==e})).map((function(e){var t=!1;"'"===e.substr(e.length-1)&&(t=!0,e=e.substr(0,e.length-1));var r=parseInt(e);if(isNaN(r))throw a;if(r<0)throw s;return t&&(r=i(r)),r}))};t.getHDPath=u;t.isMultisigPath=function(e){return Array.isArray(e)&&e[0]===i(48)};t.isSegwitPath=function(e){return Array.isArray(e)&&e[0]===i(49)};t.isBech32Path=function(e){return Array.isArray(e)&&e[0]===i(84)};t.getScriptType=function(e){if(!Array.isArray(e)||e.length<1)return"SPENDADDRESS";switch(o(e[0])){case 48:return"SPENDMULTISIG";case 49:return"SPENDP2SHWITNESS";case 84:return"SPENDWITNESS";default:return"SPENDADDRESS"}};t.getOutputScriptType=function(e){if(!Array.isArray(e)||e.length<1)return"PAYTOADDRESS";if(49===e[0])return"PAYTOP2SHWITNESS";switch(o(e[0])){case 48:return"PAYTOMULTISIG";case 49:return"PAYTOP2SHWITNESS";case 84:return"PAYTOWITNESS";default:return"PAYTOADDRESS"}};t.validatePath=function(e,t,r){var n;if(void 0===t&&(t=0),void 0===r&&(r=!1),"string"==typeof e?n=u(e):Array.isArray(e)&&(n=e.map((function(e){var t=parseInt(e);if(isNaN(t))throw a;if(t<0)throw s;return t}))),!n)throw a;if(t>0&&n.length>>0}))),e};t.getLabel=function(e,t){return t?e.replace("#NETWORK",t.label):e.replace("#NETWORK","")}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.BlockchainMessage=t.ResponseMessage=t.TransportMessage=t.DeviceMessage=t.UiMessage=void 0;var i=n(r(11)),o=r(6);function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;tt.maxLength)&&((void 0===t.length||r.length===t.length)&&r.every((function(t,r){try{return h(e,t,n)}catch(e){throw u(e,r)}}))))))}return e=l(e),t=t||{},r.toJSON=function(){var r="["+o(e)+"]";return void 0!==t.length?r+="{"+t.length+"}":void 0===t.minLength&&void 0===t.maxLength||(r+="{"+(void 0===t.minLength?0:t.minLength)+","+(void 0===t.maxLength?1/0:t.maxLength)+"}"),r},r},maybe:function e(t){function r(r,n){return i.Nil(r)||t(r,n,e)}return t=l(t),r.toJSON=function(){return"?"+o(t)},r},map:function(e,t){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{t&&h(t,o,n)}catch(e){throw u(e,o,"key")}try{var a=r[o];h(e,a,n)}catch(e){throw u(e,o)}}return!0}return e=l(e),t&&(t=l(t)),r.toJSON=t?function(){return"{"+o(t)+": "+o(e)+"}"}:function(){return"{"+o(e)+"}"},r},object:function(e){var t={};for(var r in e)t[r]=l(e[r]);function n(e,r){if(!i.Object(e))return!1;if(i.Nil(e))return!1;var n;try{for(n in t){h(t[n],e[n],r)}}catch(e){throw u(e,n)}if(r)for(n in e)if(!t[n])throw new s(void 0,n);return!0}return n.toJSON=function(){return o(t)},n},anyOf:function(){var e=[].slice.call(arguments).map(l);function t(t,r){return e.some((function(e){try{return h(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(o).join("|")},t},allOf:function(){var e=[].slice.call(arguments).map(l);function t(t,r){return e.every((function(e){try{return h(e,t,r)}catch(e){return!1}}))}return t.toJSON=function(){return e.map(o).join(" & ")},t},quacksLike:function(e){function t(t){return e===f(t)}return t.toJSON=function(){return e},t},tuple:function(){var e=[].slice.call(arguments).map(l);function t(t,r){return!i.Nil(t)&&(!i.Nil(t.length)&&((!r||t.length===e.length)&&e.every((function(e,n){try{return h(e,t[n],r)}catch(e){throw u(e,n)}}))))}return t.toJSON=function(){return"("+e.map(o).join(", ")+")"},t},value:function(e){function t(t){return t===e}return t.toJSON=function(){return e},t}};function l(e){if(i.String(e))return"?"===e[0]?c.maybe(e.slice(1)):i[e]||c.quacksLike(e);if(e&&i.Object(e)){if(i.Array(e)){if(1!==e.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return c.arrayOf(e[0])}return c.object(e)}return i.Function(e)?e:c.value(e)}function h(e,t,r,n){if(i.Function(e)){if(e(t,r))return!0;throw new a(n||e,t)}return h(l(e),t,r)}for(var d in c.oneOf=c.anyOf,i)h[d]=i[d];for(d in c)h[d]=c[d];var p=r(364);for(d in p)h[d]=p[d];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,e.exports=h},function(e,t){var r,n,i=e.exports={};function o(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}function s(e){if(r===setTimeout)return setTimeout(e,0);if((r===o||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:o}catch(e){r=o}try{n="function"==typeof clearTimeout?clearTimeout:a}catch(e){n=a}}();var u,f=[],c=!1,l=-1;function h(){c&&u&&(c=!1,u.length?f=u.concat(f):l=-1,f.length&&d())}function d(){if(!c){var e=s(h);c=!0;for(var t=f.length;t;){for(u=f,f=[];++l1)for(var r=1;r=49&&a<=54?a-49+10:a>=17&&a<=22?a-17+10:15&a}return n}function s(e,t,r,n){for(var i=0,o=Math.min(e.length,r),a=t;a=49?s-49+10:s>=17?s-17+10:s}return i}o.isBN=function(e){return e instanceof o||null!==e&&"object"==typeof e&&e.constructor.wordSize===o.wordSize&&Array.isArray(e.words)},o.max=function(e,t){return e.cmp(t)>0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this.strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this.strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this.strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,u=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},o.prototype.inspect=function(){return(this.red?""};var u=["","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],c=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function l(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r.strip()}o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?u[6-l.length]+l+r:l+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var h=f[e],d=c[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modn(d).toString(e);r=(p=p.idivn(d)).isZero()?g+r:u[h-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16)},o.prototype.toBuffer=function(e,t){return n(void 0!==Buffer),this.toArrayLike(Buffer,e,t)},o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},o.prototype.toArrayLike=function(e,t,r){var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0"),this.strip();var a,s,u="le"===t,f=new e(o),c=this.clone();if(u){for(s=0;!c.isZero();s++)a=c.andln(255),c.iushrn(8),f[s]=a;for(;s=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this.strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,g=d>>>13,y=0|a[2],m=8191&y,b=y>>>13,v=0|a[3],w=8191&v,_=v>>>13,E=0|a[4],S=8191&E,A=E>>>13,I=0|a[5],O=8191&I,P=I>>>13,M=0|a[6],k=8191&M,T=M>>>13,x=0|a[7],R=8191&x,C=x>>>13,N=0|a[8],B=8191&N,D=N>>>13,U=0|a[9],j=8191&U,L=U>>>13,F=0|s[0],H=8191&F,q=F>>>13,V=0|s[1],K=8191&V,z=V>>>13,G=0|s[2],Q=8191&G,W=G>>>13,Y=0|s[3],Z=8191&Y,J=Y>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(f+(n=Math.imul(l,H))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,H)|0))<<13)|0;f=((o=Math.imul(h,q))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(g,H)|0,o=Math.imul(g,q);var me=(f+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,z)|0)+Math.imul(h,K)|0))<<13)|0;f=((o=o+Math.imul(h,z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(b,H)|0,o=Math.imul(b,q),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,z)|0)+Math.imul(g,K)|0,o=o+Math.imul(g,z)|0;var be=(f+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,Q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,z)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,W)|0;var ve=(f+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(A,H)|0,o=Math.imul(A,q),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,z)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0;var we=(f+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,H),i=(i=Math.imul(O,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,z)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,q))+Math.imul(T,H)|0,o=Math.imul(T,q),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,z)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0;var Se=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,q))+Math.imul(D,H)|0,o=Math.imul(D,q),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,z)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,z)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,H),i=(i=Math.imul(j,q))+Math.imul(L,H)|0,o=Math.imul(L,q),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,z)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,z)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(g,le)|0,o=o+Math.imul(g,he)|0;var Ie=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ge)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,z))+Math.imul(L,K)|0,o=Math.imul(L,z),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Oe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;f=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,W))+Math.imul(L,Q)|0,o=Math.imul(L,W),n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(T,re)|0,o=o+Math.imul(T,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var Pe=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ge)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,ge)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,J))+Math.imul(L,Z)|0,o=Math.imul(L,J),n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,fe)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var Me=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,ee))+Math.imul(L,$)|0,o=Math.imul(L,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var ke=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ge)|0)+Math.imul(P,pe)|0))<<13)|0;f=((o=o+Math.imul(P,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ge)|0)+Math.imul(T,pe)|0))<<13)|0;f=((o=o+Math.imul(T,ge)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ge)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(L,le)|0,o=Math.imul(L,he);var Ce=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ge)|0)+Math.imul(D,pe)|0))<<13)|0;f=((o=o+Math.imul(D,ge)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ne=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ge))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ge))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ye,u[1]=me,u[2]=be,u[3]=ve,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Se,u[8]=Ae,u[9]=Ie,u[10]=Oe,u[11]=Pe,u[12]=Me,u[13]=ke,u[14]=Te,u[15]=xe,u[16]=Re,u[17]=Ce,u[18]=Ne,0!==f&&(u[19]=f,r.length++),r};function d(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(h=l),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?h(this,e,t):r<63?l(this,e,t):r<1024?function(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r.strip()}(this,e,t):d(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,t+=i/67108864|0,t+=o>>>26,this.words[r]=67108863&o}return 0!==t&&(this.words[r]=t,this.length++),this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this.strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this.strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modn=function(e){n(e<=67108863);for(var t=(1<<26)%e,r=0,i=this.length-1;i>=0;i--)r=(t*r+(0|this.words[i]))%e;return r},o.prototype.idivn=function(e){n(e<=67108863);for(var t=0,r=this.length-1;r>=0;r--){var i=(0|this.words[r])+67108864*t;this.words[r]=i/e|0,t=i%e}return this.strip()},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this.strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new _(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var g={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function m(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function b(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function w(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function E(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}y.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},i(m,y),m.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},m.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(g[e])return g[e];var t;if("k256"===e)t=new m;else if("p224"===e)t=new b;else if("p192"===e)t=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new w}return g[e]=t,t},_.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},_.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var g=d,y=0;0!==g.cmp(s);y++)g=g.redSqr();n(y=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new E(e)},i(E,_),E.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},E.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},E.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},E.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},E.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(65)(e))},function(e,t,r){var Buffer=r(7).Buffer,n=r(104),i=r(186),o=r(15),a=r(22),s=r(188),u=r(26),f=r(365),c=u.OP_RESERVED;function l(e){return a.Buffer(e)||function(e){return a.Number(e)&&(e===u.OP_0||e>=u.OP_1&&e<=u.OP_16||e===u.OP_1NEGATE)}(e)}function h(e){return a.Array(e)&&e.every(l)}function d(e){return 0===e.length?u.OP_0:1===e.length?e[0]>=1&&e[0]<=16?c+e[0]:129===e[0]?u.OP_1NEGATE:void 0:void 0}function p(e){if(Buffer.isBuffer(e))return e;o(a.Array,e);var t=e.reduce((function(e,t){return Buffer.isBuffer(t)?1===t.length&&void 0!==d(t)?e+1:e+i.encodingLength(t.length)+t.length:e+1}),0),r=Buffer.allocUnsafe(t),n=0;if(e.forEach((function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0!==t)return r.writeUInt8(t,n),void(n+=1);n+=i.encode(r,e.length,n),e.copy(r,n),n+=e.length}else r.writeUInt8(e,n),n+=1})),n!==r.length)throw new Error("Could not decode chunks");return r}function g(e){if(a.Array(e))return e;o(a.Buffer,e);for(var t=[],r=0;ru.OP_0&&n<=u.OP_PUSHDATA4){var s=i.decode(e,r);if(null===s)return[];if((r+=s.size)+s.number>e.length)return[];var f=e.slice(r,r+s.number);r+=s.number;var c=d(f);void 0!==c?t.push(c):t.push(f)}else t.push(n),r+=1}return t}function y(e){var t=-193&e;return t>0&&t<4}e.exports={compile:p,decompile:g,fromASM:function(e){return o(a.String,e),p(e.split(" ").map((function(e){return void 0!==u[e]?u[e]:(o(a.Hex,e),Buffer.from(e,"hex"))})))},toASM:function(e){return Buffer.isBuffer(e)&&(e=g(e)),e.map((function(e){if(Buffer.isBuffer(e)){var t=d(e);if(void 0===t)return e.toString("hex");e=t}return f[e]})).join(" ")},toStack:function(e){return e=g(e),o(h,e),e.map((function(e){return Buffer.isBuffer(e)?e:e===u.OP_0?Buffer.allocUnsafe(0):s.encode(e-c)}))},number:r(188),isCanonicalPubKey:function(e){if(!Buffer.isBuffer(e))return!1;if(e.length<33)return!1;switch(e[0]){case 2:case 3:return 33===e.length;case 4:return 65===e.length}return!1},isCanonicalSignature:function(e){return!!Buffer.isBuffer(e)&&(!!y(e[e.length-1])&&n.check(e.slice(0,-1)))},isPushOnly:h,isDefinedHashType:y}},function(e,t,r){"use strict";t.__esModule=!0,t.IFRAME_FAILURE=t.ADDRESS_VALIDATION=t.BUNDLE_PROGRESS=t.LOGIN_CHALLENGE_RESPONSE=t.LOGIN_CHALLENGE_REQUEST=t.CUSTOM_MESSAGE_RESPONSE=t.CUSTOM_MESSAGE_REQUEST=t.CHANGE_SETTINGS=t.RECEIVE_WORD=t.RECEIVE_FEE=t.RECEIVE_ACCOUNT=t.CHANGE_ACCOUNT=t.RECEIVE_DEVICE=t.RECEIVE_PASSPHRASE=t.RECEIVE_PIN=t.RECEIVE_CONFIRMATION=t.RECEIVE_PERMISSION=t.REQUEST_WORD=t.REQUEST_BUTTON=t.INSUFFICIENT_FUNDS=t.UPDATE_CUSTOM_FEE=t.SELECT_FEE=t.SELECT_ACCOUNT=t.SELECT_DEVICE=t.SET_OPERATION=t.LOADING=t.CONNECT=t.INVALID_PASSPHRASE_ACTION=t.INVALID_PASSPHRASE=t.REQUEST_PASSPHRASE_ON_DEVICE=t.REQUEST_PASSPHRASE=t.INVALID_PIN=t.REQUEST_PIN=t.REQUEST_CONFIRMATION=t.REQUEST_PERMISSION=t.CLOSE_UI_WINDOW=t.REQUEST_UI_WINDOW=t.DEVICE_NEEDS_BACKUP=t.FIRMWARE_PROGRESS=t.FIRMWARE_NOT_INSTALLED=t.FIRMWARE_NOT_COMPATIBLE=t.FIRMWARE_NOT_SUPPORTED=t.FIRMWARE_OUTDATED=t.FIRMWARE_OLD=t.SEEDLESS=t.INITIALIZE=t.REQUIRE_MODE=t.NOT_IN_BOOTLOADER=t.BOOTLOADER=t.TRANSPORT=void 0;t.TRANSPORT="ui-no_transport";t.BOOTLOADER="ui-device_bootloader_mode";t.NOT_IN_BOOTLOADER="ui-device_not_in_bootloader_mode";t.REQUIRE_MODE="ui-device_require_mode";t.INITIALIZE="ui-device_not_initialized";t.SEEDLESS="ui-device_seedless";t.FIRMWARE_OLD="ui-device_firmware_old";t.FIRMWARE_OUTDATED="ui-device_firmware_outdated";t.FIRMWARE_NOT_SUPPORTED="ui-device_firmware_unsupported";t.FIRMWARE_NOT_COMPATIBLE="ui-device_firmware_not_compatible";t.FIRMWARE_NOT_INSTALLED="ui-device_firmware_not_installed";t.FIRMWARE_PROGRESS="ui-firmware-progress";t.DEVICE_NEEDS_BACKUP="ui-device_needs_backup";t.REQUEST_UI_WINDOW="ui-request_window";t.CLOSE_UI_WINDOW="ui-close_window";t.REQUEST_PERMISSION="ui-request_permission";t.REQUEST_CONFIRMATION="ui-request_confirmation";t.REQUEST_PIN="ui-request_pin";t.INVALID_PIN="ui-invalid_pin";t.REQUEST_PASSPHRASE="ui-request_passphrase";t.REQUEST_PASSPHRASE_ON_DEVICE="ui-request_passphrase_on_device";t.INVALID_PASSPHRASE="ui-invalid_passphrase";t.INVALID_PASSPHRASE_ACTION="ui-invalid_passphrase_action";t.CONNECT="ui-connect";t.LOADING="ui-loading";t.SET_OPERATION="ui-set_operation";t.SELECT_DEVICE="ui-select_device";t.SELECT_ACCOUNT="ui-select_account";t.SELECT_FEE="ui-select_fee";t.UPDATE_CUSTOM_FEE="ui-update_custom_fee";t.INSUFFICIENT_FUNDS="ui-insufficient_funds";t.REQUEST_BUTTON="ui-button";t.REQUEST_WORD="ui-request_word";t.RECEIVE_PERMISSION="ui-receive_permission";t.RECEIVE_CONFIRMATION="ui-receive_confirmation";t.RECEIVE_PIN="ui-receive_pin";t.RECEIVE_PASSPHRASE="ui-receive_passphrase";t.RECEIVE_DEVICE="ui-receive_device";t.CHANGE_ACCOUNT="ui-change_account";t.RECEIVE_ACCOUNT="ui-receive_account";t.RECEIVE_FEE="ui-receive_fee";t.RECEIVE_WORD="ui-receive_word";t.CHANGE_SETTINGS="ui-change_settings";t.CUSTOM_MESSAGE_REQUEST="ui-custom_request";t.CUSTOM_MESSAGE_RESPONSE="ui-custom_response";t.LOGIN_CHALLENGE_REQUEST="ui-login_challenge_request";t.LOGIN_CHALLENGE_RESPONSE="ui-login_challenge_response";t.BUNDLE_PROGRESS="ui-bundle_progress";t.ADDRESS_VALIDATION="ui-address_validation";t.IFRAME_FAILURE="ui-iframe_failure"},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(181),i=r(70),o=r(57);t.create=function(e,t){return t.check=r,t.assert=r,t._innerValidate=function(r,n){return n.has(r,t)?{success:!0,value:r}:e(r,n)},t.validate=function(e){return t._innerValidate(e,(r=new WeakMap,{has:function(e,t){var n=r.get(e),i=n&&n.get(t)||!1;return function(e,t){if(null!==e&&"object"==typeof e){var n=r.get(e);r.set(e,n?n.set(t,!0):(new WeakMap).set(t,!0))}}(e,t),i}}));var r},t.guard=function(e){return t.validate(e).success},t.Or=function(e){return n.Union(t,e)},t.And=function(e){return n.Intersect(t,e)},t.withConstraint=function(e,r){return n.Constraint(t,e,r)},t.withGuard=function(e,r){return n.Constraint(t,e,r)},t.withBrand=function(e){return n.Brand(e,t)},t.reflect=t,t.toString=function(){return"Runtype<"+i.default(t)+">"},t;function r(e){var r=t.validate(e);if(r.success)return r.value;throw new o.ValidationError(r.message,r.key)}},t.innerValidate=function(e,t,r){return e._innerValidate(t,r)}},function(e,t,r){var n=r(15),i=Math.pow(2,31)-1;function o(e){return n.String(e)&&e.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}o.toJSON=function(){return"BIP32 derivation path"};var a=n.quacksLike("BigInteger"),s=n.quacksLike("Point"),u=n.compile({r:a,s:a}),f=n.oneOf(n.UInt8,n.UInt16),c=n.compile({messagePrefix:n.oneOf(n.Buffer,n.String),bip32:{public:n.UInt32,private:n.UInt32},pubKeyHash:f,scriptHash:f,wif:n.UInt8}),l={BigInt:a,BIP32Path:o,Buffer256bit:n.BufferN(32),ECPoint:s,ECSignature:u,Hash160bit:n.BufferN(20),Hash256bit:n.BufferN(32),Network:c,Satoshi:function(e){return n.UInt53(e)&&e<=21e14},UInt31:function(e){return n.UInt32(e)&&e<=i},NetworkVersion:f};for(var h in n)l[h]=n[h];e.exports=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.initBlockchain=t.isBackendSupported=t.setCustomBackend=t.findBackend=t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=n(r(455)),u=r(13),f=r(6),c=r(213);function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e){for(var t=1;t12e5,a=r.filter((function(e){return"string"!=typeof u.feeForBlock})),!o&&a.length,e.next=8,this.link.estimateFee(t);case 8:s=e.sent,r.forEach((function(e,t){u.feeForBlock[e]=s[t]})),this.feeTimestamp=n;case 11:return e.abrupt("return",this.link.estimateFee(t));case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.subscribe=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return 0===this.link.listenerCount("block")&&this.link.on("block",(function(e){n.postMessage((0,u.BlockchainMessage)(f.BLOCKCHAIN.BLOCK,h({coin:n.coinInfo},e)))})),0===this.link.listenerCount("notification")&&this.link.on("notification",(function(e){n.postMessage((0,u.BlockchainMessage)(f.BLOCKCHAIN.NOTIFICATION,{coin:n.coinInfo,notification:e}))})),e.next=4,this.link.subscribe({type:"block"});case 4:if(r=e.sent,t){e.next=7;break}return e.abrupt("return",r);case 7:return e.abrupt("return",this.link.subscribe({type:"accounts",accounts:t}));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.subscribeFiatRates=function(e){var t=this;return 0===this.link.listenerCount("fiatRates")&&this.link.on("fiatRates",(function(e){var r=e.rates;t.postMessage((0,u.BlockchainMessage)(f.BLOCKCHAIN.FIAT_RATES_UPDATE,{coin:t.coinInfo,rates:r}))})),this.link.subscribe({type:"fiatRates"})},t.unsubscribe=function(){var e=(0,o.default)(i.default.mark((function e(t){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t){e.next=7;break}return this.link.removeAllListeners("block"),this.link.removeAllListeners("fiatRates"),this.link.removeAllListeners("notification"),e.next=6,this.link.unsubscribe({type:"fiatRates"});case 6:return e.abrupt("return",this.link.unsubscribe({type:"block"}));case 7:return e.abrupt("return",this.link.unsubscribe({type:"accounts",accounts:t}));case 8:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.unsubscribeFiatRates=function(){return this.link.removeAllListeners("fiatRates"),this.link.unsubscribe({type:"fiatRates"})},t.pushTransaction=function(e){return this.link.pushTransaction(e)},t.disconnect=function(){this.link.removeAllListeners(),this.link.disconnect(),this.onError(f.ERRORS.TypedError("Backend_Disconnected"))},e}();t.default=d;var p=[],g={},y={},m=function(e){var t=p.indexOf(e);t>=0&&p.splice(t,1)},b=function(e){for(var t=0;t0&&a.length>i&&!a.warned){a.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=a.length,s=u,console&&console.warn&&console.warn(s)}return e}function h(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function d(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=h.bind(n);return i.listener=r,n.wrapFn=i,i}function p(e,t,r){var n=e._events;if(void 0===n)return[];var i=n[t];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(e){for(var t=new Array(e.length),r=0;r0&&(a=t[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=i[e];if(void 0===u)return!1;if("function"==typeof u)o(u,this,t);else{var f=u.length,c=y(u,f);for(r=0;r=0;o--)if(r[o]===t||r[o].listener===t){a=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(e,t){for(;t+1=0;n--)this.removeListener(e,t[n]);return this},s.prototype.listeners=function(e){return p(this,e,!0)},s.prototype.rawListeners=function(e){return p(this,e,!1)},s.listenerCount=function(e,t){return"function"==typeof e.listenerCount?e.listenerCount(t):g.call(e,t)},s.prototype.listenerCount=g,s.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]}},function(e){e.exports=JSON.parse('{"OP_FALSE":0,"OP_0":0,"OP_PUSHDATA1":76,"OP_PUSHDATA2":77,"OP_PUSHDATA4":78,"OP_1NEGATE":79,"OP_RESERVED":80,"OP_TRUE":81,"OP_1":81,"OP_2":82,"OP_3":83,"OP_4":84,"OP_5":85,"OP_6":86,"OP_7":87,"OP_8":88,"OP_9":89,"OP_10":90,"OP_11":91,"OP_12":92,"OP_13":93,"OP_14":94,"OP_15":95,"OP_16":96,"OP_NOP":97,"OP_VER":98,"OP_IF":99,"OP_NOTIF":100,"OP_VERIF":101,"OP_VERNOTIF":102,"OP_ELSE":103,"OP_ENDIF":104,"OP_VERIFY":105,"OP_RETURN":106,"OP_TOALTSTACK":107,"OP_FROMALTSTACK":108,"OP_2DROP":109,"OP_2DUP":110,"OP_3DUP":111,"OP_2OVER":112,"OP_2ROT":113,"OP_2SWAP":114,"OP_IFDUP":115,"OP_DEPTH":116,"OP_DROP":117,"OP_DUP":118,"OP_NIP":119,"OP_OVER":120,"OP_PICK":121,"OP_ROLL":122,"OP_ROT":123,"OP_SWAP":124,"OP_TUCK":125,"OP_CAT":126,"OP_SUBSTR":127,"OP_LEFT":128,"OP_RIGHT":129,"OP_SIZE":130,"OP_INVERT":131,"OP_AND":132,"OP_OR":133,"OP_XOR":134,"OP_EQUAL":135,"OP_EQUALVERIFY":136,"OP_RESERVED1":137,"OP_RESERVED2":138,"OP_1ADD":139,"OP_1SUB":140,"OP_2MUL":141,"OP_2DIV":142,"OP_NEGATE":143,"OP_ABS":144,"OP_NOT":145,"OP_0NOTEQUAL":146,"OP_ADD":147,"OP_SUB":148,"OP_MUL":149,"OP_DIV":150,"OP_MOD":151,"OP_LSHIFT":152,"OP_RSHIFT":153,"OP_BOOLAND":154,"OP_BOOLOR":155,"OP_NUMEQUAL":156,"OP_NUMEQUALVERIFY":157,"OP_NUMNOTEQUAL":158,"OP_LESSTHAN":159,"OP_GREATERTHAN":160,"OP_LESSTHANOREQUAL":161,"OP_GREATERTHANOREQUAL":162,"OP_MIN":163,"OP_MAX":164,"OP_WITHIN":165,"OP_RIPEMD160":166,"OP_SHA1":167,"OP_SHA256":168,"OP_HASH160":169,"OP_HASH256":170,"OP_CODESEPARATOR":171,"OP_CHECKSIG":172,"OP_CHECKSIGVERIFY":173,"OP_CHECKMULTISIG":174,"OP_CHECKMULTISIGVERIFY":175,"OP_NOP1":176,"OP_NOP2":177,"OP_CHECKLOCKTIMEVERIFY":177,"OP_NOP3":178,"OP_CHECKSEQUENCEVERIFY":178,"OP_NOP4":179,"OP_NOP5":180,"OP_NOP6":181,"OP_NOP7":182,"OP_NOP8":183,"OP_NOP9":184,"OP_NOP10":185,"OP_PUBKEYHASH":253,"OP_PUBKEY":254,"OP_INVALIDOPCODE":255}')},function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=r,r.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)}},function(e,t,r){"use strict";var n=t,i=r(18),o=r(27),a=r(166);n.assert=o,n.toArray=a.toArray,n.zero2=a.zero2,n.toHex=a.toHex,n.encode=a.encode,n.getNAF=function(e,t,r){var n=new Array(Math.max(e.bitLength(),r)+1);n.fill(0);for(var i=1<(i>>1)-1?(i>>1)-u:u,o.isubn(s)):s=0,n[a]=s,o.iushrn(1)}return n},n.getJSF=function(e,t){var r=[[],[]];e=e.clone(),t=t.clone();for(var n=0,i=0;e.cmpn(-n)>0||t.cmpn(-i)>0;){var o,a,s,u=e.andln(3)+n&3,f=t.andln(3)+i&3;if(3===u&&(u=-1),3===f&&(f=-1),0==(1&u))o=0;else o=3!==(s=e.andln(7)+n&7)&&5!==s||2!==f?u:-u;if(r[0].push(o),0==(1&f))a=0;else a=3!==(s=t.andln(7)+i&7)&&5!==s||2!==u?f:-f;r[1].push(a),2*n===o+1&&(n=1-n),2*i===a+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},n.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},n.parseBytes=function(e){return"string"==typeof e?n.toArray(e,"hex"):e},n.intFromLE=function(e){return new i(e,"hex","le")}},function(e,t,r){var n;!function(i){"use strict";var o,a=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,s=Math.ceil,u=Math.floor,f="[BigNumber Error] ",c=f+"Number primitive has more than 15 significant digits: ",l=1e14,h=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],d=1e9;function p(e){var t=0|e;return e>0||e===t?t:t-1}function g(e){for(var t,r,n=1,i=e.length,o=e[0]+"";nf^r?1:-1;for(s=(u=i.length)<(f=o.length)?u:f,a=0;ao[a]^r?1:-1;return u==f?0:u>f^r?1:-1}function m(e,t,r,n){if(er||e!==u(e))throw Error(f+(n||"Argument")+("number"==typeof e?er?" out of range: ":" not an integer: ":" not a primitive number: ")+String(e))}function b(e){var t=e.c.length-1;return p(e.e/14)==t&&e.c[t]%2!=0}function v(e,t){return(e.length>1?e.charAt(0)+"."+e.slice(1):e)+(t<0?"e":"e+")+t}function w(e,t,r){var n,i;if(t<0){for(i=r+".";++t;i+=r);e=i+e}else if(++t>(n=e.length)){for(i=r,t-=n;--t;i+=r);e+=i}else tC?g.c=g.e=null:e.e=10;l/=10,f++);return void(f>C?g.c=g.e=null:(g.e=f,g.c=[e]))}p=String(e)}else{if(!a.test(p=String(e)))return i(g,p,h);g.s=45==p.charCodeAt(0)?(p=p.slice(1),-1):1}(f=p.indexOf("."))>-1&&(p=p.replace(".","")),(l=p.search(/e/i))>0?(f<0&&(f=l),f+=+p.slice(l+1),p=p.substring(0,l)):f<0&&(f=p.length)}else{if(m(t,2,j.length,"Base"),10==t)return V(g=new L(e),M+g.e+1,k);if(p=String(e),h="number"==typeof e){if(0*e!=0)return i(g,p,h,t);if(g.s=1/e<0?(p=p.slice(1),-1):1,L.DEBUG&&p.replace(/^0\.0*|\./,"").length>15)throw Error(c+e)}else g.s=45===p.charCodeAt(0)?(p=p.slice(1),-1):1;for(r=j.slice(0,t),f=l=0,d=p.length;lf){f=d;continue}}else if(!s&&(p==p.toUpperCase()&&(p=p.toLowerCase())||p==p.toLowerCase()&&(p=p.toUpperCase()))){s=!0,l=-1,f=0;continue}return i(g,String(e),h,t)}h=!1,(f=(p=n(p,t,10,g.s)).indexOf("."))>-1?p=p.replace(".",""):f=p.length}for(l=0;48===p.charCodeAt(l);l++);for(d=p.length;48===p.charCodeAt(--d););if(p=p.slice(l,++d)){if(d-=l,h&&L.DEBUG&&d>15&&(e>9007199254740991||e!==u(e)))throw Error(c+g.s*e);if((f=f-l-1)>C)g.c=g.e=null;else if(f=x)?v(u,a):w(u,a,"0");else if(o=(e=V(new L(e),t,r)).e,s=(u=g(e.c)).length,1==n||2==n&&(t<=o||o<=T)){for(;ss){if(--t>0)for(u+=".";t--;u+="0");}else if((t+=o-s)>0)for(o+1==s&&(u+=".");t--;u+="0");return e.s<0&&i?"-"+u:u}function H(e,t){for(var r,n=1,i=new L(e[0]);n=10;i/=10,n++);return(r=n+14*r-1)>C?e.c=e.e=null:r=10;f/=10,i++);if((o=t-i)<0)o+=14,a=t,p=(c=g[d=0])/y[i-a-1]%10|0;else if((d=s((o+1)/14))>=g.length){if(!n)break e;for(;g.length<=d;g.push(0));c=p=0,i=1,a=(o%=14)-14+1}else{for(c=f=g[d],i=1;f>=10;f/=10,i++);p=(a=(o%=14)-14+i)<0?0:c/y[i-a-1]%10|0}if(n=n||t<0||null!=g[d+1]||(a<0?c:c%y[i-a-1]),n=r<4?(p||n)&&(0==r||r==(e.s<0?3:2)):p>5||5==p&&(4==r||n||6==r&&(o>0?a>0?c/y[i-a]:0:g[d-1])%10&1||r==(e.s<0?8:7)),t<1||!g[0])return g.length=0,n?(t-=e.e+1,g[0]=y[(14-t%14)%14],e.e=-t||0):g[0]=e.e=0,e;if(0==o?(g.length=d,f=1,d--):(g.length=d+1,f=y[14-o],g[d]=a>0?u(c/y[i-a]%y[a])*f:0),n)for(;;){if(0==d){for(o=1,a=g[0];a>=10;a/=10,o++);for(a=g[0]+=f,f=1;a>=10;a/=10,f++);o!=f&&(e.e++,g[0]==l&&(g[0]=1));break}if(g[d]+=f,g[d]!=l)break;g[d--]=0,f=1}for(o=g.length;0===g[--o];g.pop());}e.e>C?e.c=e.e=null:e.e=x?v(t,r):w(t,r,"0"),e.s<0?"-"+t:t)}return L.clone=e,L.ROUND_UP=0,L.ROUND_DOWN=1,L.ROUND_CEIL=2,L.ROUND_FLOOR=3,L.ROUND_HALF_UP=4,L.ROUND_HALF_DOWN=5,L.ROUND_HALF_EVEN=6,L.ROUND_HALF_CEIL=7,L.ROUND_HALF_FLOOR=8,L.EUCLID=9,L.config=L.set=function(e){var t,r;if(null!=e){if("object"!=typeof e)throw Error(f+"Object expected: "+e);if(e.hasOwnProperty(t="DECIMAL_PLACES")&&(m(r=e[t],0,d,t),M=r),e.hasOwnProperty(t="ROUNDING_MODE")&&(m(r=e[t],0,8,t),k=r),e.hasOwnProperty(t="EXPONENTIAL_AT")&&((r=e[t])&&r.pop?(m(r[0],-d,0,t),m(r[1],0,d,t),T=r[0],x=r[1]):(m(r,-d,d,t),T=-(x=r<0?-r:r))),e.hasOwnProperty(t="RANGE"))if((r=e[t])&&r.pop)m(r[0],-d,-1,t),m(r[1],1,d,t),R=r[0],C=r[1];else{if(m(r,-d,d,t),!r)throw Error(f+t+" cannot be zero: "+r);R=-(C=r<0?-r:r)}if(e.hasOwnProperty(t="CRYPTO")){if((r=e[t])!==!!r)throw Error(f+t+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw N=!r,Error(f+"crypto unavailable");N=r}else N=r}if(e.hasOwnProperty(t="MODULO_MODE")&&(m(r=e[t],0,9,t),B=r),e.hasOwnProperty(t="POW_PRECISION")&&(m(r=e[t],0,d,t),D=r),e.hasOwnProperty(t="FORMAT")){if("object"!=typeof(r=e[t]))throw Error(f+t+" not an object: "+r);U=r}if(e.hasOwnProperty(t="ALPHABET")){if("string"!=typeof(r=e[t])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(f+t+" invalid: "+r);j=r}}return{DECIMAL_PLACES:M,ROUNDING_MODE:k,EXPONENTIAL_AT:[T,x],RANGE:[R,C],CRYPTO:N,MODULO_MODE:B,POW_PRECISION:D,FORMAT:U,ALPHABET:j}},L.isBigNumber=function(e){if(!e||!0!==e._isBigNumber)return!1;if(!L.DEBUG)return!0;var t,r,n=e.c,i=e.e,o=e.s;e:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-d&&i<=d&&i===u(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break e}if((t=(i+1)%14)<1&&(t+=14),String(n[0]).length==t){for(t=0;t=l||r!==u(r))break e;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(f+"Invalid BigNumber: "+e)},L.maximum=L.max=function(){return H(arguments,O.lt)},L.minimum=L.min=function(){return H(arguments,O.gt)},L.random=(o=9007199254740992*Math.random()&2097151?function(){return u(9007199254740992*Math.random())}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(e){var t,r,n,i,a,c=0,l=[],p=new L(P);if(null==e?e=M:m(e,0,d),i=s(e/14),N)if(crypto.getRandomValues){for(t=crypto.getRandomValues(new Uint32Array(i*=2));c>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),t[c]=r[0],t[c+1]=r[1]):(l.push(a%1e14),c+=2);c=i/2}else{if(!crypto.randomBytes)throw N=!1,Error(f+"crypto unavailable");for(t=crypto.randomBytes(i*=7);c=9e15?crypto.randomBytes(7).copy(t,c):(l.push(a%1e14),c+=7);c=i/7}if(!N)for(;c=10;a/=10,c++);c<14&&(n-=14-c)}return p.e=n,p.c=l,p}),L.sum=function(){for(var e=1,t=arguments,r=new L(t[0]);er-1&&(null==a[i+1]&&(a[i+1]=0),a[i+1]+=a[i]/r|0,a[i]%=r)}return a.reverse()}return function(t,n,i,o,a){var s,u,f,c,l,h,d,p,y=t.indexOf("."),m=M,b=k;for(y>=0&&(c=D,D=0,t=t.replace(".",""),h=(p=new L(n)).pow(t.length-y),D=c,p.c=e(w(g(h.c),h.e,"0"),10,i,"0123456789"),p.e=p.c.length),f=c=(d=e(t,n,i,a?(s=j,"0123456789"):(s="0123456789",j))).length;0==d[--c];d.pop());if(!d[0])return s.charAt(0);if(y<0?--f:(h.c=d,h.e=f,h.s=o,d=(h=r(h,p,m,b,i)).c,l=h.r,f=h.e),y=d[u=f+m+1],c=i/2,l=l||u<0||null!=d[u+1],l=b<4?(null!=y||l)&&(0==b||b==(h.s<0?3:2)):y>c||y==c&&(4==b||l||6==b&&1&d[u-1]||b==(h.s<0?8:7)),u<1||!d[0])t=l?w(s.charAt(1),-m,s.charAt(0)):s.charAt(0);else{if(d.length=u,l)for(--i;++d[--u]>i;)d[u]=0,u||(++f,d=[1].concat(d));for(c=d.length;!d[--c];);for(y=0,t="";y<=c;t+=s.charAt(d[y++]));t=w(t,f,s.charAt(0))}return t}}(),r=function(){function e(e,t,r){var n,i,o,a,s=0,u=e.length,f=t%1e7,c=t/1e7|0;for(e=e.slice();u--;)s=((i=f*(o=e[u]%1e7)+(n=c*o+(a=e[u]/1e7|0)*f)%1e7*1e7+s)/r|0)+(n/1e7|0)+c*a,e[u]=i%r;return s&&(e=[s].concat(e)),e}function t(e,t,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;it[i]?1:-1;break}return o}function r(e,t,r,n){for(var i=0;r--;)e[r]-=i,i=e[r]1;e.splice(0,1));}return function(n,i,o,a,s){var f,c,h,d,g,y,m,b,v,w,_,E,S,A,I,O,P,M=n.s==i.s?1:-1,k=n.c,T=i.c;if(!(k&&k[0]&&T&&T[0]))return new L(n.s&&i.s&&(k?!T||k[0]!=T[0]:T)?k&&0==k[0]||!T?0*M:M/0:NaN);for(v=(b=new L(M)).c=[],M=o+(c=n.e-i.e)+1,s||(s=l,c=p(n.e/14)-p(i.e/14),M=M/14|0),h=0;T[h]==(k[h]||0);h++);if(T[h]>(k[h]||0)&&c--,M<0)v.push(1),d=!0;else{for(A=k.length,O=T.length,h=0,M+=2,(g=u(s/(T[0]+1)))>1&&(T=e(T,g,s),k=e(k,g,s),O=T.length,A=k.length),S=O,_=(w=k.slice(0,O)).length;_=s/2&&I++;do{if(g=0,(f=t(T,w,O,_))<0){if(E=w[0],O!=_&&(E=E*s+(w[1]||0)),(g=u(E/I))>1)for(g>=s&&(g=s-1),m=(y=e(T,g,s)).length,_=w.length;1==t(y,w,m,_);)g--,r(y,O=10;M/=10,h++);V(b,o+(b.e=h+14*c-1)+1,a,d)}else b.e=c,b.r=+d;return b}}(),_=/^(-?)0([xbo])(?=\w[\w.]*$)/i,E=/^([^.]+)\.$/,S=/^\.([^.]+)$/,A=/^-?(Infinity|NaN)$/,I=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(e,t,r,n){var i,o=r?t:t.replace(I,"");if(A.test(o))e.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(_,(function(e,t,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?e:t})),n&&(i=n,o=o.replace(E,"$1").replace(S,"0.$1")),t!=o))return new L(o,i);if(L.DEBUG)throw Error(f+"Not a"+(n?" base "+n:"")+" number: "+t);e.s=null}e.c=e.e=null},O.absoluteValue=O.abs=function(){var e=new L(this);return e.s<0&&(e.s=1),e},O.comparedTo=function(e,t){return y(this,new L(e,t))},O.decimalPlaces=O.dp=function(e,t){var r,n,i,o=this;if(null!=e)return m(e,0,d),null==t?t=k:m(t,0,8),V(new L(o),e+o.e+1,t);if(!(r=o.c))return null;if(n=14*((i=r.length-1)-p(this.e/14)),i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},O.dividedBy=O.div=function(e,t){return r(this,new L(e,t),M,k)},O.dividedToIntegerBy=O.idiv=function(e,t){return r(this,new L(e,t),0,1)},O.exponentiatedBy=O.pow=function(e,t){var r,n,i,o,a,c,l,h,d=this;if((e=new L(e)).c&&!e.isInteger())throw Error(f+"Exponent not an integer: "+K(e));if(null!=t&&(t=new L(t)),a=e.e>14,!d.c||!d.c[0]||1==d.c[0]&&!d.e&&1==d.c.length||!e.c||!e.c[0])return h=new L(Math.pow(+K(d),a?2-b(e):+K(e))),t?h.mod(t):h;if(c=e.s<0,t){if(t.c?!t.c[0]:!t.s)return new L(NaN);(n=!c&&d.isInteger()&&t.isInteger())&&(d=d.mod(t))}else{if(e.e>9&&(d.e>0||d.e<-1||(0==d.e?d.c[0]>1||a&&d.c[1]>=24e7:d.c[0]<8e13||a&&d.c[0]<=9999975e7)))return o=d.s<0&&b(e)?-0:0,d.e>-1&&(o=1/o),new L(c?1/o:o);D&&(o=s(D/14+2))}for(a?(r=new L(.5),c&&(e.s=1),l=b(e)):l=(i=Math.abs(+K(e)))%2,h=new L(P);;){if(l){if(!(h=h.times(d)).c)break;o?h.c.length>o&&(h.c.length=o):n&&(h=h.mod(t))}if(i){if(0===(i=u(i/2)))break;l=i%2}else if(V(e=e.times(r),e.e+1,1),e.e>14)l=b(e);else{if(0===(i=+K(e)))break;l=i%2}d=d.times(d),o?d.c&&d.c.length>o&&(d.c.length=o):n&&(d=d.mod(t))}return n?h:(c&&(h=P.div(h)),t?h.mod(t):o?V(h,D,k,void 0):h)},O.integerValue=function(e){var t=new L(this);return null==e?e=k:m(e,0,8),V(t,t.e+1,e)},O.isEqualTo=O.eq=function(e,t){return 0===y(this,new L(e,t))},O.isFinite=function(){return!!this.c},O.isGreaterThan=O.gt=function(e,t){return y(this,new L(e,t))>0},O.isGreaterThanOrEqualTo=O.gte=function(e,t){return 1===(t=y(this,new L(e,t)))||0===t},O.isInteger=function(){return!!this.c&&p(this.e/14)>this.c.length-2},O.isLessThan=O.lt=function(e,t){return y(this,new L(e,t))<0},O.isLessThanOrEqualTo=O.lte=function(e,t){return-1===(t=y(this,new L(e,t)))||0===t},O.isNaN=function(){return!this.s},O.isNegative=function(){return this.s<0},O.isPositive=function(){return this.s>0},O.isZero=function(){return!!this.c&&0==this.c[0]},O.minus=function(e,t){var r,n,i,o,a=this,s=a.s;if(t=(e=new L(e,t)).s,!s||!t)return new L(NaN);if(s!=t)return e.s=-t,a.plus(e);var u=a.e/14,f=e.e/14,c=a.c,h=e.c;if(!u||!f){if(!c||!h)return c?(e.s=-t,e):new L(h?a:NaN);if(!c[0]||!h[0])return h[0]?(e.s=-t,e):new L(c[0]?a:3==k?-0:0)}if(u=p(u),f=p(f),c=c.slice(),s=u-f){for((o=s<0)?(s=-s,i=c):(f=u,i=h),i.reverse(),t=s;t--;i.push(0));i.reverse()}else for(n=(o=(s=c.length)<(t=h.length))?s:t,s=t=0;t0)for(;t--;c[r++]=0);for(t=l-1;n>s;){if(c[--n]=0;){for(r=0,d=w[i]%1e7,g=w[i]/1e7|0,o=i+(a=u);o>i;)r=((f=d*(f=v[--a]%1e7)+(s=g*f+(c=v[a]/1e7|0)*d)%1e7*1e7+y[o]+r)/m|0)+(s/1e7|0)+g*c,y[o--]=f%m;y[o]=r}return r?++n:y.splice(0,1),q(e,y,n)},O.negated=function(){var e=new L(this);return e.s=-e.s||null,e},O.plus=function(e,t){var r,n=this,i=n.s;if(t=(e=new L(e,t)).s,!i||!t)return new L(NaN);if(i!=t)return e.s=-t,n.minus(e);var o=n.e/14,a=e.e/14,s=n.c,u=e.c;if(!o||!a){if(!s||!u)return new L(i/0);if(!s[0]||!u[0])return u[0]?e:new L(s[0]?n:0*i)}if(o=p(o),a=p(a),s=s.slice(),i=o-a){for(i>0?(a=o,r=u):(i=-i,r=s),r.reverse();i--;r.push(0));r.reverse()}for((i=s.length)-(t=u.length)<0&&(r=u,u=s,s=r,t=i),i=0;t;)i=(s[--t]=s[t]+u[t]+i)/l|0,s[t]=l===s[t]?0:s[t]%l;return i&&(s=[i].concat(s),++a),q(e,s,a)},O.precision=O.sd=function(e,t){var r,n,i,o=this;if(null!=e&&e!==!!e)return m(e,1,d),null==t?t=k:m(t,0,8),V(new L(o),e,t);if(!(r=o.c))return null;if(n=14*(i=r.length-1)+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return e&&o.e+1>n&&(n=o.e+1),n},O.shiftedBy=function(e){return m(e,-9007199254740991,9007199254740991),this.times("1e"+e)},O.squareRoot=O.sqrt=function(){var e,t,n,i,o,a=this,s=a.c,u=a.s,f=a.e,c=M+4,l=new L("0.5");if(1!==u||!s||!s[0])return new L(!u||u<0&&(!s||s[0])?NaN:s?a:1/0);if(0==(u=Math.sqrt(+K(a)))||u==1/0?(((t=g(s)).length+f)%2==0&&(t+="0"),u=Math.sqrt(+t),f=p((f+1)/2)-(f<0||f%2),n=new L(t=u==1/0?"5e"+f:(t=u.toExponential()).slice(0,t.indexOf("e")+1)+f)):n=new L(u+""),n.c[0])for((u=(f=n.e)+c)<3&&(u=0);;)if(o=n,n=l.times(o.plus(r(a,o,c,1))),g(o.c).slice(0,u)===(t=g(n.c)).slice(0,u)){if(n.e0&&g>0){for(o=g%s||s,l=p.substr(0,o);o0&&(l+=c+p.slice(o)),d&&(l="-"+l)}n=h?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?h.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):h):l}return(r.prefix||"")+n+(r.suffix||"")},O.toFraction=function(e){var t,n,i,o,a,s,u,c,l,d,p,y,m=this,b=m.c;if(null!=e&&(!(u=new L(e)).isInteger()&&(u.c||1!==u.s)||u.lt(P)))throw Error(f+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+K(u));if(!b)return new L(m);for(t=new L(P),l=n=new L(P),i=c=new L(P),y=g(b),a=t.e=y.length-m.e-1,t.c[0]=h[(s=a%14)<0?14+s:s],e=!e||u.comparedTo(t)>0?a>0?t:l:u,s=C,C=1/0,u=new L(y),c.c[0]=0;d=r(u,t,0,1),1!=(o=n.plus(d.times(i))).comparedTo(e);)n=i,i=o,l=c.plus(d.times(o=l)),c=o,t=u.minus(d.times(o=t)),u=o;return o=r(e.minus(n),i,0,1),c=c.plus(o.times(l)),n=n.plus(o.times(i)),c.s=l.s=m.s,p=r(l,i,a*=2,k).minus(m).abs().comparedTo(r(c,n,a,k).minus(m).abs())<1?[l,i]:[c,n],C=s,p},O.toNumber=function(){return+K(this)},O.toPrecision=function(e,t){return null!=e&&m(e,1,d),F(this,e,t,2)},O.toString=function(e){var t,r=this,i=r.s,o=r.e;return null===o?i?(t="Infinity",i<0&&(t="-"+t)):t="NaN":(null==e?t=o<=T||o>=x?v(g(r.c),o):w(g(r.c),o,"0"):10===e?t=w(g((r=V(new L(r),M+o+1,k)).c),r.e,"0"):(m(e,2,j.length,"Base"),t=n(w(g(r.c),o,"0"),10,e,i,!0)),i<0&&r.c[0]&&(t="-"+t)),t},O.valueOf=O.toJSON=function(){return K(this)},O._isBigNumber=!0,null!=t&&L.set(t),L}()).default=o.BigNumber=o,void 0===(n=function(){return o}.call(t,r,t,e))||(e.exports=n)}()},function(e,t,r){"use strict";var n=r(27),i=r(10);function o(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function a(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function s(e){return 1===e.length?"0"+e:e}function u(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=i,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var r=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),i=0;i>6|192,r[n++]=63&a|128):o(e,i)?(a=65536+((1023&a)<<10)+(1023&e.charCodeAt(++i)),r[n++]=a>>18|240,r[n++]=a>>12&63|128,r[n++]=a>>6&63|128,r[n++]=63&a|128):(r[n++]=a>>12|224,r[n++]=a>>6&63|128,r[n++]=63&a|128)}else for(i=0;i>>0}return a},t.split32=function(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=o>>>16&255,r[i+2]=o>>>8&255,r[i+3]=255&o):(r[i+3]=o>>>24,r[i+2]=o>>>16&255,r[i+1]=o>>>8&255,r[i]=255&o)}return r},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,r){return e+t+r>>>0},t.sum32_4=function(e,t,r,n){return e+t+r+n>>>0},t.sum32_5=function(e,t,r,n,i){return e+t+r+n+i>>>0},t.sum64=function(e,t,r,n){var i=e[t],o=n+e[t+1]>>>0,a=(o>>0,e[t+1]=o},t.sum64_hi=function(e,t,r,n){return(t+n>>>0>>0},t.sum64_lo=function(e,t,r,n){return t+n>>>0},t.sum64_4_hi=function(e,t,r,n,i,o,a,s){var u=0,f=t;return u+=(f=f+n>>>0)>>0)>>0)>>0},t.sum64_4_lo=function(e,t,r,n,i,o,a,s){return t+n+o+s>>>0},t.sum64_5_hi=function(e,t,r,n,i,o,a,s,u,f){var c=0,l=t;return c+=(l=l+n>>>0)>>0)>>0)>>0)>>0},t.sum64_5_lo=function(e,t,r,n,i,o,a,s,u,f){return t+n+o+s+f>>>0},t.rotr64_hi=function(e,t,r){return(t<<32-r|e>>>r)>>>0},t.rotr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0},t.shr64_hi=function(e,t,r){return e>>>r},t.shr64_lo=function(e,t,r){return(e<<32-r|t>>>r)>>>0}},function(e,t,r){var n=r(19),i=r(106);for(var o in i)n[o]=i[o];e.exports={bufferutils:r(110),Block:r(388),ECPair:r(113),ECSignature:r(72),HDNode:r(406),Transaction:r(112),TransactionBuilder:r(407),address:r(114),coins:r(58),crypto:r(51),networks:r(40),opcodes:r(26),script:n}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=r(126),u=r(125),f=r(8),c=r(80),l=r(103),h=n(r(359)),d=r(48);function p(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return g(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return g(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function g(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0&&(0,d.versionCompare)(e,i)<=0}));return this.messages[r?r.name:"default"]},e.isWhitelisted=function(e){if(!this.config)return null;var t=(0,h.default)(e);if(t&&"string"==typeof t.host){var r=t.host.split(".");return r.length>2&&(t.host=r.slice(r.length-2,r.length).join(".")),this.config.whitelist.find((function(r){return r.origin===e||r.origin===t.host}))}},e.isManagementAllowed=function(){var e=this;if(this.config){var t=(0,h.default)(this.settings.origin);if(t&&"string"==typeof t.host){var r=t.host.split(".");return r.length>2&&(t.host=r.slice(r.length-2,r.length).join(".")),this.config.management.find((function(r){return r.origin===e.settings.origin||r.origin===t.host}))}}},e.getPriority=function(e){return e?e.priority:u.DEFAULT_PRIORITY},e.getHostLabel=function(e){return this.config.knownHosts.find((function(t){return t.origin===e}))},e.getSettings=function(e){return this.settings?"string"==typeof e?this.settings[e]:this.settings:null},e.getDebugSettings=function(e){return!1},e.getConfig=function(){return this.config},e}();t.default=y,(0,a.default)(y,"assets",{}),(0,a.default)(y,"messages",{})},function(e,t,r){"use strict";(function(Buffer){var e=r(0);t.__esModule=!0,t.messageToHex=t.stripHexPrefix=t.hasHexPrefix=t.btckb2satoshib=t.formatTime=t.formatAmountOld=t.formatAmount=void 0;var n=e(r(29));t.formatAmount=function(e,t){return new n.default(e).div(Math.pow(10,t.decimals)).toString(10)+" "+t.shortcut};t.formatAmountOld=function(e,t){var r=e/1e8;return r.toString()+" "+t.shortcut};t.formatTime=function(e){if(!e||e<=0)return"No time estimate";var t=Math.floor(e/60),r=e%60,n="";return 0!==t&&(n+=t+" hour",t>1&&(n+="s"),n+=" "),0!==r&&(n+=r+" minutes"),n};t.btckb2satoshib=function(e){return new n.default(e).times(1e5).toFixed(0,n.default.ROUND_HALF_UP)};var i=function(e){return"0x"===e.slice(0,2).toLowerCase()};t.hasHexPrefix=i;var o=function(e){return i(e)?e.slice(2):e};t.stripHexPrefix=o;t.messageToHex=function(e){var t,r,n;if("string"!=typeof(r=e)||!r.match(/^(0x|0X)?[0-9A-Fa-f]*$/)||n&&r.length!==2+2*n)t=Buffer.from(e);else{var i=o(e);i.length%2!=0&&(i="0"+i),t=Buffer.from(i,"hex")}return t.toString("hex")}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";(function(t,n){var Buffer=r(7).Buffer,i=t.crypto||t.msCrypto;i&&i.getRandomValues?e.exports=function(e,t){if(e>4294967295)throw new RangeError("requested too many random bytes");var r=Buffer.allocUnsafe(e);if(e>0)if(e>65536)for(var o=0;o>5==6?2:e>>4==14?3:e>>3==30?4:e>>6==2?-1:-2}function a(e){var t=this.lastTotal-this.lastNeed,r=function(e,t,r){if(128!=(192&t[0]))return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if(128!=(192&t[1]))return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&128!=(192&t[2]))return e.lastNeed=2,"�"}}(this,e);return void 0!==r?r:this.lastNeed<=e.length?(e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(e.copy(this.lastChar,t,0,e.length),void(this.lastNeed-=e.length))}function s(e,t){if((e.length-t)%2==0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function u(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function f(e,t){var r=(e.length-t)%3;return 0===r?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function c(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function l(e){return e.toString(this.encoding)}function h(e){return e&&e.length?this.write(e):""}t.StringDecoder=i,i.prototype.write=function(e){if(0===e.length)return"";var t,r;if(this.lastNeed){if(void 0===(t=this.fillLast(e)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r=0)return i>0&&(e.lastNeed=i-1),i;if(--n=0)return i>0&&(e.lastNeed=i-2),i;if(--n=0)return i>0&&(2===i?i=0:e.lastNeed=i-3),i;return 0}(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)},i.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length}},function(e,t,r){"use strict";var n=r(61),i=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=l;var o=Object.create(r(53));o.inherits=r(10);var a=r(140),s=r(90);o.inherits(l,a);for(var u=i(s.prototype),f=0;f=t.length&&r()}))})),function(){t.forEach((function(e){return e.dispose()}))}}))}},{key:"filterError",value:function(e){return e.filter((function(e){return!(e instanceof Error)}))}}]),a(e,[{key:"awaitFirst",value:function(){var e=this;return new Promise((function(t,r){var n=function(){},i=function r(i){e.values.detach(r),e.finish.detach(n),t(i)};n=function(){e.values.detach(i),e.finish.detach(n),r(new Error("No first value."))},e.values.attach(i),e.finish.attach(n)}))}},{key:"awaitFinish",value:function(){var e=this;return new Promise((function(t){e.finish.attach((function(e,r){r(),t()}))}))}},{key:"map",value:function(t){var r=this;return new e((function(e,n){return r.values.attach((function(r){e(t(r))})),r.finish.attach(n),r.dispose}))}},{key:"mapPromise",value:function(t){var r=this;return new e((function(e,n){var i=Promise.resolve(),o=!1;return r.values.attach((function(r){var n=i,a=function(){try{return t(r)}catch(e){return Promise.reject(e)}}();i=a.then((function(t){return n.then((function(){o||e(t)}))}),(function(t){return n.then((function(){o||e(t)}))}))})),r.finish.attach((function(){i.then((function(){o||n()}))})),function(){o=!0,r.dispose()}}))}},{key:"filter",value:function(t){var r=this;return new e((function(e,n){return r.values.attach((function(r){t(r)&&e(r)})),r.finish.attach(n),r.dispose}))}},{key:"reduce",value:function(e,t){var r=this;return new Promise((function(n){var i=t,o=function(t){i=e(i,t)};r.values.attach(o),r.finish.attach((function(e,t){n(i),t(),r.values.detach(o)}))}))}}]),e}();t.Stream=l;var h=function(){function e(){i(this,e)}return a(e,null,[{key:"fromStreamAndPromise",value:function(t,r){r.catch((function(){}));var i=new e;i.stream=t;var o=(0,n.deferred)();return i.dispose=function(e){o.reject(e),o.promise.catch((function(){})),t.dispose()},t.awaitFinish().then((function(){o.resolve()})),i.ending=o.promise.then((function(){return r})),i.ending.catch((function(){})),i}},{key:"fromPromise",value:function(t){var r=new e,n=!1;r.stream=l.fromPromise(t.then((function(e){if(n)throw new Error("disposed");return e.stream})),!0),r.ending=t.then((function(e){return e.ending})),r.ending.catch((function(){}));var i=null;return t.then((function(e){i=e})),r.dispose=function(e){n=!0,null!=i&&i.dispose(e)},r}}]),e}();t.StreamWithEnding=h},function(e,t,r){"use strict";var n={};function i(e,t,r){r||(r=Error);var i=function(e){var r,n;function i(r,n,i){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,i))||this}return n=e,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=e,n[e]=i}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=f;var i=r(132),o=r(136);r(10)(f,i);for(var a=n(o.prototype),s=0;s=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return e?o.toString(e):o},n.prototype._update=function(){throw new Error("_update must be implemented by subclass")},e.exports=n},function(e,t,r){"use strict";var n={};function i(e,t,r){r||(r=Error);var i=function(e){var r,n;function i(r,n,i){return e.call(this,function(e,r,n){return"string"==typeof t?t:t(e,r,n)}(r,n,i))||this}return n=e,(r=i).prototype=Object.create(n.prototype),r.prototype.constructor=r,r.__proto__=n,i}(r);i.prototype.name=r.name,i.prototype.code=e,n[e]=i}function o(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map((function(e){return String(e)})),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:2===r?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}return"of ".concat(t," ").concat(String(e))}i("ERR_INVALID_OPT_VALUE",(function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'}),TypeError),i("ERR_INVALID_ARG_TYPE",(function(e,t,r){var n,i,a,s;if("string"==typeof t&&(i="not ",t.substr(!a||a<0?0:+a,i.length)===i)?(n="must not be",t=t.replace(/^not /,"")):n="must be",function(e,t,r){return(void 0===r||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}(e," argument"))s="The ".concat(e," ").concat(n," ").concat(o(t,"type"));else{var u=function(e,t,r){return"number"!=typeof r&&(r=0),!(r+t.length>e.length)&&-1!==e.indexOf(t,r)}(e,".")?"property":"argument";s='The "'.concat(e,'" ').concat(u," ").concat(n," ").concat(o(t,"type"))}return s+=". Received type ".concat(typeof r)}),TypeError),i("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),i("ERR_METHOD_NOT_IMPLEMENTED",(function(e){return"The "+e+" method is not implemented"})),i("ERR_STREAM_PREMATURE_CLOSE","Premature close"),i("ERR_STREAM_DESTROYED",(function(e){return"Cannot call "+e+" after a stream was destroyed"})),i("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),i("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),i("ERR_STREAM_WRITE_AFTER_END","write after end"),i("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),i("ERR_UNKNOWN_ENCODING",(function(e){return"Unknown encoding: "+e}),TypeError),i("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),e.exports.codes=n},function(e,t,r){"use strict";(function(t){var n=Object.keys||function(e){var t=[];for(var r in e)t.push(r);return t};e.exports=f;var i=r(160),o=r(164);r(10)(f,i);for(var a=n(o.prototype),s=0;s3)return!1;if(0===e[0])return!1;for(var t=0;tc[l])return 1;if(c[l]>f[l])return-1}return 0}},function(e,t,r){"use strict";t.__esModule=!0,t.getLog=t.enableLogByPrefix=t.enableLog=t.initLog=void 0;var n={DescriptorStream:"color: #77ab59",DeviceList:"color: #36802d",Device:"color: #bada55",Core:"color: #c9df8a",IFrame:"color: #FFFFFF; background: #f4a742;",Popup:"color: #f48a00"},i=function(){function e(e,t){this.prefix=e,this.enabled=t,this.messages=[],this.css=n[e]||"color: #000000; background: #FFFFFF;"}var t=e.prototype;return t.addMessage=function(e,t){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i100&&this.messages.shift()},t.log=function(){for(var e=arguments.length,t=new Array(e),r=0;r1&&void 0!==arguments[1]&&arguments[1];return e.reduce((function(e,r){if(Number.isNaN(e))return new i.default(NaN);var n=f(r.value);return n.isNaN()?t?new i.default(0).plus(e):new i.default(NaN):n.plus(e)}),new i.default(0))}function l(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],i=e*t,o=r.baseFee||0;if(o&&t&&(r.floorBaseFee?o*=parseInt((o+i)/o,10):o+=i),r.dustOutputFee)for(var a=0;a=this._delta8){var r=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-r,e.length),0===this.pending.length&&(this.pending=null),e=n.join32(e,0,e.length-r,this.endian);for(var i=0;i>>24&255,n[i++]=e>>>16&255,n[i++]=e>>>8&255,n[i++]=255&e}else for(n[i++]=255&e,n[i++]=e>>>8&255,n[i++]=e>>>16&255,n[i++]=e>>>24&255,n[i++]=0,n[i++]=0,n[i++]=0,n[i++]=0,o=8;o=8?a+=e[s].toUpperCase():a+=e[s];return a};t.getNetworkLabel=function(e,t){if(t){var r=t.name.toLowerCase().indexOf("testnet")>=0?"Testnet":t.name;return e.replace("#NETWORK",r)}return e.replace("#NETWORK","")}},function(e,t,r){"use strict";(function(t){void 0===t||!t.version||0===t.version.indexOf("v0.")||0===t.version.indexOf("v1.")&&0!==t.version.indexOf("v1.8.")?e.exports={nextTick:function(e,r,n,i){if("function"!=typeof e)throw new TypeError('"callback" argument must be a function');var o,a,s=arguments.length;switch(s){case 0:case 1:return t.nextTick(e);case 2:return t.nextTick((function(){e.call(null,r)}));case 3:return t.nextTick((function(){e.call(null,r,n)}));case 4:return t.nextTick((function(){e.call(null,r,n,i)}));default:for(o=new Array(s-1),a=0;ar)?t=("rmd160"===e?new s:u(e)).update(t).digest():t.length>>24]^c[p>>>16&255]^l[g>>>8&255]^h[255&y]^t[m++],a=f[p>>>24]^c[g>>>16&255]^l[y>>>8&255]^h[255&d]^t[m++],s=f[g>>>24]^c[y>>>16&255]^l[d>>>8&255]^h[255&p]^t[m++],u=f[y>>>24]^c[d>>>16&255]^l[p>>>8&255]^h[255&g]^t[m++],d=o,p=a,g=s,y=u;return o=(n[d>>>24]<<24|n[p>>>16&255]<<16|n[g>>>8&255]<<8|n[255&y])^t[m++],a=(n[p>>>24]<<24|n[g>>>16&255]<<16|n[y>>>8&255]<<8|n[255&d])^t[m++],s=(n[g>>>24]<<24|n[y>>>16&255]<<16|n[d>>>8&255]<<8|n[255&p])^t[m++],u=(n[y>>>24]<<24|n[d>>>16&255]<<16|n[p>>>8&255]<<8|n[255&g])^t[m++],[o>>>=0,a>>>=0,s>>>=0,u>>>=0]}var a=[0,1,2,4,8,16,32,64,128,27,54],s=function(){for(var e=new Array(256),t=0;t<256;t++)e[t]=t<128?t<<1:t<<1^283;for(var r=[],n=[],i=[[],[],[],[]],o=[[],[],[],[]],a=0,s=0,u=0;u<256;++u){var f=s^s<<1^s<<2^s<<3^s<<4;f=f>>>8^255&f^99,r[a]=f,n[f]=a;var c=e[a],l=e[c],h=e[l],d=257*e[f]^16843008*f;i[0][a]=d<<24|d>>>8,i[1][a]=d<<16|d>>>16,i[2][a]=d<<8|d>>>24,i[3][a]=d,d=16843009*h^65537*l^257*c^16843008*a,o[0][f]=d<<24|d>>>8,o[1][f]=d<<16|d>>>16,o[2][f]=d<<8|d>>>24,o[3][f]=d,0===a?a=s=1:(a=c^e[e[e[h^c]]],s^=e[e[s]])}return{SBOX:r,INV_SBOX:n,SUB_MIX:i,INV_SUB_MIX:o}}();function u(e){this._key=n(e),this._reset()}u.blockSize=16,u.keySize=32,u.prototype.blockSize=u.blockSize,u.prototype.keySize=u.keySize,u.prototype._reset=function(){for(var e=this._key,t=e.length,r=t+6,n=4*(r+1),i=[],o=0;o>>24,u=s.SBOX[u>>>24]<<24|s.SBOX[u>>>16&255]<<16|s.SBOX[u>>>8&255]<<8|s.SBOX[255&u],u^=a[o/t|0]<<24):t>6&&o%t==4&&(u=s.SBOX[u>>>24]<<24|s.SBOX[u>>>16&255]<<16|s.SBOX[u>>>8&255]<<8|s.SBOX[255&u]),i[o]=i[o-t]^u}for(var f=[],c=0;c>>24]]^s.INV_SUB_MIX[1][s.SBOX[h>>>16&255]]^s.INV_SUB_MIX[2][s.SBOX[h>>>8&255]]^s.INV_SUB_MIX[3][s.SBOX[255&h]]}this._nRounds=r,this._keySchedule=i,this._invKeySchedule=f},u.prototype.encryptBlockRaw=function(e){return o(e=n(e),this._keySchedule,s.SUB_MIX,s.SBOX,this._nRounds)},u.prototype.encryptBlock=function(e){var t=this.encryptBlockRaw(e),r=Buffer.allocUnsafe(16);return r.writeUInt32BE(t[0],0),r.writeUInt32BE(t[1],4),r.writeUInt32BE(t[2],8),r.writeUInt32BE(t[3],12),r},u.prototype.decryptBlock=function(e){var t=(e=n(e))[1];e[1]=e[3],e[3]=t;var r=o(e,this._invKeySchedule,s.INV_SUB_MIX,s.INV_SBOX,this._nRounds),i=Buffer.allocUnsafe(16);return i.writeUInt32BE(r[0],0),i.writeUInt32BE(r[3],4),i.writeUInt32BE(r[2],8),i.writeUInt32BE(r[1],12),i},u.prototype.scrub=function(){i(this._keySchedule),i(this._invKeySchedule),i(this._key)},e.exports.AES=u},function(e,t,r){var Buffer=r(7).Buffer,n=r(82);e.exports=function(e,t,r,i){if(Buffer.isBuffer(e)||(e=Buffer.from(e,"binary")),t&&(Buffer.isBuffer(t)||(t=Buffer.from(t,"binary")),8!==t.length))throw new RangeError("salt should be Buffer with 8 byte length");for(var o=r/8,a=Buffer.alloc(o),s=Buffer.alloc(i||0),u=Buffer.alloc(0);o>0||i>0;){var f=new n;f.update(u),f.update(e),t&&f.update(t),u=f.digest();var c=0;if(o>0){var l=a.length-o;c=Math.min(o,u.length),u.copy(a,l,0,c),o-=c}if(c0){var h=s.length-i,d=Math.min(i,u.length-c);u.copy(s,h,c,c+d),i-=d}}return u.fill(0),{key:a,iv:s}}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t,r){"use strict";var n=t;n.version=r(304).version,n.utils=r(28),n.rand=r(94),n.curve=r(167),n.curves=r(97),n.ec=r(315),n.eddsa=r(319)},function(e,t,r){"use strict";var n=r(18),i=r(28),o=i.getNAF,a=i.getJSF,s=i.assert;function u(e,t){this.type=e,this.p=new n(t.p,16),this.red=t.prime?n.red(t.prime):n.mont(this.p),this.zero=new n(0).toRed(this.red),this.one=new n(1).toRed(this.red),this.two=new n(2).toRed(this.red),this.n=t.n&&new n(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var r=this.n&&this.p.div(this.n);!r||r.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function f(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=u,u.prototype.point=function(){throw new Error("Not implemented")},u.prototype.validate=function(){throw new Error("Not implemented")},u.prototype._fixedNafMul=function(e,t){s(e.precomputed);var r=e._getDoubles(),n=o(t,1,this._bitLength),i=(1<=u;t--)f=(f<<1)+n[t];a.push(f)}for(var c=this.jpoint(null,null,null),l=this.jpoint(null,null,null),h=i;h>0;h--){for(u=0;u=0;f--){for(t=0;f>=0&&0===a[f];f--)t++;if(f>=0&&t++,u=u.dblp(t),f<0)break;var c=a[f];s(0!==c),u="affine"===e.type?c>0?u.mixedAdd(i[c-1>>1]):u.mixedAdd(i[-c-1>>1].neg()):c>0?u.add(i[c-1>>1]):u.add(i[-c-1>>1].neg())}return"affine"===e.type?u.toP():u},u.prototype._wnafMulAdd=function(e,t,r,n,i){for(var s=this._wnafT1,u=this._wnafT2,f=this._wnafT3,c=0,l=0;l=1;l-=2){var d=l-1,p=l;if(1===s[d]&&1===s[p]){var g=[t[d],null,null,t[p]];0===t[d].y.cmp(t[p].y)?(g[1]=t[d].add(t[p]),g[2]=t[d].toJ().mixedAdd(t[p].neg())):0===t[d].y.cmp(t[p].y.redNeg())?(g[1]=t[d].toJ().mixedAdd(t[p]),g[2]=t[d].add(t[p].neg())):(g[1]=t[d].toJ().mixedAdd(t[p]),g[2]=t[d].toJ().mixedAdd(t[p].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],m=a(r[d],r[p]);c=Math.max(m[0].length,c),f[d]=new Array(c),f[p]=new Array(c);for(var b=0;b=0;l--){for(var S=0;l>=0;){var A=!0;for(b=0;b=0&&S++,_=_.dblp(S),l<0)break;for(b=0;b0?I=u[b][O-1>>1]:O<0&&(I=u[b][-O-1>>1].neg()),_="affine"===I.type?_.mixedAdd(I):_.add(I))}}for(l=0;l=Math.ceil((e.bitLength()+1)/t.step)},f.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i";case"brand":return n(e,t)(r.entity)}}finally{t.delete(r)}throw Error("impossible")}};function i(e){return e.isReadonly?"readonly ":""}t.default=n(!1,new Set)},function(e,t,r){"use strict";var Buffer=r(7).Buffer;function n(e){if(e<0||e>9007199254740991||e%1!=0)throw new RangeError("value out of range")}function i(e){return n(e),e<253?1:e<=65535?3:e<=4294967295?5:9}e.exports={encode:function e(t,r,o){if(n(t),r||(r=Buffer.allocUnsafe(i(t))),!Buffer.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return o||(o=0),t<253?(r.writeUInt8(t,o),e.bytes=1):t<=65535?(r.writeUInt8(253,o),r.writeUInt16LE(t,o+1),e.bytes=3):t<=4294967295?(r.writeUInt8(254,o),r.writeUInt32LE(t,o+1),e.bytes=5):(r.writeUInt8(255,o),r.writeUInt32LE(t>>>0,o+1),r.writeUInt32LE(t/4294967296|0,o+5),e.bytes=9),r},decode:function e(t,r){if(!Buffer.isBuffer(t))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=t.readUInt8(r);if(i<253)return e.bytes=1,i;if(253===i)return e.bytes=3,t.readUInt16LE(r+1);if(254===i)return e.bytes=5,t.readUInt32LE(r+1);e.bytes=9;var o=t.readUInt32LE(r+1),a=4294967296*t.readUInt32LE(r+5)+o;return n(a),a},encodingLength:i}},function(e,t,r){(function(Buffer){var t=r(104),n=r(15),i=r(22),BigInteger=r(37);function o(e,t){n(i.tuple(i.BigInt,i.BigInt),arguments),this.r=e,this.s=t}o.parseCompact=function(e){n(i.BufferN(65),e);var t=e.readUInt8(0)-27;if(t!==(7&t))throw new Error("Invalid signature parameter");return{compressed:!!(4&t),i:3&t,signature:o.fromRSBuffer(e.slice(1))}},o.fromRSBuffer=function(e){return n(i.BufferN(64),e),new o(BigInteger.fromBuffer(e.slice(0,32)),BigInteger.fromBuffer(e.slice(32,64)))},o.fromDER=function(e){var r=t.decode(e);return new o(BigInteger.fromDERInteger(r.r),BigInteger.fromDERInteger(r.s))},o.parseScriptSignature=function(e){var t=e.readUInt8(e.length-1),r=-193&t;if(r<=0||r>=4)throw new Error("Invalid hashType "+t);return{signature:o.fromDER(e.slice(0,-1)),hashType:t}},o.prototype.toCompact=function(e,t){t&&(e+=4),e+=27;var r=Buffer.alloc(65);return r.writeUInt8(e,0),this.toRSBuffer(r,1),r},o.prototype.toDER=function(){var e=Buffer.from(this.r.toDERInteger()),r=Buffer.from(this.s.toDERInteger());return t.encode(e,r)},o.prototype.toRSBuffer=function(e,t){return e=e||Buffer.alloc(64),this.r.toBuffer(32).copy(e,t),this.s.toBuffer(32).copy(e,t+32),e},o.prototype.toScriptSignature=function(e){var t=-193&e;if(t<=0||t>=4)throw new Error("Invalid hashType "+e);var r=Buffer.alloc(1);return r.writeUInt8(e,0),Buffer.concat([this.toDER(),r])},e.exports=o}).call(this,r(9).Buffer)},function(e,t,r){var Point=r(195),n=r(196),i=r(398);e.exports={Curve:n,Point,getCurveByName:i}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getPublicKeyLabel=t.getAccountLabel=t.getAccountAddressN=void 0;var i=n(r(11)),o=r(12),a=r(8),s=r(6);function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.getAccountAddressN=function(e,t,r){if(!e)throw s.ERRORS.TypedError("Method_UnknownCoin");var n="number"==typeof t?t:0,a=function(e){for(var t=1;taccount #"+(n+1)+""}return"account #"+((0,o.fromHardened)(e[4])+1)};t.getPublicKeyLabel=function(e,t){var r=!1,n="Unknown coin";t?(n=t.label,r=t.segwit):n=(0,a.getCoinName)(e);var i=(0,o.fromHardened)(e[0]),s=e.length>=3?(0,o.fromHardened)(e[2]):-1,u=s+1,f="Export public key",c="";if(45342===i){var l=(0,o.fromHardened)(e[1]);u=(s=(0,o.fromHardened)(e[3]))+1,f="Export Copay ID of",48===l?c="multisig":44===l&&(c="legacy")}else c=48===i?n+" multisig":44===i&&r?n+" legacy":84===i&&r?n+" native segwit":n;return u>0?f+" of "+c+" account #"+u+"":f}},function(e,t,r){"use strict";var n=r(431);e.exports=Function.prototype.bind||n},function(e,t,r){"use strict";function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r1e3?"".concat(e.substring(0,1e3),"..."):e}))),[")"]));var s=i.apply(this,arguments);return s.then((function(e){return r&&(null==e?console.log("[trezor-link] Done ".concat(o,".").concat(t)):console.log("[trezor-link] Done ".concat(o,".").concat(t,", result "),e)),e}),(function(e){throw r&&console.error("[trezor-link] Error in ".concat(o,".").concat(t),e),e}))},r}},function(e,t,r){ /*** * @license * https://github.com/ealmansi/bchaddrjs @@ -15,33 +15,33 @@ var n=r(246),i=r(247),o=r(131);function a(){return Buffer.TYPED_ARRAY_SUPPORT?21 * Distributed under the MIT software license, see the accompanying * file LICENSE or http://www.opensource.org/licenses/mit-license.php. */ -var n=r(60),i=r(487),Buffer=r(9).Buffer,o={Legacy:"legacy",Bitpay:"bitpay",Cashaddr:"cashaddr"},a={Mainnet:"mainnet",Testnet:"testnet"},s={};function u(e){return h(e).format}function f(e){return h(e).network}function c(e){return h(e).type}s.P2PKH="p2pkh",s.P2SH="p2sh";var l={};function h(e){try{return function(e){try{var t=n.decode(e);if(21!==t.length)throw new p;var r=t[0],i=Array.prototype.slice.call(t,1);switch(r){case l[o.Legacy][a.Mainnet][s.P2PKH]:return{hash:i,format:o.Legacy,network:a.Mainnet,type:s.P2PKH};case l[o.Legacy][a.Mainnet][s.P2SH]:return{hash:i,format:o.Legacy,network:a.Mainnet,type:s.P2SH};case l[o.Legacy][a.Testnet][s.P2PKH]:return{hash:i,format:o.Legacy,network:a.Testnet,type:s.P2PKH};case l[o.Legacy][a.Testnet][s.P2SH]:return{hash:i,format:o.Legacy,network:a.Testnet,type:s.P2SH};case l[o.Bitpay][a.Mainnet][s.P2PKH]:return{hash:i,format:o.Bitpay,network:a.Mainnet,type:s.P2PKH};case l[o.Bitpay][a.Mainnet][s.P2SH]:return{hash:i,format:o.Bitpay,network:a.Mainnet,type:s.P2SH}}}catch(e){}throw new p}(e)}catch(e){}try{return function(e){if(-1!==e.indexOf(":"))try{return d(e)}catch(e){}else for(var t=["bitcoincash","bchtest","bchreg"],r=0;r>>0}))),e};t.convertMultisigPubKey=function(e,t){return t.multisig&&t.multisig.pubkeys&&t.multisig.pubkeys.forEach((function(t){"string"==typeof t.node&&(t.node=(0,i.xpubToHDNodeType)(t.node,e))})),t}},function(e,t,r){"use strict";t.__esModule=!0,t.UNREADABLE=t.WAIT_FOR_SELECTION=t.WORD=t.PASSPHRASE_ON_DEVICE=t.PASSPHRASE=t.PIN=t.BUTTON=t.LOADING=t.USED_ELSEWHERE=t.RELEASED=t.ACQUIRED=t.RELEASE=t.ACQUIRE=t.CHANGED=t.DISCONNECT=t.CONNECT_UNACQUIRED=t.CONNECT=void 0;t.CONNECT="device-connect";t.CONNECT_UNACQUIRED="device-connect_unacquired";t.DISCONNECT="device-disconnect";t.CHANGED="device-changed";t.ACQUIRE="device-acquire";t.RELEASE="device-release";t.ACQUIRED="device-acquired";t.RELEASED="device-released";t.USED_ELSEWHERE="device-used_elsewhere";t.LOADING="device-loading";t.BUTTON="button";t.PIN="pin";t.PASSPHRASE="passphrase";t.PASSPHRASE_ON_DEVICE="passphrase_on_device";t.WORD="word";t.WAIT_FOR_SELECTION="device-wait_for_selection";t.UNREADABLE="unreadable-device"},function(e,t,r){"use strict";t.__esModule=!0,t.POOL_RELAY_TYPE=t.CERTIFICATE_TYPE=t.ADDRESS_TYPE=t.NETWORK_IDS=t.PROTOCOL_MAGICS=void 0;var n=Object.freeze({mainnet:764824073,testnet:42});t.PROTOCOL_MAGICS=n;var i=Object.freeze({mainnet:1,testnet:0});t.NETWORK_IDS=i;var o=Object.freeze({Base:0,Pointer:4,Enterprise:6,Byron:8,Reward:14});t.ADDRESS_TYPE=o;var a=Object.freeze({StakeRegistration:0,StakeDeregistration:1,StakeDelegation:2,StakePoolRegistration:3});t.CERTIFICATE_TYPE=a;var s=Object.freeze({SingleHostIp:0,SingleHostName:1,MultipleHostName:2});t.POOL_RELAY_TYPE=s},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getReleases=t.getRelease=t.getFirmwareStatus=t.parseFirmware=void 0;var i,o=n(r(11)),a=r(129);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function u(e){for(var t=1;t>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function l(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;r=u(r,n,i,a,e[0],3614090360,7),a=u(a,r,n,i,e[1],3905402710,12),i=u(i,a,r,n,e[2],606105819,17),n=u(n,i,a,r,e[3],3250441966,22),r=u(r,n,i,a,e[4],4118548399,7),a=u(a,r,n,i,e[5],1200080426,12),i=u(i,a,r,n,e[6],2821735955,17),n=u(n,i,a,r,e[7],4249261313,22),r=u(r,n,i,a,e[8],1770035416,7),a=u(a,r,n,i,e[9],2336552879,12),i=u(i,a,r,n,e[10],4294925233,17),n=u(n,i,a,r,e[11],2304563134,22),r=u(r,n,i,a,e[12],1804603682,7),a=u(a,r,n,i,e[13],4254626195,12),i=u(i,a,r,n,e[14],2792965006,17),r=f(r,n=u(n,i,a,r,e[15],1236535329,22),i,a,e[1],4129170786,5),a=f(a,r,n,i,e[6],3225465664,9),i=f(i,a,r,n,e[11],643717713,14),n=f(n,i,a,r,e[0],3921069994,20),r=f(r,n,i,a,e[5],3593408605,5),a=f(a,r,n,i,e[10],38016083,9),i=f(i,a,r,n,e[15],3634488961,14),n=f(n,i,a,r,e[4],3889429448,20),r=f(r,n,i,a,e[9],568446438,5),a=f(a,r,n,i,e[14],3275163606,9),i=f(i,a,r,n,e[3],4107603335,14),n=f(n,i,a,r,e[8],1163531501,20),r=f(r,n,i,a,e[13],2850285829,5),a=f(a,r,n,i,e[2],4243563512,9),i=f(i,a,r,n,e[7],1735328473,14),r=c(r,n=f(n,i,a,r,e[12],2368359562,20),i,a,e[5],4294588738,4),a=c(a,r,n,i,e[8],2272392833,11),i=c(i,a,r,n,e[11],1839030562,16),n=c(n,i,a,r,e[14],4259657740,23),r=c(r,n,i,a,e[1],2763975236,4),a=c(a,r,n,i,e[4],1272893353,11),i=c(i,a,r,n,e[7],4139469664,16),n=c(n,i,a,r,e[10],3200236656,23),r=c(r,n,i,a,e[13],681279174,4),a=c(a,r,n,i,e[0],3936430074,11),i=c(i,a,r,n,e[3],3572445317,16),n=c(n,i,a,r,e[6],76029189,23),r=c(r,n,i,a,e[9],3654602809,4),a=c(a,r,n,i,e[12],3873151461,11),i=c(i,a,r,n,e[15],530742520,16),r=l(r,n=c(n,i,a,r,e[2],3299628645,23),i,a,e[0],4096336452,6),a=l(a,r,n,i,e[7],1126891415,10),i=l(i,a,r,n,e[14],2878612391,15),n=l(n,i,a,r,e[5],4237533241,21),r=l(r,n,i,a,e[12],1700485571,6),a=l(a,r,n,i,e[3],2399980690,10),i=l(i,a,r,n,e[10],4293915773,15),n=l(n,i,a,r,e[1],2240044497,21),r=l(r,n,i,a,e[8],1873313359,6),a=l(a,r,n,i,e[15],4264355552,10),i=l(i,a,r,n,e[6],2734768916,15),n=l(n,i,a,r,e[13],1309151649,21),r=l(r,n,i,a,e[4],4149444226,6),a=l(a,r,n,i,e[11],3174756917,10),i=l(i,a,r,n,e[2],718787259,15),n=l(n,i,a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(24))},function(e,t,r){"use strict";var n=r(43).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i>>32-t}function p(e,t,r,n,i,o,a,s){return d(e+(t^r^n)+o+a|0,s)+i|0}function y(e,t,r,n,i,o,a,s){return d(e+(t&r|~t&n)+o+a|0,s)+i|0}function g(e,t,r,n,i,o,a,s){return d(e+((t|~r)^n)+o+a|0,s)+i|0}function m(e,t,r,n,i,o,a,s){return d(e+(t&n|r&~n)+o+a|0,s)+i|0}function b(e,t,r,n,i,o,a,s){return d(e+(t^(r|~n))+o+a|0,s)+i|0}n(h,i),h.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,h=0|this._d,v=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,A=0|this._e,I=0;I<80;I+=1){var O,P;I<16?(O=p(r,n,i,h,v,e[a[I]],c[0],u[I]),P=b(w,_,E,S,A,e[s[I]],l[0],f[I])):I<32?(O=y(r,n,i,h,v,e[a[I]],c[1],u[I]),P=m(w,_,E,S,A,e[s[I]],l[1],f[I])):I<48?(O=g(r,n,i,h,v,e[a[I]],c[2],u[I]),P=g(w,_,E,S,A,e[s[I]],l[2],f[I])):I<64?(O=m(r,n,i,h,v,e[a[I]],c[3],u[I]),P=y(w,_,E,S,A,e[s[I]],l[3],f[I])):(O=b(r,n,i,h,v,e[a[I]],c[4],u[I]),P=p(w,_,E,S,A,e[s[I]],l[4],f[I])),r=v,v=h,h=d(i,10),i=n,n=O,w=A,A=S,S=d(E,10),E=_,_=P}var M=this._b+i+S|0;this._b=this._c+h+A|0,this._c=this._d+v+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=M},h.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=h},function(e,t,r){(t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r}).sha=r(256),t.sha1=r(257),t.sha224=r(258),t.sha256=r(139),t.sha384=r(259),t.sha512=r(140)},function(e,t,r){e.exports=i;var n=r(25).EventEmitter;function i(){n.call(this)}r(10)(i,n),i.Readable=r(89),i.Writable=r(266),i.Duplex=r(267),i.Transform=r(268),i.PassThrough=r(269),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function f(e){if(c(),0===n.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",f),e.on("error",f),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}},function(e,t,r){(t=e.exports=r(141)).Stream=t,t.Readable=t,t.Writable=r(91),t.Duplex=r(39),t.Transform=r(144),t.PassThrough=r(265)},function(e,t,r){var n=r(9),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=o),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t,n,i){var o=r(62);function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=m;var s,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:o.nextTick;m.WritableState=g;var f=Object.create(r(53));f.inherits=r(10);var c={deprecate:r(84)},l=r(142),Buffer=r(90).Buffer,h=i.Uint8Array||function(){};var d,p=r(143);function y(){}function g(e,t){s=s||r(39),e=e||{};var n=t instanceof s;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,f=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(f||0===f)?f:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?u(v,e,r,a,i):v(e,r,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function m(e){if(s=s||r(39),!(d.call(m,this)||this instanceof s))return new m(e);this._writableState=new g(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function b(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function v(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,b(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,c=r.encoding,l=r.callback;if(b(e,t,!1,t.objectMode?1:f.length,f,c,l),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)}))}function S(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}f.inherits(m,l),g.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(g.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof g)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,i=this._writableState,a=!1,s=!i.objectMode&&(n=e,Buffer.isBuffer(n)||n instanceof h);return s&&!Buffer.isBuffer(e)&&(e=function(e){return Buffer.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=y),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(n,a),i=!1),i}(this,i,e,r))&&(i.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Buffer.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(16),r(263).setImmediate,r(24))},function(e,t,r){"use strict";var n=r(27);function i(e){this.options=e,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=i,i.prototype._init=function(){},i.prototype.update=function(e){return 0===e.length?[]:"decrypt"===this.type?this._updateDecrypt(e):this._updateEncrypt(e)},i.prototype._buffer=function(e,t){for(var r=Math.min(this.buffer.length-this.bufferOff,e.length-t),n=0;n0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t=0||!r.umod(e.prime1)||!r.umod(e.prime2));return r}function o(e,r){var n=function(e){var r=i(e);return{blinder:r.toRed(t.mont(e.modulus)).redPow(new t(e.publicExponent)).fromRed(),unblinder:r.invm(e.modulus)}}(r),o=r.modulus.byteLength(),a=new t(e).mul(n.blinder).umod(r.modulus),s=a.toRed(t.mont(r.prime1)),u=a.toRed(t.mont(r.prime2)),f=r.coefficient,c=r.prime1,l=r.prime2,h=s.redPow(r.exponent1).fromRed(),d=u.redPow(r.exponent2).fromRed(),p=h.isub(d).imul(f).umod(c).imul(l);return d.iadd(p).imul(n.unblinder).umod(r.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n,i=t,o=r(99),a=r(168),s=r(28).assert;function u(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function f(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(315)}catch(e){n=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(e,t,r){var n=t;n.utils=r(30),n.common=r(55),n.sha=r(309),n.ripemd=r(313),n.hmac=r(314),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(e,t,r){"use strict";(function(t){var n,i=r(9),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var a=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(a[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,a.from&&a.from!==Uint8Array.from||(a.from=function(e,t,r){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return Buffer(e,t,r)}),a.alloc||(a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=Buffer(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(e){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this,r(16))},function(e,t,r){"use strict";const n=r(102).Reporter,i=r(56).EncoderBuffer,o=r(56).DecoderBuffer,a=r(27),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function f(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}e.exports=f;const c=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];f.prototype.clone=function(){const e=this._baseState,t={};c.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},f.prototype._wrap=function(){const e=this._baseState;u.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},f.prototype._init=function(e){const t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),a.equal(t.children.length,1,"Root node can have only one child")},f.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){f.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),s.forEach((function(e){f.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}})),f.prototype.use=function(e){a(e);const t=this._baseState;return a(null===t.use),t.use=e,this},f.prototype.optional=function(){return this._baseState.optional=!0,this},f.prototype.def=function(e){const t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},f.prototype.explicit=function(e){const t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},f.prototype.implicit=function(e){const t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},f.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},f.prototype.key=function(e){const t=this._baseState;return a(null===t.key),t.key=e,this},f.prototype.any=function(){return this._baseState.any=!0,this},f.prototype.choice=function(e){const t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},f.prototype.contains=function(e){const t=this._baseState;return a(null===t.use),t.contains=e,this},f.prototype._decode=function(e,t){const r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));let n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){let n=null;if(null!==r.explicit?n=r.explicit:null!==r.implicit?n=r.implicit:null!==r.tag&&(n=r.tag),null!==n||r.any){if(a=this._peekTag(e,n,r.any),e.isError(a))return a}else{const n=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(n)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){const t=this._decodeTag(e,r.explicit);if(e.isError(t))return t;e=t}const n=e.offset;if(null===r.use&&null===r.choice){let t;r.any&&(t=e.save());const n=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(n))return n;r.any?i=e.raw(t):e=n}if(t&&t.track&&null!==r.tag&&t.track(e.path(),n,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(i=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){const n=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(n,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},f.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},f.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},f.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,i=!1;return Object.keys(r.choice).some((function(o){const a=e.save(),s=r.choice[o];try{const r=s._decode(e,t);if(e.isError(r))return!1;n={type:o,value:r},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?n:e.error("Choice not matched")},f.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},f.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const i=this._encodeValue(e,t,r);return void 0===i||this._skipDefault(i,t,r)?void 0:i},f.prototype._encodeValue=function(e,t,r){const i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);let o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}let a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");const n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const r=this.clone();r._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(r){const n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),r))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){const e=null!==i.implicit?i.implicit:i.tag,r=null===i.implicit?"universal":"context";null===e?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(e,s,r,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},f.prototype._encodeChoice=function(e,t){const r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},f.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},f.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},f.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}},function(e,t,r){"use strict";const n=r(10);function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},function(e,t,r){"use strict";function n(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=n(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=n(t.tag)},function(e,t,r){"use strict";t.__esModule=!0,t.getBridgeInfo=t.parseBridgeJSON=void 0;var n={version:[],directory:"",packages:[],changelog:""};t.parseBridgeJSON=function(e){var t=e[0],r=t.version.join("."),i=JSON.parse(JSON.stringify(t).replace(/{version}/g,r)),o=i.directory,a=i.packages.map((function(e){return{name:e.name,platform:e.platform,url:""+o+e.url,signature:e.signature?""+o+e.signature:void 0}}));return n.version=i.version,n.directory=o,n.packages=a,n};t.getBridgeInfo=function(){return n}},function(e,t,r){var Buffer=r(7).Buffer;e.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return 0!==r&&(6+t+r===e.length&&(!(128&e[4])&&(!(t>1&&0===e[4]&&!(128&e[5]))&&(!(128&e[t+6])&&!(r>1&&0===e[t+6]&&!(128&e[t+7]))))))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,n=t.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(n>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}}},function(e,t){var r={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var n in r.Null=r.Nil,r)r[n].toJSON=function(e){return e}.bind(null,n);e.exports=r},function(e,t,r){var n=r(19).decompile,i=r(108),o=r(367),a=r(109),s=r(110),u=r(372),f=r(375),c=r(377),l=r(379),h={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(e,t){var r=n(e);return s.input.check(r)?h.P2PKH:u.input.check(r,t)?h.P2SH:i.input.check(r,t)?h.MULTISIG:a.input.check(r)?h.P2PK:h.NONSTANDARD},classifyOutput:function(e){if(f.output.check(e))return h.P2WPKH;if(c.output.check(e))return h.P2WSH;if(s.output.check(e))return h.P2PKH;if(u.output.check(e))return h.P2SH;var t=n(e);return i.output.check(t)?h.MULTISIG:a.output.check(t)?h.P2PK:l.output.check(t)?h.WITNESS_COMMITMENT:o.output.check(t)?h.NULLDATA:h.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return f.input.check(r)?h.P2WPKH:c.input.check(r,t)?h.P2WSH:h.NONSTANDARD},multisig:i,nullData:o,pubKey:a,pubKeyHash:s,scriptHash:u,witnessPubKeyHash:f,witnessScriptHash:c,witnessCommitment:l,types:h}},function(e,t,r){e.exports={input:r(366),output:r(190)}},function(e,t,r){e.exports={input:r(368),output:r(369)}},function(e,t,r){e.exports={input:r(370),output:r(371)}},function(e,t,r){var n=r(187),i=r(72),BigInteger=r(37),o=r(387).Int64LE;function a(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function s(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return a((n*=4294967296)+r,9007199254740991),n+r}function u(e,t,r){return a(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:s,readUInt64LEasString:function(e,t){try{return s(e,t).toString()}catch(s){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4),i=new BigInteger(Number(4294967296).toString()),o=new BigInteger(r.toString()),a=new BigInteger(n.toString()).multiply(i);return o.add(a).toString()}},readInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readInt32LE(t+4);return(n*=4294967296)+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:u,writeUInt64LEasString:function(e,t,r){return"string"!=typeof t?u(e,t,r):(new o(t).toBuffer().copy(e,r),r+8)},writeInt64LE:function(e,t,r){for(var n=new o(t).toArray(),i=0;i<8;i++)e.writeUInt8(n[i],r+i);return r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},function(e,t,r){"use strict";(function(t){var n=r(383); +var n=r(59),i=r(487),Buffer=r(9).Buffer,o={Legacy:"legacy",Bitpay:"bitpay",Cashaddr:"cashaddr"},a={Mainnet:"mainnet",Testnet:"testnet"},s={};function u(e){return h(e).format}function f(e){return h(e).network}function c(e){return h(e).type}s.P2PKH="p2pkh",s.P2SH="p2sh";var l={};function h(e){try{return function(e){try{var t=n.decode(e);if(21!==t.length)throw new p;var r=t[0],i=Array.prototype.slice.call(t,1);switch(r){case l[o.Legacy][a.Mainnet][s.P2PKH]:return{hash:i,format:o.Legacy,network:a.Mainnet,type:s.P2PKH};case l[o.Legacy][a.Mainnet][s.P2SH]:return{hash:i,format:o.Legacy,network:a.Mainnet,type:s.P2SH};case l[o.Legacy][a.Testnet][s.P2PKH]:return{hash:i,format:o.Legacy,network:a.Testnet,type:s.P2PKH};case l[o.Legacy][a.Testnet][s.P2SH]:return{hash:i,format:o.Legacy,network:a.Testnet,type:s.P2SH};case l[o.Bitpay][a.Mainnet][s.P2PKH]:return{hash:i,format:o.Bitpay,network:a.Mainnet,type:s.P2PKH};case l[o.Bitpay][a.Mainnet][s.P2SH]:return{hash:i,format:o.Bitpay,network:a.Mainnet,type:s.P2SH}}}catch(e){}throw new p}(e)}catch(e){}try{return function(e){if(-1!==e.indexOf(":"))try{return d(e)}catch(e){}else for(var t=["bitcoincash","bchtest","bchreg"],r=0;r>>32-t}function u(e,t,r,n,i,o,a){return s(e+(t&r|~t&n)+i+o|0,a)+t|0}function f(e,t,r,n,i,o,a){return s(e+(t&n|r&~n)+i+o|0,a)+t|0}function c(e,t,r,n,i,o,a){return s(e+(t^r^n)+i+o|0,a)+t|0}function l(e,t,r,n,i,o,a){return s(e+(r^(t|~n))+i+o|0,a)+t|0}n(a,i),a.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);var r=this._a,n=this._b,i=this._c,a=this._d;r=u(r,n,i,a,e[0],3614090360,7),a=u(a,r,n,i,e[1],3905402710,12),i=u(i,a,r,n,e[2],606105819,17),n=u(n,i,a,r,e[3],3250441966,22),r=u(r,n,i,a,e[4],4118548399,7),a=u(a,r,n,i,e[5],1200080426,12),i=u(i,a,r,n,e[6],2821735955,17),n=u(n,i,a,r,e[7],4249261313,22),r=u(r,n,i,a,e[8],1770035416,7),a=u(a,r,n,i,e[9],2336552879,12),i=u(i,a,r,n,e[10],4294925233,17),n=u(n,i,a,r,e[11],2304563134,22),r=u(r,n,i,a,e[12],1804603682,7),a=u(a,r,n,i,e[13],4254626195,12),i=u(i,a,r,n,e[14],2792965006,17),r=f(r,n=u(n,i,a,r,e[15],1236535329,22),i,a,e[1],4129170786,5),a=f(a,r,n,i,e[6],3225465664,9),i=f(i,a,r,n,e[11],643717713,14),n=f(n,i,a,r,e[0],3921069994,20),r=f(r,n,i,a,e[5],3593408605,5),a=f(a,r,n,i,e[10],38016083,9),i=f(i,a,r,n,e[15],3634488961,14),n=f(n,i,a,r,e[4],3889429448,20),r=f(r,n,i,a,e[9],568446438,5),a=f(a,r,n,i,e[14],3275163606,9),i=f(i,a,r,n,e[3],4107603335,14),n=f(n,i,a,r,e[8],1163531501,20),r=f(r,n,i,a,e[13],2850285829,5),a=f(a,r,n,i,e[2],4243563512,9),i=f(i,a,r,n,e[7],1735328473,14),r=c(r,n=f(n,i,a,r,e[12],2368359562,20),i,a,e[5],4294588738,4),a=c(a,r,n,i,e[8],2272392833,11),i=c(i,a,r,n,e[11],1839030562,16),n=c(n,i,a,r,e[14],4259657740,23),r=c(r,n,i,a,e[1],2763975236,4),a=c(a,r,n,i,e[4],1272893353,11),i=c(i,a,r,n,e[7],4139469664,16),n=c(n,i,a,r,e[10],3200236656,23),r=c(r,n,i,a,e[13],681279174,4),a=c(a,r,n,i,e[0],3936430074,11),i=c(i,a,r,n,e[3],3572445317,16),n=c(n,i,a,r,e[6],76029189,23),r=c(r,n,i,a,e[9],3654602809,4),a=c(a,r,n,i,e[12],3873151461,11),i=c(i,a,r,n,e[15],530742520,16),r=l(r,n=c(n,i,a,r,e[2],3299628645,23),i,a,e[0],4096336452,6),a=l(a,r,n,i,e[7],1126891415,10),i=l(i,a,r,n,e[14],2878612391,15),n=l(n,i,a,r,e[5],4237533241,21),r=l(r,n,i,a,e[12],1700485571,6),a=l(a,r,n,i,e[3],2399980690,10),i=l(i,a,r,n,e[10],4293915773,15),n=l(n,i,a,r,e[1],2240044497,21),r=l(r,n,i,a,e[8],1873313359,6),a=l(a,r,n,i,e[15],4264355552,10),i=l(i,a,r,n,e[6],2734768916,15),n=l(n,i,a,r,e[13],1309151649,21),r=l(r,n,i,a,e[4],4149444226,6),a=l(a,r,n,i,e[11],3174756917,10),i=l(i,a,r,n,e[2],718787259,15),n=l(n,i,a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0},a.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e},e.exports=a},function(e,t,r){(function(t){function r(e){try{if(!t.localStorage)return!1}catch(e){return!1}var r=t.localStorage[e];return null!=r&&"true"===String(r).toLowerCase()}e.exports=function(e,t){if(r("noDeprecation"))return e;var n=!1;return function(){if(!n){if(r("throwDeprecation"))throw new Error(t);r("traceDeprecation")?console.trace(t):console.warn(t),n=!0}return e.apply(this,arguments)}}}).call(this,r(24))},function(e,t,r){"use strict";var n=r(43).codes.ERR_STREAM_PREMATURE_CLOSE;function i(){}e.exports=function e(t,r,o){if("function"==typeof r)return e(t,null,r);r||(r={}),o=function(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i>>32-t}function p(e,t,r,n,i,o,a,s){return d(e+(t^r^n)+o+a|0,s)+i|0}function g(e,t,r,n,i,o,a,s){return d(e+(t&r|~t&n)+o+a|0,s)+i|0}function y(e,t,r,n,i,o,a,s){return d(e+((t|~r)^n)+o+a|0,s)+i|0}function m(e,t,r,n,i,o,a,s){return d(e+(t&n|r&~n)+o+a|0,s)+i|0}function b(e,t,r,n,i,o,a,s){return d(e+(t^(r|~n))+o+a|0,s)+i|0}n(h,i),h.prototype._update=function(){for(var e=o,t=0;t<16;++t)e[t]=this._block.readInt32LE(4*t);for(var r=0|this._a,n=0|this._b,i=0|this._c,h=0|this._d,v=0|this._e,w=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,A=0|this._e,I=0;I<80;I+=1){var O,P;I<16?(O=p(r,n,i,h,v,e[a[I]],c[0],u[I]),P=b(w,_,E,S,A,e[s[I]],l[0],f[I])):I<32?(O=g(r,n,i,h,v,e[a[I]],c[1],u[I]),P=m(w,_,E,S,A,e[s[I]],l[1],f[I])):I<48?(O=y(r,n,i,h,v,e[a[I]],c[2],u[I]),P=y(w,_,E,S,A,e[s[I]],l[2],f[I])):I<64?(O=m(r,n,i,h,v,e[a[I]],c[3],u[I]),P=g(w,_,E,S,A,e[s[I]],l[3],f[I])):(O=b(r,n,i,h,v,e[a[I]],c[4],u[I]),P=p(w,_,E,S,A,e[s[I]],l[4],f[I])),r=v,v=h,h=d(i,10),i=n,n=O,w=A,A=S,S=d(E,10),E=_,_=P}var M=this._b+i+S|0;this._b=this._c+h+A|0,this._c=this._d+v+w|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=M},h.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=Buffer.alloc?Buffer.alloc(20):new Buffer(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e},e.exports=h},function(e,t,r){(t=e.exports=function(e){e=e.toLowerCase();var r=t[e];if(!r)throw new Error(e+" is not supported (we accept pull requests)");return new r}).sha=r(255),t.sha1=r(256),t.sha224=r(257),t.sha256=r(138),t.sha384=r(258),t.sha512=r(139)},function(e,t,r){e.exports=i;var n=r(25).EventEmitter;function i(){n.call(this)}r(10)(i,n),i.Readable=r(88),i.Writable=r(265),i.Duplex=r(266),i.Transform=r(267),i.PassThrough=r(268),i.Stream=i,i.prototype.pipe=function(e,t){var r=this;function i(t){e.writable&&!1===e.write(t)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),e.on("drain",o),e._isStdio||t&&!1===t.end||(r.on("end",s),r.on("close",u));var a=!1;function s(){a||(a=!0,e.end())}function u(){a||(a=!0,"function"==typeof e.destroy&&e.destroy())}function f(e){if(c(),0===n.listenerCount(this,"error"))throw e}function c(){r.removeListener("data",i),e.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",f),e.removeListener("error",f),r.removeListener("end",c),r.removeListener("close",c),e.removeListener("close",c)}return r.on("error",f),e.on("error",f),r.on("end",c),r.on("close",c),e.on("close",c),e.emit("pipe",r),e}},function(e,t,r){(t=e.exports=r(140)).Stream=t,t.Readable=t,t.Writable=r(90),t.Duplex=r(39),t.Transform=r(143),t.PassThrough=r(264)},function(e,t,r){var n=r(9),Buffer=n.Buffer;function i(e,t){for(var r in e)t[r]=e[r]}function o(e,t,r){return Buffer(e,t,r)}Buffer.from&&Buffer.alloc&&Buffer.allocUnsafe&&Buffer.allocUnsafeSlow?e.exports=n:(i(n,t),t.Buffer=o),i(Buffer,o),o.from=function(e,t,r){if("number"==typeof e)throw new TypeError("Argument must not be a number");return Buffer(e,t,r)},o.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError("Argument must be a number");var n=Buffer(e);return void 0!==t?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n},o.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return Buffer(e)},o.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return n.SlowBuffer(e)}},function(e,t,r){"use strict";(function(t,n,i){var o=r(61);function a(e){var t=this;this.next=null,this.entry=null,this.finish=function(){!function(e,t,r){var n=e.entry;e.entry=null;for(;n;){var i=n.callback;t.pendingcb--,i(r),n=n.next}t.corkedRequestsFree?t.corkedRequestsFree.next=e:t.corkedRequestsFree=e}(t,e)}}e.exports=m;var s,u=!t.browser&&["v0.10","v0.9."].indexOf(t.version.slice(0,5))>-1?n:o.nextTick;m.WritableState=y;var f=Object.create(r(53));f.inherits=r(10);var c={deprecate:r(83)},l=r(141),Buffer=r(89).Buffer,h=i.Uint8Array||function(){};var d,p=r(142);function g(){}function y(e,t){s=s||r(39),e=e||{};var n=t instanceof s;this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.writableObjectMode);var i=e.highWaterMark,f=e.writableHighWaterMark,c=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(f||0===f)?f:c,this.highWaterMark=Math.floor(this.highWaterMark),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var l=!1===e.decodeStrings;this.decodeStrings=!l,this.defaultEncoding=e.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(e){!function(e,t){var r=e._writableState,n=r.sync,i=r.writecb;if(function(e){e.writing=!1,e.writecb=null,e.length-=e.writelen,e.writelen=0}(r),t)!function(e,t,r,n,i){--t.pendingcb,r?(o.nextTick(i,n),o.nextTick(S,e,t),e._writableState.errorEmitted=!0,e.emit("error",n)):(i(n),e._writableState.errorEmitted=!0,e.emit("error",n),S(e,t))}(e,r,n,t,i);else{var a=_(r);a||r.corked||r.bufferProcessing||!r.bufferedRequest||w(e,r),n?u(v,e,r,a,i):v(e,r,a,i)}}(t,e)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.bufferedRequestCount=0,this.corkedRequestsFree=new a(this)}function m(e){if(s=s||r(39),!(d.call(m,this)||this instanceof s))return new m(e);this._writableState=new y(e,this),this.writable=!0,e&&("function"==typeof e.write&&(this._write=e.write),"function"==typeof e.writev&&(this._writev=e.writev),"function"==typeof e.destroy&&(this._destroy=e.destroy),"function"==typeof e.final&&(this._final=e.final)),l.call(this)}function b(e,t,r,n,i,o,a){t.writelen=n,t.writecb=a,t.writing=!0,t.sync=!0,r?e._writev(i,t.onwrite):e._write(i,o,t.onwrite),t.sync=!1}function v(e,t,r,n){r||function(e,t){0===t.length&&t.needDrain&&(t.needDrain=!1,e.emit("drain"))}(e,t),t.pendingcb--,n(),S(e,t)}function w(e,t){t.bufferProcessing=!0;var r=t.bufferedRequest;if(e._writev&&r&&r.next){var n=t.bufferedRequestCount,i=new Array(n),o=t.corkedRequestsFree;o.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,b(e,t,!0,t.length,i,"",o.finish),t.pendingcb++,t.lastBufferedRequest=null,o.next?(t.corkedRequestsFree=o.next,o.next=null):t.corkedRequestsFree=new a(t),t.bufferedRequestCount=0}else{for(;r;){var f=r.chunk,c=r.encoding,l=r.callback;if(b(e,t,!1,t.objectMode?1:f.length,f,c,l),r=r.next,t.bufferedRequestCount--,t.writing)break}null===r&&(t.lastBufferedRequest=null)}t.bufferedRequest=r,t.bufferProcessing=!1}function _(e){return e.ending&&0===e.length&&null===e.bufferedRequest&&!e.finished&&!e.writing}function E(e,t){e._final((function(r){t.pendingcb--,r&&e.emit("error",r),t.prefinished=!0,e.emit("prefinish"),S(e,t)}))}function S(e,t){var r=_(t);return r&&(!function(e,t){t.prefinished||t.finalCalled||("function"==typeof e._final?(t.pendingcb++,t.finalCalled=!0,o.nextTick(E,e,t)):(t.prefinished=!0,e.emit("prefinish")))}(e,t),0===t.pendingcb&&(t.finished=!0,e.emit("finish"))),r}f.inherits(m,l),y.prototype.getBuffer=function(){for(var e=this.bufferedRequest,t=[];e;)t.push(e),e=e.next;return t},function(){try{Object.defineProperty(y.prototype,"buffer",{get:c.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(e){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(d=Function.prototype[Symbol.hasInstance],Object.defineProperty(m,Symbol.hasInstance,{value:function(e){return!!d.call(this,e)||this===m&&(e&&e._writableState instanceof y)}})):d=function(e){return e instanceof this},m.prototype.pipe=function(){this.emit("error",new Error("Cannot pipe, not readable"))},m.prototype.write=function(e,t,r){var n,i=this._writableState,a=!1,s=!i.objectMode&&(n=e,Buffer.isBuffer(n)||n instanceof h);return s&&!Buffer.isBuffer(e)&&(e=function(e){return Buffer.from(e)}(e)),"function"==typeof t&&(r=t,t=null),s?t="buffer":t||(t=i.defaultEncoding),"function"!=typeof r&&(r=g),i.ended?function(e,t){var r=new Error("write after end");e.emit("error",r),o.nextTick(t,r)}(this,r):(s||function(e,t,r,n){var i=!0,a=!1;return null===r?a=new TypeError("May not write null values to stream"):"string"==typeof r||void 0===r||t.objectMode||(a=new TypeError("Invalid non-string/buffer chunk")),a&&(e.emit("error",a),o.nextTick(n,a),i=!1),i}(this,i,e,r))&&(i.pendingcb++,a=function(e,t,r,n,i,o){if(!r){var a=function(e,t,r){e.objectMode||!1===e.decodeStrings||"string"!=typeof t||(t=Buffer.from(t,r));return t}(t,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=t.objectMode?1:n.length;t.length+=s;var u=t.length-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(m.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),m.prototype._write=function(e,t,r){r(new Error("_write() is not implemented"))},m.prototype._writev=null,m.prototype.end=function(e,t,r){var n=this._writableState;"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),n.corked&&(n.corked=1,this.uncork()),n.ending||n.finished||function(e,t,r){t.ending=!0,S(e,t),r&&(t.finished?o.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,n,r)},Object.defineProperty(m.prototype,"destroyed",{get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),m.prototype.destroy=p.destroy,m.prototype._undestroy=p.undestroy,m.prototype._destroy=function(e,t){this.end(),t(e)}}).call(this,r(16),r(262).setImmediate,r(24))},function(e,t,r){"use strict";var n=r(27);function i(e){this.options=e,this.type=this.options.type,this.blockSize=8,this._init(),this.buffer=new Array(this.blockSize),this.bufferOff=0}e.exports=i,i.prototype._init=function(){},i.prototype.update=function(e){return 0===e.length?[]:"decrypt"===this.type?this._updateDecrypt(e):this._updateEncrypt(e)},i.prototype._buffer=function(e,t){for(var r=Math.min(this.buffer.length-this.bufferOff,e.length-t),n=0;n0;n--)t+=this._buffer(e,t),r+=this._flushBuffer(i,r);return t+=this._buffer(e,t),i},i.prototype.final=function(e){var t,r;return e&&(t=this.update(e)),r="encrypt"===this.type?this._finalEncrypt():this._finalDecrypt(),t?t.concat(r):r},i.prototype._pad=function(e,t){if(0===t)return!1;for(;t=0||!r.umod(e.prime1)||!r.umod(e.prime2));return r}function o(e,r){var n=function(e){var r=i(e);return{blinder:r.toRed(t.mont(e.modulus)).redPow(new t(e.publicExponent)).fromRed(),unblinder:r.invm(e.modulus)}}(r),o=r.modulus.byteLength(),a=new t(e).mul(n.blinder).umod(r.modulus),s=a.toRed(t.mont(r.prime1)),u=a.toRed(t.mont(r.prime2)),f=r.coefficient,c=r.prime1,l=r.prime2,h=s.redPow(r.exponent1).fromRed(),d=u.redPow(r.exponent2).fromRed(),p=h.isub(d).imul(f).umod(c).imul(l);return d.iadd(p).imul(n.unblinder).umod(r.modulus).toArrayLike(Buffer,"be",o)}o.getr=i,e.exports=o}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n,i=t,o=r(98),a=r(167),s=r(28).assert;function u(e){"short"===e.type?this.curve=new a.short(e):"edwards"===e.type?this.curve=new a.edwards(e):this.curve=new a.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,s(this.g.validate(),"Invalid curve"),s(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function f(e,t){Object.defineProperty(i,e,{configurable:!0,enumerable:!0,get:function(){var r=new u(t);return Object.defineProperty(i,e,{configurable:!0,enumerable:!0,value:r}),r}})}i.PresetCurve=u,f("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:o.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),f("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:o.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),f("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:o.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),f("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:o.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),f("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:o.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),f("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["9"]}),f("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:o.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{n=r(314)}catch(e){n=void 0}f("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:o.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",n]})},function(e,t,r){var n=t;n.utils=r(30),n.common=r(55),n.sha=r(308),n.ripemd=r(312),n.hmac=r(313),n.sha1=n.sha.sha1,n.sha256=n.sha.sha256,n.sha224=n.sha.sha224,n.sha384=n.sha.sha384,n.sha512=n.sha.sha512,n.ripemd160=n.ripemd.ripemd160},function(e,t,r){"use strict";(function(t){var n,i=r(9),Buffer=i.Buffer,o={};for(n in i)i.hasOwnProperty(n)&&"SlowBuffer"!==n&&"Buffer"!==n&&(o[n]=i[n]);var a=o.Buffer={};for(n in Buffer)Buffer.hasOwnProperty(n)&&"allocUnsafe"!==n&&"allocUnsafeSlow"!==n&&(a[n]=Buffer[n]);if(o.Buffer.prototype=Buffer.prototype,a.from&&a.from!==Uint8Array.from||(a.from=function(e,t,r){if("number"==typeof e)throw new TypeError('The "value" argument must not be of type number. Received type '+typeof e);if(e&&void 0===e.length)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof e);return Buffer(e,t,r)}),a.alloc||(a.alloc=function(e,t,r){if("number"!=typeof e)throw new TypeError('The "size" argument must be of type number. Received type '+typeof e);if(e<0||e>=2*(1<<30))throw new RangeError('The value "'+e+'" is invalid for option "size"');var n=Buffer(e);return t&&0!==t.length?"string"==typeof r?n.fill(t,r):n.fill(t):n.fill(0),n}),!o.kStringMaxLength)try{o.kStringMaxLength=t.binding("buffer").kStringMaxLength}catch(e){}o.constants||(o.constants={MAX_LENGTH:o.kMaxLength},o.kStringMaxLength&&(o.constants.MAX_STRING_LENGTH=o.kStringMaxLength)),e.exports=o}).call(this,r(16))},function(e,t,r){"use strict";const n=r(101).Reporter,i=r(56).EncoderBuffer,o=r(56).DecoderBuffer,a=r(27),s=["seq","seqof","set","setof","objid","bool","gentime","utctime","null_","enum","int","objDesc","bitstr","bmpstr","charstr","genstr","graphstr","ia5str","iso646str","numstr","octstr","printstr","t61str","unistr","utf8str","videostr"],u=["key","obj","use","optional","explicit","implicit","def","choice","any","contains"].concat(s);function f(e,t,r){const n={};this._baseState=n,n.name=r,n.enc=e,n.parent=t||null,n.children=null,n.tag=null,n.args=null,n.reverseArgs=null,n.choice=null,n.optional=!1,n.any=!1,n.obj=!1,n.use=null,n.useDecoder=null,n.key=null,n.default=null,n.explicit=null,n.implicit=null,n.contains=null,n.parent||(n.children=[],this._wrap())}e.exports=f;const c=["enc","parent","children","tag","args","reverseArgs","choice","optional","any","obj","use","alteredUse","key","default","explicit","implicit","contains"];f.prototype.clone=function(){const e=this._baseState,t={};c.forEach((function(r){t[r]=e[r]}));const r=new this.constructor(t.parent);return r._baseState=t,r},f.prototype._wrap=function(){const e=this._baseState;u.forEach((function(t){this[t]=function(){const r=new this.constructor(this);return e.children.push(r),r[t].apply(r,arguments)}}),this)},f.prototype._init=function(e){const t=this._baseState;a(null===t.parent),e.call(this),t.children=t.children.filter((function(e){return e._baseState.parent===this}),this),a.equal(t.children.length,1,"Root node can have only one child")},f.prototype._useArgs=function(e){const t=this._baseState,r=e.filter((function(e){return e instanceof this.constructor}),this);e=e.filter((function(e){return!(e instanceof this.constructor)}),this),0!==r.length&&(a(null===t.children),t.children=r,r.forEach((function(e){e._baseState.parent=this}),this)),0!==e.length&&(a(null===t.args),t.args=e,t.reverseArgs=e.map((function(e){if("object"!=typeof e||e.constructor!==Object)return e;const t={};return Object.keys(e).forEach((function(r){r==(0|r)&&(r|=0);const n=e[r];t[n]=r})),t})))},["_peekTag","_decodeTag","_use","_decodeStr","_decodeObjid","_decodeTime","_decodeNull","_decodeInt","_decodeBool","_decodeList","_encodeComposite","_encodeStr","_encodeObjid","_encodeTime","_encodeNull","_encodeInt","_encodeBool"].forEach((function(e){f.prototype[e]=function(){const t=this._baseState;throw new Error(e+" not implemented for encoding: "+t.enc)}})),s.forEach((function(e){f.prototype[e]=function(){const t=this._baseState,r=Array.prototype.slice.call(arguments);return a(null===t.tag),t.tag=e,this._useArgs(r),this}})),f.prototype.use=function(e){a(e);const t=this._baseState;return a(null===t.use),t.use=e,this},f.prototype.optional=function(){return this._baseState.optional=!0,this},f.prototype.def=function(e){const t=this._baseState;return a(null===t.default),t.default=e,t.optional=!0,this},f.prototype.explicit=function(e){const t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.explicit=e,this},f.prototype.implicit=function(e){const t=this._baseState;return a(null===t.explicit&&null===t.implicit),t.implicit=e,this},f.prototype.obj=function(){const e=this._baseState,t=Array.prototype.slice.call(arguments);return e.obj=!0,0!==t.length&&this._useArgs(t),this},f.prototype.key=function(e){const t=this._baseState;return a(null===t.key),t.key=e,this},f.prototype.any=function(){return this._baseState.any=!0,this},f.prototype.choice=function(e){const t=this._baseState;return a(null===t.choice),t.choice=e,this._useArgs(Object.keys(e).map((function(t){return e[t]}))),this},f.prototype.contains=function(e){const t=this._baseState;return a(null===t.use),t.contains=e,this},f.prototype._decode=function(e,t){const r=this._baseState;if(null===r.parent)return e.wrapResult(r.children[0]._decode(e,t));let n,i=r.default,a=!0,s=null;if(null!==r.key&&(s=e.enterKey(r.key)),r.optional){let n=null;if(null!==r.explicit?n=r.explicit:null!==r.implicit?n=r.implicit:null!==r.tag&&(n=r.tag),null!==n||r.any){if(a=this._peekTag(e,n,r.any),e.isError(a))return a}else{const n=e.save();try{null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t),a=!0}catch(e){a=!1}e.restore(n)}}if(r.obj&&a&&(n=e.enterObject()),a){if(null!==r.explicit){const t=this._decodeTag(e,r.explicit);if(e.isError(t))return t;e=t}const n=e.offset;if(null===r.use&&null===r.choice){let t;r.any&&(t=e.save());const n=this._decodeTag(e,null!==r.implicit?r.implicit:r.tag,r.any);if(e.isError(n))return n;r.any?i=e.raw(t):e=n}if(t&&t.track&&null!==r.tag&&t.track(e.path(),n,e.length,"tagged"),t&&t.track&&null!==r.tag&&t.track(e.path(),e.offset,e.length,"content"),r.any||(i=null===r.choice?this._decodeGeneric(r.tag,e,t):this._decodeChoice(e,t)),e.isError(i))return i;if(r.any||null!==r.choice||null===r.children||r.children.forEach((function(r){r._decode(e,t)})),r.contains&&("octstr"===r.tag||"bitstr"===r.tag)){const n=new o(i);i=this._getUse(r.contains,e._reporterState.obj)._decode(n,t)}}return r.obj&&a&&(i=e.leaveObject(n)),null===r.key||null===i&&!0!==a?null!==s&&e.exitKey(s):e.leaveKey(s,r.key,i),i},f.prototype._decodeGeneric=function(e,t,r){const n=this._baseState;return"seq"===e||"set"===e?null:"seqof"===e||"setof"===e?this._decodeList(t,e,n.args[0],r):/str$/.test(e)?this._decodeStr(t,e,r):"objid"===e&&n.args?this._decodeObjid(t,n.args[0],n.args[1],r):"objid"===e?this._decodeObjid(t,null,null,r):"gentime"===e||"utctime"===e?this._decodeTime(t,e,r):"null_"===e?this._decodeNull(t,r):"bool"===e?this._decodeBool(t,r):"objDesc"===e?this._decodeStr(t,e,r):"int"===e||"enum"===e?this._decodeInt(t,n.args&&n.args[0],r):null!==n.use?this._getUse(n.use,t._reporterState.obj)._decode(t,r):t.error("unknown tag: "+e)},f.prototype._getUse=function(e,t){const r=this._baseState;return r.useDecoder=this._use(e,t),a(null===r.useDecoder._baseState.parent),r.useDecoder=r.useDecoder._baseState.children[0],r.implicit!==r.useDecoder._baseState.implicit&&(r.useDecoder=r.useDecoder.clone(),r.useDecoder._baseState.implicit=r.implicit),r.useDecoder},f.prototype._decodeChoice=function(e,t){const r=this._baseState;let n=null,i=!1;return Object.keys(r.choice).some((function(o){const a=e.save(),s=r.choice[o];try{const r=s._decode(e,t);if(e.isError(r))return!1;n={type:o,value:r},i=!0}catch(t){return e.restore(a),!1}return!0}),this),i?n:e.error("Choice not matched")},f.prototype._createEncoderBuffer=function(e){return new i(e,this.reporter)},f.prototype._encode=function(e,t,r){const n=this._baseState;if(null!==n.default&&n.default===e)return;const i=this._encodeValue(e,t,r);return void 0===i||this._skipDefault(i,t,r)?void 0:i},f.prototype._encodeValue=function(e,t,r){const i=this._baseState;if(null===i.parent)return i.children[0]._encode(e,t||new n);let o=null;if(this.reporter=t,i.optional&&void 0===e){if(null===i.default)return;e=i.default}let a=null,s=!1;if(i.any)o=this._createEncoderBuffer(e);else if(i.choice)o=this._encodeChoice(e,t);else if(i.contains)a=this._getUse(i.contains,r)._encode(e,t),s=!0;else if(i.children)a=i.children.map((function(r){if("null_"===r._baseState.tag)return r._encode(null,t,e);if(null===r._baseState.key)return t.error("Child should have a key");const n=t.enterKey(r._baseState.key);if("object"!=typeof e)return t.error("Child expected, but input is not object");const i=r._encode(e[r._baseState.key],t,e);return t.leaveKey(n),i}),this).filter((function(e){return e})),a=this._createEncoderBuffer(a);else if("seqof"===i.tag||"setof"===i.tag){if(!i.args||1!==i.args.length)return t.error("Too many args for : "+i.tag);if(!Array.isArray(e))return t.error("seqof/setof, but data is not Array");const r=this.clone();r._baseState.implicit=null,a=this._createEncoderBuffer(e.map((function(r){const n=this._baseState;return this._getUse(n.args[0],e)._encode(r,t)}),r))}else null!==i.use?o=this._getUse(i.use,r)._encode(e,t):(a=this._encodePrimitive(i.tag,e),s=!0);if(!i.any&&null===i.choice){const e=null!==i.implicit?i.implicit:i.tag,r=null===i.implicit?"universal":"context";null===e?null===i.use&&t.error("Tag could be omitted only for .use()"):null===i.use&&(o=this._encodeComposite(e,s,r,a))}return null!==i.explicit&&(o=this._encodeComposite(i.explicit,!1,"context",o)),o},f.prototype._encodeChoice=function(e,t){const r=this._baseState,n=r.choice[e.type];return n||a(!1,e.type+" not found in "+JSON.stringify(Object.keys(r.choice))),n._encode(e.value,t)},f.prototype._encodePrimitive=function(e,t){const r=this._baseState;if(/str$/.test(e))return this._encodeStr(t,e);if("objid"===e&&r.args)return this._encodeObjid(t,r.reverseArgs[0],r.args[1]);if("objid"===e)return this._encodeObjid(t,null,null);if("gentime"===e||"utctime"===e)return this._encodeTime(t,e);if("null_"===e)return this._encodeNull();if("int"===e||"enum"===e)return this._encodeInt(t,r.args&&r.reverseArgs[0]);if("bool"===e)return this._encodeBool(t);if("objDesc"===e)return this._encodeStr(t,e);throw new Error("Unsupported tag: "+e)},f.prototype._isNumstr=function(e){return/^[0-9 ]*$/.test(e)},f.prototype._isPrintstr=function(e){return/^[A-Za-z0-9 '()+,-./:=?]*$/.test(e)}},function(e,t,r){"use strict";const n=r(10);function i(e){this._reporterState={obj:null,path:[],options:e||{},errors:[]}}function o(e,t){this.path=e,this.rethrow(t)}t.Reporter=i,i.prototype.isError=function(e){return e instanceof o},i.prototype.save=function(){const e=this._reporterState;return{obj:e.obj,pathLen:e.path.length}},i.prototype.restore=function(e){const t=this._reporterState;t.obj=e.obj,t.path=t.path.slice(0,e.pathLen)},i.prototype.enterKey=function(e){return this._reporterState.path.push(e)},i.prototype.exitKey=function(e){const t=this._reporterState;t.path=t.path.slice(0,e-1)},i.prototype.leaveKey=function(e,t,r){const n=this._reporterState;this.exitKey(e),null!==n.obj&&(n.obj[t]=r)},i.prototype.path=function(){return this._reporterState.path.join("/")},i.prototype.enterObject=function(){const e=this._reporterState,t=e.obj;return e.obj={},t},i.prototype.leaveObject=function(e){const t=this._reporterState,r=t.obj;return t.obj=e,r},i.prototype.error=function(e){let t;const r=this._reporterState,n=e instanceof o;if(t=n?e:new o(r.path.map((function(e){return"["+JSON.stringify(e)+"]"})).join(""),e.message||e,e.stack),!r.options.partial)throw t;return n||r.errors.push(t),t},i.prototype.wrapResult=function(e){const t=this._reporterState;return t.options.partial?{result:this.isError(e)?null:e,errors:t.errors}:e},n(o,Error),o.prototype.rethrow=function(e){if(this.message=e+" at: "+(this.path||"(shallow)"),Error.captureStackTrace&&Error.captureStackTrace(this,o),!this.stack)try{throw new Error(this.message)}catch(e){this.stack=e.stack}return this}},function(e,t,r){"use strict";function n(e){const t={};return Object.keys(e).forEach((function(r){(0|r)==r&&(r|=0);const n=e[r];t[n]=r})),t}t.tagClass={0:"universal",1:"application",2:"context",3:"private"},t.tagClassByName=n(t.tagClass),t.tag={0:"end",1:"bool",2:"int",3:"bitstr",4:"octstr",5:"null_",6:"objid",7:"objDesc",8:"external",9:"real",10:"enum",11:"embed",12:"utf8str",13:"relativeOid",16:"seq",17:"set",18:"numstr",19:"printstr",20:"t61str",21:"videostr",22:"ia5str",23:"utctime",24:"gentime",25:"graphstr",26:"iso646str",27:"genstr",28:"unistr",29:"charstr",30:"bmpstr"},t.tagByName=n(t.tag)},function(e,t,r){"use strict";t.__esModule=!0,t.getBridgeInfo=t.parseBridgeJSON=void 0;var n={version:[],directory:"",packages:[],changelog:""};t.parseBridgeJSON=function(e){var t=e[0],r=t.version.join("."),i=JSON.parse(JSON.stringify(t).replace(/{version}/g,r)),o=i.directory,a=i.packages.map((function(e){return{name:e.name,platform:e.platform,url:""+o+e.url,signature:e.signature?""+o+e.signature:void 0}}));return n.version=i.version,n.directory=o,n.packages=a,n};t.getBridgeInfo=function(){return n}},function(e,t,r){var Buffer=r(7).Buffer;e.exports={check:function(e){if(e.length<8)return!1;if(e.length>72)return!1;if(48!==e[0])return!1;if(e[1]!==e.length-2)return!1;if(2!==e[2])return!1;var t=e[3];if(0===t)return!1;if(5+t>=e.length)return!1;if(2!==e[4+t])return!1;var r=e[5+t];return 0!==r&&(6+t+r===e.length&&(!(128&e[4])&&(!(t>1&&0===e[4]&&!(128&e[5]))&&(!(128&e[t+6])&&!(r>1&&0===e[t+6]&&!(128&e[t+7]))))))},decode:function(e){if(e.length<8)throw new Error("DER sequence length is too short");if(e.length>72)throw new Error("DER sequence length is too long");if(48!==e[0])throw new Error("Expected DER sequence");if(e[1]!==e.length-2)throw new Error("DER sequence length is invalid");if(2!==e[2])throw new Error("Expected DER integer");var t=e[3];if(0===t)throw new Error("R length is zero");if(5+t>=e.length)throw new Error("R length is too long");if(2!==e[4+t])throw new Error("Expected DER integer (2)");var r=e[5+t];if(0===r)throw new Error("S length is zero");if(6+t+r!==e.length)throw new Error("S length is invalid");if(128&e[4])throw new Error("R value is negative");if(t>1&&0===e[4]&&!(128&e[5]))throw new Error("R value excessively padded");if(128&e[t+6])throw new Error("S value is negative");if(r>1&&0===e[t+6]&&!(128&e[t+7]))throw new Error("S value excessively padded");return{r:e.slice(4,4+t),s:e.slice(6+t)}},encode:function(e,t){var r=e.length,n=t.length;if(0===r)throw new Error("R length is zero");if(0===n)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(n>33)throw new Error("S length is too long");if(128&e[0])throw new Error("R value is negative");if(128&t[0])throw new Error("S value is negative");if(r>1&&0===e[0]&&!(128&e[1]))throw new Error("R value excessively padded");if(n>1&&0===t[0]&&!(128&t[1]))throw new Error("S value excessively padded");var i=Buffer.allocUnsafe(6+r+n);return i[0]=48,i[1]=i.length-2,i[2]=2,i[3]=e.length,e.copy(i,4),i[4+r]=2,i[5+r]=t.length,t.copy(i,6+r),i}}},function(e,t){var r={Array:function(e){return null!=e&&e.constructor===Array},Boolean:function(e){return"boolean"==typeof e},Function:function(e){return"function"==typeof e},Nil:function(e){return null==e},Number:function(e){return"number"==typeof e},Object:function(e){return"object"==typeof e},String:function(e){return"string"==typeof e},"":function(){return!0}};for(var n in r.Null=r.Nil,r)r[n].toJSON=function(e){return e}.bind(null,n);e.exports=r},function(e,t,r){var n=r(19).decompile,i=r(107),o=r(367),a=r(108),s=r(109),u=r(372),f=r(375),c=r(377),l=r(379),h={MULTISIG:"multisig",NONSTANDARD:"nonstandard",NULLDATA:"nulldata",P2PK:"pubkey",P2PKH:"pubkeyhash",P2SH:"scripthash",P2WPKH:"witnesspubkeyhash",P2WSH:"witnessscripthash",WITNESS_COMMITMENT:"witnesscommitment"};e.exports={classifyInput:function(e,t){var r=n(e);return s.input.check(r)?h.P2PKH:u.input.check(r,t)?h.P2SH:i.input.check(r,t)?h.MULTISIG:a.input.check(r)?h.P2PK:h.NONSTANDARD},classifyOutput:function(e){if(f.output.check(e))return h.P2WPKH;if(c.output.check(e))return h.P2WSH;if(s.output.check(e))return h.P2PKH;if(u.output.check(e))return h.P2SH;var t=n(e);return i.output.check(t)?h.MULTISIG:a.output.check(t)?h.P2PK:l.output.check(t)?h.WITNESS_COMMITMENT:o.output.check(t)?h.NULLDATA:h.NONSTANDARD},classifyWitness:function(e,t){var r=n(e);return f.input.check(r)?h.P2WPKH:c.input.check(r,t)?h.P2WSH:h.NONSTANDARD},multisig:i,nullData:o,pubKey:a,pubKeyHash:s,scriptHash:u,witnessPubKeyHash:f,witnessScriptHash:c,witnessCommitment:l,types:h}},function(e,t,r){e.exports={input:r(366),output:r(189)}},function(e,t,r){e.exports={input:r(368),output:r(369)}},function(e,t,r){e.exports={input:r(370),output:r(371)}},function(e,t,r){var n=r(186),i=r(71),BigInteger=r(37),o=r(387).Int64LE;function a(e,t){if("number"!=typeof e)throw new Error("cannot write a non-number as a number");if(e<0)throw new Error("specified a negative value for writing an unsigned value");if(e>t)throw new Error("RangeError: value out of range");if(Math.floor(e)!==e)throw new Error("value has a fractional component")}function s(e,t){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4);return a((n*=4294967296)+r,9007199254740991),n+r}function u(e,t,r){return a(t,9007199254740991),e.writeInt32LE(-1&t,r),e.writeUInt32LE(Math.floor(t/4294967296),r+4),r+8}e.exports={pushDataSize:n.encodingLength,readPushDataInt:n.decode,readUInt64LE:s,readUInt64LEasString:function(e,t){try{return s(e,t).toString()}catch(s){var r=e.readUInt32LE(t),n=e.readUInt32LE(t+4),i=new BigInteger(Number(4294967296).toString()),o=new BigInteger(r.toString()),a=new BigInteger(n.toString()).multiply(i);return o.add(a).toString()}},readInt64LE:function(e,t){var r=e.readUInt32LE(t),n=e.readInt32LE(t+4);return(n*=4294967296)+r},readVarInt:function(e,t){return{number:i.decode(e,t),size:i.decode.bytes}},varIntBuffer:i.encode,varIntSize:i.encodingLength,writePushDataInt:n.encode,writeUInt64LE:u,writeUInt64LEasString:function(e,t,r){return"string"!=typeof t?u(e,t,r):(new o(t).toBuffer().copy(e,r),r+8)},writeInt64LE:function(e,t,r){for(var n=new o(t).toArray(),i=0;i<8;i++)e.writeUInt8(n[i],r+i);return r+8},writeVarInt:function(e,t,r){return i.encode(t,e,r),i.encode.bytes}}},function(e,t,r){"use strict";(function(t){var n=r(383); /*! * The buffer module from node.js, for the browser. * * @author Feross Aboukhadijeh * @license MIT - */function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;f--)if(c[f]!==l[f])return!1;for(f=c.length-1;f>=0;f--)if(s=c[f],!v(e[s],t[s],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function E(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&m(i,r,"Missing expected exception"+n);var o="string"==typeof n,s=!e&&i&&!r;if((!e&&a.isError(i)&&o&&_(i,r)||s)&&m(i,r,"Got unwanted exception"+n),e&&i&&r&&!_(i,r)||!e&&i)throw i}h.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return y(g(e.actual),128)+" "+e.operator+" "+y(g(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||m;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=p(t),o=n.indexOf("\n"+i);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},a.inherits(h.AssertionError,Error),h.fail=m,h.ok=b,h.equal=function(e,t,r){e!=t&&m(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&m(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||m(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||m(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&m(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&m(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&m(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&m(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){E(!0,e,t,r)},h.doesNotThrow=function(e,t,r){E(!1,e,t,r)},h.ifError=function(e){if(e)throw e},h.strict=n((function e(t,r){t||m(t,!0,r,"==",e)}),h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var S=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(24))},function(e,t,r){var Buffer=r(7).Buffer,n=r(390),i=r(51),o=r(19),a=r(111),s=r(59),u=r(26),f=r(40),c=r(15),l=r(22),h=r(72),d=r(391);function p(e){var t=e.length;return h.encodingLength(t)+t}function y(e=f.bitcoin){this.version=1,this.locktime=0,this.ins=[],this.outs=[],this.network=e,s.isZcashType(e)&&(this.joinsplits=[],this.joinsplitPubkey=[],this.joinsplitSig=[],this.overwintered=0,this.versionGroupId=0,this.expiryHeight=0,this.valueBalance=0,this.vShieldedSpend=[],this.vShieldedOutput=[],this.bindingSig=0),s.isDash(e)&&(this.type=0,this.extraPayload=Buffer.alloc(0)),s.hasTimestamp(e)&&(this.timestamp=0)}y.USE_STRING_VALUES=!1,y.DEFAULT_SEQUENCE=4294967295,y.SIGHASH_ALL=1,y.SIGHASH_NONE=2,y.SIGHASH_SINGLE=3,y.SIGHASH_ANYONECANPAY=128,y.SIGHASH_BITCOINCASHBIP143=64,y.ADVANCED_TRANSACTION_MARKER=0,y.ADVANCED_TRANSACTION_FLAG=1;var g=Buffer.allocUnsafe(0),m=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),v=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),w=Buffer.from("ffffffffffffffff","hex"),_={script:g,valueBuffer:w};y.ZCASH_OVERWINTER_VERSION=3,y.ZCASH_SAPLING_VERSION=4,y.ZCASH_JOINSPLITS_SUPPORT_VERSION=2,y.ZCASH_NUM_JOINSPLITS_INPUTS=2,y.ZCASH_NUM_JOINSPLITS_OUTPUTS=2,y.ZCASH_NOTECIPHERTEXT_SIZE=601,y.ZCASH_G1_PREFIX_MASK=2,y.ZCASH_G2_PREFIX_MASK=10,y.DASH_NORMAL=0,y.DASH_PROVIDER_REGISTER=1,y.DASH_PROVIDER_UPDATE_SERVICE=2,y.DASH_PROVIDER_UPDATE_REGISTRAR=3,y.DASH_PROVIDER_UPDATE_REVOKE=4,y.DASH_COINBASE=5,y.DASH_QUORUM_COMMITMENT=6,y.fromBuffer=function(e,t=f.bitcoin,r){var n=0;function i(t){return n+=t,e.slice(n-t,n)}function o(){var t=e.readUInt8(n);return n+=1,t}function u(){var t=e.readUInt32LE(n);return n+=4,t}function c(){var t=a.readUInt64LE(e,n);return n+=8,t}function l(){var t=a.readUInt64LEasString(e,n);return n+=8,t}function d(){var t=h.decode(e,n);return n+=h.decode.bytes,t}function p(){return i(d())}function g(){for(var e=d(),t=[],r=0;r>>31,_.version=2147483647&_.version,!t.consensusBranchId.hasOwnProperty(_.version)))throw new Error("Unsupported Zcash transaction");if(s.isDash(t)&&(_.type=_.version>>16,_.version=65535&_.version,3===_.version&&(_.typey.DASH_QUORUM_COMMITMENT)))throw new Error("Unsupported Dash transaction type");var E=e.readUInt8(n),S=e.readUInt8(n+1),A=!1;E!==y.ADVANCED_TRANSACTION_MARKER||S!==y.ADVANCED_TRANSACTION_FLAG||s.isZcashType(t)||(n+=2,A=!0),_.isOverwinterCompatible()&&(_.versionGroupId=u()),s.hasTimestamp(_.network)&&(_.timestamp=u());for(var I=d(),O=0;O0&&(_.joinsplitPubkey=i(32),_.joinsplitSig=i(64))}_.isSaplingCompatible()&&_.vShieldedSpend.length+_.vShieldedOutput.length>0&&(_.bindingSig=i(64))}if(_.isDashSpecialTransaction()&&(_.extraPayload=p()),_.network=t,r)return _;if(n!==e.length)throw new Error("Transaction has unexpected data");return _},y.fromHex=function(e,t){return y.fromBuffer(Buffer.from(e,"hex"),t)},y.isCoinbaseHash=function(e){c(l.Hash256bit,e);for(var t=0;t<32;++t)if(0!==e[t])return!1;return!0},y.prototype.isSaplingCompatible=function(){return s.isZcashType(this.network)&&this.version>=y.ZCASH_SAPLING_VERSION},y.prototype.isOverwinterCompatible=function(){return s.isZcashType(this.network)&&this.version>=y.ZCASH_OVERWINTER_VERSION},y.prototype.supportsJoinSplits=function(){return s.isZcashType(this.network)&&this.version>=y.ZCASH_JOINSPLITS_SUPPORT_VERSION},y.prototype.versionSupportsDashSpecialTransactions=function(){return s.isDash(this.network)&&this.version>=3},y.prototype.isDashSpecialTransaction=function(){return this.versionSupportsDashSpecialTransactions()&&this.type!==y.DASH_NORMAL},y.prototype.isCoinbase=function(){return 1===this.ins.length&&y.isCoinbaseHash(this.ins[0].hash)},y.prototype.addInput=function(e,t,r,n){return c(l.tuple(l.Hash256bit,l.UInt32,l.maybe(l.UInt32),l.maybe(l.Buffer)),arguments),l.Null(r)&&(r=y.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||g,sequence:r,witness:m})-1},y.prototype.addOutput=function(e,t){return c(l.tuple(l.Buffer,l.Satoshi),arguments),this.outs.push({script:e,value:t})-1},y.prototype.hasWitnesses=function(){return this.ins.some((function(e){return 0!==e.witness.length}))},y.prototype.weight=function(){return 3*this.__byteLength(!1)+this.__byteLength(!0)},y.prototype.virtualSize=function(){return Math.ceil(this.weight()/4)},y.prototype.byteLength=function(){return this.__byteLength(!0)},y.prototype.getShieldedSpendByteLength=function(){if(!this.isSaplingCompatible())return 0;var e=0;return e+=h.encodingLength(this.vShieldedSpend.length),e+=384*this.vShieldedSpend.length},y.prototype.getShieldedOutputByteLength=function(){if(!this.isSaplingCompatible())return 0;var e=0;return e+=h.encodingLength(this.vShieldedOutput.length),e+=948*this.vShieldedOutput.length},y.prototype.getJoinSplitByteLength=function(){if(!this.supportsJoinSplits())return 0;var e=this.joinsplits.length,t=0;return t+=a.varIntSize(e),e>0&&(this.isSaplingCompatible()?t+=1698*e:t+=1802*e,t+=32,t+=64),t},y.prototype.zcashTransactionByteLength=function(){if(!s.isZcashType(this.network))throw new Error("zcashTransactionByteLength can only be called when using Zcash network");var e=0;return e+=4,this.isOverwinterCompatible()&&(e+=4),e+=h.encodingLength(this.ins.length),e+=this.ins.reduce((function(e,t){return e+40+p(t.script)}),0),e+=h.encodingLength(this.outs.length),e+=this.outs.reduce((function(e,t){return e+8+p(t.script)}),0),e+=4,this.isOverwinterCompatible()&&(e+=4),this.isSaplingCompatible()&&(e+=8,e+=this.getShieldedSpendByteLength(),e+=this.getShieldedOutputByteLength()),this.supportsJoinSplits()&&(e+=this.getJoinSplitByteLength()),this.isSaplingCompatible()&&this.vShieldedSpend.length+this.vShieldedOutput.length>0&&(e+=64),e},y.prototype.__byteLength=function(e){var t=e&&this.hasWitnesses();return s.isZcashType(this.network)?this.zcashTransactionByteLength():(t?10:8)+(this.timestamp?4:0)+h.encodingLength(this.ins.length)+h.encodingLength(this.outs.length)+this.ins.reduce((function(e,t){return e+40+p(t.script)}),0)+this.outs.reduce((function(e,t){return e+8+p(t.script)}),0)+(this.isDashSpecialTransaction()?p(this.extraPayload):0)+(t?this.ins.reduce((function(e,t){return e+(r=t.witness,n=r.length,h.encodingLength(n)+r.reduce((function(e,t){return e+p(t)}),0));var r,n}),0):0)},y.prototype.clone=function(){var e=new y(this.network);return e.version=this.version,e.locktime=this.locktime,e.network=this.network,s.isDash(this.network)&&(e.type=this.type,e.extraPayload=this.extraPayload),s.hasTimestamp(this.network)&&(e.timestamp=this.timestamp),this.isOverwinterCompatible()&&(e.overwintered=this.overwintered,e.versionGroupId=this.versionGroupId,e.expiryHeight=this.expiryHeight),this.isSaplingCompatible()&&(e.valueBalance=this.valueBalance),e.ins=this.ins.map((function(e){return{hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}})),e.outs=this.outs.map((function(e){return{script:e.script,value:e.value}})),this.isSaplingCompatible()&&(e.vShieldedSpend=this.vShieldedSpend.map((function(e){return{cv:e.cv,anchor:e.anchor,nullifier:e.nullifier,rk:e.rk,zkproof:e.zkproof,spendAuthSig:e.spendAuthSig}})),e.vShieldedOutput=this.vShieldedOutput.map((function(e){return{cv:e.cv,cmu:e.cmu,ephemeralKey:e.ephemeralKey,encCiphertext:e.encCiphertext,outCiphertext:e.outCiphertext,zkproof:e.zkproof}}))),this.supportsJoinSplits()&&(e.joinsplits=this.joinsplits.map((function(e){return{vpubOld:e.vpubOld,vpubNew:e.vpubNew,anchor:e.anchor,nullifiers:e.nullifiers,commitments:e.commitments,ephemeralKey:e.ephemeralKey,randomSeed:e.randomSeed,macs:e.macs,zkproof:e.zkproof,ciphertexts:e.ciphertexts}})),e.joinsplitPubkey=this.joinsplitPubkey,e.joinsplitSig=this.joinsplitSig),this.isSaplingCompatible()&&this.vShieldedSpend.length+this.vShieldedOutput.length>0&&(e.bindingSig=this.bindingSig),e},y.prototype.getHeader=function(){var e=this.overwintered?1:0;return this.version|e<<31},y.prototype.hashForSignature=function(e,t,r){if(c(l.tuple(l.UInt32,l.Buffer,l.Number),arguments),e>=this.ins.length)return v;var n=o.compile(o.decompile(t).filter((function(e){return e!==u.OP_CODESEPARATOR}))),a=this.clone();if((31&r)===y.SIGHASH_NONE)a.outs=[],a.ins.forEach((function(t,r){r!==e&&(t.sequence=0)}));else if((31&r)===y.SIGHASH_SINGLE){if(e>=this.outs.length)return v;a.outs.length=e+1;for(var s=0;s0)throw new Error("Hash signature for Zcash protected transactions is not supported");if(e>=this.ins.length&&e!==w)throw new Error("Input index is out of range");if(this.isOverwinterCompatible()){var o,a=this.getPrevoutHash(i),u=this.getSequenceHash(i),f=this.getOutputsHash(i,e),h=b,d=b,y=b,g=0;if(g+=20,g+=128,e!==w&&(g+=8,g+=8,g+=32,g+=p(t)),this.isSaplingCompatible()&&(g+=64,g+=8),(o=new n(g)).writeInt32(this.getHeader()),o.writeUInt32(this.versionGroupId),o.writeSlice(a),o.writeSlice(u),o.writeSlice(f),o.writeSlice(h),this.isSaplingCompatible()&&(o.writeSlice(d),o.writeSlice(y)),o.writeUInt32(this.locktime),o.writeUInt32(this.expiryHeight),this.isSaplingCompatible()&&o.writeInt64(this.valueBalance),o.writeUInt32(i),e!==w){var m=this.ins[e];o.writeSlice(m.hash),o.writeUInt32(m.index),o.writeVarSlice(t),o.writeUInt64(r),o.writeUInt32(m.sequence)}var v=Buffer.alloc(16),_="ZcashSigHash";return v.write(_),v.writeUInt32LE(this.network.consensusBranchId[this.version],_.length),this.getBlake2bHash(o.getBuffer(),v)}},y.prototype.hashForWitnessV0=function(e,t,r,o){c(l.tuple(l.UInt32,l.Buffer,l.Satoshi,l.UInt32),arguments);var a=this.getPrevoutHash(o),s=this.getSequenceHash(o),u=this.getOutputsHash(o,e),f=new n(156+p(t)),h=this.ins[e];return f.writeUInt32(this.version),f.writeSlice(a),f.writeSlice(s),f.writeSlice(h.hash),f.writeUInt32(h.index),f.writeVarSlice(t),f.writeUInt64(r),f.writeUInt32(h.sequence),f.writeSlice(u),f.writeUInt32(this.locktime),f.writeUInt32(o),i.hash256(f.getBuffer())},y.prototype.hashForCashSignature=function(e,t,r,n){if(c(l.tuple(l.UInt32,l.Buffer,l.Number,l.maybe(l.UInt53)),arguments),n&y.SIGHASH_BITCOINCASHBIP143){if(l.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,n)}return this.hashForSignature(e,t,n)},y.prototype.hashForGoldSignature=function(e,t,r,n,i){c(l.tuple(l.UInt32,l.Buffer,l.Number,l.maybe(l.UInt53)),arguments);var o=n,a=(n&y.SIGHASH_BITCOINCASHBIP143)>0;if(a&&(o|=this.network.forkId<<8),i||a){if(l.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,o)}return this.hashForSignature(e,t,o)},y.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},y.prototype.getId=function(){return this.getHash().reverse().toString("hex")},y.prototype.toBuffer=function(e,t){return this.__toBuffer(e,t,!0)},y.prototype.__toBuffer=function(e,t,r){e||(e=Buffer.allocUnsafe(this.__byteLength(r)));var n=t||0;function i(t){n+=t.copy(e,n)}function o(t){n=e.writeUInt8(t,n)}function s(t){n=e.writeUInt16LE(t,n)}function u(t){n=e.writeUInt32LE(t,n)}function f(t){n=e.writeInt32LE(t,n)}function c(t){n=a.writeUInt64LE(e,t,n)}function l(t){h.encode(t,e,n),n+=h.encode.bytes}function d(e){l(e.length),i(e)}function p(e){o(y.ZCASH_G1_PREFIX_MASK|e.yLsb),i(e.x)}if(this.isOverwinterCompatible()){var g=this.overwintered?1:0;f(this.version|g<<31),u(this.versionGroupId)}else this.isDashSpecialTransaction()?(s(this.version),s(this.type)):f(this.version);var m=r&&this.hasWitnesses();return m&&(o(y.ADVANCED_TRANSACTION_MARKER),o(y.ADVANCED_TRANSACTION_FLAG)),this.timestamp&&u(this.timestamp),l(this.ins.length),this.ins.forEach((function(e){i(e.hash),u(e.index),d(e.script),u(e.sequence)})),l(this.outs.length),this.outs.forEach((function(t){y.USE_STRING_VALUES?function(t){n=a.writeUInt64LEasString(e,t,n)}(t.value):t.valueBuffer?i(t.valueBuffer):c(t.value),d(t.script)})),m&&this.ins.forEach((function(e){var t;l((t=e.witness).length),t.forEach(d)})),u(this.locktime),this.isOverwinterCompatible()&&u(this.expiryHeight),this.isSaplingCompatible()&&(!function(t){n=a.writeInt64LE(e,t,n)}(this.valueBalance),l(this.vShieldedSpend.length),this.vShieldedSpend.forEach((function(e){i(e.cv),i(e.anchor),i(e.nullifier),i(e.rk),i(e.zkproof.sA),i(e.zkproof.sB),i(e.zkproof.sC),i(e.spendAuthSig)})),l(this.vShieldedOutput.length),this.vShieldedOutput.forEach((function(e){i(e.cv),i(e.cmu),i(e.ephemeralKey),i(e.encCiphertext),i(e.outCiphertext),i(e.zkproof.sA),i(e.zkproof.sB),i(e.zkproof.sC)}))),this.supportsJoinSplits()&&(l(this.joinsplits.length),this.joinsplits.forEach((function(e){c(e.vpubOld),c(e.vpubNew),i(e.anchor),e.nullifiers.forEach((function(e){i(e)})),e.commitments.forEach((function(e){i(e)})),i(e.ephemeralKey),i(e.randomSeed),e.macs.forEach((function(e){i(e)})),this.isSaplingCompatible()?(i(e.zkproof.sA),i(e.zkproof.sB),i(e.zkproof.sC)):(p(e.zkproof.gA),p(e.zkproof.gAPrime),function(e){o(y.ZCASH_G2_PREFIX_MASK|e.yLsb),i(e.x)}(e.zkproof.gB),p(e.zkproof.gBPrime),p(e.zkproof.gC),p(e.zkproof.gCPrime),p(e.zkproof.gK),p(e.zkproof.gH)),e.ciphertexts.forEach((function(e){i(e)}))}),this),this.joinsplits.length>0&&(i(this.joinsplitPubkey),i(this.joinsplitSig))),this.isSaplingCompatible()&&this.vShieldedSpend.length+this.vShieldedOutput.length>0&&i(this.bindingSig),this.isDashSpecialTransaction()&&d(this.extraPayload),void 0!==t?e.slice(t,n):e.slice(0,n)},y.prototype.toHex=function(){return this.toBuffer().toString("hex")},y.prototype.setInputScript=function(e,t){c(l.tuple(l.Number,l.Buffer),arguments),this.ins[e].script=t},y.prototype.setWitness=function(e,t){c(l.tuple(l.Number,[l.Buffer]),arguments),this.ins[e].witness=t},y.prototype.getExtraData=function(){if(this.supportsJoinSplits()){var e=4;return this.isOverwinterCompatible()&&(e+=4),e+=h.encodingLength(this.ins.length),e+=this.ins.reduce((function(e,t){return e+40+p(t.script)}),0),e+=h.encodingLength(this.outs.length),e+=this.outs.reduce((function(e,t){return e+8+p(t.script)}),0),e+=4,this.isOverwinterCompatible()&&(e+=4),this.toBuffer().slice(e)}if(this.isDashSpecialTransaction()){var t=h.encode(this.extraPayload.length);return Buffer.concat([t,this.extraPayload])}return null},e.exports=y},function(e,t,r){(function(Buffer){var t=r(115),n=r(51),i=r(397),o=r(34),a=r(15),s=r(22),u=r(400),f=r(40),BigInteger=r(37),c=r(74),l=c.getCurveByName("secp256k1"),h=i.__curve,d=r(198);function ECPair(e,t,r){if(r&&a({compressed:s.maybe(s.Boolean),network:s.maybe(s.Network)},r),r=r||{},e){if(e.signum()<=0)throw new Error("Private key must be greater than 0");if(e.compareTo(h.n)>=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(s.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=h.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(e,t){var r=c.Point.decodeFrom(h,e);return new ECPair(null,r,{compressed:r.compressed,network:t})},ECPair.fromPrivateKeyBuffer=function(e,t){if(!Buffer.isBuffer(e)||32!==e.length)throw new Error("invalid private key buffer");var r=BigInteger.fromBuffer(e);if(r.signum()<=0||r.compareTo(l.n)>=0)throw new Error("private key out of range");var n=new ECPair(r,null,{network:t});return!n.__Q&&l&&(n.__Q=c.Point.decodeFrom(l,d.publicKeyCreate(r.toBuffer(32),!1))),n},ECPair.fromWIF=function(e,t){var r=u.decode(e),n=r.version;if(s.Array(t)){if(!(t=t.filter((function(e){return n===e.wif})).pop()))throw new Error("Unknown network version")}else if(t=t||f.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},ECPair.makeRandom=function(e){var t,r=(e=e||{}).rng||o;do{var n=r(32);a(s.Buffer256bit,n),t=BigInteger.fromBuffer(n)}while(t.signum()<=0||t.compareTo(h.n)>=0);return new ECPair(t,null,e)},ECPair.prototype.getAddress=function(){return t.toBase58Check(n.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.getPrivateKeyBuffer=function(){if(!this.d)throw new Error("Missing private key");var e=this.d.toBuffer();if(e.length>32)throw new Error("Private key size exceeds 32 bytes");if(32===e.length)return e;var t=Buffer.alloc(32);return e.copy(t,t.length-e.length,0,e.length),t},ECPair.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");var t=d.sign(e,this.d);return void 0!==t?t:i.sign(e,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return u.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(e,t){var r=d.verify(e,t,this.getPublicKeyBuffer());return void 0!==r?r:i.verify(e,t,this.Q)},e.exports=ECPair}).call(this,r(9).Buffer)},function(e,t,r){var Buffer=r(7).Buffer,n=r(394),i=r(60),o=r(19),a=r(107),s=r(40),u=r(15),f=r(22);function c(e){var t=i.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>22)throw new TypeError(e+" is too long");var r=22===t.length,n=r?2:1;return{version:r?t.readUInt16BE(0):t[0],hash:t.slice(n)}}function l(e){var t=n.decode(e),r=n.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:Buffer.from(r)}}function h(e,t){u(f.tuple(f.Hash160bit,f.UInt16),arguments);var r=t>255,n=r?22:21,o=r?2:1,a=Buffer.allocUnsafe(n);return r?a.writeUInt16BE(t,0):a.writeUInt8(t,0),e.copy(a,o),i.encode(a)}function d(e,t,r){var i=n.toWords(e);return i.unshift(t),n.encode(r,i)}e.exports={fromBase58Check:c,fromBech32:l,fromOutputScript:function(e,t){if(t=t||s.bitcoin,a.pubKeyHash.output.check(e))return h(o.compile(e).slice(3,23),t.pubKeyHash);if(a.scriptHash.output.check(e))return h(o.compile(e).slice(2,22),t.scriptHash);if(a.witnessPubKeyHash.output.check(e))return d(o.compile(e).slice(2,22),0,t.bech32);if(a.witnessScriptHash.output.check(e))return d(o.compile(e).slice(2,34),0,t.bech32);throw new Error(o.toASM(e)+" has no matching Address")},toBase58Check:h,toBech32:d,toOutputScript:function(e,t){var r;t=t||s.bitcoin;try{r=c(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return a.pubKeyHash.output.encode(r.hash);if(r.version===t.scriptHash)return a.scriptHash.output.encode(r.hash)}else{try{r=l(e)}catch(e){}if(r){if(r.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===r.version){if(20===r.data.length)return a.witnessPubKeyHash.output.encode(r.data);if(32===r.data.length)return a.witnessScriptHash.output.encode(r.data)}}}throw new Error(e+" has no matching Script")}}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getAccountLabel=t.getAccountAddressN=void 0;var i=n(r(11)),o=r(12),a=r(6);function s(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}t.getAccountAddressN=function(e,t,r){if(!e)throw a.ERRORS.TypedError("Method_UnknownCoin");var n="number"==typeof t?t:0,u=function(e){for(var t=1;taccount #"+(n+1)+""}return"account #"+((0,o.fromHardened)(e[4])+1)}},function(e,t,r){"use strict";var n=r(75);e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deferred=function(){var e=function(){},t=function(){};return{promise:new Promise((function(r,n){e=r,t=n})),resolve:e,reject:t}}},function(e,t,r){"use strict"; + */function i(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,o=Math.min(r,n);i=0;f--)if(c[f]!==l[f])return!1;for(f=c.length-1;f>=0;f--)if(s=c[f],!v(e[s],t[s],r,n))return!1;return!0}(e,t,r,n))}return r?e===t:e==t}function w(e){return"[object Arguments]"==Object.prototype.toString.call(e)}function _(e,t){if(!e||!t)return!1;if("[object RegExp]"==Object.prototype.toString.call(t))return t.test(e);try{if(e instanceof t)return!0}catch(e){}return!Error.isPrototypeOf(t)&&!0===t.call({},e)}function E(e,t,r,n){var i;if("function"!=typeof t)throw new TypeError('"block" argument must be a function');"string"==typeof r&&(n=r,r=null),i=function(e){var t;try{e()}catch(e){t=e}return t}(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&m(i,r,"Missing expected exception"+n);var o="string"==typeof n,s=!e&&i&&!r;if((!e&&a.isError(i)&&o&&_(i,r)||s)&&m(i,r,"Got unwanted exception"+n),e&&i&&r&&!_(i,r)||!e&&i)throw i}h.AssertionError=function(e){this.name="AssertionError",this.actual=e.actual,this.expected=e.expected,this.operator=e.operator,e.message?(this.message=e.message,this.generatedMessage=!1):(this.message=function(e){return g(y(e.actual),128)+" "+e.operator+" "+g(y(e.expected),128)}(this),this.generatedMessage=!0);var t=e.stackStartFunction||m;if(Error.captureStackTrace)Error.captureStackTrace(this,t);else{var r=new Error;if(r.stack){var n=r.stack,i=p(t),o=n.indexOf("\n"+i);if(o>=0){var a=n.indexOf("\n",o+1);n=n.substring(a+1)}this.stack=n}}},a.inherits(h.AssertionError,Error),h.fail=m,h.ok=b,h.equal=function(e,t,r){e!=t&&m(e,t,r,"==",h.equal)},h.notEqual=function(e,t,r){e==t&&m(e,t,r,"!=",h.notEqual)},h.deepEqual=function(e,t,r){v(e,t,!1)||m(e,t,r,"deepEqual",h.deepEqual)},h.deepStrictEqual=function(e,t,r){v(e,t,!0)||m(e,t,r,"deepStrictEqual",h.deepStrictEqual)},h.notDeepEqual=function(e,t,r){v(e,t,!1)&&m(e,t,r,"notDeepEqual",h.notDeepEqual)},h.notDeepStrictEqual=function e(t,r,n){v(t,r,!0)&&m(t,r,n,"notDeepStrictEqual",e)},h.strictEqual=function(e,t,r){e!==t&&m(e,t,r,"===",h.strictEqual)},h.notStrictEqual=function(e,t,r){e===t&&m(e,t,r,"!==",h.notStrictEqual)},h.throws=function(e,t,r){E(!0,e,t,r)},h.doesNotThrow=function(e,t,r){E(!1,e,t,r)},h.ifError=function(e){if(e)throw e},h.strict=n((function e(t,r){t||m(t,!0,r,"==",e)}),h,{equal:h.strictEqual,deepEqual:h.deepStrictEqual,notEqual:h.notStrictEqual,notDeepEqual:h.notDeepStrictEqual}),h.strict.strict=h.strict;var S=Object.keys||function(e){var t=[];for(var r in e)s.call(e,r)&&t.push(r);return t}}).call(this,r(24))},function(e,t,r){var Buffer=r(7).Buffer,n=r(390),i=r(51),o=r(19),a=r(110),s=r(58),u=r(26),f=r(40),c=r(15),l=r(22),h=r(71),d=r(391);function p(e){var t=e.length;return h.encodingLength(t)+t}function g(e=f.bitcoin){this.version=1,this.locktime=0,this.ins=[],this.outs=[],this.network=e,s.isZcashType(e)&&(this.joinsplits=[],this.joinsplitPubkey=[],this.joinsplitSig=[],this.overwintered=0,this.versionGroupId=0,this.expiryHeight=0,this.valueBalance=0,this.vShieldedSpend=[],this.vShieldedOutput=[],this.bindingSig=0),s.isDash(e)&&(this.type=0,this.extraPayload=Buffer.alloc(0)),s.hasTimestamp(e)&&(this.timestamp=0)}g.USE_STRING_VALUES=!1,g.DEFAULT_SEQUENCE=4294967295,g.SIGHASH_ALL=1,g.SIGHASH_NONE=2,g.SIGHASH_SINGLE=3,g.SIGHASH_ANYONECANPAY=128,g.SIGHASH_BITCOINCASHBIP143=64,g.ADVANCED_TRANSACTION_MARKER=0,g.ADVANCED_TRANSACTION_FLAG=1;var y=Buffer.allocUnsafe(0),m=[],b=Buffer.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),v=Buffer.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),w=Buffer.from("ffffffffffffffff","hex"),_={script:y,valueBuffer:w};g.ZCASH_OVERWINTER_VERSION=3,g.ZCASH_SAPLING_VERSION=4,g.ZCASH_JOINSPLITS_SUPPORT_VERSION=2,g.ZCASH_NUM_JOINSPLITS_INPUTS=2,g.ZCASH_NUM_JOINSPLITS_OUTPUTS=2,g.ZCASH_NOTECIPHERTEXT_SIZE=601,g.ZCASH_G1_PREFIX_MASK=2,g.ZCASH_G2_PREFIX_MASK=10,g.DASH_NORMAL=0,g.DASH_PROVIDER_REGISTER=1,g.DASH_PROVIDER_UPDATE_SERVICE=2,g.DASH_PROVIDER_UPDATE_REGISTRAR=3,g.DASH_PROVIDER_UPDATE_REVOKE=4,g.DASH_COINBASE=5,g.DASH_QUORUM_COMMITMENT=6,g.fromBuffer=function(e,t=f.bitcoin,r){var n=0;function i(t){return n+=t,e.slice(n-t,n)}function o(){var t=e.readUInt8(n);return n+=1,t}function u(){var t=e.readUInt32LE(n);return n+=4,t}function c(){var t=a.readUInt64LE(e,n);return n+=8,t}function l(){var t=a.readUInt64LEasString(e,n);return n+=8,t}function d(){var t=h.decode(e,n);return n+=h.decode.bytes,t}function p(){return i(d())}function y(){for(var e=d(),t=[],r=0;r>>31,_.version=2147483647&_.version,!t.consensusBranchId.hasOwnProperty(_.version)))throw new Error("Unsupported Zcash transaction");if(s.isDash(t)&&(_.type=_.version>>16,_.version=65535&_.version,3===_.version&&(_.typeg.DASH_QUORUM_COMMITMENT)))throw new Error("Unsupported Dash transaction type");var E=e.readUInt8(n),S=e.readUInt8(n+1),A=!1;E!==g.ADVANCED_TRANSACTION_MARKER||S!==g.ADVANCED_TRANSACTION_FLAG||s.isZcashType(t)||(n+=2,A=!0),_.isOverwinterCompatible()&&(_.versionGroupId=u()),s.hasTimestamp(_.network)&&(_.timestamp=u());for(var I=d(),O=0;O0&&(_.joinsplitPubkey=i(32),_.joinsplitSig=i(64))}_.isSaplingCompatible()&&_.vShieldedSpend.length+_.vShieldedOutput.length>0&&(_.bindingSig=i(64))}if(_.isDashSpecialTransaction()&&(_.extraPayload=p()),_.network=t,r)return _;if(n!==e.length)throw new Error("Transaction has unexpected data");return _},g.fromHex=function(e,t){return g.fromBuffer(Buffer.from(e,"hex"),t)},g.isCoinbaseHash=function(e){c(l.Hash256bit,e);for(var t=0;t<32;++t)if(0!==e[t])return!1;return!0},g.prototype.isSaplingCompatible=function(){return s.isZcashType(this.network)&&this.version>=g.ZCASH_SAPLING_VERSION},g.prototype.isOverwinterCompatible=function(){return s.isZcashType(this.network)&&this.version>=g.ZCASH_OVERWINTER_VERSION},g.prototype.supportsJoinSplits=function(){return s.isZcashType(this.network)&&this.version>=g.ZCASH_JOINSPLITS_SUPPORT_VERSION},g.prototype.versionSupportsDashSpecialTransactions=function(){return s.isDash(this.network)&&this.version>=3},g.prototype.isDashSpecialTransaction=function(){return this.versionSupportsDashSpecialTransactions()&&this.type!==g.DASH_NORMAL},g.prototype.isCoinbase=function(){return 1===this.ins.length&&g.isCoinbaseHash(this.ins[0].hash)},g.prototype.addInput=function(e,t,r,n){return c(l.tuple(l.Hash256bit,l.UInt32,l.maybe(l.UInt32),l.maybe(l.Buffer)),arguments),l.Null(r)&&(r=g.DEFAULT_SEQUENCE),this.ins.push({hash:e,index:t,script:n||y,sequence:r,witness:m})-1},g.prototype.addOutput=function(e,t){return c(l.tuple(l.Buffer,l.Satoshi),arguments),this.outs.push({script:e,value:t})-1},g.prototype.hasWitnesses=function(){return this.ins.some((function(e){return 0!==e.witness.length}))},g.prototype.weight=function(){return 3*this.__byteLength(!1)+this.__byteLength(!0)},g.prototype.virtualSize=function(){return Math.ceil(this.weight()/4)},g.prototype.byteLength=function(){return this.__byteLength(!0)},g.prototype.getShieldedSpendByteLength=function(){if(!this.isSaplingCompatible())return 0;var e=0;return e+=h.encodingLength(this.vShieldedSpend.length),e+=384*this.vShieldedSpend.length},g.prototype.getShieldedOutputByteLength=function(){if(!this.isSaplingCompatible())return 0;var e=0;return e+=h.encodingLength(this.vShieldedOutput.length),e+=948*this.vShieldedOutput.length},g.prototype.getJoinSplitByteLength=function(){if(!this.supportsJoinSplits())return 0;var e=this.joinsplits.length,t=0;return t+=a.varIntSize(e),e>0&&(this.isSaplingCompatible()?t+=1698*e:t+=1802*e,t+=32,t+=64),t},g.prototype.zcashTransactionByteLength=function(){if(!s.isZcashType(this.network))throw new Error("zcashTransactionByteLength can only be called when using Zcash network");var e=0;return e+=4,this.isOverwinterCompatible()&&(e+=4),e+=h.encodingLength(this.ins.length),e+=this.ins.reduce((function(e,t){return e+40+p(t.script)}),0),e+=h.encodingLength(this.outs.length),e+=this.outs.reduce((function(e,t){return e+8+p(t.script)}),0),e+=4,this.isOverwinterCompatible()&&(e+=4),this.isSaplingCompatible()&&(e+=8,e+=this.getShieldedSpendByteLength(),e+=this.getShieldedOutputByteLength()),this.supportsJoinSplits()&&(e+=this.getJoinSplitByteLength()),this.isSaplingCompatible()&&this.vShieldedSpend.length+this.vShieldedOutput.length>0&&(e+=64),e},g.prototype.__byteLength=function(e){var t=e&&this.hasWitnesses();return s.isZcashType(this.network)?this.zcashTransactionByteLength():(t?10:8)+(this.timestamp?4:0)+h.encodingLength(this.ins.length)+h.encodingLength(this.outs.length)+this.ins.reduce((function(e,t){return e+40+p(t.script)}),0)+this.outs.reduce((function(e,t){return e+8+p(t.script)}),0)+(this.isDashSpecialTransaction()?p(this.extraPayload):0)+(t?this.ins.reduce((function(e,t){return e+(r=t.witness,n=r.length,h.encodingLength(n)+r.reduce((function(e,t){return e+p(t)}),0));var r,n}),0):0)},g.prototype.clone=function(){var e=new g(this.network);return e.version=this.version,e.locktime=this.locktime,e.network=this.network,s.isDash(this.network)&&(e.type=this.type,e.extraPayload=this.extraPayload),s.hasTimestamp(this.network)&&(e.timestamp=this.timestamp),this.isOverwinterCompatible()&&(e.overwintered=this.overwintered,e.versionGroupId=this.versionGroupId,e.expiryHeight=this.expiryHeight),this.isSaplingCompatible()&&(e.valueBalance=this.valueBalance),e.ins=this.ins.map((function(e){return{hash:e.hash,index:e.index,script:e.script,sequence:e.sequence,witness:e.witness}})),e.outs=this.outs.map((function(e){return{script:e.script,value:e.value}})),this.isSaplingCompatible()&&(e.vShieldedSpend=this.vShieldedSpend.map((function(e){return{cv:e.cv,anchor:e.anchor,nullifier:e.nullifier,rk:e.rk,zkproof:e.zkproof,spendAuthSig:e.spendAuthSig}})),e.vShieldedOutput=this.vShieldedOutput.map((function(e){return{cv:e.cv,cmu:e.cmu,ephemeralKey:e.ephemeralKey,encCiphertext:e.encCiphertext,outCiphertext:e.outCiphertext,zkproof:e.zkproof}}))),this.supportsJoinSplits()&&(e.joinsplits=this.joinsplits.map((function(e){return{vpubOld:e.vpubOld,vpubNew:e.vpubNew,anchor:e.anchor,nullifiers:e.nullifiers,commitments:e.commitments,ephemeralKey:e.ephemeralKey,randomSeed:e.randomSeed,macs:e.macs,zkproof:e.zkproof,ciphertexts:e.ciphertexts}})),e.joinsplitPubkey=this.joinsplitPubkey,e.joinsplitSig=this.joinsplitSig),this.isSaplingCompatible()&&this.vShieldedSpend.length+this.vShieldedOutput.length>0&&(e.bindingSig=this.bindingSig),e},g.prototype.getHeader=function(){var e=this.overwintered?1:0;return this.version|e<<31},g.prototype.hashForSignature=function(e,t,r){if(c(l.tuple(l.UInt32,l.Buffer,l.Number),arguments),e>=this.ins.length)return v;var n=o.compile(o.decompile(t).filter((function(e){return e!==u.OP_CODESEPARATOR}))),a=this.clone();if((31&r)===g.SIGHASH_NONE)a.outs=[],a.ins.forEach((function(t,r){r!==e&&(t.sequence=0)}));else if((31&r)===g.SIGHASH_SINGLE){if(e>=this.outs.length)return v;a.outs.length=e+1;for(var s=0;s0)throw new Error("Hash signature for Zcash protected transactions is not supported");if(e>=this.ins.length&&e!==w)throw new Error("Input index is out of range");if(this.isOverwinterCompatible()){var o,a=this.getPrevoutHash(i),u=this.getSequenceHash(i),f=this.getOutputsHash(i,e),h=b,d=b,g=b,y=0;if(y+=20,y+=128,e!==w&&(y+=8,y+=8,y+=32,y+=p(t)),this.isSaplingCompatible()&&(y+=64,y+=8),(o=new n(y)).writeInt32(this.getHeader()),o.writeUInt32(this.versionGroupId),o.writeSlice(a),o.writeSlice(u),o.writeSlice(f),o.writeSlice(h),this.isSaplingCompatible()&&(o.writeSlice(d),o.writeSlice(g)),o.writeUInt32(this.locktime),o.writeUInt32(this.expiryHeight),this.isSaplingCompatible()&&o.writeInt64(this.valueBalance),o.writeUInt32(i),e!==w){var m=this.ins[e];o.writeSlice(m.hash),o.writeUInt32(m.index),o.writeVarSlice(t),o.writeUInt64(r),o.writeUInt32(m.sequence)}var v=Buffer.alloc(16),_="ZcashSigHash";return v.write(_),v.writeUInt32LE(this.network.consensusBranchId[this.version],_.length),this.getBlake2bHash(o.getBuffer(),v)}},g.prototype.hashForWitnessV0=function(e,t,r,o){c(l.tuple(l.UInt32,l.Buffer,l.Satoshi,l.UInt32),arguments);var a=this.getPrevoutHash(o),s=this.getSequenceHash(o),u=this.getOutputsHash(o,e),f=new n(156+p(t)),h=this.ins[e];return f.writeUInt32(this.version),f.writeSlice(a),f.writeSlice(s),f.writeSlice(h.hash),f.writeUInt32(h.index),f.writeVarSlice(t),f.writeUInt64(r),f.writeUInt32(h.sequence),f.writeSlice(u),f.writeUInt32(this.locktime),f.writeUInt32(o),i.hash256(f.getBuffer())},g.prototype.hashForCashSignature=function(e,t,r,n){if(c(l.tuple(l.UInt32,l.Buffer,l.Number,l.maybe(l.UInt53)),arguments),n&g.SIGHASH_BITCOINCASHBIP143){if(l.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,n)}return this.hashForSignature(e,t,n)},g.prototype.hashForGoldSignature=function(e,t,r,n,i){c(l.tuple(l.UInt32,l.Buffer,l.Number,l.maybe(l.UInt53)),arguments);var o=n,a=(n&g.SIGHASH_BITCOINCASHBIP143)>0;if(a&&(o|=this.network.forkId<<8),i||a){if(l.Null(r))throw new Error("Bitcoin Cash sighash requires value of input to be signed.");return this.hashForWitnessV0(e,t,r,o)}return this.hashForSignature(e,t,o)},g.prototype.getHash=function(){return i.hash256(this.__toBuffer(void 0,void 0,!1))},g.prototype.getId=function(){return this.getHash().reverse().toString("hex")},g.prototype.toBuffer=function(e,t){return this.__toBuffer(e,t,!0)},g.prototype.__toBuffer=function(e,t,r){e||(e=Buffer.allocUnsafe(this.__byteLength(r)));var n=t||0;function i(t){n+=t.copy(e,n)}function o(t){n=e.writeUInt8(t,n)}function s(t){n=e.writeUInt16LE(t,n)}function u(t){n=e.writeUInt32LE(t,n)}function f(t){n=e.writeInt32LE(t,n)}function c(t){n=a.writeUInt64LE(e,t,n)}function l(t){h.encode(t,e,n),n+=h.encode.bytes}function d(e){l(e.length),i(e)}function p(e){o(g.ZCASH_G1_PREFIX_MASK|e.yLsb),i(e.x)}if(this.isOverwinterCompatible()){var y=this.overwintered?1:0;f(this.version|y<<31),u(this.versionGroupId)}else this.isDashSpecialTransaction()?(s(this.version),s(this.type)):f(this.version);var m=r&&this.hasWitnesses();return m&&(o(g.ADVANCED_TRANSACTION_MARKER),o(g.ADVANCED_TRANSACTION_FLAG)),this.timestamp&&u(this.timestamp),l(this.ins.length),this.ins.forEach((function(e){i(e.hash),u(e.index),d(e.script),u(e.sequence)})),l(this.outs.length),this.outs.forEach((function(t){g.USE_STRING_VALUES?function(t){n=a.writeUInt64LEasString(e,t,n)}(t.value):t.valueBuffer?i(t.valueBuffer):c(t.value),d(t.script)})),m&&this.ins.forEach((function(e){var t;l((t=e.witness).length),t.forEach(d)})),u(this.locktime),this.isOverwinterCompatible()&&u(this.expiryHeight),this.isSaplingCompatible()&&(!function(t){n=a.writeInt64LE(e,t,n)}(this.valueBalance),l(this.vShieldedSpend.length),this.vShieldedSpend.forEach((function(e){i(e.cv),i(e.anchor),i(e.nullifier),i(e.rk),i(e.zkproof.sA),i(e.zkproof.sB),i(e.zkproof.sC),i(e.spendAuthSig)})),l(this.vShieldedOutput.length),this.vShieldedOutput.forEach((function(e){i(e.cv),i(e.cmu),i(e.ephemeralKey),i(e.encCiphertext),i(e.outCiphertext),i(e.zkproof.sA),i(e.zkproof.sB),i(e.zkproof.sC)}))),this.supportsJoinSplits()&&(l(this.joinsplits.length),this.joinsplits.forEach((function(e){c(e.vpubOld),c(e.vpubNew),i(e.anchor),e.nullifiers.forEach((function(e){i(e)})),e.commitments.forEach((function(e){i(e)})),i(e.ephemeralKey),i(e.randomSeed),e.macs.forEach((function(e){i(e)})),this.isSaplingCompatible()?(i(e.zkproof.sA),i(e.zkproof.sB),i(e.zkproof.sC)):(p(e.zkproof.gA),p(e.zkproof.gAPrime),function(e){o(g.ZCASH_G2_PREFIX_MASK|e.yLsb),i(e.x)}(e.zkproof.gB),p(e.zkproof.gBPrime),p(e.zkproof.gC),p(e.zkproof.gCPrime),p(e.zkproof.gK),p(e.zkproof.gH)),e.ciphertexts.forEach((function(e){i(e)}))}),this),this.joinsplits.length>0&&(i(this.joinsplitPubkey),i(this.joinsplitSig))),this.isSaplingCompatible()&&this.vShieldedSpend.length+this.vShieldedOutput.length>0&&i(this.bindingSig),this.isDashSpecialTransaction()&&d(this.extraPayload),void 0!==t?e.slice(t,n):e.slice(0,n)},g.prototype.toHex=function(){return this.toBuffer().toString("hex")},g.prototype.setInputScript=function(e,t){c(l.tuple(l.Number,l.Buffer),arguments),this.ins[e].script=t},g.prototype.setWitness=function(e,t){c(l.tuple(l.Number,[l.Buffer]),arguments),this.ins[e].witness=t},g.prototype.getExtraData=function(){if(this.supportsJoinSplits()){var e=4;return this.isOverwinterCompatible()&&(e+=4),e+=h.encodingLength(this.ins.length),e+=this.ins.reduce((function(e,t){return e+40+p(t.script)}),0),e+=h.encodingLength(this.outs.length),e+=this.outs.reduce((function(e,t){return e+8+p(t.script)}),0),e+=4,this.isOverwinterCompatible()&&(e+=4),this.toBuffer().slice(e)}if(this.isDashSpecialTransaction()){var t=h.encode(this.extraPayload.length);return Buffer.concat([t,this.extraPayload])}return null},e.exports=g},function(e,t,r){(function(Buffer){var t=r(114),n=r(51),i=r(397),o=r(34),a=r(15),s=r(22),u=r(400),f=r(40),BigInteger=r(37),c=r(73),l=c.getCurveByName("secp256k1"),h=i.__curve,d=r(197);function ECPair(e,t,r){if(r&&a({compressed:s.maybe(s.Boolean),network:s.maybe(s.Network)},r),r=r||{},e){if(e.signum()<=0)throw new Error("Private key must be greater than 0");if(e.compareTo(h.n)>=0)throw new Error("Private key must be less than the curve order");if(t)throw new TypeError("Unexpected publicKey parameter");this.d=e}else a(s.ECPoint,t),this.__Q=t;this.compressed=void 0===r.compressed||r.compressed,this.network=r.network||f.bitcoin}Object.defineProperty(ECPair.prototype,"Q",{get:function(){return!this.__Q&&this.d&&(this.__Q=h.G.multiply(this.d)),this.__Q}}),ECPair.fromPublicKeyBuffer=function(e,t){var r=c.Point.decodeFrom(h,e);return new ECPair(null,r,{compressed:r.compressed,network:t})},ECPair.fromPrivateKeyBuffer=function(e,t){if(!Buffer.isBuffer(e)||32!==e.length)throw new Error("invalid private key buffer");var r=BigInteger.fromBuffer(e);if(r.signum()<=0||r.compareTo(l.n)>=0)throw new Error("private key out of range");var n=new ECPair(r,null,{network:t});return!n.__Q&&l&&(n.__Q=c.Point.decodeFrom(l,d.publicKeyCreate(r.toBuffer(32),!1))),n},ECPair.fromWIF=function(e,t){var r=u.decode(e),n=r.version;if(s.Array(t)){if(!(t=t.filter((function(e){return n===e.wif})).pop()))throw new Error("Unknown network version")}else if(t=t||f.bitcoin,n!==t.wif)throw new Error("Invalid network version");return new ECPair(BigInteger.fromBuffer(r.privateKey),null,{compressed:r.compressed,network:t})},ECPair.makeRandom=function(e){var t,r=(e=e||{}).rng||o;do{var n=r(32);a(s.Buffer256bit,n),t=BigInteger.fromBuffer(n)}while(t.signum()<=0||t.compareTo(h.n)>=0);return new ECPair(t,null,e)},ECPair.prototype.getAddress=function(){return t.toBase58Check(n.hash160(this.getPublicKeyBuffer()),this.getNetwork().pubKeyHash)},ECPair.prototype.getNetwork=function(){return this.network},ECPair.prototype.getPublicKeyBuffer=function(){return this.Q.getEncoded(this.compressed)},ECPair.prototype.getPrivateKeyBuffer=function(){if(!this.d)throw new Error("Missing private key");var e=this.d.toBuffer();if(e.length>32)throw new Error("Private key size exceeds 32 bytes");if(32===e.length)return e;var t=Buffer.alloc(32);return e.copy(t,t.length-e.length,0,e.length),t},ECPair.prototype.sign=function(e){if(!this.d)throw new Error("Missing private key");var t=d.sign(e,this.d);return void 0!==t?t:i.sign(e,this.d)},ECPair.prototype.toWIF=function(){if(!this.d)throw new Error("Missing private key");return u.encode(this.network.wif,this.d.toBuffer(32),this.compressed)},ECPair.prototype.verify=function(e,t){var r=d.verify(e,t,this.getPublicKeyBuffer());return void 0!==r?r:i.verify(e,t,this.Q)},e.exports=ECPair}).call(this,r(9).Buffer)},function(e,t,r){var Buffer=r(7).Buffer,n=r(394),i=r(59),o=r(19),a=r(106),s=r(40),u=r(15),f=r(22);function c(e){var t=i.decode(e);if(t.length<21)throw new TypeError(e+" is too short");if(t.length>22)throw new TypeError(e+" is too long");var r=22===t.length,n=r?2:1;return{version:r?t.readUInt16BE(0):t[0],hash:t.slice(n)}}function l(e){var t=n.decode(e),r=n.fromWords(t.words.slice(1));return{version:t.words[0],prefix:t.prefix,data:Buffer.from(r)}}function h(e,t){u(f.tuple(f.Hash160bit,f.UInt16),arguments);var r=t>255,n=r?22:21,o=r?2:1,a=Buffer.allocUnsafe(n);return r?a.writeUInt16BE(t,0):a.writeUInt8(t,0),e.copy(a,o),i.encode(a)}function d(e,t,r){var i=n.toWords(e);return i.unshift(t),n.encode(r,i)}e.exports={fromBase58Check:c,fromBech32:l,fromOutputScript:function(e,t){if(t=t||s.bitcoin,a.pubKeyHash.output.check(e))return h(o.compile(e).slice(3,23),t.pubKeyHash);if(a.scriptHash.output.check(e))return h(o.compile(e).slice(2,22),t.scriptHash);if(a.witnessPubKeyHash.output.check(e))return d(o.compile(e).slice(2,22),0,t.bech32);if(a.witnessScriptHash.output.check(e))return d(o.compile(e).slice(2,34),0,t.bech32);throw new Error(o.toASM(e)+" has no matching Address")},toBase58Check:h,toBech32:d,toOutputScript:function(e,t){var r;t=t||s.bitcoin;try{r=c(e)}catch(e){}if(r){if(r.version===t.pubKeyHash)return a.pubKeyHash.output.encode(r.hash);if(r.version===t.scriptHash)return a.scriptHash.output.encode(r.hash)}else{try{r=l(e)}catch(e){}if(r){if(r.prefix!==t.bech32)throw new Error(e+" has an invalid prefix");if(0===r.version){if(20===r.data.length)return a.witnessPubKeyHash.output.encode(r.data);if(32===r.data.length)return a.witnessScriptHash.output.encode(r.data)}}}throw new Error(e+" has no matching Script")}}},function(e,t,r){"use strict";(function(Buffer){var e=r(14);t.__esModule=!0,t.xpubDerive=function(e,t,r,i,a){var s=u(e,i||n.networks.bitcoin),f=u(t,i||n.networks.bitcoin);return function(e,t,r){var n=e.derive(r).toBase58(),i=t.toBase58();if(n!==i)throw o.ERRORS.TypedError("Runtime","checkDerivation: Invalid child cross-check public key. Derived: "+n+", Received: "+i)}(s,f,r),e},t.convertMultisigPubKey=t.xpubToHDNodeType=t.convertBitcoinXpub=t.convertXpub=void 0;var n=e(r(31)),i=e(r(73)),o=r(6),a=i.getCurveByName("secp256k1"),s=function(e,t,r){var i=n.HDNode.fromBase58(e,t);return r&&(i.keyPair.network=r),i.toBase58()};t.convertXpub=s;t.convertBitcoinXpub=function(e,t){if(76067358===t.bip32.public)return e;var r=n.HDNode.fromBase58(e);return r.keyPair.network=t,r.toBase58()};var u=function(e,t){var r=function(e,t){var r=Buffer.from(e.chain_code,"hex"),s=Buffer.from(e.public_key,"hex");if(null==a)throw o.ERRORS.TypedError("Runtime","pubNode2bjsNode: secp256k1 is null");var u=i.Point.decodeFrom(a,s),f=new n.HDNode(new n.ECPair(null,u,{network:t}),r);return f.depth=+e.depth,f.index=+e.child_num,f.parentFingerprint=e.fingerprint,f}(e.node,t),u=r.toBase58(),f=s(e.xpub,t);if(u!==f)throw o.ERRORS.TypedError("Runtime","pubKey2bjsNode: Invalid public key transmission detected. Key: "+u+", Received: "+f);return r};var f=function(e,t){var r=n.HDNode.fromBase58(e,t);return{depth:r.depth,child_num:r.index,fingerprint:r.parentFingerprint,public_key:r.keyPair.getPublicKeyBuffer().toString("hex"),chain_code:r.chainCode.toString("hex")}};t.xpubToHDNodeType=f;t.convertMultisigPubKey=function(e,t){return t.multisig&&t.multisig.pubkeys&&t.multisig.pubkeys.forEach((function(t){"string"==typeof t.node&&(t.node=f(t.node,e))})),t}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(75);e.exports=n.call(Function.call,Object.prototype.hasOwnProperty)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.deferred=function(){var e=function(){},t=function(){};return{promise:new Promise((function(r,n){e=r,t=n})),resolve:e,reject:t}}},function(e,t,r){"use strict"; /** * @license * https://github.com/ealmansi/cashaddrjs * Copyright (c) 2017-2020 Emilio Almansi * Distributed under the MIT software license, see the accompanying * file LICENSE or http://www.opensource.org/licenses/mit-license.php. - */function n(e){var t=new Error;this.name=t.name="ValidationError",this.message=t.message=e,this.stack=t.stack}n.prototype=Object.create(Error.prototype),e.exports={ValidationError:n,validate:function(e,t){if(!e)throw new n(t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitByCompleteness=function(e){var t={complete:[],incomplete:[]};return e.forEach((function(e){"complete"===e.type||"send-max"===e.type||"opreturn"===e.type?t.complete.push(e):t.incomplete.push(e)})),t},t.getMax=function(e){var t=e.filter((function(e){return"send-max-noaddress"===e.type||"send-max"===e.type}));if(t.length>=2)throw new Error("TWO-SEND-MAX");var r=e.findIndex((function(e){return"send-max-noaddress"===e.type||"send-max"===e.type})),n=1===t.length;return{id:r,exists:n}}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.coinselect=function(e,t,r,n,i,f,c,l,h,p,g,m,b){var v=function(e,t,r){var n=r?51:109;return e.map((function(e,r){return{id:r,script:{length:n},value:e.value,own:e.own,coinbase:e.coinbase,confirmations:null==e.height?0:1+t-e.height}}))}(e,r,i),w=function(e,t){var r={length:25};return e.map((function(e){if("complete"===e.type)return{value:e.amount,script:y(e.address,t)};if("noaddress"===e.type)return{value:e.amount,script:r};if("opreturn"===e.type)return{value:"0",script:{length:2+e.dataHex.length/2}};if("send-max"===e.type)return{script:y(e.address,t)};if("send-max-noaddress"===e.type)return{script:r};throw new Error("WRONG-OUTPUT-TYPE")}))}(t,h),_={inputLength:i?51:109,changeOutputLength:i?23:25,dustThreshold:l,baseFee:p,floorBaseFee:g,dustOutputFee:m},E=f?a.default:s.default,S=null==b||f?E(v,w,n,_):(0,u.finalize)(v,w,parseInt(n,10),_);if(!S.inputs)return{type:"false"};var A=S.fee,I=-1===c?-1:S.outputs[c].value,O=S.outputs.filter((function(e,r){return r!==t.length})).map((function(e){return e.value})).reduce((function(e,t){return new o.default(e).plus(t)}),new o.default(0)).plus(new o.default(S.fee)),P=(0,u.transactionBytes)(S.inputs,S.outputs),M=A/P;return{type:"true",result:d(d({},S),{},{fee:S.fee.toString(),feePerByte:M.toString(),bytes:P,max:I,totalSpent:O.toString()})}};var i=r(31),o=l(r(29)),a=l(r(496)),s=l(r(497)),u=r(52),f=(function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r)}(r(120)),r(224));function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function l(e){return e&&e.__esModule?e:{default:e}}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t-1)return"electron"}return"web"};t.getEnv=u;var f=function(e){if("string"==typeof e)return e.match(/^https:\/\/([A-Za-z0-9\-_]+\.)*trezor\.io\//)||e.match(/^https?:\/\/localhost:[58][0-9]{3}\//)||e.match(/^https:\/\/([A-Za-z0-9\-_]+\.)*sldev\.cz\//)||e.match(/^https?:\/\/([A-Za-z0-9\-_]+\.)*trezoriovpjcahpzkrewelclulmszwbqpzmzgub37gbcjlvluxtruqad\.onion\//)?e:void 0};t.corsValidator=f;t.parse=function(t){void 0===t&&(t={});var r=function(e){for(var t=1;t=0}));if(n){var c=n.split("=")[1];r.connectSrc=f(decodeURIComponent(c)),r.debug=!0}}var l=r.connectSrc||a;return r.iframeSrc=l+"iframe.html",r.popupSrc=l+"popup.html",r.webusbSrc=l+"webusb.html","boolean"==typeof t.transportReconnect&&(r.transportReconnect=t.transportReconnect),"boolean"==typeof t.webusb&&(r.webusb=t.webusb),"boolean"==typeof t.popup&&(r.popup=t.popup),"boolean"==typeof t.lazyLoad&&(r.lazyLoad=t.lazyLoad),"boolean"==typeof t.pendingTransportEvent&&(r.pendingTransportEvent=t.pendingTransportEvent),"undefined"!=typeof window&&window.location&&"file:"===window.location.protocol&&(r.origin="file://"+window.location.pathname,r.webusb=!1),"string"==typeof t.extension&&(r.extension=t.extension),"string"==typeof t.env?r.env=t.env:r.env=u(),"number"==typeof t.timestamp&&(r.timestamp=t.timestamp),"number"==typeof t.interactionTimeout&&(r.interactionTimeout=t.interactionTimeout),"object"==typeof t.manifest&&(r.manifest=function(e){if(e&&"string"==typeof e.email&&"string"==typeof e.appUrl)return{email:e.email,appUrl:e.appUrl}}(t.manifest)),s=r}}).call(this,r(24))},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getOrigin=t.httpRequest=void 0;var i=n(r(1)),o=n(r(2));r(128);var a=function(){var e=(0,o.default)(i.default.mark((function e(t,r){var n,o;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="text"),e.next=3,fetch(t,{credentials:"same-origin"});case 3:if(!(n=e.sent).ok){e.next=23;break}if("json"!==r){e.next=12;break}return e.next=8,n.text();case 8:return o=e.sent,e.abrupt("return",JSON.parse(o));case 12:if("binary"!==r){e.next=18;break}return e.next=15,n.arrayBuffer();case 15:return e.abrupt("return",e.sent);case 18:return e.next=20,n.text();case 20:return e.abrupt("return",e.sent);case 21:e.next=24;break;case 23:throw new Error("httpRequest error: "+t+" "+n.statusText);case 24:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();t.httpRequest=a;t.getOrigin=function(e){if(0===e.indexOf("file://"))return"file://";var t=e.match(/^.+\:\/\/[^\/]+/);return Array.isArray(t)&&t.length>0?t[0]:"unknown"}},function(e,t,r){"use strict";r.r(t),r.d(t,"Headers",(function(){return p})),r.d(t,"Request",(function(){return _})),r.d(t,"Response",(function(){return S})),r.d(t,"DOMException",(function(){return I})),r.d(t,"fetch",(function(){return O}));var n="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==n&&n,i="URLSearchParams"in n,o="Symbol"in n&&"iterator"in Symbol,a="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in n,u="ArrayBuffer"in n;if(u)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&f.indexOf(Object.prototype.toString.call(e))>-1};function l(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return o&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function y(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function g(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function m(e){var t=new FileReader,r=g(t);return t.readAsArrayBuffer(e),r}function b(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:a&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():u&&a&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=b(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=b(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var e=y(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=y(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(m)}),this.text=function(){var e,t,r,n=y(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=g(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function S(e,t){if(!(this instanceof S))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"",this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}_.prototype.clone=function(){return new _(this,{body:this._bodyInit})},v.call(_.prototype),v.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:0,statusText:""});return e.type="error",e};var A=[301,302,303,307,308];S.redirect=function(e,t){if(-1===A.indexOf(t))throw new RangeError("Invalid status code");return new S(null,{status:t,headers:{location:e}})};var I=n.DOMException;try{new I}catch(e){(I=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack}).prototype=Object.create(Error.prototype),I.prototype.constructor=I}function O(e,t){return new Promise((function(r,i){var o=new _(e,t);if(o.signal&&o.signal.aborted)return i(new I("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;setTimeout((function(){r(new S(i,n))}),0)},s.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},s.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},s.onabort=function(){setTimeout((function(){i(new I("Aborted","AbortError"))}),0)},s.open(o.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(o.url),!0),"include"===o.credentials?s.withCredentials=!0:"omit"===o.credentials&&(s.withCredentials=!1),"responseType"in s&&(a?s.responseType="blob":u&&o.headers.get("Content-Type")&&-1!==o.headers.get("Content-Type").indexOf("application/octet-stream")&&(s.responseType="arraybuffer")),!t||"object"!=typeof t.headers||t.headers instanceof p?o.headers.forEach((function(e,t){s.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){s.setRequestHeader(e,h(t.headers[e]))})),o.signal&&(o.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&o.signal.removeEventListener("abort",f)}),s.send(void 0===o._bodyInit?null:o._bodyInit)}))}O.polyfill=!0,n.fetch||(n.fetch=O,n.Headers=p,n.Request=_,n.Response=S)},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=o}))),2===s&&a?(null!==p&&null!==b&&null!==v&&(i=f.filterSafeListByFirmware(i,[p,b,v])),i=f.filterSafeListByBootloader(i,[s,u,c])):i=1===s&&a?f.filterSafeListByBootloader(i,[s,u,c]):f.filterSafeListByFirmware(i,[s,u,c]),!i.length)return null;var _=function(e,t){return t.bootloader_mode?t.firmware_present&&1===t.major_version?null:t.firmware_present&&2===t.major_version?e.filter((function(e){return h.isNewer(e.version,[t.fw_major,t.fw_minor,t.fw_patch])})):e:e.filter((function(e){return h.isNewer(e.version,[t.major_version,t.minor_version,t.patch_version])}))}(i,n);return{changelog:_,release:i[0],isLatest:m(i[0],w),isRequired:g(_),isNewer:y(i[0],n)}},t.getBinary=function(e){var r=e.features,i=e.releases,o=e.baseUrl,a=e.baseUrlBeta,f=e.version,l=e.btcOnly,y=e.intermediary,g=void 0!==y&&y;return s(void 0,void 0,void 0,(function(){var e,s,y,m,b,v;return u(this,(function(u){switch(u.label){case 0:if(e=d.parseFeatures(r),s=t.getInfo({features:r,releases:i}),g)return[3,1];if(y=i.find((function(e){return h.isEqual(e.version,f)})),!s||!y)throw new Error("no firmware found for this device");return[3,3];case 1:return[4,c.fetchFirmware(o+"/firmware/1/trezor-inter-1.8.0.bin")];case 2:return m=u.sent(),[2,{binary:p({fw:m,features:e})}];case 3:if(l&&!y.url_bitcoinonly)throw new Error("firmware version "+f+" does not exist in btc only variant");if(!h.isEqual(y.version,s.release.version))throw new Error("version provided as param does not match firmware version found by features in bootloader");return b="beta"===y.channel?a:o,[4,c.fetchFirmware(b+"/"+(l?y.url_bitcoinonly:y.url))];case 4:return v=u.sent(),[2,n(n({},s),{binary:p({fw:v,features:e})})]}}))}))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNewerOrEqual=t.isEqual=t.isNewer=t.toString=t.parse=void 0,t.parse=function(e){return{major:e[0],minor:e[1],patch:e[2]}},t.toString=function(e){return e[0]+"."+e[1]+"."+e[2]},t.isNewer=function(e,r){var n=t.parse(e),i=t.parse(r);return n.major-i.major!=0?n.major>i.major:n.minor-i.minor!=0?n.minor>i.minor:n.patch-i.patch!=0&&n.patch>i.patch},t.isEqual=function(e,r){return t.toString(e)===t.toString(r)},t.isNewerOrEqual=function(e,r){return t.isNewer(e,r)||t.isEqual(e,r)}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";var Buffer=r(7).Buffer,n=r(248).Transform;function i(e){n.call(this),this._block=Buffer.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(10)(i,n),i.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},i.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},i.prototype.update=function(e,t){if(function(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(e)||(e=Buffer.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},function(e,t,r){"use strict";(function(t,n){var i;e.exports=A,A.ReadableState=S;r(25).EventEmitter;var o=function(e,t){return e.listeners(t).length},a=r(134),Buffer=r(9).Buffer,s=t.Uint8Array||function(){};var u,f=r(249);u=f&&f.debuglog?f.debuglog("stream"):function(){};var c,l,h,d=r(250),p=r(135),y=r(136).getHighWaterMark,g=r(43).codes,m=g.ERR_INVALID_ARG_TYPE,b=g.ERR_STREAM_PUSH_AFTER_EOF,v=g.ERR_METHOD_NOT_IMPLEMENTED,w=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(10)(A,a);var _=p.errorOrDestroy,E=["error","close","destroy","pause","resume"];function S(e,t,n){i=i||r(44),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=y(this,e,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(c||(c=r(38).StringDecoder),this.decoder=new c(e.encoding),this.encoding=e.encoding)}function A(e){if(i=i||r(44),!(this instanceof A))return new A(e);var t=this instanceof i;this._readableState=new S(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function I(e,t,r,n,i){u("readableAddChunk",t);var o,a=e._readableState;if(null===t)a.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?M(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,k(e)))}(e,a);else if(i||(o=function(e,t){var r;n=t,Buffer.isBuffer(n)||n instanceof s||"string"==typeof t||void 0===t||e.objectMode||(r=new m("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(a,t)),o)_(e,o);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n)a.endEmitted?_(e,new w):O(e,a,t,!0);else if(a.ended)_(e,new b);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?O(e,a,t,!1):T(e,a)):O(e,a,t,!1)}else n||(a.reading=!1,T(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(k,e))}function k(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,B(e)}function T(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){u("readable nexttick read 0"),e.read(0)}function N(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),B(e),t.flowing&&!t.reading&&e.read(0)}function B(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function U(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function L(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):M(this),null;if(0===(e=P(e,t))&&t.ended)return 0===t.length&&U(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?D(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&U(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){_(this,new v("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?f:g;function s(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",y),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",f),r.removeListener("end",g),r.removeListener("data",h),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function f(){u("onend"),e.end()}i.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,B(e))}}(r);e.on("drain",c);var l=!1;function h(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==L(i.pipes,e))&&!l&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),g(),e.removeListener("error",d),0===o(e,"error")&&_(e,t)}function p(){e.removeListener("finish",y),g()}function y(){u("onfinish"),e.removeListener("close",p),g()}function g(){u("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",y),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||n.nextTick(C,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(R,this),r},A.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(R,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(N,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new p("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,T(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=c.destroy,A.prototype._undestroy=c.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(24),r(16))},function(e,t,r){"use strict";e.exports=c;var n=r(43).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(44);function f(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function h(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,d=0|this._e,p=0|this._f,y=0|this._g,g=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+h(r[m-15])+r[m-16];for(var b=0;b<64;++b){var v=g+l(d)+u(d,p,y)+o[b]+r[b]|0,w=c(n)+f(n,i,a)|0;g=y,y=p,p=d,d=s+v|0,s=a,a=i,i=n,n=v+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=s},function(e,t,r){var n=r(10),i=r(45),Buffer=r(7).Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function s(){this.init(),this._w=a,i.call(this,128,112)}function u(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function c(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function y(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function g(e,t){return e>>>0>>0?1:0}n(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,a=0|this._dh,s=0|this._eh,m=0|this._fh,b=0|this._gh,v=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,A=0|this._el,I=0|this._fl,O=0|this._gl,P=0|this._hl,M=0;M<32;M+=2)t[M]=e.readInt32BE(4*M),t[M+1]=e.readInt32BE(4*M+4);for(;M<160;M+=2){var k=t[M-30],T=t[M-30+1],x=h(k,T),R=d(T,k),C=p(k=t[M-4],T=t[M-4+1]),N=y(T,k),B=t[M-14],D=t[M-14+1],U=t[M-32],j=t[M-32+1],L=R+D|0,F=x+B+g(L,R)|0;F=(F=F+C+g(L=L+N|0,N)|0)+U+g(L=L+j|0,j)|0,t[M]=F,t[M+1]=L}for(var H=0;H<160;H+=2){F=t[H],L=t[H+1];var q=f(r,n,i),V=f(w,_,E),K=c(r,w),z=c(w,r),G=l(s,A),Q=l(A,s),W=o[H],Y=o[H+1],Z=u(s,m,b),J=u(A,I,O),X=P+Q|0,$=v+G+g(X,P)|0;$=($=($=$+Z+g(X=X+J|0,J)|0)+W+g(X=X+Y|0,Y)|0)+F+g(X=X+L|0,L)|0;var ee=z+V|0,te=K+q+g(ee,z)|0;v=b,P=O,b=m,O=I,m=s,I=A,s=a+$+g(A=S+X|0,S)|0,a=i,S=E,i=n,E=_,n=r,_=w,r=$+te+g(w=X+ee|0,X)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+A|0,this._fl=this._fl+I|0,this._gl=this._gl+O|0,this._hl=this._hl+P|0,this._ah=this._ah+r+g(this._al,w)|0,this._bh=this._bh+n+g(this._bl,_)|0,this._ch=this._ch+i+g(this._cl,E)|0,this._dh=this._dh+a+g(this._dl,S)|0,this._eh=this._eh+s+g(this._el,A)|0,this._fh=this._fh+m+g(this._fl,I)|0,this._gh=this._gh+b+g(this._gl,O)|0,this._hh=this._hh+v+g(this._hl,P)|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=s},function(e,t,r){"use strict";(function(t,n){var i=r(62);e.exports=b;var o,a=r(131);b.ReadableState=m;r(25).EventEmitter;var s=function(e,t){return e.listeners(t).length},u=r(142),Buffer=r(90).Buffer,f=t.Uint8Array||function(){};var c=Object.create(r(53));c.inherits=r(10);var l=r(260),h=void 0;h=l&&l.debuglog?l.debuglog("stream"):function(){};var d,p=r(261),y=r(143);c.inherits(b,u);var g=["error","close","destroy","pause","resume"];function m(e,t){e=e||{};var n=t instanceof(o=o||r(39));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,a=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(a||0===a)?a:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=r(38).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function b(e){if(o=o||r(39),!(this instanceof b))return new b(e);this._readableState=new m(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function v(e,t,r,n,i){var o,a=e._readableState;null===t?(a.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,E(e)}(e,a)):(i||(o=function(e,t){var r;n=t,Buffer.isBuffer(n)||n instanceof f||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(a,t)),o?e.emit("error",o):a.objectMode||t&&t.length>0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?w(e,a,t,!1):A(e,a)):w(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function E(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(S,e):S(e))}function S(e){h("emit readable"),e.emit("readable"),M(e)}function A(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=Buffer.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function T(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(x,t,e))}function x(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):E(this),null;if(0===(e=_(e,t))&&t.ended)return 0===t.length&&T(this),null;var n,i=t.needReadable;return h("need readable",i),(0===t.length||t.length-e0?k(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&T(this)),null!==n&&this.emit("data",n),n},b.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:v;function f(t,n){h("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,h("cleanup"),e.removeListener("close",m),e.removeListener("finish",b),e.removeListener("drain",l),e.removeListener("error",g),e.removeListener("unpipe",f),r.removeListener("end",c),r.removeListener("end",v),r.removeListener("data",y),d=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function c(){h("onend"),e.end()}o.endEmitted?i.nextTick(u):r.once("end",u),e.on("unpipe",f);var l=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,M(e))}}(r);e.on("drain",l);var d=!1;var p=!1;function y(t){h("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==R(o.pipes,e))&&!d&&(h("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function g(t){h("onerror",t),v(),e.removeListener("error",g),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",b),v()}function b(){h("onfinish"),e.removeListener("close",m),v()}function v(){h("unpipe"),r.unpipe(e)}return r.on("data",y),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",g),e.once("close",m),e.once("finish",b),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},b.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;or||t!=t)throw new TypeError("Bad key length")}},function(e,t,r){(function(t){var r;if(t.browser)r="utf-8";else if(t.version){r=parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else r="utf-8";e.exports=r}).call(this,r(16))},function(e,t,r){var n=r(145),i=r(86),o=r(87),Buffer=r(7).Buffer,a=r(148),s=r(149),u=r(151),f=Buffer.alloc(128),c={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(e,t,r){var a=function(e){function t(t){return o(e).update(t).digest()}return"rmd160"===e||"ripemd160"===e?function(e){return(new i).update(e).digest()}:"md5"===e?n:t}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length>>0},t.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},t.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},t.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},t.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},t.padSplit=function(e,t,r){for(var n=e.toString(2);n.length>>1];r=o.r28shl(r,s),i=o.r28shl(i,s),o.pc2(r,i,e.keys,a)}},u.prototype._update=function(e,t,r,n){var i=this._desState,a=o.readUInt32BE(e,t),s=o.readUInt32BE(e,t+4);o.ip(a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,a,s,i.tmp,0):this._decrypt(i,a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],o.writeUInt32BE(r,a,n),o.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,a=h}o.rip(s,a,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var a=r,s=t,u=e.keys.length-2;u>=0;u-=2){var f=e.keys[u],c=e.keys[u+1];o.expand(a,e.tmp,0),f^=e.tmp[0],c^=e.tmp[1];var l=o.substitute(f,c),h=a;a=(s^o.permute(l))>>>0,s=h}o.rip(a,s,n,i)}},function(e,t,r){var n=r(54),Buffer=r(7).Buffer,i=r(155);function o(e){var t=e._cipher.encryptBlockRaw(e._prev);return i(e._prev),t}t.encrypt=function(e,t){var r=Math.ceil(t.length/16),i=e._cache.length;e._cache=Buffer.concat([e._cache,Buffer.allocUnsafe(16*r)]);for(var a=0;ae;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(f))for(;r.mod(c).cmp(l);)r.iadd(d)}else for(;r.mod(o).cmp(h);)r.iadd(d);if(g(p=r.shrn(1))&&g(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},function(e,t,r){var n=r(18),i=r(95);function o(e){this.rand=e||new i.Rand}e.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var f=e.shrn(u),c=s.toRed(o);t>0;t--){var l=this._randrange(new n(2),s);r&&r(l);var h=l.toRed(o).redPow(f);if(0!==h.cmp(a)&&0!==h.cmp(c)){for(var d=1;d0;t--){var c=this._randrange(new n(2),a),l=e.gcd(c);if(0!==l.cmpn(1))return l;var h=c.toRed(i).redPow(u);if(0!==h.cmp(o)&&0!==h.cmp(f)){for(var d=1;d0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n)a.endEmitted?_(e,new w):O(e,a,t,!0);else if(a.ended)_(e,new b);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?O(e,a,t,!1):T(e,a)):O(e,a,t,!1)}else n||(a.reading=!1,T(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(k,e))}function k(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,B(e)}function T(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){u("readable nexttick read 0"),e.read(0)}function N(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),B(e),t.flowing&&!t.reading&&e.read(0)}function B(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function U(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function L(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):M(this),null;if(0===(e=P(e,t))&&t.ended)return 0===t.length&&U(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?D(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&U(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){_(this,new v("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?f:g;function s(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",y),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",f),r.removeListener("end",g),r.removeListener("data",h),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function f(){u("onend"),e.end()}i.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,B(e))}}(r);e.on("drain",c);var l=!1;function h(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==L(i.pipes,e))&&!l&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),g(),e.removeListener("error",d),0===o(e,"error")&&_(e,t)}function p(){e.removeListener("finish",y),g()}function y(){u("onfinish"),e.removeListener("close",p),g()}function g(){u("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",y),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||n.nextTick(C,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(R,this),r},A.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(R,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(N,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new p("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,T(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=c.destroy,A.prototype._undestroy=c.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(24),r(16))},function(e,t,r){"use strict";e.exports=c;var n=r(46).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(47);function f(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,r){"use strict";var n=t;n.base=r(68),n.short=r(306),n.mont=r(307),n.edwards=r(308)},function(e,t,r){"use strict";var n=r(30).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function a(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?a(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=a,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(30),i=r(55),o=r(169),a=r(27),s=n.sum32,u=n.sum32_4,f=n.sum32_5,c=o.ch32,l=o.maj32,h=o.s0_256,d=o.s1_256,p=o.g0_256,y=o.g1_256,g=i.BlockHash,m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;g.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}n.inherits(b,g),e.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n=49&&f<=54?f-49+10:f>=17&&f<=22?f-17+10:f,a|=u}return n(!(240&a),"Invalid character in "+e),i}function s(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?f-49+10:f>=17?f-17+10:f,n(f>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this._strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,u=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(e){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var c=["","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"],l=[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],h=[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];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=l[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(d).toString(e);r=(p=p.idivn(d)).isZero()?y+r:c[f-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},Buffer&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(Buffer,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,y=d>>>13,g=0|a[2],m=8191&g,b=g>>>13,v=0|a[3],w=8191&v,_=v>>>13,E=0|a[4],S=8191&E,A=E>>>13,I=0|a[5],O=8191&I,P=I>>>13,M=0|a[6],k=8191&M,T=M>>>13,x=0|a[7],R=8191&x,C=x>>>13,N=0|a[8],B=8191&N,D=N>>>13,U=0|a[9],j=8191&U,L=U>>>13,F=0|s[0],H=8191&F,q=F>>>13,V=0|s[1],K=8191&V,z=V>>>13,G=0|s[2],Q=8191&G,W=G>>>13,Y=0|s[3],Z=8191&Y,J=Y>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,H))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,H)|0))<<13)|0;f=((o=Math.imul(h,q))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(y,H)|0,o=Math.imul(y,q);var me=(f+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,z)|0)+Math.imul(h,K)|0))<<13)|0;f=((o=o+Math.imul(h,z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(b,H)|0,o=Math.imul(b,q),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,z)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,z)|0;var be=(f+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,Q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,z)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,W)|0;var ve=(f+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(A,H)|0,o=Math.imul(A,q),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,z)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,J)|0;var we=(f+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,H),i=(i=Math.imul(O,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,z)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,q))+Math.imul(T,H)|0,o=Math.imul(T,q),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,z)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0;var Se=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,q))+Math.imul(D,H)|0,o=Math.imul(D,q),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,z)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,z)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,H),i=(i=Math.imul(j,q))+Math.imul(L,H)|0,o=Math.imul(L,q),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,z)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,z)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Ie=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ye)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,z))+Math.imul(L,K)|0,o=Math.imul(L,z),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Oe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;f=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,W))+Math.imul(L,Q)|0,o=Math.imul(L,W),n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(T,re)|0,o=o+Math.imul(T,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var Pe=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,J))+Math.imul(L,Z)|0,o=Math.imul(L,J),n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,fe)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var Me=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,ee))+Math.imul(L,$)|0,o=Math.imul(L,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var ke=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,ye)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(P,pe)|0))<<13)|0;f=((o=o+Math.imul(P,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(T,pe)|0))<<13)|0;f=((o=o+Math.imul(T,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(L,le)|0,o=Math.imul(L,he);var Ce=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ye)|0)+Math.imul(D,pe)|0))<<13)|0;f=((o=o+Math.imul(D,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ne=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ye))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ye))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Se,u[8]=Ae,u[9]=Ie,u[10]=Oe,u[11]=Pe,u[12]=Me,u[13]=ke,u[14]=Te,u[15]=xe,u[16]=Re,u[17]=Ce,u[18]=Ne,0!==f&&(u[19]=f,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(e,t,r){return y(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(p=d),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?y(this,e,t):g(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function I(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(w,v),w.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new w;else if("p224"===e)t=new _;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return b[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var y=d,g=0;0!==y.cmp(s);g++)y=y.redSqr();n(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new I(e)},i(I,A),I.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},I.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},I.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},I.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(66)(e))},function(e,t,r){"use strict";const n=t;n.bignum=r(18),n.define=r(325).define,n.base=r(328),n.constants=r(329),n.decoders=r(176),n.encoders=r(174)},function(e,t,r){"use strict";const n=t;n.der=r(175),n.pem=r(326)},function(e,t,r){"use strict";const n=r(10),Buffer=r(100).Buffer,i=r(101),o=r(103);function a(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){i.call(this,"der",e)}function u(e){return e<10?"0"+e:e}e.exports=a,a.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(s,i),s.prototype._encodeComposite=function(e,t,r,n){const i=function(e,t,r,n){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(o.tagByName.hasOwnProperty(e))i=o.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);i=e}if(i>=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6,i}(e,t,r,this.reporter);if(n.length<128){const e=Buffer.alloc(2);return e[0]=i,e[1]=n.length,this._createEncoderBuffer([e,n])}let a=1;for(let e=n.length;e>=256;e>>=8)a++;const s=Buffer.alloc(2+a);s[0]=i,s[1]=128|a;for(let e=1+a,t=n.length;t>0;e--,t>>=8)s[e]=255&t;return this._createEncoderBuffer([s,n])},s.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=Buffer.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},s.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!Buffer.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=Buffer.from(t)}if(Buffer.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=Buffer.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},s.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},s.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function l(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t0?(t._cancelableRequest=n,t.device.emit(u.DEVICE.PIN,t.device,e,(function(e,i){t._cancelableRequest=void 0,e||null==i?n(e):r(i)}))):(console.warn("[DeviceCommands] [call] PIN callback not configured, cancelling request"),n(u.ERRORS.TypedError("Runtime","_promptPin: PIN callback not configured")))}))},t._promptPassphrase=function(){var e=this;return new Promise((function(t,r){e.device.listenerCount(u.DEVICE.PASSPHRASE)>0?(e._cancelableRequest=r,e.device.emit(u.DEVICE.PASSPHRASE,e.device,(function(n,i){e._cancelableRequest=void 0,i?r(i):t(n)}))):(console.warn("[DeviceCommands] [call] Passphrase callback not configured, cancelling request"),r(u.ERRORS.TypedError("Runtime","_promptPassphrase: Passphrase callback not configured")))}))},t._promptWord=function(e){var t=this;return new Promise((function(r,n){t._cancelableRequest=n,t.device.emit(u.DEVICE.WORD,t.device,e,(function(e,i){t._cancelableRequest=void 0,e||null==i?n(e):r(i.toLocaleLowerCase())}))}))},t.debugLinkDecision=function(){var e=(0,a.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.transport.acquire({path:this.device.originalDescriptor.path,previous:this.device.originalDescriptor.debugSession},!0);case 2:return r=e.sent,e.next=5,(0,p.resolveAfter)(501,null);case 5:return e.next=7,this.transport.post(r,"DebugLinkDecision",t,!0);case 7:return e.next=9,this.transport.release(r,!0,!0);case 9:return this.device.originalDescriptor.debugSession=null,e.next=12,(0,p.resolveAfter)(501,null);case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.debugLinkGetState=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.transport.acquire({path:this.device.originalDescriptor.path,previous:this.device.originalDescriptor.debugSession},!0);case 2:return t=e.sent,e.next=5,(0,p.resolveAfter)(501,null);case 5:return e.next=7,this.transport.call(t,"DebugLinkGetState",{},!0);case 7:return r=e.sent,v(r,"DebugLinkState"),e.next=11,this.transport.release(t,!0,!0);case 11:return e.next=13,(0,p.resolveAfter)(501,null);case 13:return e.abrupt("return",r.message);case 14:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.getAccountDescriptor=function(){var e=(0,a.default)(o.default.mark((function e(t,r){var n,i,a,s,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Array.isArray(r)?r:(0,h.getAccountAddressN)(t,r),"bitcoin"!==t.type){e.next=8;break}return e.next=4,this.getHDNode(n,t,!1);case 4:return i=e.sent,e.abrupt("return",{descriptor:i.xpubSegwit||i.xpub,legacyXpub:i.xpub,address_n:n});case 8:if("ethereum"!==t.type){e.next=15;break}return e.next=11,this.ethereumGetAddress({address_n:n},t);case 11:return a=e.sent,e.abrupt("return",{descriptor:a.address,address_n:n});case 15:if("XRP"!==t.shortcut&&"tXRP"!==t.shortcut){e.next=21;break}return e.next=18,this.typedCall("RippleGetAddress","RippleAddress",{address_n:n});case 18:return s=e.sent,u=s.message,e.abrupt("return",{descriptor:u.address,address_n:n});case 21:return e.abrupt("return");case 22:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.cancel=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._cancelableRequest){e.next=4;break}return this._cancelableRequest(),this._cancelableRequest=void 0,e.abrupt("return");case 4:if(t=this.transport,r=t.activeName,n=t.version,!(r&&"BridgeTransport"===r&&(0,y.versionCompare)(n,"2.0.28")<1)){e.next=8;break}return e.next=8,this.device.legacyForceRelease();case 8:this.transport.post(this.sessionId,"Cancel",{},!1);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();t.default=E},function(e,t,r){var n=r(26);function i(e){return ee.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},function(e,t,r){var n=r(106);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function a(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function s(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function u(e,t,r){var i=function(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}(t);return"Expected "+s(e)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function f(e,t,r){r=r||o(t),this.message=u(e,t,r),a(this,f),this.__type=e,this.__value=t,this.__valueTypeName=r}function c(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),u('property "'+s(r)+o+s(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',a(this,f),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,c.prototype=Object.create(Error.prototype),c.prototype.constructor=f,e.exports={TfTypeError:f,TfPropertyTypeError:c,tfCustomError:function(e,t){return new f(e,{},t)},tfSubError:function(e,t,r){return e instanceof c?(t=t+"."+e.__property,e=new c(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof f&&(e=new c(e.__type,t,r,e.__value,e.__valueTypeName)),a(e),e},tfJSON:s,getValueTypeName:o}},function(e,t,r){var Buffer=r(7).Buffer;e.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),n=Buffer.allocUnsafe(r),i=e<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26),s=a.OP_RESERVED;function u(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==a.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-s,u=r[r.length-2]-s;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(e,t){var r=n.decompile(e);return o(u,r,t),{m:r[0]-s,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(r=0;){var a=t*this[e++]+r[n]+i;i=Math.floor(a/67108864),r[n++]=67108863&a}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,a,s=new Array;for(o="0".charCodeAt(0),a=0;a<=9;++a)s[o++]=a;for(o="a".charCodeAt(0),a=10;a<36;++a)s[o++]=a;for(o="A".charCodeAt(0),a=10;a<36;++a)s[o++]=a;function u(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function f(e,t){var r=s[e.charCodeAt(t)];return null==r?-1:r}function c(e){var t=new BigInteger;return t.fromInt(e),t}function l(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function h(e){this.m=e}function d(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function v(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function w(){}function _(e){return e}function E(e){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}h.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},h.prototype.revert=function(e){return e},h.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},h.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},h.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},d.prototype.convert=function(e){var t=new BigInteger;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},d.prototype.revert=function(e){var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},d.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},n.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},n.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+i:this.t=0},n.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var a=8==r?255&e[n]:f(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},n.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},n.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+a+1]=this[r]>>i|s,s=(this[r]&o)<=0;--r)t[r]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()},n.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var a=r+1;a>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},n.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},n.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var f=o.t,c=o[f-1];if(0!=c){var h=c*(1<1?o[f-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(b,r)),BigInteger.ONE.dlShiftTo(f,b),b.subTo(o,o);o.t=0;){var v=r[--g]==c?this.DM:Math.floor(r[g]*d+(r[g-1]+y)*p);if((r[g]+=o.am(0,v,r,m,0,f))0&&r.rShiftTo(u,r),a<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=t.convert(this),o=l(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var a=r;r=n,n=a}return t.revert(r)},n.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(s>s)>0&&(i=!0,o=u(r));a>=0;)s>(s+=this.DB-t)):(r=this[a]>>(s-=t)&n,s<=0&&(s+=this.DB,--a)),r>0&&(i=!0),i&&(o+=u(r));return i?o:"0"},n.negate=function(){var e=new BigInteger;return BigInteger.ZERO.subTo(this,e),e},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(e){var t=new BigInteger;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},n.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new h(t):new d(t),this.exp(e,r)},w.prototype.convert=_,w.prototype.revert=_,w.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},w.prototype.sqrTo=function(e,t){e.squareTo(t)},E.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},E.prototype.revert=function(e){return e},E.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},E.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var S=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/S[S.length-1];n.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},n.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=c(r),i=new BigInteger,o=new BigInteger,a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},n.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,a=0,s=0;s=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),y,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},n.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},n.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},n.millerRabin=function(e){var t=this.subtract(BigInteger.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>S.length&&(e=S.length);for(var i=new BigInteger(null),o=[],a=0;a>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this[e]&(1<>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},n.equals=function(e){return 0==this.compareTo(e)},n.min=function(e){return this.compareTo(e)<0?this:e},n.max=function(e){return this.compareTo(e)>0?this:e},n.and=function(e){var t=new BigInteger;return this.bitwiseTo(e,p,t),t},n.or=function(e){var t=new BigInteger;return this.bitwiseTo(e,y,t),t},n.xor=function(e){var t=new BigInteger;return this.bitwiseTo(e,g,t),t},n.andNot=function(e){var t=new BigInteger;return this.bitwiseTo(e,m,t),t},n.not=function(){for(var e=new BigInteger,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var p=new BigInteger;for(n.sqrTo(a[1],p);s<=f;)a[s]=new BigInteger,n.mulTo(p,a[s-2],a[s]),s+=2}var y,g,m=e.t-1,b=!0,v=new BigInteger;for(i=l(e[m])-1;m>=0;){for(i>=u?y=e[m]>>i-u&f:(y=(e[m]&(1<0&&(y|=e[m-1]>>this.DB+i-u)),s=r;0==(1&y);)y>>=1,--s;if((i-=s)<0&&(i+=this.DB,--m),b)a[y].copyTo(o),b=!1;else{for(;s>1;)n.sqrTo(o,v),n.sqrTo(v,o),s-=2;s>0?n.sqrTo(o,v):(g=o,o=v,v=g),n.mulTo(v,a[y],o)}for(;m>=0&&0==(e[m]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(s,o)):(n.subTo(r,n),t&&a.subTo(i,a),s.subTo(o,s))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;s.compareTo(e)>=0;)s.subTo(e,s);for(;s.signum()<0;)s.addTo(e,s);return s},n.pow=function(e){return this.exp(e,new w)},n.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=S[S.length-1]){for(t=0;t0;--a){var s=r.testBit(a),u=t.testBit(a);o=o.twice(),s!==u&&(o=o.add(s?this:n))}return o},Point.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var a=e.testBit(n),s=r.testBit(n);i=i.twice(),a?i=s?i.add(o):i.add(this):s&&(i=i.add(t)),--n}return i},Point.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var t,r=this.affineX,n=this.affineY,i=this.curve.pLength;return e?(t=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((t=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(t,1+i)),r.toBuffer(i).copy(t,1),t},Point.decodeFrom=function(e,t){var r,i=t.readUInt8(0),o=4!==i,a=Math.floor((e.p.bitLength()+7)/8),s=BigInteger.fromBuffer(t.slice(1,1+a));if(o){n.equal(t.length,a+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=e.pointFromX(u,s)}else{n.equal(t.length,1+a+a,"Invalid sequence length");var f=BigInteger.fromBuffer(t.slice(1+a));r=Point.fromAffine(e,s,f)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},function(e,t,r){var n=r(112),BigInteger=r(37),Point=r(196);function i(e,t,r,n,i,o,a){this.p=e,this.a=t,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=a,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=e.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),Point.fromAffine(this,t,n)},i.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},i.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var a=r.square().mod(o),s=t.pow(3).add(n.multiply(t)).add(i).mod(o);return a.equals(s)},i.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},e.exports=i},function(e,t,r){var n,i=r(15),o=r(73),a=r(22),s=!1;try{n=r(401),s=!0}catch(e){}e.exports={available:s,publicKeyCreate:function(e,t){if(i(a.tuple(a.Buffer256bit,a.Boolean),arguments),s)return n.publicKeyCreate(e,t)},sign:function(e,t){if(i(a.tuple(a.Buffer256bit,a.BigInt),arguments),s){var r=n.sign(e,t.toBuffer(32)).signature;return o.fromDER(n.signatureExport(r))}},verify:function(e,t,r){if(i(a.tuple(a.Hash256bit,a.ECSignature,a.oneOf(a.BufferN(33),a.BufferN(65))),arguments),s)return t=new o(t.r,t.s),t=n.signatureNormalize(n.signatureImport(t.toDER())),n.verify(e,t,r)}}},function(e){e.exports=JSON.parse('{"COMPRESSED_TYPE_INVALID":"compressed should be a boolean","EC_PRIVATE_KEY_TYPE_INVALID":"private key should be a Buffer","EC_PRIVATE_KEY_LENGTH_INVALID":"private key length is invalid","EC_PRIVATE_KEY_RANGE_INVALID":"private key range is invalid","EC_PRIVATE_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting private key is invalid","EC_PRIVATE_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PRIVATE_KEY_EXPORT_DER_FAIL":"couldn\'t export to DER format","EC_PRIVATE_KEY_IMPORT_DER_FAIL":"couldn\'t import from DER format","EC_PUBLIC_KEYS_TYPE_INVALID":"public keys should be an Array","EC_PUBLIC_KEYS_LENGTH_INVALID":"public keys Array should have at least 1 element","EC_PUBLIC_KEY_TYPE_INVALID":"public key should be a Buffer","EC_PUBLIC_KEY_LENGTH_INVALID":"public key length is invalid","EC_PUBLIC_KEY_PARSE_FAIL":"the public key could not be parsed or is invalid","EC_PUBLIC_KEY_CREATE_FAIL":"private was invalid, try again","EC_PUBLIC_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting public key is invalid","EC_PUBLIC_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PUBLIC_KEY_COMBINE_FAIL":"the sum of the public keys is not valid","ECDH_FAIL":"scalar was invalid (zero or overflow)","ECDSA_SIGNATURE_TYPE_INVALID":"signature should be a Buffer","ECDSA_SIGNATURE_LENGTH_INVALID":"signature length is invalid","ECDSA_SIGNATURE_PARSE_FAIL":"couldn\'t parse signature","ECDSA_SIGNATURE_PARSE_DER_FAIL":"couldn\'t parse DER signature","ECDSA_SIGNATURE_SERIALIZE_DER_FAIL":"couldn\'t serialize signature to DER format","ECDSA_SIGN_FAIL":"nonce generation function failed or private key is invalid","ECDSA_RECOVER_FAIL":"couldn\'t recover public key from signature","MSG32_TYPE_INVALID":"message should be a Buffer","MSG32_LENGTH_INVALID":"message length is invalid","OPTIONS_TYPE_INVALID":"options should be an Object","OPTIONS_DATA_TYPE_INVALID":"options.data should be a Buffer","OPTIONS_DATA_LENGTH_INVALID":"options.data length is invalid","OPTIONS_NONCEFN_TYPE_INVALID":"options.noncefn should be a Function","RECOVERY_ID_TYPE_INVALID":"recovery should be a Number","RECOVERY_ID_VALUE_INVALID":"recovery should have value between -1 and 4","TWEAK_TYPE_INVALID":"tweak should be a Buffer","TWEAK_LENGTH_INVALID":"tweak length is invalid"}')},function(e,t,r){"use strict";(function(Buffer){var e=r(14);t.__esModule=!0,t.xpubDerive=function(e,t,r,i,a){var s=u(e,i||n.networks.bitcoin),f=u(t,i||n.networks.bitcoin);return function(e,t,r){var n=e.derive(r).toBase58(),i=t.toBase58();if(n!==i)throw o.ERRORS.TypedError("Runtime","checkDerivation: Invalid child cross-check public key. Derived: "+n+", Received: "+i)}(s,f,r),e},t.xpubToHDNodeType=t.convertBitcoinXpub=t.convertXpub=void 0;var n=e(r(31)),i=e(r(74)),o=r(6),a=i.getCurveByName("secp256k1"),s=function(e,t,r){var i=n.HDNode.fromBase58(e,t);return r&&(i.keyPair.network=r),i.toBase58()};t.convertXpub=s;t.convertBitcoinXpub=function(e,t){if(76067358===t.bip32.public)return e;var r=n.HDNode.fromBase58(e);return r.keyPair.network=t,r.toBase58()};var u=function(e,t){var r=function(e,t){var r=Buffer.from(e.chain_code,"hex"),s=Buffer.from(e.public_key,"hex");if(null==a)throw o.ERRORS.TypedError("Runtime","pubNode2bjsNode: secp256k1 is null");var u=i.Point.decodeFrom(a,s),f=new n.HDNode(new n.ECPair(null,u,{network:t}),r);return f.depth=+e.depth,f.index=+e.child_num,f.parentFingerprint=e.fingerprint,f}(e.node,t),u=r.toBase58(),f=s(e.xpub,t);if(u!==f)throw o.ERRORS.TypedError("Runtime","pubKey2bjsNode: Invalid public key transmission detected. Key: "+u+", Received: "+f);return r};t.xpubToHDNodeType=function(e,t){var r=n.HDNode.fromBase58(e,t);return{depth:r.depth,child_num:r.index,fingerprint:r.parentFingerprint,public_key:r.keyPair.getPublicKeyBuffer().toString("hex"),chain_code:r.chainCode.toString("hex")}}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.create=function(e,t){var r,n=function(e){},a=function(e){},s=new Promise(function(){var t=(0,o.default)(i.default.mark((function t(o,s){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o,a=s,"function"!=typeof e){t.next=11;break}return t.prev=3,t.next=6,e();case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(3),s(t.t0);case 11:"string"==typeof e&&(r=e);case 12:case"end":return t.stop()}}),t,null,[[3,8]])})));return function(e,r){return t.apply(this,arguments)}}());return{id:r,device:t,resolve:n,reject:a,promise:s}},t.createAsync=function(e){var t=function(e){},r=function(e){},n=new Promise((function(e,n){t=e,r=n})),a=function(){var t=(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e();case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return{resolve:t,reject:r,promise:n,run:function(){return a(),n}}},t.resolveTimeoutPromise=function(e,t){return new Promise((function(r){setTimeout((function(){r(t)}),e)}))},t.rejectTimeoutPromise=function(e,t){return new Promise((function(r,n){setTimeout((function(){n(t)}),e)}))};var i=n(r(1)),o=n(r(2))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=s(r(419)),i=s(r(440)),o=s(r(447)),a=s(r(448));function s(e){return e&&e.__esModule?e:{default:e}}try{r(128)}catch(e){}if("undefined"==typeof window){var u=r(449);n.default.setFetch(u,!0)}else n.default.setFetch(fetch,!1);var f={BridgeV2:n.default,Fallback:o.default,Lowlevel:i.default,WebUsb:a.default};t.default=f,e.exports=t.default},function(e,t,r){"use strict";(function(Buffer){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.buildOne=function(e,t,r){return new g(e,t,r).encodeOne()},t.buildAndSend=function(e,t,r,n){return b.apply(this,arguments)};var n,i=(n=r(1))&&n.__esModule?n:{default:n},o=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=a();if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var s=i?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}n.default=t,r&&r.set(t,n);return n}(r(41));function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=f(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function u(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=f)throw new Error("Config too old; "+c+" >= "+f);var l=u.wire_protocol,h=(0,o.protocolToJSON)(l.toRaw()),d=n.newBuilder({}).import(h).build();return new i.Messages(d)};var n=u(r(41)),i=r(205),o=r(427),a=u(r(438));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function u(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=s();if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var a=i?Object.getOwnPropertyDescriptor(t,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=t[o]}return n.default=t,r&&r.set(t,n),n}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.Messages=void 0;!function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=o?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}r.default=e,t&&t.set(e,r)}(r(41));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}t.Messages=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.messagesByName=t;var r={};Object.keys(t.MessageType).forEach((function(e){var n=t.MessageType[e],i=e.split("_")[1],o=e.indexOf("Deprecated");o>=0&&(i=e.substr(o)),r[n]={name:i,constructor:t[i]}})),this.messagesByType=r,this.messageTypes=t.MessageType}},function(e,t,r){"use strict";var n=r(429),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=Object.defineProperty,u=s&&function(){var e={};try{for(var t in s(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(e){return!1}}(),f=function(e,t,r,n){var i;(!(t in e)||"function"==typeof(i=n)&&"[object Function]"===o.call(i)&&n())&&(u?s(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},c=function(e,t){var r=arguments.length>2?arguments[2]:{},o=n(t);i&&(o=a.call(o,Object.getOwnPropertySymbols(t)));for(var s=0;s=0&&"[object Function]"===n.call(e.callee)),r}},function(e,t,r){"use strict";var n=r(75),i=r(209),o=i("%Function.prototype.apply%"),a=i("%Function.prototype.call%"),s=i("%Reflect.apply%",!0)||n.call(a,o),u=i("%Object.getOwnPropertyDescriptor%",!0),f=i("%Object.defineProperty%",!0),c=i("%Math.max%");if(f)try{f({},"a",{value:1})}catch(e){f=null}e.exports=function(e){var t=s(n,a,arguments);if(u&&f){var r=u(t,"length");r.configurable&&f(t,"length",{value:1+c(0,e.length-(arguments.length-1))})}return t};var l=function(){return s(n,o,arguments)};f?f(e.exports,"apply",{value:l}):e.exports.apply=l},function(e,t,r){"use strict";var n=SyntaxError,i=Function,o=TypeError,a=function(e){try{return Function('"use strict"; return ('+e+").constructor;")()}catch(e){}},s=Object.getOwnPropertyDescriptor;if(s)try{s({},"")}catch(e){s=null}var u=function(){throw new o},f=s?function(){try{return u}catch(e){try{return s(arguments,"callee").get}catch(e){return u}}}():u,c=r(210)(),l=Object.getPrototypeOf||function(e){return e.__proto__},h=a("async function* () {}"),d=h?h.prototype:void 0,p=d?d.prototype:void 0,y="undefined"==typeof Uint8Array?void 0:l(Uint8Array),g={"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":c?l([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":a("async function () {}"),"%AsyncGenerator%":d,"%AsyncGeneratorFunction%":h,"%AsyncIteratorPrototype%":p?l(p):void 0,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":i,"%GeneratorFunction%":a("function* () {}"),"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":c?l(l([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&c?l((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&c?l((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":c?l(""[Symbol.iterator]()):void 0,"%Symbol%":c?Symbol:void 0,"%SyntaxError%":n,"%ThrowTypeError%":f,"%TypedArray%":y,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet},m={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},b=r(75),v=r(117),w=b.call(Function.call,Array.prototype.concat),_=b.call(Function.apply,Array.prototype.splice),E=b.call(Function.call,String.prototype.replace),S=b.call(Function.call,String.prototype.slice),A=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,I=/\\(\\)?/g,O=function(e){var t=S(e,0,1),r=S(e,-1);if("%"===t&&"%"!==r)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var i=[];return E(e,A,(function(e,t,r,n){i[i.length]=r?E(n,I,"$1"):t||e})),i},P=function(e,t){var r,i=e;if(v(m,i)&&(i="%"+(r=m[i])[0]+"%"),v(g,i)){var a=g[i];if(void 0===a&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:i,value:a}}throw new n("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var r=O(e),i=r.length>0?r[0]:"",a=P("%"+i+"%",t),u=a.name,f=a.value,c=!1,l=a.alias;l&&(i=l[0],_(r,w([0,1],l)));for(var h=1,d=!0;h=r.length){var b=s(f,p);f=(d=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:f[p]}else d=v(f,p),f=f[p];d&&!c&&(g[u]=f)}}return f}},function(e,t,r){"use strict";(function(t){var n=t.Symbol,i=r(432);e.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&i())))}}).call(this,r(24))},function(e,t,r){"use strict";var n=r(117),i=r(433),o=r(436)("Object.prototype.propertyIsEnumerable");e.exports=function(e){var t=i(e),r=[];for(var a in t)n(t,a)&&o(t,a)&&r.push(t[a]);return r}},function(e,t,r){"use strict";var n=r(211);e.exports=function(){return"function"==typeof Object.values?Object.values:n}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.receiveOne=function(e,t){var r=a.ByteBuffer.concat([t]),n=r.readUint16();r.readUint32();var i=new o.MessageDecoder(e,n,r.toArrayBuffer());return{message:i.decodedJSON(),type:i.messageName()}},t.receiveAndParse=function(e,t){return g.apply(this,arguments)};var n,i=(n=r(1))&&n.__esModule?n:{default:n},o=r(439),a=r(41);function s(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,u,"next",e)}function u(e){s(o,n,i,a,u,"throw",e)}a(void 0)}))}}function f(e,t){for(var r=0;r=this.expectedLength}},{key:"append",value:function(e){this.buffer.append(e)}},{key:"arrayBuffer",value:function(){var e=this.buffer;return e.reset(),e.toArrayBuffer()}}])&&f(t.prototype,r),n&&f(t,n),e}();function l(e){var t=a.ByteBuffer.concat([e]),r=t.readByte(),n=t.readByte();if(35!==r||35!==n)throw new Error("Didn't receive expected header signature.");var i=t.readUint16(),o=t.readUint32(),s=new c(i,o);return s.append(t),s}function h(e,t){return d.apply(this,arguments)}function d(){return(d=u(i.default.mark((function e(t,r){var n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.isDone()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,r();case 4:if(null!=(n=e.sent)){e.next=7;break}throw new Error("Received no data.");case 7:return t.append(n),e.abrupt("return",h(t,r));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(e){return y.apply(this,arguments)}function y(){return(y=u(i.default.mark((function e(t){var r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:return r=e.sent,n=l(r),e.next=6,h(n,t);case 6:return e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function g(){return(g=u(i.default.mark((function e(t,r){var n,a,s,u;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p(r);case 2:return n=e.sent,a=n.typeNumber,s=n.arrayBuffer(),u=new o.MessageDecoder(t,a,s),e.abrupt("return",{message:u.decodedJSON(),type:u.messageName()});case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=function(){var e=function(e){},t=function(e){},r=new Promise((function(r,n){e=r,t=n})),n=r.then((function(){throw new Error("Promise is always rejecting")}));return n.catch((function(){})),{resolve:e,reject:t,promise:r,rejectingPromise:n}},t.resolveTimeoutPromise=function(e,t){return new Promise((function(r){setTimeout((function(){r(t)}),e)}))},t.rejectTimeoutPromise=function(e,t){return new Promise((function(r,n){setTimeout((function(){n(t)}),e)}))}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.ReactNativeUsbPlugin=t.WebUsbPlugin=void 0;var i=n(r(450)),o=n(r(451));t.BlockbookWorker=o.default;var a=n(r(452));t.RippleWorker=a.default;var s=n(r(202));t.WebUsbPlugin=function(){return new s.default.Lowlevel(new s.default.WebUsb,"undefined"!=typeof SharedWorker?function(){return new i.default}:null)};t.ReactNativeUsbPlugin=void 0},function(e,t,r){"use strict";t.__esModule=!0,t.load=t.save=t.CONFIRMATION_KEY=t.PERMISSIONS_KEY=t.BROWSER_KEY=void 0;t.BROWSER_KEY="trezorconnect_browser";t.PERMISSIONS_KEY="trezorconnect_permissions";t.CONFIRMATION_KEY="trezorconnect_confirmations";var n={};t.save=function(e,t,r){if(void 0===r&&(r=!1),r)n[e]=JSON.stringify(t);else{try{return void(window.localStorage[e]=JSON.stringify(t))}catch(e){}try{window.document.cookie=encodeURIComponent(e)+"="+JSON.stringify(t)+";"}catch(e){}}};t.load=function(e,t){var r;if(void 0===t&&(t=!1),t)return(r=n[e])?JSON.parse(r):null;try{r=window.localStorage[e]}catch(e){}if(void 0===r)try{var i=window.document.cookie,o=i.indexOf(encodeURIComponent(e)+"=");if(-1!==o){var a=/^([^;]+)/.exec(i.slice(o));a&&(r=a[1])}}catch(e){}return r?JSON.parse(r):null}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=n(r(29));n(r(23));function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t=t.indexOf(i))return i;for(var o=e;"string"!=typeof t[o]&&o1&&(r=this.levels.map((function(e){return e.blocks})).reduce((function(e,t){if(0===e.length)return e.concat([t]);var r=e[e.length-1],n=t-r,i=h(r,n<=30?1:6,n);return e.concat(i)}),[])),e.prev=4,e.next=7,t.estimateFee({blocks:r});case 7:e.sent.forEach((function(e,t){o.blocks[r[t]]=l(e.feePerUnit)})),1===this.levels.length?"string"==typeof(n=d(this.blocks))&&(this.levels[0].blocks=this.blocks.indexOf(n),this.levels[0].feePerUnit=n):this.levels.forEach((function(e){var t=p(e.blocks,o.blocks);"string"==typeof t&&(e.blocks=o.blocks.indexOf(t),e.feePerUnit=t)})),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:return e.abrupt("return",this.levels);case 15:case"end":return e.stop()}}),e,this,[[4,12]])})));return function(t){return e.apply(this,arguments)}}(),t.updateCustomFee=function(e){this.levels=this.levels.filter((function(e){return"custom"!==e.label}));var t=function(e,t){var r=new s.default(e),n=t.find((function(e){return"string"==typeof e&&r.gte(e)}));return n?t.indexOf(n):-1}(e,this.blocks);this.levels.push({label:"custom",feePerUnit:e,blocks:t})},e}();t.default=y},function(e,t,r){"use strict";t.__esModule=!0,t.addressParametersFromProto=t.addressParametersToProto=t.validateAddressParameters=void 0;var n=r(4),i=r(12);t.validateAddressParameters=function(e){(0,n.validateParams)(e,[{name:"addressType",type:"number",obligatory:!0},{name:"path",obligatory:!0},{name:"stakingKeyHash",type:"string"}]),(0,i.validatePath)(e.path),e.stakingPath&&(0,i.validatePath)(e.stakingPath),e.certificatePointer&&(0,n.validateParams)(e.certificatePointer,[{name:"blockIndex",type:"number",obligatory:!0},{name:"txIndex",type:"number",obligatory:!0},{name:"certificateIndex",type:"number",obligatory:!0}])};t.addressParametersToProto=function(e){var t,r=(0,i.validatePath)(e.path,3),n=[];return e.stakingPath&&(n=(0,i.validatePath)(e.stakingPath,3)),e.certificatePointer&&(t={block_index:e.certificatePointer.blockIndex,tx_index:e.certificatePointer.txIndex,certificate_index:e.certificatePointer.certificateIndex}),{address_type:e.addressType,address_n:r,address_n_staking:n,staking_key_hash:e.stakingKeyHash,certificate_pointer:t}};t.addressParametersFromProto=function(e){var t;return e.certificate_pointer&&(t={blockIndex:e.certificate_pointer.block_index,txIndex:e.certificate_pointer.tx_index,certificateIndex:e.certificate_pointer.certificate_index}),{addressType:e.address_type,path:e.address_n,stakingPath:e.address_n_staking,stakingKeyHash:e.staking_key_hash,certificatePointer:t}}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(25)),c=r(6),l=(n(r(23)),n(r(186)),r(116)),h=r(33);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t0?"segwit":"normal",getPath:i.bind((0,a.default)(r),49)}),r.types.push({type:r.types.length>0?"legacy":"normal",getPath:i.bind((0,a.default)(r),44)})}else r.types.push({type:"normal",getPath:l.getAccountAddressN.bind((0,a.default)(r),n)});return r}(0,s.default)(t,e);var r=t.prototype;return r.start=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n,o=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:10,this.interrupted=!1,r=i.default.mark((function e(){var r,n,a,s,u,f,l,d;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.types[o.typeIndex],n="Account #"+(o.index+1),a=o.index>=10,s=r.getPath(o.index),e.next=6,o.commands.getAccountDescriptor(o.coinInfo,s);case 6:if(u=e.sent){e.next=9;break}throw c.ERRORS.TypedError("Runtime","Discovery: descriptor not found");case 9:if(!o.interrupted){e.next=11;break}return e.abrupt("return",{v:void 0});case 11:return f=p(p({},u),{},{type:r.type,label:n}),o.accounts=o.accounts.filter((function(e){return e.descriptor!==f.descriptor})),a||(o.accounts.push(f),o.emit("progress",o.accounts)),e.next=16,o.blockchain.getAccountInfo({descriptor:f.descriptor,details:t});case 16:if(l=e.sent,!o.interrupted){e.next=19;break}return e.abrupt("return",{v:void 0});case 19:o.accounts=o.accounts.filter((function(e){return e.descriptor!==f.descriptor})),(!a||a&&!l.empty)&&(d=(0,h.formatAmount)(l.availableBalance,o.coinInfo),o.accounts.push(p(p({},f),{},{empty:l.empty,balance:d,addresses:l.addresses})),o.emit("progress",o.accounts)),l.empty?o.typeIndex+11?r-1:0),i=1;i1?t-1:0),n=1;ne.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(i[r]=e[r]);return i}},function(e,t,r){"use strict";var n,i=r(14),o=r(0),a=o(r(1)),s=o(r(11)),u=o(r(2)),f=r(6),c=i(r(124)),l=i(r(123)),h=i(r(20)),d=r(126),p=o(r(32)),y=r(361),g=r(564),m=r(13),b=r(49),v=r(565),w=r(127),_=r(566),E=r(216);function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function A(e){for(var t=1;t=0)&&(o="*"),(0,v.sendMessage)(e,o)}},k=function(e){var t=[l.LOADED,l.ERROR,c.CANCEL_POPUP_REQUEST,h.CLOSE_UI_WINDOW,h.CUSTOM_MESSAGE_REQUEST,h.LOGIN_CHALLENGE_REQUEST,h.BUNDLE_PROGRESS,h.ADDRESS_VALIDATION];return e.event===f.UI_EVENT&&t.indexOf(e.type)<0},T=function(e){if(!e.payload)return!1;var t=e.payload.features;if(t){var r=(0,E.load)(E.PERMISSIONS_KEY)||(0,E.load)(E.PERMISSIONS_KEY,!0);if(r&&Array.isArray(r))return r.filter((function(e){return e.origin===p.default.getSettings("origin")&&"read"===e.type&&e.device===t.device_id})).length>0}return!1},x=function(){var e=(0,u.default)(a.default.mark((function e(t,r){var i,o;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.default.getSettings("origin")){e.next=2;break}return e.abrupt("return");case 2:if((i=(0,d.parse)(A(A({},t.settings),{},{extension:t.extension}))).origin=r&&"null"!==r?r:t.settings.origin,i.popup&&"undefined"!=typeof BroadcastChannel){o=i.env+"-"+i.timestamp;try{(I=new BroadcastChannel(o)).onmessage=function(e){return P(e)}}catch(e){}}return O.enabled=!!i.debug,e.prev=6,e.next=9,(0,y.init)(i);case 9:return(n=e.sent).on(f.CORE_EVENT,M),e.next=13,(0,y.initTransport)(i);case 13:M((0,m.UiMessage)(l.LOADED,{useBroadcastChannel:!!I})),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(6),M((0,m.UiMessage)(l.ERROR,{error:e.t0}));case 19:case"end":return e.stop()}}),e,null,[[6,16]])})));return function(t,r){return e.apply(this,arguments)}}();window.addEventListener("message",P,!1),window.addEventListener("unload",(function(){n&&n.onBeforeUnload()}))},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=r=function(e){return typeof e}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(t)}e.exports=r},function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof l?t:l,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return I()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function l(){}function h(){}function d(){}var p={};p[i]=function(){return this};var y=Object.getPrototypeOf,g=y&&y(y(A([])));g&&g!==t&&r.call(g,i)&&(p=g);var m=d.prototype=l.prototype=Object.create(p);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u=f(e[i],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=f(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function A(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){"use strict";t.__esModule=!0,t.FIAT_RATES_UPDATE=t.NOTIFICATION=t.BLOCK=t.CONNECT=t.ERROR=void 0;t.ERROR="blockchain-error";t.CONNECT="blockchain-connect";t.BLOCK="blockchain-block";t.NOTIFICATION="blockchain-notification";t.FIAT_RATES_UPDATE="fiat-rates-update"},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.WEBUSB_ERROR_MESSAGE=t.INVALID_PIN_ERROR_MESSAGE=t.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE=t.TypedError=t.TrezorError=t.ERROR_CODES=void 0;var i=n(r(3)),o=n(r(236)),a={Init_NotInitialized:"TrezorConnect not yet initialized",Init_AlreadyInitialized:"TrezorConnect has been already initialized",Init_IframeBlocked:"Iframe blocked",Init_IframeTimeout:"Iframe timeout",Init_ManifestMissing:"Manifest not set. Read more at https://github.com/trezor/connect/blob/develop/docs/index.md",Popup_ConnectionMissing:"Unable to establish connection with iframe",Transport_Missing:"Transport is missing",Transport_InvalidProtobuf:"",Method_InvalidPackage:"This version of trezor-connect is not suitable to work without browser. Use trezor-connect@extended package instead",Method_InvalidParameter:"",Method_NotAllowed:"Method not allowed for this configuration",Method_PermissionsNotGranted:"Permissions not granted",Method_Cancel:"Cancelled",Method_Interrupted:"Popup closed",Method_UnknownCoin:"Coin not found",Method_AddressNotMatch:"Addresses do not match",Method_FirmwareUpdate_DownloadFailed:"Failed to download firmware binary",Method_CustomMessage_Callback:'Parameter "callback" is not a function',Method_Discovery_BundleException:"",Method_Override:"override",Method_NoResponse:"Call resolved without response",Backend_NotSupported:"BlockchainLink settings not found in coins.json",Backend_WorkerMissing:"",Backend_Disconnected:"Backend disconnected",Backend_Invalid:"Invalid backend",Backend_Error:"",Runtime:"",Device_NotFound:"Device not found",Device_InitializeFailed:"",Device_FwException:"",Device_ModeException:"",Device_Disconnected:"Device disconnected",Device_UsedElsewhere:"Device is used in another window",Device_InvalidState:"Passphrase is incorrect",Device_CallInProgress:"Device call in progress"};t.ERROR_CODES=a;var s=function(e){function t(t,r){var n;return(n=e.call(this,r)||this).code=t,n.message=r,n}return(0,i.default)(t,e),t}((0,o.default)(Error));t.TrezorError=s;t.TypedError=function(e,t){return new s(e,t||a[e])};t.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE="wrong previous session";t.INVALID_PIN_ERROR_MESSAGE="PIN invalid";t.WEBUSB_ERROR_MESSAGE="NetworkError: Unable to claim interface."},function(e,t,r){var n=r(237),i=r(122),o=r(238),a=r(239);function s(t){var r="function"==typeof Map?new Map:void 0;return e.exports=s=function(e){if(null===e||!o(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return a(e,arguments,n(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)},s(t)}e.exports=s},function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(t)}e.exports=r},function(e,t){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}},function(e,t,r){var n=r(122),i=r(240);function o(t,r,a){return i()?e.exports=o=Reflect.construct:e.exports=o=function(e,t,r){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return r&&n(o,r.prototype),o},o.apply(null,arguments)}e.exports=o},function(e,t){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}},function(e,t,r){"use strict";t.__esModule=!0,t.TYPES=void 0;var n=Object.freeze({bitcoin:"Bitcoin",ethereum:"Ethereum",eos:"Eos",nem:"NEM",stellar:"Stellar",lisk:"Lisk",cardano:"Cardano",ripple:"Ripple",tezos:"Tezors",binance:"Binance"});t.TYPES=n},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.filterSafeListByFirmware=t.filterSafeListByBootloader=void 0;var a=o(r(130));t.filterSafeListByBootloader=function(e,t){return e.filter((function(e){return(!e.min_bootloader_version||a.isNewerOrEqual(t,e.min_bootloader_version))&&(!e.bootloader_version||a.isNewerOrEqual(e.bootloader_version,t))}))},t.filterSafeListByFirmware=function(e,t){return e.filter((function(e){return a.isNewerOrEqual(t,e.min_firmware_version)}))}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.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]-1};function f(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function c(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function y(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var e,t,r,n=d(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];_.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,r){return new Promise((function(n,o){var a=new v(e,r);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function u(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new _(i,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(e,t){s.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",u),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",u)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=h,e.Request=v,e.Response=_),t.Headers=h,t.Request=v,t.Response=_,t.fetch=S}({})}(r),delete r.fetch.polyfill,(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getScore=void 0;var n=r(82);t.getScore=function(e){var t=n.createHash("sha256");t.update(e);var r=parseInt(t.digest("hex"),16)/Math.pow(2,256);return Math.round(100*r)/100}},function(e,t,r){"use strict";t.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=f(e),a=n[0],s=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,a,s)),c=0,l=s>0?a-4:a;for(r=0;r>16&255,u[c++]=t>>8&255,u[c++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[c++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){ + */function n(e){var t=new Error;this.name=t.name="ValidationError",this.message=t.message=e,this.stack=t.stack}n.prototype=Object.create(Error.prototype),e.exports={ValidationError:n,validate:function(e,t){if(!e)throw new n(t)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.splitByCompleteness=function(e){var t={complete:[],incomplete:[]};return e.forEach((function(e){"complete"===e.type||"send-max"===e.type||"opreturn"===e.type?t.complete.push(e):t.incomplete.push(e)})),t},t.getMax=function(e){var t=e.filter((function(e){return"send-max-noaddress"===e.type||"send-max"===e.type}));if(t.length>=2)throw new Error("TWO-SEND-MAX");var r=e.findIndex((function(e){return"send-max-noaddress"===e.type||"send-max"===e.type})),n=1===t.length;return{id:r,exists:n}}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.coinselect=function(e,t,r,n,i,f,c,l,h,p,y,m,b){var v=function(e,t,r){var n=r?51:109;return e.map((function(e,r){return{id:r,script:{length:n},value:e.value,own:e.own,coinbase:e.coinbase,confirmations:null==e.height?0:1+t-e.height}}))}(e,r,i),w=function(e,t){var r={length:25};return e.map((function(e){if("complete"===e.type)return{value:e.amount,script:g(e.address,t)};if("noaddress"===e.type)return{value:e.amount,script:r};if("opreturn"===e.type)return{value:"0",script:{length:2+e.dataHex.length/2}};if("send-max"===e.type)return{script:g(e.address,t)};if("send-max-noaddress"===e.type)return{script:r};throw new Error("WRONG-OUTPUT-TYPE")}))}(t,h),_={inputLength:i?51:109,changeOutputLength:i?23:25,dustThreshold:l,baseFee:p,floorBaseFee:y,dustOutputFee:m},E=f?a.default:s.default,S=null==b||f?E(v,w,n,_):(0,u.finalize)(v,w,parseInt(n,10),_);if(!S.inputs)return{type:"false"};var A=S.fee,I=-1===c?-1:S.outputs[c].value,O=S.outputs.filter((function(e,r){return r!==t.length})).map((function(e){return e.value})).reduce((function(e,t){return new o.default(e).plus(t)}),new o.default(0)).plus(new o.default(S.fee)),P=(0,u.transactionBytes)(S.inputs,S.outputs),M=A/P;return{type:"true",result:d(d({},S),{},{fee:S.fee.toString(),feePerByte:M.toString(),bytes:P,max:I,totalSpent:O.toString()})}};var i=r(31),o=l(r(29)),a=l(r(496)),s=l(r(497)),u=r(52),f=(function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=c();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r)}(r(119)),r(222));function c(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return c=function(){return e},e}function l(e){return e&&e.__esModule?e:{default:e}}function h(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e){for(var t=1;t-1)return"electron"}return"web"};t.getEnv=u;var f=function(e){if("string"==typeof e)return e.match(/^https:\/\/([A-Za-z0-9\-_]+\.)*trezor\.io\//)||e.match(/^https?:\/\/localhost:[58][0-9]{3}\//)||e.match(/^https:\/\/([A-Za-z0-9\-_]+\.)*sldev\.cz\//)||e.match(/^https?:\/\/([A-Za-z0-9\-_]+\.)*trezoriovpjcahpzkrewelclulmszwbqpzmzgub37gbcjlvluxtruqad\.onion\//)?e:void 0};t.corsValidator=f;t.parse=function(t){void 0===t&&(t={});var r=function(e){for(var t=1;t=0}));if(n){var c=n.split("=")[1];r.connectSrc=f(decodeURIComponent(c)),r.debug=!0}}var l=r.connectSrc||a;return r.iframeSrc=l+"iframe.html",r.popupSrc=l+"popup.html",r.webusbSrc=l+"webusb.html","boolean"==typeof t.transportReconnect&&(r.transportReconnect=t.transportReconnect),"boolean"==typeof t.webusb&&(r.webusb=t.webusb),"boolean"==typeof t.popup&&(r.popup=t.popup),"boolean"==typeof t.lazyLoad&&(r.lazyLoad=t.lazyLoad),"boolean"==typeof t.pendingTransportEvent&&(r.pendingTransportEvent=t.pendingTransportEvent),"undefined"!=typeof window&&window.location&&"file:"===window.location.protocol&&(r.origin="file://"+window.location.pathname,r.webusb=!1),"string"==typeof t.extension&&(r.extension=t.extension),"string"==typeof t.env?r.env=t.env:r.env=u(),"number"==typeof t.timestamp&&(r.timestamp=t.timestamp),"number"==typeof t.interactionTimeout&&(r.interactionTimeout=t.interactionTimeout),"object"==typeof t.manifest&&(r.manifest=function(e){if(e&&"string"==typeof e.email&&"string"==typeof e.appUrl)return{email:e.email,appUrl:e.appUrl}}(t.manifest)),s=r}}).call(this,r(24))},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getOrigin=t.httpRequest=void 0;var i=n(r(1)),o=n(r(2));r(127);var a=function(){var e=(0,o.default)(i.default.mark((function e(t,r){var n,o;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return void 0===r&&(r="text"),e.next=3,fetch(t,{credentials:"same-origin"});case 3:if(!(n=e.sent).ok){e.next=23;break}if("json"!==r){e.next=12;break}return e.next=8,n.text();case 8:return o=e.sent,e.abrupt("return",JSON.parse(o));case 12:if("binary"!==r){e.next=18;break}return e.next=15,n.arrayBuffer();case 15:return e.abrupt("return",e.sent);case 18:return e.next=20,n.text();case 20:return e.abrupt("return",e.sent);case 21:e.next=24;break;case 23:throw new Error("httpRequest error: "+t+" "+n.statusText);case 24:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}();t.httpRequest=a;t.getOrigin=function(e){if(0===e.indexOf("file://"))return"file://";var t=e.match(/^.+\:\/\/[^\/]+/);return Array.isArray(t)&&t.length>0?t[0]:"unknown"}},function(e,t,r){"use strict";r.r(t),r.d(t,"Headers",(function(){return p})),r.d(t,"Request",(function(){return _})),r.d(t,"Response",(function(){return S})),r.d(t,"DOMException",(function(){return I})),r.d(t,"fetch",(function(){return O}));var n="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==n&&n,i="URLSearchParams"in n,o="Symbol"in n&&"iterator"in Symbol,a="FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(e){return!1}}(),s="FormData"in n,u="ArrayBuffer"in n;if(u)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],c=ArrayBuffer.isView||function(e){return e&&f.indexOf(Object.prototype.toString.call(e))>-1};function l(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function h(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return o&&(t[Symbol.iterator]=function(){return t}),t}function p(e){this.map={},e instanceof p?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function g(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function y(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function m(e){var t=new FileReader,r=y(t);return t.readAsArrayBuffer(e),r}function b(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function v(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:a&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:s&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:i&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():u&&a&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=b(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u&&(ArrayBuffer.prototype.isPrototypeOf(e)||c(e))?this._bodyArrayBuffer=b(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):i&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},a&&(this.blob=function(){var e=g(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=g(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}return this.blob().then(m)}),this.text=function(){var e,t,r,n=g(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=y(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(i),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function E(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function S(e,t){if(!(this instanceof S))throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"",this.headers=new p(t.headers),this.url=t.url||"",this._initBody(e)}_.prototype.clone=function(){return new _(this,{body:this._bodyInit})},v.call(_.prototype),v.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new p(this.headers),url:this.url})},S.error=function(){var e=new S(null,{status:0,statusText:""});return e.type="error",e};var A=[301,302,303,307,308];S.redirect=function(e,t){if(-1===A.indexOf(t))throw new RangeError("Invalid status code");return new S(null,{status:t,headers:{location:e}})};var I=n.DOMException;try{new I}catch(e){(I=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack}).prototype=Object.create(Error.prototype),I.prototype.constructor=I}function O(e,t){return new Promise((function(r,i){var o=new _(e,t);if(o.signal&&o.signal.aborted)return i(new I("Aborted","AbortError"));var s=new XMLHttpRequest;function f(){s.abort()}s.onload=function(){var e,t,n={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new p,e.replace(/\r?\n[\t ]+/g," ").split("\r").map((function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e})).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};n.url="responseURL"in s?s.responseURL:n.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;setTimeout((function(){r(new S(i,n))}),0)},s.onerror=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},s.ontimeout=function(){setTimeout((function(){i(new TypeError("Network request failed"))}),0)},s.onabort=function(){setTimeout((function(){i(new I("Aborted","AbortError"))}),0)},s.open(o.method,function(e){try{return""===e&&n.location.href?n.location.href:e}catch(t){return e}}(o.url),!0),"include"===o.credentials?s.withCredentials=!0:"omit"===o.credentials&&(s.withCredentials=!1),"responseType"in s&&(a?s.responseType="blob":u&&o.headers.get("Content-Type")&&-1!==o.headers.get("Content-Type").indexOf("application/octet-stream")&&(s.responseType="arraybuffer")),!t||"object"!=typeof t.headers||t.headers instanceof p?o.headers.forEach((function(e,t){s.setRequestHeader(t,e)})):Object.getOwnPropertyNames(t.headers).forEach((function(e){s.setRequestHeader(e,h(t.headers[e]))})),o.signal&&(o.signal.addEventListener("abort",f),s.onreadystatechange=function(){4===s.readyState&&o.signal.removeEventListener("abort",f)}),s.send(void 0===o._bodyInit?null:o._bodyInit)}))}O.polyfill=!0,n.fetch||(n.fetch=O,n.Headers=p,n.Request=_,n.Response=S)},function(e,t,r){"use strict";var n=this&&this.__assign||function(){return(n=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=o}))),2===s&&a?(null!==p&&null!==b&&null!==v&&(i=f.filterSafeListByFirmware(i,[p,b,v])),i=f.filterSafeListByBootloader(i,[s,u,c])):i=1===s&&a?f.filterSafeListByBootloader(i,[s,u,c]):f.filterSafeListByFirmware(i,[s,u,c]),!i.length)return null;var _=function(e,t){return t.bootloader_mode?t.firmware_present&&1===t.major_version?null:t.firmware_present&&2===t.major_version?e.filter((function(e){return h.isNewer(e.version,[t.fw_major,t.fw_minor,t.fw_patch])})):e:e.filter((function(e){return h.isNewer(e.version,[t.major_version,t.minor_version,t.patch_version])}))}(i,n);return{changelog:_,release:i[0],isLatest:m(i[0],w),isRequired:y(_),isNewer:g(i[0],n)}},t.getBinary=function(e){var r=e.features,i=e.releases,o=e.baseUrl,a=e.baseUrlBeta,f=e.version,l=e.btcOnly,g=e.intermediary,y=void 0!==g&&g;return s(void 0,void 0,void 0,(function(){var e,s,g,m,b,v;return u(this,(function(u){switch(u.label){case 0:if(e=d.parseFeatures(r),s=t.getInfo({features:r,releases:i}),y)return[3,1];if(g=i.find((function(e){return h.isEqual(e.version,f)})),!s||!g)throw new Error("no firmware found for this device");return[3,3];case 1:return[4,c.fetchFirmware(o+"/firmware/1/trezor-inter-1.8.0.bin")];case 2:return m=u.sent(),[2,{binary:p({fw:m,features:e})}];case 3:if(l&&!g.url_bitcoinonly)throw new Error("firmware version "+f+" does not exist in btc only variant");if(!h.isEqual(g.version,s.release.version))throw new Error("version provided as param does not match firmware version found by features in bootloader");return b="beta"===g.channel?a:o,[4,c.fetchFirmware(b+"/"+(l?g.url_bitcoinonly:g.url))];case 4:return v=u.sent(),[2,n(n({},s),{binary:p({fw:v,features:e})})]}}))}))}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isNewerOrEqual=t.isEqual=t.isNewer=t.toString=t.parse=void 0,t.parse=function(e){return{major:e[0],minor:e[1],patch:e[2]}},t.toString=function(e){return e[0]+"."+e[1]+"."+e[2]},t.isNewer=function(e,r){var n=t.parse(e),i=t.parse(r);return n.major-i.major!=0?n.major>i.major:n.minor-i.minor!=0?n.minor>i.minor:n.patch-i.patch!=0&&n.patch>i.patch},t.isEqual=function(e,r){return t.toString(e)===t.toString(r)},t.isNewerOrEqual=function(e,r){return t.isNewer(e,r)||t.isEqual(e,r)}},function(e,t){var r={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==r.call(e)}},function(e,t,r){"use strict";var Buffer=r(7).Buffer,n=r(247).Transform;function i(e){n.call(this),this._block=Buffer.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(10)(i,n),i.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(e){n=e}r(n)},i.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(e){t=e}e(t)},i.prototype.update=function(e,t){if(function(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError(t+" must be a string or a buffer")}(e,"Data"),this._finalized)throw new Error("Digest already called");Buffer.isBuffer(e)||(e=Buffer.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i0;++o)this._length[o]+=a,(a=this._length[o]/4294967296|0)>0&&(this._length[o]-=4294967296*a);return this},i.prototype._update=function(){throw new Error("_update is not implemented")},i.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();void 0!==e&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t},i.prototype._digest=function(){throw new Error("_digest is not implemented")},e.exports=i},function(e,t,r){"use strict";(function(t,n){var i;e.exports=A,A.ReadableState=S;r(25).EventEmitter;var o=function(e,t){return e.listeners(t).length},a=r(133),Buffer=r(9).Buffer,s=t.Uint8Array||function(){};var u,f=r(248);u=f&&f.debuglog?f.debuglog("stream"):function(){};var c,l,h,d=r(249),p=r(134),g=r(135).getHighWaterMark,y=r(43).codes,m=y.ERR_INVALID_ARG_TYPE,b=y.ERR_STREAM_PUSH_AFTER_EOF,v=y.ERR_METHOD_NOT_IMPLEMENTED,w=y.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(10)(A,a);var _=p.errorOrDestroy,E=["error","close","destroy","pause","resume"];function S(e,t,n){i=i||r(44),e=e||{},"boolean"!=typeof n&&(n=t instanceof i),this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode),this.highWaterMark=g(this,e,"readableHighWaterMark",n),this.buffer=new d,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=!1!==e.emitClose,this.autoDestroy=!!e.autoDestroy,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(c||(c=r(38).StringDecoder),this.decoder=new c(e.encoding),this.encoding=e.encoding)}function A(e){if(i=i||r(44),!(this instanceof A))return new A(e);var t=this instanceof i;this._readableState=new S(e,this,t),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),a.call(this)}function I(e,t,r,n,i){u("readableAddChunk",t);var o,a=e._readableState;if(null===t)a.reading=!1,function(e,t){if(u("onEofChunk"),t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,t.sync?M(e):(t.needReadable=!1,t.emittedReadable||(t.emittedReadable=!0,k(e)))}(e,a);else if(i||(o=function(e,t){var r;n=t,Buffer.isBuffer(n)||n instanceof s||"string"==typeof t||void 0===t||e.objectMode||(r=new m("chunk",["string","Buffer","Uint8Array"],t));var n;return r}(a,t)),o)_(e,o);else if(a.objectMode||t&&t.length>0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n)a.endEmitted?_(e,new w):O(e,a,t,!0);else if(a.ended)_(e,new b);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?O(e,a,t,!1):T(e,a)):O(e,a,t,!1)}else n||(a.reading=!1,T(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(k,e))}function k(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,B(e)}function T(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){u("readable nexttick read 0"),e.read(0)}function N(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),B(e),t.flowing&&!t.reading&&e.read(0)}function B(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function U(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function L(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):M(this),null;if(0===(e=P(e,t))&&t.ended)return 0===t.length&&U(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?D(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&U(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){_(this,new v("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?f:y;function s(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",f),r.removeListener("end",y),r.removeListener("data",h),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function f(){u("onend"),e.end()}i.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,B(e))}}(r);e.on("drain",c);var l=!1;function h(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==L(i.pipes,e))&&!l&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),y(),e.removeListener("error",d),0===o(e,"error")&&_(e,t)}function p(){e.removeListener("finish",g),y()}function g(){u("onfinish"),e.removeListener("close",p),y()}function y(){u("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||n.nextTick(C,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(R,this),r},A.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(R,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(N,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new p("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,T(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=c.destroy,A.prototype._undestroy=c.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(24),r(16))},function(e,t,r){"use strict";e.exports=c;var n=r(43).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(44);function f(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function l(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function h(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}n(s,i),s.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this},s.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,d=0|this._e,p=0|this._f,g=0|this._g,y=0|this._h,m=0;m<16;++m)r[m]=e.readInt32BE(4*m);for(;m<64;++m)r[m]=0|(((t=r[m-2])>>>17|t<<15)^(t>>>19|t<<13)^t>>>10)+r[m-7]+h(r[m-15])+r[m-16];for(var b=0;b<64;++b){var v=y+l(d)+u(d,p,g)+o[b]+r[b]|0,w=c(n)+f(n,i,a)|0;y=g,g=p,p=d,d=s+v|0,s=a,a=i,i=n,n=v+w|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=d+this._e|0,this._f=p+this._f|0,this._g=g+this._g|0,this._h=y+this._h|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e},e.exports=s},function(e,t,r){var n=r(10),i=r(45),Buffer=r(7).Buffer,o=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],a=new Array(160);function s(){this.init(),this._w=a,i.call(this,128,112)}function u(e,t,r){return r^e&(t^r)}function f(e,t,r){return e&t|r&(e|t)}function c(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function l(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function h(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function d(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function p(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function g(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function y(e,t){return e>>>0>>0?1:0}n(s,i),s.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this},s.prototype._update=function(e){for(var t=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,a=0|this._dh,s=0|this._eh,m=0|this._fh,b=0|this._gh,v=0|this._hh,w=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,A=0|this._el,I=0|this._fl,O=0|this._gl,P=0|this._hl,M=0;M<32;M+=2)t[M]=e.readInt32BE(4*M),t[M+1]=e.readInt32BE(4*M+4);for(;M<160;M+=2){var k=t[M-30],T=t[M-30+1],x=h(k,T),R=d(T,k),C=p(k=t[M-4],T=t[M-4+1]),N=g(T,k),B=t[M-14],D=t[M-14+1],U=t[M-32],j=t[M-32+1],L=R+D|0,F=x+B+y(L,R)|0;F=(F=F+C+y(L=L+N|0,N)|0)+U+y(L=L+j|0,j)|0,t[M]=F,t[M+1]=L}for(var H=0;H<160;H+=2){F=t[H],L=t[H+1];var q=f(r,n,i),V=f(w,_,E),K=c(r,w),z=c(w,r),G=l(s,A),Q=l(A,s),W=o[H],Y=o[H+1],Z=u(s,m,b),J=u(A,I,O),X=P+Q|0,$=v+G+y(X,P)|0;$=($=($=$+Z+y(X=X+J|0,J)|0)+W+y(X=X+Y|0,Y)|0)+F+y(X=X+L|0,L)|0;var ee=z+V|0,te=K+q+y(ee,z)|0;v=b,P=O,b=m,O=I,m=s,I=A,s=a+$+y(A=S+X|0,S)|0,a=i,S=E,i=n,E=_,n=r,_=w,r=$+te+y(w=X+ee|0,X)|0}this._al=this._al+w|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+A|0,this._fl=this._fl+I|0,this._gl=this._gl+O|0,this._hl=this._hl+P|0,this._ah=this._ah+r+y(this._al,w)|0,this._bh=this._bh+n+y(this._bl,_)|0,this._ch=this._ch+i+y(this._cl,E)|0,this._dh=this._dh+a+y(this._dl,S)|0,this._eh=this._eh+s+y(this._el,A)|0,this._fh=this._fh+m+y(this._fl,I)|0,this._gh=this._gh+b+y(this._gl,O)|0,this._hh=this._hh+v+y(this._hl,P)|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(64);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e},e.exports=s},function(e,t,r){"use strict";(function(t,n){var i=r(61);e.exports=b;var o,a=r(130);b.ReadableState=m;r(25).EventEmitter;var s=function(e,t){return e.listeners(t).length},u=r(141),Buffer=r(89).Buffer,f=t.Uint8Array||function(){};var c=Object.create(r(53));c.inherits=r(10);var l=r(259),h=void 0;h=l&&l.debuglog?l.debuglog("stream"):function(){};var d,p=r(260),g=r(142);c.inherits(b,u);var y=["error","close","destroy","pause","resume"];function m(e,t){e=e||{};var n=t instanceof(o=o||r(39));this.objectMode=!!e.objectMode,n&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var i=e.highWaterMark,a=e.readableHighWaterMark,s=this.objectMode?16:16384;this.highWaterMark=i||0===i?i:n&&(a||0===a)?a:s,this.highWaterMark=Math.floor(this.highWaterMark),this.buffer=new p,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.destroyed=!1,this.defaultEncoding=e.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(d||(d=r(38).StringDecoder),this.decoder=new d(e.encoding),this.encoding=e.encoding)}function b(e){if(o=o||r(39),!(this instanceof b))return new b(e);this._readableState=new m(e,this),this.readable=!0,e&&("function"==typeof e.read&&(this._read=e.read),"function"==typeof e.destroy&&(this._destroy=e.destroy)),u.call(this)}function v(e,t,r,n,i){var o,a=e._readableState;null===t?(a.reading=!1,function(e,t){if(t.ended)return;if(t.decoder){var r=t.decoder.end();r&&r.length&&(t.buffer.push(r),t.length+=t.objectMode?1:r.length)}t.ended=!0,E(e)}(e,a)):(i||(o=function(e,t){var r;n=t,Buffer.isBuffer(n)||n instanceof f||"string"==typeof t||void 0===t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk"));var n;return r}(a,t)),o?e.emit("error",o):a.objectMode||t&&t.length>0?("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n?a.endEmitted?e.emit("error",new Error("stream.unshift() after end event")):w(e,a,t,!0):a.ended?e.emit("error",new Error("stream.push() after EOF")):(a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?w(e,a,t,!1):A(e,a)):w(e,a,t,!1))):n||(a.reading=!1));return function(e){return!e.ended&&(e.needReadable||e.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=8388608?e=8388608:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function E(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(h("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?i.nextTick(S,e):S(e))}function S(e){h("emit readable"),e.emit("readable"),M(e)}function A(e,t){t.readingMore||(t.readingMore=!0,i.nextTick(I,e,t))}function I(e,t){for(var r=t.length;!t.reading&&!t.flowing&&!t.ended&&t.length=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.head.data:t.buffer.concat(t.length),t.buffer.clear()):r=function(e,t,r){var n;eo.length?o.length:e;if(a===o.length?i+=o:i+=o.slice(0,e),0===(e-=a)){a===o.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=o.slice(a));break}++n}return t.length-=n,i}(e,t):function(e,t){var r=Buffer.allocUnsafe(e),n=t.head,i=1;n.data.copy(r),e-=n.data.length;for(;n=n.next;){var o=n.data,a=e>o.length?o.length:e;if(o.copy(r,r.length-e,0,a),0===(e-=a)){a===o.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=o.slice(a));break}++i}return t.length-=i,r}(e,t);return n}(e,t.buffer,t.decoder),r);var r}function T(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,i.nextTick(x,t,e))}function x(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function R(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return h("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?T(this):E(this),null;if(0===(e=_(e,t))&&t.ended)return 0===t.length&&T(this),null;var n,i=t.needReadable;return h("need readable",i),(0===t.length||t.length-e0?k(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&T(this)),null!==n&&this.emit("data",n),n},b.prototype._read=function(e){this.emit("error",new Error("_read() is not implemented"))},b.prototype.pipe=function(e,t){var r=this,o=this._readableState;switch(o.pipesCount){case 0:o.pipes=e;break;case 1:o.pipes=[o.pipes,e];break;default:o.pipes.push(e)}o.pipesCount+=1,h("pipe count=%d opts=%j",o.pipesCount,t);var u=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?c:v;function f(t,n){h("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,h("cleanup"),e.removeListener("close",m),e.removeListener("finish",b),e.removeListener("drain",l),e.removeListener("error",y),e.removeListener("unpipe",f),r.removeListener("end",c),r.removeListener("end",v),r.removeListener("data",g),d=!0,!o.awaitDrain||e._writableState&&!e._writableState.needDrain||l())}function c(){h("onend"),e.end()}o.endEmitted?i.nextTick(u):r.once("end",u),e.on("unpipe",f);var l=function(e){return function(){var t=e._readableState;h("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&s(e,"data")&&(t.flowing=!0,M(e))}}(r);e.on("drain",l);var d=!1;var p=!1;function g(t){h("ondata"),p=!1,!1!==e.write(t)||p||((1===o.pipesCount&&o.pipes===e||o.pipesCount>1&&-1!==R(o.pipes,e))&&!d&&(h("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,p=!0),r.pause())}function y(t){h("onerror",t),v(),e.removeListener("error",y),0===s(e,"error")&&e.emit("error",t)}function m(){e.removeListener("finish",b),v()}function b(){h("onfinish"),e.removeListener("close",m),v()}function v(){h("unpipe"),r.unpipe(e)}return r.on("data",g),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?a(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",y),e.once("close",m),e.once("finish",b),e.emit("pipe",r),o.flowing||(h("pipe resume"),r.resume()),e},b.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;or||t!=t)throw new TypeError("Bad key length")}},function(e,t,r){(function(t){var r;if(t.browser)r="utf-8";else if(t.version){r=parseInt(t.version.split(".")[0].slice(1),10)>=6?"utf-8":"binary"}else r="utf-8";e.exports=r}).call(this,r(16))},function(e,t,r){var n=r(144),i=r(85),o=r(86),Buffer=r(7).Buffer,a=r(147),s=r(148),u=r(150),f=Buffer.alloc(128),c={md5:16,sha1:20,sha224:28,sha256:32,sha384:48,sha512:64,rmd160:20,ripemd160:20};function l(e,t,r){var a=function(e){function t(t){return o(e).update(t).digest()}return"rmd160"===e||"ripemd160"===e?function(e){return(new i).update(e).digest()}:"md5"===e?n:t}(e),s="sha512"===e||"sha384"===e?128:64;t.length>s?t=a(t):t.length>>0},t.writeUInt32BE=function(e,t,r){e[0+r]=t>>>24,e[1+r]=t>>>16&255,e[2+r]=t>>>8&255,e[3+r]=255&t},t.ip=function(e,t,r,n){for(var i=0,o=0,a=6;a>=0;a-=2){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>>s+a&1}for(a=6;a>=0;a-=2){for(s=1;s<=25;s+=8)o<<=1,o|=t>>>s+a&1;for(s=1;s<=25;s+=8)o<<=1,o|=e>>>s+a&1}r[n+0]=i>>>0,r[n+1]=o>>>0},t.rip=function(e,t,r,n){for(var i=0,o=0,a=0;a<4;a++)for(var s=24;s>=0;s-=8)i<<=1,i|=t>>>s+a&1,i<<=1,i|=e>>>s+a&1;for(a=4;a<8;a++)for(s=24;s>=0;s-=8)o<<=1,o|=t>>>s+a&1,o<<=1,o|=e>>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.pc1=function(e,t,r,n){for(var i=0,o=0,a=7;a>=5;a--){for(var s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(s=0;s<=24;s+=8)i<<=1,i|=e>>s+a&1}for(s=0;s<=24;s+=8)i<<=1,i|=t>>s+a&1;for(a=1;a<=3;a++){for(s=0;s<=24;s+=8)o<<=1,o|=t>>s+a&1;for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1}for(s=0;s<=24;s+=8)o<<=1,o|=e>>s+a&1;r[n+0]=i>>>0,r[n+1]=o>>>0},t.r28shl=function(e,t){return e<>>28-t};var n=[14,11,17,4,27,23,25,0,13,22,7,18,5,9,16,24,2,20,12,21,1,8,15,26,15,4,25,19,9,1,26,16,5,11,23,8,12,7,17,0,22,3,10,14,6,20,27,24];t.pc2=function(e,t,r,i){for(var o=0,a=0,s=n.length>>>1,u=0;u>>n[u]&1;for(u=s;u>>n[u]&1;r[i+0]=o>>>0,r[i+1]=a>>>0},t.expand=function(e,t,r){var n=0,i=0;n=(1&e)<<5|e>>>27;for(var o=23;o>=15;o-=4)n<<=6,n|=e>>>o&63;for(o=11;o>=3;o-=4)i|=e>>>o&63,i<<=6;i|=(31&e)<<1|e>>>31,t[r+0]=n>>>0,t[r+1]=i>>>0};var i=[14,0,4,15,13,7,1,4,2,14,15,2,11,13,8,1,3,10,10,6,6,12,12,11,5,9,9,5,0,3,7,8,4,15,1,12,14,8,8,2,13,4,6,9,2,1,11,7,15,5,12,11,9,3,7,14,3,10,10,0,5,6,0,13,15,3,1,13,8,4,14,7,6,15,11,2,3,8,4,14,9,12,7,0,2,1,13,10,12,6,0,9,5,11,10,5,0,13,14,8,7,10,11,1,10,3,4,15,13,4,1,2,5,11,8,6,12,7,6,12,9,0,3,5,2,14,15,9,10,13,0,7,9,0,14,9,6,3,3,4,15,6,5,10,1,2,13,8,12,5,7,14,11,12,4,11,2,15,8,1,13,1,6,10,4,13,9,0,8,6,15,9,3,8,0,7,11,4,1,15,2,14,12,3,5,11,10,5,14,2,7,12,7,13,13,8,14,11,3,5,0,6,6,15,9,0,10,3,1,4,2,7,8,2,5,12,11,1,12,10,4,14,15,9,10,3,6,15,9,0,0,6,12,10,11,1,7,13,13,8,15,9,1,4,3,5,14,11,5,12,2,7,8,2,4,14,2,14,12,11,4,2,1,12,7,4,10,7,11,13,6,1,8,5,5,0,3,15,15,10,13,3,0,9,14,8,9,6,4,11,2,8,1,12,11,7,10,1,13,14,7,2,8,13,15,6,9,15,12,0,5,9,6,10,3,4,0,5,14,3,12,10,1,15,10,4,15,2,9,7,2,12,6,9,8,5,0,6,13,1,3,13,4,14,14,0,7,11,5,3,11,8,9,4,14,3,15,2,5,12,2,9,8,5,12,15,3,10,7,11,0,14,4,1,10,7,1,6,13,0,11,8,6,13,4,13,11,0,2,11,14,7,15,4,0,9,8,1,13,10,3,14,12,3,9,5,7,12,5,2,10,15,6,8,1,6,1,6,4,11,11,13,13,8,12,1,3,4,7,10,14,7,10,9,15,5,6,0,8,15,0,14,5,2,9,3,2,12,13,1,2,15,8,13,4,8,6,10,15,3,11,7,1,4,10,12,9,5,3,6,14,11,5,0,0,14,12,9,7,2,7,2,11,1,4,14,1,7,9,4,12,10,14,8,2,13,0,15,6,12,10,9,13,0,15,3,3,5,5,6,8,11];t.substitute=function(e,t){for(var r=0,n=0;n<4;n++){r<<=4,r|=i[64*n+(e>>>18-6*n&63)]}for(n=0;n<4;n++){r<<=4,r|=i[256+64*n+(t>>>18-6*n&63)]}return r>>>0};var o=[16,25,12,11,3,20,4,15,31,17,9,6,27,14,1,22,30,24,8,18,0,5,29,23,13,19,2,26,10,21,28,7];t.permute=function(e){for(var t=0,r=0;r>>o[r]&1;return t>>>0},t.padSplit=function(e,t,r){for(var n=e.toString(2);n.length>>1];r=o.r28shl(r,s),i=o.r28shl(i,s),o.pc2(r,i,e.keys,a)}},u.prototype._update=function(e,t,r,n){var i=this._desState,a=o.readUInt32BE(e,t),s=o.readUInt32BE(e,t+4);o.ip(a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],"encrypt"===this.type?this._encrypt(i,a,s,i.tmp,0):this._decrypt(i,a,s,i.tmp,0),a=i.tmp[0],s=i.tmp[1],o.writeUInt32BE(r,a,n),o.writeUInt32BE(r,s,n+4)},u.prototype._pad=function(e,t){for(var r=e.length-t,n=t;n>>0,a=h}o.rip(s,a,n,i)},u.prototype._decrypt=function(e,t,r,n,i){for(var a=r,s=t,u=e.keys.length-2;u>=0;u-=2){var f=e.keys[u],c=e.keys[u+1];o.expand(a,e.tmp,0),f^=e.tmp[0],c^=e.tmp[1];var l=o.substitute(f,c),h=a;a=(s^o.permute(l))>>>0,s=h}o.rip(a,s,n,i)}},function(e,t,r){var n=r(54),Buffer=r(7).Buffer,i=r(154);function o(e){var t=e._cipher.encryptBlockRaw(e._prev);return i(e._prev),t}t.encrypt=function(e,t){var r=Math.ceil(t.length/16),i=e._cache.length;e._cache=Buffer.concat([e._cache,Buffer.allocUnsafe(16*r)]);for(var a=0;ae;)r.ishrn(1);if(r.isEven()&&r.iadd(s),r.testn(1)||r.iadd(u),t.cmp(u)){if(!t.cmp(f))for(;r.mod(c).cmp(l);)r.iadd(d)}else for(;r.mod(o).cmp(h);)r.iadd(d);if(y(p=r.shrn(1))&&y(r)&&m(p)&&m(r)&&a.test(p)&&a.test(r))return r}}},function(e,t,r){var n=r(18),i=r(94);function o(e){this.rand=e||new i.Rand}e.exports=o,o.create=function(e){return new o(e)},o.prototype._randbelow=function(e){var t=e.bitLength(),r=Math.ceil(t/8);do{var i=new n(this.rand.generate(r))}while(i.cmp(e)>=0);return i},o.prototype._randrange=function(e,t){var r=t.sub(e);return e.add(this._randbelow(r))},o.prototype.test=function(e,t,r){var i=e.bitLength(),o=n.mont(e),a=new n(1).toRed(o);t||(t=Math.max(1,i/48|0));for(var s=e.subn(1),u=0;!s.testn(u);u++);for(var f=e.shrn(u),c=s.toRed(o);t>0;t--){var l=this._randrange(new n(2),s);r&&r(l);var h=l.toRed(o).redPow(f);if(0!==h.cmp(a)&&0!==h.cmp(c)){for(var d=1;d0;t--){var c=this._randrange(new n(2),a),l=e.gcd(c);if(0!==l.cmpn(1))return l;var h=c.toRed(i).redPow(u);if(0!==h.cmp(o)&&0!==h.cmp(f)){for(var d=1;d0)if("string"==typeof t||a.objectMode||Object.getPrototypeOf(t)===Buffer.prototype||(t=function(e){return Buffer.from(e)}(t)),n)a.endEmitted?_(e,new w):O(e,a,t,!0);else if(a.ended)_(e,new b);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(t=a.decoder.write(t),a.objectMode||0!==t.length?O(e,a,t,!1):T(e,a)):O(e,a,t,!1)}else n||(a.reading=!1,T(e,a));return!a.ended&&(a.lengtht.highWaterMark&&(t.highWaterMark=function(e){return e>=1073741824?e=1073741824:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function M(e){var t=e._readableState;u("emitReadable",t.needReadable,t.emittedReadable),t.needReadable=!1,t.emittedReadable||(u("emitReadable",t.flowing),t.emittedReadable=!0,n.nextTick(k,e))}function k(e){var t=e._readableState;u("emitReadable_",t.destroyed,t.length,t.ended),t.destroyed||!t.length&&!t.ended||(e.emit("readable"),t.emittedReadable=!1),t.needReadable=!t.flowing&&!t.ended&&t.length<=t.highWaterMark,B(e)}function T(e,t){t.readingMore||(t.readingMore=!0,n.nextTick(x,e,t))}function x(e,t){for(;!t.reading&&!t.ended&&(t.length0,t.resumeScheduled&&!t.paused?t.flowing=!0:e.listenerCount("data")>0&&e.resume()}function C(e){u("readable nexttick read 0"),e.read(0)}function N(e,t){u("resume",t.reading),t.reading||e.read(0),t.resumeScheduled=!1,e.emit("resume"),B(e),t.flowing&&!t.reading&&e.read(0)}function B(e){var t=e._readableState;for(u("flow",t.flowing);t.flowing&&null!==e.read(););}function D(e,t){return 0===t.length?null:(t.objectMode?r=t.buffer.shift():!e||e>=t.length?(r=t.decoder?t.buffer.join(""):1===t.buffer.length?t.buffer.first():t.buffer.concat(t.length),t.buffer.clear()):r=t.buffer.consume(e,t.decoder),r);var r}function U(e){var t=e._readableState;u("endReadable",t.endEmitted),t.endEmitted||(t.ended=!0,n.nextTick(j,t,e))}function j(e,t){if(u("endReadableNT",e.endEmitted,e.length),!e.endEmitted&&0===e.length&&(e.endEmitted=!0,t.readable=!1,t.emit("end"),e.autoDestroy)){var r=t._writableState;(!r||r.autoDestroy&&r.finished)&&t.destroy()}}function L(e,t){for(var r=0,n=e.length;r=t.highWaterMark:t.length>0)||t.ended))return u("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?U(this):M(this),null;if(0===(e=P(e,t))&&t.ended)return 0===t.length&&U(this),null;var n,i=t.needReadable;return u("need readable",i),(0===t.length||t.length-e0?D(e,t):null)?(t.needReadable=t.length<=t.highWaterMark,e=0):(t.length-=e,t.awaitDrain=0),0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&U(this)),null!==n&&this.emit("data",n),n},A.prototype._read=function(e){_(this,new v("_read()"))},A.prototype.pipe=function(e,t){var r=this,i=this._readableState;switch(i.pipesCount){case 0:i.pipes=e;break;case 1:i.pipes=[i.pipes,e];break;default:i.pipes.push(e)}i.pipesCount+=1,u("pipe count=%d opts=%j",i.pipesCount,t);var a=(!t||!1!==t.end)&&e!==n.stdout&&e!==n.stderr?f:y;function s(t,n){u("onunpipe"),t===r&&n&&!1===n.hasUnpiped&&(n.hasUnpiped=!0,u("cleanup"),e.removeListener("close",p),e.removeListener("finish",g),e.removeListener("drain",c),e.removeListener("error",d),e.removeListener("unpipe",s),r.removeListener("end",f),r.removeListener("end",y),r.removeListener("data",h),l=!0,!i.awaitDrain||e._writableState&&!e._writableState.needDrain||c())}function f(){u("onend"),e.end()}i.endEmitted?n.nextTick(a):r.once("end",a),e.on("unpipe",s);var c=function(e){return function(){var t=e._readableState;u("pipeOnDrain",t.awaitDrain),t.awaitDrain&&t.awaitDrain--,0===t.awaitDrain&&o(e,"data")&&(t.flowing=!0,B(e))}}(r);e.on("drain",c);var l=!1;function h(t){u("ondata");var n=e.write(t);u("dest.write",n),!1===n&&((1===i.pipesCount&&i.pipes===e||i.pipesCount>1&&-1!==L(i.pipes,e))&&!l&&(u("false write response, pause",i.awaitDrain),i.awaitDrain++),r.pause())}function d(t){u("onerror",t),y(),e.removeListener("error",d),0===o(e,"error")&&_(e,t)}function p(){e.removeListener("finish",g),y()}function g(){u("onfinish"),e.removeListener("close",p),y()}function y(){u("unpipe"),r.unpipe(e)}return r.on("data",h),function(e,t,r){if("function"==typeof e.prependListener)return e.prependListener(t,r);e._events&&e._events[t]?Array.isArray(e._events[t])?e._events[t].unshift(r):e._events[t]=[r,e._events[t]]:e.on(t,r)}(e,"error",d),e.once("close",p),e.once("finish",g),e.emit("pipe",r),i.flowing||(u("pipe resume"),r.resume()),e},A.prototype.unpipe=function(e){var t=this._readableState,r={hasUnpiped:!1};if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes||(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this,r)),this;if(!e){var n=t.pipes,i=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var o=0;o0,!1!==i.flowing&&this.resume()):"readable"===e&&(i.endEmitted||i.readableListening||(i.readableListening=i.needReadable=!0,i.flowing=!1,i.emittedReadable=!1,u("on readable",i.length,i.reading),i.length?M(this):i.reading||n.nextTick(C,this))),r},A.prototype.addListener=A.prototype.on,A.prototype.removeListener=function(e,t){var r=a.prototype.removeListener.call(this,e,t);return"readable"===e&&n.nextTick(R,this),r},A.prototype.removeAllListeners=function(e){var t=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==e&&void 0!==e||n.nextTick(R,this),t},A.prototype.resume=function(){var e=this._readableState;return e.flowing||(u("resume"),e.flowing=!e.readableListening,function(e,t){t.resumeScheduled||(t.resumeScheduled=!0,n.nextTick(N,e,t))}(this,e)),e.paused=!1,this},A.prototype.pause=function(){return u("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(u("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},A.prototype.wrap=function(e){var t=this,r=this._readableState,n=!1;for(var i in e.on("end",(function(){if(u("wrapped end"),r.decoder&&!r.ended){var e=r.decoder.end();e&&e.length&&t.push(e)}t.push(null)})),e.on("data",(function(i){(u("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i)||(r.objectMode||i&&i.length)&&(t.push(i)||(n=!0,e.pause()))})),e)void 0===this[i]&&"function"==typeof e[i]&&(this[i]=function(t){return function(){return e[t].apply(e,arguments)}}(i));for(var o=0;o-1))throw new w(e);return this._writableState.defaultEncoding=e,this},Object.defineProperty(A.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(A.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),A.prototype._write=function(e,t,r){r(new p("_write()"))},A.prototype._writev=null,A.prototype.end=function(e,t,r){var i=this._writableState;return"function"==typeof e?(r=e,e=null,t=null):"function"==typeof t&&(r=t,t=null),null!=e&&this.write(e,t),i.corked&&(i.corked=1,this.uncork()),i.ending||function(e,t,r){t.ending=!0,T(e,t),r&&(t.finished?n.nextTick(r):e.once("finish",r));t.ended=!0,e.writable=!1}(this,i,r),this},Object.defineProperty(A.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(A.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(e){this._writableState&&(this._writableState.destroyed=e)}}),A.prototype.destroy=c.destroy,A.prototype._undestroy=c.undestroy,A.prototype._destroy=function(e,t){t(e)}}).call(this,r(24),r(16))},function(e,t,r){"use strict";e.exports=c;var n=r(46).codes,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(47);function f(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=t&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length>8,a=255&i;o?r.push(o,a):r.push(a)}return r},n.zero2=i,n.toHex=o,n.encode=function(e,t){return"hex"===t?o(e):e}},function(e,t,r){"use strict";var n=t;n.base=r(67),n.short=r(305),n.mont=r(306),n.edwards=r(307)},function(e,t,r){"use strict";var n=r(30).rotr32;function i(e,t,r){return e&t^~e&r}function o(e,t,r){return e&t^e&r^t&r}function a(e,t,r){return e^t^r}t.ft_1=function(e,t,r,n){return 0===e?i(t,r,n):1===e||3===e?a(t,r,n):2===e?o(t,r,n):void 0},t.ch32=i,t.maj32=o,t.p32=a,t.s0_256=function(e){return n(e,2)^n(e,13)^n(e,22)},t.s1_256=function(e){return n(e,6)^n(e,11)^n(e,25)},t.g0_256=function(e){return n(e,7)^n(e,18)^e>>>3},t.g1_256=function(e){return n(e,17)^n(e,19)^e>>>10}},function(e,t,r){"use strict";var n=r(30),i=r(55),o=r(168),a=r(27),s=n.sum32,u=n.sum32_4,f=n.sum32_5,c=o.ch32,l=o.maj32,h=o.s0_256,d=o.s1_256,p=o.g0_256,g=o.g1_256,y=i.BlockHash,m=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function b(){if(!(this instanceof b))return new b;y.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=m,this.W=new Array(64)}n.inherits(b,y),e.exports=b,b.blockSize=512,b.outSize=256,b.hmacStrength=192,b.padLength=64,b.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;n=49&&f<=54?f-49+10:f>=17&&f<=22?f-17+10:f,a|=u}return n(!(240&a),"Invalid character in "+e),i}function s(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?f-49+10:f>=17?f-17+10:f,n(f>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this._strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,u=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(e){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var c=["","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"],l=[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],h=[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];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=l[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(d).toString(e);r=(p=p.idivn(d)).isZero()?g+r:c[f-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},Buffer&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(Buffer,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,g=d>>>13,y=0|a[2],m=8191&y,b=y>>>13,v=0|a[3],w=8191&v,_=v>>>13,E=0|a[4],S=8191&E,A=E>>>13,I=0|a[5],O=8191&I,P=I>>>13,M=0|a[6],k=8191&M,T=M>>>13,x=0|a[7],R=8191&x,C=x>>>13,N=0|a[8],B=8191&N,D=N>>>13,U=0|a[9],j=8191&U,L=U>>>13,F=0|s[0],H=8191&F,q=F>>>13,V=0|s[1],K=8191&V,z=V>>>13,G=0|s[2],Q=8191&G,W=G>>>13,Y=0|s[3],Z=8191&Y,J=Y>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(f+(n=Math.imul(l,H))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,H)|0))<<13)|0;f=((o=Math.imul(h,q))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(g,H)|0,o=Math.imul(g,q);var me=(f+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,z)|0)+Math.imul(h,K)|0))<<13)|0;f=((o=o+Math.imul(h,z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(b,H)|0,o=Math.imul(b,q),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,z)|0)+Math.imul(g,K)|0,o=o+Math.imul(g,z)|0;var be=(f+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,Q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,z)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,W)|0;var ve=(f+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(A,H)|0,o=Math.imul(A,q),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,z)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0;var we=(f+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,H),i=(i=Math.imul(O,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,z)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,q))+Math.imul(T,H)|0,o=Math.imul(T,q),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,z)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0;var Se=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,q))+Math.imul(D,H)|0,o=Math.imul(D,q),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,z)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,z)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,H),i=(i=Math.imul(j,q))+Math.imul(L,H)|0,o=Math.imul(L,q),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,z)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,z)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(g,le)|0,o=o+Math.imul(g,he)|0;var Ie=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ge)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,z))+Math.imul(L,K)|0,o=Math.imul(L,z),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Oe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;f=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,W))+Math.imul(L,Q)|0,o=Math.imul(L,W),n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(T,re)|0,o=o+Math.imul(T,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var Pe=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ge)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,ge)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,J))+Math.imul(L,Z)|0,o=Math.imul(L,J),n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,fe)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var Me=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,ee))+Math.imul(L,$)|0,o=Math.imul(L,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var ke=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ge)|0)+Math.imul(P,pe)|0))<<13)|0;f=((o=o+Math.imul(P,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ge)|0)+Math.imul(T,pe)|0))<<13)|0;f=((o=o+Math.imul(T,ge)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ge)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(L,le)|0,o=Math.imul(L,he);var Ce=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ge)|0)+Math.imul(D,pe)|0))<<13)|0;f=((o=o+Math.imul(D,ge)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ne=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ge))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ge))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ye,u[1]=me,u[2]=be,u[3]=ve,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Se,u[8]=Ae,u[9]=Ie,u[10]=Oe,u[11]=Pe,u[12]=Me,u[13]=ke,u[14]=Te,u[15]=xe,u[16]=Re,u[17]=Ce,u[18]=Ne,0!==f&&(u[19]=f,r.length++),r};function g(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function y(e,t,r){return g(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(p=d),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?g(this,e,t):y(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function I(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(w,v),w.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new w;else if("p224"===e)t=new _;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return b[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var g=d,y=0;0!==g.cmp(s);y++)g=g.redSqr();n(y=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new I(e)},i(I,A),I.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},I.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},I.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},I.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(65)(e))},function(e,t,r){"use strict";const n=t;n.bignum=r(18),n.define=r(324).define,n.base=r(327),n.constants=r(328),n.decoders=r(175),n.encoders=r(173)},function(e,t,r){"use strict";const n=t;n.der=r(174),n.pem=r(325)},function(e,t,r){"use strict";const n=r(10),Buffer=r(99).Buffer,i=r(100),o=r(102);function a(e){this.enc="der",this.name=e.name,this.entity=e,this.tree=new s,this.tree._init(e.body)}function s(e){i.call(this,"der",e)}function u(e){return e<10?"0"+e:e}e.exports=a,a.prototype.encode=function(e,t){return this.tree._encode(e,t).join()},n(s,i),s.prototype._encodeComposite=function(e,t,r,n){const i=function(e,t,r,n){let i;"seqof"===e?e="seq":"setof"===e&&(e="set");if(o.tagByName.hasOwnProperty(e))i=o.tagByName[e];else{if("number"!=typeof e||(0|e)!==e)return n.error("Unknown tag: "+e);i=e}if(i>=31)return n.error("Multi-octet tag encoding unsupported");t||(i|=32);return i|=o.tagClassByName[r||"universal"]<<6,i}(e,t,r,this.reporter);if(n.length<128){const e=Buffer.alloc(2);return e[0]=i,e[1]=n.length,this._createEncoderBuffer([e,n])}let a=1;for(let e=n.length;e>=256;e>>=8)a++;const s=Buffer.alloc(2+a);s[0]=i,s[1]=128|a;for(let e=1+a,t=n.length;t>0;e--,t>>=8)s[e]=255&t;return this._createEncoderBuffer([s,n])},s.prototype._encodeStr=function(e,t){if("bitstr"===t)return this._createEncoderBuffer([0|e.unused,e.data]);if("bmpstr"===t){const t=Buffer.alloc(2*e.length);for(let r=0;r=40)return this.reporter.error("Second objid identifier OOB");e.splice(0,2,40*e[0]+e[1])}let n=0;for(let t=0;t=128;r>>=7)n++}const i=Buffer.alloc(n);let o=i.length-1;for(let t=e.length-1;t>=0;t--){let r=e[t];for(i[o--]=127&r;(r>>=7)>0;)i[o--]=128|127&r}return this._createEncoderBuffer(i)},s.prototype._encodeTime=function(e,t){let r;const n=new Date(e);return"gentime"===t?r=[u(n.getUTCFullYear()),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):"utctime"===t?r=[u(n.getUTCFullYear()%100),u(n.getUTCMonth()+1),u(n.getUTCDate()),u(n.getUTCHours()),u(n.getUTCMinutes()),u(n.getUTCSeconds()),"Z"].join(""):this.reporter.error("Encoding "+t+" time is not supported yet"),this._encodeStr(r,"octstr")},s.prototype._encodeNull=function(){return this._createEncoderBuffer("")},s.prototype._encodeInt=function(e,t){if("string"==typeof e){if(!t)return this.reporter.error("String int or enum given, but no values map");if(!t.hasOwnProperty(e))return this.reporter.error("Values map doesn't contain: "+JSON.stringify(e));e=t[e]}if("number"!=typeof e&&!Buffer.isBuffer(e)){const t=e.toArray();!e.sign&&128&t[0]&&t.unshift(0),e=Buffer.from(t)}if(Buffer.isBuffer(e)){let t=e.length;0===e.length&&t++;const r=Buffer.alloc(t);return e.copy(r),0===e.length&&(r[0]=0),this._createEncoderBuffer(r)}if(e<128)return this._createEncoderBuffer(e);if(e<256)return this._createEncoderBuffer([0,e]);let r=1;for(let t=e;t>=256;t>>=8)r++;const n=new Array(r);for(let t=n.length-1;t>=0;t--)n[t]=255&e,e>>=8;return 128&n[0]&&n.unshift(0),this._createEncoderBuffer(Buffer.from(n))},s.prototype._encodeBool=function(e){return this._createEncoderBuffer(e?255:0)},s.prototype._use=function(e,t){return"function"==typeof e&&(e=e(t)),e._getEncoder("der").tree},s.prototype._skipDefault=function(e,t,r){const n=this._baseState;let i;if(null===n.default)return!1;const o=e.join();if(void 0===n.defaultBuffer&&(n.defaultBuffer=this._encodeValue(n.default,t,r).join()),o.length!==n.defaultBuffer.length)return!1;for(i=0;i>6],i=0==(32&r);if(31==(31&r)){let n=r;for(r=0;128==(128&n);){if(n=e.readUInt8(t),e.isError(n))return n;r<<=7,r|=127&n}}else r&=31;return{cls:n,primitive:i,tag:r,tagStr:s.tag[r]}}function l(e,t,r){let n=e.readUInt8(r);if(e.isError(n))return n;if(!t&&128===n)return null;if(0==(128&n))return n;const i=127&n;if(i>4)return e.error("length octect is too long");n=0;for(let t=0;t0?(t._cancelableRequest=n,t.device.emit(u.DEVICE.PIN,t.device,e,(function(e,i){t._cancelableRequest=void 0,e||null==i?n(e):r(i)}))):(console.warn("[DeviceCommands] [call] PIN callback not configured, cancelling request"),n(u.ERRORS.TypedError("Runtime","_promptPin: PIN callback not configured")))}))},t._promptPassphrase=function(){var e=this;return new Promise((function(t,r){e.device.listenerCount(u.DEVICE.PASSPHRASE)>0?(e._cancelableRequest=r,e.device.emit(u.DEVICE.PASSPHRASE,e.device,(function(n,i){e._cancelableRequest=void 0,i?r(i):t(n)}))):(console.warn("[DeviceCommands] [call] Passphrase callback not configured, cancelling request"),r(u.ERRORS.TypedError("Runtime","_promptPassphrase: Passphrase callback not configured")))}))},t._promptWord=function(e){var t=this;return new Promise((function(r,n){t._cancelableRequest=n,t.device.emit(u.DEVICE.WORD,t.device,e,(function(e,i){t._cancelableRequest=void 0,e||null==i?n(e):r(i.toLocaleLowerCase())}))}))},t.debugLinkDecision=function(){var e=(0,a.default)(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.transport.acquire({path:this.device.originalDescriptor.path,previous:this.device.originalDescriptor.debugSession},!0);case 2:return r=e.sent,e.next=5,(0,p.resolveAfter)(501,null);case 5:return e.next=7,this.transport.post(r,"DebugLinkDecision",t,!0);case 7:return e.next=9,this.transport.release(r,!0,!0);case 9:return this.device.originalDescriptor.debugSession=null,e.next=12,(0,p.resolveAfter)(501,null);case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.debugLinkGetState=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.transport.acquire({path:this.device.originalDescriptor.path,previous:this.device.originalDescriptor.debugSession},!0);case 2:return t=e.sent,e.next=5,(0,p.resolveAfter)(501,null);case 5:return e.next=7,this.transport.call(t,"DebugLinkGetState",{},!0);case 7:return r=e.sent,v(r,"DebugLinkState"),e.next=11,this.transport.release(t,!0,!0);case 11:return e.next=13,(0,p.resolveAfter)(501,null);case 13:return e.abrupt("return",r.message);case 14:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t.getAccountDescriptor=function(){var e=(0,a.default)(o.default.mark((function e(t,r){var n,i,a,s,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(n=Array.isArray(r)?r:(0,h.getAccountAddressN)(t,r),"bitcoin"!==t.type){e.next=8;break}return e.next=4,this.getHDNode(n,t,!1);case 4:return i=e.sent,e.abrupt("return",{descriptor:i.xpubSegwit||i.xpub,legacyXpub:i.xpub,address_n:n});case 8:if("ethereum"!==t.type){e.next=15;break}return e.next=11,this.ethereumGetAddress({address_n:n},t);case 11:return a=e.sent,e.abrupt("return",{descriptor:a.address,address_n:n});case 15:if("XRP"!==t.shortcut&&"tXRP"!==t.shortcut){e.next=21;break}return e.next=18,this.typedCall("RippleGetAddress","RippleAddress",{address_n:n});case 18:return s=e.sent,u=s.message,e.abrupt("return",{descriptor:u.address,address_n:n});case 21:return e.abrupt("return");case 22:case"end":return e.stop()}}),e,this)})));return function(t,r){return e.apply(this,arguments)}}(),t.cancel=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this._cancelableRequest){e.next=4;break}return this._cancelableRequest(),this._cancelableRequest=void 0,e.abrupt("return");case 4:if(t=this.transport,r=t.activeName,n=t.version,!(r&&"BridgeTransport"===r&&(0,g.versionCompare)(n,"2.0.28")<1)){e.next=8;break}return e.next=8,this.device.legacyForceRelease();case 8:this.transport.post(this.sessionId,"Cancel",{},!1);case 9:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),e}();t.default=E},function(e,t,r){var n=r(26);function i(e){return ee.length)return null;r=e.readUInt8(t+1),i=2}else if(o===n.OP_PUSHDATA2){if(t+3>e.length)return null;r=e.readUInt16LE(t+1),i=3}else{if(t+5>e.length)return null;if(o!==n.OP_PUSHDATA4)throw new Error("Unexpected opcode");r=e.readUInt32LE(t+1),i=5}return{opcode:o,number:r,size:i}}}},function(e,t,r){var n=r(105);function i(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function o(e){return n.Nil(e)?"":i(e.constructor)}function a(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function s(e){return n.Function(e)?e.toJSON?e.toJSON():i(e):n.Array(e)?"Array":e&&n.Object(e)?"Object":void 0!==e?e:""}function u(e,t,r){var i=function(e){return n.Function(e)?"":n.String(e)?JSON.stringify(e):e&&n.Object(e)?"":e}(t);return"Expected "+s(e)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function f(e,t,r){r=r||o(t),this.message=u(e,t,r),a(this,f),this.__type=e,this.__value=t,this.__valueTypeName=r}function c(e,t,r,n,i){e?(i=i||o(n),this.message=function(e,t,r,n,i){var o='" of type ';return"key"===t&&(o='" with key type '),u('property "'+s(r)+o+s(e),n,i)}(e,r,t,n,i)):this.message='Unexpected property "'+t+'"',a(this,f),this.__label=r,this.__property=t,this.__type=e,this.__value=n,this.__valueTypeName=i}f.prototype=Object.create(Error.prototype),f.prototype.constructor=f,c.prototype=Object.create(Error.prototype),c.prototype.constructor=f,e.exports={TfTypeError:f,TfPropertyTypeError:c,tfCustomError:function(e,t){return new f(e,{},t)},tfSubError:function(e,t,r){return e instanceof c?(t=t+"."+e.__property,e=new c(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof f&&(e=new c(e.__type,t,r,e.__value,e.__valueTypeName)),a(e),e},tfJSON:s,getValueTypeName:o}},function(e,t,r){var Buffer=r(7).Buffer;e.exports={decode:function(e,t,r){t=t||4,r=void 0===r||r;var n=e.length;if(0===n)return 0;if(n>t)throw new TypeError("Script number overflow");if(r&&0==(127&e[n-1])&&(n<=1||0==(128&e[n-2])))throw new Error("Non-minimally encoded script number");if(5===n){var i=e.readUInt32LE(0),o=e.readUInt8(4);return 128&o?-(4294967296*(-129&o)+i):4294967296*o+i}for(var a=0,s=0;s2147483647?5:e>8388607?4:e>32767?3:e>127?2:e>0?1:0}(t),n=Buffer.allocUnsafe(r),i=e<0,o=0;o>=8;return 128&n[r-1]?n.writeUInt8(i?128:0,r-1):i&&(n[r-1]|=128),n}}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26),s=a.OP_RESERVED;function u(e,t){var r=n.decompile(e);if(r.length<4)return!1;if(r[r.length-1]!==a.OP_CHECKMULTISIG)return!1;if(!i.Number(r[0]))return!1;if(!i.Number(r[r.length-2]))return!1;var o=r[0]-s,u=r[r.length-2]-s;return!(o<=0)&&(!(u>16)&&(!(o>u)&&(u===r.length-3&&(!!t||r.slice(1,-2).every(n.isCanonicalPubKey)))))}u.toJSON=function(){return"multi-sig output"},e.exports={check:u,decode:function(e,t){var r=n.decompile(e);return o(u,r,t),{m:r[0]-s,pubKeys:r.slice(1,-2)}},encode:function(e,t){o({m:i.Number,pubKeys:[n.isCanonicalPubKey]},{m:e,pubKeys:t});var r=t.length;if(r=0;){var a=t*this[e++]+r[n]+i;i=Math.floor(a/67108864),r[n++]=67108863&a}return i},BigInteger.prototype.DB=26,BigInteger.prototype.DM=67108863;var i=BigInteger.prototype.DV=1<<26;BigInteger.prototype.FV=Math.pow(2,52),BigInteger.prototype.F1=26,BigInteger.prototype.F2=0;var o,a,s=new Array;for(o="0".charCodeAt(0),a=0;a<=9;++a)s[o++]=a;for(o="a".charCodeAt(0),a=10;a<36;++a)s[o++]=a;for(o="A".charCodeAt(0),a=10;a<36;++a)s[o++]=a;function u(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function f(e,t){var r=s[e.charCodeAt(t)];return null==r?-1:r}function c(e){var t=new BigInteger;return t.fromInt(e),t}function l(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function h(e){this.m=e}function d(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<>=16,t+=16),0==(255&e)&&(e>>=8,t+=8),0==(15&e)&&(e>>=4,t+=4),0==(3&e)&&(e>>=2,t+=2),0==(1&e)&&++t,t}function v(e){for(var t=0;0!=e;)e&=e-1,++t;return t}function w(){}function _(e){return e}function E(e){this.r2=new BigInteger,this.q3=new BigInteger,BigInteger.ONE.dlShiftTo(2*e.t,this.r2),this.mu=this.r2.divide(e),this.m=e}h.prototype.convert=function(e){return e.s<0||e.compareTo(this.m)>=0?e.mod(this.m):e},h.prototype.revert=function(e){return e},h.prototype.reduce=function(e){e.divRemTo(this.m,null,e)},h.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},h.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},d.prototype.convert=function(e){var t=new BigInteger;return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(BigInteger.ZERO)>0&&this.m.subTo(t,t),t},d.prototype.revert=function(e){var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},d.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},d.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},d.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},n.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},n.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+i:this.t=0},n.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(256==t)r=8;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)return void this.fromRadix(e,t);r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,o=0;--n>=0;){var a=8==r?255&e[n]:f(e,n);a<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==o?this[this.t++]=a:o+r>this.DB?(this[this.t-1]|=(a&(1<>this.DB-o):this[this.t-1]|=a<=this.DB&&(o-=this.DB))}8==r&&0!=(128&e[0])&&(this.s=-1,o>0&&(this[this.t-1]|=(1<0&&this[this.t-1]==e;)--this.t},n.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},n.drShiftTo=function(e,t){for(var r=e;r=0;--r)t[r+a+1]=this[r]>>i|s,s=(this[r]&o)<=0;--r)t[r]=0;t[a]=s,t.t=this.t+a+1,t.s=this.s,t.clamp()},n.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,o=(1<>n;for(var a=r+1;a>n;n>0&&(t[this.t-r-1]|=(this.s&o)<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},n.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i=0;)e[r]=0;for(r=0;r=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},n.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t0?(n.lShiftTo(u,o),i.lShiftTo(u,r)):(n.copyTo(o),i.copyTo(r));var f=o.t,c=o[f-1];if(0!=c){var h=c*(1<1?o[f-2]>>this.F2:0),d=this.FV/h,p=(1<=0&&(r[r.t++]=1,r.subTo(b,r)),BigInteger.ONE.dlShiftTo(f,b),b.subTo(o,o);o.t=0;){var v=r[--y]==c?this.DM:Math.floor(r[y]*d+(r[y-1]+g)*p);if((r[y]+=o.am(0,v,r,m,0,f))0&&r.rShiftTo(u,r),a<0&&BigInteger.ZERO.subTo(r,r)}}},n.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},n.isEven=function(){return 0==(this.t>0?1&this[0]:this.s)},n.exp=function(e,t){if(e>4294967295||e<1)return BigInteger.ONE;var r=new BigInteger,n=new BigInteger,i=t.convert(this),o=l(e)-1;for(i.copyTo(r);--o>=0;)if(t.sqrTo(r,n),(e&1<0)t.mulTo(n,i,r);else{var a=r;r=n,n=a}return t.revert(r)},n.toString=function(e){var t;if(this.s<0)return"-"+this.negate().toString(e);if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)return this.toRadix(e);t=2}var r,n=(1<0)for(s>s)>0&&(i=!0,o=u(r));a>=0;)s>(s+=this.DB-t)):(r=this[a]>>(s-=t)&n,s<=0&&(s+=this.DB,--a)),r>0&&(i=!0),i&&(o+=u(r));return i?o:"0"},n.negate=function(){var e=new BigInteger;return BigInteger.ZERO.subTo(this,e),e},n.abs=function(){return this.s<0?this.negate():this},n.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},n.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+l(this[this.t-1]^this.s&this.DM)},n.byteLength=function(){return this.bitLength()>>3},n.mod=function(e){var t=new BigInteger;return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(BigInteger.ZERO)>0&&e.subTo(t,t),t},n.modPowInt=function(e,t){var r;return r=e<256||t.isEven()?new h(t):new d(t),this.exp(e,r)},w.prototype.convert=_,w.prototype.revert=_,w.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r)},w.prototype.sqrTo=function(e,t){e.squareTo(t)},E.prototype.convert=function(e){if(e.s<0||e.t>2*this.m.t)return e.mod(this.m);if(e.compareTo(this.m)<0)return e;var t=new BigInteger;return e.copyTo(t),this.reduce(t),t},E.prototype.revert=function(e){return e},E.prototype.reduce=function(e){for(e.drShiftTo(this.m.t-1,this.r2),e.t>this.m.t+1&&(e.t=this.m.t+1,e.clamp()),this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3),this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);e.compareTo(this.r2)<0;)e.dAddOffset(1,this.m.t+1);for(e.subTo(this.r2,e);e.compareTo(this.m)>=0;)e.subTo(this.m,e)},E.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},E.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)};var S=[2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997],A=(1<<26)/S[S.length-1];n.chunkSize=function(e){return Math.floor(Math.LN2*this.DB/Math.log(e))},n.toRadix=function(e){if(null==e&&(e=10),0==this.signum()||e<2||e>36)return"0";var t=this.chunkSize(e),r=Math.pow(e,t),n=c(r),i=new BigInteger,o=new BigInteger,a="";for(this.divRemTo(n,i,o);i.signum()>0;)a=(r+o.intValue()).toString(e).substr(1)+a,i.divRemTo(n,i,o);return o.intValue().toString(e)+a},n.fromRadix=function(e,t){this.fromInt(0),null==t&&(t=10);for(var r=this.chunkSize(t),n=Math.pow(t,r),i=!1,o=0,a=0,s=0;s=r&&(this.dMultiply(n),this.dAddOffset(a,0),o=0,a=0))}o>0&&(this.dMultiply(Math.pow(t,o)),this.dAddOffset(a,0)),i&&BigInteger.ZERO.subTo(this,this)},n.fromNumber=function(e,t,r){if("number"==typeof t)if(e<2)this.fromInt(1);else for(this.fromNumber(e,r),this.testBit(e-1)||this.bitwiseTo(BigInteger.ONE.shiftLeft(e-1),g,this),this.isEven()&&this.dAddOffset(1,0);!this.isProbablePrime(t);)this.dAddOffset(2,0),this.bitLength()>e&&this.subTo(BigInteger.ONE.shiftLeft(e-1),this);else{var n=new Array,i=7&e;n.length=1+(e>>3),t.nextBytes(n),i>0?n[0]&=(1<>=this.DB;if(e.t>=this.DB;n+=this.s}else{for(n+=this.s;r>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},n.dMultiply=function(e){this[this.t]=this.am(0,e-1,this,0,0,this.t),++this.t,this.clamp()},n.dAddOffset=function(e,t){if(0!=e){for(;this.t<=t;)this[this.t++]=0;for(this[t]+=e;this[t]>=this.DV;)this[t]-=this.DV,++t>=this.t&&(this[this.t++]=0),++this[t]}},n.multiplyLowerTo=function(e,t,r){var n,i=Math.min(this.t+e.t,t);for(r.s=0,r.t=i;i>0;)r[--i]=0;for(n=r.t-this.t;i=0;)r[n]=0;for(n=Math.max(t-this.t,0);n0)if(0==t)r=this[0]%e;else for(var n=this.t-1;n>=0;--n)r=(t*r+this[n])%e;return r},n.millerRabin=function(e){var t=this.subtract(BigInteger.ONE),r=t.getLowestSetBit();if(r<=0)return!1;var n=t.shiftRight(r);(e=e+1>>1)>S.length&&(e=S.length);for(var i=new BigInteger(null),o=[],a=0;a>24},n.shortValue=function(){return 0==this.t?this.s:this[0]<<16>>16},n.signum=function(){return this.s<0?-1:this.t<=0||1==this.t&&this[0]<=0?0:1},n.toByteArray=function(){var e=this.t,t=new Array;t[0]=this.s;var r,n=this.DB-e*this.DB%8,i=0;if(e-- >0)for(n>n)!=(this.s&this.DM)>>n&&(t[i++]=r|this.s<=0;)n<8?(r=(this[e]&(1<>(n+=this.DB-8)):(r=this[e]>>(n-=8)&255,n<=0&&(n+=this.DB,--e)),0!=(128&r)&&(r|=-256),0===i&&(128&this.s)!=(128&r)&&++i,(i>0||r!=this.s)&&(t[i++]=r);return t},n.equals=function(e){return 0==this.compareTo(e)},n.min=function(e){return this.compareTo(e)<0?this:e},n.max=function(e){return this.compareTo(e)>0?this:e},n.and=function(e){var t=new BigInteger;return this.bitwiseTo(e,p,t),t},n.or=function(e){var t=new BigInteger;return this.bitwiseTo(e,g,t),t},n.xor=function(e){var t=new BigInteger;return this.bitwiseTo(e,y,t),t},n.andNot=function(e){var t=new BigInteger;return this.bitwiseTo(e,m,t),t},n.not=function(){for(var e=new BigInteger,t=0;t=this.t?0!=this.s:0!=(this[t]&1<1){var p=new BigInteger;for(n.sqrTo(a[1],p);s<=f;)a[s]=new BigInteger,n.mulTo(p,a[s-2],a[s]),s+=2}var g,y,m=e.t-1,b=!0,v=new BigInteger;for(i=l(e[m])-1;m>=0;){for(i>=u?g=e[m]>>i-u&f:(g=(e[m]&(1<0&&(g|=e[m-1]>>this.DB+i-u)),s=r;0==(1&g);)g>>=1,--s;if((i-=s)<0&&(i+=this.DB,--m),b)a[g].copyTo(o),b=!1;else{for(;s>1;)n.sqrTo(o,v),n.sqrTo(v,o),s-=2;s>0?n.sqrTo(o,v):(y=o,o=v,v=y),n.mulTo(v,a[g],o)}for(;m>=0&&0==(e[m]&1<=0?(r.subTo(n,r),t&&i.subTo(a,i),o.subTo(s,o)):(n.subTo(r,n),t&&a.subTo(i,a),s.subTo(o,s))}if(0!=n.compareTo(BigInteger.ONE))return BigInteger.ZERO;for(;s.compareTo(e)>=0;)s.subTo(e,s);for(;s.signum()<0;)s.addTo(e,s);return s},n.pow=function(e){return this.exp(e,new w)},n.gcd=function(e){var t=this.s<0?this.negate():this.clone(),r=e.s<0?e.negate():e.clone();if(t.compareTo(r)<0){var n=t;t=r,r=n}var i=t.getLowestSetBit(),o=r.getLowestSetBit();if(o<0)return t;for(i0&&(t.rShiftTo(o,t),r.rShiftTo(o,r));t.signum()>0;)(i=t.getLowestSetBit())>0&&t.rShiftTo(i,t),(i=r.getLowestSetBit())>0&&r.rShiftTo(i,r),t.compareTo(r)>=0?(t.subTo(r,t),t.rShiftTo(1,t)):(r.subTo(t,r),r.rShiftTo(1,r));return o>0&&r.lShiftTo(o,r),r},n.isProbablePrime=function(e){var t,r=this.abs();if(1==r.t&&r[0]<=S[S.length-1]){for(t=0;t0;--a){var s=r.testBit(a),u=t.testBit(a);o=o.twice(),s!==u&&(o=o.add(s?this:n))}return o},Point.prototype.multiplyTwo=function(e,t,r){for(var n=Math.max(e.bitLength(),r.bitLength())-1,i=this.curve.infinity,o=this.add(t);n>=0;){var a=e.testBit(n),s=r.testBit(n);i=i.twice(),a?i=s?i.add(o):i.add(this):s&&(i=i.add(t)),--n}return i},Point.prototype.getEncoded=function(e){if(null==e&&(e=this.compressed),this.curve.isInfinity(this))return Buffer.alloc(1,0);var t,r=this.affineX,n=this.affineY,i=this.curve.pLength;return e?(t=Buffer.allocUnsafe(1+i)).writeUInt8(n.isEven()?2:3,0):((t=Buffer.allocUnsafe(1+i+i)).writeUInt8(4,0),n.toBuffer(i).copy(t,1+i)),r.toBuffer(i).copy(t,1),t},Point.decodeFrom=function(e,t){var r,i=t.readUInt8(0),o=4!==i,a=Math.floor((e.p.bitLength()+7)/8),s=BigInteger.fromBuffer(t.slice(1,1+a));if(o){n.equal(t.length,a+1,"Invalid sequence length"),n(2===i||3===i,"Invalid sequence tag");var u=3===i;r=e.pointFromX(u,s)}else{n.equal(t.length,1+a+a,"Invalid sequence length");var f=BigInteger.fromBuffer(t.slice(1+a));r=Point.fromAffine(e,s,f)}return r.compressed=o,r},Point.prototype.toString=function(){return this.curve.isInfinity(this)?"(INFINITY)":"("+this.affineX.toString()+","+this.affineY.toString()+")"},e.exports=Point},function(e,t,r){var n=r(111),BigInteger=r(37),Point=r(195);function i(e,t,r,n,i,o,a){this.p=e,this.a=t,this.b=r,this.G=Point.fromAffine(this,n,i),this.n=o,this.h=a,this.infinity=new Point(this,null,null,BigInteger.ZERO),this.pOverFour=e.add(BigInteger.ONE).shiftRight(2),this.pLength=Math.floor((this.p.bitLength()+7)/8)}i.prototype.pointFromX=function(e,t){var r=t.pow(3).add(this.a.multiply(t)).add(this.b).mod(this.p).modPow(this.pOverFour,this.p),n=r;return r.isEven()^!e&&(n=this.p.subtract(n)),Point.fromAffine(this,t,n)},i.prototype.isInfinity=function(e){return e===this.infinity||0===e.z.signum()&&0!==e.y.signum()},i.prototype.isOnCurve=function(e){if(this.isInfinity(e))return!0;var t=e.affineX,r=e.affineY,n=this.a,i=this.b,o=this.p;if(t.signum()<0||t.compareTo(o)>=0)return!1;if(r.signum()<0||r.compareTo(o)>=0)return!1;var a=r.square().mod(o),s=t.pow(3).add(n.multiply(t)).add(i).mod(o);return a.equals(s)},i.prototype.validate=function(e){n(!this.isInfinity(e),"Point is at infinity"),n(this.isOnCurve(e),"Point is not on the curve");var t=e.multiply(this.n);return n(this.isInfinity(t),"Point is not a scalar multiple of G"),!0},e.exports=i},function(e,t,r){var n,i=r(15),o=r(72),a=r(22),s=!1;try{n=r(401),s=!0}catch(e){}e.exports={available:s,publicKeyCreate:function(e,t){if(i(a.tuple(a.Buffer256bit,a.Boolean),arguments),s)return n.publicKeyCreate(e,t)},sign:function(e,t){if(i(a.tuple(a.Buffer256bit,a.BigInt),arguments),s){var r=n.sign(e,t.toBuffer(32)).signature;return o.fromDER(n.signatureExport(r))}},verify:function(e,t,r){if(i(a.tuple(a.Hash256bit,a.ECSignature,a.oneOf(a.BufferN(33),a.BufferN(65))),arguments),s)return t=new o(t.r,t.s),t=n.signatureNormalize(n.signatureImport(t.toDER())),n.verify(e,t,r)}}},function(e){e.exports=JSON.parse('{"COMPRESSED_TYPE_INVALID":"compressed should be a boolean","EC_PRIVATE_KEY_TYPE_INVALID":"private key should be a Buffer","EC_PRIVATE_KEY_LENGTH_INVALID":"private key length is invalid","EC_PRIVATE_KEY_RANGE_INVALID":"private key range is invalid","EC_PRIVATE_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting private key is invalid","EC_PRIVATE_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PRIVATE_KEY_EXPORT_DER_FAIL":"couldn\'t export to DER format","EC_PRIVATE_KEY_IMPORT_DER_FAIL":"couldn\'t import from DER format","EC_PUBLIC_KEYS_TYPE_INVALID":"public keys should be an Array","EC_PUBLIC_KEYS_LENGTH_INVALID":"public keys Array should have at least 1 element","EC_PUBLIC_KEY_TYPE_INVALID":"public key should be a Buffer","EC_PUBLIC_KEY_LENGTH_INVALID":"public key length is invalid","EC_PUBLIC_KEY_PARSE_FAIL":"the public key could not be parsed or is invalid","EC_PUBLIC_KEY_CREATE_FAIL":"private was invalid, try again","EC_PUBLIC_KEY_TWEAK_ADD_FAIL":"tweak out of range or resulting public key is invalid","EC_PUBLIC_KEY_TWEAK_MUL_FAIL":"tweak out of range","EC_PUBLIC_KEY_COMBINE_FAIL":"the sum of the public keys is not valid","ECDH_FAIL":"scalar was invalid (zero or overflow)","ECDSA_SIGNATURE_TYPE_INVALID":"signature should be a Buffer","ECDSA_SIGNATURE_LENGTH_INVALID":"signature length is invalid","ECDSA_SIGNATURE_PARSE_FAIL":"couldn\'t parse signature","ECDSA_SIGNATURE_PARSE_DER_FAIL":"couldn\'t parse DER signature","ECDSA_SIGNATURE_SERIALIZE_DER_FAIL":"couldn\'t serialize signature to DER format","ECDSA_SIGN_FAIL":"nonce generation function failed or private key is invalid","ECDSA_RECOVER_FAIL":"couldn\'t recover public key from signature","MSG32_TYPE_INVALID":"message should be a Buffer","MSG32_LENGTH_INVALID":"message length is invalid","OPTIONS_TYPE_INVALID":"options should be an Object","OPTIONS_DATA_TYPE_INVALID":"options.data should be a Buffer","OPTIONS_DATA_LENGTH_INVALID":"options.data length is invalid","OPTIONS_NONCEFN_TYPE_INVALID":"options.noncefn should be a Function","RECOVERY_ID_TYPE_INVALID":"recovery should be a Number","RECOVERY_ID_VALUE_INVALID":"recovery should have value between -1 and 4","TWEAK_TYPE_INVALID":"tweak should be a Buffer","TWEAK_LENGTH_INVALID":"tweak length is invalid"}')},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.create=function(e,t){var r,n=function(e){},a=function(e){},s=new Promise(function(){var t=(0,o.default)(i.default.mark((function t(o,s){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=o,a=s,"function"!=typeof e){t.next=11;break}return t.prev=3,t.next=6,e();case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(3),s(t.t0);case 11:"string"==typeof e&&(r=e);case 12:case"end":return t.stop()}}),t,null,[[3,8]])})));return function(e,r){return t.apply(this,arguments)}}());return{id:r,device:t,resolve:n,reject:a,promise:s}},t.createAsync=function(e){var t=function(e){},r=function(e){},n=new Promise((function(e,n){t=e,r=n})),a=function(){var t=(0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,e();case 2:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}();return{resolve:t,reject:r,promise:n,run:function(){return a(),n}}},t.resolveTimeoutPromise=function(e,t){return new Promise((function(r){setTimeout((function(){r(t)}),e)}))},t.rejectTimeoutPromise=function(e,t){return new Promise((function(r,n){setTimeout((function(){n(t)}),e)}))};var i=n(r(1)),o=n(r(2))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var n=s(r(419)),i=s(r(440)),o=s(r(447)),a=s(r(448));function s(e){return e&&e.__esModule?e:{default:e}}try{r(127)}catch(e){}if("undefined"==typeof window){var u=r(449);n.default.setFetch(u,!0)}else n.default.setFetch(fetch,!1);var f={BridgeV2:n.default,Fallback:o.default,Lowlevel:i.default,WebUsb:a.default};t.default=f,e.exports=t.default},function(e,t,r){"use strict";(function(Buffer){function e(t){return(e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.buildOne=function(e,t,r){return new y(e,t,r).encodeOne()},t.buildAndSend=function(e,t,r,n){return b.apply(this,arguments)};var n,i=(n=r(1))&&n.__esModule?n:{default:n},o=function(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=a();if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var s=i?Object.getOwnPropertyDescriptor(t,o):null;s&&(s.get||s.set)?Object.defineProperty(n,o,s):n[o]=t[o]}n.default=t,r&&r.set(t,n);return n}(r(41));function a(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return a=function(){return e},e}function s(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=f(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,i=function(){};return{s:i,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function u(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||f(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(e,t){if(e){if("string"==typeof e)return c(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=f)throw new Error("Config too old; "+c+" >= "+f);var l=u.wire_protocol,h=(0,o.protocolToJSON)(l.toRaw()),d=n.newBuilder({}).import(h).build();return new i.Messages(d)};var n=u(r(41)),i=r(203),o=r(427),a=u(r(438));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}function u(t){if(t&&t.__esModule)return t;if(null===t||"object"!==e(t)&&"function"!=typeof t)return{default:t};var r=s();if(r&&r.has(t))return r.get(t);var n={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var a=i?Object.getOwnPropertyDescriptor(t,o):null;a&&(a.get||a.set)?Object.defineProperty(n,o,a):n[o]=t[o]}return n.default=t,r&&r.set(t,n),n}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.Messages=void 0;!function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=o?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}r.default=e,t&&t.set(e,r)}(r(41));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}t.Messages=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.messagesByName=t;var r={};Object.keys(t.MessageType).forEach((function(e){var n=t.MessageType[e],i=e.split("_")[1],o=e.indexOf("Deprecated");o>=0&&(i=e.substr(o)),r[n]={name:i,constructor:t[i]}})),this.messagesByType=r,this.messageTypes=t.MessageType}},function(e,t,r){"use strict";var n=r(429),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=Object.defineProperty,u=s&&function(){var e={};try{for(var t in s(e,"x",{enumerable:!1,value:e}),e)return!1;return e.x===e}catch(e){return!1}}(),f=function(e,t,r,n){var i;(!(t in e)||"function"==typeof(i=n)&&"[object Function]"===o.call(i)&&n())&&(u?s(e,t,{configurable:!0,enumerable:!1,value:r,writable:!0}):e[t]=r)},c=function(e,t){var r=arguments.length>2?arguments[2]:{},o=n(t);i&&(o=a.call(o,Object.getOwnPropertySymbols(t)));for(var s=0;s=0&&"[object Function]"===n.call(e.callee)),r}},function(e,t,r){"use strict";var n=r(75),i=r(207),o=i("%Function.prototype.apply%"),a=i("%Function.prototype.call%"),s=i("%Reflect.apply%",!0)||n.call(a,o),u=i("%Object.getOwnPropertyDescriptor%",!0),f=i("%Object.defineProperty%",!0),c=i("%Math.max%");if(f)try{f({},"a",{value:1})}catch(e){f=null}e.exports=function(e){var t=s(n,a,arguments);if(u&&f){var r=u(t,"length");r.configurable&&f(t,"length",{value:1+c(0,e.length-(arguments.length-1))})}return t};var l=function(){return s(n,o,arguments)};f?f(e.exports,"apply",{value:l}):e.exports.apply=l},function(e,t,r){"use strict";var n=SyntaxError,i=Function,o=TypeError,a=function(e){try{return Function('"use strict"; return ('+e+").constructor;")()}catch(e){}},s=Object.getOwnPropertyDescriptor;if(s)try{s({},"")}catch(e){s=null}var u=function(){throw new o},f=s?function(){try{return u}catch(e){try{return s(arguments,"callee").get}catch(e){return u}}}():u,c=r(208)(),l=Object.getPrototypeOf||function(e){return e.__proto__},h=a("async function* () {}"),d=h?h.prototype:void 0,p=d?d.prototype:void 0,g="undefined"==typeof Uint8Array?void 0:l(Uint8Array),y={"%AggregateError%":"undefined"==typeof AggregateError?void 0:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?void 0:ArrayBuffer,"%ArrayIteratorPrototype%":c?l([][Symbol.iterator]()):void 0,"%AsyncFromSyncIteratorPrototype%":void 0,"%AsyncFunction%":a("async function () {}"),"%AsyncGenerator%":d,"%AsyncGeneratorFunction%":h,"%AsyncIteratorPrototype%":p?l(p):void 0,"%Atomics%":"undefined"==typeof Atomics?void 0:Atomics,"%BigInt%":"undefined"==typeof BigInt?void 0:BigInt,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?void 0:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":Error,"%eval%":eval,"%EvalError%":EvalError,"%Float32Array%":"undefined"==typeof Float32Array?void 0:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?void 0:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?void 0:FinalizationRegistry,"%Function%":i,"%GeneratorFunction%":a("function* () {}"),"%Int8Array%":"undefined"==typeof Int8Array?void 0:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?void 0:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?void 0:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":c?l(l([][Symbol.iterator]())):void 0,"%JSON%":"object"==typeof JSON?JSON:void 0,"%Map%":"undefined"==typeof Map?void 0:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&c?l((new Map)[Symbol.iterator]()):void 0,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?void 0:Promise,"%Proxy%":"undefined"==typeof Proxy?void 0:Proxy,"%RangeError%":RangeError,"%ReferenceError%":ReferenceError,"%Reflect%":"undefined"==typeof Reflect?void 0:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?void 0:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&c?l((new Set)[Symbol.iterator]()):void 0,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?void 0:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":c?l(""[Symbol.iterator]()):void 0,"%Symbol%":c?Symbol:void 0,"%SyntaxError%":n,"%ThrowTypeError%":f,"%TypedArray%":g,"%TypeError%":o,"%Uint8Array%":"undefined"==typeof Uint8Array?void 0:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?void 0:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?void 0:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?void 0:Uint32Array,"%URIError%":URIError,"%WeakMap%":"undefined"==typeof WeakMap?void 0:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?void 0:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?void 0:WeakSet},m={"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},b=r(75),v=r(116),w=b.call(Function.call,Array.prototype.concat),_=b.call(Function.apply,Array.prototype.splice),E=b.call(Function.call,String.prototype.replace),S=b.call(Function.call,String.prototype.slice),A=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,I=/\\(\\)?/g,O=function(e){var t=S(e,0,1),r=S(e,-1);if("%"===t&&"%"!==r)throw new n("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==t)throw new n("invalid intrinsic syntax, expected opening `%`");var i=[];return E(e,A,(function(e,t,r,n){i[i.length]=r?E(n,I,"$1"):t||e})),i},P=function(e,t){var r,i=e;if(v(m,i)&&(i="%"+(r=m[i])[0]+"%"),v(y,i)){var a=y[i];if(void 0===a&&!t)throw new o("intrinsic "+e+" exists, but is not available. Please file an issue!");return{alias:r,name:i,value:a}}throw new n("intrinsic "+e+" does not exist!")};e.exports=function(e,t){if("string"!=typeof e||0===e.length)throw new o("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var r=O(e),i=r.length>0?r[0]:"",a=P("%"+i+"%",t),u=a.name,f=a.value,c=!1,l=a.alias;l&&(i=l[0],_(r,w([0,1],l)));for(var h=1,d=!0;h=r.length){var b=s(f,p);f=(d=!!b)&&"get"in b&&!("originalValue"in b.get)?b.get:f[p]}else d=v(f,p),f=f[p];d&&!c&&(y[u]=f)}}return f}},function(e,t,r){"use strict";(function(t){var n=t.Symbol,i=r(432);e.exports=function(){return"function"==typeof n&&("function"==typeof Symbol&&("symbol"==typeof n("foo")&&("symbol"==typeof Symbol("bar")&&i())))}}).call(this,r(24))},function(e,t,r){"use strict";var n=r(116),i=r(433),o=r(436)("Object.prototype.propertyIsEnumerable");e.exports=function(e){var t=i(e),r=[];for(var a in t)n(t,a)&&o(t,a)&&r.push(t[a]);return r}},function(e,t,r){"use strict";var n=r(209);e.exports=function(){return"function"==typeof Object.values?Object.values:n}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.receiveOne=function(e,t){var r=a.ByteBuffer.concat([t]),n=r.readUint16();r.readUint32();var i=new o.MessageDecoder(e,n,r.toArrayBuffer());return{message:i.decodedJSON(),type:i.messageName()}},t.receiveAndParse=function(e,t){return y.apply(this,arguments)};var n,i=(n=r(1))&&n.__esModule?n:{default:n},o=r(439),a=r(41);function s(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}function u(e){return function(){var t=this,r=arguments;return new Promise((function(n,i){var o=e.apply(t,r);function a(e){s(o,n,i,a,u,"next",e)}function u(e){s(o,n,i,a,u,"throw",e)}a(void 0)}))}}function f(e,t){for(var r=0;r=this.expectedLength}},{key:"append",value:function(e){this.buffer.append(e)}},{key:"arrayBuffer",value:function(){var e=this.buffer;return e.reset(),e.toArrayBuffer()}}])&&f(t.prototype,r),n&&f(t,n),e}();function l(e){var t=a.ByteBuffer.concat([e]),r=t.readByte(),n=t.readByte();if(35!==r||35!==n)throw new Error("Didn't receive expected header signature.");var i=t.readUint16(),o=t.readUint32(),s=new c(i,o);return s.append(t),s}function h(e,t){return d.apply(this,arguments)}function d(){return(d=u(i.default.mark((function e(t,r){var n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!t.isDone()){e.next=2;break}return e.abrupt("return");case 2:return e.next=4,r();case 4:if(null!=(n=e.sent)){e.next=7;break}throw new Error("Received no data.");case 7:return t.append(n),e.abrupt("return",h(t,r));case 9:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function p(e){return g.apply(this,arguments)}function g(){return(g=u(i.default.mark((function e(t){var r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:return r=e.sent,n=l(r),e.next=6,h(n,t);case 6:return e.abrupt("return",n);case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function y(){return(y=u(i.default.mark((function e(t,r){var n,a,s,u;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,p(r);case 2:return n=e.sent,a=n.typeNumber,s=n.arrayBuffer(),u=new o.MessageDecoder(t,a,s),e.abrupt("return",{message:u.decodedJSON(),type:u.messageName()});case 7:case"end":return e.stop()}}),e)})))).apply(this,arguments)}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.create=function(){var e=function(e){},t=function(e){},r=new Promise((function(r,n){e=r,t=n})),n=r.then((function(){throw new Error("Promise is always rejecting")}));return n.catch((function(){})),{resolve:e,reject:t,promise:r,rejectingPromise:n}},t.resolveTimeoutPromise=function(e,t){return new Promise((function(r){setTimeout((function(){r(t)}),e)}))},t.rejectTimeoutPromise=function(e,t){return new Promise((function(r,n){setTimeout((function(){n(t)}),e)}))}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.ReactNativeUsbPlugin=t.WebUsbPlugin=void 0;var i=n(r(450)),o=n(r(451));t.BlockbookWorker=o.default;var a=n(r(452));t.RippleWorker=a.default;var s=n(r(200));t.WebUsbPlugin=function(){return new s.default.Lowlevel(new s.default.WebUsb,"undefined"!=typeof SharedWorker?function(){return new i.default}:null)};t.ReactNativeUsbPlugin=void 0},function(e,t,r){"use strict";t.__esModule=!0,t.load=t.save=t.CONFIRMATION_KEY=t.PERMISSIONS_KEY=t.BROWSER_KEY=void 0;t.BROWSER_KEY="trezorconnect_browser";t.PERMISSIONS_KEY="trezorconnect_permissions";t.CONFIRMATION_KEY="trezorconnect_confirmations";var n={};t.save=function(e,t,r){if(void 0===r&&(r=!1),r)n[e]=JSON.stringify(t);else{try{return void(window.localStorage[e]=JSON.stringify(t))}catch(e){}try{window.document.cookie=encodeURIComponent(e)+"="+JSON.stringify(t)+";"}catch(e){}}};t.load=function(e,t){var r;if(void 0===t&&(t=!1),t)return(r=n[e])?JSON.parse(r):null;try{r=window.localStorage[e]}catch(e){}if(void 0===r)try{var i=window.document.cookie,o=i.indexOf(encodeURIComponent(e)+"=");if(-1!==o){var a=/^([^;]+)/.exec(i.slice(o));a&&(r=a[1])}}catch(e){}return r?JSON.parse(r):null}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=n(r(29));n(r(23));function u(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function f(e){for(var t=1;t=t.indexOf(i))return i;for(var o=e;"string"!=typeof t[o]&&o1&&(r=this.levels.map((function(e){return e.blocks})).reduce((function(e,t){if(0===e.length)return e.concat([t]);var r=e[e.length-1],n=t-r,i=h(r,n<=30?1:6,n);return e.concat(i)}),[])),e.prev=4,e.next=7,t.estimateFee({blocks:r});case 7:e.sent.forEach((function(e,t){o.blocks[r[t]]=l(e.feePerUnit)})),1===this.levels.length?"string"==typeof(n=d(this.blocks))&&(this.levels[0].blocks=this.blocks.indexOf(n),this.levels[0].feePerUnit=n):this.levels.forEach((function(e){var t=p(e.blocks,o.blocks);"string"==typeof t&&(e.blocks=o.blocks.indexOf(t),e.feePerUnit=t)})),e.next=14;break;case 12:e.prev=12,e.t0=e.catch(4);case 14:return e.abrupt("return",this.levels);case 15:case"end":return e.stop()}}),e,this,[[4,12]])})));return function(t){return e.apply(this,arguments)}}(),t.updateCustomFee=function(e){this.levels=this.levels.filter((function(e){return"custom"!==e.label}));var t=function(e,t){var r=new s.default(e),n=t.find((function(e){return"string"==typeof e&&r.gte(e)}));return n?t.indexOf(n):-1}(e,this.blocks);this.levels.push({label:"custom",feePerUnit:e,blocks:t})},e}();t.default=g},function(e,t,r){"use strict";t.__esModule=!0,t.addressParametersFromProto=t.addressParametersToProto=t.validateAddressParameters=void 0;var n=r(4),i=r(12);t.validateAddressParameters=function(e){(0,n.validateParams)(e,[{name:"addressType",type:"number",obligatory:!0},{name:"path",obligatory:!0},{name:"stakingKeyHash",type:"string"}]),(0,i.validatePath)(e.path),e.stakingPath&&(0,i.validatePath)(e.stakingPath),e.certificatePointer&&(0,n.validateParams)(e.certificatePointer,[{name:"blockIndex",type:"number",obligatory:!0},{name:"txIndex",type:"number",obligatory:!0},{name:"certificateIndex",type:"number",obligatory:!0}])};t.addressParametersToProto=function(e){var t,r=(0,i.validatePath)(e.path,3),n=[];return e.stakingPath&&(n=(0,i.validatePath)(e.stakingPath,3)),e.certificatePointer&&(t={block_index:e.certificatePointer.blockIndex,tx_index:e.certificatePointer.txIndex,certificate_index:e.certificatePointer.certificateIndex}),{address_type:e.addressType,address_n:r,address_n_staking:n,staking_key_hash:e.stakingKeyHash,certificate_pointer:t}};t.addressParametersFromProto=function(e){var t;return e.certificate_pointer&&(t={blockIndex:e.certificate_pointer.block_index,txIndex:e.certificate_pointer.tx_index,certificateIndex:e.certificate_pointer.certificate_index}),{addressType:e.address_type,path:e.address_n,stakingPath:e.address_n_staking,stakingKeyHash:e.staking_key_hash,certificatePointer:t}}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(25)),c=r(6),l=(n(r(23)),n(r(185)),r(74)),h=r(33);function d(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function p(e){for(var t=1;t0?"segwit":"normal",getPath:i.bind((0,a.default)(r),49)}),r.types.push({type:r.types.length>0?"legacy":"normal",getPath:i.bind((0,a.default)(r),44)})}else r.types.push({type:"normal",getPath:l.getAccountAddressN.bind((0,a.default)(r),n)});return r}(0,s.default)(t,e);var r=t.prototype;return r.start=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n,o=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:10,this.interrupted=!1,r=i.default.mark((function e(){var r,n,a,s,u,f,l,d;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=o.types[o.typeIndex],n="Account #"+(o.index+1),a=o.index>=10,s=r.getPath(o.index),e.next=6,o.commands.getAccountDescriptor(o.coinInfo,s);case 6:if(u=e.sent){e.next=9;break}throw c.ERRORS.TypedError("Runtime","Discovery: descriptor not found");case 9:if(!o.interrupted){e.next=11;break}return e.abrupt("return",{v:void 0});case 11:return f=p(p({},u),{},{type:r.type,label:n}),o.accounts=o.accounts.filter((function(e){return e.descriptor!==f.descriptor})),a||(o.accounts.push(f),o.emit("progress",o.accounts)),e.next=16,o.blockchain.getAccountInfo({descriptor:f.descriptor,details:t});case 16:if(l=e.sent,!o.interrupted){e.next=19;break}return e.abrupt("return",{v:void 0});case 19:o.accounts=o.accounts.filter((function(e){return e.descriptor!==f.descriptor})),(!a||a&&!l.empty)&&(d=(0,h.formatAmount)(l.availableBalance,o.coinInfo),o.accounts.push(p(p({},f),{},{empty:l.empty,balance:d,addresses:l.addresses})),o.emit("progress",o.accounts)),l.empty?o.typeIndex+11?r-1:0),i=1;i1?t-1:0),n=1;ne.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0||(i[r]=e[r]);return i}},function(e,t,r){"use strict";var n,i=r(14),o=r(0),a=o(r(1)),s=o(r(11)),u=o(r(2)),f=r(6),c=i(r(123)),l=i(r(122)),h=i(r(20)),d=r(125),p=o(r(32)),g=r(360),y=r(564),m=r(13),b=r(49),v=r(565),w=r(126),_=r(566),E=r(214);function S(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function A(e){for(var t=1;t=0)&&(o="*"),(0,v.sendMessage)(e,o)}},k=function(e){var t=[l.LOADED,l.ERROR,c.CANCEL_POPUP_REQUEST,h.CLOSE_UI_WINDOW,h.CUSTOM_MESSAGE_REQUEST,h.LOGIN_CHALLENGE_REQUEST,h.BUNDLE_PROGRESS,h.ADDRESS_VALIDATION];return e.event===f.UI_EVENT&&t.indexOf(e.type)<0},T=function(e){if(!e.payload)return!1;var t=e.payload.features;if(t){var r=(0,E.load)(E.PERMISSIONS_KEY)||(0,E.load)(E.PERMISSIONS_KEY,!0);if(r&&Array.isArray(r))return r.filter((function(e){return e.origin===p.default.getSettings("origin")&&"read"===e.type&&e.device===t.device_id})).length>0}return!1},x=function(){var e=(0,u.default)(a.default.mark((function e(t,r){var i,o;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!p.default.getSettings("origin")){e.next=2;break}return e.abrupt("return");case 2:if((i=(0,d.parse)(A(A({},t.settings),{},{extension:t.extension}))).origin=r&&"null"!==r?r:t.settings.origin,i.popup&&"undefined"!=typeof BroadcastChannel){o=i.env+"-"+i.timestamp;try{(I=new BroadcastChannel(o)).onmessage=function(e){return P(e)}}catch(e){}}return O.enabled=!!i.debug,e.prev=6,e.next=9,(0,g.init)(i);case 9:return(n=e.sent).on(f.CORE_EVENT,M),e.next=13,(0,g.initTransport)(i);case 13:M((0,m.UiMessage)(l.LOADED,{useBroadcastChannel:!!I})),e.next=19;break;case 16:e.prev=16,e.t0=e.catch(6),M((0,m.UiMessage)(l.ERROR,{error:e.t0}));case 19:case"end":return e.stop()}}),e,null,[[6,16]])})));return function(t,r){return e.apply(this,arguments)}}();window.addEventListener("message",P,!1),window.addEventListener("unload",(function(){n&&n.onBeforeUnload()}))},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?e.exports=r=function(e){return typeof e}:e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},r(t)}e.exports=r},function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof l?t:l,o=Object.create(i.prototype),a=new S(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return I()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=w(a,r);if(s){if(s===c)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=f(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===c)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function f(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var c={};function l(){}function h(){}function d(){}var p={};p[i]=function(){return this};var g=Object.getPrototypeOf,y=g&&g(g(A([])));y&&y!==t&&r.call(y,i)&&(p=y);var m=d.prototype=l.prototype=Object.create(p);function b(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function v(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u=f(e[i],e,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(l).then((function(e){c.value=e,a(c)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return c;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return c}var n=f(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,c;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,c):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,c)}function _(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function E(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function S(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(_,this),this.reset(!0)}function A(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),E(r),c}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;E(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:A(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),c}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){"use strict";t.__esModule=!0,t.FIAT_RATES_UPDATE=t.NOTIFICATION=t.BLOCK=t.CONNECT=t.ERROR=void 0;t.ERROR="blockchain-error";t.CONNECT="blockchain-connect";t.BLOCK="blockchain-block";t.NOTIFICATION="blockchain-notification";t.FIAT_RATES_UPDATE="fiat-rates-update"},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.WEBUSB_ERROR_MESSAGE=t.INVALID_PIN_ERROR_MESSAGE=t.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE=t.TypedError=t.TrezorError=t.ERROR_CODES=void 0;var i=n(r(3)),o=n(r(235)),a={Init_NotInitialized:"TrezorConnect not yet initialized",Init_AlreadyInitialized:"TrezorConnect has been already initialized",Init_IframeBlocked:"Iframe blocked",Init_IframeTimeout:"Iframe timeout",Init_ManifestMissing:"Manifest not set. Read more at https://github.com/trezor/connect/blob/develop/docs/index.md",Popup_ConnectionMissing:"Unable to establish connection with iframe",Transport_Missing:"Transport is missing",Transport_InvalidProtobuf:"",Method_InvalidPackage:"This version of trezor-connect is not suitable to work without browser. Use trezor-connect@extended package instead",Method_InvalidParameter:"",Method_NotAllowed:"Method not allowed for this configuration",Method_PermissionsNotGranted:"Permissions not granted",Method_Cancel:"Cancelled",Method_Interrupted:"Popup closed",Method_UnknownCoin:"Coin not found",Method_AddressNotMatch:"Addresses do not match",Method_FirmwareUpdate_DownloadFailed:"Failed to download firmware binary",Method_CustomMessage_Callback:'Parameter "callback" is not a function',Method_Discovery_BundleException:"",Method_Override:"override",Method_NoResponse:"Call resolved without response",Backend_NotSupported:"BlockchainLink settings not found in coins.json",Backend_WorkerMissing:"",Backend_Disconnected:"Backend disconnected",Backend_Invalid:"Invalid backend",Backend_Error:"",Runtime:"",Device_NotFound:"Device not found",Device_InitializeFailed:"",Device_FwException:"",Device_ModeException:"",Device_Disconnected:"Device disconnected",Device_UsedElsewhere:"Device is used in another window",Device_InvalidState:"Passphrase is incorrect",Device_CallInProgress:"Device call in progress"};t.ERROR_CODES=a;var s=function(e){function t(t,r){var n;return(n=e.call(this,r)||this).code=t,n.message=r,n}return(0,i.default)(t,e),t}((0,o.default)(Error));t.TrezorError=s;t.TypedError=function(e,t){return new s(e,t||a[e])};t.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE="wrong previous session";t.INVALID_PIN_ERROR_MESSAGE="PIN invalid";t.WEBUSB_ERROR_MESSAGE="NetworkError: Unable to claim interface."},function(e,t,r){var n=r(236),i=r(121),o=r(237),a=r(238);function s(t){var r="function"==typeof Map?new Map:void 0;return e.exports=s=function(e){if(null===e||!o(e))return e;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return a(e,arguments,n(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),i(t,e)},s(t)}e.exports=s},function(e,t){function r(t){return e.exports=r=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},r(t)}e.exports=r},function(e,t){e.exports=function(e){return-1!==Function.toString.call(e).indexOf("[native code]")}},function(e,t,r){var n=r(121),i=r(239);function o(t,r,a){return i()?e.exports=o=Reflect.construct:e.exports=o=function(e,t,r){var i=[null];i.push.apply(i,t);var o=new(Function.bind.apply(e,i));return r&&n(o,r.prototype),o},o.apply(null,arguments)}e.exports=o},function(e,t){e.exports=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}},function(e,t,r){"use strict";t.__esModule=!0,t.TYPES=void 0;var n=Object.freeze({bitcoin:"Bitcoin",ethereum:"Ethereum",eos:"Eos",nem:"NEM",stellar:"Stellar",lisk:"Lisk",cardano:"Cardano",ripple:"Ripple",tezos:"Tezors",binance:"Binance"});t.TYPES=n},function(e,t,r){"use strict";var n=this&&this.__createBinding||(Object.create?function(e,t,r,n){void 0===n&&(n=r),Object.defineProperty(e,n,{enumerable:!0,get:function(){return t[r]}})}:function(e,t,r,n){void 0===n&&(n=r),e[n]=t[r]}),i=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),o=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)"default"!==r&&Object.prototype.hasOwnProperty.call(e,r)&&n(t,e,r);return i(t,e),t};Object.defineProperty(t,"__esModule",{value:!0}),t.filterSafeListByFirmware=t.filterSafeListByBootloader=void 0;var a=o(r(129));t.filterSafeListByBootloader=function(e,t){return e.filter((function(e){return(!e.min_bootloader_version||a.isNewerOrEqual(t,e.min_bootloader_version))&&(!e.bootloader_version||a.isNewerOrEqual(e.bootloader_version,t))}))},t.filterSafeListByFirmware=function(e,t){return e.filter((function(e){return a.isNewerOrEqual(t,e.min_firmware_version)}))}},function(e,t,r){"use strict";var n=this&&this.__awaiter||function(e,t,r,n){return new(r||(r=Promise))((function(i,o){function a(e){try{u(n.next(e))}catch(e){o(e)}}function s(e){try{u(n.throw(e))}catch(e){o(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}u((n=n.apply(e,t||[])).next())}))},i=this&&this.__generator||function(e,t){var r,n,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(r)throw new TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=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++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=a.trys,(i=i.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]-1};function f(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(e))throw new TypeError("Invalid character in header field name");return e.toLowerCase()}function c(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){this.append(e[0],e[1])}),this):e&&Object.getOwnPropertyNames(e).forEach((function(t){this.append(t,e[t])}),this)}function d(e){if(e.bodyUsed)return Promise.reject(new TypeError("Already read"));e.bodyUsed=!0}function p(e){return new Promise((function(t,r){e.onload=function(){t(e.result)},e.onerror=function(){r(e.error)}}))}function g(e){var t=new FileReader,r=p(t);return t.readAsArrayBuffer(e),r}function y(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(e){var t;this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:i&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:o&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():a&&i&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=y(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):a&&(ArrayBuffer.prototype.isPrototypeOf(e)||u(e))?this._bodyArrayBuffer=y(e):this._bodyText=e=Object.prototype.toString.call(e):this._bodyText="",this.headers.get("content-type")||("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},i&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?d(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(g)}),this.text=function(){var e,t,r,n=d(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,r=p(t),t.readAsText(e),r;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),r=new Array(t.length),n=0;n-1?n:r),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&i)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(i)}function w(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var r=e.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");t.append(decodeURIComponent(n),decodeURIComponent(i))}})),t}function _(e,t){t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in t?t.statusText:"OK",this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(_.prototype),_.prototype.clone=function(){return new _(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},_.error=function(){var e=new _(null,{status:0,statusText:""});return e.type="error",e};var E=[301,302,303,307,308];_.redirect=function(e,t){if(-1===E.indexOf(t))throw new RangeError("Invalid status code");return new _(null,{status:t,headers:{location:e}})},t.DOMException=e.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var r=Error(e);this.stack=r.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function S(e,r){return new Promise((function(n,o){var a=new v(e,r);if(a.signal&&a.signal.aborted)return o(new t.DOMException("Aborted","AbortError"));var s=new XMLHttpRequest;function u(){s.abort()}s.onload=function(){var e,t,r={status:s.status,statusText:s.statusText,headers:(e=s.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(e){var r=e.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();t.append(n,i)}})),t)};r.url="responseURL"in s?s.responseURL:r.headers.get("X-Request-URL");var i="response"in s?s.response:s.responseText;n(new _(i,r))},s.onerror=function(){o(new TypeError("Network request failed"))},s.ontimeout=function(){o(new TypeError("Network request failed"))},s.onabort=function(){o(new t.DOMException("Aborted","AbortError"))},s.open(a.method,a.url,!0),"include"===a.credentials?s.withCredentials=!0:"omit"===a.credentials&&(s.withCredentials=!1),"responseType"in s&&i&&(s.responseType="blob"),a.headers.forEach((function(e,t){s.setRequestHeader(t,e)})),a.signal&&(a.signal.addEventListener("abort",u),s.onreadystatechange=function(){4===s.readyState&&a.signal.removeEventListener("abort",u)}),s.send(void 0===a._bodyInit?null:a._bodyInit)}))}S.polyfill=!0,e.fetch||(e.fetch=S,e.Headers=h,e.Request=v,e.Response=_),t.Headers=h,t.Request=v,t.Response=_,t.fetch=S}({})}(r),delete r.fetch.polyfill,(t=r.fetch).default=r.fetch,t.fetch=r.fetch,t.Headers=r.Headers,t.Request=r.Request,t.Response=r.Response,e.exports=t},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.getScore=void 0;var n=r(81);t.getScore=function(e){var t=n.createHash("sha256");t.update(e);var r=parseInt(t.digest("hex"),16)/Math.pow(2,256);return Math.round(100*r)/100}},function(e,t,r){"use strict";t.byteLength=function(e){var t=f(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,n=f(e),a=n[0],s=n[1],u=new o(function(e,t,r){return 3*(t+r)/4-r}(0,a,s)),c=0,l=s>0?a-4:a;for(r=0;r>16&255,u[c++]=t>>8&255,u[c++]=255&t;2===s&&(t=i[e.charCodeAt(r)]<<2|i[e.charCodeAt(r+1)]>>4,u[c++]=255&t);1===s&&(t=i[e.charCodeAt(r)]<<10|i[e.charCodeAt(r+1)]<<4|i[e.charCodeAt(r+2)]>>2,u[c++]=t>>8&255,u[c++]=255&t);return u},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,o=[],a=0,s=r-i;as?s:a+16383));1===i?(t=e[r-1],o.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],o.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"="));return o.join("")};for(var n=[],i=[],o="undefined"!=typeof Uint8Array?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0,u=a.length;s0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,r){for(var i,o,a=[],s=t;s>18&63]+n[o>>12&63]+n[o>>6&63]+n[63&o]);return a.join("")}i["-".charCodeAt(0)]=62,i["_".charCodeAt(0)]=63},function(e,t){ /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */ -t.read=function(e,t,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+e[t+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,y=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(t*u-1)*Math.pow(2,i),a+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,f-=8);e[r+d-p]|=128*y}},function(e,t,r){(t=e.exports=r(133)).Stream=t,t.Readable=t,t.Writable=r(137),t.Duplex=r(44),t.Transform=r(138),t.PassThrough=r(254),t.finished=r(85),t.pipeline=r(255)},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return Buffer.alloc(0);for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,Buffer.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=Buffer.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:s,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&a.forEach(f),o||(a.forEach(f),i(n))}))}));return t.reduce(c)}},function(e,t,r){var n=r(10),i=r(45),Buffer=r(7).Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var d=~~(h/20),p=0|((t=n)<<5|t>>>27)+f(d,i,a,s)+c+r[h]+o[d];c=s,s=a,a=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=s},function(e,t,r){var n=r(10),i=r(45),Buffer=r(7).Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function c(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,l=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=(t=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),y=u(n)+c(p,i,a,s)+l+r[d]+o[p]|0;l=s,s=a,a=f(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=l+this._e|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=s},function(e,t,r){var n=r(10),i=r(139),o=r(45),Buffer=r(7).Buffer,a=new Array(64);function s(){this.init(),this._w=a,o.call(this,64,56)}n(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var e=Buffer.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=s},function(e,t,r){var n=r(10),i=r(140),o=r(45),Buffer=r(7).Buffer,a=new Array(160);function s(){this.init(),this._w=a,o.call(this,128,112)}n(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var e=Buffer.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=s},function(e,t){},function(e,t,r){"use strict";var Buffer=r(90).Buffer,n=r(262);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,t.copy(r,n),a+=o.data.length,o=o.next;return i},e}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(264),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(24))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,a,s,u=1,f={},c=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},n=function(e){o.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,n=function(e){var t=l.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(p,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&p(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),n=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r64?t=e(t):t.length<64&&(t=Buffer.concat([t,o],64));for(var r=this._ipad=Buffer.allocUnsafe(64),n=this._opad=Buffer.allocUnsafe(64),a=0;a<64;a++)r[a]=54^t[a],n[a]=92^t[a];this._hash=[r]}n(a,i),a.prototype._update=function(e){this._hash.push(e)},a.prototype._final=function(){var e=this._alg(Buffer.concat(this._hash));return this._alg(Buffer.concat([this._opad,e]))},e.exports=a},function(e,t,r){e.exports=r(146)},function(e,t,r){(function(t,n){var i,Buffer=r(7).Buffer,o=r(148),a=r(149),s=r(150),u=r(151),f=t.crypto&&t.crypto.subtle,c={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},l=[];function h(e,t,r,n,i){return f.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return f.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)})).then((function(e){return Buffer.from(e)}))}e.exports=function(e,r,d,p,y,g){"function"==typeof y&&(g=y,y=void 0);var m=c[(y=y||"sha1").toLowerCase()];if(!m||"function"!=typeof t.Promise)return n.nextTick((function(){var t;try{t=s(e,r,d,p,y)}catch(e){return g(e)}g(null,t)}));if(o(d,p),e=u(e,a,"Password"),r=u(r,a,"Salt"),"function"!=typeof g)throw new Error("No callback provided to pbkdf2");!function(e,t){e.then((function(e){n.nextTick((function(){t(null,e)}))}),(function(e){n.nextTick((function(){t(e)}))}))}(function(e){if(t.process&&!t.process.browser)return Promise.resolve(!1);if(!f||!f.importKey||!f.deriveBits)return Promise.resolve(!1);if(void 0!==l[e])return l[e];var r=h(i=i||Buffer.alloc(8),i,10,128,e).then((function(){return!0})).catch((function(){return!1}));return l[e]=r,r}(m).then((function(t){return t?h(e,r,d,p,m):s(e,r,d,p,y)})),g)}}).call(this,r(24),r(16))},function(e,t,r){var n=r(274),i=r(93),o=r(94),a=r(287),s=r(65);function u(e,t,r){if(e=e.toLowerCase(),o[e])return i.createCipheriv(e,t,r);if(a[e])return new n({key:t,iv:r,mode:e});throw new TypeError("invalid suite type")}function f(e,t,r){if(e=e.toLowerCase(),o[e])return i.createDecipheriv(e,t,r);if(a[e])return new n({key:t,iv:r,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}t.createCipher=t.Cipher=function(e,t){var r,n;if(e=e.toLowerCase(),o[e])r=o[e].key,n=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");r=8*a[e].key,n=a[e].iv}var i=s(t,!1,r,n);return u(e,i.key,i.iv)},t.createCipheriv=t.Cipheriv=u,t.createDecipher=t.Decipher=function(e,t){var r,n;if(e=e.toLowerCase(),o[e])r=o[e].key,n=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");r=8*a[e].key,n=a[e].iv}var i=s(t,!1,r,n);return f(e,i.key,i.iv)},t.createDecipheriv=t.Decipheriv=f,t.listCiphers=t.getCiphers=function(){return Object.keys(a).concat(i.getCiphers())}},function(e,t,r){var n=r(36),i=r(275),o=r(10),Buffer=r(7).Buffer,a={"des-ede3-cbc":i.CBC.instantiate(i.EDE),"des-ede3":i.EDE,"des-ede-cbc":i.CBC.instantiate(i.EDE),"des-ede":i.EDE,"des-cbc":i.CBC.instantiate(i.DES),"des-ecb":i.DES};function s(e){n.call(this);var t,r=e.mode.toLowerCase(),i=a[r];t=e.decrypt?"decrypt":"encrypt";var o=e.key;Buffer.isBuffer(o)||(o=Buffer.from(o)),"des-ede"!==r&&"des-ede-cbc"!==r||(o=Buffer.concat([o,o.slice(0,8)]));var s=e.iv;Buffer.isBuffer(s)||(s=Buffer.from(s)),this._des=i.create({key:o,iv:s,type:t})}a.des=a["des-cbc"],a.des3=a["des-ede3-cbc"],e.exports=s,o(s,n),s.prototype._update=function(e){return Buffer.from(this._des.update(e))},s.prototype._final=function(){return Buffer.from(this._des.final())}},function(e,t,r){"use strict";t.utils=r(152),t.Cipher=r(92),t.DES=r(153),t.CBC=r(276),t.EDE=r(277)},function(e,t,r){"use strict";var n=r(27),i=r(10),o={};function a(e){n.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=Buffer.allocUnsafe(e),r=-1;++r>a%8,e._prev=i(e._prev,r?n:o);return s}function i(e,t){var r=e.length,n=-1,i=Buffer.allocUnsafe(e.length);for(e=Buffer.concat([e,Buffer.from([t])]);++n>7;return i}t.encrypt=function(e,t,r){for(var i=t.length,o=Buffer.allocUnsafe(i),a=-1;++a>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(e){var t;for(this.cache=Buffer.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,e,0,t])),this.state},e.exports=o},function(e,t,r){var n=r(157),Buffer=r(7).Buffer,i=r(94),o=r(158),a=r(36),s=r(64),u=r(65);function f(e,t,r){a.call(this),this._cache=new c,this._last=void 0,this._cipher=new s.AES(t),this._prev=Buffer.from(r),this._mode=e,this._autopadding=!0}function c(){this.cache=Buffer.allocUnsafe(0)}function l(e,t,r){var a=i[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof t&&(t=Buffer.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===a.type?new o(a.module,t,r,!0):"auth"===a.type?new n(a.module,t,r,!0):new f(a.module,t,r)}r(10)(f,a),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,t),n.push(r);return Buffer.concat(n)},f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},c.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(e,t){var r=i[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},t.createDecipheriv=l},function(e,t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}},function(e,t,r){(function(Buffer){var e=r(159),n=r(291),i=r(292);var o={binary:!0,hex:!0,base64:!0};t.DiffieHellmanGroup=t.createDiffieHellmanGroup=t.getDiffieHellman=function(e){var t=new Buffer(n[e].prime,"hex"),r=new Buffer(n[e].gen,"hex");return new i(t,r)},t.createDiffieHellman=t.DiffieHellman=function t(r,n,a,s){return Buffer.isBuffer(n)||void 0===o[n]?t(r,"binary",n,a):(n=n||"binary",s=s||"binary",a=a||new Buffer([2]),Buffer.isBuffer(a)||(a=new Buffer(a,s)),"number"==typeof r?new i(e(r,a),a,!0):(Buffer.isBuffer(r)||(r=new Buffer(r,n)),new i(r,a,!0)))}}).call(this,r(9).Buffer)},function(e,t){},function(e,t){},function(e){e.exports=JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}')},function(e,t,r){(function(Buffer){var t=r(18),n=new(r(160)),i=new t(24),o=new t(11),a=new t(10),s=new t(3),u=new t(7),f=r(159),c=r(34);function l(e,r){return r=r||"utf8",Buffer.isBuffer(e)||(e=new Buffer(e,r)),this._pub=new t(e),this}function h(e,r){return r=r||"utf8",Buffer.isBuffer(e)||(e=new Buffer(e,r)),this._priv=new t(e),this}e.exports=p;var d={};function p(e,r,n){this.setGenerator(r),this.__prime=new t(e),this._prime=t.mont(this.__prime),this._primeLen=e.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,n?(this.setPublicKey=l,this.setPrivateKey=h):this._primeCode=8}function y(e,t){var r=new Buffer(e.toArray());return t?r.toString(t):r}Object.defineProperty(p.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(e,t){var r=t.toString("hex"),c=[r,e.toString(16)].join("_");if(c in d)return d[c];var l,h=0;if(e.isEven()||!f.simpleSieve||!f.fermatTest(e)||!n.test(e))return h+=1,h+="02"===r||"05"===r?8:4,d[c]=h,h;switch(n.test(e.shrn(1))||(h+=2),r){case"02":e.mod(i).cmp(o)&&(h+=8);break;case"05":(l=e.mod(a)).cmp(s)&&l.cmp(u)&&(h+=8);break;default:h+=4}return d[c]=h,h}(this.__prime,this.__gen)),this._primeCode}}),p.prototype.generateKeys=function(){return this._priv||(this._priv=new t(c(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},p.prototype.computeSecret=function(e){var r=(e=(e=new t(e)).toRed(this._prime)).redPow(this._priv).fromRed(),n=new Buffer(r.toArray()),i=this.getPrime();if(n.length0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return Buffer.alloc(0);for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,Buffer.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=Buffer.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:s,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&a.forEach(f),o||(a.forEach(f),i(n))}))}));return t.reduce(c)}},function(e,t,r){var Buffer=r(7).Buffer,n=r(63),i=r(97),o=r(67).ec,a=r(172),s=r(69),u=r(178);function f(e,t,r,i){if((e=Buffer.from(e.toArray())).length0&&r.ishrn(n),r}function l(e,t,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=49&&f<=54?f-49+10:f>=17&&f<=22?f-17+10:f,a|=u}return n(!(240&a),"Invalid character in "+e),i}function s(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?f-49+10:f>=17?f-17+10:f,n(f>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this._strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,u=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(e){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var c=["","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"],l=[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],h=[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];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=l[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var y=p.modrn(d).toString(e);r=(p=p.idivn(d)).isZero()?y+r:c[f-y.length]+y+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},Buffer&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(Buffer,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,y=d>>>13,g=0|a[2],m=8191&g,b=g>>>13,v=0|a[3],w=8191&v,_=v>>>13,E=0|a[4],S=8191&E,A=E>>>13,I=0|a[5],O=8191&I,P=I>>>13,M=0|a[6],k=8191&M,T=M>>>13,x=0|a[7],R=8191&x,C=x>>>13,N=0|a[8],B=8191&N,D=N>>>13,U=0|a[9],j=8191&U,L=U>>>13,F=0|s[0],H=8191&F,q=F>>>13,V=0|s[1],K=8191&V,z=V>>>13,G=0|s[2],Q=8191&G,W=G>>>13,Y=0|s[3],Z=8191&Y,J=Y>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,ye=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ge=(f+(n=Math.imul(l,H))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,H)|0))<<13)|0;f=((o=Math.imul(h,q))+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(y,H)|0,o=Math.imul(y,q);var me=(f+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,z)|0)+Math.imul(h,K)|0))<<13)|0;f=((o=o+Math.imul(h,z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(b,H)|0,o=Math.imul(b,q),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,z)|0)+Math.imul(y,K)|0,o=o+Math.imul(y,z)|0;var be=(f+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,Q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,z)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(y,Q)|0,o=o+Math.imul(y,W)|0;var ve=(f+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(A,H)|0,o=Math.imul(A,q),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,z)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(y,Z)|0,o=o+Math.imul(y,J)|0;var we=(f+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,H),i=(i=Math.imul(O,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,z)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(y,$)|0,o=o+Math.imul(y,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,q))+Math.imul(T,H)|0,o=Math.imul(T,q),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(y,re)|0,o=o+Math.imul(y,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,z)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(y,oe)|0,o=o+Math.imul(y,ae)|0;var Se=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,q))+Math.imul(D,H)|0,o=Math.imul(D,q),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,z)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,z)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(y,ue)|0,o=o+Math.imul(y,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,H),i=(i=Math.imul(j,q))+Math.imul(L,H)|0,o=Math.imul(L,q),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,z)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,z)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(y,le)|0,o=o+Math.imul(y,he)|0;var Ie=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ye)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,ye)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,z))+Math.imul(L,K)|0,o=Math.imul(L,z),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Oe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ye)|0)+Math.imul(y,pe)|0))<<13)|0;f=((o=o+Math.imul(y,ye)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,W))+Math.imul(L,Q)|0,o=Math.imul(L,W),n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(T,re)|0,o=o+Math.imul(T,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var Pe=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ye)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,ye)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,J))+Math.imul(L,Z)|0,o=Math.imul(L,J),n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,fe)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var Me=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ye)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ye)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,ee))+Math.imul(L,$)|0,o=Math.imul(L,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var ke=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ye)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,ye)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ye)|0)+Math.imul(P,pe)|0))<<13)|0;f=((o=o+Math.imul(P,ye)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ye)|0)+Math.imul(T,pe)|0))<<13)|0;f=((o=o+Math.imul(T,ye)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ye)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ye)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(L,le)|0,o=Math.imul(L,he);var Ce=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ye)|0)+Math.imul(D,pe)|0))<<13)|0;f=((o=o+Math.imul(D,ye)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ne=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ye))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ye))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ge,u[1]=me,u[2]=be,u[3]=ve,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Se,u[8]=Ae,u[9]=Ie,u[10]=Oe,u[11]=Pe,u[12]=Me,u[13]=ke,u[14]=Te,u[15]=xe,u[16]=Re,u[17]=Ce,u[18]=Ne,0!==f&&(u[19]=f,r.length++),r};function y(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function g(e,t,r){return y(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(p=d),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?y(this,e,t):g(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,y=1;0==(r.words[0]&y)&&p<26;++p,y<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function I(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(w,v),w.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new w;else if("p224"===e)t=new _;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return b[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var y=d,g=0;0!==y.cmp(s);g++)y=y.redSqr();n(g=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new I(e)},i(I,A),I.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},I.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},I.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},I.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(66)(e))},function(e,t){},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.3","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny ","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^1.4.3","coveralls":"^3.0.8","grunt":"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.2","jscs":"^3.0.7","jshint":"^2.10.3","mocha":"^6.2.2"},"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"}}')},function(e,t,r){"use strict";var n=r(28),i=r(18),o=r(10),a=r(68),s=n.assert;function u(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),e.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,s,u,f,c,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=e,d=this.n.clone(),p=new i(1),y=new i(0),g=new i(0),m=new i(1),b=0;0!==h.cmpn(0);){var v=d.div(h);f=d.sub(v.mul(h)),c=g.sub(v.mul(p));var w=m.sub(v.mul(y));if(!n&&f.cmp(l)<0)t=u.neg(),r=p,n=f.neg(),o=c;else if(n&&2==++b)break;u=f,d=h,h=f,g=p,p=c,m=y,y=w}a=f.neg(),s=c;var _=n.sqr().add(o.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:o},{a,b:s}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Point.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(18),i=r(10),o=r(68),a=r(28);function s(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(s,o),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new Point(this,e,t)},s.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1]||e.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},Point.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(28),i=r(18),o=r(10),a=r(68),s=n.assert;function u(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function Point(e,t,r,n,o){a.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,a),e.exports=u,u.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},u.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},u.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(o.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var u=s.fromRed().isOdd();return(t&&!u||!t&&u)&&(s=s.redNeg()),this.point(e,s)},u.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},u.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(Point,a.BasePoint),u.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},u.prototype.point=function(e,t,r,n){return new Point(this,e,t,r,n)},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1],t[2])},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),f=o.redMul(s),c=i.redMul(s),l=a.redMul(o);return this.curve.point(u,f,l,c)},Point.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(f=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(f.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(f.redSub(o)),r=a.redMul(u)}}else{var f=i.redAdd(o);s=this.curve._mulC(this.z).redSqr(),u=f.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(f)).redMul(u),t=this.curve._mulC(f).redMul(i.redISub(o)),r=f.redMul(u)}return this.curve.point(e,t,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),f=o.redMul(a),c=s.redMul(u),l=o.redMul(u),h=a.redMul(s);return this.curve.point(f,c,h,l)},Point.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),f=i.redAdd(s),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),l=n.redMul(u).redMul(c);return this.curve.twisted?(t=n.redMul(f).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(f)):(t=n.redMul(f).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(f)),this.curve.point(l,t,r)},Point.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Point.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Point.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},function(e,t,r){"use strict";t.sha1=r(310),t.sha224=r(311),t.sha256=r(170),t.sha384=r(312),t.sha512=r(171)},function(e,t,r){"use strict";var n=r(30),i=r(55),o=r(169),a=n.rotl32,s=n.sum32,u=n.sum32_5,f=o.ft_1,c=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(h,c),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),u=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new n(1)),h=0;;h++){var d=o.k?o.k(h):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(l)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var y=p.getX(),g=y.umod(this.n);if(0!==g.cmpn(0)){var m=d.invm(this.n).mul(g.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var b=(p.getY().isOdd()?1:0)|(0!==y.cmp(g)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),b^=1),new c({r:g,s:m,recoveryParam:b})}}}}}},l.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new c(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,u=a.invm(this.n),f=u.mul(e).umod(this.n),l=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),l)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),l)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},l.prototype.recoverPubKey=function(e,t,r,i){u((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,a=new n(e),s=t.r,f=t.s,l=1&r,h=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");s=h?this.curve.pointFromX(s.add(this.curve.n),l):this.curve.pointFromX(s,l);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),y=f.mul(d).umod(o);return this.g.mulAdd(p,s,y)},l.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(99),i=r(167),o=r(27);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length"}},function(e,t,r){"use strict";var n=r(18),i=r(28),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function u(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function f(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new s;if(48!==e[r.place++])return!1;var o=u(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var a=u(e,r);if(!1===a)return!1;var f=e.slice(r.place,a+r.place);if(r.place+=a,2!==e[r.place++])return!1;var c=u(e,r);if(!1===c)return!1;if(e.length!==c+r.place)return!1;var l=e.slice(r.place,c+r.place);if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new n(f),this.s=new n(l),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=f(t),r=f(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,r){"use strict";var n=r(99),i=r(98),o=r(28),a=o.assert,s=o.parseBytes,u=r(321),f=r(322);function c(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);e=i[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=c,c.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},c.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},c.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=t)throw new Error("invalid sig")}e.exports=function(e,t,r,u,f){var c=o(r);if("ec"===c.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,c)}if("dsa"===c.type){if("dsa"!==u)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,f=r.data.pub_key,c=o.signature.decode(e,"der"),l=c.s,h=c.r;s(l,a),s(h,a);var d=n.mont(i),p=l.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(f.toRed(d).redPow(h.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(h)}(e,t,c)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");t=Buffer.concat([f,t]);for(var l=c.modulus.byteLength(),h=[1],d=0;t.length+h.length+2r-l-2)throw new Error("message too long");var h=Buffer.alloc(r-n-l-2),d=r-c-1,p=i(c),y=s(Buffer.concat([f,h,Buffer.alloc(1,1),t],d),a(p,d)),g=s(p,a(y,c));return new u(Buffer.concat([Buffer.alloc(1),g,y],r))}(d,t);else if(1===l)h=function(e,t,r){var n,o=t.length,a=e.modulus.byteLength();if(o>a-11)throw new Error("message too long");n=r?Buffer.alloc(a-o-3,255):function(e){var t,r=Buffer.allocUnsafe(e),n=0,o=i(2*e),a=0;for(;n=0)throw new Error("data too long for modulus")}return r?c(h,d):f(h,d)}},function(e,t,r){var n=r(69),i=r(179),o=r(180),a=r(18),s=r(97),u=r(35),f=r(181),Buffer=r(7).Buffer;e.exports=function(e,t,r){var c;c=e.padding?e.padding:r?1:4;var l,h=n(e),d=h.modulus.byteLength();if(t.length>d||new a(t).cmp(h.modulus)>=0)throw new Error("decryption error");l=r?f(new a(t),h):s(t,h);var p=Buffer.alloc(d-l.length);if(l=Buffer.concat([p,l],d),4===c)return function(e,t){var r=e.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),a=n.length;if(0!==t[0])throw new Error("decryption error");var s=t.slice(1,a+1),f=t.slice(a+1),c=o(s,i(f,a)),l=o(f,i(c,r-a-1));if(function(e,t){e=Buffer.from(e),t=Buffer.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var a=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,r);if(3===c)return l;throw new Error("unknown padding")}},function(e,t,r){"use strict";(function(e,n){function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=r(7),a=r(34),Buffer=o.Buffer,s=o.kMaxLength,u=e.crypto||e.msCrypto,f=Math.pow(2,32)-1;function c(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>s||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>s)throw new RangeError("buffer too small")}function h(e,t,r,i){if(n.browser){var o=e.buffer,s=new Uint8Array(o,t,r);return u.getRandomValues(s),i?void n.nextTick((function(){i(null,e)})):e}if(!i)return a(r).copy(e,t),e;a(r,(function(r,n){if(r)return i(r);n.copy(e,t),i(null,e)}))}u&&u.getRandomValues||!n.browser?(t.randomFill=function(t,r,n,i){if(!(Buffer.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof r)i=r,r=0,n=t.length;else if("function"==typeof n)i=n,n=t.length-r;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return c(r,t.length),l(n,r,t.length),h(t,r,n,i)},t.randomFillSync=function(t,r,n){void 0===r&&(r=0);if(!(Buffer.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');c(r,t.length),void 0===n&&(n=t.length-r);return l(n,r,t.length),h(t,r,n)}):(t.randomFill=i,t.randomFillSync=i)}).call(this,r(24),r(16))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseReleases=t.parseFeatures=void 0;var n=r(182);t.parseFeatures=function(e){if(2===e.major_version&&!1===e.firmware_present)return e;if(2===e.major_version&&null==e.bootloader_mode)return e;if(2===e.major_version&&!0===e.bootloader_mode)return e;if(1===e.major_version&&!1===e.firmware_present)return e;if(1===e.major_version&&null===e.bootloader_mode)return e;if(1===e.major_version&&!0===e.bootloader_mode)return e;throw new Error("Features of unexpected shape provided to rollout")};var i=n.Tuple(n.Literal(2),n.Number,n.Number),o=n.Tuple(n.Literal(1),n.Number,n.Number),a=n.Record({required:n.Boolean,url:n.String,fingerprint:n.String,changelog:n.String,min_bridge_version:n.Tuple(n.Number,n.Number,n.Number),version:n.Union(o,i),min_firmware_version:n.Union(o,i),min_bootloader_version:n.Union(o,i)}).And(n.Partial({bootloader_version:n.Union(o,i),url_bitcoinonly:n.String,fingerprint_bitcoinonly:n.String,notes:n.String,rollout:n.Number,channel:n.String}));t.parseReleases=function(e){try{return e.forEach((function(e){a.check(e)})),e}catch(e){throw new Error("Release object in unexpected shape: "+e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(57);t.Contract=function(){for(var e=[],t=0;ta.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");i.value=function(){for(var t=[],r=0;r=0&&S.splice(t,1)}i.emit(y.CORE_EVENT,e)},O=function(e){return void 0===e&&(e=!0),e&&I((0,g.UiMessage)(y.UI.REQUEST_UI_WINDOW)),a||(a=(0,b.create)()),a},P=function(){return u.start((function(){H("Interaction timeout")}))},M=function(e,t){var r=(0,b.create)(e,t);return E.push(r),P(),r},k=function(e,t){return E.find((function(e){return e.id===t}))},T=function(e){E=E.filter((function(t){return t!==e}))},x=function(e,t){void 0===t&&(t=!1),A.log("handle message in core",t,e);var r=[y.IFRAME.CALL,y.POPUP.CLOSED,y.UI.CUSTOM_MESSAGE_RESPONSE,y.UI.LOGIN_CHALLENGE_RESPONSE,y.TRANSPORT.DISABLE_WEBUSB];if(t||-1!==r.indexOf(e.type))switch(e.type){case y.POPUP.HANDSHAKE:O(!1).resolve();break;case y.POPUP.CLOSED:H(e.payload?e.payload.error:null);break;case y.TRANSPORT.DISABLE_WEBUSB:Y();break;case y.UI.RECEIVE_DEVICE:case y.UI.RECEIVE_CONFIRMATION:case y.UI.RECEIVE_PERMISSION:case y.UI.RECEIVE_PIN:case y.UI.RECEIVE_PASSPHRASE:case y.UI.INVALID_PASSPHRASE_ACTION:case y.UI.RECEIVE_ACCOUNT:case y.UI.CHANGE_ACCOUNT:case y.UI.RECEIVE_FEE:case y.UI.CUSTOM_MESSAGE_RESPONSE:case y.UI.RECEIVE_WORD:case y.UI.LOGIN_CHALLENGE_RESPONSE:var n=k(0,e.type);n&&(n.resolve({event:e.type,payload:e.payload}),T(n));break;case y.IFRAME.CALL:C(e).catch((function(e){A.debug("onCall error",e)}))}};t.handleMessage=x;var R=function(){var e=(0,l.default)(c.default.mark((function e(t){var r,n,i,a,u;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}throw y.ERRORS.TypedError("Transport_Missing");case 2:if(r="WebUsbPlugin"===o.transportType(),!t.devicePath){e.next=7;break}n=o.getDevice(t.devicePath),e.next=31;break;case 7:if(1!==o.length()||r){e.next=13;break}i=o.getFirstDevicePath(),n=o.getDevice(i),e.next=31;break;case 13:return M(y.UI.RECEIVE_DEVICE),e.next=16,O().promise;case 16:if(1!==o.length()||r){e.next=22;break}i=o.getFirstDevicePath(),n=o.getDevice(i),e.next=31;break;case 22:if(I((0,g.UiMessage)(y.UI.SELECT_DEVICE,{webusb:r,devices:o.asArray()})),!(a=k(t.responseID,y.UI.RECEIVE_DEVICE))){e.next=31;break}return e.next=27,a.promise;case 27:(u=e.sent).payload.remember&&(u.payload.device.state||delete u.payload.device.state,s=u.payload.device),i=u.payload.device.path,n=o.getDevice(i);case 31:if(n){e.next=33;break}throw y.ERRORS.TypedError("Device_NotFound");case 33:return e.abrupt("return",n);case 34:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),C=function(){var e=(0,l.default)(c.default.mark((function e(t){var r,n,i,a,u,f,h,p,b,v,w,_,E;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.id&&t.payload){e.next=2;break}throw y.ERRORS.TypedError("Method_InvalidParameter","onCall: message.id or message.payload is missing");case 2:r=t.id,n=d.default.getSettings("trustedHost"),i=d.default.getSettings("popup"),s&&!t.payload.device&&(t.payload.device=s),e.prev=6,(a=(0,m.find)(t)).postMessage=I,a.getPopupPromise=O,a.createUiPromise=M,a.findUiPromise=k,a.removeUiPromise=T,e.next=20;break;case 15:return e.prev=15,e.t0=e.catch(6),I((0,g.UiMessage)(y.POPUP.CANCEL_POPUP_REQUEST)),I((0,g.ResponseMessage)(r,!1,{error:e.t0})),e.abrupt("return",Promise.resolve());case 20:if(S.push(a),a.useDevice){e.next=40;break}if(e.prev=22,!a.useUi){e.next=28;break}return e.next=26,O().promise;case 26:e.next=29;break;case 28:I((0,g.UiMessage)(y.POPUP.CANCEL_POPUP_REQUEST));case 29:return e.next=31,a.run();case 31:f=e.sent,u=(0,g.ResponseMessage)(a.responseID,!0,f),e.next=38;break;case 35:e.prev=35,e.t1=e.catch(22),u=(0,g.ResponseMessage)(a.responseID,!1,{error:e.t1});case 38:return I(u),e.abrupt("return",Promise.resolve());case 40:if(o||d.default.getSettings("transportReconnect")){e.next=43;break}return e.next=43,W(d.default.getSettings());case 43:if(!i||!a.requiredPermissions.includes("management")||d.default.isManagementAllowed()){e.next=47;break}return I((0,g.UiMessage)(y.POPUP.CANCEL_POPUP_REQUEST)),I((0,g.ResponseMessage)(r,!1,{error:y.ERRORS.TypedError("Method_NotAllowed")})),e.abrupt("return",Promise.resolve());case 47:return e.prev=47,e.next=50,R(a);case 50:h=e.sent,e.next=64;break;case 53:if(e.prev=53,e.t2=e.catch(47),"Transport_Missing"!==e.t2.code){e.next=61;break}return e.next=58,O().promise;case 58:I((0,g.UiMessage)(y.UI.TRANSPORT)),e.next=62;break;case 61:I((0,g.UiMessage)(y.POPUP.CANCEL_POPUP_REQUEST));case 62:throw I((0,g.ResponseMessage)(r,!1,{error:e.t2})),e.t2;case 64:if(a.setDevice(h),!a.debugLink){e.next=79;break}return e.prev=66,e.next=69,a.run();case 69:return p=e.sent,u=(0,g.ResponseMessage)(a.responseID,!0,p),I(u),e.abrupt("return",Promise.resolve());case 75:throw e.prev=75,e.t3=e.catch(66),I((0,g.ResponseMessage)(a.responseID,!1,{error:e.t3})),e.t3;case 79:if(!((b=S.filter((function(e){return e&&e!==a&&e.devicePath===a.devicePath}))).length>0&&a.overridePreviousCall)){e.next=90;break}return b.forEach((function(e){e.overridden=!0})),v=y.ERRORS.TypedError("Method_Override"),e.next=85,h.override(v);case 85:if(!a.overridden){e.next=88;break}throw I((0,g.ResponseMessage)(a.responseID,!1,{error:v})),v;case 88:e.next=98;break;case 90:if(!h.isRunning()){e.next=98;break}if(h.isLoaded()){e.next=96;break}return e.next=94,h.waitForFirstRun();case 94:e.next=98;break;case 96:throw I((0,g.ResponseMessage)(r,!1,{error:y.ERRORS.TypedError("Device_CallInProgress")})),y.ERRORS.TypedError("Device_CallInProgress");case 98:if(h.setInstance(a.deviceInstance),a.hasExpectedDeviceState&&h.setExternalState(a.deviceState),h.on(y.DEVICE.BUTTON,(function(e,t){D(e,t,a)})),h.on(y.DEVICE.PIN,U),h.on(y.DEVICE.WORD,j),h.on(y.DEVICE.PASSPHRASE,a.useEmptyPassphrase?F:L),h.on(y.DEVICE.PASSPHRASE_ON_DEVICE,(function(){I((0,g.UiMessage)(y.UI.REQUEST_PASSPHRASE_ON_DEVICE,{device:h.toMessageObject()}))})),!o){e.next=108;break}return e.next=108,o.reconfigure(h.getVersion());case 108:return e.prev=108,w=1,3,_=function(){var e=(0,l.default)(c.default.mark((function e(){var t,r,s,f,l,d,p,m;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.checkFirmwareRange(i);case 2:if(!(t=e.sent)){e.next=14;break}if(!i){e.next=13;break}return e.next=7,O().promise;case 7:return I((0,g.UiMessage)(t,h.toMessageObject())),e.next=10,M(y.DEVICE.DISCONNECT,h).promise;case 10:return e.abrupt("return",Promise.reject(y.ERRORS.TypedError("Method_Cancel")));case 13:return e.abrupt("return",Promise.reject(y.ERRORS.TypedError("Device_FwException",t)));case 14:if(!(r=h.hasUnexpectedMode(a.allowDeviceMode,a.requireDeviceMode))){e.next=27;break}if(h.keepSession=!1,!i){e.next=26;break}return e.next=20,O().promise;case 20:return I((0,g.UiMessage)(r,h.toMessageObject())),e.next=23,M(y.DEVICE.DISCONNECT,h).promise;case 23:case 26:return e.abrupt("return",Promise.reject(y.ERRORS.TypedError("Device_ModeException",r)));case 27:if(a.checkPermissions(),n||!(a.requiredPermissions.length>0)){e.next=34;break}return e.next=31,a.requestPermissions();case 31:if(e.sent){e.next=34;break}return e.abrupt("return",Promise.reject(y.ERRORS.TypedError("Method_PermissionsNotGranted")));case 34:if(!(s=h.features.needs_backup)||"function"!=typeof a.noBackupConfirmation){e.next=41;break}return e.next=38,a.noBackupConfirmation();case 38:if(e.sent){e.next=41;break}return e.abrupt("return",Promise.reject(y.ERRORS.TypedError("Method_PermissionsNotGranted")));case 41:if(!s){e.next=45;break}return e.next=44,O().promise;case 44:I((0,g.UiMessage)(y.UI.DEVICE_NEEDS_BACKUP,h.toMessageObject()));case 45:if("outdated"!==h.firmwareStatus){e.next=49;break}return e.next=48,O().promise;case 48:I((0,g.UiMessage)(y.UI.FIRMWARE_OUTDATED,h.toMessageObject()));case 49:if(n||"function"!=typeof a.confirmation){e.next=55;break}return e.next=52,a.confirmation();case 52:if(e.sent){e.next=55;break}return e.abrupt("return",Promise.reject(y.ERRORS.TypedError("Method_Cancel")));case 55:if(!o){e.next=58;break}return e.next=58,o.reconfigure(h.getVersion());case 58:if(e.prev=58,!a.useDeviceState){e.next=65;break}return e.next=62,h.validateState(a.network);case 62:e.t0=e.sent,e.next=66;break;case 65:e.t0=void 0;case 66:if(!(f=e.t0)){e.next=86;break}if(!i){e.next=85;break}return l=M(y.UI.INVALID_PASSPHRASE_ACTION,h),I((0,g.UiMessage)(y.UI.INVALID_PASSPHRASE,{device:h.toMessageObject()})),e.next=73,l.promise;case 73:if(d=e.sent,!d.payload){e.next=82;break}return h.setInternalState(void 0),e.next=79,h.initialize(a.useEmptyPassphrase);case 79:return e.abrupt("return",_());case 82:h.setExternalState(f);case 83:e.next=86;break;case 85:throw y.ERRORS.TypedError("Device_InvalidState");case 86:e.next=98;break;case 88:if(e.prev=88,e.t1=e.catch(58),!(e.t1.message===y.ERRORS.INVALID_PIN_ERROR_MESSAGE&&w<3)){e.next=96;break}return w++,I((0,g.UiMessage)(y.UI.INVALID_PIN,{device:h.toMessageObject()})),e.abrupt("return",_());case 96:return h.setInternalState(void 0),e.abrupt("return",Promise.reject(e.t1));case 98:if(!a.useUi){e.next=103;break}return e.next=101,O().promise;case 101:e.next=104;break;case 103:I((0,g.UiMessage)(y.POPUP.CANCEL_POPUP_REQUEST));case 104:if(e.prev=104,p=a.getCustomMessages(),!o||!p){e.next=109;break}return e.next=109,o.reconfigure(p,!0);case 109:return e.next=111,a.run();case 111:m=e.sent,u=(0,g.ResponseMessage)(a.responseID,!0,m),e.next=118;break;case 115:return e.prev=115,e.t2=e.catch(104),e.abrupt("return",Promise.reject(e.t2));case 118:case"end":return e.stop()}}),e,null,[[58,88],[104,115]])})));return function(){return e.apply(this,arguments)}}(),e.next=114,h.run(_,{keepSession:a.keepSession,useEmptyPassphrase:a.useEmptyPassphrase,skipFinalReload:a.skipFinalReload});case 114:e.next=120;break;case 116:e.prev=116,e.t4=e.catch(108),o&&"Device_Disconnected"===e.t4.code&&o.addAuthPenalty(h),a&&(o&&e.t4.message===y.ERRORS.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE&&o.enumerate(),u=(0,g.ResponseMessage)(a.responseID,!1,{error:e.t4}));case 120:if(e.prev=120,A.log("onCall::finally",u),!(E=u)){e.next=134;break}return e.next=126,h.cleanup();case 126:if(B(),N(),a&&a.dispose(),!o){e.next=133;break}return E.success&&o.removeAuthPenalty(h),e.next=133,o.restoreMessages();case 133:I(E);case 134:return e.finish(120);case 135:case"end":return e.stop()}}),e,null,[[6,15],[22,35],[47,53],[66,75],[108,116,120,135]])})));return function(t){return e.apply(this,arguments)}}();t.onCall=C;var N=function(){a=null,E=[],u.stop(),A.log("Cleanup...")},B=function(){a&&I((0,g.UiMessage)(y.POPUP.CANCEL_POPUP_REQUEST)),I((0,g.UiMessage)(y.UI.CLOSE_UI_WINDOW))},D=function(){var e=(0,l.default)(c.default.mark((function e(t,r,n){var i,o;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!(i="ButtonRequest_Address"===r)||i&&n.useUi)){e.next=4;break}return e.next=4,O().promise;case 4:o="function"==typeof n.getButtonRequestData?n.getButtonRequestData(r):null,P(),I((0,g.DeviceMessage)(y.DEVICE.BUTTON,{device:t.toMessageObject(),code:r})),I((0,g.UiMessage)(y.UI.REQUEST_BUTTON,{device:t.toMessageObject(),code:r,data:o})),i&&!n.useUi&&I((0,g.UiMessage)(y.UI.ADDRESS_VALIDATION,o));case 9:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),U=function(){var e=(0,l.default)(c.default.mark((function e(t,r,n){var i,o,a;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O().promise;case 2:return i=M(y.UI.RECEIVE_PIN,t),I((0,g.UiMessage)(y.UI.REQUEST_PIN,{device:t.toMessageObject(),type:r})),e.next=6,i.promise;case 6:o=e.sent,a=o.payload,n(null,a);case 9:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),j=function(){var e=(0,l.default)(c.default.mark((function e(t,r,n){var i,o,a;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O().promise;case 2:return i=M(y.UI.RECEIVE_WORD,t),I((0,g.UiMessage)(y.UI.REQUEST_WORD,{device:t.toMessageObject(),type:r})),e.next=6,i.promise;case 6:o=e.sent,a=o.payload,n(null,a);case 9:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),L=function(){var e=(0,l.default)(c.default.mark((function e(t,r){var n,i,o,a,s;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O().promise;case 2:return n=M(y.UI.RECEIVE_PASSPHRASE,t),I((0,g.UiMessage)(y.UI.REQUEST_PASSPHRASE,{device:t.toMessageObject()})),e.next=6,n.promise;case 6:i=e.sent,o=i.payload.value,a=i.payload.passphraseOnDevice,s=i.payload.save,r({passphrase:o.normalize("NFKD"),passphraseOnDevice:a,cache:s});case 11:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),F=function(){var e=(0,l.default)(c.default.mark((function e(t,r){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r({passphrase:""});case 1:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),H=function(e){var t=e?y.ERRORS.TypedError("Method_Cancel",e):y.ERRORS.TypedError("Method_Interrupted");o&&o.asArray().length>0?(o.allDevices().forEach((function(e){if(e.keepSession=!1,e.isUsedHere())e.interruptionFromUser(t);else{var r=k(0,y.DEVICE.DISCONNECT);r?r.resolve({event:t.message,payload:null}):(S.forEach((function(e){I((0,g.ResponseMessage)(e.responseID,!1,{error:t}))})),S.splice(0,S.length))}})),N()):(E.length>0&&(E.forEach((function(e){e.reject(t)})),E=[]),a&&(a.reject(t),a=null),N())},q=function(e){void 0===e&&(e=null);var t=k(0,y.UI.RECEIVE_DEVICE);if(t&&o){var r=o.asArray(),n=o.transportType().indexOf("webusb")>=0;1!==r.length||n?I((0,g.UiMessage)(y.UI.SELECT_DEVICE,{webusb:n,devices:r})):(t.resolve({event:y.UI.RECEIVE_DEVICE,payload:{device:r[0]}}),T(t))}if(e){var i=e.path,a=!1;E.forEach((function(e){e.device&&e.device.getDevicePath()===i&&(e.id===y.DEVICE.DISCONNECT&&e.resolve({event:y.DEVICE.DISCONNECT,payload:null}),a=!0)})),s&&s.path===i&&(s=null),a&&(B(),N())}},V=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,(o=new p.default).on(y.DEVICE.CONNECT,(function(e){q(),I((0,g.DeviceMessage)(y.DEVICE.CONNECT,e))})),o.on(y.DEVICE.CONNECT_UNACQUIRED,(function(e){q(),I((0,g.DeviceMessage)(y.DEVICE.CONNECT_UNACQUIRED,e))})),o.on(y.DEVICE.DISCONNECT,(function(e){q(e),I((0,g.DeviceMessage)(y.DEVICE.DISCONNECT,e))})),o.on(y.DEVICE.CHANGED,(function(e){I((0,g.DeviceMessage)(y.DEVICE.CHANGED,e))})),o.on(y.TRANSPORT.ERROR,function(){var e=(0,l.default)(c.default.mark((function e(r){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(A.error("TRANSPORT ERROR",r),o&&(o.disconnectDevices(),o.removeAllListeners()),o=null,I((0,g.TransportMessage)(y.TRANSPORT.ERROR,{error:r})),!t.transportReconnect){e.next=9;break}return e.next=7,(0,v.resolveAfter)(1e3,null);case 7:return e.next=9,V(t);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),o.on(y.TRANSPORT.START,(function(e){return I((0,g.TransportMessage)(y.TRANSPORT.START,e))})),e.next=10,o.init();case 10:if(!o){e.next=13;break}return e.next=13,o.waitForTransportFirstEvent();case 13:e.next=27;break;case 15:if(e.prev=15,e.t0=e.catch(0),o=null,I((0,g.TransportMessage)(y.TRANSPORT.ERROR,{error:e.t0})),t.transportReconnect){e.next=23;break}throw e.t0;case 23:return e.next=25,(0,v.resolveAfter)(3e3,null);case 25:return e.next=27,V(t);case 27:case"end":return e.stop()}}),e,null,[[0,15]])})));return function(t){return e.apply(this,arguments)}}(),K=function(e){function t(){return e.call(this)||this}(0,f.default)(t,e);var r=t.prototype;return r.handleMessage=function(e,t){x(e,t)},r.onBeforeUnload=function(){o&&o.onBeforeUnload(),this.removeAllListeners()},r.getCurrentMethod=function(){return S},r.getTransportInfo=function(){return o?o.getTransportInfo():{type:"",version:"",outdated:!0}},t}(h.default);t.Core=K;var z=function(){return i=new K};t.initCore=z;var G=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d.default.load(t);case 3:e.next=9;break;case 5:throw e.prev=5,e.t0=e.catch(0),A.log("init error",e.t0),e.t0;case 9:case"end":return e.stop()}}),e,null,[[0,5]])})));return function(t){return e.apply(this,arguments)}}();t.initData=G;var Q=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,A.enabled=!!t.debug,e.next=4,d.default.load(t);case 4:return e.next=6,z();case 6:return u=new _.default(t.popup?t.interactionTimeout:0),e.abrupt("return",i);case 10:throw e.prev=10,e.t0=e.catch(0),A.log("init error",e.t0),e.t0;case 14:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t){return e.apply(this,arguments)}}();t.init=Q;var W=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t.transportReconnect){e.next=6;break}return e.next=4,V(t);case 4:e.next=7;break;case 6:V(t);case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(0),A.log("initTransport",e.t0),e.t0;case 13:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}();t.initTransport=W;var Y=function(){var e=(0,l.default)(c.default.mark((function e(){var t;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}return e.abrupt("return");case 2:if("WebUsbPlugin"===o.transportType()){e.next=4;break}return e.abrupt("return");case 4:return(t=d.default.getSettings()).webusb=!1,e.prev=6,o.onBeforeUnload(),e.next=10,V(t);case 10:e.next=14;break;case 12:e.prev=12,e.t0=e.catch(6);case 14:case"end":return e.stop()}}),e,null,[[6,12]])})));return function(){return e.apply(this,arguments)}}()},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getDeviceList=t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(25)),c=r(6),l=n(r(363)),h=n(r(58)),d=n(r(202)),p=n(r(32)),y=r(104),g=r(49),m=r(50),b=r(215);function v(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return w(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return w(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&p.default.getSettings("pendingTransportEvent")?this.emit(l.START_PENDING,n.length):this.emit(l.START)),this.listening){e.next=19;break}return e.abrupt("return");case 19:this.upcoming=n,g.debug("Listen result",n),this._reportChanges(),this.listening&&this.listen(),e.next=37;break;case 25:if(e.prev=25,e.t1=e.catch(3),i=(new Date).getTime()-this.listenTimestamp,g.debug("Listen error","timestamp",i,typeof e.t1),!(i>1100)){e.next=35;break}return e.next=32,(0,y.resolveAfter)(1e3,null);case 32:this.listening&&this.listen(),e.next=37;break;case 35:g.log("Transport error"),this.emit(l.ERROR,e.t1);case 37:case"end":return e.stop()}}),e,this,[[3,25]])})));return function(){return e.apply(this,arguments)}}(),r.enumerate=function(){var e=(0,a.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.listening){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.transport.enumerate();case 5:this.upcoming=e.sent,this._reportChanges(),e.next=11;break;case 9:e.prev=9,e.t0=e.catch(2);case 11:case"end":return e.stop()}}),e,this,[[2,9]])})));return function(){return e.apply(this,arguments)}}(),r.stop=function(){this.listening=!1},r._diff=function(e,t){var r=e||[],n=t.filter((function(e){return void 0===r.find((function(t){return t.path===e.path}))})),i=r.filter((function(e){return void 0===t.find((function(t){return t.path===e.path}))})),o=t.filter((function(e){var t=r.find((function(t){return t.path===e.path}));return!!t&&t.session!==e.session})),a=o.filter((function(e){return"string"==typeof e.session})),s=o.filter((function(e){return"string"!=typeof e.session})),u=t.filter((function(e){var t=r.find((function(t){return t.path===e.path}));return!!t&&t.debugSession!==e.debugSession})),f=o.filter((function(e){return"string"==typeof e.debugSession})),c=o.filter((function(e){return"string"!=typeof e.debugSession}));return{connected:n,disconnected:i,changedSessions:o,acquired:a,released:s,changedDebugSessions:u,debugAcquired:f,debugReleased:c,didUpdate:n.length+i.length+o.length+u.length>0,descriptors:t}},r._reportChanges=function(){var e=this,t=this._diff(this.current,this.upcoming);this.current=this.upcoming,t.didUpdate&&this.listening&&(t.connected.forEach((function(t){e.emit(h.CONNECT,t)})),t.disconnected.forEach((function(t){e.emit(h.DISCONNECT,t)})),t.acquired.forEach((function(t){e.emit(h.ACQUIRED,t)})),t.released.forEach((function(t){e.emit(h.RELEASED,t)})),t.changedSessions.forEach((function(t){e.emit(h.CHANGED,t)})),this.emit(l.UPDATE,t))},t}(c.default);t.default=m},function(e,t,r){(function(Buffer){var t=r(106),n=r(188);function i(e){return Buffer.isBuffer(e)}function o(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function a(e,t){var r=e.toJSON();function i(i){if(!e(i))return!1;if(i.length===t)return!0;throw n.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+i.length+")")}return i.toJSON=function(){return r},i}var s=a.bind(null,t.Array),u=a.bind(null,i),f=a.bind(null,o),c=a.bind(null,t.String);var l=Math.pow(2,53)-1;var h={ArrayN:s,Buffer:i,BufferN:u,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:o,HexN:f,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-l&&e<=l&&Math.floor(e)===e},Range:function(e,r,n){function i(t,i){return n(t,i)&&t>e&&t>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=l&&Math.floor(e)===e}};for(var d in h)h[d].toJSON=function(e){return e}.bind(null,d);e.exports=h}).call(this,r(9).Buffer)},function(e,t,r){var n=r(26),i={};for(var o in n){i[n[o]]=o}e.exports=i},function(e,t,r){var Buffer=r(7).Buffer,n=r(19),i=r(190),o=r(15),a=r(26);function s(e){return e===a.OP_0||n.isCanonicalSignature(e)}function u(e,t){var r=n.decompile(e);return!(r.length<2)&&(r[0]===a.OP_0&&(t?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}u.toJSON=function(){return"multisig input"};var f=Buffer.allocUnsafe(0);function c(e,t){if(o([s],e),t){var r=i.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(f,e.map((function(e){return e===a.OP_0?f:e})))}function l(e,t){return o(u,e,t),e.slice(1)}e.exports={check:u,decode:function(e,t){return l(n.decompile(e),t)},decodeStack:l,encode:function(e,t){return n.compile(c(e,t))},encodeStack:c}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26);function s(e){var t=n.compile(e);return t.length>1&&t[0]===a.OP_RETURN}s.toJSON=function(){return"null data output"},e.exports={output:{check:s,decode:function(e){o(s,e);var t=n.decompile(e);return t.shift(),1===t.length?t[0]:t},encode:function(e){return o(o.oneOf(i.Buffer,i.Array),e),n.compile([a.OP_RETURN].concat(e))}}}},function(e,t,r){var n=r(19),i=r(15);function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function a(e){return i(n.isCanonicalSignature,e),[e]}function s(e){return i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(e){return s(n.decompile(e))},decodeStack:s,encode:function(e){return n.compile(a(e))},encodeStack:a}},function(e,t,r){var n=r(19),i=r(15),o=r(26);function a(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}a.toJSON=function(){return"pubKey output"},e.exports={check:a,decode:function(e){var t=n.decompile(e);return i(a,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},function(e,t,r){var n=r(19),i=r(15);function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function a(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function s(e){return i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(e){return s(n.decompile(e))},decodeStack:s,encode:function(e,t){return n.compile(a(e,t))},encodeStack:a}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26);function s(e){var t=n.compile(e);return 25===t.length&&t[0]===a.OP_DUP&&t[1]===a.OP_HASH160&&20===t[2]&&t[23]===a.OP_EQUALVERIFY&&t[24]===a.OP_CHECKSIG}s.toJSON=function(){return"pubKeyHash output"},e.exports={check:s,decode:function(e){return o(s,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([a.OP_DUP,a.OP_HASH160,e,a.OP_EQUALVERIFY,a.OP_CHECKSIG])}}},function(e,t,r){e.exports={input:r(373),output:r(374)}},function(e,t,r){var Buffer=r(7).Buffer,n=r(19),i=r(15),o=r(108),a=r(109),s=r(110),u=r(191),f=r(192);function c(e,t){var r=n.decompile(e);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var c=n.decompile(n.compile(r.slice(0,-1))),l=n.decompile(i);return 0!==l.length&&(!!n.isPushOnly(c)&&(1===r.length?f.check(l)||u.check(l):!(!s.input.check(c)||!s.output.check(l))||(!(!o.input.check(c,t)||!o.output.check(l))||!(!a.input.check(c)||!a.output.check(l)))))}function l(e,t){var r=n.compile(t);return[].concat(e,r)}function h(e){return i(c,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}c.toJSON=function(){return"scriptHash input"},e.exports={check:c,decode:function(e){var t=h(n.decompile(e));return t.redeemScriptSig=n.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:h,encode:function(e,t){var r=n.decompile(e);return n.compile(l(r,t))},encodeStack:l}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26);function s(e){var t=n.compile(e);return 23===t.length&&t[0]===a.OP_HASH160&&20===t[1]&&t[22]===a.OP_EQUAL}s.toJSON=function(){return"scriptHash output"},e.exports={check:s,decode:function(e){return o(s,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([a.OP_HASH160,e,a.OP_EQUAL])}}},function(e,t,r){e.exports={input:r(376),output:r(191)}},function(e,t,r){var n=r(19),i=r(15);function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function a(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}a.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:a,decodeStack:function(e){return i(a,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},function(e,t,r){e.exports={input:r(378),output:r(192)}},function(e,t,r){(function(Buffer){var t=r(19),n=r(22),i=r(15),o=r(108),a=r(109),s=r(110);function u(e,r){if(i(n.Array,e),e.length<1)return!1;var u=e[e.length-1];if(!Buffer.isBuffer(u))return!1;var f=t.decompile(u);if(0===f.length)return!1;var c=t.compile(e.slice(0,-1));return!(!s.input.check(c)||!s.output.check(f))||(!(!o.input.check(c,r)||!o.output.check(f))||!(!a.input.check(c)||!a.output.check(f)))}u.toJSON=function(){return"witnessScriptHash input"},e.exports={check:u,decodeStack:function(e){return i(u,e),{witnessData:e.slice(0,-1),witnessScript:e[e.length-1]}},encodeStack:function(e,t){return i({witnessData:[n.Buffer],witnessScript:n.Buffer},{witnessData:e,witnessScript:t}),[].concat(e,t)}}}).call(this,r(9).Buffer)},function(e,t,r){e.exports={output:r(380)}},function(e,t,r){var Buffer=r(7).Buffer,n=r(19),i=r(22),o=r(15),a=r(26),s=Buffer.from("aa21a9ed","hex");function u(e){var t=n.compile(e);return t.length>37&&t[0]===a.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(s)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(e){return o(u,e),n.decompile(e)[1].slice(4,36)},encode:function(e){o(i.Hash256bit,e);var t=Buffer.allocUnsafe(36);return s.copy(t,0),e.copy(t,4),n.compile([a.OP_RETURN,t])}}},function(e){e.exports=JSON.parse('{"name":"bigi","version":"1.4.2","description":"Big integers.","keywords":["cryptography","math","bitcoin","arbitrary","precision","arithmetic","big","integer","int","number","biginteger","bigint","bignumber","decimal","float"],"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.5","jshint":"^2.5.1","mocha":"^2.1.0","mochify":"^2.1.0"},"repository":{"url":"https://github.com/cryptocoinjs/bigi","type":"git"},"main":"./lib/index.js","scripts":{"browser-test":"./node_modules/.bin/mochify --wd -R spec","test":"./node_modules/.bin/_mocha -- test/*.js","jshint":"./node_modules/.bin/jshint --config jshint.json lib/*.js ; true","unit":"./node_modules/.bin/mocha","coverage":"./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js","coveralls":"npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info"},"dependencies":{},"testling":{"files":"test/*.js","harness":"mocha","browsers":["ie/9..latest","firefox/latest","chrome/latest","safari/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]}}')},function(e,t,r){(function(Buffer){var e=r(112),BigInteger=r(193);BigInteger.fromByteArrayUnsigned=function(e){return 128&e[0]?new BigInteger([0].concat(e)):new BigInteger(e)},BigInteger.prototype.toByteArrayUnsigned=function(){var e=this.toByteArray();return 0===e[0]?e.slice(1):e},BigInteger.fromDERInteger=function(e){return new BigInteger(e)},BigInteger.prototype.toDERInteger=BigInteger.prototype.toByteArray,BigInteger.fromBuffer=function(e){if(128&e[0]){var t=Array.prototype.slice.call(e);return new BigInteger([0].concat(t))}return new BigInteger(e)},BigInteger.fromHex=function(t){return""===t?BigInteger.ZERO:(e.equal(t,t.match(/^[A-Fa-f0-9]+/),"Invalid hex string"),e.equal(t.length%2,0,"Incomplete hex"),new BigInteger(t,16))},BigInteger.prototype.toBuffer=function(e){for(var t=this.toByteArrayUnsigned(),r=[],n=e-t.length;r.length>1,c=-7,l=r?i-1:0,h=r?-1:1,d=e[t+l];for(l+=h,o=d&(1<<-c)-1,d>>=-c,c+=s;c>0;o=256*o+e[t+l],l+=h,c-=8);for(a=o&(1<<-c)-1,o>>=-c,c+=n;c>0;a=256*a+e[t+l],l+=h,c-=8);if(0===o)o=1-f;else{if(o===u)return a?NaN:1/0*(d?-1:1);a+=Math.pow(2,n),o-=f}return(d?-1:1)*a*Math.pow(2,o-n)},t.write=function(e,t,r,n,i,o){var a,s,u,f=8*o-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:o-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,a=c):(a=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-a))<1&&(a--,u*=2),(t+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=c?(s=0,a=c):a+l>=1?(s=(t*u-1)*Math.pow(2,i),a+=l):(s=t*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;e[r+d]=255&s,d+=p,s/=256,i-=8);for(a=a<0;e[r+d]=255&a,d+=p,a/=256,f-=8);e[r+d-p]|=128*g}},function(e,t,r){(t=e.exports=r(132)).Stream=t,t.Readable=t,t.Writable=r(136),t.Duplex=r(44),t.Transform=r(137),t.PassThrough=r(253),t.finished=r(84),t.pipeline=r(254)},function(e,t){},function(e,t,r){"use strict";function n(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e,t){for(var r=0;r0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return Buffer.alloc(0);for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,Buffer.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=Buffer.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:s,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&a.forEach(f),o||(a.forEach(f),i(n))}))}));return t.reduce(c)}},function(e,t,r){var n=r(10),i=r(45),Buffer=r(7).Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<30|e>>>2}function f(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,c=0|this._e,l=0;l<16;++l)r[l]=e.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var d=~~(h/20),p=0|((t=n)<<5|t>>>27)+f(d,i,a,s)+c+r[h]+o[d];c=s,s=a,a=u(i),i=n,n=p}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=s},function(e,t,r){var n=r(10),i=r(45),Buffer=r(7).Buffer,o=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function s(){this.init(),this._w=a,i.call(this,64,56)}function u(e){return e<<5|e>>>27}function f(e){return e<<30|e>>>2}function c(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}n(s,i),s.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},s.prototype._update=function(e){for(var t,r=this._w,n=0|this._a,i=0|this._b,a=0|this._c,s=0|this._d,l=0|this._e,h=0;h<16;++h)r[h]=e.readInt32BE(4*h);for(;h<80;++h)r[h]=(t=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|t>>>31;for(var d=0;d<80;++d){var p=~~(d/20),g=u(n)+c(p,i,a,s)+l+r[d]+o[p]|0;l=s,s=a,a=f(i),i=n,n=g}this._a=n+this._a|0,this._b=i+this._b|0,this._c=a+this._c|0,this._d=s+this._d|0,this._e=l+this._e|0},s.prototype._hash=function(){var e=Buffer.allocUnsafe(20);return e.writeInt32BE(0|this._a,0),e.writeInt32BE(0|this._b,4),e.writeInt32BE(0|this._c,8),e.writeInt32BE(0|this._d,12),e.writeInt32BE(0|this._e,16),e},e.exports=s},function(e,t,r){var n=r(10),i=r(138),o=r(45),Buffer=r(7).Buffer,a=new Array(64);function s(){this.init(),this._w=a,o.call(this,64,56)}n(s,i),s.prototype.init=function(){return this._a=3238371032,this._b=914150663,this._c=812702999,this._d=4144912697,this._e=4290775857,this._f=1750603025,this._g=1694076839,this._h=3204075428,this},s.prototype._hash=function(){var e=Buffer.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e},e.exports=s},function(e,t,r){var n=r(10),i=r(139),o=r(45),Buffer=r(7).Buffer,a=new Array(160);function s(){this.init(),this._w=a,o.call(this,128,112)}n(s,i),s.prototype.init=function(){return this._ah=3418070365,this._bh=1654270250,this._ch=2438529370,this._dh=355462360,this._eh=1731405415,this._fh=2394180231,this._gh=3675008525,this._hh=1203062813,this._al=3238371032,this._bl=914150663,this._cl=812702999,this._dl=4144912697,this._el=4290775857,this._fl=1750603025,this._gl=1694076839,this._hl=3204075428,this},s.prototype._hash=function(){var e=Buffer.allocUnsafe(48);function t(t,r,n){e.writeInt32BE(t,n),e.writeInt32BE(r,n+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e},e.exports=s},function(e,t){},function(e,t,r){"use strict";var Buffer=r(89).Buffer,n=r(261);e.exports=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.head=null,this.tail=null,this.length=0}return e.prototype.push=function(e){var t={data:e,next:null};this.length>0?this.tail.next=t:this.head=t,this.tail=t,++this.length},e.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},e.prototype.shift=function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}},e.prototype.clear=function(){this.head=this.tail=null,this.length=0},e.prototype.join=function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r},e.prototype.concat=function(e){if(0===this.length)return Buffer.alloc(0);if(1===this.length)return this.head.data;for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,t.copy(r,n),a+=o.data.length,o=o.next;return i},e}(),n&&n.inspect&&n.inspect.custom&&(e.exports.prototype[n.inspect.custom]=function(){var e=n.inspect({length:this.length});return this.constructor.name+" "+e})},function(e,t){},function(e,t,r){(function(e){var n=void 0!==e&&e||"undefined"!=typeof self&&self||window,i=Function.prototype.apply;function o(e,t){this._id=e,this._clearFn=t}t.setTimeout=function(){return new o(i.call(setTimeout,n,arguments),clearTimeout)},t.setInterval=function(){return new o(i.call(setInterval,n,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e&&e.close()},o.prototype.unref=o.prototype.ref=function(){},o.prototype.close=function(){this._clearFn.call(n,this._id)},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout((function(){e._onTimeout&&e._onTimeout()}),t))},r(263),t.setImmediate="undefined"!=typeof self&&self.setImmediate||void 0!==e&&e.setImmediate||this&&this.setImmediate,t.clearImmediate="undefined"!=typeof self&&self.clearImmediate||void 0!==e&&e.clearImmediate||this&&this.clearImmediate}).call(this,r(24))},function(e,t,r){(function(e,t){!function(e,r){"use strict";if(!e.setImmediate){var n,i,o,a,s,u=1,f={},c=!1,l=e.document,h=Object.getPrototypeOf&&Object.getPrototypeOf(e);h=h&&h.setTimeout?h:e,"[object process]"==={}.toString.call(e.process)?n=function(e){t.nextTick((function(){p(e)}))}:!function(){if(e.postMessage&&!e.importScripts){var t=!0,r=e.onmessage;return e.onmessage=function(){t=!1},e.postMessage("","*"),e.onmessage=r,t}}()?e.MessageChannel?((o=new MessageChannel).port1.onmessage=function(e){p(e.data)},n=function(e){o.port2.postMessage(e)}):l&&"onreadystatechange"in l.createElement("script")?(i=l.documentElement,n=function(e){var t=l.createElement("script");t.onreadystatechange=function(){p(e),t.onreadystatechange=null,i.removeChild(t),t=null},i.appendChild(t)}):n=function(e){setTimeout(p,0,e)}:(a="setImmediate$"+Math.random()+"$",s=function(t){t.source===e&&"string"==typeof t.data&&0===t.data.indexOf(a)&&p(+t.data.slice(a.length))},e.addEventListener?e.addEventListener("message",s,!1):e.attachEvent("onmessage",s),n=function(t){e.postMessage(a+t,"*")}),h.setImmediate=function(e){"function"!=typeof e&&(e=new Function(""+e));for(var t=new Array(arguments.length-1),r=0;r64?t=e(t):t.length<64&&(t=Buffer.concat([t,o],64));for(var r=this._ipad=Buffer.allocUnsafe(64),n=this._opad=Buffer.allocUnsafe(64),a=0;a<64;a++)r[a]=54^t[a],n[a]=92^t[a];this._hash=[r]}n(a,i),a.prototype._update=function(e){this._hash.push(e)},a.prototype._final=function(){var e=this._alg(Buffer.concat(this._hash));return this._alg(Buffer.concat([this._opad,e]))},e.exports=a},function(e,t,r){e.exports=r(145)},function(e,t,r){(function(t,n){var i,Buffer=r(7).Buffer,o=r(147),a=r(148),s=r(149),u=r(150),f=t.crypto&&t.crypto.subtle,c={sha:"SHA-1","sha-1":"SHA-1",sha1:"SHA-1",sha256:"SHA-256","sha-256":"SHA-256",sha384:"SHA-384","sha-384":"SHA-384","sha-512":"SHA-512",sha512:"SHA-512"},l=[];function h(e,t,r,n,i){return f.importKey("raw",e,{name:"PBKDF2"},!1,["deriveBits"]).then((function(e){return f.deriveBits({name:"PBKDF2",salt:t,iterations:r,hash:{name:i}},e,n<<3)})).then((function(e){return Buffer.from(e)}))}e.exports=function(e,r,d,p,g,y){"function"==typeof g&&(y=g,g=void 0);var m=c[(g=g||"sha1").toLowerCase()];if(!m||"function"!=typeof t.Promise)return n.nextTick((function(){var t;try{t=s(e,r,d,p,g)}catch(e){return y(e)}y(null,t)}));if(o(d,p),e=u(e,a,"Password"),r=u(r,a,"Salt"),"function"!=typeof y)throw new Error("No callback provided to pbkdf2");!function(e,t){e.then((function(e){n.nextTick((function(){t(null,e)}))}),(function(e){n.nextTick((function(){t(e)}))}))}(function(e){if(t.process&&!t.process.browser)return Promise.resolve(!1);if(!f||!f.importKey||!f.deriveBits)return Promise.resolve(!1);if(void 0!==l[e])return l[e];var r=h(i=i||Buffer.alloc(8),i,10,128,e).then((function(){return!0})).catch((function(){return!1}));return l[e]=r,r}(m).then((function(t){return t?h(e,r,d,p,m):s(e,r,d,p,g)})),y)}}).call(this,r(24),r(16))},function(e,t,r){var n=r(273),i=r(92),o=r(93),a=r(286),s=r(64);function u(e,t,r){if(e=e.toLowerCase(),o[e])return i.createCipheriv(e,t,r);if(a[e])return new n({key:t,iv:r,mode:e});throw new TypeError("invalid suite type")}function f(e,t,r){if(e=e.toLowerCase(),o[e])return i.createDecipheriv(e,t,r);if(a[e])return new n({key:t,iv:r,mode:e,decrypt:!0});throw new TypeError("invalid suite type")}t.createCipher=t.Cipher=function(e,t){var r,n;if(e=e.toLowerCase(),o[e])r=o[e].key,n=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");r=8*a[e].key,n=a[e].iv}var i=s(t,!1,r,n);return u(e,i.key,i.iv)},t.createCipheriv=t.Cipheriv=u,t.createDecipher=t.Decipher=function(e,t){var r,n;if(e=e.toLowerCase(),o[e])r=o[e].key,n=o[e].iv;else{if(!a[e])throw new TypeError("invalid suite type");r=8*a[e].key,n=a[e].iv}var i=s(t,!1,r,n);return f(e,i.key,i.iv)},t.createDecipheriv=t.Decipheriv=f,t.listCiphers=t.getCiphers=function(){return Object.keys(a).concat(i.getCiphers())}},function(e,t,r){var n=r(36),i=r(274),o=r(10),Buffer=r(7).Buffer,a={"des-ede3-cbc":i.CBC.instantiate(i.EDE),"des-ede3":i.EDE,"des-ede-cbc":i.CBC.instantiate(i.EDE),"des-ede":i.EDE,"des-cbc":i.CBC.instantiate(i.DES),"des-ecb":i.DES};function s(e){n.call(this);var t,r=e.mode.toLowerCase(),i=a[r];t=e.decrypt?"decrypt":"encrypt";var o=e.key;Buffer.isBuffer(o)||(o=Buffer.from(o)),"des-ede"!==r&&"des-ede-cbc"!==r||(o=Buffer.concat([o,o.slice(0,8)]));var s=e.iv;Buffer.isBuffer(s)||(s=Buffer.from(s)),this._des=i.create({key:o,iv:s,type:t})}a.des=a["des-cbc"],a.des3=a["des-ede3-cbc"],e.exports=s,o(s,n),s.prototype._update=function(e){return Buffer.from(this._des.update(e))},s.prototype._final=function(){return Buffer.from(this._des.final())}},function(e,t,r){"use strict";t.utils=r(151),t.Cipher=r(91),t.DES=r(152),t.CBC=r(275),t.EDE=r(276)},function(e,t,r){"use strict";var n=r(27),i=r(10),o={};function a(e){n.equal(e.length,8,"Invalid IV length"),this.iv=new Array(8);for(var t=0;t15){var e=this.cache.slice(0,16);return this.cache=this.cache.slice(16),e}return null},l.prototype.flush=function(){for(var e=16-this.cache.length,t=Buffer.allocUnsafe(e),r=-1;++r>a%8,e._prev=i(e._prev,r?n:o);return s}function i(e,t){var r=e.length,n=-1,i=Buffer.allocUnsafe(e.length);for(e=Buffer.concat([e,Buffer.from([t])]);++n>7;return i}t.encrypt=function(e,t,r){for(var i=t.length,o=Buffer.allocUnsafe(i),a=-1;++a>>0,0),t.writeUInt32BE(e[1]>>>0,4),t.writeUInt32BE(e[2]>>>0,8),t.writeUInt32BE(e[3]>>>0,12),t}function o(e){this.h=e,this.state=Buffer.alloc(16,0),this.cache=Buffer.allocUnsafe(0)}o.prototype.ghash=function(e){for(var t=-1;++t0;t--)n[t]=n[t]>>>1|(1&n[t-1])<<31;n[0]=n[0]>>>1,r&&(n[0]=n[0]^225<<24)}this.state=i(o)},o.prototype.update=function(e){var t;for(this.cache=Buffer.concat([this.cache,e]);this.cache.length>=16;)t=this.cache.slice(0,16),this.cache=this.cache.slice(16),this.ghash(t)},o.prototype.final=function(e,t){return this.cache.length&&this.ghash(Buffer.concat([this.cache,n],16)),this.ghash(i([0,e,0,t])),this.state},e.exports=o},function(e,t,r){var n=r(156),Buffer=r(7).Buffer,i=r(93),o=r(157),a=r(36),s=r(63),u=r(64);function f(e,t,r){a.call(this),this._cache=new c,this._last=void 0,this._cipher=new s.AES(t),this._prev=Buffer.from(r),this._mode=e,this._autopadding=!0}function c(){this.cache=Buffer.allocUnsafe(0)}function l(e,t,r){var a=i[e.toLowerCase()];if(!a)throw new TypeError("invalid suite type");if("string"==typeof r&&(r=Buffer.from(r)),"GCM"!==a.mode&&r.length!==a.iv)throw new TypeError("invalid iv length "+r.length);if("string"==typeof t&&(t=Buffer.from(t)),t.length!==a.key/8)throw new TypeError("invalid key length "+t.length);return"stream"===a.type?new o(a.module,t,r,!0):"auth"===a.type?new n(a.module,t,r,!0):new f(a.module,t,r)}r(10)(f,a),f.prototype._update=function(e){var t,r;this._cache.add(e);for(var n=[];t=this._cache.get(this._autopadding);)r=this._mode.decrypt(this,t),n.push(r);return Buffer.concat(n)},f.prototype._final=function(){var e=this._cache.flush();if(this._autopadding)return function(e){var t=e[15];if(t<1||t>16)throw new Error("unable to decrypt data");var r=-1;for(;++r16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t}else if(this.cache.length>=16)return t=this.cache.slice(0,16),this.cache=this.cache.slice(16),t;return null},c.prototype.flush=function(){if(this.cache.length)return this.cache},t.createDecipher=function(e,t){var r=i[e.toLowerCase()];if(!r)throw new TypeError("invalid suite type");var n=u(t,!1,r.key,r.iv);return l(e,n.key,n.iv)},t.createDecipheriv=l},function(e,t){t["des-ecb"]={key:8,iv:0},t["des-cbc"]=t.des={key:8,iv:8},t["des-ede3-cbc"]=t.des3={key:24,iv:8},t["des-ede3"]={key:24,iv:0},t["des-ede-cbc"]={key:16,iv:8},t["des-ede"]={key:16,iv:0}},function(e,t,r){(function(Buffer){var e=r(158),n=r(290),i=r(291);var o={binary:!0,hex:!0,base64:!0};t.DiffieHellmanGroup=t.createDiffieHellmanGroup=t.getDiffieHellman=function(e){var t=new Buffer(n[e].prime,"hex"),r=new Buffer(n[e].gen,"hex");return new i(t,r)},t.createDiffieHellman=t.DiffieHellman=function t(r,n,a,s){return Buffer.isBuffer(n)||void 0===o[n]?t(r,"binary",n,a):(n=n||"binary",s=s||"binary",a=a||new Buffer([2]),Buffer.isBuffer(a)||(a=new Buffer(a,s)),"number"==typeof r?new i(e(r,a),a,!0):(Buffer.isBuffer(r)||(r=new Buffer(r,n)),new i(r,a,!0)))}}).call(this,r(9).Buffer)},function(e,t){},function(e,t){},function(e){e.exports=JSON.parse('{"modp1":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a63a3620ffffffffffffffff"},"modp2":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece65381ffffffffffffffff"},"modp5":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca237327ffffffffffffffff"},"modp14":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aacaa68ffffffffffffffff"},"modp15":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a93ad2caffffffffffffffff"},"modp16":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c934063199ffffffffffffffff"},"modp17":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dcc4024ffffffffffffffff"},"modp18":{"gen":"02","prime":"ffffffffffffffffc90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b139b22514a08798e3404ddef9519b3cd3a431b302b0a6df25f14374fe1356d6d51c245e485b576625e7ec6f44c42e9a637ed6b0bff5cb6f406b7edee386bfb5a899fa5ae9f24117c4b1fe649286651ece45b3dc2007cb8a163bf0598da48361c55d39a69163fa8fd24cf5f83655d23dca3ad961c62f356208552bb9ed529077096966d670c354e4abc9804f1746c08ca18217c32905e462e36ce3be39e772c180e86039b2783a2ec07a28fb5c55df06f4c52c9de2bcbf6955817183995497cea956ae515d2261898fa051015728e5a8aaac42dad33170d04507a33a85521abdf1cba64ecfb850458dbef0a8aea71575d060c7db3970f85a6e1e4c7abf5ae8cdb0933d71e8c94e04a25619dcee3d2261ad2ee6bf12ffa06d98a0864d87602733ec86a64521f2b18177b200cbbe117577a615d6c770988c0bad946e208e24fa074e5ab3143db5bfce0fd108e4b82d120a92108011a723c12a787e6d788719a10bdba5b2699c327186af4e23c1a946834b6150bda2583e9ca2ad44ce8dbbbc2db04de8ef92e8efc141fbecaa6287c59474e6bc05d99b2964fa090c3a2233ba186515be7ed1f612970cee2d7afb81bdd762170481cd0069127d5b05aa993b4ea988d8fddc186ffb7dc90a6c08f4df435c93402849236c3fab4d27c7026c1d4dcb2602646dec9751e763dba37bdf8ff9406ad9e530ee5db382f413001aeb06a53ed9027d831179727b0865a8918da3edbebcf9b14ed44ce6cbaced4bb1bdb7f1447e6cc254b332051512bd7af426fb8f401378cd2bf5983ca01c64b92ecf032ea15d1721d03f482d7ce6e74fef6d55e702f46980c82b5a84031900b1c9e59e7c97fbec7e8f323a97a7e36cc88be0f1d45b7ff585ac54bd407b22b4154aacc8f6d7ebf48e1d814cc5ed20f8037e0a79715eef29be32806a1d58bb7c5da76f550aa3d8a1fbff0eb19ccb1a313d55cda56c9ec2ef29632387fe8d76e3c0468043e8f663f4860ee12bf2d5b0b7474d6e694f91e6dbe115974a3926f12fee5e438777cb6a932df8cd8bec4d073b931ba3bc832b68d9dd300741fa7bf8afc47ed2576f6936ba424663aab639c5ae4f5683423b4742bf1c978238f16cbe39d652de3fdb8befc848ad922222e04a4037c0713eb57a81a23f0c73473fc646cea306b4bcbc8862f8385ddfa9d4b7fa2c087e879683303ed5bdd3a062b3cf5b3a278a66d2a13f83f44f82ddf310ee074ab6a364597e899a0255dc164f31cc50846851df9ab48195ded7ea1b1d510bd7ee74d73faf36bc31ecfa268359046f4eb879f924009438b481c6cd7889a002ed5ee382bc9190da6fc026e479558e4475677e9aa9e3050e2765694dfc81f56e880b96e7160c980dd98edd3dfffffffffffffffff"}}')},function(e,t,r){(function(Buffer){var t=r(18),n=new(r(159)),i=new t(24),o=new t(11),a=new t(10),s=new t(3),u=new t(7),f=r(158),c=r(34);function l(e,r){return r=r||"utf8",Buffer.isBuffer(e)||(e=new Buffer(e,r)),this._pub=new t(e),this}function h(e,r){return r=r||"utf8",Buffer.isBuffer(e)||(e=new Buffer(e,r)),this._priv=new t(e),this}e.exports=p;var d={};function p(e,r,n){this.setGenerator(r),this.__prime=new t(e),this._prime=t.mont(this.__prime),this._primeLen=e.length,this._pub=void 0,this._priv=void 0,this._primeCode=void 0,n?(this.setPublicKey=l,this.setPrivateKey=h):this._primeCode=8}function g(e,t){var r=new Buffer(e.toArray());return t?r.toString(t):r}Object.defineProperty(p.prototype,"verifyError",{enumerable:!0,get:function(){return"number"!=typeof this._primeCode&&(this._primeCode=function(e,t){var r=t.toString("hex"),c=[r,e.toString(16)].join("_");if(c in d)return d[c];var l,h=0;if(e.isEven()||!f.simpleSieve||!f.fermatTest(e)||!n.test(e))return h+=1,h+="02"===r||"05"===r?8:4,d[c]=h,h;switch(n.test(e.shrn(1))||(h+=2),r){case"02":e.mod(i).cmp(o)&&(h+=8);break;case"05":(l=e.mod(a)).cmp(s)&&l.cmp(u)&&(h+=8);break;default:h+=4}return d[c]=h,h}(this.__prime,this.__gen)),this._primeCode}}),p.prototype.generateKeys=function(){return this._priv||(this._priv=new t(c(this._primeLen))),this._pub=this._gen.toRed(this._prime).redPow(this._priv).fromRed(),this.getPublicKey()},p.prototype.computeSecret=function(e){var r=(e=(e=new t(e)).toRed(this._prime)).redPow(this._priv).fromRed(),n=new Buffer(r.toArray()),i=this.getPrime();if(n.length0?this.tail.next=t:this.head=t,this.tail=t,++this.length}},{key:"unshift",value:function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length}},{key:"shift",value:function(){if(0!==this.length){var e=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,e}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(e){if(0===this.length)return"";for(var t=this.head,r=""+t.data;t=t.next;)r+=e+t.data;return r}},{key:"concat",value:function(e){if(0===this.length)return Buffer.alloc(0);for(var t,r,n,i=Buffer.allocUnsafe(e>>>0),o=this.head,a=0;o;)t=o.data,r=i,n=a,Buffer.prototype.copy.call(t,r,n),a+=o.data.length,o=o.next;return i}},{key:"consume",value:function(e,t){var r;return ei.length?i.length:e;if(o===i.length?n+=i:n+=i.slice(0,e),0==(e-=o)){o===i.length?(++r,t.next?this.head=t.next:this.head=this.tail=null):(this.head=t,t.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(e){var t=Buffer.allocUnsafe(e),r=this.head,n=1;for(r.data.copy(t),e-=r.data.length;r=r.next;){var i=r.data,o=e>i.length?i.length:e;if(i.copy(t,t.length-e,0,o),0==(e-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,t}},{key:s,value:function(e,t){return a(this,function(e){for(var t=1;t0,(function(e){n||(n=e),e&&a.forEach(f),o||(a.forEach(f),i(n))}))}));return t.reduce(c)}},function(e,t,r){var Buffer=r(7).Buffer,n=r(62),i=r(96),o=r(66).ec,a=r(171),s=r(68),u=r(177);function f(e,t,r,i){if((e=Buffer.from(e.toArray())).length0&&r.ishrn(n),r}function l(e,t,r){var i,o;do{for(i=Buffer.alloc(0);8*i.length=49&&f<=54?f-49+10:f>=17&&f<=22?f-17+10:f,a|=u}return n(!(240&a),"Invalid character in "+e),i}function s(e,t,r,i){for(var o=0,a=0,s=Math.min(e.length,r),u=t;u=49?f-49+10:f>=17?f-17+10:f,n(f>=0&&a0?e:t},o.min=function(e,t){return e.cmp(t)<0?e:t},o.prototype._init=function(e,t,r){if("number"==typeof e)return this._initNumber(e,t,r);if("object"==typeof e)return this._initArray(e,t,r);"hex"===t&&(t=16),n(t===(0|t)&&t>=2&&t<=36);var i=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&i++,16===t?this._parseHex(e,i):this._parseBase(e,t,i),"-"===e[0]&&(this.negative=1),this._strip(),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initNumber=function(e,t,r){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(n(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===r&&this._initArray(this.toArray(),t,r)},o.prototype._initArray=function(e,t,r){if(n("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)a=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[o]|=a<>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);else if("le"===r)for(i=0,o=0;i>>26-s&67108863,(s+=24)>=26&&(s-=26,o++);return this._strip()},o.prototype._parseHex=function(e,t){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var r=0;r=t;r-=6)i=a(e,r,r+6),this.words[n]|=i<>>26-o&4194303,(o+=24)>=26&&(o-=26,n++);r+6!==t&&(i=a(e,t,r+6),this.words[n]|=i<>>26-o&4194303),this._strip()},o.prototype._parseBase=function(e,t,r){this.words=[0],this.length=1;for(var n=0,i=1;i<=67108863;i*=t)n++;n--,i=i/t|0;for(var o=e.length-r,a=o%n,u=Math.min(o,o-a)+r,f=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},o.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},"undefined"!=typeof Symbol&&"function"==typeof Symbol.for)try{o.prototype[Symbol.for("nodejs.util.inspect.custom")]=f}catch(e){o.prototype.inspect=f}else o.prototype.inspect=f;function f(){return(this.red?""}var c=["","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"],l=[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],h=[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];o.prototype.toString=function(e,t){var r;if(t=0|t||1,16===(e=e||10)||"hex"===e){r="";for(var i=0,o=0,a=0;a>>24-i&16777215)||a!==this.length-1?c[6-u.length]+u+r:u+r,(i+=2)>=26&&(i-=26,a--)}for(0!==o&&(r=o.toString(16)+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}if(e===(0|e)&&e>=2&&e<=36){var f=l[e],d=h[e];r="";var p=this.clone();for(p.negative=0;!p.isZero();){var g=p.modrn(d).toString(e);r=(p=p.idivn(d)).isZero()?g+r:c[f-g.length]+g+r}for(this.isZero()&&(r="0"+r);r.length%t!=0;)r="0"+r;return 0!==this.negative&&(r="-"+r),r}n(!1,"Base should be between 2 and 36")},o.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&n(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},o.prototype.toJSON=function(){return this.toString(16,2)},Buffer&&(o.prototype.toBuffer=function(e,t){return this.toArrayLike(Buffer,e,t)}),o.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)};function d(e,t,r){r.negative=t.negative^e.negative;var n=e.length+t.length|0;r.length=n,n=n-1|0;var i=0|e.words[0],o=0|t.words[0],a=i*o,s=67108863&a,u=a/67108864|0;r.words[0]=s;for(var f=1;f>>26,l=67108863&u,h=Math.min(f,t.length-1),d=Math.max(0,f-e.length+1);d<=h;d++){var p=f-d|0;c+=(a=(i=0|e.words[p])*(o=0|t.words[d])+l)/67108864|0,l=67108863&a}r.words[f]=0|l,u=0|c}return 0!==u?r.words[f]=0|u:r.length--,r._strip()}o.prototype.toArrayLike=function(e,t,r){this._strip();var i=this.byteLength(),o=r||Math.max(1,i);n(i<=o,"byte array longer than desired length"),n(o>0,"Requested array length <= 0");var a=function(e,t){return e.allocUnsafe?e.allocUnsafe(t):new e(t)}(e,o);return this["_toArrayLike"+("le"===t?"LE":"BE")](a,i),a},o.prototype._toArrayLikeLE=function(e,t){for(var r=0,n=0,i=0,o=0;i>8&255),r>16&255),6===o?(r>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r=0&&(e[r--]=a>>8&255),r>=0&&(e[r--]=a>>16&255),6===o?(r>=0&&(e[r--]=a>>24&255),n=0,o=0):(n=a>>>24,o+=2)}if(r>=0)for(e[r--]=n;r>=0;)e[r--]=0},Math.clz32?o.prototype._countBits=function(e){return 32-Math.clz32(e)}:o.prototype._countBits=function(e){var t=e,r=0;return t>=4096&&(r+=13,t>>>=13),t>=64&&(r+=7,t>>>=7),t>=8&&(r+=4,t>>>=4),t>=2&&(r+=2,t>>>=2),r+t},o.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,r=0;return 0==(8191&t)&&(r+=13,t>>>=13),0==(127&t)&&(r+=7,t>>>=7),0==(15&t)&&(r+=4,t>>>=4),0==(3&t)&&(r+=2,t>>>=2),0==(1&t)&&r++,r},o.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},o.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},o.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},o.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},o.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},o.prototype.iuxor=function(e){var t,r;this.length>e.length?(t=this,r=e):(t=e,r=this);for(var n=0;ne.length?this.clone().ixor(e):e.clone().ixor(this)},o.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},o.prototype.inotn=function(e){n("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),r=e%26;this._expand(t),r>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-r),this._strip()},o.prototype.notn=function(e){return this.clone().inotn(e)},o.prototype.setn=function(e,t){n("number"==typeof e&&e>=0);var r=e/26|0,i=e%26;return this._expand(r+1),this.words[r]=t?this.words[r]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,o=0;o>>26;for(;0!==i&&o>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;oe.length?this.clone().iadd(e):e.clone().iadd(this)},o.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var r,n,i=this.cmp(e);if(0===i)return this.negative=0,this.length=1,this.words[0]=0,this;i>0?(r=this,n=e):(r=e,n=this);for(var o=0,a=0;a>26,this.words[a]=67108863&t;for(;0!==o&&a>26,this.words[a]=67108863&t;if(0===o&&a>>13,d=0|a[1],p=8191&d,g=d>>>13,y=0|a[2],m=8191&y,b=y>>>13,v=0|a[3],w=8191&v,_=v>>>13,E=0|a[4],S=8191&E,A=E>>>13,I=0|a[5],O=8191&I,P=I>>>13,M=0|a[6],k=8191&M,T=M>>>13,x=0|a[7],R=8191&x,C=x>>>13,N=0|a[8],B=8191&N,D=N>>>13,U=0|a[9],j=8191&U,L=U>>>13,F=0|s[0],H=8191&F,q=F>>>13,V=0|s[1],K=8191&V,z=V>>>13,G=0|s[2],Q=8191&G,W=G>>>13,Y=0|s[3],Z=8191&Y,J=Y>>>13,X=0|s[4],$=8191&X,ee=X>>>13,te=0|s[5],re=8191&te,ne=te>>>13,ie=0|s[6],oe=8191&ie,ae=ie>>>13,se=0|s[7],ue=8191&se,fe=se>>>13,ce=0|s[8],le=8191&ce,he=ce>>>13,de=0|s[9],pe=8191&de,ge=de>>>13;r.negative=e.negative^t.negative,r.length=19;var ye=(f+(n=Math.imul(l,H))|0)+((8191&(i=(i=Math.imul(l,q))+Math.imul(h,H)|0))<<13)|0;f=((o=Math.imul(h,q))+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul(p,H),i=(i=Math.imul(p,q))+Math.imul(g,H)|0,o=Math.imul(g,q);var me=(f+(n=n+Math.imul(l,K)|0)|0)+((8191&(i=(i=i+Math.imul(l,z)|0)+Math.imul(h,K)|0))<<13)|0;f=((o=o+Math.imul(h,z)|0)+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(m,H),i=(i=Math.imul(m,q))+Math.imul(b,H)|0,o=Math.imul(b,q),n=n+Math.imul(p,K)|0,i=(i=i+Math.imul(p,z)|0)+Math.imul(g,K)|0,o=o+Math.imul(g,z)|0;var be=(f+(n=n+Math.imul(l,Q)|0)|0)+((8191&(i=(i=i+Math.imul(l,W)|0)+Math.imul(h,Q)|0))<<13)|0;f=((o=o+Math.imul(h,W)|0)+(i>>>13)|0)+(be>>>26)|0,be&=67108863,n=Math.imul(w,H),i=(i=Math.imul(w,q))+Math.imul(_,H)|0,o=Math.imul(_,q),n=n+Math.imul(m,K)|0,i=(i=i+Math.imul(m,z)|0)+Math.imul(b,K)|0,o=o+Math.imul(b,z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(g,Q)|0,o=o+Math.imul(g,W)|0;var ve=(f+(n=n+Math.imul(l,Z)|0)|0)+((8191&(i=(i=i+Math.imul(l,J)|0)+Math.imul(h,Z)|0))<<13)|0;f=((o=o+Math.imul(h,J)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(S,H),i=(i=Math.imul(S,q))+Math.imul(A,H)|0,o=Math.imul(A,q),n=n+Math.imul(w,K)|0,i=(i=i+Math.imul(w,z)|0)+Math.imul(_,K)|0,o=o+Math.imul(_,z)|0,n=n+Math.imul(m,Q)|0,i=(i=i+Math.imul(m,W)|0)+Math.imul(b,Q)|0,o=o+Math.imul(b,W)|0,n=n+Math.imul(p,Z)|0,i=(i=i+Math.imul(p,J)|0)+Math.imul(g,Z)|0,o=o+Math.imul(g,J)|0;var we=(f+(n=n+Math.imul(l,$)|0)|0)+((8191&(i=(i=i+Math.imul(l,ee)|0)+Math.imul(h,$)|0))<<13)|0;f=((o=o+Math.imul(h,ee)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(O,H),i=(i=Math.imul(O,q))+Math.imul(P,H)|0,o=Math.imul(P,q),n=n+Math.imul(S,K)|0,i=(i=i+Math.imul(S,z)|0)+Math.imul(A,K)|0,o=o+Math.imul(A,z)|0,n=n+Math.imul(w,Q)|0,i=(i=i+Math.imul(w,W)|0)+Math.imul(_,Q)|0,o=o+Math.imul(_,W)|0,n=n+Math.imul(m,Z)|0,i=(i=i+Math.imul(m,J)|0)+Math.imul(b,Z)|0,o=o+Math.imul(b,J)|0,n=n+Math.imul(p,$)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(g,$)|0,o=o+Math.imul(g,ee)|0;var _e=(f+(n=n+Math.imul(l,re)|0)|0)+((8191&(i=(i=i+Math.imul(l,ne)|0)+Math.imul(h,re)|0))<<13)|0;f=((o=o+Math.imul(h,ne)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(k,H),i=(i=Math.imul(k,q))+Math.imul(T,H)|0,o=Math.imul(T,q),n=n+Math.imul(O,K)|0,i=(i=i+Math.imul(O,z)|0)+Math.imul(P,K)|0,o=o+Math.imul(P,z)|0,n=n+Math.imul(S,Q)|0,i=(i=i+Math.imul(S,W)|0)+Math.imul(A,Q)|0,o=o+Math.imul(A,W)|0,n=n+Math.imul(w,Z)|0,i=(i=i+Math.imul(w,J)|0)+Math.imul(_,Z)|0,o=o+Math.imul(_,J)|0,n=n+Math.imul(m,$)|0,i=(i=i+Math.imul(m,ee)|0)+Math.imul(b,$)|0,o=o+Math.imul(b,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(g,re)|0,o=o+Math.imul(g,ne)|0;var Ee=(f+(n=n+Math.imul(l,oe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ae)|0)+Math.imul(h,oe)|0))<<13)|0;f=((o=o+Math.imul(h,ae)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(R,H),i=(i=Math.imul(R,q))+Math.imul(C,H)|0,o=Math.imul(C,q),n=n+Math.imul(k,K)|0,i=(i=i+Math.imul(k,z)|0)+Math.imul(T,K)|0,o=o+Math.imul(T,z)|0,n=n+Math.imul(O,Q)|0,i=(i=i+Math.imul(O,W)|0)+Math.imul(P,Q)|0,o=o+Math.imul(P,W)|0,n=n+Math.imul(S,Z)|0,i=(i=i+Math.imul(S,J)|0)+Math.imul(A,Z)|0,o=o+Math.imul(A,J)|0,n=n+Math.imul(w,$)|0,i=(i=i+Math.imul(w,ee)|0)+Math.imul(_,$)|0,o=o+Math.imul(_,ee)|0,n=n+Math.imul(m,re)|0,i=(i=i+Math.imul(m,ne)|0)+Math.imul(b,re)|0,o=o+Math.imul(b,ne)|0,n=n+Math.imul(p,oe)|0,i=(i=i+Math.imul(p,ae)|0)+Math.imul(g,oe)|0,o=o+Math.imul(g,ae)|0;var Se=(f+(n=n+Math.imul(l,ue)|0)|0)+((8191&(i=(i=i+Math.imul(l,fe)|0)+Math.imul(h,ue)|0))<<13)|0;f=((o=o+Math.imul(h,fe)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(B,H),i=(i=Math.imul(B,q))+Math.imul(D,H)|0,o=Math.imul(D,q),n=n+Math.imul(R,K)|0,i=(i=i+Math.imul(R,z)|0)+Math.imul(C,K)|0,o=o+Math.imul(C,z)|0,n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(T,Q)|0,o=o+Math.imul(T,W)|0,n=n+Math.imul(O,Z)|0,i=(i=i+Math.imul(O,J)|0)+Math.imul(P,Z)|0,o=o+Math.imul(P,J)|0,n=n+Math.imul(S,$)|0,i=(i=i+Math.imul(S,ee)|0)+Math.imul(A,$)|0,o=o+Math.imul(A,ee)|0,n=n+Math.imul(w,re)|0,i=(i=i+Math.imul(w,ne)|0)+Math.imul(_,re)|0,o=o+Math.imul(_,ne)|0,n=n+Math.imul(m,oe)|0,i=(i=i+Math.imul(m,ae)|0)+Math.imul(b,oe)|0,o=o+Math.imul(b,ae)|0,n=n+Math.imul(p,ue)|0,i=(i=i+Math.imul(p,fe)|0)+Math.imul(g,ue)|0,o=o+Math.imul(g,fe)|0;var Ae=(f+(n=n+Math.imul(l,le)|0)|0)+((8191&(i=(i=i+Math.imul(l,he)|0)+Math.imul(h,le)|0))<<13)|0;f=((o=o+Math.imul(h,he)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(j,H),i=(i=Math.imul(j,q))+Math.imul(L,H)|0,o=Math.imul(L,q),n=n+Math.imul(B,K)|0,i=(i=i+Math.imul(B,z)|0)+Math.imul(D,K)|0,o=o+Math.imul(D,z)|0,n=n+Math.imul(R,Q)|0,i=(i=i+Math.imul(R,W)|0)+Math.imul(C,Q)|0,o=o+Math.imul(C,W)|0,n=n+Math.imul(k,Z)|0,i=(i=i+Math.imul(k,J)|0)+Math.imul(T,Z)|0,o=o+Math.imul(T,J)|0,n=n+Math.imul(O,$)|0,i=(i=i+Math.imul(O,ee)|0)+Math.imul(P,$)|0,o=o+Math.imul(P,ee)|0,n=n+Math.imul(S,re)|0,i=(i=i+Math.imul(S,ne)|0)+Math.imul(A,re)|0,o=o+Math.imul(A,ne)|0,n=n+Math.imul(w,oe)|0,i=(i=i+Math.imul(w,ae)|0)+Math.imul(_,oe)|0,o=o+Math.imul(_,ae)|0,n=n+Math.imul(m,ue)|0,i=(i=i+Math.imul(m,fe)|0)+Math.imul(b,ue)|0,o=o+Math.imul(b,fe)|0,n=n+Math.imul(p,le)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(g,le)|0,o=o+Math.imul(g,he)|0;var Ie=(f+(n=n+Math.imul(l,pe)|0)|0)+((8191&(i=(i=i+Math.imul(l,ge)|0)+Math.imul(h,pe)|0))<<13)|0;f=((o=o+Math.imul(h,ge)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(j,K),i=(i=Math.imul(j,z))+Math.imul(L,K)|0,o=Math.imul(L,z),n=n+Math.imul(B,Q)|0,i=(i=i+Math.imul(B,W)|0)+Math.imul(D,Q)|0,o=o+Math.imul(D,W)|0,n=n+Math.imul(R,Z)|0,i=(i=i+Math.imul(R,J)|0)+Math.imul(C,Z)|0,o=o+Math.imul(C,J)|0,n=n+Math.imul(k,$)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(T,$)|0,o=o+Math.imul(T,ee)|0,n=n+Math.imul(O,re)|0,i=(i=i+Math.imul(O,ne)|0)+Math.imul(P,re)|0,o=o+Math.imul(P,ne)|0,n=n+Math.imul(S,oe)|0,i=(i=i+Math.imul(S,ae)|0)+Math.imul(A,oe)|0,o=o+Math.imul(A,ae)|0,n=n+Math.imul(w,ue)|0,i=(i=i+Math.imul(w,fe)|0)+Math.imul(_,ue)|0,o=o+Math.imul(_,fe)|0,n=n+Math.imul(m,le)|0,i=(i=i+Math.imul(m,he)|0)+Math.imul(b,le)|0,o=o+Math.imul(b,he)|0;var Oe=(f+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,ge)|0)+Math.imul(g,pe)|0))<<13)|0;f=((o=o+Math.imul(g,ge)|0)+(i>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,n=Math.imul(j,Q),i=(i=Math.imul(j,W))+Math.imul(L,Q)|0,o=Math.imul(L,W),n=n+Math.imul(B,Z)|0,i=(i=i+Math.imul(B,J)|0)+Math.imul(D,Z)|0,o=o+Math.imul(D,J)|0,n=n+Math.imul(R,$)|0,i=(i=i+Math.imul(R,ee)|0)+Math.imul(C,$)|0,o=o+Math.imul(C,ee)|0,n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(T,re)|0,o=o+Math.imul(T,ne)|0,n=n+Math.imul(O,oe)|0,i=(i=i+Math.imul(O,ae)|0)+Math.imul(P,oe)|0,o=o+Math.imul(P,ae)|0,n=n+Math.imul(S,ue)|0,i=(i=i+Math.imul(S,fe)|0)+Math.imul(A,ue)|0,o=o+Math.imul(A,fe)|0,n=n+Math.imul(w,le)|0,i=(i=i+Math.imul(w,he)|0)+Math.imul(_,le)|0,o=o+Math.imul(_,he)|0;var Pe=(f+(n=n+Math.imul(m,pe)|0)|0)+((8191&(i=(i=i+Math.imul(m,ge)|0)+Math.imul(b,pe)|0))<<13)|0;f=((o=o+Math.imul(b,ge)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(j,Z),i=(i=Math.imul(j,J))+Math.imul(L,Z)|0,o=Math.imul(L,J),n=n+Math.imul(B,$)|0,i=(i=i+Math.imul(B,ee)|0)+Math.imul(D,$)|0,o=o+Math.imul(D,ee)|0,n=n+Math.imul(R,re)|0,i=(i=i+Math.imul(R,ne)|0)+Math.imul(C,re)|0,o=o+Math.imul(C,ne)|0,n=n+Math.imul(k,oe)|0,i=(i=i+Math.imul(k,ae)|0)+Math.imul(T,oe)|0,o=o+Math.imul(T,ae)|0,n=n+Math.imul(O,ue)|0,i=(i=i+Math.imul(O,fe)|0)+Math.imul(P,ue)|0,o=o+Math.imul(P,fe)|0,n=n+Math.imul(S,le)|0,i=(i=i+Math.imul(S,he)|0)+Math.imul(A,le)|0,o=o+Math.imul(A,he)|0;var Me=(f+(n=n+Math.imul(w,pe)|0)|0)+((8191&(i=(i=i+Math.imul(w,ge)|0)+Math.imul(_,pe)|0))<<13)|0;f=((o=o+Math.imul(_,ge)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(j,$),i=(i=Math.imul(j,ee))+Math.imul(L,$)|0,o=Math.imul(L,ee),n=n+Math.imul(B,re)|0,i=(i=i+Math.imul(B,ne)|0)+Math.imul(D,re)|0,o=o+Math.imul(D,ne)|0,n=n+Math.imul(R,oe)|0,i=(i=i+Math.imul(R,ae)|0)+Math.imul(C,oe)|0,o=o+Math.imul(C,ae)|0,n=n+Math.imul(k,ue)|0,i=(i=i+Math.imul(k,fe)|0)+Math.imul(T,ue)|0,o=o+Math.imul(T,fe)|0,n=n+Math.imul(O,le)|0,i=(i=i+Math.imul(O,he)|0)+Math.imul(P,le)|0,o=o+Math.imul(P,he)|0;var ke=(f+(n=n+Math.imul(S,pe)|0)|0)+((8191&(i=(i=i+Math.imul(S,ge)|0)+Math.imul(A,pe)|0))<<13)|0;f=((o=o+Math.imul(A,ge)|0)+(i>>>13)|0)+(ke>>>26)|0,ke&=67108863,n=Math.imul(j,re),i=(i=Math.imul(j,ne))+Math.imul(L,re)|0,o=Math.imul(L,ne),n=n+Math.imul(B,oe)|0,i=(i=i+Math.imul(B,ae)|0)+Math.imul(D,oe)|0,o=o+Math.imul(D,ae)|0,n=n+Math.imul(R,ue)|0,i=(i=i+Math.imul(R,fe)|0)+Math.imul(C,ue)|0,o=o+Math.imul(C,fe)|0,n=n+Math.imul(k,le)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(T,le)|0,o=o+Math.imul(T,he)|0;var Te=(f+(n=n+Math.imul(O,pe)|0)|0)+((8191&(i=(i=i+Math.imul(O,ge)|0)+Math.imul(P,pe)|0))<<13)|0;f=((o=o+Math.imul(P,ge)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(j,oe),i=(i=Math.imul(j,ae))+Math.imul(L,oe)|0,o=Math.imul(L,ae),n=n+Math.imul(B,ue)|0,i=(i=i+Math.imul(B,fe)|0)+Math.imul(D,ue)|0,o=o+Math.imul(D,fe)|0,n=n+Math.imul(R,le)|0,i=(i=i+Math.imul(R,he)|0)+Math.imul(C,le)|0,o=o+Math.imul(C,he)|0;var xe=(f+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,ge)|0)+Math.imul(T,pe)|0))<<13)|0;f=((o=o+Math.imul(T,ge)|0)+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,n=Math.imul(j,ue),i=(i=Math.imul(j,fe))+Math.imul(L,ue)|0,o=Math.imul(L,fe),n=n+Math.imul(B,le)|0,i=(i=i+Math.imul(B,he)|0)+Math.imul(D,le)|0,o=o+Math.imul(D,he)|0;var Re=(f+(n=n+Math.imul(R,pe)|0)|0)+((8191&(i=(i=i+Math.imul(R,ge)|0)+Math.imul(C,pe)|0))<<13)|0;f=((o=o+Math.imul(C,ge)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863,n=Math.imul(j,le),i=(i=Math.imul(j,he))+Math.imul(L,le)|0,o=Math.imul(L,he);var Ce=(f+(n=n+Math.imul(B,pe)|0)|0)+((8191&(i=(i=i+Math.imul(B,ge)|0)+Math.imul(D,pe)|0))<<13)|0;f=((o=o+Math.imul(D,ge)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863;var Ne=(f+(n=Math.imul(j,pe))|0)+((8191&(i=(i=Math.imul(j,ge))+Math.imul(L,pe)|0))<<13)|0;return f=((o=Math.imul(L,ge))+(i>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,u[0]=ye,u[1]=me,u[2]=be,u[3]=ve,u[4]=we,u[5]=_e,u[6]=Ee,u[7]=Se,u[8]=Ae,u[9]=Ie,u[10]=Oe,u[11]=Pe,u[12]=Me,u[13]=ke,u[14]=Te,u[15]=xe,u[16]=Re,u[17]=Ce,u[18]=Ne,0!==f&&(u[19]=f,r.length++),r};function g(e,t,r){r.negative=t.negative^e.negative,r.length=e.length+t.length;for(var n=0,i=0,o=0;o>>26)|0)>>>26,a&=67108863}r.words[o]=s,n=a,a=i}return 0!==n?r.words[o]=n:r.length--,r._strip()}function y(e,t,r){return g(e,t,r)}function m(e,t){this.x=e,this.y=t}Math.imul||(p=d),o.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?p(this,e,t):r<63?d(this,e,t):r<1024?g(this,e,t):y(this,e,t)},m.prototype.makeRBT=function(e){for(var t=new Array(e),r=o.prototype._countBits(e)-1,n=0;n>=1;return n},m.prototype.permute=function(e,t,r,n,i,o){for(var a=0;a>>=1)i++;return 1<>>=13,r[2*a+1]=8191&o,o>>>=13;for(a=2*t;a>=26,r+=o/67108864|0,r+=a>>>26,this.words[i]=67108863&a}return 0!==r&&(this.words[i]=r,this.length++),t?this.ineg():this},o.prototype.muln=function(e){return this.clone().imuln(e)},o.prototype.sqr=function(){return this.mul(this)},o.prototype.isqr=function(){return this.imul(this.clone())},o.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i&1}return t}(e);if(0===t.length)return new o(1);for(var r=this,n=0;n=0);var t,r=e%26,i=(e-r)/26,o=67108863>>>26-r<<26-r;if(0!==r){var a=0;for(t=0;t>>26-r}a&&(this.words[t]=a,this.length++)}if(0!==i){for(t=this.length-1;t>=0;t--)this.words[t+i]=this.words[t];for(t=0;t=0),i=t?(t-t%26)/26:0;var o=e%26,a=Math.min((e-o)/26,this.length),s=67108863^67108863>>>o<a)for(this.length-=a,f=0;f=0&&(0!==c||f>=i);f--){var l=0|this.words[f];this.words[f]=c<<26-o|l>>>o,c=l&s}return u&&0!==c&&(u.words[u.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this._strip()},o.prototype.ishrn=function(e,t,r){return n(0===this.negative),this.iushrn(e,t,r)},o.prototype.shln=function(e){return this.clone().ishln(e)},o.prototype.ushln=function(e){return this.clone().iushln(e)},o.prototype.shrn=function(e){return this.clone().ishrn(e)},o.prototype.ushrn=function(e){return this.clone().iushrn(e)},o.prototype.testn=function(e){n("number"==typeof e&&e>=0);var t=e%26,r=(e-t)/26,i=1<=0);var t=e%26,r=(e-t)/26;if(n(0===this.negative,"imaskn works only with positive numbers"),this.length<=r)return this;if(0!==t&&r++,this.length=Math.min(r,this.length),0!==t){var i=67108863^67108863>>>t<=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},o.prototype.isubn=function(e){if(n("number"==typeof e),n(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(u/67108864|0),this.words[i+r]=67108863&o}for(;i>26,this.words[i+r]=67108863&o;if(0===s)return this._strip();for(n(-1===s),s=0,i=0;i>26,this.words[i]=67108863&o;return this.negative=1,this._strip()},o.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),i=e,a=0|i.words[i.length-1];0!==(r=26-this._countBits(a))&&(i=i.ushln(r),n.iushln(r),a=0|i.words[i.length-1]);var s,u=n.length-i.length;if("mod"!==t){(s=new o(null)).length=u+1,s.words=new Array(s.length);for(var f=0;f=0;l--){var h=67108864*(0|n.words[i.length+l])+(0|n.words[i.length+l-1]);for(h=Math.min(h/a|0,67108863),n._ishlnsubmul(i,h,l);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(i,1,l),n.isZero()||(n.negative^=1);s&&(s.words[l]=h)}return s&&s._strip(),n._strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:s||null,mod:n}},o.prototype.divmod=function(e,t,r){return n(!e.isZero()),this.isZero()?{div:new o(0),mod:new o(0)}:0!==this.negative&&0===e.negative?(s=this.neg().divmod(e,t),"mod"!==t&&(i=s.div.neg()),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.iadd(e)),{div:i,mod:a}):0===this.negative&&0!==e.negative?(s=this.divmod(e.neg(),t),"mod"!==t&&(i=s.div.neg()),{div:i,mod:s.mod}):0!=(this.negative&e.negative)?(s=this.neg().divmod(e.neg(),t),"div"!==t&&(a=s.mod.neg(),r&&0!==a.negative&&a.isub(e)),{div:s.div,mod:a}):e.length>this.length||this.cmp(e)<0?{div:new o(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new o(this.modrn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new o(this.modrn(e.words[0]))}:this._wordDiv(e,t);var i,a,s},o.prototype.div=function(e){return this.divmod(e,"div",!1).div},o.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},o.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},o.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),o=r.cmp(n);return o<0||1===i&&0===o?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},o.prototype.modrn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=(1<<26)%e,i=0,o=this.length-1;o>=0;o--)i=(r*i+(0|this.words[o]))%e;return t?-i:i},o.prototype.modn=function(e){return this.modrn(e)},o.prototype.idivn=function(e){var t=e<0;t&&(e=-e),n(e<=67108863);for(var r=0,i=this.length-1;i>=0;i--){var o=(0|this.words[i])+67108864*r;this.words[i]=o/e|0,r=o%e}return this._strip(),t?this.ineg():this},o.prototype.divn=function(e){return this.clone().idivn(e)},o.prototype.egcd=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i=new o(1),a=new o(0),s=new o(0),u=new o(1),f=0;t.isEven()&&r.isEven();)t.iushrn(1),r.iushrn(1),++f;for(var c=r.clone(),l=t.clone();!t.isZero();){for(var h=0,d=1;0==(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(i.isOdd()||a.isOdd())&&(i.iadd(c),a.isub(l)),i.iushrn(1),a.iushrn(1);for(var p=0,g=1;0==(r.words[0]&g)&&p<26;++p,g<<=1);if(p>0)for(r.iushrn(p);p-- >0;)(s.isOdd()||u.isOdd())&&(s.iadd(c),u.isub(l)),s.iushrn(1),u.iushrn(1);t.cmp(r)>=0?(t.isub(r),i.isub(s),a.isub(u)):(r.isub(t),s.isub(i),u.isub(a))}return{a:s,b:u,gcd:r.iushln(f)}},o.prototype._invmp=function(e){n(0===e.negative),n(!e.isZero());var t=this,r=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var i,a=new o(1),s=new o(0),u=r.clone();t.cmpn(1)>0&&r.cmpn(1)>0;){for(var f=0,c=1;0==(t.words[0]&c)&&f<26;++f,c<<=1);if(f>0)for(t.iushrn(f);f-- >0;)a.isOdd()&&a.iadd(u),a.iushrn(1);for(var l=0,h=1;0==(r.words[0]&h)&&l<26;++l,h<<=1);if(l>0)for(r.iushrn(l);l-- >0;)s.isOdd()&&s.iadd(u),s.iushrn(1);t.cmp(r)>=0?(t.isub(r),a.isub(s)):(r.isub(t),s.isub(a))}return(i=0===t.cmpn(1)?a:s).cmpn(0)<0&&i.iadd(e),i},o.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),r=e.clone();t.negative=0,r.negative=0;for(var n=0;t.isEven()&&r.isEven();n++)t.iushrn(1),r.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;r.isEven();)r.iushrn(1);var i=t.cmp(r);if(i<0){var o=t;t=r,r=o}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},o.prototype.invm=function(e){return this.egcd(e).a.umod(e)},o.prototype.isEven=function(){return 0==(1&this.words[0])},o.prototype.isOdd=function(){return 1==(1&this.words[0])},o.prototype.andln=function(e){return this.words[0]&e},o.prototype.bincn=function(e){n("number"==typeof e);var t=e%26,r=(e-t)/26,i=1<>>26,s&=67108863,this.words[a]=s}return 0!==o&&(this.words[a]=o,this.length++),this},o.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},o.prototype.cmpn=function(e){var t,r=e<0;if(0!==this.negative&&!r)return-1;if(0===this.negative&&r)return 1;if(this._strip(),this.length>1)t=1;else{r&&(e=-e),n(e<=67108863,"Number is too big");var i=0|this.words[0];t=i===e?0:ie.length)return 1;if(this.length=0;r--){var n=0|this.words[r],i=0|e.words[r];if(n!==i){ni&&(t=1);break}}return t},o.prototype.gtn=function(e){return 1===this.cmpn(e)},o.prototype.gt=function(e){return 1===this.cmp(e)},o.prototype.gten=function(e){return this.cmpn(e)>=0},o.prototype.gte=function(e){return this.cmp(e)>=0},o.prototype.ltn=function(e){return-1===this.cmpn(e)},o.prototype.lt=function(e){return-1===this.cmp(e)},o.prototype.lten=function(e){return this.cmpn(e)<=0},o.prototype.lte=function(e){return this.cmp(e)<=0},o.prototype.eqn=function(e){return 0===this.cmpn(e)},o.prototype.eq=function(e){return 0===this.cmp(e)},o.red=function(e){return new A(e)},o.prototype.toRed=function(e){return n(!this.red,"Already a number in reduction context"),n(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},o.prototype.fromRed=function(){return n(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},o.prototype._forceRed=function(e){return this.red=e,this},o.prototype.forceRed=function(e){return n(!this.red,"Already a number in reduction context"),this._forceRed(e)},o.prototype.redAdd=function(e){return n(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},o.prototype.redIAdd=function(e){return n(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},o.prototype.redSub=function(e){return n(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},o.prototype.redISub=function(e){return n(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},o.prototype.redShl=function(e){return n(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},o.prototype.redMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},o.prototype.redIMul=function(e){return n(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},o.prototype.redSqr=function(){return n(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},o.prototype.redISqr=function(){return n(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},o.prototype.redSqrt=function(){return n(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},o.prototype.redInvm=function(){return n(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},o.prototype.redNeg=function(){return n(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},o.prototype.redPow=function(e){return n(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function v(e,t){this.name=e,this.p=new o(t,16),this.n=this.p.bitLength(),this.k=new o(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){v.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){v.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function E(){v.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function S(){v.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function A(e){if("string"==typeof e){var t=o._prime(e);this.m=t.p,this.prime=t}else n(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function I(e){A.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new o(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)}v.prototype._tmp=function(){var e=new o(null);return e.words=new Array(Math.ceil(this.n/13)),e},v.prototype.ireduce=function(e){var t,r=e;do{this.split(r,this.tmp),t=(r=(r=this.imulK(r)).iadd(this.tmp)).bitLength()}while(t>this.n);var n=t0?r.isub(this.p):void 0!==r.strip?r.strip():r._strip(),r},v.prototype.split=function(e,t){e.iushrn(this.n,0,t)},v.prototype.imulK=function(e){return e.imul(this.k)},i(w,v),w.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=o}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,r=0;r>>=26,e.words[r]=i,t=n}return 0!==t&&(e.words[e.length++]=t),e},o._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new w;else if("p224"===e)t=new _;else if("p192"===e)t=new E;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new S}return b[e]=t,t},A.prototype._verify1=function(e){n(0===e.negative,"red works only with positives"),n(e.red,"red works only with red numbers")},A.prototype._verify2=function(e,t){n(0==(e.negative|t.negative),"red works only with positives"),n(e.red&&e.red===t.red,"red works only with red numbers")},A.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):(u(e,e.umod(this.m)._forceRed(this)),e)},A.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},A.prototype.add=function(e,t){this._verify2(e,t);var r=e.add(t);return r.cmp(this.m)>=0&&r.isub(this.m),r._forceRed(this)},A.prototype.iadd=function(e,t){this._verify2(e,t);var r=e.iadd(t);return r.cmp(this.m)>=0&&r.isub(this.m),r},A.prototype.sub=function(e,t){this._verify2(e,t);var r=e.sub(t);return r.cmpn(0)<0&&r.iadd(this.m),r._forceRed(this)},A.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},A.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},A.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},A.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},A.prototype.isqr=function(e){return this.imul(e,e.clone())},A.prototype.sqr=function(e){return this.mul(e,e)},A.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(n(t%2==1),3===t){var r=this.m.add(new o(1)).iushrn(2);return this.pow(e,r)}for(var i=this.m.subn(1),a=0;!i.isZero()&&0===i.andln(1);)a++,i.iushrn(1);n(!i.isZero());var s=new o(1).toRed(this),u=s.redNeg(),f=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new o(2*c*c).toRed(this);0!==this.pow(c,f).cmp(u);)c.redIAdd(u);for(var l=this.pow(c,i),h=this.pow(e,i.addn(1).iushrn(1)),d=this.pow(e,i),p=a;0!==d.cmp(s);){for(var g=d,y=0;0!==g.cmp(s);y++)g=g.redSqr();n(y=0;n--){for(var f=t.words[n],c=u-1;c>=0;c--){var l=f>>c&1;i!==r[0]&&(i=this.sqr(i)),0!==l||0!==a?(a<<=1,a|=l,(4===++s||0===n&&0===c)&&(i=this.mul(i,r[a]),s=0,a=0)):s=0}u=26}return i},A.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},A.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},o.mont=function(e){return new I(e)},i(I,A),I.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},I.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},I.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var r=e.imul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),o=i;return i.cmp(this.m)>=0?o=i.isub(this.m):i.cmpn(0)<0&&(o=i.iadd(this.m)),o._forceRed(this)},I.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new o(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),i=r.isub(n).iushrn(this.shift),a=i;return i.cmp(this.m)>=0?a=i.isub(this.m):i.cmpn(0)<0&&(a=i.iadd(this.m)),a._forceRed(this)},I.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,this)}).call(this,r(65)(e))},function(e,t){},function(e){e.exports=JSON.parse('{"name":"elliptic","version":"6.5.3","description":"EC cryptography","main":"lib/elliptic.js","files":["lib"],"scripts":{"jscs":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","jshint":"jscs benchmarks/*.js lib/*.js lib/**/*.js lib/**/**/*.js test/index.js","lint":"npm run jscs && npm run jshint","unit":"istanbul test _mocha --reporter=spec test/index.js","test":"npm run lint && npm run unit","version":"grunt dist && git add dist/"},"repository":{"type":"git","url":"git@github.com:indutny/elliptic"},"keywords":["EC","Elliptic","curve","Cryptography"],"author":"Fedor Indutny ","license":"MIT","bugs":{"url":"https://github.com/indutny/elliptic/issues"},"homepage":"https://github.com/indutny/elliptic","devDependencies":{"brfs":"^1.4.3","coveralls":"^3.0.8","grunt":"^1.0.4","grunt-browserify":"^5.0.0","grunt-cli":"^1.2.0","grunt-contrib-connect":"^1.0.0","grunt-contrib-copy":"^1.0.0","grunt-contrib-uglify":"^1.0.1","grunt-mocha-istanbul":"^3.0.1","grunt-saucelabs":"^9.0.1","istanbul":"^0.4.2","jscs":"^3.0.7","jshint":"^2.10.3","mocha":"^6.2.2"},"dependencies":{"bn.js":"^4.4.0","brorand":"^1.0.1","hash.js":"^1.0.0","hmac-drbg":"^1.0.0","inherits":"^2.0.1","minimalistic-assert":"^1.0.0","minimalistic-crypto-utils":"^1.0.0"}}')},function(e,t,r){"use strict";var n=r(28),i=r(18),o=r(10),a=r(67),s=n.assert;function u(e){a.call(this,"short",e),this.a=new i(e.a,16).toRed(this.red),this.b=new i(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function Point(e,t,r,n){a.BasePoint.call(this,e,"affine"),null===t&&null===r?(this.x=null,this.y=null,this.inf=!0):(this.x=new i(t,16),this.y=new i(r,16),n&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function f(e,t,r,n){a.BasePoint.call(this,e,"jacobian"),null===t&&null===r&&null===n?(this.x=this.curve.one,this.y=this.curve.one,this.z=new i(0)):(this.x=new i(t,16),this.y=new i(r,16),this.z=new i(n,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}o(u,a),e.exports=u,u.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,r;if(e.beta)t=new i(e.beta,16).toRed(this.red);else{var n=this._getEndoRoots(this.p);t=(t=n[0].cmp(n[1])<0?n[0]:n[1]).toRed(this.red)}if(e.lambda)r=new i(e.lambda,16);else{var o=this._getEndoRoots(this.n);0===this.g.mul(o[0]).x.cmp(this.g.x.redMul(t))?r=o[0]:(r=o[1],s(0===this.g.mul(r).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:r,basis:e.basis?e.basis.map((function(e){return{a:new i(e.a,16),b:new i(e.b,16)}})):this._getEndoBasis(r)}}},u.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:i.mont(e),r=new i(2).toRed(t).redInvm(),n=r.redNeg(),o=new i(3).toRed(t).redNeg().redSqrt().redMul(r);return[n.redAdd(o).fromRed(),n.redSub(o).fromRed()]},u.prototype._getEndoBasis=function(e){for(var t,r,n,o,a,s,u,f,c,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),h=e,d=this.n.clone(),p=new i(1),g=new i(0),y=new i(0),m=new i(1),b=0;0!==h.cmpn(0);){var v=d.div(h);f=d.sub(v.mul(h)),c=y.sub(v.mul(p));var w=m.sub(v.mul(g));if(!n&&f.cmp(l)<0)t=u.neg(),r=p,n=f.neg(),o=c;else if(n&&2==++b)break;u=f,d=h,h=f,y=p,p=c,m=g,g=w}a=f.neg(),s=c;var _=n.sqr().add(o.sqr());return a.sqr().add(s.sqr()).cmp(_)>=0&&(a=t,s=r),n.negative&&(n=n.neg(),o=o.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:o},{a,b:s}]},u.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),o=r.b.neg().mul(e).divRound(this.n),a=i.mul(r.a),s=o.mul(n.a),u=i.mul(r.b),f=o.mul(n.b);return{k1:e.sub(a).sub(s),k2:u.add(f).neg()}},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),n=r.redSqrt();if(0!==n.redSqr().redSub(r).cmp(this.zero))throw new Error("invalid point");var o=n.fromRed().isOdd();return(t&&!o||!t&&o)&&(n=n.redNeg()),this.point(e,n)},u.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,r=e.y,n=this.a.redMul(t),i=t.redSqr().redMul(t).redIAdd(n).redIAdd(this.b);return 0===r.redSqr().redISub(i).cmpn(0)},u.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,o=0;o":""},Point.prototype.isInfinity=function(){return this.inf},Point.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var r=t.redSqr().redISub(this.x).redISub(e.x),n=t.redMul(this.x.redSub(r)).redISub(this.y);return this.curve.point(r,n)},Point.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,r=this.x.redSqr(),n=e.redInvm(),i=r.redAdd(r).redIAdd(r).redIAdd(t).redMul(n),o=i.redSqr().redISub(this.x.redAdd(this.x)),a=i.redMul(this.x.redSub(o)).redISub(this.y);return this.curve.point(o,a)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(e){return e=new i(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i):this.curve._wnafMulAdd(1,n,i,2)},Point.prototype.jmulAdd=function(e,t,r){var n=[this,t],i=[e,r];return this.curve.endo?this.curve._endoWnafMulAdd(n,i,!0):this.curve._wnafMulAdd(1,n,i,2,!0)},Point.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},Point.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var r=this.precomputed,n=function(e){return e.neg()};t.precomputed={naf:r.naf&&{wnd:r.naf.wnd,points:r.naf.points.map(n)},doubles:r.doubles&&{step:r.doubles.step,points:r.doubles.points.map(n)}}}return t},Point.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},o(f,a.BasePoint),u.prototype.jpoint=function(e,t,r){return new f(this,e,t,r)},f.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),r=this.x.redMul(t),n=this.y.redMul(t).redMul(e);return this.curve.point(r,n)},f.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},f.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),r=this.z.redSqr(),n=this.x.redMul(t),i=e.x.redMul(r),o=this.y.redMul(t.redMul(e.z)),a=e.y.redMul(r.redMul(this.z)),s=n.redSub(i),u=o.redSub(a);if(0===s.cmpn(0))return 0!==u.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),c=f.redMul(s),l=n.redMul(f),h=u.redSqr().redIAdd(c).redISub(l).redISub(l),d=u.redMul(l.redISub(h)).redISub(o.redMul(c)),p=this.z.redMul(e.z).redMul(s);return this.curve.jpoint(h,d,p)},f.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),r=this.x,n=e.x.redMul(t),i=this.y,o=e.y.redMul(t).redMul(this.z),a=r.redSub(n),s=i.redSub(o);if(0===a.cmpn(0))return 0!==s.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=a.redSqr(),f=u.redMul(a),c=r.redMul(u),l=s.redSqr().redIAdd(f).redISub(c).redISub(c),h=s.redMul(c.redISub(l)).redISub(i.redMul(f)),d=this.z.redMul(a);return this.curve.jpoint(l,h,d)},f.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();if(this.curve.zeroA||this.curve.threeA){for(var t=this,r=0;r=0)return!1;if(r.redIAdd(i),0===this.x.cmp(r))return!0}},f.prototype.inspect=function(){return this.isInfinity()?"":""},f.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},function(e,t,r){"use strict";var n=r(18),i=r(10),o=r(67),a=r(28);function s(e){o.call(this,"mont",e),this.a=new n(e.a,16).toRed(this.red),this.b=new n(e.b,16).toRed(this.red),this.i4=new n(4).toRed(this.red).redInvm(),this.two=new n(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function Point(e,t,r){o.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new n(t,16),this.z=new n(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}i(s,o),e.exports=s,s.prototype.validate=function(e){var t=e.normalize().x,r=t.redSqr(),n=r.redMul(t).redAdd(r.redMul(this.a)).redAdd(t);return 0===n.redSqrt().redSqr().cmp(n)},i(Point,o.BasePoint),s.prototype.decodePoint=function(e,t){return this.point(a.toArray(e,t),1)},s.prototype.point=function(e,t){return new Point(this,e,t)},s.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},Point.prototype.precompute=function(){},Point.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1]||e.one)},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),r=e.redSub(t),n=e.redMul(t),i=r.redMul(t.redAdd(this.curve.a24.redMul(r)));return this.curve.point(n,i)},Point.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),o=e.x.redSub(e.z).redMul(r),a=i.redMul(n),s=t.z.redMul(o.redAdd(a).redSqr()),u=t.x.redMul(o.redISub(a).redSqr());return this.curve.point(s,u)},Point.prototype.mul=function(e){for(var t=e.clone(),r=this,n=this.curve.point(null,null),i=[];0!==t.cmpn(0);t.iushrn(1))i.push(t.andln(1));for(var o=i.length-1;o>=0;o--)0===i[o]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Point.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},function(e,t,r){"use strict";var n=r(28),i=r(18),o=r(10),a=r(67),s=n.assert;function u(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,a.call(this,"edwards",e),this.a=new i(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new i(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new i(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),s(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function Point(e,t,r,n,o){a.BasePoint.call(this,e,"projective"),null===t&&null===r&&null===n?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new i(t,16),this.y=new i(r,16),this.z=n?new i(n,16):this.curve.one,this.t=o&&new i(o,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}o(u,a),e.exports=u,u.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},u.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},u.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},u.prototype.pointFromX=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),o=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(o.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var u=s.fromRed().isOdd();return(t&&!u||!t&&u)&&(s=s.redNeg()),this.point(e,s)},u.prototype.pointFromY=function(e,t){(e=new i(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),o=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(o.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},u.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),r=e.y.redSqr(),n=t.redMul(this.a).redAdd(r),i=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(r)));return 0===n.cmp(i)},o(Point,a.BasePoint),u.prototype.pointFromJSON=function(e){return Point.fromJSON(this,e)},u.prototype.point=function(e,t,r,n){return new Point(this,e,t,r,n)},Point.fromJSON=function(e,t){return new Point(e,t[0],t[1],t[2])},Point.prototype.inspect=function(){return this.isInfinity()?"":""},Point.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},Point.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),r=this.z.redSqr();r=r.redIAdd(r);var n=this.curve._mulA(e),i=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),o=n.redAdd(t),a=o.redSub(r),s=n.redSub(t),u=i.redMul(a),f=o.redMul(s),c=i.redMul(s),l=a.redMul(o);return this.curve.point(u,f,l,c)},Point.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),o=this.y.redSqr();if(this.curve.twisted){var a=(f=this.curve._mulA(i)).redAdd(o);if(this.zOne)e=n.redSub(i).redSub(o).redMul(a.redSub(this.curve.two)),t=a.redMul(f.redSub(o)),r=a.redSqr().redSub(a).redSub(a);else{var s=this.z.redSqr(),u=a.redSub(s).redISub(s);e=n.redSub(i).redISub(o).redMul(u),t=a.redMul(f.redSub(o)),r=a.redMul(u)}}else{var f=i.redAdd(o);s=this.curve._mulC(this.z).redSqr(),u=f.redSub(s).redSub(s);e=this.curve._mulC(n.redISub(f)).redMul(u),t=this.curve._mulC(f).redMul(i.redISub(o)),r=f.redMul(u)}return this.curve.point(e,t,r)},Point.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),r=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),n=this.t.redMul(this.curve.dd).redMul(e.t),i=this.z.redMul(e.z.redAdd(e.z)),o=r.redSub(t),a=i.redSub(n),s=i.redAdd(n),u=r.redAdd(t),f=o.redMul(a),c=s.redMul(u),l=o.redMul(u),h=a.redMul(s);return this.curve.point(f,c,h,l)},Point.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),o=this.x.redMul(e.x),a=this.y.redMul(e.y),s=this.curve.d.redMul(o).redMul(a),u=i.redSub(s),f=i.redAdd(s),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(o).redISub(a),l=n.redMul(u).redMul(c);return this.curve.twisted?(t=n.redMul(f).redMul(a.redSub(this.curve._mulA(o))),r=u.redMul(f)):(t=n.redMul(f).redMul(a.redSub(o)),r=this.curve._mulC(u).redMul(f)),this.curve.point(l,t,r)},Point.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Point.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Point.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},Point.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Point.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var r=e.clone(),n=this.curve.redN.redMul(this.z);;){if(r.iadd(this.curve.n),r.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(n),0===this.x.cmp(t))return!0}},Point.prototype.toP=Point.prototype.normalize,Point.prototype.mixedAdd=Point.prototype.add},function(e,t,r){"use strict";t.sha1=r(309),t.sha224=r(310),t.sha256=r(169),t.sha384=r(311),t.sha512=r(170)},function(e,t,r){"use strict";var n=r(30),i=r(55),o=r(168),a=n.rotl32,s=n.sum32,u=n.sum32_5,f=o.ft_1,c=i.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function h(){if(!(this instanceof h))return new h;c.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}n.inherits(h,c),e.exports=h,h.blockSize=512,h.outSize=160,h.hmacStrength=80,h.padLength=64,h.prototype._update=function(e,t){for(var r=this.W,n=0;n<16;n++)r[n]=e[t+n];for(;nthis.blockSize&&(e=(new this.Hash).update(e).digest()),i(e.length<=this.blockSize);for(var t=e.length;t0))return a.iaddn(1),this.keyFromPrivate(a)}},l.prototype._truncateToN=function(e,t){var r=8*e.byteLength()-this.n.bitLength();return r>0&&(e=e.ushrn(r)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,r,o){"object"==typeof r&&(o=r,r=null),o||(o={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new n(e,16));for(var a=this.n.byteLength(),s=t.getPrivate().toArray("be",a),u=e.toArray("be",a),f=new i({hash:this.hash,entropy:s,nonce:u,pers:o.pers,persEnc:o.persEnc||"utf8"}),l=this.n.sub(new n(1)),h=0;;h++){var d=o.k?o.k(h):new n(f.generate(this.n.byteLength()));if(!((d=this._truncateToN(d,!0)).cmpn(1)<=0||d.cmp(l)>=0)){var p=this.g.mul(d);if(!p.isInfinity()){var g=p.getX(),y=g.umod(this.n);if(0!==y.cmpn(0)){var m=d.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(m=m.umod(this.n)).cmpn(0)){var b=(p.getY().isOdd()?1:0)|(0!==g.cmp(y)?2:0);return o.canonical&&m.cmp(this.nh)>0&&(m=this.n.sub(m),b^=1),new c({r:y,s:m,recoveryParam:b})}}}}}},l.prototype.verify=function(e,t,r,i){e=this._truncateToN(new n(e,16)),r=this.keyFromPublic(r,i);var o=(t=new c(t,"hex")).r,a=t.s;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,u=a.invm(this.n),f=u.mul(e).umod(this.n),l=u.mul(o).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),l)).isInfinity()&&s.eqXToP(o):!(s=this.g.mulAdd(f,r.getPublic(),l)).isInfinity()&&0===s.getX().umod(this.n).cmp(o)},l.prototype.recoverPubKey=function(e,t,r,i){u((3&r)===r,"The recovery param is more than two bits"),t=new c(t,i);var o=this.n,a=new n(e),s=t.r,f=t.s,l=1&r,h=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&h)throw new Error("Unable to find sencond key candinate");s=h?this.curve.pointFromX(s.add(this.curve.n),l):this.curve.pointFromX(s,l);var d=t.r.invm(o),p=o.sub(a).mul(d).umod(o),g=f.mul(d).umod(o);return this.g.mulAdd(p,s,g)},l.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new c(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var o;try{o=this.recoverPubKey(e,t,i)}catch(e){continue}if(o.eq(r))return i}throw new Error("Unable to find valid recovery factor")}},function(e,t,r){"use strict";var n=r(98),i=r(166),o=r(27);function a(e){if(!(this instanceof a))return new a(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=i.toArray(e.entropy,e.entropyEnc||"hex"),r=i.toArray(e.nonce,e.nonceEnc||"hex"),n=i.toArray(e.pers,e.persEnc||"hex");o(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}e.exports=a,a.prototype._init=function(e,t,r){var n=e.concat(t).concat(r);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var i=0;i=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(r||[])),this._reseed=1},a.prototype.generate=function(e,t,r,n){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(n=r,r=t,t=null),r&&(r=i.toArray(r,n||"hex"),this._update(r));for(var o=[];o.length"}},function(e,t,r){"use strict";var n=r(18),i=r(28),o=i.assert;function a(e,t){if(e instanceof a)return e;this._importDER(e,t)||(o(e.r&&e.s,"Signature without r or s"),this.r=new n(e.r,16),this.s=new n(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function s(){this.place=0}function u(e,t){var r=e[t.place++];if(!(128&r))return r;var n=15&r;if(0===n||n>4)return!1;for(var i=0,o=0,a=t.place;o>>=0;return!(i<=127)&&(t.place=a,i)}function f(e){for(var t=0,r=e.length-1;!e[t]&&!(128&e[t+1])&&t>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}e.exports=a,a.prototype._importDER=function(e,t){e=i.toArray(e,t);var r=new s;if(48!==e[r.place++])return!1;var o=u(e,r);if(!1===o)return!1;if(o+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var a=u(e,r);if(!1===a)return!1;var f=e.slice(r.place,a+r.place);if(r.place+=a,2!==e[r.place++])return!1;var c=u(e,r);if(!1===c)return!1;if(e.length!==c+r.place)return!1;var l=e.slice(r.place,c+r.place);if(0===f[0]){if(!(128&f[1]))return!1;f=f.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new n(f),this.s=new n(l),this.recoveryParam=null,!0},a.prototype.toDER=function(e){var t=this.r.toArray(),r=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&r[0]&&(r=[0].concat(r)),t=f(t),r=f(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];c(n,t.length),(n=n.concat(t)).push(2),c(n,r.length);var o=n.concat(r),a=[48];return c(a,o.length),a=a.concat(o),i.encode(a,e)}},function(e,t,r){"use strict";var n=r(98),i=r(97),o=r(28),a=o.assert,s=o.parseBytes,u=r(320),f=r(321);function c(e){if(a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof c))return new c(e);e=i[e].curve;this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=n.sha512}e.exports=c,c.prototype.sign=function(e,t){e=s(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),o=this.encodePoint(i),a=this.hashInt(o,r.pubBytes(),e).mul(r.priv()),u=n.add(a).umod(this.curve.n);return this.makeSignature({R:i,S:u,Rencoded:o})},c.prototype.verify=function(e,t,r){e=s(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),o=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(o)},c.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=t)throw new Error("invalid sig")}e.exports=function(e,t,r,u,f){var c=o(r);if("ec"===c.type){if("ecdsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");return function(e,t,r){var n=a[r.data.algorithm.curve.join(".")];if(!n)throw new Error("unknown curve "+r.data.algorithm.curve.join("."));var o=new i(n),s=r.data.subjectPrivateKey.data;return o.verify(t,e,s)}(e,t,c)}if("dsa"===c.type){if("dsa"!==u)throw new Error("wrong public key type");return function(e,t,r){var i=r.data.p,a=r.data.q,u=r.data.g,f=r.data.pub_key,c=o.signature.decode(e,"der"),l=c.s,h=c.r;s(l,a),s(h,a);var d=n.mont(i),p=l.invm(a);return 0===u.toRed(d).redPow(new n(t).mul(p).mod(a)).fromRed().mul(f.toRed(d).redPow(h.mul(p).mod(a)).fromRed()).mod(i).mod(a).cmp(h)}(e,t,c)}if("rsa"!==u&&"ecdsa/rsa"!==u)throw new Error("wrong public key type");t=Buffer.concat([f,t]);for(var l=c.modulus.byteLength(),h=[1],d=0;t.length+h.length+2r-l-2)throw new Error("message too long");var h=Buffer.alloc(r-n-l-2),d=r-c-1,p=i(c),g=s(Buffer.concat([f,h,Buffer.alloc(1,1),t],d),a(p,d)),y=s(p,a(g,c));return new u(Buffer.concat([Buffer.alloc(1),y,g],r))}(d,t);else if(1===l)h=function(e,t,r){var n,o=t.length,a=e.modulus.byteLength();if(o>a-11)throw new Error("message too long");n=r?Buffer.alloc(a-o-3,255):function(e){var t,r=Buffer.allocUnsafe(e),n=0,o=i(2*e),a=0;for(;n=0)throw new Error("data too long for modulus")}return r?c(h,d):f(h,d)}},function(e,t,r){var n=r(68),i=r(178),o=r(179),a=r(18),s=r(96),u=r(35),f=r(180),Buffer=r(7).Buffer;e.exports=function(e,t,r){var c;c=e.padding?e.padding:r?1:4;var l,h=n(e),d=h.modulus.byteLength();if(t.length>d||new a(t).cmp(h.modulus)>=0)throw new Error("decryption error");l=r?f(new a(t),h):s(t,h);var p=Buffer.alloc(d-l.length);if(l=Buffer.concat([p,l],d),4===c)return function(e,t){var r=e.modulus.byteLength(),n=u("sha1").update(Buffer.alloc(0)).digest(),a=n.length;if(0!==t[0])throw new Error("decryption error");var s=t.slice(1,a+1),f=t.slice(a+1),c=o(s,i(f,a)),l=o(f,i(c,r-a-1));if(function(e,t){e=Buffer.from(e),t=Buffer.from(t);var r=0,n=e.length;e.length!==t.length&&(r++,n=Math.min(e.length,t.length));var i=-1;for(;++i=t.length){o++;break}var a=t.slice(2,i-1);("0002"!==n.toString("hex")&&!r||"0001"!==n.toString("hex")&&r)&&o++;a.length<8&&o++;if(o)throw new Error("decryption error");return t.slice(i)}(0,l,r);if(3===c)return l;throw new Error("unknown padding")}},function(e,t,r){"use strict";(function(e,n){function i(){throw new Error("secure random number generation not supported by this browser\nuse chrome, FireFox or Internet Explorer 11")}var o=r(7),a=r(34),Buffer=o.Buffer,s=o.kMaxLength,u=e.crypto||e.msCrypto,f=Math.pow(2,32)-1;function c(e,t){if("number"!=typeof e||e!=e)throw new TypeError("offset must be a number");if(e>f||e<0)throw new TypeError("offset must be a uint32");if(e>s||e>t)throw new RangeError("offset out of range")}function l(e,t,r){if("number"!=typeof e||e!=e)throw new TypeError("size must be a number");if(e>f||e<0)throw new TypeError("size must be a uint32");if(e+t>r||e>s)throw new RangeError("buffer too small")}function h(e,t,r,i){if(n.browser){var o=e.buffer,s=new Uint8Array(o,t,r);return u.getRandomValues(s),i?void n.nextTick((function(){i(null,e)})):e}if(!i)return a(r).copy(e,t),e;a(r,(function(r,n){if(r)return i(r);n.copy(e,t),i(null,e)}))}u&&u.getRandomValues||!n.browser?(t.randomFill=function(t,r,n,i){if(!(Buffer.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');if("function"==typeof r)i=r,r=0,n=t.length;else if("function"==typeof n)i=n,n=t.length-r;else if("function"!=typeof i)throw new TypeError('"cb" argument must be a function');return c(r,t.length),l(n,r,t.length),h(t,r,n,i)},t.randomFillSync=function(t,r,n){void 0===r&&(r=0);if(!(Buffer.isBuffer(t)||t instanceof e.Uint8Array))throw new TypeError('"buf" argument must be a Buffer or Uint8Array');c(r,t.length),void 0===n&&(n=t.length-r);return l(n,r,t.length),h(t,r,n)}):(t.randomFill=i,t.randomFillSync=i)}).call(this,r(24),r(16))},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseReleases=t.parseFeatures=void 0;var n=r(181);t.parseFeatures=function(e){if(2===e.major_version&&!1===e.firmware_present)return e;if(2===e.major_version&&null==e.bootloader_mode)return e;if(2===e.major_version&&!0===e.bootloader_mode)return e;if(1===e.major_version&&!1===e.firmware_present)return e;if(1===e.major_version&&null===e.bootloader_mode)return e;if(1===e.major_version&&!0===e.bootloader_mode)return e;throw new Error("Features of unexpected shape provided to rollout")};var i=n.Tuple(n.Literal(2),n.Number,n.Number),o=n.Tuple(n.Literal(1),n.Number,n.Number),a=n.Record({required:n.Boolean,url:n.String,fingerprint:n.String,changelog:n.String,min_bridge_version:n.Tuple(n.Number,n.Number,n.Number),version:n.Union(o,i),min_firmware_version:n.Union(o,i),min_bootloader_version:n.Union(o,i)}).And(n.Partial({bootloader_version:n.Union(o,i),url_bitcoinonly:n.String,fingerprint_bitcoinonly:n.String,notes:n.String,rollout:n.Number,channel:n.String}));t.parseReleases=function(e){try{return e.forEach((function(e){a.check(e)})),e}catch(e){throw new Error("Release object in unexpected shape: "+e)}}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=r(57);t.Contract=function(){for(var e=[],t=0;ta.length)throw new Error("Number of `@checked` runtypes exceeds actual parameter length.");i.value=function(){for(var t=[],r=0;r=0&&S.splice(t,1)}i.emit(g.CORE_EVENT,e)},O=function(e){return void 0===e&&(e=!0),e&&I((0,y.UiMessage)(g.UI.REQUEST_UI_WINDOW)),a||(a=(0,b.create)()),a},P=function(){return u.start((function(){H("Interaction timeout")}))},M=function(e,t){var r=(0,b.create)(e,t);return E.push(r),P(),r},k=function(e,t){return E.find((function(e){return e.id===t}))},T=function(e){E=E.filter((function(t){return t!==e}))},x=function(e,t){void 0===t&&(t=!1),A.log("handle message in core",t,e);var r=[g.IFRAME.CALL,g.POPUP.CLOSED,g.UI.CUSTOM_MESSAGE_RESPONSE,g.UI.LOGIN_CHALLENGE_RESPONSE,g.TRANSPORT.DISABLE_WEBUSB];if(t||-1!==r.indexOf(e.type))switch(e.type){case g.POPUP.HANDSHAKE:O(!1).resolve();break;case g.POPUP.CLOSED:H(e.payload?e.payload.error:null);break;case g.TRANSPORT.DISABLE_WEBUSB:Y();break;case g.UI.RECEIVE_DEVICE:case g.UI.RECEIVE_CONFIRMATION:case g.UI.RECEIVE_PERMISSION:case g.UI.RECEIVE_PIN:case g.UI.RECEIVE_PASSPHRASE:case g.UI.INVALID_PASSPHRASE_ACTION:case g.UI.RECEIVE_ACCOUNT:case g.UI.CHANGE_ACCOUNT:case g.UI.RECEIVE_FEE:case g.UI.CUSTOM_MESSAGE_RESPONSE:case g.UI.RECEIVE_WORD:case g.UI.LOGIN_CHALLENGE_RESPONSE:var n=k(0,e.type);n&&(n.resolve({event:e.type,payload:e.payload}),T(n));break;case g.IFRAME.CALL:C(e).catch((function(e){A.debug("onCall error",e)}))}};t.handleMessage=x;var R=function(){var e=(0,l.default)(c.default.mark((function e(t){var r,n,i,a,u;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}throw g.ERRORS.TypedError("Transport_Missing");case 2:if(r="WebUsbPlugin"===o.transportType(),!t.devicePath){e.next=7;break}n=o.getDevice(t.devicePath),e.next=31;break;case 7:if(1!==o.length()||r){e.next=13;break}i=o.getFirstDevicePath(),n=o.getDevice(i),e.next=31;break;case 13:return M(g.UI.RECEIVE_DEVICE),e.next=16,O().promise;case 16:if(1!==o.length()||r){e.next=22;break}i=o.getFirstDevicePath(),n=o.getDevice(i),e.next=31;break;case 22:if(I((0,y.UiMessage)(g.UI.SELECT_DEVICE,{webusb:r,devices:o.asArray()})),!(a=k(t.responseID,g.UI.RECEIVE_DEVICE))){e.next=31;break}return e.next=27,a.promise;case 27:(u=e.sent).payload.remember&&(u.payload.device.state||delete u.payload.device.state,s=u.payload.device),i=u.payload.device.path,n=o.getDevice(i);case 31:if(n){e.next=33;break}throw g.ERRORS.TypedError("Device_NotFound");case 33:return e.abrupt("return",n);case 34:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),C=function(){var e=(0,l.default)(c.default.mark((function e(t){var r,n,i,a,u,f,h,p,b,v,w,_,E;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.id&&t.payload){e.next=2;break}throw g.ERRORS.TypedError("Method_InvalidParameter","onCall: message.id or message.payload is missing");case 2:r=t.id,n=d.default.getSettings("trustedHost"),i=d.default.getSettings("popup"),s&&!t.payload.device&&(t.payload.device=s),e.prev=6,(a=(0,m.find)(t)).postMessage=I,a.getPopupPromise=O,a.createUiPromise=M,a.findUiPromise=k,a.removeUiPromise=T,e.next=20;break;case 15:return e.prev=15,e.t0=e.catch(6),I((0,y.UiMessage)(g.POPUP.CANCEL_POPUP_REQUEST)),I((0,y.ResponseMessage)(r,!1,{error:e.t0})),e.abrupt("return",Promise.resolve());case 20:if(S.push(a),a.useDevice){e.next=40;break}if(e.prev=22,!a.useUi){e.next=28;break}return e.next=26,O().promise;case 26:e.next=29;break;case 28:I((0,y.UiMessage)(g.POPUP.CANCEL_POPUP_REQUEST));case 29:return e.next=31,a.run();case 31:f=e.sent,u=(0,y.ResponseMessage)(a.responseID,!0,f),e.next=38;break;case 35:e.prev=35,e.t1=e.catch(22),u=(0,y.ResponseMessage)(a.responseID,!1,{error:e.t1});case 38:return I(u),e.abrupt("return",Promise.resolve());case 40:if(o||d.default.getSettings("transportReconnect")){e.next=43;break}return e.next=43,W(d.default.getSettings());case 43:if(!i||!a.requiredPermissions.includes("management")||d.default.isManagementAllowed()){e.next=47;break}return I((0,y.UiMessage)(g.POPUP.CANCEL_POPUP_REQUEST)),I((0,y.ResponseMessage)(r,!1,{error:g.ERRORS.TypedError("Method_NotAllowed")})),e.abrupt("return",Promise.resolve());case 47:return e.prev=47,e.next=50,R(a);case 50:h=e.sent,e.next=64;break;case 53:if(e.prev=53,e.t2=e.catch(47),"Transport_Missing"!==e.t2.code){e.next=61;break}return e.next=58,O().promise;case 58:I((0,y.UiMessage)(g.UI.TRANSPORT)),e.next=62;break;case 61:I((0,y.UiMessage)(g.POPUP.CANCEL_POPUP_REQUEST));case 62:throw I((0,y.ResponseMessage)(r,!1,{error:e.t2})),e.t2;case 64:if(a.setDevice(h),!a.debugLink){e.next=79;break}return e.prev=66,e.next=69,a.run();case 69:return p=e.sent,u=(0,y.ResponseMessage)(a.responseID,!0,p),I(u),e.abrupt("return",Promise.resolve());case 75:throw e.prev=75,e.t3=e.catch(66),I((0,y.ResponseMessage)(a.responseID,!1,{error:e.t3})),e.t3;case 79:if(!((b=S.filter((function(e){return e&&e!==a&&e.devicePath===a.devicePath}))).length>0&&a.overridePreviousCall)){e.next=90;break}return b.forEach((function(e){e.overridden=!0})),v=g.ERRORS.TypedError("Method_Override"),e.next=85,h.override(v);case 85:if(!a.overridden){e.next=88;break}throw I((0,y.ResponseMessage)(a.responseID,!1,{error:v})),v;case 88:e.next=98;break;case 90:if(!h.isRunning()){e.next=98;break}if(h.isLoaded()){e.next=96;break}return e.next=94,h.waitForFirstRun();case 94:e.next=98;break;case 96:throw I((0,y.ResponseMessage)(r,!1,{error:g.ERRORS.TypedError("Device_CallInProgress")})),g.ERRORS.TypedError("Device_CallInProgress");case 98:if(h.setInstance(a.deviceInstance),a.hasExpectedDeviceState&&h.setExternalState(a.deviceState),h.on(g.DEVICE.BUTTON,(function(e,t){D(e,t,a)})),h.on(g.DEVICE.PIN,U),h.on(g.DEVICE.WORD,j),h.on(g.DEVICE.PASSPHRASE,a.useEmptyPassphrase?F:L),h.on(g.DEVICE.PASSPHRASE_ON_DEVICE,(function(){I((0,y.UiMessage)(g.UI.REQUEST_PASSPHRASE_ON_DEVICE,{device:h.toMessageObject()}))})),!o){e.next=108;break}return e.next=108,o.reconfigure(h.getVersion());case 108:return e.prev=108,w=1,3,_=function(){var e=(0,l.default)(c.default.mark((function e(){var t,r,s,f,l,d,p,m;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,a.checkFirmwareRange(i);case 2:if(!(t=e.sent)){e.next=14;break}if(!i){e.next=13;break}return e.next=7,O().promise;case 7:return I((0,y.UiMessage)(t,h.toMessageObject())),e.next=10,M(g.DEVICE.DISCONNECT,h).promise;case 10:return e.abrupt("return",Promise.reject(g.ERRORS.TypedError("Method_Cancel")));case 13:return e.abrupt("return",Promise.reject(g.ERRORS.TypedError("Device_FwException",t)));case 14:if(!(r=h.hasUnexpectedMode(a.allowDeviceMode,a.requireDeviceMode))){e.next=27;break}if(h.keepSession=!1,!i){e.next=26;break}return e.next=20,O().promise;case 20:return I((0,y.UiMessage)(r,h.toMessageObject())),e.next=23,M(g.DEVICE.DISCONNECT,h).promise;case 23:case 26:return e.abrupt("return",Promise.reject(g.ERRORS.TypedError("Device_ModeException",r)));case 27:if(a.checkPermissions(),n||!(a.requiredPermissions.length>0)){e.next=34;break}return e.next=31,a.requestPermissions();case 31:if(e.sent){e.next=34;break}return e.abrupt("return",Promise.reject(g.ERRORS.TypedError("Method_PermissionsNotGranted")));case 34:if(!(s=h.features.needs_backup)||"function"!=typeof a.noBackupConfirmation){e.next=41;break}return e.next=38,a.noBackupConfirmation();case 38:if(e.sent){e.next=41;break}return e.abrupt("return",Promise.reject(g.ERRORS.TypedError("Method_PermissionsNotGranted")));case 41:if(!s){e.next=45;break}return e.next=44,O().promise;case 44:I((0,y.UiMessage)(g.UI.DEVICE_NEEDS_BACKUP,h.toMessageObject()));case 45:if("outdated"!==h.firmwareStatus){e.next=49;break}return e.next=48,O().promise;case 48:I((0,y.UiMessage)(g.UI.FIRMWARE_OUTDATED,h.toMessageObject()));case 49:if(n||"function"!=typeof a.confirmation){e.next=55;break}return e.next=52,a.confirmation();case 52:if(e.sent){e.next=55;break}return e.abrupt("return",Promise.reject(g.ERRORS.TypedError("Method_Cancel")));case 55:if(!o){e.next=58;break}return e.next=58,o.reconfigure(h.getVersion());case 58:if(e.prev=58,!a.useDeviceState){e.next=65;break}return e.next=62,h.validateState(a.network);case 62:e.t0=e.sent,e.next=66;break;case 65:e.t0=void 0;case 66:if(!(f=e.t0)){e.next=86;break}if(!i){e.next=85;break}return l=M(g.UI.INVALID_PASSPHRASE_ACTION,h),I((0,y.UiMessage)(g.UI.INVALID_PASSPHRASE,{device:h.toMessageObject()})),e.next=73,l.promise;case 73:if(d=e.sent,!d.payload){e.next=82;break}return h.setInternalState(void 0),e.next=79,h.initialize(a.useEmptyPassphrase);case 79:return e.abrupt("return",_());case 82:h.setExternalState(f);case 83:e.next=86;break;case 85:throw g.ERRORS.TypedError("Device_InvalidState");case 86:e.next=98;break;case 88:if(e.prev=88,e.t1=e.catch(58),!(e.t1.message===g.ERRORS.INVALID_PIN_ERROR_MESSAGE&&w<3)){e.next=96;break}return w++,I((0,y.UiMessage)(g.UI.INVALID_PIN,{device:h.toMessageObject()})),e.abrupt("return",_());case 96:return h.setInternalState(void 0),e.abrupt("return",Promise.reject(e.t1));case 98:if(!a.useUi){e.next=103;break}return e.next=101,O().promise;case 101:e.next=104;break;case 103:I((0,y.UiMessage)(g.POPUP.CANCEL_POPUP_REQUEST));case 104:if(e.prev=104,p=a.getCustomMessages(),!o||!p){e.next=109;break}return e.next=109,o.reconfigure(p,!0);case 109:return e.next=111,a.run();case 111:m=e.sent,u=(0,y.ResponseMessage)(a.responseID,!0,m),e.next=118;break;case 115:return e.prev=115,e.t2=e.catch(104),e.abrupt("return",Promise.reject(e.t2));case 118:case"end":return e.stop()}}),e,null,[[58,88],[104,115]])})));return function(){return e.apply(this,arguments)}}(),e.next=114,h.run(_,{keepSession:a.keepSession,useEmptyPassphrase:a.useEmptyPassphrase,skipFinalReload:a.skipFinalReload});case 114:e.next=120;break;case 116:e.prev=116,e.t4=e.catch(108),o&&"Device_Disconnected"===e.t4.code&&o.addAuthPenalty(h),a&&(o&&e.t4.message===g.ERRORS.WRONG_PREVIOUS_SESSION_ERROR_MESSAGE&&o.enumerate(),u=(0,y.ResponseMessage)(a.responseID,!1,{error:e.t4}));case 120:if(e.prev=120,A.log("onCall::finally",u),!(E=u)){e.next=134;break}return e.next=126,h.cleanup();case 126:if(B(),N(),a&&a.dispose(),!o){e.next=133;break}return E.success&&o.removeAuthPenalty(h),e.next=133,o.restoreMessages();case 133:I(E);case 134:return e.finish(120);case 135:case"end":return e.stop()}}),e,null,[[6,15],[22,35],[47,53],[66,75],[108,116,120,135]])})));return function(t){return e.apply(this,arguments)}}();t.onCall=C;var N=function(){a=null,E=[],u.stop(),A.log("Cleanup...")},B=function(){a&&I((0,y.UiMessage)(g.POPUP.CANCEL_POPUP_REQUEST)),I((0,y.UiMessage)(g.UI.CLOSE_UI_WINDOW))},D=function(){var e=(0,l.default)(c.default.mark((function e(t,r,n){var i,o;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(!(i="ButtonRequest_Address"===r)||i&&n.useUi)){e.next=4;break}return e.next=4,O().promise;case 4:o="function"==typeof n.getButtonRequestData?n.getButtonRequestData(r):null,P(),I((0,y.DeviceMessage)(g.DEVICE.BUTTON,{device:t.toMessageObject(),code:r})),I((0,y.UiMessage)(g.UI.REQUEST_BUTTON,{device:t.toMessageObject(),code:r,data:o})),i&&!n.useUi&&I((0,y.UiMessage)(g.UI.ADDRESS_VALIDATION,o));case 9:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),U=function(){var e=(0,l.default)(c.default.mark((function e(t,r,n){var i,o,a;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O().promise;case 2:return i=M(g.UI.RECEIVE_PIN,t),I((0,y.UiMessage)(g.UI.REQUEST_PIN,{device:t.toMessageObject(),type:r})),e.next=6,i.promise;case 6:o=e.sent,a=o.payload,n(null,a);case 9:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),j=function(){var e=(0,l.default)(c.default.mark((function e(t,r,n){var i,o,a;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O().promise;case 2:return i=M(g.UI.RECEIVE_WORD,t),I((0,y.UiMessage)(g.UI.REQUEST_WORD,{device:t.toMessageObject(),type:r})),e.next=6,i.promise;case 6:o=e.sent,a=o.payload,n(null,a);case 9:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),L=function(){var e=(0,l.default)(c.default.mark((function e(t,r){var n,i,o,a,s;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,O().promise;case 2:return n=M(g.UI.RECEIVE_PASSPHRASE,t),I((0,y.UiMessage)(g.UI.REQUEST_PASSPHRASE,{device:t.toMessageObject()})),e.next=6,n.promise;case 6:i=e.sent,o=i.payload.value,a=i.payload.passphraseOnDevice,s=i.payload.save,r({passphrase:o.normalize("NFKD"),passphraseOnDevice:a,cache:s});case 11:case"end":return e.stop()}}),e)})));return function(t,r){return e.apply(this,arguments)}}(),F=function(e,t){t({passphrase:""})},H=function(e){var t=e?g.ERRORS.TypedError("Method_Cancel",e):g.ERRORS.TypedError("Method_Interrupted");o&&o.asArray().length>0?(o.allDevices().forEach((function(e){if(e.keepSession=!1,e.isUsedHere())e.interruptionFromUser(t);else{var r=k(0,g.DEVICE.DISCONNECT);r?r.resolve({event:t.message,payload:null}):(S.forEach((function(e){I((0,y.ResponseMessage)(e.responseID,!1,{error:t}))})),S.splice(0,S.length))}})),N()):(E.length>0&&(E.forEach((function(e){e.reject(t)})),E=[]),a&&(a.reject(t),a=null),N())},q=function(e){void 0===e&&(e=null);var t=k(0,g.UI.RECEIVE_DEVICE);if(t&&o){var r=o.asArray(),n=o.transportType().indexOf("webusb")>=0;1!==r.length||n?I((0,y.UiMessage)(g.UI.SELECT_DEVICE,{webusb:n,devices:r})):(t.resolve({event:g.UI.RECEIVE_DEVICE,payload:{device:r[0]}}),T(t))}if(e){var i=e.path,a=!1;E.forEach((function(e){e.device&&e.device.getDevicePath()===i&&(e.id===g.DEVICE.DISCONNECT&&e.resolve({event:g.DEVICE.DISCONNECT,payload:null}),a=!0)})),s&&s.path===i&&(s=null),a&&(B(),N())}},V=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,(o=new p.default).on(g.DEVICE.CONNECT,(function(e){q(),I((0,y.DeviceMessage)(g.DEVICE.CONNECT,e))})),o.on(g.DEVICE.CONNECT_UNACQUIRED,(function(e){q(),I((0,y.DeviceMessage)(g.DEVICE.CONNECT_UNACQUIRED,e))})),o.on(g.DEVICE.DISCONNECT,(function(e){q(e),I((0,y.DeviceMessage)(g.DEVICE.DISCONNECT,e))})),o.on(g.DEVICE.CHANGED,(function(e){I((0,y.DeviceMessage)(g.DEVICE.CHANGED,e))})),o.on(g.TRANSPORT.ERROR,function(){var e=(0,l.default)(c.default.mark((function e(r){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(A.error("TRANSPORT ERROR",r),o&&(o.disconnectDevices(),o.removeAllListeners()),o=null,I((0,y.TransportMessage)(g.TRANSPORT.ERROR,{error:r})),!t.transportReconnect){e.next=9;break}return e.next=7,(0,v.resolveAfter)(1e3,null);case 7:return e.next=9,V(t);case 9:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}()),o.on(g.TRANSPORT.START,(function(e){return I((0,y.TransportMessage)(g.TRANSPORT.START,e))})),e.next=10,o.init();case 10:if(!o){e.next=13;break}return e.next=13,o.waitForTransportFirstEvent();case 13:e.next=27;break;case 15:if(e.prev=15,e.t0=e.catch(0),o=null,I((0,y.TransportMessage)(g.TRANSPORT.ERROR,{error:e.t0})),t.transportReconnect){e.next=23;break}throw e.t0;case 23:return e.next=25,(0,v.resolveAfter)(3e3,null);case 25:return e.next=27,V(t);case 27:case"end":return e.stop()}}),e,null,[[0,15]])})));return function(t){return e.apply(this,arguments)}}(),K=function(e){function t(){return e.call(this)||this}(0,f.default)(t,e);var r=t.prototype;return r.handleMessage=function(e,t){x(e,t)},r.onBeforeUnload=function(){o&&o.onBeforeUnload(),this.removeAllListeners()},r.getCurrentMethod=function(){return S},r.getTransportInfo=function(){return o?o.getTransportInfo():{type:"",version:"",outdated:!0}},t}(h.default);t.Core=K;var z=function(){return i=new K};t.initCore=z;var G=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,e.next=3,d.default.load(t);case 3:e.next=9;break;case 5:throw e.prev=5,e.t0=e.catch(0),A.log("init error",e.t0),e.t0;case 9:case"end":return e.stop()}}),e,null,[[0,5]])})));return function(t){return e.apply(this,arguments)}}();t.initData=G;var Q=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.prev=0,A.enabled=!!t.debug,e.next=4,d.default.load(t);case 4:return e.next=6,z();case 6:return u=new _.default(t.popup?t.interactionTimeout:0),e.abrupt("return",i);case 10:throw e.prev=10,e.t0=e.catch(0),A.log("init error",e.t0),e.t0;case 14:case"end":return e.stop()}}),e,null,[[0,10]])})));return function(t){return e.apply(this,arguments)}}();t.init=Q;var W=function(){var e=(0,l.default)(c.default.mark((function e(t){return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(e.prev=0,t.transportReconnect){e.next=6;break}return e.next=4,V(t);case 4:e.next=7;break;case 6:V(t);case 7:e.next=13;break;case 9:throw e.prev=9,e.t0=e.catch(0),A.log("initTransport",e.t0),e.t0;case 13:case"end":return e.stop()}}),e,null,[[0,9]])})));return function(t){return e.apply(this,arguments)}}();t.initTransport=W;var Y=function(){var e=(0,l.default)(c.default.mark((function e(){var t;return c.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o){e.next=2;break}return e.abrupt("return");case 2:if("WebUsbPlugin"===o.transportType()){e.next=4;break}return e.abrupt("return");case 4:return(t=d.default.getSettings()).webusb=!1,e.prev=6,o.onBeforeUnload(),e.next=10,V(t);case 10:e.next=14;break;case 12:e.prev=12,e.t0=e.catch(6);case 14:case"end":return e.stop()}}),e,null,[[6,12]])})));return function(){return e.apply(this,arguments)}}()},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.getDeviceList=t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(25)),c=r(6),l=n(r(362)),h=n(r(363)),d=n(r(200)),p=n(r(32)),g=r(103),y=r(49),m=r(50),b=r(213);function v(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return w(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return w(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function w(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0&&p.default.getSettings("pendingTransportEvent")?this.emit(l.START_PENDING,n.length):this.emit(l.START)),this.listening){e.next=19;break}return e.abrupt("return");case 19:this.upcoming=n,y.debug("Listen result",n),this._reportChanges(),this.listening&&this.listen(),e.next=37;break;case 25:if(e.prev=25,e.t1=e.catch(3),i=(new Date).getTime()-this.listenTimestamp,y.debug("Listen error","timestamp",i,typeof e.t1),!(i>1100)){e.next=35;break}return e.next=32,(0,g.resolveAfter)(1e3,null);case 32:this.listening&&this.listen(),e.next=37;break;case 35:y.log("Transport error"),this.emit(l.ERROR,e.t1);case 37:case"end":return e.stop()}}),e,this,[[3,25]])})));return function(){return e.apply(this,arguments)}}(),r.enumerate=function(){var e=(0,a.default)(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.listening){e.next=2;break}return e.abrupt("return");case 2:return e.prev=2,e.next=5,this.transport.enumerate();case 5:this.upcoming=e.sent,this._reportChanges(),e.next=11;break;case 9:e.prev=9,e.t0=e.catch(2);case 11:case"end":return e.stop()}}),e,this,[[2,9]])})));return function(){return e.apply(this,arguments)}}(),r.stop=function(){this.listening=!1},r._diff=function(e,t){var r=e||[],n=t.filter((function(e){return void 0===r.find((function(t){return t.path===e.path}))})),i=r.filter((function(e){return void 0===t.find((function(t){return t.path===e.path}))})),o=t.filter((function(e){var t=r.find((function(t){return t.path===e.path}));return!!t&&t.session!==e.session})),a=o.filter((function(e){return"string"==typeof e.session})),s=o.filter((function(e){return"string"!=typeof e.session})),u=t.filter((function(e){var t=r.find((function(t){return t.path===e.path}));return!!t&&t.debugSession!==e.debugSession})),f=o.filter((function(e){return"string"==typeof e.debugSession})),c=o.filter((function(e){return"string"!=typeof e.debugSession}));return{connected:n,disconnected:i,changedSessions:o,acquired:a,released:s,changedDebugSessions:u,debugAcquired:f,debugReleased:c,didUpdate:n.length+i.length+o.length+u.length>0,descriptors:t}},r._reportChanges=function(){var e=this,t=this._diff(this.current,this.upcoming);this.current=this.upcoming,t.didUpdate&&this.listening&&(t.connected.forEach((function(t){e.emit(h.CONNECT,t)})),t.disconnected.forEach((function(t){e.emit(h.DISCONNECT,t)})),t.acquired.forEach((function(t){e.emit(h.ACQUIRED,t)})),t.released.forEach((function(t){e.emit(h.RELEASED,t)})),t.changedSessions.forEach((function(t){e.emit(h.CHANGED,t)})),this.emit(l.UPDATE,t))},t}(c.default);t.default=m},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(25)),c=n(r(185)),l=r(6),h=r(199),d=n(r(32)),p=r(8),g=r(80),y=r(418),m=r(48);function b(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function v(e){for(var t=1;t0&&this.emit(l.DEVICE.ACQUIRED),o=this.commands&&!this.commands.disposed,n||o?n===this.activitySessionID?(w.debug("ACQUIRED BY MYSELF"),this.deferredActions[l.DEVICE.ACQUIRE]&&this.deferredActions[l.DEVICE.ACQUIRE].resolve()):(w.debug("ACQUIRED BY OTHER"),this.interruptionFromOutside()):(r===this.activitySessionID?(w.debug("RELEASED BY MYSELF"),this.deferredActions[l.DEVICE.RELEASE]&&(this.deferredActions[l.DEVICE.RELEASE].resolve(),delete this.deferredActions[l.DEVICE.RELEASE]),this.activitySessionID=null):(w.debug("RELEASED BY OTHER APP"),this.featuresNeedsReload=!0),this.keepSession=!1),this.originalDescriptor=t;case 12:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.disconnect=function(){w.debug("DISCONNECT CLEANUP!"),this.deferredActions[l.DEVICE.RELEASE]&&(this.deferredActions[l.DEVICE.RELEASE].resolve(),delete this.deferredActions[l.DEVICE.RELEASE]),this.interruptionFromUser(l.ERRORS.TypedError("Device_Disconnected")),this.runPromise=null},r.isBootloader=function(){return this.features&&!!this.features.bootloader_mode},r.isInitialized=function(){return this.features&&!!this.features.initialized},r.isSeedless=function(){return this.features&&!!this.features.no_backup},r.isInconsistent=function(){return this.inconsistent},r.getVersion=function(){return this.features?[this.features.major_version,this.features.minor_version,this.features.patch_version]:[]},r.atLeast=function(e){if(!this.features)return!1;var t="string"==typeof e?e:e[this.features.major_version-1];return(0,m.versionCompare)(this.getVersion(),t)>=0},r.isUsed=function(){return"string"==typeof this.originalDescriptor.session},r.isUsedHere=function(){return this.isUsed()&&this.originalDescriptor.session===this.activitySessionID},r.isUsedElsewhere=function(){return this.isUsed()&&!this.isUsedHere()},r.isRunning=function(){return!!this.runPromise},r.isLoaded=function(){return this.loaded},r.waitForFirstRun=function(){return this.firstRunPromise.promise},r.getDevicePath=function(){return this.originalDescriptor.path},r.needAuthentication=function(){if(this.isUnacquired()||this.isUsedElsewhere()||this.featuresNeedsReload)return!0;if(this.features.bootloader_mode||!this.features.initialized)return!0;var e=!this.features.pin_protection||!!this.features.unlocked,t=!this.features.passphrase_protection||this.features.passphrase_cached;return e&&t},r.isT1=function(){return!!this.features&&1===this.features.major_version},r.hasUnexpectedMode=function(e,t){if(this.features){if(this.isBootloader()&&!e.includes(l.UI.BOOTLOADER))return l.UI.BOOTLOADER;if(!this.isInitialized()&&!e.includes(l.UI.INITIALIZE))return l.UI.INITIALIZE;if(this.isSeedless()&&!e.includes(l.UI.SEEDLESS))return l.UI.SEEDLESS;if(!this.isBootloader()&&t.includes(l.UI.BOOTLOADER))return l.UI.NOT_IN_BOOTLOADER}return null},r.onBeforeUnload=function(){if(this.isUsedHere()&&this.activitySessionID)try{this.commands&&this.commands.cancel(),this.transport.release(this.activitySessionID,!0,!1)}catch(e){}},r.getMode=function(){return this.features.bootloader_mode?"bootloader":this.features.initialized?this.features.no_backup?"seedless":"normal":"initialize"},r.toMessageObject=function(){if(this.originalDescriptor.path===l.DEVICE.UNREADABLE)return{type:"unreadable",path:this.originalDescriptor.path,label:"Unreadable device"};if(this.isUnacquired())return{type:"unacquired",path:this.originalDescriptor.path,label:"Unacquired device"};var e=""!==this.features.label&&this.features.label?this.features.label:"My Trezor";return{type:"acquired",id:this.features.device_id||null,path:this.originalDescriptor.path,label:e,state:this.getExternalState(),status:this.isUsedElsewhere()?"occupied":this.featuresNeedsReload?"used":"available",mode:this.getMode(),firmware:this.firmwareStatus,firmwareRelease:this.firmwareRelease,features:this.features,unavailableCapabilities:this.unavailableCapabilities}},r._getNetworkTypeState=function(){return this.networkTypeState[this.instance]},r._setNetworkTypeState=function(e){"string"!=typeof e?delete this.networkTypeState[this.instance]:this.networkTypeState[this.instance]=e},r._altModeChange=function(e){var t=this._isAltModeNetworkType(this._getNetworkTypeState()),r=this._isAltModeNetworkType(e);return this._setNetworkTypeState(e),t!==r},r._isAltModeNetworkType=function(e){return[l.NETWORK.TYPES.cardano].includes(e)},r.legacyForceRelease=function(){var e=(0,o.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.isUsedHere()){e.next=7;break}return e.next=3,this.acquire();case 3:return e.next=5,this.getFeatures();case 5:return e.next=7,this.release();case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(f.default);t.default=_},function(e,t,r){(function(Buffer){var t=r(105),n=r(187);function i(e){return Buffer.isBuffer(e)}function o(e){return"string"==typeof e&&/^([0-9a-f]{2})+$/i.test(e)}function a(e,t){var r=e.toJSON();function i(i){if(!e(i))return!1;if(i.length===t)return!0;throw n.tfCustomError(r+"(Length: "+t+")",r+"(Length: "+i.length+")")}return i.toJSON=function(){return r},i}var s=a.bind(null,t.Array),u=a.bind(null,i),f=a.bind(null,o),c=a.bind(null,t.String);var l=Math.pow(2,53)-1;var h={ArrayN:s,Buffer:i,BufferN:u,Finite:function(e){return"number"==typeof e&&isFinite(e)},Hex:o,HexN:f,Int8:function(e){return e<<24>>24===e},Int16:function(e){return e<<16>>16===e},Int32:function(e){return(0|e)===e},Int53:function(e){return"number"==typeof e&&e>=-l&&e<=l&&Math.floor(e)===e},Range:function(e,r,n){function i(t,i){return n(t,i)&&t>e&&t>>0===e},UInt53:function(e){return"number"==typeof e&&e>=0&&e<=l&&Math.floor(e)===e}};for(var d in h)h[d].toJSON=function(e){return e}.bind(null,d);e.exports=h}).call(this,r(9).Buffer)},function(e,t,r){var n=r(26),i={};for(var o in n){i[n[o]]=o}e.exports=i},function(e,t,r){var Buffer=r(7).Buffer,n=r(19),i=r(189),o=r(15),a=r(26);function s(e){return e===a.OP_0||n.isCanonicalSignature(e)}function u(e,t){var r=n.decompile(e);return!(r.length<2)&&(r[0]===a.OP_0&&(t?r.slice(1).every(s):r.slice(1).every(n.isCanonicalSignature)))}u.toJSON=function(){return"multisig input"};var f=Buffer.allocUnsafe(0);function c(e,t){if(o([s],e),t){var r=i.decode(t);if(e.lengthr.pubKeys.length)throw new TypeError("Too many signatures provided")}return[].concat(f,e.map((function(e){return e===a.OP_0?f:e})))}function l(e,t){return o(u,e,t),e.slice(1)}e.exports={check:u,decode:function(e,t){return l(n.decompile(e),t)},decodeStack:l,encode:function(e,t){return n.compile(c(e,t))},encodeStack:c}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26);function s(e){var t=n.compile(e);return t.length>1&&t[0]===a.OP_RETURN}s.toJSON=function(){return"null data output"},e.exports={output:{check:s,decode:function(e){o(s,e);var t=n.decompile(e);return t.shift(),1===t.length?t[0]:t},encode:function(e){return o(o.oneOf(i.Buffer,i.Array),e),n.compile([a.OP_RETURN].concat(e))}}}},function(e,t,r){var n=r(19),i=r(15);function o(e){var t=n.decompile(e);return 1===t.length&&n.isCanonicalSignature(t[0])}function a(e){return i(n.isCanonicalSignature,e),[e]}function s(e){return i(o,e),e[0]}o.toJSON=function(){return"pubKey input"},e.exports={check:o,decode:function(e){return s(n.decompile(e))},decodeStack:s,encode:function(e){return n.compile(a(e))},encodeStack:a}},function(e,t,r){var n=r(19),i=r(15),o=r(26);function a(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalPubKey(t[0])&&t[1]===o.OP_CHECKSIG}a.toJSON=function(){return"pubKey output"},e.exports={check:a,decode:function(e){var t=n.decompile(e);return i(a,t),t[0]},encode:function(e){return i(n.isCanonicalPubKey,e),n.compile([e,o.OP_CHECKSIG])}}},function(e,t,r){var n=r(19),i=r(15);function o(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&n.isCanonicalPubKey(t[1])}function a(e,t){return i({signature:n.isCanonicalSignature,pubKey:n.isCanonicalPubKey},{signature:e,pubKey:t}),[e,t]}function s(e){return i(o,e),{signature:e[0],pubKey:e[1]}}o.toJSON=function(){return"pubKeyHash input"},e.exports={check:o,decode:function(e){return s(n.decompile(e))},decodeStack:s,encode:function(e,t){return n.compile(a(e,t))},encodeStack:a}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26);function s(e){var t=n.compile(e);return 25===t.length&&t[0]===a.OP_DUP&&t[1]===a.OP_HASH160&&20===t[2]&&t[23]===a.OP_EQUALVERIFY&&t[24]===a.OP_CHECKSIG}s.toJSON=function(){return"pubKeyHash output"},e.exports={check:s,decode:function(e){return o(s,e),e.slice(3,23)},encode:function(e){return o(i.Hash160bit,e),n.compile([a.OP_DUP,a.OP_HASH160,e,a.OP_EQUALVERIFY,a.OP_CHECKSIG])}}},function(e,t,r){e.exports={input:r(373),output:r(374)}},function(e,t,r){var Buffer=r(7).Buffer,n=r(19),i=r(15),o=r(107),a=r(108),s=r(109),u=r(190),f=r(191);function c(e,t){var r=n.decompile(e);if(r.length<1)return!1;var i=r[r.length-1];if(!Buffer.isBuffer(i))return!1;var c=n.decompile(n.compile(r.slice(0,-1))),l=n.decompile(i);return 0!==l.length&&(!!n.isPushOnly(c)&&(1===r.length?f.check(l)||u.check(l):!(!s.input.check(c)||!s.output.check(l))||(!(!o.input.check(c,t)||!o.output.check(l))||!(!a.input.check(c)||!a.output.check(l)))))}function l(e,t){var r=n.compile(t);return[].concat(e,r)}function h(e){return i(c,e),{redeemScriptStack:e.slice(0,-1),redeemScript:e[e.length-1]}}c.toJSON=function(){return"scriptHash input"},e.exports={check:c,decode:function(e){var t=h(n.decompile(e));return t.redeemScriptSig=n.compile(t.redeemScriptStack),delete t.redeemScriptStack,t},decodeStack:h,encode:function(e,t){var r=n.decompile(e);return n.compile(l(r,t))},encodeStack:l}},function(e,t,r){var n=r(19),i=r(22),o=r(15),a=r(26);function s(e){var t=n.compile(e);return 23===t.length&&t[0]===a.OP_HASH160&&20===t[1]&&t[22]===a.OP_EQUAL}s.toJSON=function(){return"scriptHash output"},e.exports={check:s,decode:function(e){return o(s,e),e.slice(2,22)},encode:function(e){return o(i.Hash160bit,e),n.compile([a.OP_HASH160,e,a.OP_EQUAL])}}},function(e,t,r){e.exports={input:r(376),output:r(190)}},function(e,t,r){var n=r(19),i=r(15);function o(e){return n.isCanonicalPubKey(e)&&33===e.length}function a(e){var t=n.decompile(e);return 2===t.length&&n.isCanonicalSignature(t[0])&&o(t[1])}a.toJSON=function(){return"witnessPubKeyHash input"},e.exports={check:a,decodeStack:function(e){return i(a,e),{signature:e[0],pubKey:e[1]}},encodeStack:function(e,t){return i({signature:n.isCanonicalSignature,pubKey:o},{signature:e,pubKey:t}),[e,t]}}},function(e,t,r){e.exports={input:r(378),output:r(191)}},function(e,t,r){(function(Buffer){var t=r(19),n=r(22),i=r(15),o=r(107),a=r(108),s=r(109);function u(e,r){if(i(n.Array,e),e.length<1)return!1;var u=e[e.length-1];if(!Buffer.isBuffer(u))return!1;var f=t.decompile(u);if(0===f.length)return!1;var c=t.compile(e.slice(0,-1));return!(!s.input.check(c)||!s.output.check(f))||(!(!o.input.check(c,r)||!o.output.check(f))||!(!a.input.check(c)||!a.output.check(f)))}u.toJSON=function(){return"witnessScriptHash input"},e.exports={check:u,decodeStack:function(e){return i(u,e),{witnessData:e.slice(0,-1),witnessScript:e[e.length-1]}},encodeStack:function(e,t){return i({witnessData:[n.Buffer],witnessScript:n.Buffer},{witnessData:e,witnessScript:t}),[].concat(e,t)}}}).call(this,r(9).Buffer)},function(e,t,r){e.exports={output:r(380)}},function(e,t,r){var Buffer=r(7).Buffer,n=r(19),i=r(22),o=r(15),a=r(26),s=Buffer.from("aa21a9ed","hex");function u(e){var t=n.compile(e);return t.length>37&&t[0]===a.OP_RETURN&&36===t[1]&&t.slice(2,6).equals(s)}u.toJSON=function(){return"Witness commitment output"},e.exports={check:u,decode:function(e){return o(u,e),n.decompile(e)[1].slice(4,36)},encode:function(e){o(i.Hash256bit,e);var t=Buffer.allocUnsafe(36);return s.copy(t,0),e.copy(t,4),n.compile([a.OP_RETURN,t])}}},function(e){e.exports=JSON.parse('{"name":"bigi","version":"1.4.2","description":"Big integers.","keywords":["cryptography","math","bitcoin","arbitrary","precision","arithmetic","big","integer","int","number","biginteger","bigint","bignumber","decimal","float"],"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.5","jshint":"^2.5.1","mocha":"^2.1.0","mochify":"^2.1.0"},"repository":{"url":"https://github.com/cryptocoinjs/bigi","type":"git"},"main":"./lib/index.js","scripts":{"browser-test":"./node_modules/.bin/mochify --wd -R spec","test":"./node_modules/.bin/_mocha -- test/*.js","jshint":"./node_modules/.bin/jshint --config jshint.json lib/*.js ; true","unit":"./node_modules/.bin/mocha","coverage":"./node_modules/.bin/istanbul cover ./node_modules/.bin/_mocha -- --reporter list test/*.js","coveralls":"npm run-script coverage && node ./node_modules/.bin/coveralls < coverage/lcov.info"},"dependencies":{},"testling":{"files":"test/*.js","harness":"mocha","browsers":["ie/9..latest","firefox/latest","chrome/latest","safari/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]}}')},function(e,t,r){(function(Buffer){var e=r(111),BigInteger=r(192);BigInteger.fromByteArrayUnsigned=function(e){return 128&e[0]?new BigInteger([0].concat(e)):new BigInteger(e)},BigInteger.prototype.toByteArrayUnsigned=function(){var e=this.toByteArray();return 0===e[0]?e.slice(1):e},BigInteger.fromDERInteger=function(e){return new BigInteger(e)},BigInteger.prototype.toDERInteger=BigInteger.prototype.toByteArray,BigInteger.fromBuffer=function(e){if(128&e[0]){var t=Array.prototype.slice.call(e);return new BigInteger([0].concat(t))}return new BigInteger(e)},BigInteger.fromHex=function(t){return""===t?BigInteger.ZERO:(e.equal(t,t.match(/^[A-Fa-f0-9]+/),"Invalid hex string"),e.equal(t.length%2,0,"Incomplete hex"),new BigInteger(t,16))},BigInteger.prototype.toBuffer=function(e){for(var t=this.toByteArrayUnsigned(),r=[],n=e-t.length;r.length=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&t._extend(n,r),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),c(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function f(e,t){return e}function c(e,r,n){if(e.customInspect&&r&&S(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return m(i)||(i=c(e,i,n)),i}var o=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(g(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(y(t))return e.stylize("null","null")}(e,r);if(o)return o;var a=Object.keys(r),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),E(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(r);if(0===a.length){if(S(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(v(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return e.stylize(Date.prototype.toString.call(r),"date");if(E(r))return l(r)}var f,w="",A=!1,I=["{","}"];(d(r)&&(A=!0,I=["[","]"]),S(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(w=" "+RegExp.prototype.toString.call(r)),_(r)&&(w=" "+Date.prototype.toUTCString.call(r)),E(r)&&(w=" "+l(r)),0!==a.length||A&&0!=r.length?n<0?v(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),f=A?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,w,I)):I[0]+w+I[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=y(r)?c(e,u.value,null):c(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),b(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function y(e){return null===e}function g(e){return"number"==typeof e}function m(e){return"string"==typeof e}function b(e){return void 0===e}function v(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===A(e)}function E(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function S(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function I(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(r){if(b(o)&&(o=e.env.NODE_DEBUG||""),r=r.toUpperCase(),!a[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=e.pid;a[r]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",r,n,e)}}else a[r]=function(){};return a[r]},t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=p,t.isNull=y,t.isNullOrUndefined=function(e){return null==e},t.isNumber=g,t.isString=m,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=b,t.isRegExp=v,t.isObject=w,t.isDate=_,t.isError=E,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(385);var O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date,t=[I(e.getHours()),I(e.getMinutes()),I(e.getSeconds())].join(":");return[e.getDate(),O[e.getMonth()],t].join(" ")}function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",P(),t.format.apply(t,arguments))},t.inherits=r(386),t._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var k="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(k&&e[k]){var t;if("function"!=typeof(t=e[k]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,k,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o=0))break;u=u*n+c,a=a*n+Math.floor(u/s),u%=s}f&&(a=~a,u?u=s-u:a++);C(e,t+w,a),C(e,t+_,u)}(r,a,u,f||10):h(u,f)?d(r,a,u,f):"number"==typeof f?(C(r,a+w,u),C(r,a+_,f)):u>0?O(r,a,u):u<0?P(r,a,u):d(r,a,o,0)}(this,e,r,a,u):new x(e,r,a,u)}function R(){var e=this.buffer,t=this.offset,r=N(e,t+w),n=N(e,t+_);return v||(r|=0),r?r*s+n:n}function C(e,t,r){e[t+I]=255&r,r>>=8,e[t+A]=255&r,r>>=8,e[t+S]=255&r,r>>=8,e[t+E]=255&r}function N(e,t){return 16777216*e[t+E]+(e[t+S]<<16)+(e[t+A]<<8)+e[t+I]}}function f(e){var r=this.buffer,n=this.offset;return t=null,!1!==e&&a(r)?8===r.length?r:r.slice(n,n+8):p(r,n)}function c(e){var n=this.buffer,i=this.offset;return t=r,!1!==e&&r.isBuffer(n)?8===n.length?n:n.slice(i,i+8):r.from(l.call(this,e))}function l(e){var r=this.buffer,o=this.offset,a=r.buffer;if(t=n,!1!==e&&!r.offset&&a instanceof i)return 8===a.byteLength?a:a.slice(o,o+8);var s=new n(8);return d(s,0,r,o),s.buffer}function h(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function d(e,t,r,n){t|=0,n|=0;for(var i=0;i<8;i++)e[t++]=255&r[n++]}function p(e,t){return Array.prototype.slice.call(e,t,t+8)}function y(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}function g(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}function m(e,t,r){for(var n=t+8;t>24)-3,r=8388607&e,n=Buffer.alloc(32,0);return t<0?(r>>=8*Math.abs(t),n.writeUInt32BE(r,28)):t>28?(r<<=8*(t-28),n.writeUInt32BE(r,0)):n.writeUInt32BE(r,28-t),n},l.calculateMerkleRoot=function(e){if(o([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map((function(e){return e.getHash()}));return i(t,n.hash256)},l.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=l.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},l.prototype.checkProofOfWork=function(){var e=this.getHash().reverse(),t=l.calculateTarget(this.bits);return e.compare(t)<=0},e.exports=l},function(e,t,r){(function(Buffer){e.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var r=e.length,n=e.concat();r>1;){for(var i=0,o=0;o=4294967296&&i++,e[t]=n,e[t+1]=i}function a(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var o=e[t+1]+n;i>=4294967296&&o++,e[t]=i,e[t+1]=o}function s(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function u(e,t,r,n,i,s){var u=h[i],f=h[i+1],c=h[s],d=h[s+1];o(l,e,t),a(l,e,u,f);var p=l[n]^l[e],y=l[n+1]^l[e+1];l[n]=y,l[n+1]=p,o(l,r,n),p=l[t]^l[r],y=l[t+1]^l[r+1],l[t]=p>>>24^y<<8,l[t+1]=y>>>24^p<<8,o(l,e,t),a(l,e,c,d),p=l[n]^l[e],y=l[n+1]^l[e+1],l[n]=p>>>16^y<<16,l[n+1]=y>>>16^p<<16,o(l,r,n),p=l[t]^l[r],y=l[t+1]^l[r+1],l[t]=y>>>31^p<<1,l[t+1]=p>>>31^y<<1}var f=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),l=new Uint32Array(32),h=new Uint32Array(32);function d(e,t){var r=0;for(r=0;r<16;r++)l[r]=e.h[r],l[r+16]=f[r];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,t&&(l[28]=~l[28],l[29]=~l[29]),r=0;r<32;r++)h[r]=s(e.b,4*r);for(r=0;r<12;r++)u(0,8,16,24,c[16*r+0],c[16*r+1]),u(2,10,18,26,c[16*r+2],c[16*r+3]),u(4,12,20,28,c[16*r+4],c[16*r+5]),u(6,14,22,30,c[16*r+6],c[16*r+7]),u(0,10,20,30,c[16*r+8],c[16*r+9]),u(2,12,22,24,c[16*r+10],c[16*r+11]),u(4,14,16,26,c[16*r+12],c[16*r+13]),u(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^l[r]^l[r+16]}var p=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function y(e,t,r,n){p.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=e,p[0]=e,t&&(p[1]=t.length),p[2]=1,p[3]=1,r&&p.set(r,32),n&&p.set(n,48);for(var i=0;i<16;i++)this.h[i]=f[i]^s(p,4*i);t&&(g(this,t),this.c=128)}function g(e,t){for(var r=0;r=this.outlen,"out must have at least outlen bytes of space"),function(e,t){e.t+=e.c;for(;e.c<128;)e.b[e.c++]=0;d(e,!0);for(var r=0;r>2]>>8*(3&r)}(this,t),"hex"===e?function(e){for(var t="",r=0;r=v,"outlen must be at least "+v+", was given "+e),n(e<=w,"outlen must be at most "+w+", was given "+e),null!=t&&n(t.length>=_,"key must be at least "+_+", was given "+t.length),null!=t&&n(t.length<=E,"key must be at most "+E+", was given "+t.length),null!=r&&n(r.length===S,"salt must be exactly "+S+", was given "+r.length),null!=i&&n(i.length===A,"personal must be exactly "+A+", was given "+i.length)),new b(e,t,r,i)},e.exports.ready=function(e){i.ready((function(){e()}))},e.exports.WASM_SUPPORTED=i.SUPPORTED,e.exports.WASM_LOADED=!1;var v=e.exports.BYTES_MIN=16,w=e.exports.BYTES_MAX=64,_=(e.exports.BYTES=32,e.exports.KEYBYTES_MIN=16),E=e.exports.KEYBYTES_MAX=64,S=(e.exports.KEYBYTES=32,e.exports.SALTBYTES=16),A=e.exports.PERSONALBYTES=16;i.ready((function(t){t||(e.exports.WASM_LOADED=!0,b=i)}))},function(e,t,r){var n=r(194),i=r(393)(),o=64,a=[];e.exports=d;var s=e.exports.BYTES_MIN=16,u=e.exports.BYTES_MAX=64,f=(e.exports.BYTES=32,e.exports.KEYBYTES_MIN=16),c=e.exports.KEYBYTES_MAX=64,l=(e.exports.KEYBYTES=32,e.exports.SALTBYTES=16),h=e.exports.PERSONALBYTES=16;function d(e,t,r,p,y){if(!(this instanceof d))return new d(e,t,r,p,y);if(!i||!i.exports)throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");e||(e=32),!0!==y&&(n(e>=s,"digestLength must be at least "+s+", was given "+e),n(e<=u,"digestLength must be at most "+u+", was given "+e),null!=t&&n(t.length>=f,"key must be at least "+f+", was given "+t.length),null!=t&&n(t.length<=c,"key must be at least "+c+", was given "+t.length),null!=r&&n(r.length===l,"salt must be exactly "+l+", was given "+r.length),null!=p&&n(p.length===h,"personal must be exactly "+h+", was given "+p.length)),a.length||(a.push(o),o+=216),this.digestLength=e,this.finalized=!1,this.pointer=a.pop(),i.memory.fill(0,0,64),i.memory[0]=this.digestLength,i.memory[1]=t?t.length:0,i.memory[2]=1,i.memory[3]=1,r&&i.memory.set(r,32),p&&i.memory.set(p,48),this.pointer+216>i.memory.length&&i.realloc(this.pointer+216),i.exports.blake2b_init(this.pointer,this.digestLength),t&&(this.update(t),i.memory.fill(0,o,o+t.length),i.memory[this.pointer+200]=128)}function p(){}function y(e){return e<16?"0"+e.toString(16):e.toString(16)}d.prototype.update=function(e){return n(!1===this.finalized,"Hash instance finalized"),n(e,"input must be TypedArray or Buffer"),o+e.length>i.memory.length&&i.realloc(o+e.length),i.memory.set(e,o),i.exports.blake2b_update(this.pointer,o,o+e.length),this},d.prototype.digest=function(e){if(n(!1===this.finalized,"Hash instance finalized"),this.finalized=!0,a.push(this.pointer),i.exports.blake2b_final(this.pointer),!e||"binary"===e)return i.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if("hex"===e)return function(e,t,r){for(var n="",i=0;i=this.digestLength,"input must be TypedArray or Buffer");for(var t=0;t>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function a(e){let t=1;for(let r=0;r126)throw new Error("Invalid prefix ("+e+")");t=o(t)^n>>5}t=o(t);for(let r=0;r=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");let t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);let n=(e=t).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+e);let s=e.slice(0,n),u=e.slice(n+1);if(u.length<6)throw new Error("Data too short");let f=a(s),c=[];for(let e=0;e=u.length||c.push(r)}if(1!==f)throw new Error("Invalid checksum for "+e);return{prefix:s,words:c}},encode:function(e,t){if(e.length+7+t.length>90)throw new TypeError("Exceeds Bech32 maximum length");let r=a(e=e.toLowerCase()),i=e+"1";for(let e=0;e>5!=0)throw new Error("Non 5-bit word");r=o(r)^a,i+=n.charAt(a)}for(let e=0;e<6;++e)r=o(r);r^=1;for(let e=0;e<6;++e){i+=n.charAt(r>>5*(5-e)&31)}return i},toWords:function(e){return s(e,8,5,!0)},fromWords:function(e){return s(e,5,8,!1)}}},function(e,t,r){"use strict";var n=r(195),Buffer=r(7).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(Buffer.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){"use strict";var n=r(7).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==e[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var y=n.allocUnsafe(i+(a-p));y.fill(0,0,i);for(var g=i;p!==a;)y[g++]=c[p++];return y}}}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,a=t.length;o!==a&&0===t[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=t[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var y=f-i;y!==f&&0===l[y];)y++;for(var g=u.repeat(r);y=0||!r(l);)a=n("sha256",a).update(c).update(s).digest(),c=n("sha256",a).update(c).digest(),c=n("sha256",a).update(c).digest(),l=BigInteger.fromBuffer(c);return l}var l=f.n.shiftRight(1);e.exports={deterministicGenerateK:c,sign:function(e,t){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,s=t.toBuffer(32),u=BigInteger.fromBuffer(e),h=f.n,d=f.G;return c(e,s,(function(e){var i=d.multiply(e);return!f.isInfinity(i)&&(0!==(r=i.affineX.mod(h)).signum()&&0!==(n=e.modInverse(h).multiply(u.add(t.multiply(r))).mod(h)).signum())})),n.compareTo(l)>0&&(n=h.subtract(n)),new a(r,n)},verify:function(e,t,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=f.n,a=f.G,s=t.r,u=t.s;if(s.signum()<=0||s.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var c=BigInteger.fromBuffer(e),l=u.modInverse(n),h=c.multiply(l).mod(n),d=s.multiply(l).mod(n),p=a.multiplyTwo(h,r,d);if(f.isInfinity(p))return!1;var y=p.affineX,g=y.mod(n);return g.equals(s)},__curve:f}},function(e,t,r){var BigInteger=r(37),n=r(399),i=r(197);e.exports=function(e){var t=n[e];if(!t)return null;var r=new BigInteger(t.p,16),o=new BigInteger(t.a,16),a=new BigInteger(t.b,16),s=new BigInteger(t.n,16),u=new BigInteger(t.h,16),f=new BigInteger(t.Gx,16),c=new BigInteger(t.Gy,16);return new i(r,o,a,f,c,s,u)}},function(e){e.exports=JSON.parse('{"secp128r1":{"p":"fffffffdffffffffffffffffffffffff","a":"fffffffdfffffffffffffffffffffffc","b":"e87579c11079f43dd824993c2cee5ed3","n":"fffffffe0000000075a30d1b9038a115","h":"01","Gx":"161ff7528b899b2d0c28607ca52c5b86","Gy":"cf5ac8395bafeb13c02da292dded7a83"},"secp160k1":{"p":"fffffffffffffffffffffffffffffffeffffac73","a":"00","b":"07","n":"0100000000000000000001b8fa16dfab9aca16b6b3","h":"01","Gx":"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb","Gy":"938cf935318fdced6bc28286531733c3f03c4fee"},"secp160r1":{"p":"ffffffffffffffffffffffffffffffff7fffffff","a":"ffffffffffffffffffffffffffffffff7ffffffc","b":"1c97befc54bd7a8b65acf89f81d4d4adc565fa45","n":"0100000000000000000001f4c8f927aed3ca752257","h":"01","Gx":"4a96b5688ef573284664698968c38bb913cbfc82","Gy":"23a628553168947d59dcc912042351377ac5fb32"},"secp192k1":{"p":"fffffffffffffffffffffffffffffffffffffffeffffee37","a":"00","b":"03","n":"fffffffffffffffffffffffe26f2fc170f69466a74defd8d","h":"01","Gx":"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d","Gy":"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},"secp192r1":{"p":"fffffffffffffffffffffffffffffffeffffffffffffffff","a":"fffffffffffffffffffffffffffffffefffffffffffffffc","b":"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","n":"ffffffffffffffffffffffff99def836146bc9b1b4d22831","h":"01","Gx":"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","Gy":"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},"secp256k1":{"p":"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","a":"00","b":"07","n":"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141","h":"01","Gx":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","Gy":"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},"secp256r1":{"p":"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff","a":"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc","b":"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","n":"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551","h":"01","Gx":"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","Gy":"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}')},function(e,t,r){(function(Buffer){var t=r(60);function n(e,t){if(void 0!==t&&e[0]!==t)throw new Error("Invalid network version");if(33===e.length)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(34!==e.length)throw new Error("Invalid WIF length");if(1!==e[33])throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function i(e,t,r){var n=new Buffer(r?34:33);return n.writeUInt8(e,0),t.copy(n,1),r&&(n[33]=1),n}e.exports={decode:function(e,r){return n(t.decode(e),r)},decodeRaw:n,encode:function(e,r,n){return"number"==typeof e?t.encode(i(e,r,n)):t.encode(i(e.version,e.privateKey,e.compressed))},encodeRaw:i}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";e.exports=r(402)(r(405))},function(e,t,r){"use strict";var n=r(403),i=r(404),o=r(199);function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}e.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=r)throw RangeError(n)}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var Buffer=r(7).Buffer,n=r(105),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);t.privateKeyExport=function(e,t,r){var n=Buffer.from(r?i:o);return e.copy(n,r?8:9),t.copy(n,r?181:214),n},t.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[i]&&!(128&t[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),e.s]),a=33,s=0;a>1&&0===o[s]&&!(128&o[s+1]);--a,++s);return n.encode(t.slice(i),o.slice(s))},t.signatureImport=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(e);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(e){return}return i.r.copy(t,32-i.r.length),i.s.copy(r,32-i.s.length),{r:t,s:r}},t.signatureImportLax=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=e.length,i=0;if(48===e[i++]){var o=e[i++];if(!(128&o&&(i+=o-128)>n)&&2===e[i++]){var a=e[i++];if(128&a){if(i+(o=a-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(a=0;o>0;i+=1,o-=1)a=(a<<8)+e[i]}if(!(a>n-i)){var s=i;if(i+=a,2===e[i++]){var u=e[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+e[i]}if(!(u>n-i)){var f=i;for(i+=u;a>0&&0===e[s];a-=1,s+=1);if(!(a>32)){var c=e.slice(s,s+a);for(c.copy(t,32-c.length);u>0&&0===e[f];u-=1,f+=1);if(!(u>32)){var l=e.slice(f,f+u);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},function(e,t,r){"use strict";var Buffer=r(7).Buffer,n=r(35),i=r(18),o=r(67).ec,a=r(199),s=new o("secp256k1"),u=s.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new i(t);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),s.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new i(t),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return o.redSqr().redISub(a.redIAdd(u.b)).isZero()?s.keyPair({pub:{x:n,y:o}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new i(e);return t.cmp(u.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(s.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new i(e);return t.isZero()?Buffer.alloc(32):u.n.sub(t).umod(u.n).toArrayLike(Buffer,"be",32)},t.privateKeyModInverse=function(e){var t=new i(e);if(t.cmp(u.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(u.n).toArrayLike(Buffer,"be",32)},t.privateKeyTweakAdd=function(e,t){var r=new i(t);if(r.cmp(u.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(e)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},t.privateKeyTweakMul=function(e,t){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(e)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},t.publicKeyCreate=function(e,t){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(s.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==f(e)},t.publicKeyTweakAdd=function(e,t,r){var n=f(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(u.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(t).add(n.pub);if(o.isInfinity())throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},t.publicKeyTweakMul=function(e,t,r){var n=f(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(u.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(t).encode(!0,r))},t.publicKeyCombine=function(e,t){for(var r=new Array(e.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(e);return 1===r.cmp(s.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},t.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new i(t).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},t.signatureImport=function(e){var t=new i(e.r);t.cmp(u.n)>=0&&(t=new i(0));var r=new i(e.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([t.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},t.sign=function(e,t,r,n){if("function"==typeof r){var o=r;r=function(r){var s=o(e,t,null,n,r);if(!Buffer.isBuffer(s)||32!==s.length)throw new Error(a.ECDSA_SIGN_FAIL);return new i(s)}}var f=new i(t);if(f.cmp(u.n)>=0||f.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var c=s.sign(e,t,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([c.r.toArrayLike(Buffer,"be",32),c.s.toArrayLike(Buffer,"be",32)]),recovery:c.recoveryParam}},t.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},o=new i(n.r),c=new i(n.s);if(o.cmp(u.n)>=0||c.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===c.cmp(s.nh)||o.isZero()||c.isZero())return!1;var l=f(r);if(null===l)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return s.verify(e,n,{x:l.pub.x,y:l.pub.y})},t.recover=function(e,t,r,n){var o={r:t.slice(0,32),s:t.slice(32,64)},f=new i(o.r),c=new i(o.s);if(f.cmp(u.n)>=0||c.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||c.isZero())throw new Error;var l=s.recoverPubKey(e,o,r);return Buffer.from(l.encode(!0,n))}catch(e){throw new Error(a.ECDSA_RECOVER_FAIL)}},t.ecdh=function(e,r){var i=t.ecdhUnsafe(e,r,!0);return n("sha256").update(i).digest()},t.ecdhUnsafe=function(e,t,r){var n=f(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(t);if(o.cmp(u.n)>=0||o.isZero())throw new Error(a.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},function(e,t,r){var Buffer=r(7).Buffer,n=r(60),i=r(51),o=r(63),a=r(15),s=r(22),u=r(40),BigInteger=r(37),ECPair=r(114),f=r(74),c=f.getCurveByName("secp256k1"),l=r(198);function h(e,t){if(a(s.tuple("ECPair",s.Buffer256bit),arguments),!e.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=e,this.chainCode=t,this.depth=0,this.index=0,this.parentFingerprint=0,this.derivationCache={}}h.HIGHEST_BIT=2147483648,h.LENGTH=78,h.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),h.fromSeedBuffer=function(e,t){if(a(s.tuple(s.Buffer,s.maybe(s.Network)),arguments),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",h.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n),f=new ECPair(u,null,{network:t});return new h(f,i)},h.fromSeedHex=function(e,t){return h.fromSeedBuffer(Buffer.from(e,"hex"),t)},h.fromBase58=function(e,t,r=!1){var i=n.decode(e);if(78!==i.length)throw new Error("Invalid buffer length");var o,a=i.readUInt32BE(0);if(Array.isArray(t)){if(!(o=t.filter((function(e){return a===e.bip32.private||a===e.bip32.public})).pop()))throw new Error("Unknown network version")}else o=t||u.bitcoin;if(a!==o.bip32.private&&a!==o.bip32.public)throw new Error("Invalid network version");var s=i[4],l=i.readUInt32BE(5);if(0===s&&0!==l)throw new Error("Invalid parent fingerprint");var d=i.readUInt32BE(9);if(0===s&&0!==d)throw new Error("Invalid index");var p,y=i.slice(13,45);if(a===o.bip32.private){if(0!==i.readUInt8(45))throw new Error("Invalid private key");var g=BigInteger.fromBuffer(i.slice(46,78));p=new ECPair(g,null,{network:o})}else{var m=f.Point.decodeFrom(c,i.slice(45,78));r||c.validate(m),p=new ECPair(null,m,{network:o})}var b=new h(p,y);return b.depth=s,b.index=d,b.parentFingerprint=l,b},h.prototype.getAddress=function(){return this.keyPair.getAddress()},h.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},h.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},h.prototype.getNetwork=function(){return this.keyPair.getNetwork()},h.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},h.prototype.neutered=function(){var e=new h(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},h.prototype.sign=function(e){return this.keyPair.sign(e)},h.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},h.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},h.prototype.derive=function(e){a(s.UInt32,e);var t=e>=h.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),d=i.slice(32),p=BigInteger.fromBuffer(u);if(p.compareTo(c.n)>=0)return this.derive(e+1);if(this.isNeutered()){var y=l.publicKeyCreate(u,!1),g=void 0!==y?f.Point.decodeFrom(c,y).add(this.keyPair.Q):c.G.multiply(p).add(this.keyPair.Q);if(c.isInfinity(g))return this.derive(e+1);n=new ECPair(null,g,{network:this.keyPair.network})}else{var m=p.add(this.keyPair.d).mod(c.n);if(0===m.signum())return this.derive(e+1);n=new ECPair(m,null,{network:this.keyPair.network})}var b=new h(n,d);return b.depth=this.depth+1,b.index=e,b.parentFingerprint=this.getFingerprint().readUInt32BE(0),b},h.prototype.deriveHardened=function(e){return a(s.UInt31,e),this.derive(e+h.HIGHEST_BIT)},h.prototype.isNeutered=function(){return!this.keyPair.d},h.prototype.derivePath=function(e,t){a(s.BIP32Path,e),a(s.maybe(s.Object),t),t=t||this.derivationCache;var r=e.split("/");if("m"===r[0]){if(this.parentFingerprint)throw new Error("Not a master node");r=r.slice(1)}return r.reduce((function(e,r){var n,i=t[r]||{};return i.node?(t=i.next,i.node):("'"===r.slice(-1)?(n=parseInt(r.slice(0,-1),10),i.node=e.deriveHardened(n)):(n=parseInt(r,10),i.node=e.derive(n)),t[r]=i,i.next={},t=i.next,i.node)}),this)},h.prototype.cloneKeypair=function(){var e=this.keyPair,t=new ECPair(e.d,e.d?null:e.Q,{network:e.network,compressed:e.compressed});if(!t.__Q){var r=l.publicKeyCreate(e.d.toBuffer(32),!1);void 0!==r&&(t.__Q=f.Point.decodeFrom(c,r))}return t},e.exports=h},function(e,t,r){var Buffer=r(7).Buffer,n=r(115),i=r(51),o=r(19),a=r(107),s=r(59),u=r(40),f=r(26),c=r(15),l=r(22),h=a.types,d=[a.types.P2PKH,a.types.P2PK,a.types.MULTISIG],p=d.concat([a.types.P2WPKH,a.types.P2WSH]),ECPair=r(114),y=r(73),g=r(113),m=r(408)("bitgo:utxolib:txbuilder");function b(e){return-1!==d.indexOf(e)}function v(e){return-1!==p.indexOf(e)}function w(e,t){if(0===e.length&&0===t.length)return{};var r,n,s,u,f,c,l,d,p,y,g=!1,m=!1,w=!1,_=o.decompile(e);a.classifyInput(_,!0)===h.P2SH&&(w=!0,f=_[_.length-1],d=a.classifyOutput(f),r=a.scriptHash.output.encode(i.hash160(f)),n=h.P2SH,u=f);var E=a.classifyWitness(t,!0);if(E===h.P2WSH){if(c=t[t.length-1],l=a.classifyOutput(c),m=!0,g=!0,0===e.length){if(r=a.witnessScriptHash.output.encode(i.sha256(c)),n=h.P2WSH,void 0!==f)throw new Error("Redeem script given when unnecessary")}else{if(!f)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(p=a.witnessScriptHash.output.encode(i.sha256(c)),!f.equals(p))throw new Error("Redeem script didn't match witnessScript")}if(!b(a.classifyOutput(c)))throw new Error("unsupported witness script");u=c,s=l,y=t.slice(0,-1)}else if(E===h.P2WPKH){g=!0;var S=t[t.length-1],A=i.hash160(S);if(0===e.length){if(r=a.witnessPubKeyHash.output.encode(A),n=h.P2WPKH,void 0!==f)throw new Error("Redeem script given when unnecessary")}else{if(!f)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(p=a.witnessPubKeyHash.output.encode(A),!f.equals(p))throw new Error("Redeem script did not have the right witness program")}s=h.P2PKH,y=t}else if(f){if(!v(d))throw new Error("Bad redeemscript!");u=f,s=d,y=_.slice(0,-1)}else n=s=a.classifyInput(e),y=_;var I=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?a.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:if(r)n=a.multisig.output.decode(r).pubKeys;i=t.slice(1).map((function(e){return 0===e.length?void 0:e}))}return{pubKeys:n,signatures:i}}(s,y,u),O={pubKeys:I.pubKeys,signatures:I.signatures,prevOutScript:r,prevOutType:n,signType:s,signScript:u,witness:Boolean(g)};return w&&(O.redeemScript=f,O.redeemScriptType=d),m&&(O.witnessScript=c,O.witnessScriptType=l),O}function _(e,t,r){c(l.Buffer,e);var n=o.decompile(e);t||(t=a.classifyOutput(e));var s=[];switch(t){case h.P2PKH:if(!r)break;var u=n[2],f=i.hash160(r);u.equals(f)&&(s=[r]);break;case h.P2WPKH:if(!r)break;var d=n[1],p=i.hash160(r);d.equals(p)&&(s=[r]);break;case h.P2PK:s=n.slice(0,1);break;case h.MULTISIG:s=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:s,scriptType:t,signatures:s.map((function(){}))}}function E(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!o.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function S(e,t,r,n,s){var u,f,c,l,d,p,y,g,m,b=!1,v=!1,w=!1;if(r&&s){if(d=i.hash160(r),y=i.sha256(s),E(e,d),!r.equals(a.witnessScriptHash.output.encode(y)))throw new Error("Witness script inconsistent with redeem script");if(!(u=_(s,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+o.toASM(r)+'"');f=a.types.P2SH,c=a.scriptHash.output.encode(d),b=v=w=!0,l=a.types.P2WSH,g=p=u.scriptType,m=s}else if(r){if(E(e,d=i.hash160(r)),!(u=_(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+o.toASM(r)+'"');f=a.types.P2SH,c=a.scriptHash.output.encode(d),b=!0,m=r,v=(g=l=u.scriptType)===a.types.P2WPKH}else if(s){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!o.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,y=i.sha256(s)),!(u=_(s,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+o.toASM(r)+'"');f=a.types.P2WSH,c=a.witnessScriptHash.output.encode(y),v=w=!0,g=p=u.scriptType,m=s}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(f=e.prevOutType,c=e.prevOutScript,!(u=_(e.prevOutScript,e.prevOutType,t)).pubKeys)return;v=e.prevOutType===h.P2WPKH,g=f,m=c}else u=_(c=a.pubKeyHash.output.encode(i.hash160(t)),h.P2PKH,t),v=!1,g=f=h.P2PKH,m=c;g===h.P2WPKH&&(m=a.pubKeyHash.output.encode(a.witnessPubKeyHash.output.decode(m))),b&&(e.redeemScript=r,e.redeemScriptType=l),w&&(e.witnessScript=s,e.witnessScriptType=p),e.pubKeys=u.pubKeys,e.signatures=u.signatures,e.signScript=m,e.signType=g,e.prevOutScript=c,e.prevOutType=f,e.witness=v}function A(e,t,r,n){if(e===h.P2PKH){if(1===t.length&&Buffer.isBuffer(t[0])&&1===r.length)return a.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&Buffer.isBuffer(t[0]))return a.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map((function(e){return e||f.OP_0})),n||(t=t.filter((function(e){return e!==f.OP_0}))),a.multisig.input.encodeStack(t)}if(!n)throw new Error("Not enough signatures provided");return[]}function I(e,t){this.prevTxMap={},this.network=e||u.bitcoin,this.maximumFeeRate=t||2500,this.inputs=[],this.tx=new g(this.network)}function O(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&(!1===e.witness||!0===e.witness&&void 0!==e.value)}function P(e){return e.readUInt8(e.length-1)}I.prototype.setLockTime=function(e){if(c(l.UInt32,e),this.inputs.some((function(e){return!!e.signatures&&e.signatures.some((function(e){return e}))})))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},I.prototype.setVersion=function(e,t=!0){if(c(l.UInt32,e),s.isZcashType(this.network)){if(!this.network.consensusBranchId.hasOwnProperty(this.tx.version))throw new Error("Unsupported Zcash transaction");this.tx.overwintered=t?1:0}this.tx.version=e},I.prototype.setVersionGroupId=function(e){if(!s.isZcashType(this.network)||!this.tx.isOverwinterCompatible())throw new Error("expiryHeight can only be set for Zcash starting at overwinter version. Current network coin: "+this.network.coin+", version: "+this.tx.version);c(l.UInt32,e),this.tx.versionGroupId=e},I.prototype.setExpiryHeight=function(e){if(!s.isZcashType(this.network)||!this.tx.isOverwinterCompatible())throw new Error("expiryHeight can only be set for Zcash starting at overwinter version. Current network coin: "+this.network.coin+", version: "+this.tx.version);c(l.UInt32,e),this.tx.expiryHeight=e},I.prototype.setJoinSplits=function(e){if(!s.isZcashType(this.network)||!this.tx.supportsJoinSplits())throw new Error("joinsplits can only be set for Zcash starting at version 2. Current network coin: "+this.network.coin+", version: "+this.tx.version);if(e&&e.joinsplits)return this.tx.joinsplits=e.joinsplits.map((function(e){return{vpubOld:e.vpubOld,vpubNew:e.vpubNew,anchor:e.anchor,nullifiers:e.nullifiers,commitments:e.commitments,ephemeralKey:e.ephemeralKey,randomSeed:e.randomSeed,macs:e.macs,zproof:e.zproof,ciphertexts:e.ciphertexts}})),this.tx.joinsplitPubkey=e.joinsplitPubkey,void(this.tx.joinsplitSig=e.joinsplitSig);throw new Error("Invalid transaction with joinsplits")},I.fromTransaction=function(e,t){var r=t||u.bitcoin,n=new I(r);if(n.network.coin!==e.network.coin)throw new Error("This transaction is incompatible with the transaction builder");return n.setVersion(e.version,e.overwintered),n.setLockTime(e.locktime),s.isZcashType(r)&&(n.tx.isOverwinterCompatible()&&(n.setVersionGroupId(e.versionGroupId),n.setExpiryHeight(e.expiryHeight)),n.tx.supportsJoinSplits()&&n.setJoinSplits(e)),s.isDash(r)&&(c(l.UInt16,e.type),n.tx.type=e.type,n.tx.versionSupportsDashSpecialTransactions()&&(c(l.Buffer,e.extraPayload),n.tx.extraPayload=e.extraPayload)),e.outs.forEach((function(e){n.addOutput(e.script,e.value)})),e.ins.forEach((function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness,value:e.value})})),n.inputs.forEach((function(t,n){!function(e,t,r,n,i){if(e.redeemScriptType===h.MULTISIG&&e.redeemScript&&e.pubKeys.length!==e.signatures.length){i=i||u.bitcoin;var o=e.signatures.concat();e.signatures=e.pubKeys.map((function(a){var u,f=ECPair.fromPublicKeyBuffer(a);return o.some((function(a,c){if(!a)return!1;var l,h=y.parseScriptSignature(a);switch(i.coin){case s.BSV:case s.BCH:l=t.hashForCashSignature(r,e.signScript,n,h.hashType);break;case s.BTG:l=t.hashForGoldSignature(r,e.signScript,n,h.hashType);break;case s.ZEC:case s.TAZ:if(void 0===n)return!1;l=t.hashForZcashSignature(r,e.signScript,n,h.hashType);break;default:l=e.witness?t.hashForWitnessV0(r,e.signScript,n,h.hashType):t.hashForSignature(r,e.signScript,h.hashType)}return!!f.verify(l,h.signature)&&(o[c]=void 0,u=a,!0)})),u}))}}(t,e,n,t.value,r)})),n},I.prototype.addInput=function(e,t,r,n){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var i;if("string"==typeof e)e=Buffer.from(e,"hex").reverse();else if(e instanceof g){var o=e.outs[t];n=o.script,i=o.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:n,value:i})},I.prototype.__addInputUnsafe=function(e,t,r){if(g.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=w(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var s=_(r.prevOutScript);s.pubKeys&&(i.pubKeys=s.pubKeys,i.signatures=s.signatures),o=s.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||a.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},I.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=n.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},I.prototype.build=function(){return this.__build(!1)},I.prototype.buildIncomplete=function(){return this.__build(!0)},I.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach((function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!e)throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];b(r)&&(n=A(r,e.signatures,e.pubKeys,t));var s=!1;if(r===a.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");b(e.redeemScriptType)&&(n=A(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(s=!0,r=e.redeemScriptType)}switch(r){case a.types.P2WPKH:i=A(a.types.P2PKH,e.signatures,e.pubKeys,t);break;case a.types.P2WSH:if(!t&&!b(e.witnessScriptType))throw new Error("Impossible to sign this type");b(e.witnessScriptType)&&((i=A(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return s&&n.push(e.redeemScript),{type:r,script:o.compile(n),witness:i}}(r,e);if(!e&&!b(i.type)&&i.type!==a.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)})),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},I.prototype.sign=function(e,t,r,n,i,o){if(m("Signing transaction: (input: %d, hashType: %d, witnessVal: %s, witnessScript: %j)",e,n,i,o),m("Transaction Builder network: %j",this.network),t.network&&t.network!==this.network)throw new TypeError("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);n=n||g.SIGHASH_ALL;var a=this.inputs[e];if(void 0!==a.redeemScript&&r&&!a.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var u,f=t.publicKey||t.getPublicKeyBuffer();if(!O(a)){if(void 0!==i){if(void 0!==a.value&&a.value!==i)throw new Error("Input didn't match witnessValue");c(l.Satoshi,i),a.value=i}if(m("Preparing input %d for signing",e),O(a)||S(a,f,r,0,o),!O(a))throw Error(a.prevOutType+" not supported")}if(s.isBitcoinGold(this.network)?(u=this.tx.hashForGoldSignature(e,a.signScript,i,n,a.witness),m("Calculated BTG sighash (%s)",u.toString("hex"))):s.isBitcoinCash(this.network)||s.isBitcoinSV(this.network)?(u=this.tx.hashForCashSignature(e,a.signScript,i,n),m("Calculated BCH sighash (%s)",u.toString("hex"))):s.isZcashType(this.network)?(u=this.tx.hashForZcashSignature(e,a.signScript,i,n),m("Calculated ZEC sighash (%s)",u.toString("hex"))):a.witness?(u=this.tx.hashForWitnessV0(e,a.signScript,i,n),m("Calculated witnessv0 sighash (%s)",u.toString("hex"))):(u=this.tx.hashForSignature(e,a.signScript,n),m("Calculated sighash (%s)",u.toString("hex"))),!a.pubKeys.some((function(e,r){if(!f.equals(e))return!1;if(a.signatures[r])throw new Error("Signature already exists");if(33!==f.length&&a.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");var i=t.sign(u);return Buffer.isBuffer(i)&&(i=y.fromRSBuffer(i)),m("Produced signature (r: %s, s: %s)",i.r,i.s),a.signatures[r]=i.toScriptSignature(n),!0})))throw new Error("Key pair cannot sign for this input")},I.prototype.__canModifyInputs=function(){return this.inputs.every((function(e){return void 0===e.signatures||e.signatures.every((function(e){return!e||P(e)&g.SIGHASH_ANYONECANPAY}))}))},I.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every((function(r){return void 0===r.signatures||r.signatures.every((function(r){if(!r)return!0;var n=31&P(r);return n===g.SIGHASH_NONE||(n===g.SIGHASH_SINGLE?e<=t:void 0)}))}))},I.prototype.__overMaximumFees=function(e){return(this.inputs.reduce((function(e,t){return e+(t.value>>>0)}),0)-this.tx.outs.reduce((function(e,t){return e+t.value}),0))/e>this.maximumFeeRate},e.exports=I},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(409)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(16))},function(e,t,r){function n(e){var r;function n(){if(n.enabled){var e=n,i=+new Date,o=i-(r||i);e.diff=o,e.prev=r,e.curr=i,r=i;for(var a=new Array(arguments.length),s=0;s0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?a(s=e,o,"day")||a(s,i,"hour")||a(s,n,"minute")||a(s,r,"second")||s+" ms":function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=i)return Math.round(e/i)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){e.exports=r(412)(r(415))},function(e,t,r){const n=r(413),i=r(414);e.exports=function(e){const t=n(e),r=i(e);return function(e,n){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new t(1152,448,null,224,n);case"keccak256":return new t(1088,512,null,256,n);case"keccak384":return new t(832,768,null,384,n);case"keccak512":return new t(576,1024,null,512,n);case"sha3-224":return new t(1152,448,6,224,n);case"sha3-256":return new t(1088,512,6,256,n);case"sha3-384":return new t(832,768,6,384,n);case"sha3-512":return new t(576,1024,6,512,n);case"shake128":return new r(1344,256,31,n);case"shake256":return new r(1088,512,31,n);default:throw new Error("Invald algorithm: "+e)}}}},function(e,t,r){(function(Buffer){const{Transform:t}=r(88);e.exports=e=>class r extends t{constructor(t,r,n,i,o){super(o),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._hashBitLength=i,this._options=o,this._state=new e,this._state.initialize(t,r),this._finalized=!1}_transform(e,t,r){let n=null;try{this.update(e,t)}catch(e){n=e}r(n)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}digest(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new r(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}}).call(this,r(9).Buffer)},function(e,t,r){(function(Buffer){const{Transform:t}=r(88);e.exports=e=>class r extends t{constructor(t,r,n,i){super(i),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._options=i,this._state=new e,this._state.initialize(t,r),this._finalized=!1}_transform(e,t,r){let n=null;try{this.update(e,t)}catch(e){n=e}r(n)}_flush(){}_read(e){this.push(this.squeeze(e))}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}squeeze(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let r=this._state.squeeze(e);return void 0!==t&&(r=r.toString(t)),r}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new r(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}}).call(this,r(9).Buffer)},function(e,t,r){(function(Buffer){const t=r(416);function n(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}n.prototype.initialize=function(e,t){for(let e=0;e<50;++e)this.state[e]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},n.prototype.absorb=function(e){for(let r=0;r>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(t.p1600(this.state),this.count=0);return r},n.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=n}).call(this,r(9).Buffer)},function(e,t){const r=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];t.p1600=function(e){for(let t=0;t<24;++t){const n=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],c=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],h=e[9]^e[19]^e[29]^e[39]^e[49];let d=l^(o<<1|a>>>31),p=h^(a<<1|o>>>31);const y=e[0]^d,g=e[1]^p,m=e[10]^d,b=e[11]^p,v=e[20]^d,w=e[21]^p,_=e[30]^d,E=e[31]^p,S=e[40]^d,A=e[41]^p;d=n^(s<<1|u>>>31),p=i^(u<<1|s>>>31);const I=e[2]^d,O=e[3]^p,P=e[12]^d,M=e[13]^p,k=e[22]^d,T=e[23]^p,x=e[32]^d,R=e[33]^p,C=e[42]^d,N=e[43]^p;d=o^(f<<1|c>>>31),p=a^(c<<1|f>>>31);const B=e[4]^d,D=e[5]^p,U=e[14]^d,j=e[15]^p,L=e[24]^d,F=e[25]^p,H=e[34]^d,q=e[35]^p,V=e[44]^d,K=e[45]^p;d=s^(l<<1|h>>>31),p=u^(h<<1|l>>>31);const z=e[6]^d,G=e[7]^p,Q=e[16]^d,W=e[17]^p,Y=e[26]^d,Z=e[27]^p,J=e[36]^d,X=e[37]^p,$=e[46]^d,ee=e[47]^p;d=f^(n<<1|i>>>31),p=c^(i<<1|n>>>31);const te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,fe=e[48]^d,ce=e[49]^p,le=y,he=g,de=b<<4|m>>>28,pe=m<<4|b>>>28,ye=v<<3|w>>>29,ge=w<<3|v>>>29,me=E<<9|_>>>23,be=_<<9|E>>>23,ve=S<<18|A>>>14,we=A<<18|S>>>14,_e=I<<1|O>>>31,Ee=O<<1|I>>>31,Se=M<<12|P>>>20,Ae=P<<12|M>>>20,Ie=k<<10|T>>>22,Oe=T<<10|k>>>22,Pe=R<<13|x>>>19,Me=x<<13|R>>>19,ke=C<<2|N>>>30,Te=N<<2|C>>>30,xe=D<<30|B>>>2,Re=B<<30|D>>>2,Ce=U<<6|j>>>26,Ne=j<<6|U>>>26,Be=F<<11|L>>>21,De=L<<11|F>>>21,Ue=H<<15|q>>>17,je=q<<15|H>>>17,Le=K<<29|V>>>3,Fe=V<<29|K>>>3,He=z<<28|G>>>4,qe=G<<28|z>>>4,Ve=W<<23|Q>>>9,Ke=Q<<23|W>>>9,ze=Y<<25|Z>>>7,Ge=Z<<25|Y>>>7,Qe=J<<21|X>>>11,We=X<<21|J>>>11,Ye=ee<<24|$>>>8,Ze=$<<24|ee>>>8,Je=te<<27|re>>>5,Xe=re<<27|te>>>5,$e=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=fe<<14|ce>>>18,at=ce<<14|fe>>>18;e[0]=le^~Se&Be,e[1]=he^~Ae&De,e[10]=He^~$e&ye,e[11]=qe^~et&ge,e[20]=_e^~Ce&ze,e[21]=Ee^~Ne&Ge,e[30]=Je^~de&Ie,e[31]=Xe^~pe&Oe,e[40]=xe^~Ve&tt,e[41]=Re^~Ke&rt,e[2]=Se^~Be&Qe,e[3]=Ae^~De&We,e[12]=$e^~ye&Pe,e[13]=et^~ge&Me,e[22]=Ce^~ze&nt,e[23]=Ne^~Ge&it,e[32]=de^~Ie&Ue,e[33]=pe^~Oe&je,e[42]=Ve^~tt&me,e[43]=Ke^~rt&be,e[4]=Be^~Qe&ot,e[5]=De^~We&at,e[14]=ye^~Pe&Le,e[15]=ge^~Me&Fe,e[24]=ze^~nt&ve,e[25]=Ge^~it&we,e[34]=Ie^~Ue&Ye,e[35]=Oe^~je&Ze,e[44]=tt^~me&ke,e[45]=rt^~be&Te,e[6]=Qe^~ot&le,e[7]=We^~at&he,e[16]=Pe^~Le&He,e[17]=Me^~Fe&qe,e[26]=nt^~ve&_e,e[27]=it^~we&Ee,e[36]=Ue^~Ye&Je,e[37]=je^~Ze&Xe,e[46]=me^~ke&xe,e[47]=be^~Te&Re,e[8]=ot^~le&Se,e[9]=at^~he&Ae,e[18]=Le^~He&$e,e[19]=Fe^~qe&et,e[28]=ve^~_e&Ce,e[29]=we^~Ee&Ne,e[38]=Ye^~Je&de,e[39]=Ze^~Xe&pe,e[48]=ke^~xe&Ve,e[49]=Te^~Re&Ke,e[0]^=r[2*t],e[1]^=r[2*t+1]}}},function(e,t,r){"use strict";Object.freeze({SPENDADDRESS:0,SPENDMULTISIG:1,EXTERNAL:2,SPENDWITNESS:3,SPENDP2SHWITNESS:4}),Object.freeze({PAYTOADDRESS:0,PAYTOSCRIPTHASH:1,PAYTOMULTISIG:2,PAYTOOPRETURN:3,PAYTOWITNESS:4,PAYTOP2SHWITNESS:5}),Object.freeze({BITCOIN:0,MILLIBITCOIN:1,MICROBITCOIN:2,SATOSHI:3}),Object.freeze({BASE:0,BASE_SCRIPT_KEY:1,BASE_KEY_SCRIPT:2,BASE_SCRIPT_SCRIPT:3,POINTER:4,POINTER_SCRIPT:5,ENTERPRISE:6,ENTERPRISE_SCRIPT:7,BYRON:8,REWARD:14,REWARD_SCRIPT:15}),Object.freeze({STAKE_REGISTRATION:0,STAKE_DEREGISTRATION:1,STAKE_DELEGATION:2,STAKE_POOL_REGISTRATION:3}),Object.freeze({SINGLE_HOST_IP:0,SINGLE_HOST_NAME:1,MULTIPLE_HOST_NAME:2}),Object.freeze({Bip39:0,Slip39_Basic:1,Slip39_Advanced:2}),Object.freeze({Strict:0,PromptAlways:1,PromptTemporarily:2}),Object.freeze({OT_UNKNOWN:0,MARKET:1,LIMIT:2,OT_RESERVED:3}),Object.freeze({SIDE_UNKNOWN:0,BUY:1,SELL:2}),Object.freeze({TIF_UNKNOWN:0,GTE:1,TIF_RESERVED:2,IOC:3}),Object.freeze({TXINPUT:0,TXOUTPUT:1,TXMETA:2,TXFINISHED:3,TXEXTRADATA:4,TXORIGINPUT:5,TXORIGOUTPUT:6}),Object.freeze({Failure_UnexpectedMessage:1,Failure_ButtonExpected:2,Failure_DataError:3,Failure_ActionCancelled:4,Failure_PinExpected:5,Failure_PinCancelled:6,Failure_PinInvalid:7,Failure_InvalidSignature:8,Failure_ProcessError:9,Failure_NotEnoughFunds:10,Failure_NotInitialized:11,Failure_PinMismatch:12,Failure_WipeCodeMismatch:13,Failure_InvalidSession:14,Failure_FirmwareError:99}),Object.freeze({ButtonRequest_Other:1,ButtonRequest_FeeOverThreshold:2,ButtonRequest_ConfirmOutput:3,ButtonRequest_ResetDevice:4,ButtonRequest_ConfirmWord:5,ButtonRequest_WipeDevice:6,ButtonRequest_ProtectCall:7,ButtonRequest_SignTx:8,ButtonRequest_FirmwareCheck:9,ButtonRequest_Address:10,ButtonRequest_PublicKey:11,ButtonRequest_MnemonicWordCount:12,ButtonRequest_MnemonicInput:13,_Deprecated_ButtonRequest_PassphraseType:14,ButtonRequest_UnknownDerivationPath:15,ButtonRequest_RecoveryHomepage:16,ButtonRequest_Success:17,ButtonRequest_Warning:18,ButtonRequest_PassphraseEntry:19,ButtonRequest_PinEntry:20}),Object.freeze({PinMatrixRequestType_Current:1,PinMatrixRequestType_NewFirst:2,PinMatrixRequestType_NewSecond:3,PinMatrixRequestType_WipeCodeFirst:4,PinMatrixRequestType_WipeCodeSecond:5}),Object.freeze({UP:0,DOWN:1,LEFT:2,RIGHT:3}),Object.freeze({NORMAL:0,BOLD:1,MONO:2,BR:4,BR_HALF:5,SET_COLOR:6}),Object.freeze({Transfer:0,RegisterSecondPassphrase:1,RegisterDelegate:2,CastVotes:3,RegisterMultisignatureAccount:4,CreateDapp:5,TransferIntoDapp:6,TransferOutOfDapp:7}),Object.freeze({Capability_Bitcoin:1,Capability_Bitcoin_like:2,Capability_Binance:3,Capability_Cardano:4,Capability_Crypto:5,Capability_EOS:6,Capability_Ethereum:7,Capability_Lisk:8,Capability_Monero:9,Capability_NEM:10,Capability_Ripple:11,Capability_Stellar:12,Capability_Tezos:13,Capability_U2F:14,Capability_Shamir:15,Capability_ShamirGroups:16,Capability_PassphraseEntry:17}),Object.freeze({DISABLE:0,ENABLE:1,REFRESH:2}),Object.freeze({RecoveryDeviceType_ScrambledWords:0,RecoveryDeviceType_Matrix:1}),Object.freeze({WordRequestType_Plain:0,WordRequestType_Matrix9:1,WordRequestType_Matrix6:2}),Object.freeze({MosaicLevy_Absolute:1,MosaicLevy_Percentile:2}),Object.freeze({SupplyChange_Increase:1,SupplyChange_Decrease:2}),Object.freeze({CosignatoryModification_Add:1,CosignatoryModification_Delete:2}),Object.freeze({ImportanceTransfer_Activate:1,ImportanceTransfer_Deactivate:2}),Object.freeze({Implicit:0,Originated:1}),Object.freeze({Yay:0,Nay:1,Pass:2})},function(e,t,r){"use strict";t.__esModule=!0,t.getUnavailableCapabilities=t.parseCapabilities=void 0;var n=r(48),i=["Capability_Bitcoin","Capability_Bitcoin_like","Capability_Binance","Capability_Cardano","Capability_Crypto","Capability_EOS","Capability_Ethereum","Capability_Lisk","Capability_Monero","Capability_NEM","Capability_Ripple","Capability_Stellar","Capability_Tezos","Capability_U2F","Capability_Shamir","Capability_ShamirGroups","Capability_PassphraseEntry"],o=[1,2,5,7,8,10,12,14],a=[1,2,3,4,5,6,7,8,9,10,11,12,13,14];t.parseCapabilities=function(e){if(!e||!1===e.firmware_present)return[];var t=function(e){return i[e-1]?[i[e-1]]:[]};return e.capabilities&&e.capabilities.length?e.capabilities.flatMap(t):1===e.major_version?o.flatMap(t):a.flatMap(t)};t.getUnavailableCapabilities=function(e,t,r){var i=e.capabilities,o={};if(!i)return o;var a=[e.major_version,e.minor_version,e.patch_version],s=t.filter((function(e){return"bitcoin"===e.type?"Bitcoin"===e.name||"Testnet"===e.name?!i.includes("Capability_Bitcoin"):!i.includes("Capability_Bitcoin_like"):"ethereum"===e.type?!i.includes("Capability_Ethereum"):"nem"===e.type?!i.includes("Capability_NEM"):"BNB"===e.shortcut?!i.includes("Capability_Binance"):"XRP"===e.shortcut||"tXRP"===e.shortcut?!i.includes("Capability_Ripple"):!i.includes("Capability_"+e.name)}));s.forEach((function(e){o[e.shortcut.toLowerCase()]="no-capability"}));var u=t.filter((function(e){return!s.includes(e)})),f="trezor"+e.major_version;return u.forEach((function(e){e.support&&"string"==typeof e.support[f]||(o[e.shortcut.toLowerCase()]="no-support",s.push(e)),(0,n.versionCompare)(e.support[f],a)>0&&(o[e.shortcut.toLowerCase()]="update-required",s.push(e))})),r.forEach((function(e){e.min&&(0,n.versionCompare)(e.min[a[0]-1],a)>0&&e.excludedMethods.forEach((function(t){o[t]=e.coin||"update-required"})),e.max&&(0,n.versionCompare)(e.max[a[0]-1],a)<0&&e.excludedMethods.forEach((function(t){o[t]=e.coin||"trezor-connect-outdated"}))})),o}},function(e,t,r){"use strict";(function(Buffer){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,o=p(r(1)),a=p(r(420)),s=r(421),u=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r(422)),f=r(203),c=r(204),l=r(213),h=r(76);function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function p(e){return e&&e.__esModule?e:{default:e}}function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;ta)return 1;if(a>o)return-1;if(!isNaN(o)&&isNaN(a))return 1;if(isNaN(o)&&!isNaN(a))return-1}return 0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFetch=function(e,t){l=e,h=!!t},t.request=function(e){return g.apply(this,arguments)};var n,i=(n=r(1))&&n.__esModule?n:{default:n};function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t=o)return e;switch(e){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(e){return"[Circular]"}default:return e}})),u=n[r];r=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),p(r)?n.showHidden=r:r&&t._extend(n,r),b(n.showHidden)&&(n.showHidden=!1),b(n.depth)&&(n.depth=2),b(n.colors)&&(n.colors=!1),b(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=u),c(n,e,n.depth)}function u(e,t){var r=s.styles[t];return r?"["+s.colors[r][0]+"m"+e+"["+s.colors[r][1]+"m":e}function f(e,t){return e}function c(e,r,n){if(e.customInspect&&r&&S(r.inspect)&&r.inspect!==t.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,e);return m(i)||(i=c(e,i,n)),i}var o=function(e,t){if(b(t))return e.stylize("undefined","undefined");if(m(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}if(y(t))return e.stylize(""+t,"number");if(p(t))return e.stylize(""+t,"boolean");if(g(t))return e.stylize("null","null")}(e,r);if(o)return o;var a=Object.keys(r),s=function(e){var t={};return e.forEach((function(e,r){t[e]=!0})),t}(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(r)),E(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return l(r);if(0===a.length){if(S(r)){var u=r.name?": "+r.name:"";return e.stylize("[Function"+u+"]","special")}if(v(r))return e.stylize(RegExp.prototype.toString.call(r),"regexp");if(_(r))return e.stylize(Date.prototype.toString.call(r),"date");if(E(r))return l(r)}var f,w="",A=!1,I=["{","}"];(d(r)&&(A=!0,I=["[","]"]),S(r))&&(w=" [Function"+(r.name?": "+r.name:"")+"]");return v(r)&&(w=" "+RegExp.prototype.toString.call(r)),_(r)&&(w=" "+Date.prototype.toUTCString.call(r)),E(r)&&(w=" "+l(r)),0!==a.length||A&&0!=r.length?n<0?v(r)?e.stylize(RegExp.prototype.toString.call(r),"regexp"):e.stylize("[Object]","special"):(e.seen.push(r),f=A?function(e,t,r,n,i){for(var o=[],a=0,s=t.length;a=0&&0,e+t.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60)return r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1];return r[0]+t+" "+e.join(", ")+" "+r[1]}(f,w,I)):I[0]+w+I[1]}function l(e){return"["+Error.prototype.toString.call(e)+"]"}function h(e,t,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(t,i)||{value:t[i]}).get?s=u.set?e.stylize("[Getter/Setter]","special"):e.stylize("[Getter]","special"):u.set&&(s=e.stylize("[Setter]","special")),M(n,i)||(a="["+i+"]"),s||(e.seen.indexOf(u.value)<0?(s=g(r)?c(e,u.value,null):c(e,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(e){return" "+e})).join("\n").substr(2):"\n"+s.split("\n").map((function(e){return" "+e})).join("\n")):s=e.stylize("[Circular]","special")),b(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.substr(1,a.length-2),a=e.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=e.stylize(a,"string"))}return a+": "+s}function d(e){return Array.isArray(e)}function p(e){return"boolean"==typeof e}function g(e){return null===e}function y(e){return"number"==typeof e}function m(e){return"string"==typeof e}function b(e){return void 0===e}function v(e){return w(e)&&"[object RegExp]"===A(e)}function w(e){return"object"==typeof e&&null!==e}function _(e){return w(e)&&"[object Date]"===A(e)}function E(e){return w(e)&&("[object Error]"===A(e)||e instanceof Error)}function S(e){return"function"==typeof e}function A(e){return Object.prototype.toString.call(e)}function I(e){return e<10?"0"+e.toString(10):e.toString(10)}t.debuglog=function(r){if(b(o)&&(o=e.env.NODE_DEBUG||""),r=r.toUpperCase(),!a[r])if(new RegExp("\\b"+r+"\\b","i").test(o)){var n=e.pid;a[r]=function(){var e=t.format.apply(t,arguments);console.error("%s %d: %s",r,n,e)}}else a[r]=function(){};return a[r]},t.inspect=s,s.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},s.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},t.isArray=d,t.isBoolean=p,t.isNull=g,t.isNullOrUndefined=function(e){return null==e},t.isNumber=y,t.isString=m,t.isSymbol=function(e){return"symbol"==typeof e},t.isUndefined=b,t.isRegExp=v,t.isObject=w,t.isDate=_,t.isError=E,t.isFunction=S,t.isPrimitive=function(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e},t.isBuffer=r(385);var O=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(){var e=new Date,t=[I(e.getHours()),I(e.getMinutes()),I(e.getSeconds())].join(":");return[e.getDate(),O[e.getMonth()],t].join(" ")}function M(e,t){return Object.prototype.hasOwnProperty.call(e,t)}t.log=function(){console.log("%s - %s",P(),t.format.apply(t,arguments))},t.inherits=r(386),t._extend=function(e,t){if(!t||!w(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e};var k="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function T(e,t){if(!e){var r=new Error("Promise was rejected with a falsy value");r.reason=e,e=r}return t(e)}t.promisify=function(e){if("function"!=typeof e)throw new TypeError('The "original" argument must be of type Function');if(k&&e[k]){var t;if("function"!=typeof(t=e[k]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(t,k,{value:t,enumerable:!1,writable:!1,configurable:!0}),t}function t(){for(var t,r,n=new Promise((function(e,n){t=e,r=n})),i=[],o=0;o=0))break;u=u*n+c,a=a*n+Math.floor(u/s),u%=s}f&&(a=~a,u?u=s-u:a++);C(e,t+w,a),C(e,t+_,u)}(r,a,u,f||10):h(u,f)?d(r,a,u,f):"number"==typeof f?(C(r,a+w,u),C(r,a+_,f)):u>0?O(r,a,u):u<0?P(r,a,u):d(r,a,o,0)}(this,e,r,a,u):new x(e,r,a,u)}function R(){var e=this.buffer,t=this.offset,r=N(e,t+w),n=N(e,t+_);return v||(r|=0),r?r*s+n:n}function C(e,t,r){e[t+I]=255&r,r>>=8,e[t+A]=255&r,r>>=8,e[t+S]=255&r,r>>=8,e[t+E]=255&r}function N(e,t){return 16777216*e[t+E]+(e[t+S]<<16)+(e[t+A]<<8)+e[t+I]}}function f(e){var r=this.buffer,n=this.offset;return t=null,!1!==e&&a(r)?8===r.length?r:r.slice(n,n+8):p(r,n)}function c(e){var n=this.buffer,i=this.offset;return t=r,!1!==e&&r.isBuffer(n)?8===n.length?n:n.slice(i,i+8):r.from(l.call(this,e))}function l(e){var r=this.buffer,o=this.offset,a=r.buffer;if(t=n,!1!==e&&!r.offset&&a instanceof i)return 8===a.byteLength?a:a.slice(o,o+8);var s=new n(8);return d(s,0,r,o),s.buffer}function h(e,t){var r=e&&e.length;return t|=0,r&&t+8<=r&&"string"!=typeof e[t]}function d(e,t,r,n){t|=0,n|=0;for(var i=0;i<8;i++)e[t++]=255&r[n++]}function p(e,t){return Array.prototype.slice.call(e,t,t+8)}function g(e,t,r){for(var n=t+8;n>t;)e[--n]=255&r,r/=256}function y(e,t,r){var n=t+8;for(r++;n>t;)e[--n]=255&-r^255,r/=256}function m(e,t,r){for(var n=t+8;t>24)-3,r=8388607&e,n=Buffer.alloc(32,0);return t<0?(r>>=8*Math.abs(t),n.writeUInt32BE(r,28)):t>28?(r<<=8*(t-28),n.writeUInt32BE(r,0)):n.writeUInt32BE(r,28-t),n},l.calculateMerkleRoot=function(e){if(o([{getHash:a.Function}],e),0===e.length)throw TypeError("Cannot compute merkle root for zero transactions");var t=e.map((function(e){return e.getHash()}));return i(t,n.hash256)},l.prototype.checkMerkleRoot=function(){if(!this.transactions)return!1;var e=l.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(e)},l.prototype.checkProofOfWork=function(){var e=this.getHash().reverse(),t=l.calculateTarget(this.bits);return e.compare(t)<=0},e.exports=l},function(e,t,r){(function(Buffer){e.exports=function(e,t){if(!Array.isArray(e))throw TypeError("Expected values Array");if("function"!=typeof t)throw TypeError("Expected digest Function");for(var r=e.length,n=e.concat();r>1;){for(var i=0,o=0;o=4294967296&&i++,e[t]=n,e[t+1]=i}function a(e,t,r,n){var i=e[t]+r;r<0&&(i+=4294967296);var o=e[t+1]+n;i>=4294967296&&o++,e[t]=i,e[t+1]=o}function s(e,t){return e[t]^e[t+1]<<8^e[t+2]<<16^e[t+3]<<24}function u(e,t,r,n,i,s){var u=h[i],f=h[i+1],c=h[s],d=h[s+1];o(l,e,t),a(l,e,u,f);var p=l[n]^l[e],g=l[n+1]^l[e+1];l[n]=g,l[n+1]=p,o(l,r,n),p=l[t]^l[r],g=l[t+1]^l[r+1],l[t]=p>>>24^g<<8,l[t+1]=g>>>24^p<<8,o(l,e,t),a(l,e,c,d),p=l[n]^l[e],g=l[n+1]^l[e+1],l[n]=p>>>16^g<<16,l[n+1]=g>>>16^p<<16,o(l,r,n),p=l[t]^l[r],g=l[t+1]^l[r+1],l[t]=g>>>31^p<<1,l[t+1]=p>>>31^g<<1}var f=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),c=new Uint8Array([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3].map((function(e){return 2*e}))),l=new Uint32Array(32),h=new Uint32Array(32);function d(e,t){var r=0;for(r=0;r<16;r++)l[r]=e.h[r],l[r+16]=f[r];for(l[24]=l[24]^e.t,l[25]=l[25]^e.t/4294967296,t&&(l[28]=~l[28],l[29]=~l[29]),r=0;r<32;r++)h[r]=s(e.b,4*r);for(r=0;r<12;r++)u(0,8,16,24,c[16*r+0],c[16*r+1]),u(2,10,18,26,c[16*r+2],c[16*r+3]),u(4,12,20,28,c[16*r+4],c[16*r+5]),u(6,14,22,30,c[16*r+6],c[16*r+7]),u(0,10,20,30,c[16*r+8],c[16*r+9]),u(2,12,22,24,c[16*r+10],c[16*r+11]),u(4,14,16,26,c[16*r+12],c[16*r+13]),u(6,8,18,28,c[16*r+14],c[16*r+15]);for(r=0;r<16;r++)e.h[r]=e.h[r]^l[r]^l[r+16]}var p=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function g(e,t,r,n){p.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=e,p[0]=e,t&&(p[1]=t.length),p[2]=1,p[3]=1,r&&p.set(r,32),n&&p.set(n,48);for(var i=0;i<16;i++)this.h[i]=f[i]^s(p,4*i);t&&(y(this,t),this.c=128)}function y(e,t){for(var r=0;r=this.outlen,"out must have at least outlen bytes of space"),function(e,t){e.t+=e.c;for(;e.c<128;)e.b[e.c++]=0;d(e,!0);for(var r=0;r>2]>>8*(3&r)}(this,t),"hex"===e?function(e){for(var t="",r=0;r=v,"outlen must be at least "+v+", was given "+e),n(e<=w,"outlen must be at most "+w+", was given "+e),null!=t&&n(t.length>=_,"key must be at least "+_+", was given "+t.length),null!=t&&n(t.length<=E,"key must be at most "+E+", was given "+t.length),null!=r&&n(r.length===S,"salt must be exactly "+S+", was given "+r.length),null!=i&&n(i.length===A,"personal must be exactly "+A+", was given "+i.length)),new b(e,t,r,i)},e.exports.ready=function(e){i.ready((function(){e()}))},e.exports.WASM_SUPPORTED=i.SUPPORTED,e.exports.WASM_LOADED=!1;var v=e.exports.BYTES_MIN=16,w=e.exports.BYTES_MAX=64,_=(e.exports.BYTES=32,e.exports.KEYBYTES_MIN=16),E=e.exports.KEYBYTES_MAX=64,S=(e.exports.KEYBYTES=32,e.exports.SALTBYTES=16),A=e.exports.PERSONALBYTES=16;i.ready((function(t){t||(e.exports.WASM_LOADED=!0,b=i)}))},function(e,t,r){var n=r(193),i=r(393)(),o=64,a=[];e.exports=d;var s=e.exports.BYTES_MIN=16,u=e.exports.BYTES_MAX=64,f=(e.exports.BYTES=32,e.exports.KEYBYTES_MIN=16),c=e.exports.KEYBYTES_MAX=64,l=(e.exports.KEYBYTES=32,e.exports.SALTBYTES=16),h=e.exports.PERSONALBYTES=16;function d(e,t,r,p,g){if(!(this instanceof d))return new d(e,t,r,p,g);if(!i||!i.exports)throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");e||(e=32),!0!==g&&(n(e>=s,"digestLength must be at least "+s+", was given "+e),n(e<=u,"digestLength must be at most "+u+", was given "+e),null!=t&&n(t.length>=f,"key must be at least "+f+", was given "+t.length),null!=t&&n(t.length<=c,"key must be at least "+c+", was given "+t.length),null!=r&&n(r.length===l,"salt must be exactly "+l+", was given "+r.length),null!=p&&n(p.length===h,"personal must be exactly "+h+", was given "+p.length)),a.length||(a.push(o),o+=216),this.digestLength=e,this.finalized=!1,this.pointer=a.pop(),i.memory.fill(0,0,64),i.memory[0]=this.digestLength,i.memory[1]=t?t.length:0,i.memory[2]=1,i.memory[3]=1,r&&i.memory.set(r,32),p&&i.memory.set(p,48),this.pointer+216>i.memory.length&&i.realloc(this.pointer+216),i.exports.blake2b_init(this.pointer,this.digestLength),t&&(this.update(t),i.memory.fill(0,o,o+t.length),i.memory[this.pointer+200]=128)}function p(){}function g(e){return e<16?"0"+e.toString(16):e.toString(16)}d.prototype.update=function(e){return n(!1===this.finalized,"Hash instance finalized"),n(e,"input must be TypedArray or Buffer"),o+e.length>i.memory.length&&i.realloc(o+e.length),i.memory.set(e,o),i.exports.blake2b_update(this.pointer,o,o+e.length),this},d.prototype.digest=function(e){if(n(!1===this.finalized,"Hash instance finalized"),this.finalized=!0,a.push(this.pointer),i.exports.blake2b_final(this.pointer),!e||"binary"===e)return i.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if("hex"===e)return function(e,t,r){for(var n="",i=0;i=this.digestLength,"input must be TypedArray or Buffer");for(var t=0;t>25;return(33554431&e)<<5^996825010&-(t>>0&1)^642813549&-(t>>1&1)^513874426&-(t>>2&1)^1027748829&-(t>>3&1)^705979059&-(t>>4&1)}function a(e){let t=1;for(let r=0;r126)throw new Error("Invalid prefix ("+e+")");t=o(t)^n>>5}t=o(t);for(let r=0;r=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<=t)throw new Error("Excess padding");if(i<90)throw new TypeError(e+" too long");let t=e.toLowerCase(),r=e.toUpperCase();if(e!==t&&e!==r)throw new Error("Mixed-case string "+e);let n=(e=t).lastIndexOf("1");if(0===n)throw new Error("Missing prefix for "+e);let s=e.slice(0,n),u=e.slice(n+1);if(u.length<6)throw new Error("Data too short");let f=a(s),c=[];for(let e=0;e=u.length||c.push(r)}if(1!==f)throw new Error("Invalid checksum for "+e);return{prefix:s,words:c}},encode:function(e,t){if(e.length+7+t.length>90)throw new TypeError("Exceeds Bech32 maximum length");let r=a(e=e.toLowerCase()),i=e+"1";for(let e=0;e>5!=0)throw new Error("Non 5-bit word");r=o(r)^a,i+=n.charAt(a)}for(let e=0;e<6;++e)r=o(r);r^=1;for(let e=0;e<6;++e){i+=n.charAt(r>>5*(5-e)&31)}return i},toWords:function(e){return s(e,8,5,!0)},fromWords:function(e){return s(e,5,8,!1)}}},function(e,t,r){"use strict";var n=r(194),Buffer=r(7).Buffer;e.exports=function(e){function t(t){var r=t.slice(0,-4),n=t.slice(-4),i=e(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(t){var r=e(t);return n.encode(Buffer.concat([t,r],t.length+4))},decode:function(e){var r=t(n.decode(e));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(e){var r=n.decodeUnsafe(e);if(r)return t(r)}}}},function(e,t,r){"use strict";var n=r(7).Buffer;e.exports=function(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r>>0,c=new Uint8Array(a);e[r];){var l=t[e.charCodeAt(r)];if(255===l)return;for(var h=0,d=a-1;(0!==l||h>>0,c[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}if(" "!==e[r]){for(var p=a-o;p!==a&&0===c[p];)p++;var g=n.allocUnsafe(i+(a-p));g.fill(0,0,i);for(var y=i;p!==a;)g[y++]=c[p++];return g}}}return{encode:function(t){if((Array.isArray(t)||t instanceof Uint8Array)&&(t=n.from(t)),!n.isBuffer(t))throw new TypeError("Expected Buffer");if(0===t.length)return"";for(var r=0,i=0,o=0,a=t.length;o!==a&&0===t[o];)o++,r++;for(var f=(a-o)*c+1>>>0,l=new Uint8Array(f);o!==a;){for(var h=t[o],d=0,p=f-1;(0!==h||d>>0,l[p]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=d,o++}for(var g=f-i;g!==f&&0===l[g];)g++;for(var y=u.repeat(r);g=0||!r(l);)a=n("sha256",a).update(c).update(s).digest(),c=n("sha256",a).update(c).digest(),c=n("sha256",a).update(c).digest(),l=BigInteger.fromBuffer(c);return l}var l=f.n.shiftRight(1);e.exports={deterministicGenerateK:c,sign:function(e,t){i(o.tuple(o.Hash256bit,o.BigInt),arguments);var r,n,s=t.toBuffer(32),u=BigInteger.fromBuffer(e),h=f.n,d=f.G;return c(e,s,(function(e){var i=d.multiply(e);return!f.isInfinity(i)&&(0!==(r=i.affineX.mod(h)).signum()&&0!==(n=e.modInverse(h).multiply(u.add(t.multiply(r))).mod(h)).signum())})),n.compareTo(l)>0&&(n=h.subtract(n)),new a(r,n)},verify:function(e,t,r){i(o.tuple(o.Hash256bit,o.ECSignature,o.ECPoint),arguments);var n=f.n,a=f.G,s=t.r,u=t.s;if(s.signum()<=0||s.compareTo(n)>=0)return!1;if(u.signum()<=0||u.compareTo(n)>=0)return!1;var c=BigInteger.fromBuffer(e),l=u.modInverse(n),h=c.multiply(l).mod(n),d=s.multiply(l).mod(n),p=a.multiplyTwo(h,r,d);if(f.isInfinity(p))return!1;var g=p.affineX,y=g.mod(n);return y.equals(s)},__curve:f}},function(e,t,r){var BigInteger=r(37),n=r(399),i=r(196);e.exports=function(e){var t=n[e];if(!t)return null;var r=new BigInteger(t.p,16),o=new BigInteger(t.a,16),a=new BigInteger(t.b,16),s=new BigInteger(t.n,16),u=new BigInteger(t.h,16),f=new BigInteger(t.Gx,16),c=new BigInteger(t.Gy,16);return new i(r,o,a,f,c,s,u)}},function(e){e.exports=JSON.parse('{"secp128r1":{"p":"fffffffdffffffffffffffffffffffff","a":"fffffffdfffffffffffffffffffffffc","b":"e87579c11079f43dd824993c2cee5ed3","n":"fffffffe0000000075a30d1b9038a115","h":"01","Gx":"161ff7528b899b2d0c28607ca52c5b86","Gy":"cf5ac8395bafeb13c02da292dded7a83"},"secp160k1":{"p":"fffffffffffffffffffffffffffffffeffffac73","a":"00","b":"07","n":"0100000000000000000001b8fa16dfab9aca16b6b3","h":"01","Gx":"3b4c382ce37aa192a4019e763036f4f5dd4d7ebb","Gy":"938cf935318fdced6bc28286531733c3f03c4fee"},"secp160r1":{"p":"ffffffffffffffffffffffffffffffff7fffffff","a":"ffffffffffffffffffffffffffffffff7ffffffc","b":"1c97befc54bd7a8b65acf89f81d4d4adc565fa45","n":"0100000000000000000001f4c8f927aed3ca752257","h":"01","Gx":"4a96b5688ef573284664698968c38bb913cbfc82","Gy":"23a628553168947d59dcc912042351377ac5fb32"},"secp192k1":{"p":"fffffffffffffffffffffffffffffffffffffffeffffee37","a":"00","b":"03","n":"fffffffffffffffffffffffe26f2fc170f69466a74defd8d","h":"01","Gx":"db4ff10ec057e9ae26b07d0280b7f4341da5d1b1eae06c7d","Gy":"9b2f2f6d9c5628a7844163d015be86344082aa88d95e2f9d"},"secp192r1":{"p":"fffffffffffffffffffffffffffffffeffffffffffffffff","a":"fffffffffffffffffffffffffffffffefffffffffffffffc","b":"64210519e59c80e70fa7e9ab72243049feb8deecc146b9b1","n":"ffffffffffffffffffffffff99def836146bc9b1b4d22831","h":"01","Gx":"188da80eb03090f67cbf20eb43a18800f4ff0afd82ff1012","Gy":"07192b95ffc8da78631011ed6b24cdd573f977a11e794811"},"secp256k1":{"p":"fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","a":"00","b":"07","n":"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141","h":"01","Gx":"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","Gy":"483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"},"secp256r1":{"p":"ffffffff00000001000000000000000000000000ffffffffffffffffffffffff","a":"ffffffff00000001000000000000000000000000fffffffffffffffffffffffc","b":"5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b","n":"ffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551","h":"01","Gx":"6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296","Gy":"4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"}}')},function(e,t,r){(function(Buffer){var t=r(59);function n(e,t){if(void 0!==t&&e[0]!==t)throw new Error("Invalid network version");if(33===e.length)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(34!==e.length)throw new Error("Invalid WIF length");if(1!==e[33])throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function i(e,t,r){var n=new Buffer(r?34:33);return n.writeUInt8(e,0),t.copy(n,1),r&&(n[33]=1),n}e.exports={decode:function(e,r){return n(t.decode(e),r)},decodeRaw:n,encode:function(e,r,n){return"number"==typeof e?t.encode(i(e,r,n)):t.encode(i(e.version,e.privateKey,e.compressed))},encodeRaw:i}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";e.exports=r(402)(r(405))},function(e,t,r){"use strict";var n=r(403),i=r(404),o=r(198);function a(e,t){return void 0===e?t:(n.isBoolean(e,o.COMPRESSED_TYPE_INVALID),e)}e.exports=function(e){return{privateKeyVerify:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0);var s=e.privateKeyExport(t,r);return i.privateKeyExport(t,s,r)},privateKeyImport:function(t){if(n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),(t=i.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(o.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return n.isBuffer(t,o.EC_PRIVATE_KEY_TYPE_INVALID),n.isBufferLength(t,32,o.EC_PRIVATE_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),r=a(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakAdd(t,r,i)},publicKeyTweakMul:function(t,r,i){return n.isBuffer(t,o.EC_PUBLIC_KEY_TYPE_INVALID),n.isBufferLength2(t,33,65,o.EC_PUBLIC_KEY_LENGTH_INVALID),n.isBuffer(r,o.TWEAK_TYPE_INVALID),n.isBufferLength(r,32,o.TWEAK_LENGTH_INVALID),i=a(i,!0),e.publicKeyTweakMul(t,r,i)},publicKeyCombine:function(t,r){n.isArray(t,o.EC_PUBLIC_KEYS_TYPE_INVALID),n.isLengthGTZero(t,o.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var i=0;i=r)throw RangeError(n)}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var Buffer=r(7).Buffer,n=r(104),i=Buffer.from([48,129,211,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,133,48,129,130,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,33,2,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,36,3,34,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]),o=Buffer.from([48,130,1,19,2,1,1,4,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,129,165,48,129,162,2,1,1,48,44,6,7,42,134,72,206,61,1,1,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,255,255,252,47,48,6,4,1,0,4,1,7,4,65,4,121,190,102,126,249,220,187,172,85,160,98,149,206,135,11,7,2,155,252,219,45,206,40,217,89,242,129,91,22,248,23,152,72,58,218,119,38,163,196,101,93,164,251,252,14,17,8,168,253,23,180,72,166,133,84,25,156,71,208,143,251,16,212,184,2,33,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65,2,1,1,161,68,3,66,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);t.privateKeyExport=function(e,t,r){var n=Buffer.from(r?i:o);return e.copy(n,r?8:9),t.copy(n,r?181:214),n},t.privateKeyImport=function(e){var t=e.length,r=0;if(!(t2||t1?e[r+n-2]<<8:0);if(!(t<(r+=n)+i||t32||t1&&0===t[i]&&!(128&t[i+1]);--r,++i);for(var o=Buffer.concat([Buffer.from([0]),e.s]),a=33,s=0;a>1&&0===o[s]&&!(128&o[s+1]);--a,++s);return n.encode(t.slice(i),o.slice(s))},t.signatureImport=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0);try{var i=n.decode(e);if(33===i.r.length&&0===i.r[0]&&(i.r=i.r.slice(1)),i.r.length>32)throw new Error("R length is too long");if(33===i.s.length&&0===i.s[0]&&(i.s=i.s.slice(1)),i.s.length>32)throw new Error("S length is too long")}catch(e){return}return i.r.copy(t,32-i.r.length),i.s.copy(r,32-i.s.length),{r:t,s:r}},t.signatureImportLax=function(e){var t=Buffer.alloc(32,0),r=Buffer.alloc(32,0),n=e.length,i=0;if(48===e[i++]){var o=e[i++];if(!(128&o&&(i+=o-128)>n)&&2===e[i++]){var a=e[i++];if(128&a){if(i+(o=a-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(a=0;o>0;i+=1,o-=1)a=(a<<8)+e[i]}if(!(a>n-i)){var s=i;if(i+=a,2===e[i++]){var u=e[i++];if(128&u){if(i+(o=u-128)>n)return;for(;o>0&&0===e[i];i+=1,o-=1);for(u=0;o>0;i+=1,o-=1)u=(u<<8)+e[i]}if(!(u>n-i)){var f=i;for(i+=u;a>0&&0===e[s];a-=1,s+=1);if(!(a>32)){var c=e.slice(s,s+a);for(c.copy(t,32-c.length);u>0&&0===e[f];u-=1,f+=1);if(!(u>32)){var l=e.slice(f,f+u);return l.copy(r,32-l.length),{r:t,s:r}}}}}}}}}},function(e,t,r){"use strict";var Buffer=r(7).Buffer,n=r(35),i=r(18),o=r(66).ec,a=r(198),s=new o("secp256k1"),u=s.curve;function f(e){var t=e[0];switch(t){case 2:case 3:return 33!==e.length?null:function(e,t){var r=new i(t);if(r.cmp(u.p)>=0)return null;var n=(r=r.toRed(u.red)).redSqr().redIMul(r).redIAdd(u.b).redSqrt();return 3===e!==n.isOdd()&&(n=n.redNeg()),s.keyPair({pub:{x:r,y:n}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var n=new i(t),o=new i(r);if(n.cmp(u.p)>=0||o.cmp(u.p)>=0)return null;if(n=n.toRed(u.red),o=o.toRed(u.red),(6===e||7===e)&&o.isOdd()!==(7===e))return null;var a=n.redSqr().redIMul(n);return o.redSqr().redISub(a.redIAdd(u.b)).isZero()?s.keyPair({pub:{x:n,y:o}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new i(e);return t.cmp(u.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return Buffer.from(s.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new i(e);return t.isZero()?Buffer.alloc(32):u.n.sub(t).umod(u.n).toArrayLike(Buffer,"be",32)},t.privateKeyModInverse=function(e){var t=new i(e);if(t.cmp(u.n)>=0||t.isZero())throw new Error(a.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(u.n).toArrayLike(Buffer,"be",32)},t.privateKeyTweakAdd=function(e,t){var r=new i(t);if(r.cmp(u.n)>=0)throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(r.iadd(new i(e)),r.cmp(u.n)>=0&&r.isub(u.n),r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return r.toArrayLike(Buffer,"be",32)},t.privateKeyTweakMul=function(e,t){var r=new i(t);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return r.imul(new i(e)),r.cmp(u.n)&&(r=r.umod(u.n)),r.toArrayLike(Buffer,"be",32)},t.publicKeyCreate=function(e,t){var r=new i(e);if(r.cmp(u.n)>=0||r.isZero())throw new Error(a.EC_PUBLIC_KEY_CREATE_FAIL);return Buffer.from(s.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var r=f(e);if(null===r)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return Buffer.from(r.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==f(e)},t.publicKeyTweakAdd=function(e,t,r){var n=f(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(u.n)>=0)throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=u.g.mul(t).add(n.pub);if(o.isInfinity())throw new Error(a.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return Buffer.from(o.encode(!0,r))},t.publicKeyTweakMul=function(e,t,r){var n=f(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new i(t)).cmp(u.n)>=0||t.isZero())throw new Error(a.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return Buffer.from(n.pub.mul(t).encode(!0,r))},t.publicKeyCombine=function(e,t){for(var r=new Array(e.length),n=0;n=0||r.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);var n=Buffer.from(e);return 1===r.cmp(s.nh)&&u.n.sub(r).toArrayLike(Buffer,"be",32).copy(n,32),n},t.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new i(t).cmp(u.n)>=0||new i(r).cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},t.signatureImport=function(e){var t=new i(e.r);t.cmp(u.n)>=0&&(t=new i(0));var r=new i(e.s);return r.cmp(u.n)>=0&&(r=new i(0)),Buffer.concat([t.toArrayLike(Buffer,"be",32),r.toArrayLike(Buffer,"be",32)])},t.sign=function(e,t,r,n){if("function"==typeof r){var o=r;r=function(r){var s=o(e,t,null,n,r);if(!Buffer.isBuffer(s)||32!==s.length)throw new Error(a.ECDSA_SIGN_FAIL);return new i(s)}}var f=new i(t);if(f.cmp(u.n)>=0||f.isZero())throw new Error(a.ECDSA_SIGN_FAIL);var c=s.sign(e,t,{canonical:!0,k:r,pers:n});return{signature:Buffer.concat([c.r.toArrayLike(Buffer,"be",32),c.s.toArrayLike(Buffer,"be",32)]),recovery:c.recoveryParam}},t.verify=function(e,t,r){var n={r:t.slice(0,32),s:t.slice(32,64)},o=new i(n.r),c=new i(n.s);if(o.cmp(u.n)>=0||c.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);if(1===c.cmp(s.nh)||o.isZero()||c.isZero())return!1;var l=f(r);if(null===l)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);return s.verify(e,n,{x:l.pub.x,y:l.pub.y})},t.recover=function(e,t,r,n){var o={r:t.slice(0,32),s:t.slice(32,64)},f=new i(o.r),c=new i(o.s);if(f.cmp(u.n)>=0||c.cmp(u.n)>=0)throw new Error(a.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||c.isZero())throw new Error;var l=s.recoverPubKey(e,o,r);return Buffer.from(l.encode(!0,n))}catch(e){throw new Error(a.ECDSA_RECOVER_FAIL)}},t.ecdh=function(e,r){var i=t.ecdhUnsafe(e,r,!0);return n("sha256").update(i).digest()},t.ecdhUnsafe=function(e,t,r){var n=f(e);if(null===n)throw new Error(a.EC_PUBLIC_KEY_PARSE_FAIL);var o=new i(t);if(o.cmp(u.n)>=0||o.isZero())throw new Error(a.ECDH_FAIL);return Buffer.from(n.pub.mul(o).encode(!0,r))}},function(e,t,r){var Buffer=r(7).Buffer,n=r(59),i=r(51),o=r(62),a=r(15),s=r(22),u=r(40),BigInteger=r(37),ECPair=r(113),f=r(73),c=f.getCurveByName("secp256k1"),l=r(197);function h(e,t){if(a(s.tuple("ECPair",s.Buffer256bit),arguments),!e.compressed)throw new TypeError("BIP32 only allows compressed keyPairs");this.keyPair=e,this.chainCode=t,this.depth=0,this.index=0,this.parentFingerprint=0,this.derivationCache={}}h.HIGHEST_BIT=2147483648,h.LENGTH=78,h.MASTER_SECRET=Buffer.from("Bitcoin seed","utf8"),h.fromSeedBuffer=function(e,t){if(a(s.tuple(s.Buffer,s.maybe(s.Network)),arguments),e.length<16)throw new TypeError("Seed should be at least 128 bits");if(e.length>64)throw new TypeError("Seed should be at most 512 bits");var r=o("sha512",h.MASTER_SECRET).update(e).digest(),n=r.slice(0,32),i=r.slice(32),u=BigInteger.fromBuffer(n),f=new ECPair(u,null,{network:t});return new h(f,i)},h.fromSeedHex=function(e,t){return h.fromSeedBuffer(Buffer.from(e,"hex"),t)},h.fromBase58=function(e,t,r=!1){var i=n.decode(e);if(78!==i.length)throw new Error("Invalid buffer length");var o,a=i.readUInt32BE(0);if(Array.isArray(t)){if(!(o=t.filter((function(e){return a===e.bip32.private||a===e.bip32.public})).pop()))throw new Error("Unknown network version")}else o=t||u.bitcoin;if(a!==o.bip32.private&&a!==o.bip32.public)throw new Error("Invalid network version");var s=i[4],l=i.readUInt32BE(5);if(0===s&&0!==l)throw new Error("Invalid parent fingerprint");var d=i.readUInt32BE(9);if(0===s&&0!==d)throw new Error("Invalid index");var p,g=i.slice(13,45);if(a===o.bip32.private){if(0!==i.readUInt8(45))throw new Error("Invalid private key");var y=BigInteger.fromBuffer(i.slice(46,78));p=new ECPair(y,null,{network:o})}else{var m=f.Point.decodeFrom(c,i.slice(45,78));r||c.validate(m),p=new ECPair(null,m,{network:o})}var b=new h(p,g);return b.depth=s,b.index=d,b.parentFingerprint=l,b},h.prototype.getAddress=function(){return this.keyPair.getAddress()},h.prototype.getIdentifier=function(){return i.hash160(this.keyPair.getPublicKeyBuffer())},h.prototype.getFingerprint=function(){return this.getIdentifier().slice(0,4)},h.prototype.getNetwork=function(){return this.keyPair.getNetwork()},h.prototype.getPublicKeyBuffer=function(){return this.keyPair.getPublicKeyBuffer()},h.prototype.neutered=function(){var e=new h(new ECPair(null,this.keyPair.Q,{network:this.keyPair.network}),this.chainCode);return e.depth=this.depth,e.index=this.index,e.parentFingerprint=this.parentFingerprint,e},h.prototype.sign=function(e){return this.keyPair.sign(e)},h.prototype.verify=function(e,t){return this.keyPair.verify(e,t)},h.prototype.toBase58=function(e){if(void 0!==e)throw new TypeError("Unsupported argument in 2.0.0");var t=this.keyPair.network,r=this.isNeutered()?t.bip32.public:t.bip32.private,i=Buffer.allocUnsafe(78);return i.writeUInt32BE(r,0),i.writeUInt8(this.depth,4),i.writeUInt32BE(this.parentFingerprint,5),i.writeUInt32BE(this.index,9),this.chainCode.copy(i,13),this.isNeutered()?this.keyPair.getPublicKeyBuffer().copy(i,45):(i.writeUInt8(0,45),this.keyPair.d.toBuffer(32).copy(i,46)),n.encode(i)},h.prototype.derive=function(e){a(s.UInt32,e);var t=e>=h.HIGHEST_BIT,r=Buffer.allocUnsafe(37);if(t){if(this.isNeutered())throw new TypeError("Could not derive hardened child key");r[0]=0,this.keyPair.d.toBuffer(32).copy(r,1),r.writeUInt32BE(e,33)}else this.keyPair.getPublicKeyBuffer().copy(r,0),r.writeUInt32BE(e,33);var n,i=o("sha512",this.chainCode).update(r).digest(),u=i.slice(0,32),d=i.slice(32),p=BigInteger.fromBuffer(u);if(p.compareTo(c.n)>=0)return this.derive(e+1);if(this.isNeutered()){var g=l.publicKeyCreate(u,!1),y=void 0!==g?f.Point.decodeFrom(c,g).add(this.keyPair.Q):c.G.multiply(p).add(this.keyPair.Q);if(c.isInfinity(y))return this.derive(e+1);n=new ECPair(null,y,{network:this.keyPair.network})}else{var m=p.add(this.keyPair.d).mod(c.n);if(0===m.signum())return this.derive(e+1);n=new ECPair(m,null,{network:this.keyPair.network})}var b=new h(n,d);return b.depth=this.depth+1,b.index=e,b.parentFingerprint=this.getFingerprint().readUInt32BE(0),b},h.prototype.deriveHardened=function(e){return a(s.UInt31,e),this.derive(e+h.HIGHEST_BIT)},h.prototype.isNeutered=function(){return!this.keyPair.d},h.prototype.derivePath=function(e,t){a(s.BIP32Path,e),a(s.maybe(s.Object),t),t=t||this.derivationCache;var r=e.split("/");if("m"===r[0]){if(this.parentFingerprint)throw new Error("Not a master node");r=r.slice(1)}return r.reduce((function(e,r){var n,i=t[r]||{};return i.node?(t=i.next,i.node):("'"===r.slice(-1)?(n=parseInt(r.slice(0,-1),10),i.node=e.deriveHardened(n)):(n=parseInt(r,10),i.node=e.derive(n)),t[r]=i,i.next={},t=i.next,i.node)}),this)},h.prototype.cloneKeypair=function(){var e=this.keyPair,t=new ECPair(e.d,e.d?null:e.Q,{network:e.network,compressed:e.compressed});if(!t.__Q){var r=l.publicKeyCreate(e.d.toBuffer(32),!1);void 0!==r&&(t.__Q=f.Point.decodeFrom(c,r))}return t},e.exports=h},function(e,t,r){var Buffer=r(7).Buffer,n=r(114),i=r(51),o=r(19),a=r(106),s=r(58),u=r(40),f=r(26),c=r(15),l=r(22),h=a.types,d=[a.types.P2PKH,a.types.P2PK,a.types.MULTISIG],p=d.concat([a.types.P2WPKH,a.types.P2WSH]),ECPair=r(113),g=r(72),y=r(112),m=r(408)("bitgo:utxolib:txbuilder");function b(e){return-1!==d.indexOf(e)}function v(e){return-1!==p.indexOf(e)}function w(e,t){if(0===e.length&&0===t.length)return{};var r,n,s,u,f,c,l,d,p,g,y=!1,m=!1,w=!1,_=o.decompile(e);a.classifyInput(_,!0)===h.P2SH&&(w=!0,f=_[_.length-1],d=a.classifyOutput(f),r=a.scriptHash.output.encode(i.hash160(f)),n=h.P2SH,u=f);var E=a.classifyWitness(t,!0);if(E===h.P2WSH){if(c=t[t.length-1],l=a.classifyOutput(c),m=!0,y=!0,0===e.length){if(r=a.witnessScriptHash.output.encode(i.sha256(c)),n=h.P2WSH,void 0!==f)throw new Error("Redeem script given when unnecessary")}else{if(!f)throw new Error("No redeemScript provided for P2WSH, but scriptSig non-empty");if(p=a.witnessScriptHash.output.encode(i.sha256(c)),!f.equals(p))throw new Error("Redeem script didn't match witnessScript")}if(!b(a.classifyOutput(c)))throw new Error("unsupported witness script");u=c,s=l,g=t.slice(0,-1)}else if(E===h.P2WPKH){y=!0;var S=t[t.length-1],A=i.hash160(S);if(0===e.length){if(r=a.witnessPubKeyHash.output.encode(A),n=h.P2WPKH,void 0!==f)throw new Error("Redeem script given when unnecessary")}else{if(!f)throw new Error("No redeemScript provided for P2WPKH, but scriptSig wasn't empty");if(p=a.witnessPubKeyHash.output.encode(A),!f.equals(p))throw new Error("Redeem script did not have the right witness program")}s=h.P2PKH,g=t}else if(f){if(!v(d))throw new Error("Bad redeemscript!");u=f,s=d,g=_.slice(0,-1)}else n=s=a.classifyInput(e),g=_;var I=function(e,t,r){var n=[],i=[];switch(e){case h.P2PKH:n=t.slice(1),i=t.slice(0,1);break;case h.P2PK:n[0]=r?a.pubKey.output.decode(r):void 0,i=t.slice(0,1);break;case h.MULTISIG:if(r)n=a.multisig.output.decode(r).pubKeys;i=t.slice(1).map((function(e){return 0===e.length?void 0:e}))}return{pubKeys:n,signatures:i}}(s,g,u),O={pubKeys:I.pubKeys,signatures:I.signatures,prevOutScript:r,prevOutType:n,signType:s,signScript:u,witness:Boolean(y)};return w&&(O.redeemScript=f,O.redeemScriptType=d),m&&(O.witnessScript=c,O.witnessScriptType=l),O}function _(e,t,r){c(l.Buffer,e);var n=o.decompile(e);t||(t=a.classifyOutput(e));var s=[];switch(t){case h.P2PKH:if(!r)break;var u=n[2],f=i.hash160(r);u.equals(f)&&(s=[r]);break;case h.P2WPKH:if(!r)break;var d=n[1],p=i.hash160(r);d.equals(p)&&(s=[r]);break;case h.P2PK:s=n.slice(0,1);break;case h.MULTISIG:s=n.slice(1,-2);break;default:return{scriptType:t}}return{pubKeys:s,scriptType:t,signatures:s.map((function(){}))}}function E(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2SH)throw new Error("PrevOutScript must be P2SH");if(!o.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent hash160(RedeemScript)")}}function S(e,t,r,n,s){var u,f,c,l,d,p,g,y,m,b=!1,v=!1,w=!1;if(r&&s){if(d=i.hash160(r),g=i.sha256(s),E(e,d),!r.equals(a.witnessScriptHash.output.encode(g)))throw new Error("Witness script inconsistent with redeem script");if(!(u=_(s,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+o.toASM(r)+'"');f=a.types.P2SH,c=a.scriptHash.output.encode(d),b=v=w=!0,l=a.types.P2WSH,y=p=u.scriptType,m=s}else if(r){if(E(e,d=i.hash160(r)),!(u=_(r,void 0,t)).pubKeys)throw new Error('RedeemScript not supported "'+o.toASM(r)+'"');f=a.types.P2SH,c=a.scriptHash.output.encode(d),b=!0,m=r,v=(y=l=u.scriptType)===a.types.P2WPKH}else if(s){if(function(e,t){if(e.prevOutType){if(e.prevOutType!==h.P2WSH)throw new Error("PrevOutScript must be P2WSH");if(!o.decompile(e.prevOutScript)[1].equals(t))throw new Error("Inconsistent sha25(WitnessScript)")}}(e,g=i.sha256(s)),!(u=_(s,void 0,t)).pubKeys)throw new Error('WitnessScript not supported "'+o.toASM(r)+'"');f=a.types.P2WSH,c=a.witnessScriptHash.output.encode(g),v=w=!0,y=p=u.scriptType,m=s}else if(e.prevOutType){if(e.prevOutType===h.P2SH||e.prevOutType===h.P2WSH)throw new Error("PrevOutScript is "+e.prevOutType+", requires redeemScript");if(f=e.prevOutType,c=e.prevOutScript,!(u=_(e.prevOutScript,e.prevOutType,t)).pubKeys)return;v=e.prevOutType===h.P2WPKH,y=f,m=c}else u=_(c=a.pubKeyHash.output.encode(i.hash160(t)),h.P2PKH,t),v=!1,y=f=h.P2PKH,m=c;y===h.P2WPKH&&(m=a.pubKeyHash.output.encode(a.witnessPubKeyHash.output.decode(m))),b&&(e.redeemScript=r,e.redeemScriptType=l),w&&(e.witnessScript=s,e.witnessScriptType=p),e.pubKeys=u.pubKeys,e.signatures=u.signatures,e.signScript=m,e.signType=y,e.prevOutScript=c,e.prevOutType=f,e.witness=v}function A(e,t,r,n){if(e===h.P2PKH){if(1===t.length&&Buffer.isBuffer(t[0])&&1===r.length)return a.pubKeyHash.input.encodeStack(t[0],r[0])}else if(e===h.P2PK){if(1===t.length&&Buffer.isBuffer(t[0]))return a.pubKey.input.encodeStack(t[0])}else{if(e!==h.MULTISIG)throw new Error("Not yet supported");if(t.length>0)return t=t.map((function(e){return e||f.OP_0})),n||(t=t.filter((function(e){return e!==f.OP_0}))),a.multisig.input.encodeStack(t)}if(!n)throw new Error("Not enough signatures provided");return[]}function I(e,t){this.prevTxMap={},this.network=e||u.bitcoin,this.maximumFeeRate=t||2500,this.inputs=[],this.tx=new y(this.network)}function O(e){return void 0!==e.prevOutScript&&void 0!==e.signScript&&void 0!==e.pubKeys&&void 0!==e.signatures&&e.signatures.length===e.pubKeys.length&&e.pubKeys.length>0&&(!1===e.witness||!0===e.witness&&void 0!==e.value)}function P(e){return e.readUInt8(e.length-1)}I.prototype.setLockTime=function(e){if(c(l.UInt32,e),this.inputs.some((function(e){return!!e.signatures&&e.signatures.some((function(e){return e}))})))throw new Error("No, this would invalidate signatures");this.tx.locktime=e},I.prototype.setVersion=function(e,t=!0){if(c(l.UInt32,e),s.isZcashType(this.network)){if(!this.network.consensusBranchId.hasOwnProperty(this.tx.version))throw new Error("Unsupported Zcash transaction");this.tx.overwintered=t?1:0}this.tx.version=e},I.prototype.setVersionGroupId=function(e){if(!s.isZcashType(this.network)||!this.tx.isOverwinterCompatible())throw new Error("expiryHeight can only be set for Zcash starting at overwinter version. Current network coin: "+this.network.coin+", version: "+this.tx.version);c(l.UInt32,e),this.tx.versionGroupId=e},I.prototype.setExpiryHeight=function(e){if(!s.isZcashType(this.network)||!this.tx.isOverwinterCompatible())throw new Error("expiryHeight can only be set for Zcash starting at overwinter version. Current network coin: "+this.network.coin+", version: "+this.tx.version);c(l.UInt32,e),this.tx.expiryHeight=e},I.prototype.setJoinSplits=function(e){if(!s.isZcashType(this.network)||!this.tx.supportsJoinSplits())throw new Error("joinsplits can only be set for Zcash starting at version 2. Current network coin: "+this.network.coin+", version: "+this.tx.version);if(e&&e.joinsplits)return this.tx.joinsplits=e.joinsplits.map((function(e){return{vpubOld:e.vpubOld,vpubNew:e.vpubNew,anchor:e.anchor,nullifiers:e.nullifiers,commitments:e.commitments,ephemeralKey:e.ephemeralKey,randomSeed:e.randomSeed,macs:e.macs,zproof:e.zproof,ciphertexts:e.ciphertexts}})),this.tx.joinsplitPubkey=e.joinsplitPubkey,void(this.tx.joinsplitSig=e.joinsplitSig);throw new Error("Invalid transaction with joinsplits")},I.fromTransaction=function(e,t){var r=t||u.bitcoin,n=new I(r);if(n.network.coin!==e.network.coin)throw new Error("This transaction is incompatible with the transaction builder");return n.setVersion(e.version,e.overwintered),n.setLockTime(e.locktime),s.isZcashType(r)&&(n.tx.isOverwinterCompatible()&&(n.setVersionGroupId(e.versionGroupId),n.setExpiryHeight(e.expiryHeight)),n.tx.supportsJoinSplits()&&n.setJoinSplits(e)),s.isDash(r)&&(c(l.UInt16,e.type),n.tx.type=e.type,n.tx.versionSupportsDashSpecialTransactions()&&(c(l.Buffer,e.extraPayload),n.tx.extraPayload=e.extraPayload)),e.outs.forEach((function(e){n.addOutput(e.script,e.value)})),e.ins.forEach((function(e){n.__addInputUnsafe(e.hash,e.index,{sequence:e.sequence,script:e.script,witness:e.witness,value:e.value})})),n.inputs.forEach((function(t,n){!function(e,t,r,n,i){if(e.redeemScriptType===h.MULTISIG&&e.redeemScript&&e.pubKeys.length!==e.signatures.length){i=i||u.bitcoin;var o=e.signatures.concat();e.signatures=e.pubKeys.map((function(a){var u,f=ECPair.fromPublicKeyBuffer(a);return o.some((function(a,c){if(!a)return!1;var l,h=g.parseScriptSignature(a);switch(i.coin){case s.BSV:case s.BCH:l=t.hashForCashSignature(r,e.signScript,n,h.hashType);break;case s.BTG:l=t.hashForGoldSignature(r,e.signScript,n,h.hashType);break;case s.ZEC:case s.TAZ:if(void 0===n)return!1;l=t.hashForZcashSignature(r,e.signScript,n,h.hashType);break;default:l=e.witness?t.hashForWitnessV0(r,e.signScript,n,h.hashType):t.hashForSignature(r,e.signScript,h.hashType)}return!!f.verify(l,h.signature)&&(o[c]=void 0,u=a,!0)})),u}))}}(t,e,n,t.value,r)})),n},I.prototype.addInput=function(e,t,r,n){if(!this.__canModifyInputs())throw new Error("No, this would invalidate signatures");var i;if("string"==typeof e)e=Buffer.from(e,"hex").reverse();else if(e instanceof y){var o=e.outs[t];n=o.script,i=o.value,e=e.getHash()}return this.__addInputUnsafe(e,t,{sequence:r,prevOutScript:n,value:i})},I.prototype.__addInputUnsafe=function(e,t,r){if(y.isCoinbaseHash(e))throw new Error("coinbase inputs not supported");var n=e.toString("hex")+":"+t;if(void 0!==this.prevTxMap[n])throw new Error("Duplicate TxOut: "+n);var i={};if(void 0!==r.script&&(i=w(r.script,r.witness||[])),void 0!==r.value&&(i.value=r.value),!i.prevOutScript&&r.prevOutScript){var o;if(!i.pubKeys&&!i.signatures){var s=_(r.prevOutScript);s.pubKeys&&(i.pubKeys=s.pubKeys,i.signatures=s.signatures),o=s.scriptType}i.prevOutScript=r.prevOutScript,i.prevOutType=o||a.classifyOutput(r.prevOutScript)}var u=this.tx.addInput(e,t,r.sequence,r.scriptSig);return this.inputs[u]=i,this.prevTxMap[n]=u,u},I.prototype.addOutput=function(e,t){if(!this.__canModifyOutputs())throw new Error("No, this would invalidate signatures");return"string"==typeof e&&(e=n.toOutputScript(e,this.network)),this.tx.addOutput(e,t)},I.prototype.build=function(){return this.__build(!1)},I.prototype.buildIncomplete=function(){return this.__build(!0)},I.prototype.__build=function(e){if(!e){if(!this.tx.ins.length)throw new Error("Transaction has no inputs");if(!this.tx.outs.length)throw new Error("Transaction has no outputs")}var t=this.tx.clone();if(this.inputs.forEach((function(r,n){if(!(r.witnessScriptType||r.redeemScriptType||r.prevOutType)&&!e)throw new Error("Transaction is not complete");var i=function(e,t){var r=e.prevOutType,n=[],i=[];b(r)&&(n=A(r,e.signatures,e.pubKeys,t));var s=!1;if(r===a.types.P2SH){if(!t&&!v(e.redeemScriptType))throw new Error("Impossible to sign this type");b(e.redeemScriptType)&&(n=A(e.redeemScriptType,e.signatures,e.pubKeys,t)),e.redeemScriptType&&(s=!0,r=e.redeemScriptType)}switch(r){case a.types.P2WPKH:i=A(a.types.P2PKH,e.signatures,e.pubKeys,t);break;case a.types.P2WSH:if(!t&&!b(e.witnessScriptType))throw new Error("Impossible to sign this type");b(e.witnessScriptType)&&((i=A(e.witnessScriptType,e.signatures,e.pubKeys,t)).push(e.witnessScript),r=e.witnessScriptType)}return s&&n.push(e.redeemScript),{type:r,script:o.compile(n),witness:i}}(r,e);if(!e&&!b(i.type)&&i.type!==a.types.P2WPKH)throw new Error(i.type+" not supported");t.setInputScript(n,i.script),t.setWitness(n,i.witness)})),!e&&this.__overMaximumFees(t.virtualSize()))throw new Error("Transaction has absurd fees");return t},I.prototype.sign=function(e,t,r,n,i,o){if(m("Signing transaction: (input: %d, hashType: %d, witnessVal: %s, witnessScript: %j)",e,n,i,o),m("Transaction Builder network: %j",this.network),t.network&&t.network!==this.network)throw new TypeError("Inconsistent network");if(!this.inputs[e])throw new Error("No input at index: "+e);n=n||y.SIGHASH_ALL;var a=this.inputs[e];if(void 0!==a.redeemScript&&r&&!a.redeemScript.equals(r))throw new Error("Inconsistent redeemScript");var u,f=t.publicKey||t.getPublicKeyBuffer();if(!O(a)){if(void 0!==i){if(void 0!==a.value&&a.value!==i)throw new Error("Input didn't match witnessValue");c(l.Satoshi,i),a.value=i}if(m("Preparing input %d for signing",e),O(a)||S(a,f,r,0,o),!O(a))throw Error(a.prevOutType+" not supported")}if(s.isBitcoinGold(this.network)?(u=this.tx.hashForGoldSignature(e,a.signScript,i,n,a.witness),m("Calculated BTG sighash (%s)",u.toString("hex"))):s.isBitcoinCash(this.network)||s.isBitcoinSV(this.network)?(u=this.tx.hashForCashSignature(e,a.signScript,i,n),m("Calculated BCH sighash (%s)",u.toString("hex"))):s.isZcashType(this.network)?(u=this.tx.hashForZcashSignature(e,a.signScript,i,n),m("Calculated ZEC sighash (%s)",u.toString("hex"))):a.witness?(u=this.tx.hashForWitnessV0(e,a.signScript,i,n),m("Calculated witnessv0 sighash (%s)",u.toString("hex"))):(u=this.tx.hashForSignature(e,a.signScript,n),m("Calculated sighash (%s)",u.toString("hex"))),!a.pubKeys.some((function(e,r){if(!f.equals(e))return!1;if(a.signatures[r])throw new Error("Signature already exists");if(33!==f.length&&a.signType===h.P2WPKH)throw new Error("BIP143 rejects uncompressed public keys in P2WPKH or P2WSH");var i=t.sign(u);return Buffer.isBuffer(i)&&(i=g.fromRSBuffer(i)),m("Produced signature (r: %s, s: %s)",i.r,i.s),a.signatures[r]=i.toScriptSignature(n),!0})))throw new Error("Key pair cannot sign for this input")},I.prototype.__canModifyInputs=function(){return this.inputs.every((function(e){return void 0===e.signatures||e.signatures.every((function(e){return!e||P(e)&y.SIGHASH_ANYONECANPAY}))}))},I.prototype.__canModifyOutputs=function(){var e=this.tx.ins.length,t=this.tx.outs.length;return this.inputs.every((function(r){return void 0===r.signatures||r.signatures.every((function(r){if(!r)return!0;var n=31&P(r);return n===y.SIGHASH_NONE||(n===y.SIGHASH_SINGLE?e<=t:void 0)}))}))},I.prototype.__overMaximumFees=function(e){return(this.inputs.reduce((function(e,t){return e+(t.value>>>0)}),0)-this.tx.outs.reduce((function(e,t){return e+t.value}),0))/e>this.maximumFeeRate},e.exports=I},function(e,t,r){(function(n){function i(){var e;try{e=t.storage.debug}catch(e){}return!e&&void 0!==n&&"env"in n&&(e=n.env.DEBUG),e}(t=e.exports=r(409)).log=function(){return"object"==typeof console&&console.log&&Function.prototype.apply.call(console.log,console,arguments)},t.formatArgs=function(e){var r=this.useColors;if(e[0]=(r?"%c":"")+this.namespace+(r?" %c":" ")+e[0]+(r?"%c ":" ")+"+"+t.humanize(this.diff),!r)return;var n="color: "+this.color;e.splice(1,0,n,"color: inherit");var i=0,o=0;e[0].replace(/%[a-zA-Z%]/g,(function(e){"%%"!==e&&(i++,"%c"===e&&(o=i))})),e.splice(o,0,n)},t.save=function(e){try{null==e?t.storage.removeItem("debug"):t.storage.debug=e}catch(e){}},t.load=i,t.useColors=function(){if("undefined"!=typeof window&&window.process&&"renderer"===window.process.type)return!0;if("undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))return!1;return"undefined"!=typeof document&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||"undefined"!=typeof window&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||"undefined"!=typeof navigator&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)},t.storage="undefined"!=typeof chrome&&void 0!==chrome.storage?chrome.storage.local:function(){try{return window.localStorage}catch(e){}}(),t.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],t.formatters.j=function(e){try{return JSON.stringify(e)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}},t.enable(i())}).call(this,r(16))},function(e,t,r){function n(e){var r;function n(){if(n.enabled){var e=n,i=+new Date,o=i-(r||i);e.diff=o,e.prev=r,e.curr=i,r=i;for(var a=new Array(arguments.length),s=0;s0)return function(e){if((e=String(e)).length>100)return;var t=/^((?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|years?|yrs?|y)?$/i.exec(e);if(!t)return;var a=parseFloat(t[1]);switch((t[2]||"ms").toLowerCase()){case"years":case"year":case"yrs":case"yr":case"y":return 315576e5*a;case"days":case"day":case"d":return a*o;case"hours":case"hour":case"hrs":case"hr":case"h":return a*i;case"minutes":case"minute":case"mins":case"min":case"m":return a*n;case"seconds":case"second":case"secs":case"sec":case"s":return a*r;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return a;default:return}}(e);if("number"===u&&!1===isNaN(e))return t.long?a(s=e,o,"day")||a(s,i,"hour")||a(s,n,"minute")||a(s,r,"second")||s+" ms":function(e){if(e>=o)return Math.round(e/o)+"d";if(e>=i)return Math.round(e/i)+"h";if(e>=n)return Math.round(e/n)+"m";if(e>=r)return Math.round(e/r)+"s";return e+"ms"}(e);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(e))}},function(e,t,r){e.exports=r(412)(r(415))},function(e,t,r){const n=r(413),i=r(414);e.exports=function(e){const t=n(e),r=i(e);return function(e,n){switch("string"==typeof e?e.toLowerCase():e){case"keccak224":return new t(1152,448,null,224,n);case"keccak256":return new t(1088,512,null,256,n);case"keccak384":return new t(832,768,null,384,n);case"keccak512":return new t(576,1024,null,512,n);case"sha3-224":return new t(1152,448,6,224,n);case"sha3-256":return new t(1088,512,6,256,n);case"sha3-384":return new t(832,768,6,384,n);case"sha3-512":return new t(576,1024,6,512,n);case"shake128":return new r(1344,256,31,n);case"shake256":return new r(1088,512,31,n);default:throw new Error("Invald algorithm: "+e)}}}},function(e,t,r){(function(Buffer){const{Transform:t}=r(87);e.exports=e=>class r extends t{constructor(t,r,n,i,o){super(o),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._hashBitLength=i,this._options=o,this._state=new e,this._state.initialize(t,r),this._finalized=!1}_transform(e,t,r){let n=null;try{this.update(e,t)}catch(e){n=e}r(n)}_flush(e){let t=null;try{this.push(this.digest())}catch(e){t=e}e(t)}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Digest already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}digest(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0,this._delimitedSuffix&&this._state.absorbLastFewBits(this._delimitedSuffix);let t=this._state.squeeze(this._hashBitLength/8);return void 0!==e&&(t=t.toString(e)),this._resetState(),t}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new r(this._rate,this._capacity,this._delimitedSuffix,this._hashBitLength,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}}).call(this,r(9).Buffer)},function(e,t,r){(function(Buffer){const{Transform:t}=r(87);e.exports=e=>class r extends t{constructor(t,r,n,i){super(i),this._rate=t,this._capacity=r,this._delimitedSuffix=n,this._options=i,this._state=new e,this._state.initialize(t,r),this._finalized=!1}_transform(e,t,r){let n=null;try{this.update(e,t)}catch(e){n=e}r(n)}_flush(){}_read(e){this.push(this.squeeze(e))}update(e,t){if(!Buffer.isBuffer(e)&&"string"!=typeof e)throw new TypeError("Data must be a string or a buffer");if(this._finalized)throw new Error("Squeeze already called");return Buffer.isBuffer(e)||(e=Buffer.from(e,t)),this._state.absorb(e),this}squeeze(e,t){this._finalized||(this._finalized=!0,this._state.absorbLastFewBits(this._delimitedSuffix));let r=this._state.squeeze(e);return void 0!==t&&(r=r.toString(t)),r}_resetState(){return this._state.initialize(this._rate,this._capacity),this}_clone(){const e=new r(this._rate,this._capacity,this._delimitedSuffix,this._options);return this._state.copy(e._state),e._finalized=this._finalized,e}}}).call(this,r(9).Buffer)},function(e,t,r){(function(Buffer){const t=r(416);function n(){this.state=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.blockSize=null,this.count=0,this.squeezing=!1}n.prototype.initialize=function(e,t){for(let e=0;e<50;++e)this.state[e]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},n.prototype.absorb=function(e){for(let r=0;r>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(t.p1600(this.state),this.count=0);return r},n.prototype.copy=function(e){for(let t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing},e.exports=n}).call(this,r(9).Buffer)},function(e,t){const r=[1,0,32898,0,32906,2147483648,2147516416,2147483648,32907,0,2147483649,0,2147516545,2147483648,32777,2147483648,138,0,136,0,2147516425,0,2147483658,0,2147516555,0,139,2147483648,32905,2147483648,32771,2147483648,32770,2147483648,128,2147483648,32778,0,2147483658,2147483648,2147516545,2147483648,32896,2147483648,2147483649,0,2147516424,2147483648];t.p1600=function(e){for(let t=0;t<24;++t){const n=e[0]^e[10]^e[20]^e[30]^e[40],i=e[1]^e[11]^e[21]^e[31]^e[41],o=e[2]^e[12]^e[22]^e[32]^e[42],a=e[3]^e[13]^e[23]^e[33]^e[43],s=e[4]^e[14]^e[24]^e[34]^e[44],u=e[5]^e[15]^e[25]^e[35]^e[45],f=e[6]^e[16]^e[26]^e[36]^e[46],c=e[7]^e[17]^e[27]^e[37]^e[47],l=e[8]^e[18]^e[28]^e[38]^e[48],h=e[9]^e[19]^e[29]^e[39]^e[49];let d=l^(o<<1|a>>>31),p=h^(a<<1|o>>>31);const g=e[0]^d,y=e[1]^p,m=e[10]^d,b=e[11]^p,v=e[20]^d,w=e[21]^p,_=e[30]^d,E=e[31]^p,S=e[40]^d,A=e[41]^p;d=n^(s<<1|u>>>31),p=i^(u<<1|s>>>31);const I=e[2]^d,O=e[3]^p,P=e[12]^d,M=e[13]^p,k=e[22]^d,T=e[23]^p,x=e[32]^d,R=e[33]^p,C=e[42]^d,N=e[43]^p;d=o^(f<<1|c>>>31),p=a^(c<<1|f>>>31);const B=e[4]^d,D=e[5]^p,U=e[14]^d,j=e[15]^p,L=e[24]^d,F=e[25]^p,H=e[34]^d,q=e[35]^p,V=e[44]^d,K=e[45]^p;d=s^(l<<1|h>>>31),p=u^(h<<1|l>>>31);const z=e[6]^d,G=e[7]^p,Q=e[16]^d,W=e[17]^p,Y=e[26]^d,Z=e[27]^p,J=e[36]^d,X=e[37]^p,$=e[46]^d,ee=e[47]^p;d=f^(n<<1|i>>>31),p=c^(i<<1|n>>>31);const te=e[8]^d,re=e[9]^p,ne=e[18]^d,ie=e[19]^p,oe=e[28]^d,ae=e[29]^p,se=e[38]^d,ue=e[39]^p,fe=e[48]^d,ce=e[49]^p,le=g,he=y,de=b<<4|m>>>28,pe=m<<4|b>>>28,ge=v<<3|w>>>29,ye=w<<3|v>>>29,me=E<<9|_>>>23,be=_<<9|E>>>23,ve=S<<18|A>>>14,we=A<<18|S>>>14,_e=I<<1|O>>>31,Ee=O<<1|I>>>31,Se=M<<12|P>>>20,Ae=P<<12|M>>>20,Ie=k<<10|T>>>22,Oe=T<<10|k>>>22,Pe=R<<13|x>>>19,Me=x<<13|R>>>19,ke=C<<2|N>>>30,Te=N<<2|C>>>30,xe=D<<30|B>>>2,Re=B<<30|D>>>2,Ce=U<<6|j>>>26,Ne=j<<6|U>>>26,Be=F<<11|L>>>21,De=L<<11|F>>>21,Ue=H<<15|q>>>17,je=q<<15|H>>>17,Le=K<<29|V>>>3,Fe=V<<29|K>>>3,He=z<<28|G>>>4,qe=G<<28|z>>>4,Ve=W<<23|Q>>>9,Ke=Q<<23|W>>>9,ze=Y<<25|Z>>>7,Ge=Z<<25|Y>>>7,Qe=J<<21|X>>>11,We=X<<21|J>>>11,Ye=ee<<24|$>>>8,Ze=$<<24|ee>>>8,Je=te<<27|re>>>5,Xe=re<<27|te>>>5,$e=ne<<20|ie>>>12,et=ie<<20|ne>>>12,tt=ae<<7|oe>>>25,rt=oe<<7|ae>>>25,nt=se<<8|ue>>>24,it=ue<<8|se>>>24,ot=fe<<14|ce>>>18,at=ce<<14|fe>>>18;e[0]=le^~Se&Be,e[1]=he^~Ae&De,e[10]=He^~$e&ge,e[11]=qe^~et&ye,e[20]=_e^~Ce&ze,e[21]=Ee^~Ne&Ge,e[30]=Je^~de&Ie,e[31]=Xe^~pe&Oe,e[40]=xe^~Ve&tt,e[41]=Re^~Ke&rt,e[2]=Se^~Be&Qe,e[3]=Ae^~De&We,e[12]=$e^~ge&Pe,e[13]=et^~ye&Me,e[22]=Ce^~ze&nt,e[23]=Ne^~Ge&it,e[32]=de^~Ie&Ue,e[33]=pe^~Oe&je,e[42]=Ve^~tt&me,e[43]=Ke^~rt&be,e[4]=Be^~Qe&ot,e[5]=De^~We&at,e[14]=ge^~Pe&Le,e[15]=ye^~Me&Fe,e[24]=ze^~nt&ve,e[25]=Ge^~it&we,e[34]=Ie^~Ue&Ye,e[35]=Oe^~je&Ze,e[44]=tt^~me&ke,e[45]=rt^~be&Te,e[6]=Qe^~ot&le,e[7]=We^~at&he,e[16]=Pe^~Le&He,e[17]=Me^~Fe&qe,e[26]=nt^~ve&_e,e[27]=it^~we&Ee,e[36]=Ue^~Ye&Je,e[37]=je^~Ze&Xe,e[46]=me^~ke&xe,e[47]=be^~Te&Re,e[8]=ot^~le&Se,e[9]=at^~he&Ae,e[18]=Le^~He&$e,e[19]=Fe^~qe&et,e[28]=ve^~_e&Ce,e[29]=we^~Ee&Ne,e[38]=Ye^~Je&de,e[39]=Ze^~Xe&pe,e[48]=ke^~xe&Ve,e[49]=Te^~Re&Ke,e[0]^=r[2*t],e[1]^=r[2*t+1]}}},function(e,t,r){"use strict";Object.freeze({SPENDADDRESS:0,SPENDMULTISIG:1,EXTERNAL:2,SPENDWITNESS:3,SPENDP2SHWITNESS:4}),Object.freeze({PAYTOADDRESS:0,PAYTOSCRIPTHASH:1,PAYTOMULTISIG:2,PAYTOOPRETURN:3,PAYTOWITNESS:4,PAYTOP2SHWITNESS:5}),Object.freeze({BITCOIN:0,MILLIBITCOIN:1,MICROBITCOIN:2,SATOSHI:3}),Object.freeze({BASE:0,BASE_SCRIPT_KEY:1,BASE_KEY_SCRIPT:2,BASE_SCRIPT_SCRIPT:3,POINTER:4,POINTER_SCRIPT:5,ENTERPRISE:6,ENTERPRISE_SCRIPT:7,BYRON:8,REWARD:14,REWARD_SCRIPT:15}),Object.freeze({STAKE_REGISTRATION:0,STAKE_DEREGISTRATION:1,STAKE_DELEGATION:2,STAKE_POOL_REGISTRATION:3}),Object.freeze({SINGLE_HOST_IP:0,SINGLE_HOST_NAME:1,MULTIPLE_HOST_NAME:2}),Object.freeze({Bip39:0,Slip39_Basic:1,Slip39_Advanced:2}),Object.freeze({Strict:0,PromptAlways:1,PromptTemporarily:2}),Object.freeze({OT_UNKNOWN:0,MARKET:1,LIMIT:2,OT_RESERVED:3}),Object.freeze({SIDE_UNKNOWN:0,BUY:1,SELL:2}),Object.freeze({TIF_UNKNOWN:0,GTE:1,TIF_RESERVED:2,IOC:3}),Object.freeze({TXINPUT:0,TXOUTPUT:1,TXMETA:2,TXFINISHED:3,TXEXTRADATA:4,TXORIGINPUT:5,TXORIGOUTPUT:6}),Object.freeze({Failure_UnexpectedMessage:1,Failure_ButtonExpected:2,Failure_DataError:3,Failure_ActionCancelled:4,Failure_PinExpected:5,Failure_PinCancelled:6,Failure_PinInvalid:7,Failure_InvalidSignature:8,Failure_ProcessError:9,Failure_NotEnoughFunds:10,Failure_NotInitialized:11,Failure_PinMismatch:12,Failure_WipeCodeMismatch:13,Failure_InvalidSession:14,Failure_FirmwareError:99}),Object.freeze({ButtonRequest_Other:1,ButtonRequest_FeeOverThreshold:2,ButtonRequest_ConfirmOutput:3,ButtonRequest_ResetDevice:4,ButtonRequest_ConfirmWord:5,ButtonRequest_WipeDevice:6,ButtonRequest_ProtectCall:7,ButtonRequest_SignTx:8,ButtonRequest_FirmwareCheck:9,ButtonRequest_Address:10,ButtonRequest_PublicKey:11,ButtonRequest_MnemonicWordCount:12,ButtonRequest_MnemonicInput:13,_Deprecated_ButtonRequest_PassphraseType:14,ButtonRequest_UnknownDerivationPath:15,ButtonRequest_RecoveryHomepage:16,ButtonRequest_Success:17,ButtonRequest_Warning:18,ButtonRequest_PassphraseEntry:19,ButtonRequest_PinEntry:20}),Object.freeze({PinMatrixRequestType_Current:1,PinMatrixRequestType_NewFirst:2,PinMatrixRequestType_NewSecond:3,PinMatrixRequestType_WipeCodeFirst:4,PinMatrixRequestType_WipeCodeSecond:5}),Object.freeze({UP:0,DOWN:1,LEFT:2,RIGHT:3}),Object.freeze({NORMAL:0,BOLD:1,MONO:2,BR:4,BR_HALF:5,SET_COLOR:6}),Object.freeze({Transfer:0,RegisterSecondPassphrase:1,RegisterDelegate:2,CastVotes:3,RegisterMultisignatureAccount:4,CreateDapp:5,TransferIntoDapp:6,TransferOutOfDapp:7}),Object.freeze({Capability_Bitcoin:1,Capability_Bitcoin_like:2,Capability_Binance:3,Capability_Cardano:4,Capability_Crypto:5,Capability_EOS:6,Capability_Ethereum:7,Capability_Lisk:8,Capability_Monero:9,Capability_NEM:10,Capability_Ripple:11,Capability_Stellar:12,Capability_Tezos:13,Capability_U2F:14,Capability_Shamir:15,Capability_ShamirGroups:16,Capability_PassphraseEntry:17}),Object.freeze({DISABLE:0,ENABLE:1,REFRESH:2}),Object.freeze({RecoveryDeviceType_ScrambledWords:0,RecoveryDeviceType_Matrix:1}),Object.freeze({WordRequestType_Plain:0,WordRequestType_Matrix9:1,WordRequestType_Matrix6:2}),Object.freeze({MosaicLevy_Absolute:1,MosaicLevy_Percentile:2}),Object.freeze({SupplyChange_Increase:1,SupplyChange_Decrease:2}),Object.freeze({CosignatoryModification_Add:1,CosignatoryModification_Delete:2}),Object.freeze({ImportanceTransfer_Activate:1,ImportanceTransfer_Deactivate:2}),Object.freeze({Implicit:0,Originated:1}),Object.freeze({Yay:0,Nay:1,Pass:2})},function(e,t,r){"use strict";t.__esModule=!0,t.getUnavailableCapabilities=t.parseCapabilities=void 0;var n=r(48),i=["Capability_Bitcoin","Capability_Bitcoin_like","Capability_Binance","Capability_Cardano","Capability_Crypto","Capability_EOS","Capability_Ethereum","Capability_Lisk","Capability_Monero","Capability_NEM","Capability_Ripple","Capability_Stellar","Capability_Tezos","Capability_U2F","Capability_Shamir","Capability_ShamirGroups","Capability_PassphraseEntry"],o=[1,2,5,7,8,10,12,14],a=[1,2,3,4,5,6,7,8,9,10,11,12,13,14];t.parseCapabilities=function(e){if(!e||!1===e.firmware_present)return[];var t=function(e){return i[e-1]?[i[e-1]]:[]};return e.capabilities&&e.capabilities.length?e.capabilities.flatMap(t):1===e.major_version?o.flatMap(t):a.flatMap(t)};t.getUnavailableCapabilities=function(e,t,r){var i=e.capabilities,o={};if(!i)return o;var a=[e.major_version,e.minor_version,e.patch_version],s=t.filter((function(e){return"bitcoin"===e.type?"Bitcoin"===e.name||"Testnet"===e.name?!i.includes("Capability_Bitcoin"):!i.includes("Capability_Bitcoin_like"):"ethereum"===e.type?!i.includes("Capability_Ethereum"):"nem"===e.type?!i.includes("Capability_NEM"):"BNB"===e.shortcut?!i.includes("Capability_Binance"):"XRP"===e.shortcut||"tXRP"===e.shortcut?!i.includes("Capability_Ripple"):!i.includes("Capability_"+e.name)}));s.forEach((function(e){o[e.shortcut.toLowerCase()]="no-capability"}));var u=t.filter((function(e){return!s.includes(e)})),f="trezor"+e.major_version;return u.forEach((function(e){e.support&&"string"==typeof e.support[f]||(o[e.shortcut.toLowerCase()]="no-support",s.push(e)),(0,n.versionCompare)(e.support[f],a)>0&&(o[e.shortcut.toLowerCase()]="update-required",s.push(e))})),r.forEach((function(e){e.min&&(0,n.versionCompare)(e.min[a[0]-1],a)>0&&e.excludedMethods.forEach((function(t){o[t]=e.coin||"update-required"})),e.max&&(0,n.versionCompare)(e.max[a[0]-1],a)<0&&e.excludedMethods.forEach((function(t){o[t]=e.coin||"trezor-connect-outdated"}))})),o}},function(e,t,r){"use strict";(function(Buffer){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=void 0;var i,o=p(r(1)),a=p(r(420)),s=r(421),u=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=d();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r(422)),f=r(201),c=r(202),l=r(211),h=r(76);function d(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return d=function(){return e},e}function p(e){return e&&e.__esModule?e:{default:e}}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;ta)return 1;if(a>o)return-1;if(!isNaN(o)&&isNaN(a))return 1;if(isNaN(o)&&!isNaN(a))return-1}return 0}},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.setFetch=function(e,t){l=e,h=!!t},t.request=function(e){return y.apply(this,arguments)};var n,i=(n=r(1))&&n.__esModule?n:{default:n};function o(e){return(o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function s(e){for(var t=1;t * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/ProtoBuf.js for details */ -!function(t){"use strict";var n,i;e.exports=(n=r(425),(i={VERSION:"3.8.2",WIRE_TYPES:{}}).WIRE_TYPES.VARINT=0,i.WIRE_TYPES.BITS64=1,i.WIRE_TYPES.LDELIM=2,i.WIRE_TYPES.STARTGROUP=3,i.WIRE_TYPES.ENDGROUP=4,i.WIRE_TYPES.BITS32=5,i.PACKABLE_WIRE_TYPES=[i.WIRE_TYPES.VARINT,i.WIRE_TYPES.BITS64,i.WIRE_TYPES.BITS32],i.TYPES={int32:{name:"int32",wireType:i.WIRE_TYPES.VARINT},uint32:{name:"uint32",wireType:i.WIRE_TYPES.VARINT},sint32:{name:"sint32",wireType:i.WIRE_TYPES.VARINT},int64:{name:"int64",wireType:i.WIRE_TYPES.VARINT},uint64:{name:"uint64",wireType:i.WIRE_TYPES.VARINT},sint64:{name:"sint64",wireType:i.WIRE_TYPES.VARINT},bool:{name:"bool",wireType:i.WIRE_TYPES.VARINT},double:{name:"double",wireType:i.WIRE_TYPES.BITS64},string:{name:"string",wireType:i.WIRE_TYPES.LDELIM},bytes:{name:"bytes",wireType:i.WIRE_TYPES.LDELIM},fixed32:{name:"fixed32",wireType:i.WIRE_TYPES.BITS32},sfixed32:{name:"sfixed32",wireType:i.WIRE_TYPES.BITS32},fixed64:{name:"fixed64",wireType:i.WIRE_TYPES.BITS64},sfixed64:{name:"sfixed64",wireType:i.WIRE_TYPES.BITS64},float:{name:"float",wireType:i.WIRE_TYPES.BITS32},enum:{name:"enum",wireType:i.WIRE_TYPES.VARINT},message:{name:"message",wireType:i.WIRE_TYPES.LDELIM},group:{name:"group",wireType:i.WIRE_TYPES.STARTGROUP}},i.ID_MIN=1,i.ID_MAX=536870911,i.ByteBuffer=n,i.Long=n.Long||null,i.convertFieldsToCamelCase=!1,i.populateAccessors=!0,i.Util=function(){Object.create||(Object.create=function(e){if(arguments.length>1)throw Error("Object.create polyfill only accepts the first parameter.");function t(){}return t.prototype=e,new t});var e={IS_NODE:!1,XHR:function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=null,r=0;r0)return this.stack.shift();if(this.index>=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var e,r;do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if(this.index++,"\n"===r&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++,this.index==this.source.length)return null;this.index++,this.line++,e=!0}else{if("*"!==this.source.charAt(this.index))throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));for(r="";r+(r=this.source.charAt(this.index))!=="*/";)if(this.index++,"\n"===r&&this.line++,this.index===this.source.length)return null;this.index++,e=!0}}while(e);if(this.index===this.source.length)return null;var n=this.index;if(t.DELIM.lastIndex=0,t.DELIM.test(this.source.charAt(n)))++n;else for(++n;n>3;switch(i){case e.WIRE_TYPES.VARINT:do{n=r.readUint8()}while(128==(128&n));break;case e.WIRE_TYPES.BITS64:r.offset+=8;break;case e.WIRE_TYPES.LDELIM:n=r.readVarint32(),r.offset+=n;break;case e.WIRE_TYPES.STARTGROUP:f(o,r);break;case e.WIRE_TYPES.ENDGROUP:if(o===t)return!1;throw Error("Illegal GROUPEND after unknown group: "+o+" ("+t+" expected)");case e.WIRE_TYPES.BITS32:r.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+i)}return!0}u.build=function(t){if(this.clazz&&!t)return this.clazz;var r=function(e,t){var r=t.getChildren(e.Reflect.Message.Field),i=t.getChildren(e.Reflect.Message.OneOf),o=function(t,o){e.Builder.Message.call(this);for(var a=0,s=i.length;a0)if(1!==arguments.length||"object"!=typeof t||"function"==typeof t.encode||e.Util.isArray(t)||t instanceof n||t instanceof ArrayBuffer||e.Long&&t instanceof e.Long)for(a=0,s=arguments.length;a0;){if(a=(i=t.readVarint32())>>3,(o=7&i)===e.WIRE_TYPES.ENDGROUP){if(a!==n)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+a+" ("+(n?n+" expected":"not a group")+")");break}if(s=this._fieldsById[a])s.repeated&&!s.options.packed?c[s.name].push(s.decode(o,t)):(c[s.name]=s.decode(o,t),s.oneof&&(null!==this[s.oneof.name]&&(this[this[s.oneof.name]]=null),c[s.oneof.name]=s.name));else switch(o){case e.WIRE_TYPES.VARINT:t.readVarint32();break;case e.WIRE_TYPES.BITS32:t.offset+=4;break;case e.WIRE_TYPES.BITS64:t.offset+=8;break;case e.WIRE_TYPES.LDELIM:var l=t.readVarint32();t.offset+=l;break;case e.WIRE_TYPES.STARTGROUP:for(;f(a,t););break;default:throw Error("Illegal wire type for unknown field "+a+" in "+this.toString(!0)+"#decode: "+o)}}for(var h=0,d=this._fields.length;h4294967295?0|t:t;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!=typeof t||t==t&&t%1!=0)&&i(typeof t,"not an integer"),t<0?t>>>0:t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return h(t,!1)}catch(e){i(typeof t,e.message)}else i(typeof t,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return h(t,!0)}catch(e){i(typeof t,e.message)}else i(typeof t,"requires Long.js");case e.TYPES.bool:return"boolean"!=typeof t&&i(typeof t,"not a boolean"),t;case e.TYPES.float:case e.TYPES.double:return"number"!=typeof t&&i(typeof t,"not a number"),t;case e.TYPES.string:return"string"==typeof t||t&&t instanceof String||i(typeof t,"not a string"),""+t;case e.TYPES.bytes:return n.isByteBuffer(t)?t:n.wrap(t,"base64");case e.TYPES.enum:var a=this.resolvedType.getChildren(p.Value);for(u=0;u=0){r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var o=r.offset;for(i=0;i1){var u=r.slice(o,r.offset);o+=s-1,r.offset=o,r.append(u)}r.writeVarint32(a,o-s)}else for(i=0;i=0){for(r+=n.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),o=0,i=0;i=0&&!n){o=r.readVarint32(),o=r.offset+o;for(var a=[];r.offset>>0;case e.TYPES.sint32:return 0|r.readVarint32ZigZag();case e.TYPES.fixed32:return r.readUint32()>>>0;case e.TYPES.sfixed32:return 0|r.readInt32();case e.TYPES.int64:return r.readVarint64();case e.TYPES.uint64:return r.readVarint64().toUnsigned();case e.TYPES.sint64:return r.readVarint64ZigZag();case e.TYPES.fixed64:return r.readUint64();case e.TYPES.sfixed64:return r.readInt64();case e.TYPES.bool:return!!r.readVarint32();case e.TYPES.enum:return r.readVarint32();case e.TYPES.float:return r.readFloat();case e.TYPES.double:return r.readDouble();case e.TYPES.string:return r.readVString();case e.TYPES.bytes:if(o=r.readVarint32(),r.remaining()=0)return!1;a.push(o)}a=null}if(void 0!==r.enums){if(!e.Util.isArray(r.enums))return!1;for(n=0;n0;){if(t=r.pop(),!e.Util.isArray(t))throw Error("Not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var o=t.shift();if(i.isValidMessage(o)){var a=new n.Message(this,this.ptr,o.name,o.options,o.isGroup),s={};if(o.oneofs)for(var u=Object.keys(o.oneofs),f=0,c=u.length;f0)for(f=0,c=o.fields.length;f0)for(f=0;f0)for(f=0;fe.ID_MAX&&(a.extensions[1]=e.ID_MAX)),this.ptr.addChild(a),g.length>0){r.push(t),t=g,g=null,this.ptr=a,a=null;continue}g=null,a=null}else if(i.isValidEnum(o)){for(a=new n.Enum(this,this.ptr,o.name,o.options),f=0;fa.extensions[1])throw Error("Illegal extended field id in message "+a.name+": "+o.fields[f].id+" ("+a.extensions.join(" to ")+" expected)");var m=o.fields[f].name;this.options.convertFieldsToCamelCase&&(m=n.Message.Field._toCamelCase(o.fields[f].name)),l=new n.Message.ExtensionField(this,a,o.fields[f].rule,o.fields[f].type,this.ptr.fqn()+"."+m,o.fields[f].id,o.fields[f].options);var b=new n.Extension(this,this.ptr,o.fields[f].name,l);l.extension=b,this.ptr.addChild(b),a.addChild(l)}else if(!/\.?google\.protobuf\./.test(o.ref))throw Error("Extended message "+o.ref+" is not defined")}o=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},o.import=function(t,n){if("string"==typeof n){if(e.Util.IS_NODE&&(n=r(424).resolve(n)),!0===this.files[n])return this.reset(),this;this.files[n]=!0}if(t.imports&&t.imports.length>0){var i,o="/",a=!1;"object"==typeof n?(this.importRoot=n.root,a=!0,i=this.importRoot,n=n.file,(i.indexOf("\\")>=0||n.indexOf("\\")>=0)&&(o="\\")):"string"==typeof n?this.importRoot?i=this.importRoot:n.indexOf("/")>=0?""===(i=n.replace(/\/[^\/]*$/,""))&&(i="/"):n.indexOf("\\")>=0?(i=n.replace(/\\[^\\]*$/,""),o="\\"):i=".":i=null;for(var s=0;s=0)return!1;a.push(o)}a=null}return!0},o.resolveAll=function(){var r;if(null!=this.ptr&&"object"!=typeof this.ptr.type){if(this.ptr instanceof n.Namespace)for(var i=this.ptr.children,o=0,a=i.length;o1)throw Error("Object.create polyfill only accepts the first parameter.");function t(){}return t.prototype=e,new t});var e={IS_NODE:!1,XHR:function(){for(var e=[function(){return new XMLHttpRequest},function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}],t=null,r=0;r0)return this.stack.shift();if(this.index>=this.source.length)return null;if(this.readingString)return this.readingString=!1,this._readString();var e,r;do{for(e=!1;t.WHITESPACE.test(r=this.source.charAt(this.index));)if(this.index++,"\n"===r&&this.line++,this.index===this.source.length)return null;if("/"===this.source.charAt(this.index))if("/"===this.source.charAt(++this.index)){for(;"\n"!==this.source.charAt(this.index);)if(this.index++,this.index==this.source.length)return null;this.index++,this.line++,e=!0}else{if("*"!==this.source.charAt(this.index))throw Error("Unterminated comment at line "+this.line+": /"+this.source.charAt(this.index));for(r="";r+(r=this.source.charAt(this.index))!=="*/";)if(this.index++,"\n"===r&&this.line++,this.index===this.source.length)return null;this.index++,e=!0}}while(e);if(this.index===this.source.length)return null;var n=this.index;if(t.DELIM.lastIndex=0,t.DELIM.test(this.source.charAt(n)))++n;else for(++n;n>3;switch(i){case e.WIRE_TYPES.VARINT:do{n=r.readUint8()}while(128==(128&n));break;case e.WIRE_TYPES.BITS64:r.offset+=8;break;case e.WIRE_TYPES.LDELIM:n=r.readVarint32(),r.offset+=n;break;case e.WIRE_TYPES.STARTGROUP:f(o,r);break;case e.WIRE_TYPES.ENDGROUP:if(o===t)return!1;throw Error("Illegal GROUPEND after unknown group: "+o+" ("+t+" expected)");case e.WIRE_TYPES.BITS32:r.offset+=4;break;default:throw Error("Illegal wire type in unknown group "+t+": "+i)}return!0}u.build=function(t){if(this.clazz&&!t)return this.clazz;var r=function(e,t){var r=t.getChildren(e.Reflect.Message.Field),i=t.getChildren(e.Reflect.Message.OneOf),o=function(t,o){e.Builder.Message.call(this);for(var a=0,s=i.length;a0)if(1!==arguments.length||"object"!=typeof t||"function"==typeof t.encode||e.Util.isArray(t)||t instanceof n||t instanceof ArrayBuffer||e.Long&&t instanceof e.Long)for(a=0,s=arguments.length;a0;){if(a=(i=t.readVarint32())>>3,(o=7&i)===e.WIRE_TYPES.ENDGROUP){if(a!==n)throw Error("Illegal group end indicator for "+this.toString(!0)+": "+a+" ("+(n?n+" expected":"not a group")+")");break}if(s=this._fieldsById[a])s.repeated&&!s.options.packed?c[s.name].push(s.decode(o,t)):(c[s.name]=s.decode(o,t),s.oneof&&(null!==this[s.oneof.name]&&(this[this[s.oneof.name]]=null),c[s.oneof.name]=s.name));else switch(o){case e.WIRE_TYPES.VARINT:t.readVarint32();break;case e.WIRE_TYPES.BITS32:t.offset+=4;break;case e.WIRE_TYPES.BITS64:t.offset+=8;break;case e.WIRE_TYPES.LDELIM:var l=t.readVarint32();t.offset+=l;break;case e.WIRE_TYPES.STARTGROUP:for(;f(a,t););break;default:throw Error("Illegal wire type for unknown field "+a+" in "+this.toString(!0)+"#decode: "+o)}}for(var h=0,d=this._fields.length;h4294967295?0|t:t;case e.TYPES.uint32:case e.TYPES.fixed32:return("number"!=typeof t||t==t&&t%1!=0)&&i(typeof t,"not an integer"),t<0?t>>>0:t;case e.TYPES.int64:case e.TYPES.sint64:case e.TYPES.sfixed64:if(e.Long)try{return h(t,!1)}catch(e){i(typeof t,e.message)}else i(typeof t,"requires Long.js");case e.TYPES.uint64:case e.TYPES.fixed64:if(e.Long)try{return h(t,!0)}catch(e){i(typeof t,e.message)}else i(typeof t,"requires Long.js");case e.TYPES.bool:return"boolean"!=typeof t&&i(typeof t,"not a boolean"),t;case e.TYPES.float:case e.TYPES.double:return"number"!=typeof t&&i(typeof t,"not a number"),t;case e.TYPES.string:return"string"==typeof t||t&&t instanceof String||i(typeof t,"not a string"),""+t;case e.TYPES.bytes:return n.isByteBuffer(t)?t:n.wrap(t,"base64");case e.TYPES.enum:var a=this.resolvedType.getChildren(p.Value);for(u=0;u=0){r.writeVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),r.ensureCapacity(r.offset+=1);var o=r.offset;for(i=0;i1){var u=r.slice(o,r.offset);o+=s-1,r.offset=o,r.append(u)}r.writeVarint32(a,o-s)}else for(i=0;i=0){for(r+=n.calculateVarint32(this.id<<3|e.WIRE_TYPES.LDELIM),o=0,i=0;i=0&&!n){o=r.readVarint32(),o=r.offset+o;for(var a=[];r.offset>>0;case e.TYPES.sint32:return 0|r.readVarint32ZigZag();case e.TYPES.fixed32:return r.readUint32()>>>0;case e.TYPES.sfixed32:return 0|r.readInt32();case e.TYPES.int64:return r.readVarint64();case e.TYPES.uint64:return r.readVarint64().toUnsigned();case e.TYPES.sint64:return r.readVarint64ZigZag();case e.TYPES.fixed64:return r.readUint64();case e.TYPES.sfixed64:return r.readInt64();case e.TYPES.bool:return!!r.readVarint32();case e.TYPES.enum:return r.readVarint32();case e.TYPES.float:return r.readFloat();case e.TYPES.double:return r.readDouble();case e.TYPES.string:return r.readVString();case e.TYPES.bytes:if(o=r.readVarint32(),r.remaining()=0)return!1;a.push(o)}a=null}if(void 0!==r.enums){if(!e.Util.isArray(r.enums))return!1;for(n=0;n0;){if(t=r.pop(),!e.Util.isArray(t))throw Error("Not a valid namespace: "+JSON.stringify(t));for(;t.length>0;){var o=t.shift();if(i.isValidMessage(o)){var a=new n.Message(this,this.ptr,o.name,o.options,o.isGroup),s={};if(o.oneofs)for(var u=Object.keys(o.oneofs),f=0,c=u.length;f0)for(f=0,c=o.fields.length;f0)for(f=0;f0)for(f=0;fe.ID_MAX&&(a.extensions[1]=e.ID_MAX)),this.ptr.addChild(a),y.length>0){r.push(t),t=y,y=null,this.ptr=a,a=null;continue}y=null,a=null}else if(i.isValidEnum(o)){for(a=new n.Enum(this,this.ptr,o.name,o.options),f=0;fa.extensions[1])throw Error("Illegal extended field id in message "+a.name+": "+o.fields[f].id+" ("+a.extensions.join(" to ")+" expected)");var m=o.fields[f].name;this.options.convertFieldsToCamelCase&&(m=n.Message.Field._toCamelCase(o.fields[f].name)),l=new n.Message.ExtensionField(this,a,o.fields[f].rule,o.fields[f].type,this.ptr.fqn()+"."+m,o.fields[f].id,o.fields[f].options);var b=new n.Extension(this,this.ptr,o.fields[f].name,l);l.extension=b,this.ptr.addChild(b),a.addChild(l)}else if(!/\.?google\.protobuf\./.test(o.ref))throw Error("Extended message "+o.ref+" is not defined")}o=null}t=null,this.ptr=this.ptr.parent}return this.resolved=!1,this.result=null,this},o.import=function(t,n){if("string"==typeof n){if(e.Util.IS_NODE&&(n=r(424).resolve(n)),!0===this.files[n])return this.reset(),this;this.files[n]=!0}if(t.imports&&t.imports.length>0){var i,o="/",a=!1;"object"==typeof n?(this.importRoot=n.root,a=!0,i=this.importRoot,n=n.file,(i.indexOf("\\")>=0||n.indexOf("\\")>=0)&&(o="\\")):"string"==typeof n?this.importRoot?i=this.importRoot:n.indexOf("/")>=0?""===(i=n.replace(/\/[^\/]*$/,""))&&(i="/"):n.indexOf("\\")>=0?(i=n.replace(/\\[^\\]*$/,""),o="\\"):i=".":i=null;for(var s=0;s=0)return!1;a.push(o)}a=null}return!0},o.resolveAll=function(){var r;if(null!=this.ptr&&"object"!=typeof this.ptr.type){if(this.ptr instanceof n.Namespace)for(var i=this.ptr.children,o=0,a=i.length;o * This version of ByteBuffer.js uses an ArrayBuffer as its backing buffer which is accessed through a DataView and is @@ -54,18 +54,18 @@ object-assign * @license Long.js (c) 2013 Daniel Wirtz * Released under the Apache License, Version 2.0 * see: https://github.com/dcodeIO/Long.js for details - */i=[],void 0===(o="function"==typeof(n=function(){"use strict";function e(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=function(e){return!0===(e&&e.__isLong__)};var t={},r={};e.fromInt=function(n,i){var o,a;return i?0<=(n>>>=0)&&n<256&&(a=r[n])?a:(o=new e(n,(0|n)<0?-1:0,!0),0<=n&&n<256&&(r[n]=o),o):-128<=(n|=0)&&n<128&&(a=t[n])?a:(o=new e(n,n<0?-1:0,!1),-128<=n&&n<128&&(t[n]=o),o)},e.fromNumber=function(t,r){return r=!!r,isNaN(t)||!isFinite(t)?e.ZERO:!r&&t<=-o?e.MIN_VALUE:!r&&t+1>=o?e.MAX_VALUE:r&&t>=i?e.MAX_UNSIGNED_VALUE:t<0?e.fromNumber(-t,r).negate():new e(t%n|0,t/n|0,r)},e.fromBits=function(t,r,n){return new e(t,r,n)},e.fromString=function(t,r,n){if(0===t.length)throw Error("number format error: empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e.ZERO;if("number"==typeof r&&(n=r,r=!1),(n=n||10)<2||360)throw Error('number format error: interior "-" character: '+t);if(0===i)return e.fromString(t.substring(1),r,n).negate();for(var o=e.fromNumber(Math.pow(n,8)),a=e.ZERO,s=0;s>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*n+(this.low>>>0):this.high*n+(this.low>>>0)},e.prototype.toString=function(t){if((t=t||10)<2||36>>0).toString(t);if((r=s).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(e.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,r=31;r>0&&0==(t&1<=0},e.prototype.isOdd=function(){return 1==(1&this.low)},e.prototype.isEven=function(){return 0==(1&this.low)},e.prototype.equals=function(t){return e.isLong(t)||(t=e.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},e.eq=e.prototype.equals,e.prototype.notEquals=function(e){return!this.equals(e)},e.neq=e.prototype.notEquals,e.prototype.lessThan=function(e){return this.compare(e)<0},e.prototype.lt=e.prototype.lessThan,e.prototype.lessThanOrEqual=function(e){return this.compare(e)<=0},e.prototype.lte=e.prototype.lessThanOrEqual,e.prototype.greaterThan=function(e){return this.compare(e)>0},e.prototype.gt=e.prototype.greaterThan,e.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},e.prototype.gte=e.prototype.greaterThanOrEqual,e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.equals(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.subtract(t).isNegative()?-1:1},e.prototype.negate=function(){return!this.unsigned&&this.equals(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=e.prototype.negate,e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,a=t.high>>>16,s=65535&t.high,u=t.low>>>16,f=0,c=0,l=0,h=0;return l+=(h+=o+(65535&t.low))>>>16,h&=65535,c+=(l+=i+u)>>>16,l&=65535,f+=(c+=n+s)>>>16,c&=65535,f+=r+a,f&=65535,e.fromBits(l<<16|h,f<<16|c,this.unsigned)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.negate())},e.prototype.sub=e.prototype.subtract,e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())return e.ZERO;if(this.equals(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.equals(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.negate().multiply(t.negate()):this.negate().multiply(t).negate();if(t.isNegative())return this.multiply(t.negate()).negate();if(this.lessThan(a)&&t.lessThan(a))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,s=t.high>>>16,u=65535&t.high,f=t.low>>>16,c=65535&t.low,l=0,h=0,d=0,p=0;return d+=(p+=o*c)>>>16,p&=65535,h+=(d+=i*c)>>>16,d&=65535,h+=(d+=o*f)>>>16,d&=65535,l+=(h+=n*c)>>>16,h&=65535,l+=(h+=i*f)>>>16,h&=65535,l+=(h+=o*u)>>>16,h&=65535,l+=r*c+n*f+i*u+o*s,l&=65535,e.fromBits(d<<16|p,l<<16|h,this.unsigned)},e.prototype.mul=e.prototype.multiply,e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new Error("division by zero");if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var r,n,i;if(this.equals(e.MIN_VALUE))return t.equals(e.ONE)||t.equals(e.NEG_ONE)?e.MIN_VALUE:t.equals(e.MIN_VALUE)?e.ONE:(r=this.shiftRight(1).divide(t).shiftLeft(1)).equals(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(n=this.subtract(t.multiply(r)),i=r.add(n.divide(t)));if(t.equals(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.negate().divide(t.negate()):this.negate().divide(t).negate();if(t.isNegative())return this.divide(t.negate()).negate();for(i=e.ZERO,n=this;n.greaterThanOrEqual(t);){r=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var o=Math.ceil(Math.log(r)/Math.LN2),a=o<=48?1:Math.pow(2,o-48),s=e.fromNumber(r),u=s.multiply(t);u.isNegative()||u.greaterThan(n);)r-=a,u=(s=e.fromNumber(r,this.unsigned)).multiply(t);s.isZero()&&(s=e.ONE),i=i.add(s),n=n.subtract(u)}return i},e.prototype.div=e.prototype.divide,e.prototype.modulo=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.subtract(this.divide(t).multiply(t))},e.prototype.mod=e.prototype.modulo,e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.xor=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=e.prototype.shiftRight,e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),0==(t&=63))return this;var r=this.high;if(t<32){var n=this.low;return e.fromBits(n>>>t|r<<32-t,r>>>t,this.unsigned)}return 32===t?e.fromBits(r,0,this.unsigned):e.fromBits(r>>>t-32,0,this.unsigned)},e.prototype.shru=e.prototype.shiftRightUnsigned,e.prototype.toSigned=function(){return this.unsigned?new e(this.low,this.high,!1):this},e.prototype.toUnsigned=function(){return this.unsigned?this:new e(this.low,this.high,!0)},e})?n.apply(t,i):n)||(e.exports=o)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.protocolToJSON=function(e){var t=i(e.file[2]);return t.imports=[i(e.file[1])],t};var n=r(428);function i(e){var t={};t.package=e.package,t.options=e.options,t.services=[];var r=Object.values(e.message_type).map(s),n=function(e){var t={};return Object.values(e).forEach((function(e){var r=e.extendee.slice(1);null==t[r]&&(t[r]={},t[r].ref=r,t[r].fields=[]),t[r].fields.push(f(e))})),Object.values(t)}(e.extension);return t.messages=n.concat(r),t.enums=Object.values(e.enum_type).map(o),t}function o(e){var t={};return t.name=e.name,t.values=Object.values(e.value).map(a),t.options={},t}function a(e){var t={};return t.name=e.name,t.id=e.number,t}function s(e){var t={enums:[]};return t.name=e.name,t.options=e.options||{},t.messages=[],t.fields=Object.values(e.field).map(f),t.oneofs={},t}Object.values||(0,n.shim)();var u={1:"double",2:"float",3:"int64",4:"uint64",5:"int32",6:"fixed64",7:"fixed32",8:"bool",9:"string",10:"group",11:"message",12:"bytes",13:"uint32",14:"enum",15:"sfixed32",16:"sfixed64",17:"sint32",18:"sint64"};function f(e){var t={};return 1===e.label&&(t.rule="optional"),2===e.label&&(t.rule="required"),3===e.label&&(t.rule="repeated"),t.type=u[e.type],e.type_name&&(t.type=e.type_name.slice(1)),t.name=e.name,t.options=e.options||{},t.id=e.number,t}},function(e,t,r){"use strict";var n=r(206),i=r(208),o=r(211),a=r(212),s=r(437),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),e.exports=u},function(e,t,r){"use strict";var n=Array.prototype.slice,i=r(207),o=Object.keys,a=o?function(e){return o(e)}:r(430),s=Object.keys;a.shim=function(){Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return i(e)?s(n.call(e)):s(e)}):Object.keys=a;return Object.keys||a},e.exports=a},function(e,t,r){"use strict";var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(207),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),f=s.call((function(){}),"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(e){var t=e.constructor;return t&&t.prototype===e},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!h["$"+e]&&i.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{l(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();n=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===o.call(e),n=a(e),s=t&&"[object String]"===o.call(e),h=[];if(!t&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var p=f&&r;if(s&&e.length>0&&!i.call(e,0))for(var y=0;y0)for(var g=0;g1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var r=I(e),n=r.length>0?r[0]:"",i=O("%"+n+"%",t),a=i.name,u=i.value,f=!1,c=i.alias;c&&(n=c[0],_(r,w([0,1],c)));for(var l=1,h=!0;l=r.length){var p=s(u,d);if(h=!!p,!t&&!(d in u))throw new o("base intrinsic for "+e+" exists, but the property is not available.");u=h&&"get"in p&&!("originalValue"in p.get)?p.get:u[d]}else h=v(u,d),u=u[d];h&&!f&&(g[a]=u)}}return u}},function(e,t,r){"use strict";var n=r(209),i=r(208),o=i(n("String.prototype.indexOf"));e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&o(e,".prototype.")>-1?i(r):r}},function(e,t,r){"use strict";var n=r(212),i=r(206);e.exports=function(){var e=n();return i(Object,{values:e},{values:function(){return Object.values!==e}}),e}},function(e,t,r){"use strict";e.exports=r(41).newBuilder({}).import({package:null,messages:[{name:"DeviceDescriptor",fields:[{rule:"optional",options:{},type:"uint32",name:"vendor_id",id:1},{rule:"optional",options:{},type:"uint32",name:"product_id",id:2},{rule:"optional",options:{},type:"string",name:"serial_number",id:3},{rule:"optional",options:{},type:"string",name:"path",id:4}],enums:[],messages:[],options:{},oneofs:{}},{name:"Configuration",fields:[{rule:"repeated",options:{},type:"string",name:"whitelist_urls",id:1},{rule:"repeated",options:{},type:"string",name:"blacklist_urls",id:2},{rule:"required",options:{},type:"google.protobuf.FileDescriptorSet",name:"wire_protocol",id:3},{rule:"repeated",options:{},type:"DeviceDescriptor",name:"known_devices",id:4},{rule:"optional",options:{},type:"uint32",name:"valid_until",id:5}],enums:[],messages:[],options:{},oneofs:{}}],enums:[],imports:[{package:"google.protobuf",messages:[{name:"FileDescriptorSet",fields:[{rule:"repeated",options:{},type:"FileDescriptorProto",name:"file",id:1}],enums:[],messages:[],options:{},oneofs:{}},{name:"FileDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"string",name:"package",id:2},{rule:"repeated",options:{},type:"string",name:"dependency",id:3},{rule:"repeated",options:{},type:"int32",name:"public_dependency",id:10},{rule:"repeated",options:{},type:"int32",name:"weak_dependency",id:11},{rule:"repeated",options:{},type:"DescriptorProto",name:"message_type",id:4},{rule:"repeated",options:{},type:"EnumDescriptorProto",name:"enum_type",id:5},{rule:"repeated",options:{},type:"ServiceDescriptorProto",name:"service",id:6},{rule:"repeated",options:{},type:"FieldDescriptorProto",name:"extension",id:7},{rule:"optional",options:{},type:"FileOptions",name:"options",id:8},{rule:"optional",options:{},type:"SourceCodeInfo",name:"source_code_info",id:9}],enums:[],messages:[],options:{},oneofs:{}},{name:"DescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"repeated",options:{},type:"FieldDescriptorProto",name:"field",id:2},{rule:"repeated",options:{},type:"FieldDescriptorProto",name:"extension",id:6},{rule:"repeated",options:{},type:"DescriptorProto",name:"nested_type",id:3},{rule:"repeated",options:{},type:"EnumDescriptorProto",name:"enum_type",id:4},{rule:"repeated",options:{},type:"ExtensionRange",name:"extension_range",id:5},{rule:"optional",options:{},type:"MessageOptions",name:"options",id:7}],enums:[],messages:[{name:"ExtensionRange",fields:[{rule:"optional",options:{},type:"int32",name:"start",id:1},{rule:"optional",options:{},type:"int32",name:"end",id:2}],enums:[],messages:[],options:{},oneofs:{}}],options:{},oneofs:{}},{name:"FieldDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"int32",name:"number",id:3},{rule:"optional",options:{},type:"Label",name:"label",id:4},{rule:"optional",options:{},type:"Type",name:"type",id:5},{rule:"optional",options:{},type:"string",name:"type_name",id:6},{rule:"optional",options:{},type:"string",name:"extendee",id:2},{rule:"optional",options:{},type:"string",name:"default_value",id:7},{rule:"optional",options:{},type:"FieldOptions",name:"options",id:8}],enums:[{name:"Type",values:[{name:"TYPE_DOUBLE",id:1},{name:"TYPE_FLOAT",id:2},{name:"TYPE_INT64",id:3},{name:"TYPE_UINT64",id:4},{name:"TYPE_INT32",id:5},{name:"TYPE_FIXED64",id:6},{name:"TYPE_FIXED32",id:7},{name:"TYPE_BOOL",id:8},{name:"TYPE_STRING",id:9},{name:"TYPE_GROUP",id:10},{name:"TYPE_MESSAGE",id:11},{name:"TYPE_BYTES",id:12},{name:"TYPE_UINT32",id:13},{name:"TYPE_ENUM",id:14},{name:"TYPE_SFIXED32",id:15},{name:"TYPE_SFIXED64",id:16},{name:"TYPE_SINT32",id:17},{name:"TYPE_SINT64",id:18}],options:{}},{name:"Label",values:[{name:"LABEL_OPTIONAL",id:1},{name:"LABEL_REQUIRED",id:2},{name:"LABEL_REPEATED",id:3}],options:{}}],messages:[],options:{},oneofs:{}},{name:"EnumDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"repeated",options:{},type:"EnumValueDescriptorProto",name:"value",id:2},{rule:"optional",options:{},type:"EnumOptions",name:"options",id:3}],enums:[],messages:[],options:{},oneofs:{}},{name:"EnumValueDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"int32",name:"number",id:2},{rule:"optional",options:{},type:"EnumValueOptions",name:"options",id:3}],enums:[],messages:[],options:{},oneofs:{}},{name:"ServiceDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"repeated",options:{},type:"MethodDescriptorProto",name:"method",id:2},{rule:"optional",options:{},type:"ServiceOptions",name:"options",id:3}],enums:[],messages:[],options:{},oneofs:{}},{name:"MethodDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"string",name:"input_type",id:2},{rule:"optional",options:{},type:"string",name:"output_type",id:3},{rule:"optional",options:{},type:"MethodOptions",name:"options",id:4}],enums:[],messages:[],options:{},oneofs:{}},{name:"FileOptions",fields:[{rule:"optional",options:{},type:"string",name:"java_package",id:1},{rule:"optional",options:{},type:"string",name:"java_outer_classname",id:8},{rule:"optional",options:{default:!1},type:"bool",name:"java_multiple_files",id:10},{rule:"optional",options:{default:!1},type:"bool",name:"java_generate_equals_and_hash",id:20},{rule:"optional",options:{default:"SPEED"},type:"OptimizeMode",name:"optimize_for",id:9},{rule:"optional",options:{},type:"string",name:"go_package",id:11},{rule:"optional",options:{default:!1},type:"bool",name:"cc_generic_services",id:16},{rule:"optional",options:{default:!1},type:"bool",name:"java_generic_services",id:17},{rule:"optional",options:{default:!1},type:"bool",name:"py_generic_services",id:18},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[{name:"OptimizeMode",values:[{name:"SPEED",id:1},{name:"CODE_SIZE",id:2},{name:"LITE_RUNTIME",id:3}],options:{}}],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"MessageOptions",fields:[{rule:"optional",options:{default:!1},type:"bool",name:"message_set_wire_format",id:1},{rule:"optional",options:{default:!1},type:"bool",name:"no_standard_descriptor_accessor",id:2},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"FieldOptions",fields:[{rule:"optional",options:{default:"STRING"},type:"CType",name:"ctype",id:1},{rule:"optional",options:{},type:"bool",name:"packed",id:2},{rule:"optional",options:{default:!1},type:"bool",name:"lazy",id:5},{rule:"optional",options:{default:!1},type:"bool",name:"deprecated",id:3},{rule:"optional",options:{},type:"string",name:"experimental_map_key",id:9},{rule:"optional",options:{default:!1},type:"bool",name:"weak",id:10},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[{name:"CType",values:[{name:"STRING",id:0},{name:"CORD",id:1},{name:"STRING_PIECE",id:2}],options:{}}],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"EnumOptions",fields:[{rule:"optional",options:{default:!0},type:"bool",name:"allow_alias",id:2},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"EnumValueOptions",fields:[{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"ServiceOptions",fields:[{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"MethodOptions",fields:[{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"UninterpretedOption",fields:[{rule:"repeated",options:{},type:"NamePart",name:"name",id:2},{rule:"optional",options:{},type:"string",name:"identifier_value",id:3},{rule:"optional",options:{},type:"uint64",name:"positive_int_value",id:4},{rule:"optional",options:{},type:"int64",name:"negative_int_value",id:5},{rule:"optional",options:{},type:"double",name:"double_value",id:6},{rule:"optional",options:{},type:"bytes",name:"string_value",id:7},{rule:"optional",options:{},type:"string",name:"aggregate_value",id:8}],enums:[],messages:[{name:"NamePart",fields:[{rule:"required",options:{},type:"string",name:"name_part",id:1},{rule:"required",options:{},type:"bool",name:"is_extension",id:2}],enums:[],messages:[],options:{},oneofs:{}}],options:{},oneofs:{}},{name:"SourceCodeInfo",fields:[{rule:"repeated",options:{},type:"Location",name:"location",id:1}],enums:[],messages:[{name:"Location",fields:[{rule:"repeated",options:{packed:!0},type:"int32",name:"path",id:1},{rule:"repeated",options:{packed:!0},type:"int32",name:"span",id:2},{rule:"optional",options:{},type:"string",name:"leading_comments",id:3},{rule:"optional",options:{},type:"string",name:"trailing_comments",id:4}],enums:[],messages:[],options:{},oneofs:{}}],options:{},oneofs:{}}],enums:[],imports:[],options:{java_package:"com.google.protobuf",java_outer_classname:"DescriptorProtos",optimize_for:"SPEED"},services:[]}],options:{},services:[]}).build()},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDecoder=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=i?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r(41));r(205);function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}function a(e,t){for(var r=0;rt.path?1:0:parseInt(e.path)-parseInt(t.path)}var w=(g((i=function(){function e(t,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="LowlevelTransportWithSharedConnections",this.debug=!1,this.deferedDebugOnRelease={},this.deferedNormalOnRelease={},this.configured=!1,this.stopped=!1,this._lastStringified="",this.requestNeeded=!1,this.latestId=0,this.defereds={},this.isOutdated=!1,this.plugin=t,this.version=t.version,this._sharedWorkerFactory=r,!this.plugin.allowsWriteAndEnumerate)throw new Error("Plugin with shared connections cannot disallow write and enumerate")}var t,r,n,i,a,l,d,g,m,w,_,E,S,A,I;return t=e,(r=[{key:"enumerate",value:function(){return this._silentEnumerate()}},{key:"_silentEnumerate",value:(I=p(o.default.mark((function e(){var t,r,n,i,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToWorker({type:"enumerate-intent"});case 2:return t=[],e.prev=3,e.next=6,this.plugin.enumerate();case 6:t=e.sent;case 7:return e.prev=7,e.next=10,this.sendToWorker({type:"enumerate-done"});case 10:return e.finish(7);case 11:return e.next=13,this.sendToWorker({type:"get-sessions-and-disconnect",devices:t});case 13:if("sessions"===(r=e.sent).type){e.next=16;break}throw new Error("Wrong reply");case 16:return n=r.debugSessions,i=r.normalSessions,a=t.map((function(e){var t=i[e.path],r=n[e.path];return{path:e.path,session:t,debug:e.debug,debugSession:r}})),this._releaseDisconnected(a),e.abrupt("return",a.sort(v));case 21:case"end":return e.stop()}}),e,this,[[3,,7,11]])}))),function(){return I.apply(this,arguments)})},{key:"_releaseDisconnected",value:function(e){var t=this,r={};e.forEach((function(e){null!=e.session&&(r[e.session]=!0)})),Object.keys(this.deferedDebugOnRelease).forEach((function(e){null==r[e]&&t._releaseCleanup(e,!0)})),Object.keys(this.deferedNormalOnRelease).forEach((function(e){null==r[e]&&t._releaseCleanup(e,!1)}))}},{key:"listen",value:(A=p(o.default.mark((function e(t){var r,n;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=b(t),n=null==t?this._lastStringified:r,e.abrupt("return",this._runIter(0,n));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"_runIter",value:(S=p(o.default.mark((function e(t,r){var n,i;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._silentEnumerate();case 2:if(n=e.sent,(i=b(n))===r&&60!==t){e.next=7;break}return this._lastStringified=i,e.abrupt("return",n);case 7:return e.next=9,(0,s.resolveTimeoutPromise)(500,null);case 9:return e.abrupt("return",this._runIter(t+1,i));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"acquire",value:(E=p(o.default.mark((function e(t,r){var n,i,a,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToWorker({type:"acquire-intent",path:t.path,previous:t.previous,debug:r});case 2:if("wrong-previous-session"!==(n=e.sent).type){e.next=5;break}throw new Error("wrong previous session");case 5:if("other-session"===n.type){e.next=7;break}throw new Error("Strange reply");case 7:return i=null==n.otherSession,e.prev=8,e.next=11,this.plugin.connect(t.path,r,i);case 11:e.next=18;break;case 13:return e.prev=13,e.t0=e.catch(8),e.next=17,this.sendToWorker({type:"acquire-failed"});case 17:throw e.t0;case 18:return e.next=20,this.sendToWorker({type:"acquire-done"});case 20:if("session-number"===(a=e.sent).type){e.next=23;break}throw new Error("Strange reply.");case 23:return u=a.number,r?this.deferedDebugOnRelease[u]=(0,s.create)():this.deferedNormalOnRelease[u]=(0,s.create)(),e.abrupt("return",u);case 26:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(e,t){return E.apply(this,arguments)})},{key:"release",value:(_=p(o.default.mark((function e(t,r,n){var i,a,s,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r||n){e.next=3;break}return this.sendToWorker({type:"release-onclose",session:t}),e.abrupt("return");case 3:return e.next=5,this.sendToWorker({type:"release-intent",session:t,debug:n});case 5:if("double-release"!==(i=e.sent).type){e.next=8;break}throw new Error("Trying to double release.");case 8:if("path"===i.type){e.next=10;break}throw new Error("Strange reply.");case 10:return a=i.path,s=i.otherSession,u=null==s,this._releaseCleanup(t,n),e.prev=14,e.next=17,this.plugin.disconnect(a,n,u);case 17:e.next=21;break;case 19:e.prev=19,e.t0=e.catch(14);case 21:return e.next=23,this.sendToWorker({type:"release-done"});case 23:case"end":return e.stop()}}),e,this,[[14,19]])}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_releaseCleanup",value:function(e,t){var r=t?this.deferedDebugOnRelease:this.deferedNormalOnRelease;null!=r[e]&&(r[e].reject(new Error("Device released or disconnected")),delete r[e])}},{key:"configure",value:(w=p(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=(0,u.parseConfigure)(t),this._messages=r,this.configured=!0;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"_sendLowlevel",value:function(e,t){var r=this;return function(n){return r.plugin.send(e,n,t)}}},{key:"_receiveLowlevel",value:function(e,t){var r=this;return function(){return r.plugin.receive(e,t)}}},{key:"messages",value:function(){if(null==this._messages)throw new Error("Transport not configured.");return this._messages}},{key:"doWithSession",value:(m=p(o.default.mark((function e(t,r,n){var i,a,s,u,f,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToWorker({type:"get-sessions"});case 2:if("sessions"===(i=e.sent).type){e.next=5;break}throw new Error("Wrong reply");case 5:if(a=r?i.debugSessions:i.normalSessions,s=null,Object.keys(a).forEach((function(e){a[e]===t&&(s=e)})),null!=s){e.next=10;break}throw new Error("Session not available.");case 10:return u=s,e.next=13,n(u);case 13:return f=e.sent,c=r?this.deferedDebugOnRelease[t]:this.deferedNormalOnRelease[t],e.abrupt("return",Promise.race([c.rejectingPromise,f]));case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return m.apply(this,arguments)})},{key:"call",value:(g=p(o.default.mark((function e(t,r,n,i){var a,s=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(){var e=p(o.default.mark((function e(t){var a,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=s.messages(),e.next=3,(0,f.buildAndSend)(a,s._sendLowlevel(t,i),r,n);case 3:return e.next=5,(0,c.receiveAndParse)(a,s._receiveLowlevel(t,i));case 5:return u=e.sent,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return",this.doWithSession(t,i,a));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return g.apply(this,arguments)})},{key:"post",value:(d=p(o.default.mark((function e(t,r,n,i){var a,s=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(){var e=p(o.default.mark((function e(t){var a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=s.messages(),e.next=3,(0,f.buildAndSend)(a,s._sendLowlevel(t,i),r,n);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return",this.doWithSession(t,i,a));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return d.apply(this,arguments)})},{key:"read",value:(l=p(o.default.mark((function e(t,r){var n,i=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=p(o.default.mark((function e(t){var n,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.messages(),e.next=3,(0,c.receiveAndParse)(n,i._receiveLowlevel(t,r));case 3:return a=e.sent,e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return",this.doWithSession(t,r,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"init",value:(a=p(o.default.mark((function e(t){var r=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.debug=!!t,this.requestNeeded=this.plugin.requestNeeded,e.next=4,this.plugin.init(t);case 4:null!=this._sharedWorkerFactory&&(this.sharedWorker=this._sharedWorkerFactory(),null!=this.sharedWorker&&(this.sharedWorker.port.onmessage=function(e){r.receiveFromWorker(e.data)}));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"requestDevice",value:(i=p(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.plugin.requestDevice());case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"sendToWorker",value:function(e){var t=this;if(this.stopped)return Promise.reject("Transport stopped.");this.latestId++;var r=this.latestId;return this.defereds[r]=(0,s.create)(),null!=this.sharedWorker?this.sharedWorker.port.postMessage({id:r,message:e}):(0,h.postModuleMessage)({id:r,message:e},(function(e){return t.receiveFromWorker(e)})),this.defereds[r].promise}},{key:"receiveFromWorker",value:function(e){this.defereds[e.id].resolve(e.message),delete this.defereds[e.id]}},{key:"setBridgeLatestUrl",value:function(e){}},{key:"setBridgeLatestVersion",value:function(e){}},{key:"stop",value:function(){this.stopped=!0,this.sharedWorker=null}}])&&y(t.prototype,r),n&&y(t,n),e}()).prototype,"enumerate",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"enumerate"),i.prototype),g(i.prototype,"listen",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"listen"),i.prototype),g(i.prototype,"acquire",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"acquire"),i.prototype),g(i.prototype,"release",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"release"),i.prototype),g(i.prototype,"configure",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"configure"),i.prototype),g(i.prototype,"call",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"call"),i.prototype),g(i.prototype,"post",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"post"),i.prototype),g(i.prototype,"read",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"read"),i.prototype),g(i.prototype,"init",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"init"),i.prototype),i);t.default=w,e.exports=t.default},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.patch=function(){s||(i.Reflect.Message.Field.prototype.verifyValueOriginal=i.Reflect.Message.Field.prototype.verifyValue,i.Reflect.Message.Field.prototype.verifyValue=function(e,t){var r=e;return this.type===i.TYPES.bytes&&null!=e&&"string"==typeof e&&(r=a.wrap(e,"hex")),this.verifyValueOriginal(r,t)});s=!0};var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=i?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r(41));function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}var a=i.ByteBuffer,s=!1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postModuleMessage=function(e,t){var r=e.id,n=e.message;h({id:r,message:n},{postMessage:t})};var n=r(214);"undefined"!=typeof onconnect&&(onconnect=function(e){var t=e.ports[0];t.onmessage=function(e){h(e.data,t)}});var i={},o={},a=null,s=Promise.resolve();function u(){var e=(0,n.create)();a=e,setTimeout((function(){return e.reject(new Error("Timed out"))}),1e4)}function f(e){null!=a&&a.resolve(e)}function c(){return null==a?Promise.reject(new Error("???")):a.promise}function l(e){var t=s.then((function(){return e()}));s=t.catch((function(){}))}function h(e,t){var r=e.id,n=e.message;if("acquire-intent"===n.type){var a=n.path,s=n.previous,h=n.debug;l((function(){return function(e,t,r,n,a){var s=!1,f=r?o:i,l=r?i:o,h=f[e];s=null==h?null!=t:t!==h;return s?(g({type:"wrong-previous-session"},n,a),Promise.resolve()):(u(),g({type:"other-session",otherSession:l[e]},n,a),c().then((function(t){if(t.good){var n=(++y).toString();r&&(n="debug"+n),f[e]=n,g({type:"session-number",number:n},t.id,a)}else g({type:"ok"},t.id,a)})))}(a,s,h,r,t)}))}if("acquire-done"===n.type&&function(e){f({good:!0,id:e})}(r),"acquire-failed"===n.type&&function(e){f({good:!1,id:e})}(r),"get-sessions"===n.type&&l((function(){return p(r,t)})),"get-sessions-and-disconnect"===n.type){var m=n.devices;l((function(){return p(r,t,m)}))}if("release-onclose"===n.type){var b=n.session;l((function(){return function(e){var t=null;if(Object.keys(i).forEach((function(r){i[r]===e&&(t=r)})),null==t)return Promise.resolve();var r=t;return delete i[r],delete o[r],Promise.resolve()}(b)}))}if("release-intent"===n.type){var v=n.session,w=n.debug;l((function(){return function(e,t,r,n){var a=null,s=t?o:i,f=t?i:o;if(Object.keys(s).forEach((function(t){s[t]===e&&(a=t)})),null==a)return g({type:"double-release"},r,n),Promise.resolve();var l=a,h=f[l];return u(),g({type:"path",path:l,otherSession:h},r,n),c().then((function(e){delete s[l],g({type:"ok"},e.id,n)}))}(v,w,r,t)}))}"release-done"===n.type&&d(r),"enumerate-intent"===n.type&&l((function(){return function(e,t){return u(),g({type:"ok"},e,t),c().then((function(e){g({type:"ok"},e.id,t)}))}(r,t)})),"enumerate-done"===n.type&&d(r)}function d(e){f({id:e})}function p(e,t,r){if(null!=r){var n={};r.forEach((function(e){n[e.path]=!0})),Object.keys(i).forEach((function(e){i[e]||delete i[e]})),Object.keys(o).forEach((function(e){o[e]||delete o[e]}))}return g({type:"sessions",debugSessions:o,normalSessions:i},e,t),Promise.resolve()}var y=0;function g(e,t,r){r.postMessage({id:t,message:e})}},function(e,t,r){var n="undefined"!=typeof JSON?JSON:r(444);e.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},f=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),c=[];return function e(t,a,l,h){var d=r?"\n"+new Array(h+1).join(r):"",p=r?": ":":";if(l&&l.toJSON&&"function"==typeof l.toJSON&&(l=l.toJSON()),void 0!==(l=u.call(t,a,l))){if("object"!=typeof l||null===l)return n.stringify(l);if(i(l)){for(var y=[],g=0;g="0"&&n<="9";)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&n<="9";)t+=n;if("e"===n||"E"===n)for(t+=n,u(),"-"!==n&&"+"!==n||(t+=n,u());n>="0"&&n<="9";)t+=n,u();if(e=+t,isFinite(e))return e;s("Bad number")},c=function(){var e,t,r,i="";if('"'===n)for(;u();){if('"'===n)return u(),i;if("\\"===n)if(u(),"u"===n){for(r=0,t=0;t<4&&(e=parseInt(u(),16),isFinite(e));t+=1)r=16*r+e;i+=String.fromCharCode(r)}else{if("string"!=typeof a[n])break;i+=a[n]}else i+=n}s("Bad string")},l=function(){for(;n&&n<=" ";)u()};o=function(){switch(l(),n){case"{":return function(){var e,t={};if("{"===n){if(u("{"),l(),"}"===n)return u("}"),t;for(;n;){if(e=c(),l(),u(":"),Object.hasOwnProperty.call(t,e)&&s('Duplicate key "'+e+'"'),t[e]=o(),l(),"}"===n)return u("}"),t;u(","),l()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),l(),"]"===n)return u("]"),e;for(;n;){if(e.push(o()),l(),"]"===n)return u("]"),e;u(","),l()}}s("Bad array")}();case'"':return c();case"-":return f();default:return n>="0"&&n<="9"?f():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},e.exports=function(e,t){var a;return i=e,r=0,n=" ",a=o(),l(),n&&s("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":a},""):a}},function(e,t){var r,n,i,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function s(e){return o.lastIndex=0,o.test(e)?'"'+e.replace(o,(function(e){var t=a[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+e+'"'}e.exports=function(e,t,o){var a;if(r="",n="","number"==typeof o)for(a=0;a=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0,s!==this.unreadableHidDevice&&this.unreadableHidDeviceChange.emit("change"),e.abrupt("return",this._lastDevices);case 12:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"enumerate",value:(m=c(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._listDevices();case 2:return e.abrupt("return",e.sent.map((function(e){return{path:e.path,debug:e.debug}})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"_findDevice",value:(g=c(i.default.mark((function e(t){var r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=this._lastDevices.find((function(e){return e.path===t})))){e.next=3;break}throw new Error("Action was interrupted.");case 3:return e.abrupt("return",r.device);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return g.apply(this,arguments)})},{key:"send",value:(y=c(i.default.mark((function e(t,r,n){var o,a,s;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:if(o=e.sent,(a=new Uint8Array(64))[0]=63,a.set(new Uint8Array(r),1),o.opened){e.next=9;break}return e.next=9,this.connect(t,n,!1);case 9:return s=n?this.debugEndpointId:this.normalEndpointId,e.abrupt("return",o.transferOut(s,a).then((function(){})));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return y.apply(this,arguments)})},{key:"receive",value:(p=c(i.default.mark((function e(t,r){var n,o,a;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:if(n=e.sent,o=r?this.debugEndpointId:this.normalEndpointId,e.prev=4,n.opened){e.next=8;break}return e.next=8,this.connect(t,r,!1);case 8:return e.next=10,n.transferIn(o,64);case 10:if(0!==(a=e.sent).data.byteLength){e.next=13;break}return e.abrupt("return",this.receive(t,r));case 13:return e.abrupt("return",a.data.buffer.slice(1));case 16:if(e.prev=16,e.t0=e.catch(4),"Device unavailable."!==e.t0.message){e.next=22;break}throw new Error("Action was interrupted.");case 22:throw e.t0;case 23:case"end":return e.stop()}}),e,this,[[4,16]])}))),function(e,t){return p.apply(this,arguments)})},{key:"connect",value:(h=c(i.default.mark((function e(t,r,n){var o,a,s,f=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=i.default.mark((function e(o){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o>0)){e.next=3;break}return e.next=3,new Promise((function(e){return setTimeout((function(){return e()}),200*o)}));case 3:return e.prev=3,e.next=6,f._connectIn(t,r,n);case 6:return e.t0=e.sent,e.abrupt("return",{v:e.t0});case 10:if(e.prev=10,e.t1=e.catch(3),4!==o){e.next=14;break}throw e.t1;case 14:case"end":return e.stop()}}),e,null,[[3,10]])})),a=0;case 2:if(!(a<5)){e.next=10;break}return e.delegateYield(o(a),"t0",4);case 4:if("object"!==u(s=e.t0)){e.next=7;break}return e.abrupt("return",s.v);case 7:a++,e.next=2;break;case 10:case"end":return e.stop()}}),e)}))),function(e,t,r){return h.apply(this,arguments)})},{key:"_connectIn",value:(f=c(i.default.mark((function e(t,r,n){var o,a;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:return o=e.sent,e.next=5,o.open();case 5:if(!n){e.next=15;break}return e.next=8,o.selectConfiguration(this.configurationId);case 8:return e.prev=8,e.next=11,o.reset();case 11:e.next=15;break;case 13:e.prev=13,e.t0=e.catch(8);case 15:return a=r?this.debugInterfaceId:this.normalInterfaceId,e.next=18,o.claimInterface(a);case 18:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(e,t,r){return f.apply(this,arguments)})},{key:"disconnect",value:(s=c(i.default.mark((function e(t,r,n){var o,a;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:return o=e.sent,a=r?this.debugInterfaceId:this.normalInterfaceId,e.next=6,o.releaseInterface(a);case 6:if(!n){e.next=9;break}return e.next=9,o.close();case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return s.apply(this,arguments)})},{key:"requestDevice",value:(a=c(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.usb.requestDevice({filters:d});case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})}])&&l(t.prototype,r),n&&l(t,n),e}()).prototype,"init",[a.debugInOut],Object.getOwnPropertyDescriptor(n.prototype,"init"),n.prototype),h(n.prototype,"connect",[a.debugInOut],Object.getOwnPropertyDescriptor(n.prototype,"connect"),n.prototype),h(n.prototype,"disconnect",[a.debugInOut],Object.getOwnPropertyDescriptor(n.prototype,"disconnect"),n.prototype),n);t.default=p,e.exports=t.default},function(e,t,r){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();e.exports=t=n.fetch,n.fetch&&(t.default=n.fetch.bind(n)),t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response},function(e,t,r){e.exports=function(e){return new SharedWorker(r.p+"workers/shared-connection-worker.4e3e8b51bdda80805b28.js",e)}},function(e,t,r){"use strict";function n(){return new Worker(r.p+"workers/blockbook-worker.94ed925163726194918b.js")}r.r(t),r.d(t,"default",(function(){return n}))},function(e,t,r){"use strict";function n(){return new Worker(r.p+"workers/ripple-worker.5c4760bb43dccf440277.js")}r.r(t),r.d(t,"default",(function(){return n}))},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=t.find=void 0;var i=r(6),o=(n(r(5)),n(r(454))),a=n(r(463)),s=n(r(464)),u=n(r(465)),f=n(r(466)),c=n(r(467)),l=n(r(468)),h=n(r(469)),d=n(r(470)),p=n(r(471)),y=n(r(472)),g=n(r(473)),m=n(r(474)),b=n(r(475)),v=n(r(478)),w=n(r(479)),_=n(r(505)),E=n(r(506)),S=n(r(507)),A=n(r(508)),I=n(r(509)),O=n(r(510)),P=n(r(511)),M=n(r(513)),k=n(r(514)),T=n(r(515)),x=n(r(516)),R=n(r(517)),C=n(r(518)),N=n(r(519)),B=n(r(520)),D=n(r(521)),U=n(r(522)),j=n(r(523)),L=n(r(524)),F=n(r(526)),H=n(r(527)),q=n(r(528)),V=n(r(529)),K=n(r(530)),z=n(r(531)),G=n(r(532)),Q=n(r(533)),W=n(r(536)),Y=n(r(537)),Z=n(r(538)),J=n(r(539)),X=n(r(541)),$=n(r(542)),ee=n(r(543)),te=n(r(545)),re=n(r(546)),ne=n(r(548)),ie=n(r(549)),oe=n(r(550)),ae=n(r(552)),se=n(r(553)),ue=n(r(554)),fe=n(r(555)),ce=n(r(556)),le=n(r(557)),he=n(r(558)),de=n(r(560)),pe=n(r(561)),ye={blockchainDisconnect:o.default,blockchainEstimateFee:a.default,blockchainGetAccountBalanceHistory:s.default,blockchainGetCurrentFiatRates:u.default,blockchainGetFiatRatesForTimestamps:f.default,blockchainGetTransactions:c.default,blockchainSetCustomBackend:l.default,blockchainSubscribe:h.default,blockchainSubscribeFiatRates:d.default,blockchainUnsubscribe:p.default,blockchainUnsubscribeFiatRates:y.default,cardanoGetAddress:g.default,cardanoGetPublicKey:m.default,cardanoSignTransaction:b.default,cipherKeyValue:v.default,composeTransaction:w.default,customMessage:_.default,debugLinkDecision:E.default,debugLinkGetState:S.default,ethereumGetAddress:A.default,ethereumGetPublicKey:I.default,ethereumSignMessage:O.default,ethereumSignTransaction:P.default,ethereumVerifyMessage:M.default,getAccountInfo:k.default,getAddress:T.default,getDeviceState:x.default,getFeatures:R.default,getPublicKey:C.default,getSettings:N.default,liskGetAddress:B.default,liskGetPublicKey:D.default,liskSignMessage:U.default,liskSignTransaction:L.default,liskVerifyMessage:j.default,loadDevice:F.default,pushTransaction:H.default,requestLogin:q.default,resetDevice:V.default,rippleGetAddress:K.default,rippleSignTransaction:z.default,nemGetAddress:G.default,nemSignTransaction:Q.default,signMessage:W.default,signTransaction:Y.default,stellarGetAddress:Z.default,stellarSignTransaction:J.default,tezosGetAddress:X.default,tezosGetPublicKey:$.default,tezosSignTransaction:ee.default,eosGetPublicKey:te.default,eosSignTransaction:re.default,binanceGetPublicKey:ne.default,binanceGetAddress:ie.default,binanceSignTransaction:oe.default,verifyMessage:ae.default,wipeDevice:se.default,applyFlags:ue.default,applySettings:fe.default,backupDevice:ce.default,changePin:le.default,firmwareUpdate:he.default,recoveryDevice:de.default,getCoinInfo:pe.default},ge=function(e){if(!e.payload)throw i.ERRORS.TypedError("Method_InvalidParameter","Message payload not found");if(!e.payload.method||"string"!=typeof e.payload.method)throw i.ERRORS.TypedError("Method_InvalidParameter","Message method is not set");if(ye[e.payload.method])return new ye[e.payload.method](e);throw i.ERRORS.TypedError("Method_InvalidParameter","Method "+e.payload.method+" not found")};t.find=ge;var me=ge;t.default=me},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=r(6),c=r(23),l=r(8),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=[],r.info="",r.useDevice=!1,r.useUi=!1;var n=t.payload;(0,u.validateParams)(n,[{name:"coin",type:"string",obligatory:!0}]);var i=(0,l.getCoinInfo)(n.coin);if(!i)throw f.ERRORS.TypedError("Method_UnknownCoin");return(0,c.isBackendSupported)(i),r.params={coinInfo:i},r}return(0,a.default)(t,e),t.prototype.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,(0,c.find)(this.params.coinInfo.name);case 2:return(t=e.sent)&&t.disconnect(),e.abrupt("return",{disconnected:!0});case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=h},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1?"Export multiple Cardano public keys":"Export Cardano public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,y.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-xpub",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n0&&e._ensureFeatureIsSupported("MultiassetOutputs")}))},r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._ensureFirmwareSupportsParams(),t=this.device.getCommands(),e.next=4,t.typedCall("CardanoSignTx","CardanoSignedTx",this.params);case 4:return r=e.sent,n=r.message,e.abrupt("return",{hash:n.tx_hash,serializedTx:n.serialized_tx});case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=m},function(e,t,r){"use strict";(function(Buffer){t.__esModule=!0,t.transformCertificate=void 0;var e=r(4),n=r(80),i=r(12),o=r(6),a=function(t){if((0,e.validateParams)(t,[{name:"type",type:"number",obligatory:!0}]),t.type===n.POOL_RELAY_TYPE.SingleHostIp){var r=[{name:"port",type:"number",obligatory:!0}];if(t.ipv4Address&&r.push({name:"ipv4Address",type:"string"}),t.ipv6Address&&r.push({name:"ipv6Address",type:"string"}),(0,e.validateParams)(t,r),!t.ipv4Address&&!t.ipv6Address)throw o.ERRORS.TypedError("Method_InvalidParameter","Either ipv4Address or ipv6Address must be supplied")}else t.type===n.POOL_RELAY_TYPE.SingleHostName?(0,e.validateParams)(t,[{name:"hostName",type:"string",obligatory:!0},{name:"port",type:"number",obligatory:!0}]):n.POOL_RELAY_TYPE.MultipleHostName&&(0,e.validateParams)(t,[{name:"hostName",type:"string",obligatory:!0}])},s=function(t){var r,n;(0,e.validateParams)(t,[{name:"poolId",type:"string",obligatory:!0},{name:"vrfKeyHash",type:"string",obligatory:!0},{name:"pledge",type:"string",obligatory:!0},{name:"cost",type:"string",obligatory:!0},{name:"margin",type:"object",obligatory:!0},{name:"rewardAccount",type:"string",obligatory:!0},{name:"owners",type:"array",obligatory:!0},{name:"relays",type:"array",obligatory:!0,allowEmpty:!0},{name:"metadata",type:"object"}]),r=t.margin,(0,e.validateParams)(r,[{name:"numerator",type:"string",obligatory:!0},{name:"denominator",type:"string",obligatory:!0}]),function(t){if(t.forEach((function(t){if(t.stakingKeyHash&&(0,e.validateParams)(t,[{name:"stakingKeyHash",type:"string",obligatory:!t.stakingKeyPath}]),t.stakingKeyPath&&(0,i.validatePath)(t.stakingKeyPath,5),!t.stakingKeyHash&&!t.stakingKeyPath)throw o.ERRORS.TypedError("Method_InvalidParameter","Either stakingKeyHash or stakingKeyPath must be supplied")})),1!==t.filter((function(e){return!!e.stakingKeyPath})).length)throw o.ERRORS.TypedError("Method_InvalidParameter","Exactly one pool owner must be given as a path")}(t.owners),t.relays.forEach(a),t.metadata&&(n=t.metadata,(0,e.validateParams)(n,[{name:"url",type:"string",obligatory:!0},{name:"hash",type:"string",obligatory:!0}]))};t.transformCertificate=function(t){var r,o=[{name:"type",type:"number",obligatory:!0}];return t.type!==n.CERTIFICATE_TYPE.StakePoolRegistration&&o.push({name:"path",obligatory:!0}),t.type===n.CERTIFICATE_TYPE.StakeDelegation&&o.push({name:"pool",type:"string",obligatory:!0}),t.type===n.CERTIFICATE_TYPE.StakePoolRegistration&&o.push({name:"poolParameters",type:"object",obligatory:!0}),(0,e.validateParams)(t,o),{type:t.type,path:t.path?(0,i.validatePath)(t.path,5):void 0,pool:t.pool,pool_parameters:t.poolParameters?(r=t.poolParameters,s(r),{pool_id:r.poolId,vrf_key_hash:r.vrfKeyHash,pledge:r.pledge,cost:r.cost,margin_numerator:r.margin.numerator,margin_denominator:r.margin.denominator,reward_account:r.rewardAccount,owners:r.owners.map((function(e){return{staking_key_hash:e.stakingKeyHash,staking_key_path:e.stakingKeyPath?(0,i.validatePath)(e.stakingKeyPath,5):void 0}})),relays:r.relays.map((function(e){return{type:e.type,ipv4_address:e.ipv4Address?(r=e.ipv4Address,Buffer.from(r.split(".").map((function(e){return parseInt(e)}))).toString("hex")):void 0,ipv6_address:e.ipv6Address?(t=e.ipv6Address,t.split(":").join("")):void 0,host_name:e.hostName,port:e.port};var t,r})),metadata:r.metadata}):void 0}}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";t.__esModule=!0,t.tokenBundleToProto=t.validateTokenBundle=void 0;var n=r(4);t.validateTokenBundle=function(e){e.forEach((function(e){(0,n.validateParams)(e,[{name:"policyId",type:"string",obligatory:!0},{name:"tokenAmounts",type:"array",obligatory:!0}]),e.tokenAmounts.forEach((function(e){(0,n.validateParams)(e,[{name:"assetNameBytes",type:"string",obligatory:!0},{name:"amount",type:"amount",obligatory:!0}])}))}))};t.tokenBundleToProto=function(e){return e.map((function(e){return{policy_id:e.policyId,tokens:(t=e.tokenAmounts,t.map((function(e){return{asset_name_bytes:e.assetNameBytes,amount:e.amount}})))};var t}))}},function(e,t,r){"use strict";(function(Buffer){var e=r(14),n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=e(r(20)),c=r(13),l=n(r(5)),h=r(4),d=r(12);function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t0)){e.next=18;break}return e.next=13,(0,b.initBlockchain)(r,this.postMessage);case 13:return f=e.sent,e.next=16,f.getTransactions(u);case 16:c=e.sent,s=(0,w.transformReferencedTransactions)(c,r);case 18:return l=this.device.unavailableCapabilities.replaceTransaction?E.default:_.default,e.next=21,l(this.device.getCommands().typedCall.bind(this.device.getCommands()),i,a,s,n,r);case 21:return h=e.sent,e.next=24,(0,S.default)(this.device.getCommands().getHDNode.bind(this.device.getCommands()),i,a,h.serializedTx,r);case 24:if(!this.params.push){e.next=32;break}return e.next=27,(0,b.initBlockchain)(r,this.postMessage);case 27:return d=e.sent,e.next=30,d.pushTransaction(h.serializedTx);case 30:return p=e.sent,e.abrupt("return",O(O({},h),{},{txid:p}));case 32:return e.abrupt("return",h);case 33:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.dispose=function(){var e=this.discovery;e&&(e.stop(),e.removeAllListeners(),this.discovery=void 0)},t}(c.default);t.default=P},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=n(r(29)),u=r(481),f=n(r(217)),c=(n(r(23)),r(12));function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0}}))}var t=e.prototype;return t.init=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getNetworkInfo();case 2:return r=e.sent,n=r.blockHeight,this.blockHeight=n,e.next=7,this.feeLevels.load(t);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.composeAllFeeLevels=function(){var e=this.feeLevels.levels;if(this.utxos.length<1)return!1;this.composed={};for(var t,r=!1,n=h(e);!(t=n()).done;){var i=t.value;if("0"!==i.feePerUnit){var o=this.compose(i.feePerUnit);"final"===o.type&&(r=!0),this.composed[i.label]=o}}if(!r){for(var a=e[e.length-1],u=new s.default(a.feePerUnit);u.gt(this.coinInfo.minFee)&&void 0===this.composed.custom;){u=u.minus(1);var f=this.compose(u.toString());if("final"===f.type)return this.feeLevels.updateCustomFee(u.toString()),this.composed.custom=f,!0}return!1}return!0},t.composeCustomFee=function(e){var t=this.compose(e);this.composed.custom=t,"final"===t.type?this.feeLevels.updateCustomFee(t.feePerByte):this.feeLevels.updateCustomFee(e)},t.getFeeLevelList=function(){var e=this,t=[];return this.feeLevels.levels.forEach((function(r){var n=e.composed[r.label];n&&"final"===n.type?t.push({name:r.label,fee:n.fee,feePerByte:r.feePerUnit,minutes:r.blocks*e.coinInfo.blocktime,total:n.totalSpent}):t.push({name:r.label,fee:"0",disabled:!0})})),t},t.compose=function(e){var t=this.account,r=this.coinInfo,n=this.baseFee,i=t.addresses;if(!i)return{type:"error",error:"ADDRESSES-NOT-SET"};var o=i.change.find((function(e){return e.transfers<1}))||i.change[i.change.length-1],s=(0,c.getHDPath)(o.path).slice(-1)[0],f={baseFee:n,floorBaseFee:!1,dustOutputFee:0};"DOGE"===r.shortcut&&(f.floorBaseFee=0===f.baseFee,f.baseFee=f.baseFee||1e8,f.dustOutputFee=1e8);var h=(0,u.buildTx)(function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&void 0!==arguments[2]?arguments[2]:n.networks.bitcoin;p(this,e),m(this,"socket",(0,a.deferred)()),m(this,"workingUrl","none"),m(this,"_silent",!1),m(this,"closeOnInit",new i.Emitter),this.addresses=new Set,this.socketWorkerFactory=r,this.endpoints=t,this.network=s;var u=function(e){return i.Stream.filterError(e.observe("bitcoind/addresstxid").mapPromise((function(e){var t=e.txid;return o.lookupTransaction(t)})))},f=function(e){return e.subscribe("bitcoind/hashblock"),e.observe("bitcoind/hashblock")},c=i.Stream.setLater(),l=i.Stream.setLater(),h=i.Stream.setLater();this.errors=c.stream,this.notifications=l.stream,this.blocks=h.stream;var d={"-1":!0};e._tryEndpoint(t,r,d,this.closeOnInit).then((function(e){var t=e.socket,r=e.url;o.closeOnInit.destroy(),E(t,2,!1).then((function(){o.hasSmartTxFees=!0}),(function(){o.hasSmartTxFees=!1})).then((function(){o.workingUrl=r,o.socket.resolve(t),c.setter(S(t)),l.setter(u(t)),h.setter(f(t))}))}),(function(){c.setter(i.Stream.simple(new Error("All backends are offline."))),o.socket.reject(new Error("All backends are offline.")),o.socket.promise.catch((function(e){o._silent||console.error(e)}))}))}return g(e,null,[{key:"_tryEndpoint",value:function(t,r,n,i){var a=n,u=t.filter((function(e,t){return!n[t.toString()]}));if(0===u.length)return Promise.reject(new Error("All backends are down."));var f=(0,s.uniqueRandom)(u.length);return function(e,t,r){var n=new o.Socket(e,t,r);return new Promise((function(e){S(n).awaitFirst().then((function(){e(!1)})),Promise.race([new Promise((function(e,t){return setTimeout((function(){return t()}),3e4)})),_(n,0)]).then((function(){e(!0)}),(function(){e(!1)}))})).then((function(e){return e?n:(n.close(),null)}))}(r,u[f],i).then((function(n){return n?{socket:n,url:u[f]}:(a[f.toString()]=!0,e._tryEndpoint(t,r,a,i))}))}}]),g(e,[{key:"hardStatusCheck",value:function(){var t=new e(this.endpoints,this.socketWorkerFactory);return t.socket.promise.then((function(){return t.destroy().then((function(){return!0}))}),(function(){return t.destroy().then((function(){return!1}))}))}},{key:"subscribe",value:function(e){var t=this;if(!(e instanceof Set))throw new Error("Input not a set of strings.");var r=!1;if(e.forEach((function(e){"string"!=typeof e&&(r=!0)})),r)throw new Error("Input not a set of strings.");this.socket.promise.then((function(r){var n=l(e).filter((function(e){return!t.addresses.has(e)}));if(n.forEach((function(e){return t.addresses.add(e)})),0!==n.length)for(var i=0;ie.length)&&(t=e.length);for(var r=0,n=new Array(t);rthis.count&&(this.count=e,this.emitter.emit({transactions:this.count}))}}]),e}()},function(e,t,r){"use strict"; + */i=[],void 0===(o="function"==typeof(n=function(){"use strict";function e(e,t,r){this.low=0|e,this.high=0|t,this.unsigned=!!r}e.__isLong__,Object.defineProperty(e.prototype,"__isLong__",{value:!0,enumerable:!1,configurable:!1}),e.isLong=function(e){return!0===(e&&e.__isLong__)};var t={},r={};e.fromInt=function(n,i){var o,a;return i?0<=(n>>>=0)&&n<256&&(a=r[n])?a:(o=new e(n,(0|n)<0?-1:0,!0),0<=n&&n<256&&(r[n]=o),o):-128<=(n|=0)&&n<128&&(a=t[n])?a:(o=new e(n,n<0?-1:0,!1),-128<=n&&n<128&&(t[n]=o),o)},e.fromNumber=function(t,r){return r=!!r,isNaN(t)||!isFinite(t)?e.ZERO:!r&&t<=-o?e.MIN_VALUE:!r&&t+1>=o?e.MAX_VALUE:r&&t>=i?e.MAX_UNSIGNED_VALUE:t<0?e.fromNumber(-t,r).negate():new e(t%n|0,t/n|0,r)},e.fromBits=function(t,r,n){return new e(t,r,n)},e.fromString=function(t,r,n){if(0===t.length)throw Error("number format error: empty string");if("NaN"===t||"Infinity"===t||"+Infinity"===t||"-Infinity"===t)return e.ZERO;if("number"==typeof r&&(n=r,r=!1),(n=n||10)<2||360)throw Error('number format error: interior "-" character: '+t);if(0===i)return e.fromString(t.substring(1),r,n).negate();for(var o=e.fromNumber(Math.pow(n,8)),a=e.ZERO,s=0;s>>0:this.low},e.prototype.toNumber=function(){return this.unsigned?(this.high>>>0)*n+(this.low>>>0):this.high*n+(this.low>>>0)},e.prototype.toString=function(t){if((t=t||10)<2||36>>0).toString(t);if((r=s).isZero())return u+a;for(;u.length<6;)u="0"+u;a=""+u+a}},e.prototype.getHighBits=function(){return this.high},e.prototype.getHighBitsUnsigned=function(){return this.high>>>0},e.prototype.getLowBits=function(){return this.low},e.prototype.getLowBitsUnsigned=function(){return this.low>>>0},e.prototype.getNumBitsAbs=function(){if(this.isNegative())return this.equals(e.MIN_VALUE)?64:this.negate().getNumBitsAbs();for(var t=0!=this.high?this.high:this.low,r=31;r>0&&0==(t&1<=0},e.prototype.isOdd=function(){return 1==(1&this.low)},e.prototype.isEven=function(){return 0==(1&this.low)},e.prototype.equals=function(t){return e.isLong(t)||(t=e.fromValue(t)),(this.unsigned===t.unsigned||this.high>>>31!=1||t.high>>>31!=1)&&this.high===t.high&&this.low===t.low},e.eq=e.prototype.equals,e.prototype.notEquals=function(e){return!this.equals(e)},e.neq=e.prototype.notEquals,e.prototype.lessThan=function(e){return this.compare(e)<0},e.prototype.lt=e.prototype.lessThan,e.prototype.lessThanOrEqual=function(e){return this.compare(e)<=0},e.prototype.lte=e.prototype.lessThanOrEqual,e.prototype.greaterThan=function(e){return this.compare(e)>0},e.prototype.gt=e.prototype.greaterThan,e.prototype.greaterThanOrEqual=function(e){return this.compare(e)>=0},e.prototype.gte=e.prototype.greaterThanOrEqual,e.prototype.compare=function(t){if(e.isLong(t)||(t=e.fromValue(t)),this.equals(t))return 0;var r=this.isNegative(),n=t.isNegative();return r&&!n?-1:!r&&n?1:this.unsigned?t.high>>>0>this.high>>>0||t.high===this.high&&t.low>>>0>this.low>>>0?-1:1:this.subtract(t).isNegative()?-1:1},e.prototype.negate=function(){return!this.unsigned&&this.equals(e.MIN_VALUE)?e.MIN_VALUE:this.not().add(e.ONE)},e.prototype.neg=e.prototype.negate,e.prototype.add=function(t){e.isLong(t)||(t=e.fromValue(t));var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,a=t.high>>>16,s=65535&t.high,u=t.low>>>16,f=0,c=0,l=0,h=0;return l+=(h+=o+(65535&t.low))>>>16,h&=65535,c+=(l+=i+u)>>>16,l&=65535,f+=(c+=n+s)>>>16,c&=65535,f+=r+a,f&=65535,e.fromBits(l<<16|h,f<<16|c,this.unsigned)},e.prototype.subtract=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.add(t.negate())},e.prototype.sub=e.prototype.subtract,e.prototype.multiply=function(t){if(this.isZero())return e.ZERO;if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())return e.ZERO;if(this.equals(e.MIN_VALUE))return t.isOdd()?e.MIN_VALUE:e.ZERO;if(t.equals(e.MIN_VALUE))return this.isOdd()?e.MIN_VALUE:e.ZERO;if(this.isNegative())return t.isNegative()?this.negate().multiply(t.negate()):this.negate().multiply(t).negate();if(t.isNegative())return this.multiply(t.negate()).negate();if(this.lessThan(a)&&t.lessThan(a))return e.fromNumber(this.toNumber()*t.toNumber(),this.unsigned);var r=this.high>>>16,n=65535&this.high,i=this.low>>>16,o=65535&this.low,s=t.high>>>16,u=65535&t.high,f=t.low>>>16,c=65535&t.low,l=0,h=0,d=0,p=0;return d+=(p+=o*c)>>>16,p&=65535,h+=(d+=i*c)>>>16,d&=65535,h+=(d+=o*f)>>>16,d&=65535,l+=(h+=n*c)>>>16,h&=65535,l+=(h+=i*f)>>>16,h&=65535,l+=(h+=o*u)>>>16,h&=65535,l+=r*c+n*f+i*u+o*s,l&=65535,e.fromBits(d<<16|p,l<<16|h,this.unsigned)},e.prototype.mul=e.prototype.multiply,e.prototype.divide=function(t){if(e.isLong(t)||(t=e.fromValue(t)),t.isZero())throw new Error("division by zero");if(this.isZero())return this.unsigned?e.UZERO:e.ZERO;var r,n,i;if(this.equals(e.MIN_VALUE))return t.equals(e.ONE)||t.equals(e.NEG_ONE)?e.MIN_VALUE:t.equals(e.MIN_VALUE)?e.ONE:(r=this.shiftRight(1).divide(t).shiftLeft(1)).equals(e.ZERO)?t.isNegative()?e.ONE:e.NEG_ONE:(n=this.subtract(t.multiply(r)),i=r.add(n.divide(t)));if(t.equals(e.MIN_VALUE))return this.unsigned?e.UZERO:e.ZERO;if(this.isNegative())return t.isNegative()?this.negate().divide(t.negate()):this.negate().divide(t).negate();if(t.isNegative())return this.divide(t.negate()).negate();for(i=e.ZERO,n=this;n.greaterThanOrEqual(t);){r=Math.max(1,Math.floor(n.toNumber()/t.toNumber()));for(var o=Math.ceil(Math.log(r)/Math.LN2),a=o<=48?1:Math.pow(2,o-48),s=e.fromNumber(r),u=s.multiply(t);u.isNegative()||u.greaterThan(n);)r-=a,u=(s=e.fromNumber(r,this.unsigned)).multiply(t);s.isZero()&&(s=e.ONE),i=i.add(s),n=n.subtract(u)}return i},e.prototype.div=e.prototype.divide,e.prototype.modulo=function(t){return e.isLong(t)||(t=e.fromValue(t)),this.subtract(this.divide(t).multiply(t))},e.prototype.mod=e.prototype.modulo,e.prototype.not=function(){return e.fromBits(~this.low,~this.high,this.unsigned)},e.prototype.and=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low&t.low,this.high&t.high,this.unsigned)},e.prototype.or=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low|t.low,this.high|t.high,this.unsigned)},e.prototype.xor=function(t){return e.isLong(t)||(t=e.fromValue(t)),e.fromBits(this.low^t.low,this.high^t.high,this.unsigned)},e.prototype.shiftLeft=function(t){return e.isLong(t)&&(t=t.toInt()),0==(t&=63)?this:t<32?e.fromBits(this.low<>>32-t,this.unsigned):e.fromBits(0,this.low<>>t|this.high<<32-t,this.high>>t,this.unsigned):e.fromBits(this.high>>t-32,this.high>=0?0:-1,this.unsigned)},e.prototype.shr=e.prototype.shiftRight,e.prototype.shiftRightUnsigned=function(t){if(e.isLong(t)&&(t=t.toInt()),0==(t&=63))return this;var r=this.high;if(t<32){var n=this.low;return e.fromBits(n>>>t|r<<32-t,r>>>t,this.unsigned)}return 32===t?e.fromBits(r,0,this.unsigned):e.fromBits(r>>>t-32,0,this.unsigned)},e.prototype.shru=e.prototype.shiftRightUnsigned,e.prototype.toSigned=function(){return this.unsigned?new e(this.low,this.high,!1):this},e.prototype.toUnsigned=function(){return this.unsigned?this:new e(this.low,this.high,!0)},e})?n.apply(t,i):n)||(e.exports=o)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.protocolToJSON=function(e){var t=i(e.file[2]);return t.imports=[i(e.file[1])],t};var n=r(428);function i(e){var t={};t.package=e.package,t.options=e.options,t.services=[];var r=Object.values(e.message_type).map(s),n=function(e){var t={};return Object.values(e).forEach((function(e){var r=e.extendee.slice(1);null==t[r]&&(t[r]={},t[r].ref=r,t[r].fields=[]),t[r].fields.push(f(e))})),Object.values(t)}(e.extension);return t.messages=n.concat(r),t.enums=Object.values(e.enum_type).map(o),t}function o(e){var t={};return t.name=e.name,t.values=Object.values(e.value).map(a),t.options={},t}function a(e){var t={};return t.name=e.name,t.id=e.number,t}function s(e){var t={enums:[]};return t.name=e.name,t.options=e.options||{},t.messages=[],t.fields=Object.values(e.field).map(f),t.oneofs={},t}Object.values||(0,n.shim)();var u={1:"double",2:"float",3:"int64",4:"uint64",5:"int32",6:"fixed64",7:"fixed32",8:"bool",9:"string",10:"group",11:"message",12:"bytes",13:"uint32",14:"enum",15:"sfixed32",16:"sfixed64",17:"sint32",18:"sint64"};function f(e){var t={};return 1===e.label&&(t.rule="optional"),2===e.label&&(t.rule="required"),3===e.label&&(t.rule="repeated"),t.type=u[e.type],e.type_name&&(t.type=e.type_name.slice(1)),t.name=e.name,t.options=e.options||{},t.id=e.number,t}},function(e,t,r){"use strict";var n=r(204),i=r(206),o=r(209),a=r(210),s=r(437),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),e.exports=u},function(e,t,r){"use strict";var n=Array.prototype.slice,i=r(205),o=Object.keys,a=o?function(e){return o(e)}:r(430),s=Object.keys;a.shim=function(){Object.keys?function(){var e=Object.keys(arguments);return e&&e.length===arguments.length}(1,2)||(Object.keys=function(e){return i(e)?s(n.call(e)):s(e)}):Object.keys=a;return Object.keys||a},e.exports=a},function(e,t,r){"use strict";var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(205),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),f=s.call((function(){}),"prototype"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(e){var t=e.constructor;return t&&t.prototype===e},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},d=function(){if("undefined"==typeof window)return!1;for(var e in window)try{if(!h["$"+e]&&i.call(window,e)&&null!==window[e]&&"object"==typeof window[e])try{l(window[e])}catch(e){return!0}}catch(e){return!0}return!1}();n=function(e){var t=null!==e&&"object"==typeof e,r="[object Function]"===o.call(e),n=a(e),s=t&&"[object String]"===o.call(e),h=[];if(!t&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var p=f&&r;if(s&&e.length>0&&!i.call(e,0))for(var g=0;g0)for(var y=0;y1&&"boolean"!=typeof t)throw new o('"allowMissing" argument must be a boolean');var r=I(e),n=r.length>0?r[0]:"",i=O("%"+n+"%",t),a=i.name,u=i.value,f=!1,c=i.alias;c&&(n=c[0],_(r,w([0,1],c)));for(var l=1,h=!0;l=r.length){var p=s(u,d);if(h=!!p,!t&&!(d in u))throw new o("base intrinsic for "+e+" exists, but the property is not available.");u=h&&"get"in p&&!("originalValue"in p.get)?p.get:u[d]}else h=v(u,d),u=u[d];h&&!f&&(y[a]=u)}}return u}},function(e,t,r){"use strict";var n=r(207),i=r(206),o=i(n("String.prototype.indexOf"));e.exports=function(e,t){var r=n(e,!!t);return"function"==typeof r&&o(e,".prototype.")>-1?i(r):r}},function(e,t,r){"use strict";var n=r(210),i=r(204);e.exports=function(){var e=n();return i(Object,{values:e},{values:function(){return Object.values!==e}}),e}},function(e,t,r){"use strict";e.exports=r(41).newBuilder({}).import({package:null,messages:[{name:"DeviceDescriptor",fields:[{rule:"optional",options:{},type:"uint32",name:"vendor_id",id:1},{rule:"optional",options:{},type:"uint32",name:"product_id",id:2},{rule:"optional",options:{},type:"string",name:"serial_number",id:3},{rule:"optional",options:{},type:"string",name:"path",id:4}],enums:[],messages:[],options:{},oneofs:{}},{name:"Configuration",fields:[{rule:"repeated",options:{},type:"string",name:"whitelist_urls",id:1},{rule:"repeated",options:{},type:"string",name:"blacklist_urls",id:2},{rule:"required",options:{},type:"google.protobuf.FileDescriptorSet",name:"wire_protocol",id:3},{rule:"repeated",options:{},type:"DeviceDescriptor",name:"known_devices",id:4},{rule:"optional",options:{},type:"uint32",name:"valid_until",id:5}],enums:[],messages:[],options:{},oneofs:{}}],enums:[],imports:[{package:"google.protobuf",messages:[{name:"FileDescriptorSet",fields:[{rule:"repeated",options:{},type:"FileDescriptorProto",name:"file",id:1}],enums:[],messages:[],options:{},oneofs:{}},{name:"FileDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"string",name:"package",id:2},{rule:"repeated",options:{},type:"string",name:"dependency",id:3},{rule:"repeated",options:{},type:"int32",name:"public_dependency",id:10},{rule:"repeated",options:{},type:"int32",name:"weak_dependency",id:11},{rule:"repeated",options:{},type:"DescriptorProto",name:"message_type",id:4},{rule:"repeated",options:{},type:"EnumDescriptorProto",name:"enum_type",id:5},{rule:"repeated",options:{},type:"ServiceDescriptorProto",name:"service",id:6},{rule:"repeated",options:{},type:"FieldDescriptorProto",name:"extension",id:7},{rule:"optional",options:{},type:"FileOptions",name:"options",id:8},{rule:"optional",options:{},type:"SourceCodeInfo",name:"source_code_info",id:9}],enums:[],messages:[],options:{},oneofs:{}},{name:"DescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"repeated",options:{},type:"FieldDescriptorProto",name:"field",id:2},{rule:"repeated",options:{},type:"FieldDescriptorProto",name:"extension",id:6},{rule:"repeated",options:{},type:"DescriptorProto",name:"nested_type",id:3},{rule:"repeated",options:{},type:"EnumDescriptorProto",name:"enum_type",id:4},{rule:"repeated",options:{},type:"ExtensionRange",name:"extension_range",id:5},{rule:"optional",options:{},type:"MessageOptions",name:"options",id:7}],enums:[],messages:[{name:"ExtensionRange",fields:[{rule:"optional",options:{},type:"int32",name:"start",id:1},{rule:"optional",options:{},type:"int32",name:"end",id:2}],enums:[],messages:[],options:{},oneofs:{}}],options:{},oneofs:{}},{name:"FieldDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"int32",name:"number",id:3},{rule:"optional",options:{},type:"Label",name:"label",id:4},{rule:"optional",options:{},type:"Type",name:"type",id:5},{rule:"optional",options:{},type:"string",name:"type_name",id:6},{rule:"optional",options:{},type:"string",name:"extendee",id:2},{rule:"optional",options:{},type:"string",name:"default_value",id:7},{rule:"optional",options:{},type:"FieldOptions",name:"options",id:8}],enums:[{name:"Type",values:[{name:"TYPE_DOUBLE",id:1},{name:"TYPE_FLOAT",id:2},{name:"TYPE_INT64",id:3},{name:"TYPE_UINT64",id:4},{name:"TYPE_INT32",id:5},{name:"TYPE_FIXED64",id:6},{name:"TYPE_FIXED32",id:7},{name:"TYPE_BOOL",id:8},{name:"TYPE_STRING",id:9},{name:"TYPE_GROUP",id:10},{name:"TYPE_MESSAGE",id:11},{name:"TYPE_BYTES",id:12},{name:"TYPE_UINT32",id:13},{name:"TYPE_ENUM",id:14},{name:"TYPE_SFIXED32",id:15},{name:"TYPE_SFIXED64",id:16},{name:"TYPE_SINT32",id:17},{name:"TYPE_SINT64",id:18}],options:{}},{name:"Label",values:[{name:"LABEL_OPTIONAL",id:1},{name:"LABEL_REQUIRED",id:2},{name:"LABEL_REPEATED",id:3}],options:{}}],messages:[],options:{},oneofs:{}},{name:"EnumDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"repeated",options:{},type:"EnumValueDescriptorProto",name:"value",id:2},{rule:"optional",options:{},type:"EnumOptions",name:"options",id:3}],enums:[],messages:[],options:{},oneofs:{}},{name:"EnumValueDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"int32",name:"number",id:2},{rule:"optional",options:{},type:"EnumValueOptions",name:"options",id:3}],enums:[],messages:[],options:{},oneofs:{}},{name:"ServiceDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"repeated",options:{},type:"MethodDescriptorProto",name:"method",id:2},{rule:"optional",options:{},type:"ServiceOptions",name:"options",id:3}],enums:[],messages:[],options:{},oneofs:{}},{name:"MethodDescriptorProto",fields:[{rule:"optional",options:{},type:"string",name:"name",id:1},{rule:"optional",options:{},type:"string",name:"input_type",id:2},{rule:"optional",options:{},type:"string",name:"output_type",id:3},{rule:"optional",options:{},type:"MethodOptions",name:"options",id:4}],enums:[],messages:[],options:{},oneofs:{}},{name:"FileOptions",fields:[{rule:"optional",options:{},type:"string",name:"java_package",id:1},{rule:"optional",options:{},type:"string",name:"java_outer_classname",id:8},{rule:"optional",options:{default:!1},type:"bool",name:"java_multiple_files",id:10},{rule:"optional",options:{default:!1},type:"bool",name:"java_generate_equals_and_hash",id:20},{rule:"optional",options:{default:"SPEED"},type:"OptimizeMode",name:"optimize_for",id:9},{rule:"optional",options:{},type:"string",name:"go_package",id:11},{rule:"optional",options:{default:!1},type:"bool",name:"cc_generic_services",id:16},{rule:"optional",options:{default:!1},type:"bool",name:"java_generic_services",id:17},{rule:"optional",options:{default:!1},type:"bool",name:"py_generic_services",id:18},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[{name:"OptimizeMode",values:[{name:"SPEED",id:1},{name:"CODE_SIZE",id:2},{name:"LITE_RUNTIME",id:3}],options:{}}],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"MessageOptions",fields:[{rule:"optional",options:{default:!1},type:"bool",name:"message_set_wire_format",id:1},{rule:"optional",options:{default:!1},type:"bool",name:"no_standard_descriptor_accessor",id:2},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"FieldOptions",fields:[{rule:"optional",options:{default:"STRING"},type:"CType",name:"ctype",id:1},{rule:"optional",options:{},type:"bool",name:"packed",id:2},{rule:"optional",options:{default:!1},type:"bool",name:"lazy",id:5},{rule:"optional",options:{default:!1},type:"bool",name:"deprecated",id:3},{rule:"optional",options:{},type:"string",name:"experimental_map_key",id:9},{rule:"optional",options:{default:!1},type:"bool",name:"weak",id:10},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[{name:"CType",values:[{name:"STRING",id:0},{name:"CORD",id:1},{name:"STRING_PIECE",id:2}],options:{}}],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"EnumOptions",fields:[{rule:"optional",options:{default:!0},type:"bool",name:"allow_alias",id:2},{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"EnumValueOptions",fields:[{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"ServiceOptions",fields:[{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"MethodOptions",fields:[{rule:"repeated",options:{},type:"UninterpretedOption",name:"uninterpreted_option",id:999}],enums:[],messages:[],options:{},oneofs:{},extensions:[1e3,536870911]},{name:"UninterpretedOption",fields:[{rule:"repeated",options:{},type:"NamePart",name:"name",id:2},{rule:"optional",options:{},type:"string",name:"identifier_value",id:3},{rule:"optional",options:{},type:"uint64",name:"positive_int_value",id:4},{rule:"optional",options:{},type:"int64",name:"negative_int_value",id:5},{rule:"optional",options:{},type:"double",name:"double_value",id:6},{rule:"optional",options:{},type:"bytes",name:"string_value",id:7},{rule:"optional",options:{},type:"string",name:"aggregate_value",id:8}],enums:[],messages:[{name:"NamePart",fields:[{rule:"required",options:{},type:"string",name:"name_part",id:1},{rule:"required",options:{},type:"bool",name:"is_extension",id:2}],enums:[],messages:[],options:{},oneofs:{}}],options:{},oneofs:{}},{name:"SourceCodeInfo",fields:[{rule:"repeated",options:{},type:"Location",name:"location",id:1}],enums:[],messages:[{name:"Location",fields:[{rule:"repeated",options:{packed:!0},type:"int32",name:"path",id:1},{rule:"repeated",options:{packed:!0},type:"int32",name:"span",id:2},{rule:"optional",options:{},type:"string",name:"leading_comments",id:3},{rule:"optional",options:{},type:"string",name:"trailing_comments",id:4}],enums:[],messages:[],options:{},oneofs:{}}],options:{},oneofs:{}}],enums:[],imports:[],options:{java_package:"com.google.protobuf",java_outer_classname:"DescriptorProtos",optimize_for:"SPEED"},services:[]}],options:{},services:[]}).build()},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.MessageDecoder=void 0;var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=i?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r(41));r(203);function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}function a(e,t){for(var r=0;rt.path?1:0:parseInt(e.path)-parseInt(t.path)}var w=(y((i=function(){function e(t,r){if(function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.name="LowlevelTransportWithSharedConnections",this.debug=!1,this.deferedDebugOnRelease={},this.deferedNormalOnRelease={},this.configured=!1,this.stopped=!1,this._lastStringified="",this.requestNeeded=!1,this.latestId=0,this.defereds={},this.isOutdated=!1,this.plugin=t,this.version=t.version,this._sharedWorkerFactory=r,!this.plugin.allowsWriteAndEnumerate)throw new Error("Plugin with shared connections cannot disallow write and enumerate")}var t,r,n,i,a,l,d,y,m,w,_,E,S,A,I;return t=e,(r=[{key:"enumerate",value:function(){return this._silentEnumerate()}},{key:"_silentEnumerate",value:(I=p(o.default.mark((function e(){var t,r,n,i,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToWorker({type:"enumerate-intent"});case 2:return t=[],e.prev=3,e.next=6,this.plugin.enumerate();case 6:t=e.sent;case 7:return e.prev=7,e.next=10,this.sendToWorker({type:"enumerate-done"});case 10:return e.finish(7);case 11:return e.next=13,this.sendToWorker({type:"get-sessions-and-disconnect",devices:t});case 13:if("sessions"===(r=e.sent).type){e.next=16;break}throw new Error("Wrong reply");case 16:return n=r.debugSessions,i=r.normalSessions,a=t.map((function(e){var t=i[e.path],r=n[e.path];return{path:e.path,session:t,debug:e.debug,debugSession:r}})),this._releaseDisconnected(a),e.abrupt("return",a.sort(v));case 21:case"end":return e.stop()}}),e,this,[[3,,7,11]])}))),function(){return I.apply(this,arguments)})},{key:"_releaseDisconnected",value:function(e){var t=this,r={};e.forEach((function(e){null!=e.session&&(r[e.session]=!0)})),Object.keys(this.deferedDebugOnRelease).forEach((function(e){null==r[e]&&t._releaseCleanup(e,!0)})),Object.keys(this.deferedNormalOnRelease).forEach((function(e){null==r[e]&&t._releaseCleanup(e,!1)}))}},{key:"listen",value:(A=p(o.default.mark((function e(t){var r,n;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r=b(t),n=null==t?this._lastStringified:r,e.abrupt("return",this._runIter(0,n));case 3:case"end":return e.stop()}}),e,this)}))),function(e){return A.apply(this,arguments)})},{key:"_runIter",value:(S=p(o.default.mark((function e(t,r){var n,i;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._silentEnumerate();case 2:if(n=e.sent,(i=b(n))===r&&60!==t){e.next=7;break}return this._lastStringified=i,e.abrupt("return",n);case 7:return e.next=9,(0,s.resolveTimeoutPromise)(500,null);case 9:return e.abrupt("return",this._runIter(t+1,i));case 10:case"end":return e.stop()}}),e,this)}))),function(e,t){return S.apply(this,arguments)})},{key:"acquire",value:(E=p(o.default.mark((function e(t,r){var n,i,a,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToWorker({type:"acquire-intent",path:t.path,previous:t.previous,debug:r});case 2:if("wrong-previous-session"!==(n=e.sent).type){e.next=5;break}throw new Error("wrong previous session");case 5:if("other-session"===n.type){e.next=7;break}throw new Error("Strange reply");case 7:return i=null==n.otherSession,e.prev=8,e.next=11,this.plugin.connect(t.path,r,i);case 11:e.next=18;break;case 13:return e.prev=13,e.t0=e.catch(8),e.next=17,this.sendToWorker({type:"acquire-failed"});case 17:throw e.t0;case 18:return e.next=20,this.sendToWorker({type:"acquire-done"});case 20:if("session-number"===(a=e.sent).type){e.next=23;break}throw new Error("Strange reply.");case 23:return u=a.number,r?this.deferedDebugOnRelease[u]=(0,s.create)():this.deferedNormalOnRelease[u]=(0,s.create)(),e.abrupt("return",u);case 26:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(e,t){return E.apply(this,arguments)})},{key:"release",value:(_=p(o.default.mark((function e(t,r,n){var i,a,s,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!r||n){e.next=3;break}return this.sendToWorker({type:"release-onclose",session:t}),e.abrupt("return");case 3:return e.next=5,this.sendToWorker({type:"release-intent",session:t,debug:n});case 5:if("double-release"!==(i=e.sent).type){e.next=8;break}throw new Error("Trying to double release.");case 8:if("path"===i.type){e.next=10;break}throw new Error("Strange reply.");case 10:return a=i.path,s=i.otherSession,u=null==s,this._releaseCleanup(t,n),e.prev=14,e.next=17,this.plugin.disconnect(a,n,u);case 17:e.next=21;break;case 19:e.prev=19,e.t0=e.catch(14);case 21:return e.next=23,this.sendToWorker({type:"release-done"});case 23:case"end":return e.stop()}}),e,this,[[14,19]])}))),function(e,t,r){return _.apply(this,arguments)})},{key:"_releaseCleanup",value:function(e,t){var r=t?this.deferedDebugOnRelease:this.deferedNormalOnRelease;null!=r[e]&&(r[e].reject(new Error("Device released or disconnected")),delete r[e])}},{key:"configure",value:(w=p(o.default.mark((function e(t){var r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=(0,u.parseConfigure)(t),this._messages=r,this.configured=!0;case 3:case"end":return e.stop()}}),e,this)}))),function(e){return w.apply(this,arguments)})},{key:"_sendLowlevel",value:function(e,t){var r=this;return function(n){return r.plugin.send(e,n,t)}}},{key:"_receiveLowlevel",value:function(e,t){var r=this;return function(){return r.plugin.receive(e,t)}}},{key:"messages",value:function(){if(null==this._messages)throw new Error("Transport not configured.");return this._messages}},{key:"doWithSession",value:(m=p(o.default.mark((function e(t,r,n){var i,a,s,u,f,c;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.sendToWorker({type:"get-sessions"});case 2:if("sessions"===(i=e.sent).type){e.next=5;break}throw new Error("Wrong reply");case 5:if(a=r?i.debugSessions:i.normalSessions,s=null,Object.keys(a).forEach((function(e){a[e]===t&&(s=e)})),null!=s){e.next=10;break}throw new Error("Session not available.");case 10:return u=s,e.next=13,n(u);case 13:return f=e.sent,c=r?this.deferedDebugOnRelease[t]:this.deferedNormalOnRelease[t],e.abrupt("return",Promise.race([c.rejectingPromise,f]));case 16:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return m.apply(this,arguments)})},{key:"call",value:(y=p(o.default.mark((function e(t,r,n,i){var a,s=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(){var e=p(o.default.mark((function e(t){var a,u;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=s.messages(),e.next=3,(0,f.buildAndSend)(a,s._sendLowlevel(t,i),r,n);case 3:return e.next=5,(0,c.receiveAndParse)(a,s._receiveLowlevel(t,i));case 5:return u=e.sent,e.abrupt("return",u);case 7:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return",this.doWithSession(t,i,a));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return y.apply(this,arguments)})},{key:"post",value:(d=p(o.default.mark((function e(t,r,n,i){var a,s=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=function(){var e=p(o.default.mark((function e(t){var a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return a=s.messages(),e.next=3,(0,f.buildAndSend)(a,s._sendLowlevel(t,i),r,n);case 3:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return",this.doWithSession(t,i,a));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t,r,n){return d.apply(this,arguments)})},{key:"read",value:(l=p(o.default.mark((function e(t,r){var n,i=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=function(){var e=p(o.default.mark((function e(t){var n,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=i.messages(),e.next=3,(0,c.receiveAndParse)(n,i._receiveLowlevel(t,r));case 3:return a=e.sent,e.abrupt("return",a);case 5:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),e.abrupt("return",this.doWithSession(t,r,n));case 2:case"end":return e.stop()}}),e,this)}))),function(e,t){return l.apply(this,arguments)})},{key:"init",value:(a=p(o.default.mark((function e(t){var r=this;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this.debug=!!t,this.requestNeeded=this.plugin.requestNeeded,e.next=4,this.plugin.init(t);case 4:null!=this._sharedWorkerFactory&&(this.sharedWorker=this._sharedWorkerFactory(),null!=this.sharedWorker&&(this.sharedWorker.port.onmessage=function(e){r.receiveFromWorker(e.data)}));case 5:case"end":return e.stop()}}),e,this)}))),function(e){return a.apply(this,arguments)})},{key:"requestDevice",value:(i=p(o.default.mark((function e(){return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.plugin.requestDevice());case 1:case"end":return e.stop()}}),e,this)}))),function(){return i.apply(this,arguments)})},{key:"sendToWorker",value:function(e){var t=this;if(this.stopped)return Promise.reject("Transport stopped.");this.latestId++;var r=this.latestId;return this.defereds[r]=(0,s.create)(),null!=this.sharedWorker?this.sharedWorker.port.postMessage({id:r,message:e}):(0,h.postModuleMessage)({id:r,message:e},(function(e){return t.receiveFromWorker(e)})),this.defereds[r].promise}},{key:"receiveFromWorker",value:function(e){this.defereds[e.id].resolve(e.message),delete this.defereds[e.id]}},{key:"setBridgeLatestUrl",value:function(e){}},{key:"setBridgeLatestVersion",value:function(e){}},{key:"stop",value:function(){this.stopped=!0,this.sharedWorker=null}}])&&g(t.prototype,r),n&&g(t,n),e}()).prototype,"enumerate",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"enumerate"),i.prototype),y(i.prototype,"listen",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"listen"),i.prototype),y(i.prototype,"acquire",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"acquire"),i.prototype),y(i.prototype,"release",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"release"),i.prototype),y(i.prototype,"configure",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"configure"),i.prototype),y(i.prototype,"call",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"call"),i.prototype),y(i.prototype,"post",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"post"),i.prototype),y(i.prototype,"read",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"read"),i.prototype),y(i.prototype,"init",[l.debugInOut],Object.getOwnPropertyDescriptor(i.prototype,"init"),i.prototype),i);t.default=w,e.exports=t.default},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.patch=function(){s||(i.Reflect.Message.Field.prototype.verifyValueOriginal=i.Reflect.Message.Field.prototype.verifyValue,i.Reflect.Message.Field.prototype.verifyValue=function(e,t){var r=e;return this.type===i.TYPES.bytes&&null!=e&&"string"==typeof e&&(r=a.wrap(e,"hex")),this.verifyValueOriginal(r,t)});s=!0};var i=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=o();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=i?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}r.default=e,t&&t.set(e,r);return r}(r(41));function o(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return o=function(){return e},e}var a=i.ByteBuffer,s=!1},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.postModuleMessage=function(e,t){var r=e.id,n=e.message;h({id:r,message:n},{postMessage:t})};var n=r(212);"undefined"!=typeof onconnect&&(onconnect=function(e){var t=e.ports[0];t.onmessage=function(e){h(e.data,t)}});var i={},o={},a=null,s=Promise.resolve();function u(){var e=(0,n.create)();a=e,setTimeout((function(){return e.reject(new Error("Timed out"))}),1e4)}function f(e){null!=a&&a.resolve(e)}function c(){return null==a?Promise.reject(new Error("???")):a.promise}function l(e){var t=s.then((function(){return e()}));s=t.catch((function(){}))}function h(e,t){var r=e.id,n=e.message;if("acquire-intent"===n.type){var a=n.path,s=n.previous,h=n.debug;l((function(){return function(e,t,r,n,a){var s=!1,f=r?o:i,l=r?i:o,h=f[e];s=null==h?null!=t:t!==h;return s?(y({type:"wrong-previous-session"},n,a),Promise.resolve()):(u(),y({type:"other-session",otherSession:l[e]},n,a),c().then((function(t){if(t.good){var n=(++g).toString();r&&(n="debug"+n),f[e]=n,y({type:"session-number",number:n},t.id,a)}else y({type:"ok"},t.id,a)})))}(a,s,h,r,t)}))}if("acquire-done"===n.type&&function(e){f({good:!0,id:e})}(r),"acquire-failed"===n.type&&function(e){f({good:!1,id:e})}(r),"get-sessions"===n.type&&l((function(){return p(r,t)})),"get-sessions-and-disconnect"===n.type){var m=n.devices;l((function(){return p(r,t,m)}))}if("release-onclose"===n.type){var b=n.session;l((function(){return function(e){var t=null;if(Object.keys(i).forEach((function(r){i[r]===e&&(t=r)})),null==t)return Promise.resolve();var r=t;return delete i[r],delete o[r],Promise.resolve()}(b)}))}if("release-intent"===n.type){var v=n.session,w=n.debug;l((function(){return function(e,t,r,n){var a=null,s=t?o:i,f=t?i:o;if(Object.keys(s).forEach((function(t){s[t]===e&&(a=t)})),null==a)return y({type:"double-release"},r,n),Promise.resolve();var l=a,h=f[l];return u(),y({type:"path",path:l,otherSession:h},r,n),c().then((function(e){delete s[l],y({type:"ok"},e.id,n)}))}(v,w,r,t)}))}"release-done"===n.type&&d(r),"enumerate-intent"===n.type&&l((function(){return function(e,t){return u(),y({type:"ok"},e,t),c().then((function(e){y({type:"ok"},e.id,t)}))}(r,t)})),"enumerate-done"===n.type&&d(r)}function d(e){f({id:e})}function p(e,t,r){if(null!=r){var n={};r.forEach((function(e){n[e.path]=!0})),Object.keys(i).forEach((function(e){i[e]||delete i[e]})),Object.keys(o).forEach((function(e){o[e]||delete o[e]}))}return y({type:"sessions",debugSessions:o,normalSessions:i},e,t),Promise.resolve()}var g=0;function y(e,t,r){r.postMessage({id:t,message:e})}},function(e,t,r){var n="undefined"!=typeof JSON?JSON:r(444);e.exports=function(e,t){t||(t={}),"function"==typeof t&&(t={cmp:t});var r=t.space||"";"number"==typeof r&&(r=Array(r+1).join(" "));var a,s="boolean"==typeof t.cycles&&t.cycles,u=t.replacer||function(e,t){return t},f=t.cmp&&(a=t.cmp,function(e){return function(t,r){var n={key:t,value:e[t]},i={key:r,value:e[r]};return a(n,i)}}),c=[];return function e(t,a,l,h){var d=r?"\n"+new Array(h+1).join(r):"",p=r?": ":":";if(l&&l.toJSON&&"function"==typeof l.toJSON&&(l=l.toJSON()),void 0!==(l=u.call(t,a,l))){if("object"!=typeof l||null===l)return n.stringify(l);if(i(l)){for(var g=[],y=0;y="0"&&n<="9";)t+=n,u();if("."===n)for(t+=".";u()&&n>="0"&&n<="9";)t+=n;if("e"===n||"E"===n)for(t+=n,u(),"-"!==n&&"+"!==n||(t+=n,u());n>="0"&&n<="9";)t+=n,u();if(e=+t,isFinite(e))return e;s("Bad number")},c=function(){var e,t,r,i="";if('"'===n)for(;u();){if('"'===n)return u(),i;if("\\"===n)if(u(),"u"===n){for(r=0,t=0;t<4&&(e=parseInt(u(),16),isFinite(e));t+=1)r=16*r+e;i+=String.fromCharCode(r)}else{if("string"!=typeof a[n])break;i+=a[n]}else i+=n}s("Bad string")},l=function(){for(;n&&n<=" ";)u()};o=function(){switch(l(),n){case"{":return function(){var e,t={};if("{"===n){if(u("{"),l(),"}"===n)return u("}"),t;for(;n;){if(e=c(),l(),u(":"),Object.hasOwnProperty.call(t,e)&&s('Duplicate key "'+e+'"'),t[e]=o(),l(),"}"===n)return u("}"),t;u(","),l()}}s("Bad object")}();case"[":return function(){var e=[];if("["===n){if(u("["),l(),"]"===n)return u("]"),e;for(;n;){if(e.push(o()),l(),"]"===n)return u("]"),e;u(","),l()}}s("Bad array")}();case'"':return c();case"-":return f();default:return n>="0"&&n<="9"?f():function(){switch(n){case"t":return u("t"),u("r"),u("u"),u("e"),!0;case"f":return u("f"),u("a"),u("l"),u("s"),u("e"),!1;case"n":return u("n"),u("u"),u("l"),u("l"),null}s("Unexpected '"+n+"'")}()}},e.exports=function(e,t){var a;return i=e,r=0,n=" ",a=o(),l(),n&&s("Syntax error"),"function"==typeof t?function e(r,n){var i,o,a=r[n];if(a&&"object"==typeof a)for(i in a)Object.prototype.hasOwnProperty.call(a,i)&&(void 0!==(o=e(a,i))?a[i]=o:delete a[i]);return t.call(r,n,a)}({"":a},""):a}},function(e,t){var r,n,i,o=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,a={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"};function s(e){return o.lastIndex=0,o.test(e)?'"'+e.replace(o,(function(e){var t=a[e];return"string"==typeof t?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)}))+'"':'"'+e+'"'}e.exports=function(e,t,o){var a;if(r="",n="","number"==typeof o)for(a=0;a=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,s=!1;return{s:function(){r=e[Symbol.iterator]()},n:function(){var e=r.next();return a=e.done,e},e:function(e){s=!0,o=e},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r0,s!==this.unreadableHidDevice&&this.unreadableHidDeviceChange.emit("change"),e.abrupt("return",this._lastDevices);case 12:case"end":return e.stop()}}),e,this)}))),function(){return b.apply(this,arguments)})},{key:"enumerate",value:(m=c(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._listDevices();case 2:return e.abrupt("return",e.sent.map((function(e){return{path:e.path,debug:e.debug}})));case 3:case"end":return e.stop()}}),e,this)}))),function(){return m.apply(this,arguments)})},{key:"_findDevice",value:(y=c(i.default.mark((function e(t){var r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(null!=(r=this._lastDevices.find((function(e){return e.path===t})))){e.next=3;break}throw new Error("Action was interrupted.");case 3:return e.abrupt("return",r.device);case 4:case"end":return e.stop()}}),e,this)}))),function(e){return y.apply(this,arguments)})},{key:"send",value:(g=c(i.default.mark((function e(t,r,n){var o,a,s;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:if(o=e.sent,(a=new Uint8Array(64))[0]=63,a.set(new Uint8Array(r),1),o.opened){e.next=9;break}return e.next=9,this.connect(t,n,!1);case 9:return s=n?this.debugEndpointId:this.normalEndpointId,e.abrupt("return",o.transferOut(s,a).then((function(){})));case 11:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return g.apply(this,arguments)})},{key:"receive",value:(p=c(i.default.mark((function e(t,r){var n,o,a;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:if(n=e.sent,o=r?this.debugEndpointId:this.normalEndpointId,e.prev=4,n.opened){e.next=8;break}return e.next=8,this.connect(t,r,!1);case 8:return e.next=10,n.transferIn(o,64);case 10:if(0!==(a=e.sent).data.byteLength){e.next=13;break}return e.abrupt("return",this.receive(t,r));case 13:return e.abrupt("return",a.data.buffer.slice(1));case 16:if(e.prev=16,e.t0=e.catch(4),"Device unavailable."!==e.t0.message){e.next=22;break}throw new Error("Action was interrupted.");case 22:throw e.t0;case 23:case"end":return e.stop()}}),e,this,[[4,16]])}))),function(e,t){return p.apply(this,arguments)})},{key:"connect",value:(h=c(i.default.mark((function e(t,r,n){var o,a,s,f=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:o=i.default.mark((function e(o){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!(o>0)){e.next=3;break}return e.next=3,new Promise((function(e){return setTimeout((function(){return e()}),200*o)}));case 3:return e.prev=3,e.next=6,f._connectIn(t,r,n);case 6:return e.t0=e.sent,e.abrupt("return",{v:e.t0});case 10:if(e.prev=10,e.t1=e.catch(3),4!==o){e.next=14;break}throw e.t1;case 14:case"end":return e.stop()}}),e,null,[[3,10]])})),a=0;case 2:if(!(a<5)){e.next=10;break}return e.delegateYield(o(a),"t0",4);case 4:if("object"!==u(s=e.t0)){e.next=7;break}return e.abrupt("return",s.v);case 7:a++,e.next=2;break;case 10:case"end":return e.stop()}}),e)}))),function(e,t,r){return h.apply(this,arguments)})},{key:"_connectIn",value:(f=c(i.default.mark((function e(t,r,n){var o,a;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:return o=e.sent,e.next=5,o.open();case 5:if(!n){e.next=15;break}return e.next=8,o.selectConfiguration(this.configurationId);case 8:return e.prev=8,e.next=11,o.reset();case 11:e.next=15;break;case 13:e.prev=13,e.t0=e.catch(8);case 15:return a=r?this.debugInterfaceId:this.normalInterfaceId,e.next=18,o.claimInterface(a);case 18:case"end":return e.stop()}}),e,this,[[8,13]])}))),function(e,t,r){return f.apply(this,arguments)})},{key:"disconnect",value:(s=c(i.default.mark((function e(t,r,n){var o,a;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this._findDevice(t);case 2:return o=e.sent,a=r?this.debugInterfaceId:this.normalInterfaceId,e.next=6,o.releaseInterface(a);case 6:if(!n){e.next=9;break}return e.next=9,o.close();case 9:case"end":return e.stop()}}),e,this)}))),function(e,t,r){return s.apply(this,arguments)})},{key:"requestDevice",value:(a=c(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.usb.requestDevice({filters:d});case 2:case"end":return e.stop()}}),e,this)}))),function(){return a.apply(this,arguments)})}])&&l(t.prototype,r),n&&l(t,n),e}()).prototype,"init",[a.debugInOut],Object.getOwnPropertyDescriptor(n.prototype,"init"),n.prototype),h(n.prototype,"connect",[a.debugInOut],Object.getOwnPropertyDescriptor(n.prototype,"connect"),n.prototype),h(n.prototype,"disconnect",[a.debugInOut],Object.getOwnPropertyDescriptor(n.prototype,"disconnect"),n.prototype),n);t.default=p,e.exports=t.default},function(e,t,r){"use strict";var n=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==n)return n;throw new Error("unable to locate global object")}();e.exports=t=n.fetch,n.fetch&&(t.default=n.fetch.bind(n)),t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response},function(e,t,r){e.exports=function(e){return new SharedWorker(r.p+"workers/shared-connection-worker.4e3e8b51bdda80805b28.js",e)}},function(e,t,r){"use strict";function n(){return new Worker(r.p+"workers/blockbook-worker.94ed925163726194918b.js")}r.r(t),r.d(t,"default",(function(){return n}))},function(e,t,r){"use strict";function n(){return new Worker(r.p+"workers/ripple-worker.5c4760bb43dccf440277.js")}r.r(t),r.d(t,"default",(function(){return n}))},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=t.find=void 0;var i=r(6),o=(n(r(5)),n(r(454))),a=n(r(463)),s=n(r(464)),u=n(r(465)),f=n(r(466)),c=n(r(467)),l=n(r(468)),h=n(r(469)),d=n(r(470)),p=n(r(471)),g=n(r(472)),y=n(r(473)),m=n(r(474)),b=n(r(475)),v=n(r(478)),w=n(r(479)),_=n(r(505)),E=n(r(506)),S=n(r(507)),A=n(r(508)),I=n(r(509)),O=n(r(510)),P=n(r(511)),M=n(r(513)),k=n(r(514)),T=n(r(515)),x=n(r(516)),R=n(r(517)),C=n(r(518)),N=n(r(519)),B=n(r(520)),D=n(r(521)),U=n(r(522)),j=n(r(523)),L=n(r(524)),F=n(r(526)),H=n(r(527)),q=n(r(528)),V=n(r(529)),K=n(r(530)),z=n(r(531)),G=n(r(532)),Q=n(r(533)),W=n(r(536)),Y=n(r(537)),Z=n(r(538)),J=n(r(539)),X=n(r(541)),$=n(r(542)),ee=n(r(543)),te=n(r(545)),re=n(r(546)),ne=n(r(548)),ie=n(r(549)),oe=n(r(550)),ae=n(r(552)),se=n(r(553)),ue=n(r(554)),fe=n(r(555)),ce=n(r(556)),le=n(r(557)),he=n(r(558)),de=n(r(560)),pe=n(r(561)),ge={blockchainDisconnect:o.default,blockchainEstimateFee:a.default,blockchainGetAccountBalanceHistory:s.default,blockchainGetCurrentFiatRates:u.default,blockchainGetFiatRatesForTimestamps:f.default,blockchainGetTransactions:c.default,blockchainSetCustomBackend:l.default,blockchainSubscribe:h.default,blockchainSubscribeFiatRates:d.default,blockchainUnsubscribe:p.default,blockchainUnsubscribeFiatRates:g.default,cardanoGetAddress:y.default,cardanoGetPublicKey:m.default,cardanoSignTransaction:b.default,cipherKeyValue:v.default,composeTransaction:w.default,customMessage:_.default,debugLinkDecision:E.default,debugLinkGetState:S.default,ethereumGetAddress:A.default,ethereumGetPublicKey:I.default,ethereumSignMessage:O.default,ethereumSignTransaction:P.default,ethereumVerifyMessage:M.default,getAccountInfo:k.default,getAddress:T.default,getDeviceState:x.default,getFeatures:R.default,getPublicKey:C.default,getSettings:N.default,liskGetAddress:B.default,liskGetPublicKey:D.default,liskSignMessage:U.default,liskSignTransaction:L.default,liskVerifyMessage:j.default,loadDevice:F.default,pushTransaction:H.default,requestLogin:q.default,resetDevice:V.default,rippleGetAddress:K.default,rippleSignTransaction:z.default,nemGetAddress:G.default,nemSignTransaction:Q.default,signMessage:W.default,signTransaction:Y.default,stellarGetAddress:Z.default,stellarSignTransaction:J.default,tezosGetAddress:X.default,tezosGetPublicKey:$.default,tezosSignTransaction:ee.default,eosGetPublicKey:te.default,eosSignTransaction:re.default,binanceGetPublicKey:ne.default,binanceGetAddress:ie.default,binanceSignTransaction:oe.default,verifyMessage:ae.default,wipeDevice:se.default,applyFlags:ue.default,applySettings:fe.default,backupDevice:ce.default,changePin:le.default,firmwareUpdate:he.default,recoveryDevice:de.default,getCoinInfo:pe.default},ye=function(e){if(!e.payload)throw i.ERRORS.TypedError("Method_InvalidParameter","Message payload not found");if(!e.payload.method||"string"!=typeof e.payload.method)throw i.ERRORS.TypedError("Method_InvalidParameter","Message method is not set");if(ge[e.payload.method])return new ge[e.payload.method](e);throw i.ERRORS.TypedError("Method_InvalidParameter","Method "+e.payload.method+" not found")};t.find=ye;var me=ye;t.default=me},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(3)),o=n(r(5)),a=r(4),s=r(6),u=r(23),f=r(8),c=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=[],r.info="",r.useDevice=!1,r.useUi=!1;var n=t.payload;(0,a.validateParams)(n,[{name:"coin",type:"string",obligatory:!0}]);var i=(0,f.getCoinInfo)(n.coin);if(!i)throw s.ERRORS.TypedError("Method_UnknownCoin");return(0,u.isBackendSupported)(i),r.params={coinInfo:i},r}return(0,i.default)(t,e),t.prototype.run=function(){var e=(0,u.findBackend)(this.params.coinInfo.name);return e&&e.disconnect(),Promise.resolve({disconnected:!0})},t}(o.default);t.default=c},function(e,t,r){"use strict";var n,i=this&&this.__extends||(n=function(e,t){return(n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])})(e,t)},function(e,t){function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}),o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,r=1,n=arguments.length;r0&&i[i.length-1])||6!==o[0]&&2!==o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1?"Export multiple Cardano public keys":"Export Cardano public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,g.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-xpub",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n0&&e._ensureFeatureIsSupported("MultiassetOutputs")}))},r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return this._ensureFirmwareSupportsParams(),t=this.device.getCommands(),e.next=4,t.typedCall("CardanoSignTx","CardanoSignedTx",this.params);case 4:return r=e.sent,n=r.message,e.abrupt("return",{hash:n.tx_hash,serializedTx:n.serialized_tx});case 7:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=m},function(e,t,r){"use strict";(function(Buffer){t.__esModule=!0,t.transformCertificate=void 0;var e=r(4),n=r(79),i=r(12),o=r(6),a=function(t){if((0,e.validateParams)(t,[{name:"type",type:"number",obligatory:!0}]),t.type===n.POOL_RELAY_TYPE.SingleHostIp){var r=[{name:"port",type:"number",obligatory:!0}];if(t.ipv4Address&&r.push({name:"ipv4Address",type:"string"}),t.ipv6Address&&r.push({name:"ipv6Address",type:"string"}),(0,e.validateParams)(t,r),!t.ipv4Address&&!t.ipv6Address)throw o.ERRORS.TypedError("Method_InvalidParameter","Either ipv4Address or ipv6Address must be supplied")}else t.type===n.POOL_RELAY_TYPE.SingleHostName?(0,e.validateParams)(t,[{name:"hostName",type:"string",obligatory:!0},{name:"port",type:"number",obligatory:!0}]):n.POOL_RELAY_TYPE.MultipleHostName&&(0,e.validateParams)(t,[{name:"hostName",type:"string",obligatory:!0}])},s=function(t){var r,n;(0,e.validateParams)(t,[{name:"poolId",type:"string",obligatory:!0},{name:"vrfKeyHash",type:"string",obligatory:!0},{name:"pledge",type:"string",obligatory:!0},{name:"cost",type:"string",obligatory:!0},{name:"margin",type:"object",obligatory:!0},{name:"rewardAccount",type:"string",obligatory:!0},{name:"owners",type:"array",obligatory:!0},{name:"relays",type:"array",obligatory:!0,allowEmpty:!0},{name:"metadata",type:"object"}]),r=t.margin,(0,e.validateParams)(r,[{name:"numerator",type:"string",obligatory:!0},{name:"denominator",type:"string",obligatory:!0}]),function(t){if(t.forEach((function(t){if(t.stakingKeyHash&&(0,e.validateParams)(t,[{name:"stakingKeyHash",type:"string",obligatory:!t.stakingKeyPath}]),t.stakingKeyPath&&(0,i.validatePath)(t.stakingKeyPath,5),!t.stakingKeyHash&&!t.stakingKeyPath)throw o.ERRORS.TypedError("Method_InvalidParameter","Either stakingKeyHash or stakingKeyPath must be supplied")})),1!==t.filter((function(e){return!!e.stakingKeyPath})).length)throw o.ERRORS.TypedError("Method_InvalidParameter","Exactly one pool owner must be given as a path")}(t.owners),t.relays.forEach(a),t.metadata&&(n=t.metadata,(0,e.validateParams)(n,[{name:"url",type:"string",obligatory:!0},{name:"hash",type:"string",obligatory:!0}]))};t.transformCertificate=function(t){var r,o=[{name:"type",type:"number",obligatory:!0}];return t.type!==n.CERTIFICATE_TYPE.StakePoolRegistration&&o.push({name:"path",obligatory:!0}),t.type===n.CERTIFICATE_TYPE.StakeDelegation&&o.push({name:"pool",type:"string",obligatory:!0}),t.type===n.CERTIFICATE_TYPE.StakePoolRegistration&&o.push({name:"poolParameters",type:"object",obligatory:!0}),(0,e.validateParams)(t,o),{type:t.type,path:t.path?(0,i.validatePath)(t.path,5):void 0,pool:t.pool,pool_parameters:t.poolParameters?(r=t.poolParameters,s(r),{pool_id:r.poolId,vrf_key_hash:r.vrfKeyHash,pledge:r.pledge,cost:r.cost,margin_numerator:r.margin.numerator,margin_denominator:r.margin.denominator,reward_account:r.rewardAccount,owners:r.owners.map((function(e){return{staking_key_hash:e.stakingKeyHash,staking_key_path:e.stakingKeyPath?(0,i.validatePath)(e.stakingKeyPath,5):void 0}})),relays:r.relays.map((function(e){return{type:e.type,ipv4_address:e.ipv4Address?(r=e.ipv4Address,Buffer.from(r.split(".").map((function(e){return parseInt(e)}))).toString("hex")):void 0,ipv6_address:e.ipv6Address?(t=e.ipv6Address,t.split(":").join("")):void 0,host_name:e.hostName,port:e.port};var t,r})),metadata:r.metadata}):void 0}}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";t.__esModule=!0,t.tokenBundleToProto=t.validateTokenBundle=void 0;var n=r(4);t.validateTokenBundle=function(e){e.forEach((function(e){(0,n.validateParams)(e,[{name:"policyId",type:"string",obligatory:!0},{name:"tokenAmounts",type:"array",obligatory:!0}]),e.tokenAmounts.forEach((function(e){(0,n.validateParams)(e,[{name:"assetNameBytes",type:"string",obligatory:!0},{name:"amount",type:"amount",obligatory:!0}])}))}))};t.tokenBundleToProto=function(e){return e.map((function(e){return{policy_id:e.policyId,tokens:(t=e.tokenAmounts,t.map((function(e){return{asset_name_bytes:e.assetNameBytes,amount:e.amount}})))};var t}))}},function(e,t,r){"use strict";(function(Buffer){var e=r(14),n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=e(r(20)),c=r(13),l=n(r(5)),h=r(4),d=r(12);function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t0)){e.next=18;break}return e.next=13,(0,b.initBlockchain)(r,this.postMessage);case 13:return f=e.sent,e.next=16,f.getTransactions(u);case 16:c=e.sent,s=(0,w.transformReferencedTransactions)(c,r);case 18:return l=this.device.unavailableCapabilities.replaceTransaction?E.default:_.default,e.next=21,l(this.device.getCommands().typedCall.bind(this.device.getCommands()),i,a,s,n,r);case 21:return h=e.sent,e.next=24,(0,S.default)(this.device.getCommands().getHDNode.bind(this.device.getCommands()),i,a,h.serializedTx,r);case 24:if(!this.params.push){e.next=32;break}return e.next=27,(0,b.initBlockchain)(r,this.postMessage);case 27:return d=e.sent,e.next=30,d.pushTransaction(h.serializedTx);case 30:return p=e.sent,e.abrupt("return",O(O({},h),{},{txid:p}));case 32:return e.abrupt("return",h);case 33:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),r.dispose=function(){var e=this.discovery;e&&(e.stop(),e.removeAllListeners(),this.discovery=void 0)},t}(c.default);t.default=P},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(11)),s=n(r(29)),u=r(481),f=n(r(215)),c=(n(r(23)),r(12));function l(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function h(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return d(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return d(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=0}}))}var t=e.prototype;return t.init=function(){var e=(0,o.default)(i.default.mark((function e(t){var r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t.getNetworkInfo();case 2:return r=e.sent,n=r.blockHeight,this.blockHeight=n,e.next=7,this.feeLevels.load(t);case 7:case"end":return e.stop()}}),e,this)})));return function(t){return e.apply(this,arguments)}}(),t.composeAllFeeLevels=function(){var e=this.feeLevels.levels;if(this.utxos.length<1)return!1;this.composed={};for(var t,r=!1,n=h(e);!(t=n()).done;){var i=t.value;if("0"!==i.feePerUnit){var o=this.compose(i.feePerUnit);"final"===o.type&&(r=!0),this.composed[i.label]=o}}if(!r){for(var a=e[e.length-1],u=new s.default(a.feePerUnit);u.gt(this.coinInfo.minFee)&&void 0===this.composed.custom;){u=u.minus(1);var f=this.compose(u.toString());if("final"===f.type)return this.feeLevels.updateCustomFee(u.toString()),this.composed.custom=f,!0}return!1}return!0},t.composeCustomFee=function(e){var t=this.compose(e);this.composed.custom=t,"final"===t.type?this.feeLevels.updateCustomFee(t.feePerByte):this.feeLevels.updateCustomFee(e)},t.getFeeLevelList=function(){var e=this,t=[];return this.feeLevels.levels.forEach((function(r){var n=e.composed[r.label];n&&"final"===n.type?t.push({name:r.label,fee:n.fee,feePerByte:r.feePerUnit,minutes:r.blocks*e.coinInfo.blocktime,total:n.totalSpent}):t.push({name:r.label,fee:"0",disabled:!0})})),t},t.compose=function(e){var t=this.account,r=this.coinInfo,n=this.baseFee,i=t.addresses;if(!i)return{type:"error",error:"ADDRESSES-NOT-SET"};var o=i.change.find((function(e){return e.transfers<1}))||i.change[i.change.length-1],s=(0,c.getHDPath)(o.path).slice(-1)[0],f={baseFee:n,floorBaseFee:!1,dustOutputFee:0};"DOGE"===r.shortcut&&(f.floorBaseFee=0===f.baseFee,f.baseFee=f.baseFee||1e8,f.dustOutputFee=1e8);var h=(0,u.buildTx)(function(e){for(var t=1;te.length)&&(t=e.length);for(var r=0,n=new Array(t);r2&&void 0!==arguments[2]?arguments[2]:n.networks.bitcoin;p(this,e),m(this,"socket",(0,a.deferred)()),m(this,"workingUrl","none"),m(this,"_silent",!1),m(this,"closeOnInit",new i.Emitter),this.addresses=new Set,this.socketWorkerFactory=r,this.endpoints=t,this.network=s;var u=function(e){return i.Stream.filterError(e.observe("bitcoind/addresstxid").mapPromise((function(e){var t=e.txid;return o.lookupTransaction(t)})))},f=function(e){return e.subscribe("bitcoind/hashblock"),e.observe("bitcoind/hashblock")},c=i.Stream.setLater(),l=i.Stream.setLater(),h=i.Stream.setLater();this.errors=c.stream,this.notifications=l.stream,this.blocks=h.stream;var d={"-1":!0};e._tryEndpoint(t,r,d,this.closeOnInit).then((function(e){var t=e.socket,r=e.url;o.closeOnInit.destroy(),E(t,2,!1).then((function(){o.hasSmartTxFees=!0}),(function(){o.hasSmartTxFees=!1})).then((function(){o.workingUrl=r,o.socket.resolve(t),c.setter(S(t)),l.setter(u(t)),h.setter(f(t))}))}),(function(){c.setter(i.Stream.simple(new Error("All backends are offline."))),o.socket.reject(new Error("All backends are offline.")),o.socket.promise.catch((function(e){o._silent||console.error(e)}))}))}return y(e,null,[{key:"_tryEndpoint",value:function(t,r,n,i){var a=n,u=t.filter((function(e,t){return!n[t.toString()]}));if(0===u.length)return Promise.reject(new Error("All backends are down."));var f=(0,s.uniqueRandom)(u.length);return function(e,t,r){var n=new o.Socket(e,t,r);return new Promise((function(e){S(n).awaitFirst().then((function(){e(!1)})),Promise.race([new Promise((function(e,t){return setTimeout((function(){return t()}),3e4)})),_(n,0)]).then((function(){e(!0)}),(function(){e(!1)}))})).then((function(e){return e?n:(n.close(),null)}))}(r,u[f],i).then((function(n){return n?{socket:n,url:u[f]}:(a[f.toString()]=!0,e._tryEndpoint(t,r,a,i))}))}}]),y(e,[{key:"hardStatusCheck",value:function(){var t=new e(this.endpoints,this.socketWorkerFactory);return t.socket.promise.then((function(){return t.destroy().then((function(){return!0}))}),(function(){return t.destroy().then((function(){return!1}))}))}},{key:"subscribe",value:function(e){var t=this;if(!(e instanceof Set))throw new Error("Input not a set of strings.");var r=!1;if(e.forEach((function(e){"string"!=typeof e&&(r=!0)})),r)throw new Error("Input not a set of strings.");this.socket.promise.then((function(r){var n=l(e).filter((function(e){return!t.addresses.has(e)}));if(n.forEach((function(e){return t.addresses.add(e)})),0!==n.length)for(var i=0;ie.length)&&(t=e.length);for(var r=0,n=new Array(t);rthis.count&&(this.count=e,this.emitter.emit({transactions:this.count}))}}]),e}()},function(e,t,r){"use strict"; /** * @license * https://github.com/ealmansi/cashaddrjs * Copyright (c) 2017-2020 Emilio Almansi * Distributed under the MIT software license, see the accompanying * file LICENSE or http://www.opensource.org/licenses/mit-license.php. - */var n=r(488),i=r(489),o=r(490),a=r(119),s=a.validate;var u=a.ValidationError,f=["bitcoincash","bchtest","bchreg"];function c(e){for(var t=new Uint8Array(e.length),r=0;r0?Math.floor(e):Math.ceil(e)}function p(e,r){var n,i,o=e.length,a=r.length,s=new Array(o),u=0,f=t;for(i=0;i=f?1:0,s[i]=n-u*f;for(;i0&&s.push(u),s}function y(e,t){return e.length>=t.length?p(e,t):p(t,e)}function g(e,r){var n,i,o=e.length,a=new Array(o),s=t;for(i=0;i0;)a[i++]=r%s,r=Math.floor(r/s);return a}function m(e,t){var r,n,i=e.length,o=t.length,a=new Array(i),s=0;for(r=0;r0;)a[i++]=u%s,u=Math.floor(u/s);return a}function _(e,t){for(var r=[];t-- >0;)r.push(0);return r.concat(e)}function E(e,r,n){return new BigInteger(e=0;--r)i=(o=1e7*i+e[r])-(n=d(o/t))*t,s[r]=0|n;return[s,0|i]}function I(e,r){var n,i,o=K(r),u=e.value,p=o.value;if(0===p)throw new Error("Cannot divide by zero");if(e.isSmall)return o.isSmall?[new s(d(u/p)),new s(u%p)]:[a[0],e];if(o.isSmall){if(1===p)return[e,a[0]];if(-1==p)return[e.negate(),a[0]];var y=Math.abs(p);if(y=0;i--){for(n=p-1,b[i+d]!==g&&(n=Math.floor((b[i+d]*p+b[i+d-1])/g)),o=0,a=0,u=v.length,s=0;su&&(i=1e7*(i+1)),r=Math.ceil(i/o);do{if(O(a=w(t,r),h)<=0)break;r--}while(r);f.push(r),h=m(h,a)}return f.reverse(),[c(f),c(h)]}(u,p))[0];var v=e.sign!==o.sign,_=n[1],E=e.sign;return"number"==typeof i?(v&&(i=-i),i=new s(i)):i=new BigInteger(i,v),"number"==typeof _?(E&&(_=-_),_=new s(_)):_=new BigInteger(_,E),[i,_]}function O(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var r=e.length-1;r>=0;r--)if(e[r]!==t[r])return e[r]>t[r]?1:-1;return 0}function P(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function M(e,t){for(var r,i,o,s=e.prev(),u=s,f=0;u.isEven();)u=u.divide(2),f++;e:for(i=0;i=0?n=m(e,t):(n=m(t,e),r=!r),"number"==typeof(n=c(n))?(r&&(n=-n),new s(n)):new BigInteger(n,r)}(r,n,this.sign)},BigInteger.prototype.minus=BigInteger.prototype.subtract,s.prototype.subtract=function(e){var t=K(e),r=this.value;if(r<0!==t.sign)return this.add(t.negate());var n=t.value;return t.isSmall?new s(r-n):b(n,Math.abs(r),r>=0)},s.prototype.minus=s.prototype.subtract,BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)},s.prototype.negate=function(){var e=this.sign,t=new s(-this.value);return t.sign=!e,t},BigInteger.prototype.abs=function(){return new BigInteger(this.value,!1)},s.prototype.abs=function(){return new s(Math.abs(this.value))},BigInteger.prototype.multiply=function(e){var r,n,i,o=K(e),s=this.value,u=o.value,c=this.sign!==o.sign;if(o.isSmall){if(0===u)return a[0];if(1===u)return this;if(-1===u)return this.negate();if((r=Math.abs(u))0?function e(t,r){var n=Math.max(t.length,r.length);if(n<=30)return v(t,r);n=Math.ceil(n/2);var i=t.slice(n),o=t.slice(0,n),a=r.slice(n),s=r.slice(0,n),u=e(o,s),f=e(i,a),c=e(y(o,i),y(s,a)),h=y(y(u,_(m(m(c,u),f),n)),_(f,2*n));return l(h),h}(s,u):v(s,u),c)},BigInteger.prototype.times=BigInteger.prototype.multiply,s.prototype._multiplyBySmall=function(e){return u(e.value*this.value)?new s(e.value*this.value):E(Math.abs(e.value),f(Math.abs(this.value)),this.sign!==e.sign)},BigInteger.prototype._multiplyBySmall=function(e){return 0===e.value?a[0]:1===e.value?this:-1===e.value?this.negate():E(Math.abs(e.value),this.value,this.sign!==e.sign)},s.prototype.multiply=function(e){return K(e)._multiplyBySmall(this)},s.prototype.times=s.prototype.multiply,BigInteger.prototype.square=function(){return new BigInteger(S(this.value),!1)},s.prototype.square=function(){var e=this.value*this.value;return u(e)?new s(e):new BigInteger(S(f(Math.abs(this.value))),!1)},BigInteger.prototype.divmod=function(e){var t=I(this,e);return{quotient:t[0],remainder:t[1]}},s.prototype.divmod=BigInteger.prototype.divmod,BigInteger.prototype.divide=function(e){return I(this,e)[0]},s.prototype.over=s.prototype.divide=BigInteger.prototype.over=BigInteger.prototype.divide,BigInteger.prototype.mod=function(e){return I(this,e)[1]},s.prototype.remainder=s.prototype.mod=BigInteger.prototype.remainder=BigInteger.prototype.mod,BigInteger.prototype.pow=function(e){var t,r,n,i=K(e),o=this.value,f=i.value;if(0===f)return a[1];if(0===o)return a[0];if(1===o)return a[1];if(-1===o)return i.isEven()?a[1]:a[-1];if(i.sign)return a[0];if(!i.isSmall)throw new Error("The exponent "+i.toString()+" is too large.");if(this.isSmall&&u(t=Math.pow(o,f)))return new s(d(t));for(r=this,n=a[1];!0&f&&(n=n.times(r),--f),0!==f;)f/=2,r=r.square();return n},s.prototype.pow=BigInteger.prototype.pow,BigInteger.prototype.modPow=function(e,t){if(e=K(e),(t=K(t)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var r=a[1],n=this.mod(t);e.isPositive();){if(n.isZero())return a[0];e.isOdd()&&(r=r.multiply(n).mod(t)),e=e.divide(2),n=n.square().mod(t)}return r},s.prototype.modPow=BigInteger.prototype.modPow,BigInteger.prototype.compareAbs=function(e){var t=K(e),r=this.value,n=t.value;return t.isSmall?1:O(r,n)},s.prototype.compareAbs=function(e){var t=K(e),r=Math.abs(this.value),n=t.value;return t.isSmall?r===(n=Math.abs(n))?0:r>n?1:-1:-1},BigInteger.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=K(e),r=this.value,n=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:O(r,n)*(this.sign?-1:1)},BigInteger.prototype.compareTo=BigInteger.prototype.compare,s.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=K(e),r=this.value,n=t.value;return t.isSmall?r==n?0:r>n?1:-1:r<0!==t.sign?r<0?-1:1:r<0?1:-1},s.prototype.compareTo=s.prototype.compare,BigInteger.prototype.equals=function(e){return 0===this.compare(e)},s.prototype.eq=s.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals,BigInteger.prototype.notEquals=function(e){return 0!==this.compare(e)},s.prototype.neq=s.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals,BigInteger.prototype.greater=function(e){return this.compare(e)>0},s.prototype.gt=s.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater,BigInteger.prototype.lesser=function(e){return this.compare(e)<0},s.prototype.lt=s.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser,BigInteger.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},s.prototype.geq=s.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals,BigInteger.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},s.prototype.leq=s.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals,BigInteger.prototype.isEven=function(){return 0==(1&this.value[0])},s.prototype.isEven=function(){return 0==(1&this.value)},BigInteger.prototype.isOdd=function(){return 1==(1&this.value[0])},s.prototype.isOdd=function(){return 1==(1&this.value)},BigInteger.prototype.isPositive=function(){return!this.sign},s.prototype.isPositive=function(){return this.value>0},BigInteger.prototype.isNegative=function(){return this.sign},s.prototype.isNegative=function(){return this.value<0},BigInteger.prototype.isUnit=function(){return!1},s.prototype.isUnit=function(){return 1===Math.abs(this.value)},BigInteger.prototype.isZero=function(){return!1},s.prototype.isZero=function(){return 0===this.value},BigInteger.prototype.isDivisibleBy=function(e){var t=K(e),r=t.value;return 0!==r&&(1===r||(2===r?this.isEven():this.mod(t).equals(a[0])))},s.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy,BigInteger.prototype.isPrime=function(e){var t=P(this);if(void 0!==t)return t;var r=this.abs(),i=r.bitLength();if(i<=64)return M(r,[2,325,9375,28178,450775,9780504,1795265022]);for(var o=Math.log(2)*i,a=Math.ceil(!0===e?2*Math.pow(o,2):o),s=[],u=0;u-r?new s(e-1):new BigInteger(i,!0)};for(var k=[1];2*k[k.length-1]<=t;)k.push(2*k[k.length-1]);var T=k.length,x=k[T-1];function R(e){return("number"==typeof e||"string"==typeof e)&&+Math.abs(e)<=t||e instanceof BigInteger&&e.value.length<=1}function C(e,t,r){t=K(t);for(var i=e.isNegative(),o=t.isNegative(),a=i?e.not():e,s=o?t.not():t,u=0,f=0,c=null,l=null,h=[];!a.isZero()||!s.isZero();)u=(c=I(a,x))[1].toJSNumber(),i&&(u=x-1-u),f=(l=I(s,x))[1].toJSNumber(),o&&(f=x-1-f),a=c[0],s=l[0],h.push(r(u,f));for(var d=0!==r(i?1:0,o?1:0)?n(-1):n(0),p=h.length-1;p>=0;p-=1)d=d.multiply(x).add(n(h[p]));return d}BigInteger.prototype.shiftLeft=function(e){if(!R(e))throw new Error(String(e)+" is too large for shifting.");if((e=+e)<0)return this.shiftRight(-e);var t=this;if(t.isZero())return t;for(;e>=T;)t=t.multiply(x),e-=T-1;return t.multiply(k[e])},s.prototype.shiftLeft=BigInteger.prototype.shiftLeft,BigInteger.prototype.shiftRight=function(e){var t;if(!R(e))throw new Error(String(e)+" is too large for shifting.");if((e=+e)<0)return this.shiftLeft(-e);for(var r=this;e>=T;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;r=(t=I(r,x))[1].isNegative()?t[0].prev():t[0],e-=T-1}return(t=I(r,k[e]))[1].isNegative()?t[0].prev():t[0]},s.prototype.shiftRight=BigInteger.prototype.shiftRight,BigInteger.prototype.not=function(){return this.negate().prev()},s.prototype.not=BigInteger.prototype.not,BigInteger.prototype.and=function(e){return C(this,e,(function(e,t){return e&t}))},s.prototype.and=BigInteger.prototype.and,BigInteger.prototype.or=function(e){return C(this,e,(function(e,t){return e|t}))},s.prototype.or=BigInteger.prototype.or,BigInteger.prototype.xor=function(e){return C(this,e,(function(e,t){return e^t}))},s.prototype.xor=BigInteger.prototype.xor;function N(e){var r=e.value,n="number"==typeof r?r|1<<30:r[0]+r[1]*t|1073758208;return n&-n}function B(e,t){return e=K(e),t=K(t),e.greater(t)?e:t}function D(e,t){return e=K(e),t=K(t),e.lesser(t)?e:t}function U(e,t){if(e=K(e).abs(),t=K(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var r,n,i=a[1];e.isEven()&&t.isEven();)r=Math.min(N(e),N(t)),e=e.divide(r),t=t.divide(r),i=i.multiply(r);for(;e.isEven();)e=e.divide(N(e));do{for(;t.isEven();)t=t.divide(N(t));e.greater(t)&&(n=t,t=e,e=n),t=t.subtract(e)}while(!t.isZero());return i.isUnit()?e:e.multiply(i)}BigInteger.prototype.bitLength=function(){var e=this;return e.compareTo(n(0))<0&&(e=e.negate().subtract(n(1))),0===e.compareTo(n(0))?n(0):n(function e(t,r){if(r.compareTo(t)<=0){var i=e(t,r.square(r)),o=i.p,a=i.e,s=o.multiply(r);return s.compareTo(t)<=0?{p:s,e:2*a+1}:{p:o,e:2*a}}return{p:n(1),e:0}}(e,n(2)).e).add(n(1))},s.prototype.bitLength=BigInteger.prototype.bitLength;var j=function(e,t){for(var r=e.length,n=Math.abs(t),i=0;i=n){if("1"===c&&1===n)continue;throw new Error(c+" is not a valid digit in base "+t+".")}if(c.charCodeAt(0)-87>=n)throw new Error(c+" is not a valid digit in base "+t+".")}}if(2<=t&&t<=36&&r<=o/Math.log(t)){var a=parseInt(e,t);if(isNaN(a))throw new Error(c+" is not a valid digit in base "+t+".");return new s(parseInt(e,t))}t=K(t);var u=[],f="-"===e[0];for(i=f?1:0;i"!==e[i]);u.push(K(e.slice(h+1,i)))}}return L(u,t,f)};function L(e,t,r){var n,i=a[0],o=a[1];for(n=e.length-1;n>=0;n--)i=i.add(e[n].times(o)),o=o.times(t);return r?i.negate():i}function F(e){return e<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e):"<"+e+">"}function H(e,t){if((t=n(t)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e)).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(+e-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&t.isPositive()&&(i=!0,e=e.abs()),t.equals(1))return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(+e)).map(Number.prototype.valueOf,1),isNegative:i};for(var o,a=[],s=e;s.isNegative()||s.compareAbs(t)>=0;){o=s.divmod(t),s=o.quotient;var u=o.remainder;u.isNegative()&&(u=t.minus(u).abs(),s=s.next()),a.push(u.toJSNumber())}return a.push(s.toJSNumber()),{value:a.reverse(),isNegative:i}}function q(e,t){var r=H(e,t);return(r.isNegative?"-":"")+r.value.map(F).join("")}function V(e){if(u(+e)){var t=+e;if(t===d(t))return new s(t);throw new Error("Invalid integer: "+e)}var r="-"===e[0];r&&(e=e.slice(1));var n=e.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var i=n[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==d(i)||!u(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var o=n[0],a=o.indexOf(".");if(a>=0&&(i-=o.length-a-1,o=o.slice(0,a)+o.slice(a+1)),i<0)throw new Error("Cannot include negative exponent part for integers");e=o+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(e))throw new Error("Invalid integer: "+e);for(var f=[],c=e.length,h=c-7;c>0;)f.push(+e.slice(h,c)),(h-=7)<0&&(h=0),c-=7;return l(f),new BigInteger(f,r)}function K(e){return"number"==typeof e?function(e){if(u(e)){if(e!==d(e))throw new Error(e+" is not an integer.");return new s(e)}return V(e.toString())}(e):"string"==typeof e?V(e):e}BigInteger.prototype.toArray=function(e){return H(this,e)},s.prototype.toArray=function(e){return H(this,e)},BigInteger.prototype.toString=function(e){if(void 0===e&&(e=10),10!==e)return q(this,e);for(var t,r=this.value,n=r.length,i=String(r[--n]);--n>=0;)t=String(r[n]),i+="0000000".slice(t.length)+t;return(this.sign?"-":"")+i},s.prototype.toString=function(e){return void 0===e&&(e=10),10!=e?q(this,e):String(this.value)},BigInteger.prototype.toJSON=s.prototype.toJSON=function(){return this.toString()},BigInteger.prototype.valueOf=function(){return parseInt(this.toString(),10)},BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf,s.prototype.valueOf=function(){return this.value},s.prototype.toJSNumber=s.prototype.valueOf;for(var z=0;z<1e3;z++)a[z]=new s(z),z>0&&(a[-z]=new s(-z));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=B,a.min=D,a.gcd=U,a.lcm=function(e,t){return e=K(e).abs(),t=K(t).abs(),e.divide(U(e,t)).multiply(t)},a.isInstance=function(e){return e instanceof BigInteger||e instanceof s},a.randBetween=function(e,r){var n=D(e=K(e),r=K(r)),i=B(e,r).subtract(n).add(1);if(i.isSmall)return n.add(Math.floor(Math.random()*i));for(var o=[],a=!0,u=i.value.length-1;u>=0;u--){var f=a?i.value[u]:t,l=d(Math.random()*f);o.unshift(l),l>t==0,"Invalid value: "+h+"."),f=f<=r;)c-=r,s[u]=f>>c&a,++u}return i?n(c0&&(s[u]=f<=this.concurrency))if(0!==this.jobs.length){var t=this,r=this.jobs.shift(),n=!0,i=this.session,o=null,a=!1,f=null,c=r.hasOwnProperty("timeout")?r.timeout:this.timeout;c&&(o=setTimeout((function(){a=!0,t.listeners("timeout").length>0?t.emit("timeout",h,r):h()}),c),this.timers[o]=o),this.results&&(f=this.results.length,this.results[f]=null),this.pending++,t.emit("start",r);var l=r(h);l&&l.then&&"function"==typeof l.then&&l.then((function(e){return h(null,e)})).catch((function(e){return h(e||!0)})),this.running&&this.jobs.length>0&&this.start()}else 0===this.pending&&u.call(this);function h(e,s){n&&t.session===i&&(n=!1,t.pending--,null!==o&&(delete t.timers[o],clearTimeout(o)),e?t.emit("error",e,r):!1===a&&(null!==f&&(t.results[f]=Array.prototype.slice.call(arguments,1)),t.emit("success",s,r)),t.session===i&&(0===t.pending&&0===t.jobs.length?u.call(t):t.running&&t.start()))}},o.prototype.stop=function(){this.running=!1},o.prototype.end=function(e){a.call(this),this.jobs.length=0,this.pending=0,u.call(this,e)}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.buildTx=function(e){var t=e.utxos,r=e.outputs,n=e.height,u=e.feeRate,f=e.segwit,c=e.inputAmounts,l=e.basePath,h=e.network,d=e.changeId,p=e.changeAddress,y=e.dustThreshold,g=e.baseFee,m=e.floorBaseFee,b=e.dustOutputFee,v=e.skipUtxoSelection;if(0===r.length)return o.empty;if(0===t.length)return{type:"error",error:"NOT-ENOUGH-FUNDS"};var w={exists:!1,id:0};try{w=i.getMax(r)}catch(e){return{type:"error",error:e.message}}var _=i.splitByCompleteness(r),E={type:"false"};try{E=s.coinselect(t,r,n,u,f,w.exists,w.id,y,h,g,m,b,v)}catch(e){return{type:"error",error:e.message}}if("false"===E.type)return{type:"error",error:"NOT-ENOUGH-FUNDS"};if(_.incomplete.length>0)return o.getNonfinalResult(E);var S=a.createTransaction(t,E.result.inputs,_.complete,E.result.outputs,f,c,l,d,p,h);return o.getFinalResult(E,S)},Object.defineProperty(t,"BuildTxRequest",{enumerable:!0,get:function(){return i.Request}}),Object.defineProperty(t,"BuildTxOutputRequest",{enumerable:!0,get:function(){return i.OutputRequest}}),Object.defineProperty(t,"BuildTxEmptyResult",{enumerable:!0,get:function(){return o.empty}}),Object.defineProperty(t,"BuildTxResult",{enumerable:!0,get:function(){return o.Result}}),Object.defineProperty(t,"BuildTxTransaction",{enumerable:!0,get:function(){return a.Transaction}}),Object.defineProperty(t,"BuildTxOutput",{enumerable:!0,get:function(){return a.Output}}),Object.defineProperty(t,"BuildTxInput",{enumerable:!0,get:function(){return a.Input}});var i=f(r(120)),o=f(r(494)),a=f(r(223)),s=f(r(121));function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}function f(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,t&&t.set(e,r),r}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.getNonfinalResult=function(e){var t=e.result,r=t.max,n=t.fee,i=t.feePerByte,o=t.bytes,a=t.totalSpent;return{type:"nonfinal",fee:n,feePerByte:i,bytes:o,max:r,totalSpent:a}},t.getFinalResult=function(e,t){var r=e.result,n=r.max,i=r.fee,o=r.feePerByte,a=r.bytes,s=r.totalSpent;return{type:"final",fee:i,feePerByte:o,bytes:a,transaction:t,max:n,totalSpent:s}},t.empty=void 0;o(r(223)),o(r(121));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function o(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=o?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}return r.default=e,t&&t.set(e,r),r}t.empty={type:"error",error:"EMPTY"}},function(e,t,r){"use strict";function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t}))}(e,i),c=a.transactionBytes(f,t),l=a.getFee(u,c,n,t),h={fee:l.toString()};if(0===t.length)return h;var d=a.sumOrNaN(f);if(d.isNaN())return h;var p=a.sumOrNaN(t,!0),y=d.minus(p).minus(new o.default(l));if(y.comparedTo(new o.default(0))<0)return h;var g=t.reduce((function(e,t){return e+(a.bignumberOrNaN(t.value).isNaN()?1:0)}),0);if("0"===y.toString()&&0===g)return a.finalize(f,t,u,n);var m=y.div(new o.default(g)),b=a.dustThreshold(u,n.inputLength,n.changeOutputLength,n.dustThreshold);if(g&&m.lte(b))return h;var v=t.map((function(e){if(void 0!==e.value)return e;var t={};return Object.keys(e).forEach((function(r){t[r]=e[r]})),t.value=m.toString(),t}));return a.finalize(f,v,u,n)};var i,o=(i=r(29))&&i.__esModule?i:{default:i},a=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r(52));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var f=e.sort(a.score(r));return(0,u.default)(s.anyOf([(0,o.default)(.5),i.default]),n)(f,t,r,n)};var i=l(r(498)),o=l(r(499)),a=c(r(500)),s=c(r(52)),u=l(r(501));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function c(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,t&&t.set(e,r),r}function l(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var i=a.bignumberOrNaN(r);if(i.isNaN()||!i.isInteger())return{};var s=i.toNumber(),u=a.transactionBytes([],t),f=new o.default(0),c=[],l=a.sumOrNaN(t),h=[],d=[];if(e.forEach((function(e){if(e.required){h.push(e);var t=a.inputBytes(e),r=a.bignumberOrNaN(e.value);u+=t,f=f.plus(r),c.push(e)}else d.push(e)})),h.length>0){var p=a.finalize(h,t,s,n);if(p.inputs)return p}for(var y=0;y=0)return a.finalize(c,t,s,n)}}return{fee:a.getFee(s,u,n,t).toString()}};var i,o=(i=r(29))&&i.__esModule?i:{default:i},a=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r(52));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,r,n,i){var s=i.inputLength,u=i.changeOutputLength;if(i.baseFee)return{};var f=a.bignumberOrNaN(n);if(f.isNaN()||!f.isInteger())return{};var c=f.toNumber(),l=a.outputBytes({script:{length:u}})*c,h=a.inputBytes({script:{length:s}})*c,d=Math.floor((h+l)*e),p=a.transactionBytes([],r),y=f.times(p),g=a.sumOrNaN(r);if(g.isNaN())return{fee:"0"};var m=g.plus(y),b=function(e,t){return e.map((function(e){var r=a.bignumberOrNaN(e.value);if(r.isNaN())return{utxo:e,effectiveValue:new o.default(0)};var n=a.inputBytes(e)*t;return{utxo:e,effectiveValue:r.minus(n)}}))}(t,c).filter((function(e){return e.effectiveValue.comparedTo(new o.default(0))>0})).sort((function(e,t){var r=t.effectiveValue.minus(e.effectiveValue).toNumber();return 0!==r?r:e.utxo.i-t.utxo.i})),v=function(e,t,r){if(0===e.length)return null;var n=1e6,i=[],a=new o.default(0),s=!1,u=!1,f=e.reduce((function(e,t){return t.effectiveValue.plus(e)}),new o.default(0)),c=t.plus(r),l=0;for(;!s;){if(n<=0)return null;if(a.comparedTo(c)>0)u=!0;else if(a.comparedTo(t)>=0)s=!0;else if(l>=e.length)u=!0;else if(a.plus(f).comparedTo(t)<0){if(0===l)return null;u=!0}else f=f.minus(e[l].effectiveValue),i[l]=!0,a=a.plus(e[l].effectiveValue),l++;if(u){for(u=!1,l--;!i[l];)if(f=f.plus(e[l].effectiveValue),--l<0)return null;i[l]=!1,a=a.minus(e[l].effectiveValue),l++}n--}return i}(b,m,d);if(null!==v){for(var w=[],_=0;_=t:a.confirmations>=r)?n.push(a):i.push(a)}return{usable:n,unusable:i}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=t.own||1,i=t.other||6,o=t.coinbase||100;return function(t,a,s,u){t.forEach((function(e){if(null==e.coinbase||null==e.own||null==e.confirmations)throw new Error("Missing information.")}));var f=function(e,t){return e.filter((function(e){return!e.coinbase||e.confirmations>=t}))}(t,o);if(0===f.length)return{};var c,l=[];for(c=r;c>0;c--)l.push({other:i,own:c});for(c=i-1;c>0;c--)l.push({other:c,own:1});l.push({other:1,own:0}),l.push({other:0,own:0});var h=f,d=[];for(c=0;c0){d=d.concat(y.usable),h=y.unusable;var g=e(d,a,s,u);if(g.inputs)return g;if(0===h.length)return g}}throw new Error("Unexpected unreturned result")}}},function(e,t,r){"use strict";(function(Buffer){t.__esModule=!0,t.inputToTrezor=t.inputToHD=t.enhanceTrezorInputs=t.validateTrezorInputs=void 0;var e=r(225),n=r(12),i=r(78),o=r(4);function a(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=3?l.versionGroupId:void 0;return[{version:l.isDashSpecialTransaction()?l.version|l.type<<16:l.version,hash:l.getId(),inputs:l.ins.map((function(e,t){var r=f[t].addresses.join(""),a=h.find((function(e){return e.address===r})),s=a?(0,i.getHDPath)(a.path):[];return{address_n:s,prev_hash:(0,n.reverseBuffer)(e.hash).toString("hex"),prev_index:e.index,script_sig:e.script.toString("hex"),sequence:e.sequence,script_type:(0,i.getScriptType)(s),multisig:void 0,amount:f[t].value,decred_tree:void 0,witness:l.hasWitnesses()?o(e.witness):void 0,ownership_proof:void 0,commitment_data:void 0}})),outputs:l.outs.map((function(e,t){var r=c[t].addresses.join(""),n=a.change.find((function(e){return e.address===r})),o=n&&(0,i.getHDPath)(n.path),s="number"==typeof e.value?e.value.toString():e.value;return o?{address_n:o,amount:s,script_type:(0,i.getOutputScriptType)(o)}:{address:r,amount:s,script_type:"PAYTOADDRESS"}})),extra_data:d?d.toString("hex"):void 0,lock_time:l.locktime,timestamp:l.timestamp,version_group_id:p,expiry:l.expiryHeight}]}))};t.transformReferencedTransactions=function(t,r){return t.flatMap((function(t){if("bitcoin"!==r.type||"blockbook"!==t.type)return[];var i=t.tx.hex,o=e.Transaction.fromHex(i,r.network),a=o.getExtraData(),s=e.coins.isZcashType(o.network)&&"number"==typeof o.versionGroupId&&o.version>=3?o.versionGroupId:void 0;return[{version:o.isDashSpecialTransaction()?o.version|o.type<<16:o.version,hash:o.getId(),inputs:o.ins.map((function(e,t){return{prev_index:e.index,sequence:e.sequence,prev_hash:(0,n.reverseBuffer)(e.hash).toString("hex"),script_sig:e.script.toString("hex")}})),bin_outputs:o.outs.map((function(e){return{amount:"number"==typeof e.value?e.value.toString():e.value,script_pubkey:e.script.toString("hex")}})),extra_data:a?a.toString("hex"):void 0,lock_time:o.locktime,timestamp:o.timestamp,version_group_id:s,expiry:o.expiryHeight}]}))}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=r(6),c=r(13),l=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["custom-message","read","write"],r.info="Custom message";var n=t.payload;if((0,u.validateParams)(t.payload,[{name:"message",type:"string",obligatory:!0},{name:"params",type:"object",obligatory:!0}]),Object.prototype.hasOwnProperty.call(n,"messages"))try{JSON.parse(JSON.stringify(n.messages))}catch(e){throw f.ERRORS.TypedError("Method_InvalidParameter",'Parameter "messages" has invalid type. JSON expected.')}return r.params={customMessages:n.messages,message:n.message,params:n.params},r}(0,a.default)(t,e);var r=t.prototype;return r.getCustomMessages=function(){return this.params.customMessages},r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n,o;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("trezor.io"!==this.device.features.vendor&&"bitcointrezor.com"!==this.device.features.vendor){e.next=2;break}throw f.ERRORS.TypedError("Runtime",'Cannot use custom message on device with official firmware. Change device "vendor" field.');case 2:return e.next=4,this.device.getCommands()._commonCall(this.params.message,this.params.params);case 4:return t=e.sent,r=this.createUiPromise(f.UI.CUSTOM_MESSAGE_RESPONSE,this.device),this.postMessage((0,c.UiMessage)(f.UI.CUSTOM_MESSAGE_REQUEST,t)),e.next=9,r.promise;case 9:if(n=e.sent,o=n.payload,(0,u.validateParams)(o,[{name:"message",type:"string",obligatory:!0}]),"release"!==o.message.toLowerCase()){e.next=16;break}return e.abrupt("return",t);case 16:return(0,u.validateParams)(o,[{name:"params",type:"object",obligatory:!0}]),this.params.message=o.message,this.params.params=o.params,e.next=21,this.run();case 21:return e.abrupt("return",e.sent);case 22:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=r(6),c=function(e){function t(t){var r;(r=e.call(this,t)||this).useDevice=!0,r.debugLink=!0,r.useUi=!1,r.requiredPermissions=["management"];var n=t.payload;return(0,u.validateParams)(n,[{name:"yes_no",type:"boolean"},{name:"up_down",type:"boolean"},{name:"input",type:"string"}]),r.params={yes_no:n.yes_no,input:n.input},r}return(0,a.default)(t,e),t.prototype.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.device.hasDebugLink){e.next=2;break}throw f.ERRORS.TypedError("Runtime","Device is not a debug link");case 2:if(this.device.isUsedHere()){e.next=4;break}throw f.ERRORS.TypedError("Runtime","DebugLinkDecision: Device is not acquired!");case 4:return t=this.device.getCommands(),e.next=7,t.typedCall("DebugLinkDecision","Success",this.params);case 7:return e.abrupt("return",{debugLink:!0});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=c},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(11)),a=n(r(2)),s=n(r(3)),u=n(r(5)),f=r(6);function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t1)throw Error("Discovery for multiple coins in not supported");n=!0}e.coinInfo=t,r.firmwareRange=(0,l.getFirmwareRange)(r.name,t,r.firmwareRange)})),r.params=i.bundle,r.useDevice=n,r.useUi=n,r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n,o;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(g.UI.RECEIVE_CONFIRMATION,this.device),1!==this.params.length||this.params[0].path||this.params[0].descriptor?(r={},this.params.forEach((function(e){r[e.coinInfo.label]||(r[e.coinInfo.label]={coinInfo:e.coinInfo,values:[]}),r[e.coinInfo.label].values.push(e.descriptor||e.address_n)})),n=[],Object.keys(r).forEach((function(e,t,i){var o=r[e];o.values.forEach((function(t,r){n.push(""),n.push(e),n.push(" "),"string"==typeof t?n.push(t):n.push((0,d.getAccountLabel)(t,o.coinInfo)),n.push("")}))})),this.postMessage((0,m.UiMessage)(g.UI.REQUEST_CONFIRMATION,{view:"export-account-info",label:"Export info for: "+n.join("")}))):this.postMessage((0,m.UiMessage)(g.UI.REQUEST_CONFIRMATION,{view:"export-account-info",label:"Export info for "+this.params[0].coinInfo.label+" account of your selection",customConfirmButton:{label:"Proceed to account selection",className:"not-empty-css"}})),e.next=6,t.promise;case 6:return o=e.sent,e.abrupt("return",o.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.noBackupConfirmation=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(g.UI.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,m.UiMessage)(g.UI.REQUEST_CONFIRMATION,{view:"no-backup"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.checkFirmwareRange=function(){var t=(0,o.default)(i.default.mark((function t(r){var n,o,a,s;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r&&1!==this.params.length){t.next=2;break}return t.abrupt("return",e.prototype.checkFirmwareRange.call(this,r));case 2:n={1:{min:"1.0.0",max:"0"},2:{min:"2.0.0",max:"0"}},o=[],a=0;case 5:if(!(a0)){t.next=16;break}throw g.ERRORS.TypedError("Method_Discovery_BundleException",JSON.stringify(o));case 16:return t.abrupt("return",null);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n,o,a,s,u,f,c,l,h,d,p=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==this.params.length||this.params[0].address_n||this.params[0].descriptor){e.next=2;break}return e.abrupt("return",this.discover(this.params[0]));case 2:t=[],r=function(e,t,r){!p.hasBundle||p.device&&p.device.getCommands().disposed||p.postMessage((0,m.UiMessage)(g.UI.BUNDLE_PROGRESS,{progress:e,response:t,error:r}))},n=0;case 5:if(!(n1?"Export multiple public keys":(0,h.getPublicKeyLabel)(this.params[0].address_n,this.params[0].coinInfo),this.postMessage((0,p.UiMessage)(d.REQUEST_CONFIRMATION,{view:"export-xpub",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n1?"Export multiple Lisk public keys":"Export Lisk public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,y.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-xpub",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n>24&255,timestamp:e.timeStamp,fee:e.fee,deadline:e.deadline,signer:t?void 0:e.signer}};t.createTx=function(e,t){var r=e,n={transaction:c(e,t),transfer:void 0,importance_transfer:void 0,aggregate_modification:void 0,provision_namespace:void 0,mosaic_creation:void 0,supply_change:void 0};switch(258!==e.type&&4100!==e.type&&4098!==e.type||(n.cosigning=258===e.type||4098===e.type,r=e.otherTrans,n.multisig=c(r)),r.type){case 257:n.transfer=function(e){var t=e.mosaics?e.mosaics.map((function(e){return{namespace:e.mosaicId.namespaceId,mosaic:e.mosaicId.name,quantity:e.quantity}})):void 0;return{recipient:e.recipient,amount:e.amount,payload:e.message?e.message.payload:void 0,public_key:e.message&&2===e.message.type?e.message.publicKey:void 0,mosaics:t}}(r);break;case 2049:n.importance_transfer=function(e){return{mode:f[e.importanceTransfer.mode],public_key:e.importanceTransfer.publicKey}}(r);break;case 4097:n.aggregate_modification=function(e){return{modifications:e.modifications?e.modifications.map((function(e){return{type:u[e.modificationType],public_key:e.cosignatoryAccount}})):void 0,relative_change:e.minCosignatories.relativeChange}}(r);break;case 8193:n.provision_namespace=function(e){return{namespace:e.newPart,parent:e.parent||void 0,sink:e.rentalFeeSink,fee:e.rentalFee}}(r);break;case 16385:n.mosaic_creation=function(e){var t=e.mosaicDefinition.levy,r={namespace:e.mosaicDefinition.id.namespaceId,mosaic:e.mosaicDefinition.id.name,levy:t&&t.type?a[t.type]:void 0,fee:t&&t.fee,levy_address:t&&t.recipient,levy_namespace:t&&t.mosaicId&&t.mosaicId.namespaceId,levy_mosaic:t&&t.mosaicId&&t.mosaicId.name,description:e.mosaicDefinition.description},n=e.mosaicDefinition.properties;return Array.isArray(n)&&n.forEach((function(e){var t=e.name,n=e.value;switch(t){case"divisibility":r.divisibility=parseInt(n);break;case"initialSupply":r.supply=parseInt(n);break;case"supplyMutable":r.mutable_supply="true"===n;break;case"transferable":r.transferable="true"===n}})),{definition:r,sink:e.creationFeeSink,fee:e.creationFee}}(r);break;case 16386:n.supply_change=function(e){return{namespace:e.mosaicId.namespaceId,mosaic:e.mosaicId.name,type:s[e.supplyType],delta:e.delta}}(r);break;default:throw i.ERRORS.TypedError("Method_InvalidParameter","Unknown transaction type")}return n}},function(e,t,r){},function(e,t,r){"use strict";(function(Buffer){var e=r(0);t.__esModule=!0,t.default=void 0;var n=e(r(1)),i=e(r(2)),o=e(r(3)),a=e(r(5)),s=r(4),u=r(12),f=r(8),c=r(33),l=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["read","write"];var n=t.payload;(0,s.validateParams)(n,[{name:"path",obligatory:!0},{name:"coin",type:"string"},{name:"message",type:"string",obligatory:!0},{name:"hex",type:"boolean"}]);var i,o=(0,u.validatePath)(n.path);n.coin?(i=(0,f.getBitcoinNetwork)(n.coin),(0,s.validateCoinPath)(i,o)):i=(0,f.getBitcoinNetwork)(o),r.info=(0,u.getLabel)("Sign #NETWORK message",i),i&&(r.firmwareRange=(0,s.getFirmwareRange)(r.name,i,r.firmwareRange));var a=n.hex?(0,c.messageToHex)(n.message):Buffer.from(n.message,"utf8").toString("hex"),l=(0,u.getScriptType)(o);return r.params={address_n:o,message:a,coin_name:i?i.name:void 0,script_type:l&&"SPENDMULTISIG"!==l?l:"SPENDADDRESS"},r}return(0,o.default)(t,e),t.prototype.run=function(){var e=(0,i.default)(n.default.mark((function e(){var t,r,i,o;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("SignMessage","MessageSignature",this.params);case 3:return r=e.sent,i=r.message,o=Buffer.from(i.signature,"hex"),i.signature=o.toString("base64"),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(a.default);t.default=l}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(11)),a=n(r(2)),s=n(r(3)),u=n(r(29)),f=n(r(5)),c=r(4),l=r(8),h=r(12),d=r(6),p=r(23),y=n(r(227)),g=n(r(228)),m=n(r(229)),b=r(78);function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function w(e){for(var t=1;t0&&a.reduce((function(e,t){return e.plus("string"==typeof t.amount?t.amount:"0")}),new u.default(0)).lte(i.dustLimit))throw d.ERRORS.TypedError("Method_InvalidParameter","Total amount is below dust limit.");if(r.params={inputs:o,outputs:n.outputs,refTxs:n.refTxs,addresses:n.account?n.account.addresses:void 0,options:{lock_time:n.locktime,timestamp:n.timestamp,version:n.version,expiry:n.expiry,overwintered:n.overwintered,version_group_id:n.versionGroupId,branch_id:n.branchId},coinInfo:i,push:"boolean"==typeof n.push&&n.push},i.hasTimestamp&&!Object.prototype.hasOwnProperty.call(n,"timestamp")){var s=new Date;r.params.options.timestamp=Math.round(s.getTime()/1e3)}return r}return(0,s.default)(t,e),t.prototype.run=function(){var e=(0,a.default)(i.default.mark((function e(){var t,r,n,o,a,s,u,f,c,l,h,d,v,_,E,S,A;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.device,r=this.params,n=[],o=t.unavailableCapabilities.replaceTransaction,r.refTxs){e.next=33;break}if(!((a=(0,b.getReferencedTransactions)(r.inputs)).length>0)){e.next=31;break}return(0,p.isBackendSupported)(r.coinInfo),e.next=9,(0,p.initBlockchain)(r.coinInfo,this.postMessage);case 9:return s=e.sent,e.next=12,s.getTransactions(a);case 12:if(u=e.sent,(0,b.enhanceTrezorInputs)(this.params.inputs,u),n=(0,b.transformReferencedTransactions)(u,r.coinInfo),f=(0,b.getOrigTransactions)(r.inputs,r.outputs),o||!(f.length>0)){e.next=31;break}return e.next=19,s.getTransactions(f);case 19:if(c=e.sent,l=r.addresses){e.next=29;break}return e.next=24,t.getCommands().getHDNode(r.inputs[0].address_n.slice(0,3),r.coinInfo);case 24:return h=e.sent,e.next=27,s.getAccountInfo({descriptor:h.xpubSegwit||h.xpub,coin:r.coinInfo.name,details:"tokens"});case 27:d=e.sent,l=d.addresses;case 29:v=(0,b.transformOrigTransactions)(c,r.coinInfo,l),n=n.concat(v);case 31:e.next=34;break;case 33:n=r.refTxs;case 34:return _=o?g.default:y.default,e.next=37,_(t.getCommands().typedCall.bind(t.getCommands()),r.inputs,r.outputs,n,r.options,r.coinInfo);case 37:return E=e.sent,e.next=40,(0,m.default)(t.getCommands().getHDNode.bind(t.getCommands()),r.inputs,r.outputs,E.serializedTx,r.coinInfo);case 40:if(!r.push){e.next=49;break}return(0,p.isBackendSupported)(r.coinInfo),e.next=44,(0,p.initBlockchain)(r.coinInfo,this.postMessage);case 44:return S=e.sent,e.next=47,S.pushTransaction(E.serializedTx);case 47:return A=e.sent,e.abrupt("return",w(w({},E),{},{txid:A}));case 49:return e.abrupt("return",E);case 50:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(f.default);t.default=_},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(5)),c=r(4),l=r(8),h=r(12),d=r(6),p=r(13);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t=r.length,s=r[n],u=s.type,f=(0,a.default)(s,["type"]),!i){e.next=9;break}return e.next=5,t(u,"StellarSignedTx",f);case 5:return c=e.sent,e.abrupt("return",c.message);case 9:return e.next=11,t(u,"StellarTxOpRequest",f);case 11:return e.abrupt("return",l(t,r,n+1));case 12:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),h=function(){var e=(0,s.default)(o.default.mark((function e(t,r,n,i){var a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(a=d(i)).address_n=r,a.network_passphrase=n,s=[],i.operations.forEach((function(e){var t=p(e);t&&s.push(t)})),e.next=7,t("StellarSignTx","StellarTxOpRequest",a);case 7:return e.abrupt("return",l(t,s,0));case 8:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}();t.stellarSignTx=h;var d=function(e){var t={};return e.timebounds&&(t.timebounds_start=e.timebounds.minTime,t.timebounds_end=e.timebounds.maxTime),e.memo&&(t.memo_type=e.memo.type,t.memo_text=e.memo.text,t.memo_id=e.memo.id,t.memo_hash=e.memo.hash),c({address_n:[],network_passphrase:"",source_account:e.source,fee:e.fee,sequence_number:e.sequence,num_operations:e.operations.length},t)},p=function(e){switch(e.type){case"createAccount":return(0,u.validateParams)(e,[{name:"destination",type:"string",obligatory:!0},{name:"startingBalance",type:"amount",obligatory:!0}]),{type:"StellarCreateAccountOp",source_account:e.source,new_account:e.destination,starting_balance:e.startingBalance};case"payment":return(0,u.validateParams)(e,[{name:"destination",type:"string",obligatory:!0},{name:"amount",type:"amount",obligatory:!0}]),{type:"StellarPaymentOp",source_account:e.source,destination_account:e.destination,asset:e.asset,amount:e.amount};case"pathPayment":return(0,u.validateParams)(e,[{name:"destAmount",type:"amount",obligatory:!0}]),{type:"StellarPathPaymentOp",source_account:e.source,send_asset:e.sendAsset,send_max:e.sendMax,destination_account:e.destination,destination_asset:e.destAsset,destination_amount:e.destAmount,paths:e.path};case"createPassiveOffer":return(0,u.validateParams)(e,[{name:"amount",type:"amount",obligatory:!0}]),{type:"StellarCreatePassiveOfferOp",source_account:e.source,buying_asset:e.buying,selling_asset:e.selling,amount:e.amount,price_n:e.price.n,price_d:e.price.d};case"manageOffer":return(0,u.validateParams)(e,[{name:"amount",type:"amount",obligatory:!0}]),{type:"StellarManageOfferOp",source_account:e.source,buying_asset:e.buying,selling_asset:e.selling,amount:e.amount,offer_id:e.offerId,price_n:e.price.n,price_d:e.price.d};case"setOptions":var t=e.signer?{signer_type:e.signer.type,signer_key:e.signer.key,signer_weight:e.signer.weight}:void 0;return c({type:"StellarSetOptionsOp",source_account:e.source,clear_flags:e.clearFlags,set_flags:e.setFlags,master_weight:e.masterWeight,low_threshold:e.lowThreshold,medium_threshold:e.medThreshold,high_threshold:e.highThreshold,home_domain:e.homeDomain,inflation_destination_account:e.inflationDest},t);case"changeTrust":return(0,u.validateParams)(e,[{name:"limit",type:"amount"}]),{type:"StellarChangeTrustOp",source_account:e.source,asset:e.line,limit:e.limit};case"allowTrust":return{type:"StellarAllowTrustOp",source_account:e.source,trusted_account:e.trustor,asset_type:e.assetType,asset_code:e.assetCode,is_authorized:e.authorize?1:0};case"accountMerge":return{type:"StellarAccountMergeOp",source_account:e.source,destination_account:e.destination};case"manageData":return{type:"StellarManageDataOp",source_account:e.source,key:e.name,value:e.value};case"bumpSequence":return{type:"StellarBumpSequenceOp",source_account:e.source,bump_to:e.bumpTo}}}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(5)),c=r(4),l=r(8),h=r(12),d=r(6),p=r(13);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function g(e){for(var t=1;t1?"Export multiple Tezos public keys":"Export Tezos public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,y.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-address",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n1?"Export multiple Eos public keys":"Export Eos public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,y.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-address",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n=0;--n){for(var i=e[n],o=0;o="a".charCodeAt(0)&&e<="z".charCodeAt(0)?e-"a".charCodeAt(0)+6:e>="1".charCodeAt(0)&&e<="5".charCodeAt(0)?e-"1".charCodeAt(0)+1:0}for(var r=new Uint8Array(8),n=63,i=0;i=0;--a)n>=0&&(r[Math.floor(n/8)]|=(o>>a&1)<="0".charCodeAt(0)&&e.charCodeAt(t)<="9".charCodeAt(0);)i=!0,r+=e[t],++t;if(!i)throw f.ERRORS.TypedError("Method_InvalidParameter","Eos serialization error. Asset must begin with a number");if("."===e[t])for(++t;t="0".charCodeAt(0)&&e.charCodeAt(t)<="9".charCodeAt(0);)r+=e[t],++n,++t;for(var o=e.substr(t).trim(),a=[255&n],s=0;s0?e.length-2*t:0;return e.substring(r,r+4096)}},w=function(){var e=(0,a.default)(o.default.mark((function e(t,r,n,i){var a,s,u,f,c,l,h,d,p,y,g,m;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n[i],s=i+1>=n.length,f=r.data_size,!a.unknown){e.next=23;break}if(c=a.unknown,l="number"==typeof f?f:0,h=v(c.data_chunk,l),d={common:a.common,unknown:{data_size:c.data_size,data_chunk:h}},p=l>0?c.data_size-l+2048:2048,y=p>=c.data_size,!s||!y){e.next=17;break}return e.next=13,t("EosTxActionAck","EosSignedTx",d);case 13:return g=e.sent,e.abrupt("return",g.message);case 17:return e.next=19,t("EosTxActionAck","EosTxActionRequest",d);case 19:u=e.sent,y&&i++;case 21:e.next=32;break;case 23:if(!s){e.next=28;break}return e.next=26,t("EosTxActionAck","EosSignedTx",a);case 26:return m=e.sent,e.abrupt("return",m.message);case 28:return e.next=30,t("EosTxActionAck","EosTxActionRequest",a);case 30:u=e.sent,i++;case 32:return e.abrupt("return",w(t,u.message,n,i));case 33:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),_=function(){var e=(0,a.default)(o.default.mark((function e(t,r,n,i,a){var s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t("EosSignTx","EosTxActionRequest",{address_n:r,chain_id:n,header:i,num_actions:a.length});case 2:return s=e.sent,e.abrupt("return",w(t,s.message,a,0));case 4:case"end":return e.stop()}}),e)})));return function(t,r,n,i,o){return e.apply(this,arguments)}}();t.signTx=_},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(17)),u=i(r(3)),f=i(r(11)),c=i(r(5)),l=r(4),h=r(8),d=r(12),p=n(r(20)),y=r(13);function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t1?"Export multiple Binance public keys":"Export Binance public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,y.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-address",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n=r.length)){e.next=7;break}return e.next=5,t(s,"BinanceSignedTx",u);case 5:return f=e.sent,e.abrupt("return",f.message);case 7:return e.next=9,t(s,"BinanceTxRequest",u);case 9:return n++,e.abrupt("return",h(t,r,n));case 11:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();t.validate=function(e){(0,f.validateParams)(e,[{name:"chain_id",type:"string",obligatory:!0},{name:"account_number",type:"number"},{name:"memo",type:"string"},{name:"sequence",type:"number"},{name:"source",type:"number"},{name:"message",type:"object"}]);var t={chain_id:e.chain_id,account_number:e.account_number||0,memo:e.memo,sequence:e.sequence||0,source:e.source||0,messages:[]},r=e.transfer,n=e.placeOrder,i=e.cancelOrder;if(r&&((0,f.validateParams)(r,[{name:"inputs",type:"array",obligatory:!0},{name:"outputs",type:"array",obligatory:!0}]),t.messages.push(l(l({},r),{},{type:"BinanceTransferMsg"}))),n&&((0,f.validateParams)(n,[{name:"id",type:"string"},{name:"ordertype",type:"number"},{name:"price",type:"number"},{name:"quantity",type:"number"},{name:"sender",type:"string"},{name:"side",type:"number"}]),t.messages.push(l(l({},n),{},{type:"BinanceOrderMsg"}))),i&&((0,f.validateParams)(e.cancelOrder,[{name:"refid",type:"string",obligatory:!0},{name:"sender",type:"string",obligatory:!0},{name:"symbol",type:"string",obligatory:!0}]),t.messages.push(l(l({},i),{},{type:"BinanceCancelMsg"}))),t.messages.length<1)throw u.ERRORS.TypedError("Method_InvalidParameter","Transaction does not have any message");return t};var d=function(){var e=(0,s.default)(o.default.mark((function e(t,r,n){var i,a,s,u,f,c,l;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.account_number,a=n.chain_id,s=n.memo,u=n.sequence,f=n.source,c=n.messages,l=c.length,e.next=4,t("BinanceSignTx","BinanceTxRequest",{address_n:r,msg_count:l,account_number:i,chain_id:a,memo:s,sequence:u,source:f});case 4:return e.abrupt("return",h(t,c,0));case 5:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();t.signTx=d},function(e,t,r){"use strict";(function(Buffer){var e=r(0);t.__esModule=!0,t.default=void 0;var n=e(r(1)),i=e(r(2)),o=e(r(3)),a=e(r(5)),s=r(4),u=r(8),f=r(12),c=r(33),l=r(6),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["read","write"],r.info="Verify message";var n=t.payload;(0,s.validateParams)(n,[{name:"address",type:"string",obligatory:!0},{name:"signature",type:"string",obligatory:!0},{name:"message",type:"string",obligatory:!0},{name:"coin",type:"string",obligatory:!0},{name:"hex",type:"boolean"}]);var i=(0,u.getBitcoinNetwork)(n.coin);if(!i)throw l.ERRORS.TypedError("Method_UnknownCoin");r.firmwareRange=(0,s.getFirmwareRange)(r.name,i,r.firmwareRange),r.info=(0,f.getLabel)("Verify #NETWORK message",i);var o=n.hex?(0,c.messageToHex)(n.message):Buffer.from(n.message,"utf8").toString("hex"),a=Buffer.from(n.signature,"base64").toString("hex");return r.params={address:n.address,signature:a,message:o,coin_name:i.name},r}return(0,o.default)(t,e),t.prototype.run=function(){var e=(0,i.default)(n.default.mark((function e(){var t,r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("VerifyMessage","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(a.default);t.default=h}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(13),l=r(4),h=function(e){function t(t){var r;return(r=e.call(this,t)||this).allowDeviceMode=[f.INITIALIZE,f.SEEDLESS],r.useDeviceState=!1,r.requiredPermissions=["management"],r.firmwareRange=(0,l.getFirmwareRange)(r.name,null,r.firmwareRange),r.info="Wipe device",r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.confirmed){e.next=2;break}return e.abrupt("return",!0);case 2:return e.next=4,this.getPopupPromise().promise;case 4:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,c.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"wipe",label:"Wipe "+this.device.toMessageObject().label},label:"Are you sure you want to wipe your device?"})),e.next=8,t.promise;case 8:return r=e.sent,this.confirmed=r.payload,e.abrupt("return",this.confirmed);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("WipeDevice","Success");case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=r(4),c=n(r(20)),l=r(13),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1;var n=t.payload;return(0,f.validateParams)(n,[{name:"flags",type:"number",obligatory:!0}]),r.params={flags:n.flags},r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(c.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(c.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you really want to apply flags?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("ApplyFlags","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(4),l=r(13),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1;var n=t.payload;return(0,c.validateParams)(n,[{name:"language",type:"string"},{name:"label",type:"string"},{name:"use_passphrase",type:"boolean"},{name:"homescreen",type:"string"},{name:"passphrase_source",type:"number"},{name:"passphrase_always_on_device",type:"boolean"},{name:"auto_lock_delay_ms",type:"number"},{name:"display_rotation",type:"number"},{name:"safety_checks",type:"number"}]),r.params={language:n.language,label:n.label,use_passphrase:n.use_passphrase,homescreen:n.homescreen,passphrase_source:n.passphrase_source,passphrase_always_on_device:n.passphrase_always_on_device,auto_lock_delay_ms:n.auto_lock_delay_ms,display_rotation:n.display_rotation,safety_checks:n.safety_checks},r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you really want to change device settings?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("ApplySettings","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(13),l=function(e){function t(t){var r;return(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1,r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,c.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you want to initiate backup procedure?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("BackupDevice","Success");case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1;var n=t.payload;return(0,u.validateParams)(n,[{name:"remove",type:"boolean"}]),r.params={remove:n.remove},r}return(0,a.default)(t,e),t.prototype.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("ChangePin","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=f},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=r(129),u=n(r(5)),f=r(6),c=r(559),l=r(13),h=r(4),d=r(81),p=function(e){function t(t){var r;(r=e.call(this,t)||this).useEmptyPassphrase=!0,r.requiredPermissions=["management"],r.allowDeviceMode=[f.UI.BOOTLOADER,f.UI.INITIALIZE],r.requireDeviceMode=[f.UI.BOOTLOADER],r.useDeviceState=!1,r.skipFirmwareCheck=!0;var n=t.payload;return(0,h.validateParams)(n,[{name:"version",type:"array"},{name:"btcOnly",type:"boolean"},{name:"baseUrl",type:"string"},{name:"binary",type:"buffer"},{name:"intermediary",type:"boolean"}]),r.params={version:n.version,btcOnly:n.btcOnly,baseUrl:n.baseUrl||"https://data.trezor.io",binary:n.binary,intermediary:n.intermediary},r}(0,a.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.UI.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(f.UI.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"wipe",label:"Proceed"},label:"Do you want to update firmware? Never do this without your recovery card."})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.device,e.prev=1,!this.params.binary){e.next=6;break}r=this.params.binary,e.next=10;break;case 6:return e.next=8,(0,s.getBinary)({features:t.features,releases:(0,d.getReleases)(t.features.major_version),version:this.params.version,btcOnly:this.params.btcOnly,baseUrl:this.params.baseUrl,intermediary:this.params.intermediary});case 8:n=e.sent,r=n.binary;case 10:e.next=15;break;case 12:throw e.prev=12,e.t0=e.catch(1),f.ERRORS.TypedError("Method_FirmwareUpdate_DownloadFailed","Failed to download firmware binary");case 15:return e.abrupt("return",(0,c.uploadFirmware)(this.device.getCommands().typedCall.bind(this.device.getCommands()),this.postMessage,t,{payload:r}));case 16:case"end":return e.stop()}}),e,this,[[1,12]])})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=p},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.uploadFirmware=void 0;var o=i(r(1)),a=i(r(2)),s=r(13),u=(i(r(58)),n(r(20))),f=n(r(79)),c=function(e){e.features.firmware_present&&e.emit(f.BUTTON,e,"ButtonRequest_FirmwareUpdate")},l=function(e,t,r){r((0,s.UiMessage)(u.FIRMWARE_PROGRESS,{device:e.toMessageObject(),progress:t}))},h=function(){var e=(0,a.default)(o.default.mark((function e(t,r,n,i){var a,s,u,f,h,d,p,y;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=i.payload,s={},1!==n.features.major_version){e.next=13;break}return c(n),e.next=6,t("FirmwareErase","Success",{});case 6:return l(n,0,r),e.next=9,t("FirmwareUpload","Success",{payload:a});case 9:return u=e.sent,f=u.message,l(n,100,r),e.abrupt("return",f);case 13:if(2!==n.features.major_version){e.next=31;break}return c(n),h=a.byteLength,e.next=18,t("FirmwareErase","FirmwareRequest",{length:h});case 18:s=e.sent;case 19:if("Success"===s.type){e.next=29;break}return d=s.message.offset,p=s.message.offset+s.message.length,y=a.slice(d,p),d>0&&l(n,Math.round(d/h*100),r),e.next=26,t("FirmwareUpload","FirmwareRequest|Success",{payload:y});case 26:s=e.sent,e.next=19;break;case 29:return l(n,100,r),e.abrupt("return",s.message);case 31:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}();t.uploadFirmware=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(4),l=r(13),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useEmptyPassphrase=!0;var n=t.payload;return(0,c.validateParams)(n,[{name:"word_count",type:"number"},{name:"passphrase_protection",type:"boolean"},{name:"pin_protection",type:"boolean"},{name:"language",type:"string"},{name:"label",type:"string"},{name:"enforce_wordlist",type:"boolean"},{name:"type",type:"number"},{name:"u2f_counter",type:"number"},{name:"dry_run",type:"boolean"}]),r.params={word_count:n.word_count,passphrase_protection:n.passphrase_protection,pin_protection:n.pin_protection,language:n.language,label:n.label,enforce_wordlist:n.enforce_wordlist,type:n.type,u2f_counter:n.u2f_counter,dry_run:n.dry_run},r.allowDeviceMode=[].concat(r.allowDeviceMode,[f.INITIALIZE]),r.useDeviceState=!1,r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you want to recover device from seed?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("RecoveryDevice","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=r(6),c=r(8),l=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=[],r.useDevice=!1,r.useUi=!1;var n=t.payload;(0,u.validateParams)(n,[{name:"coin",type:"string",obligatory:!0}]);var i=(0,c.getCoinInfo)(n.coin);if(!i)throw f.ERRORS.TypedError("Method_UnknownCoin");return r.params={coinInfo:i},r}return(0,a.default)(t,e),t.prototype.run=function(){var e=(0,o.default)(i.default.mark((function e(){return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",this.params.coinInfo);case 1:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(563)),s=n(r(11)),u=(0,r(49).initLog)("InteractionTimeout"),f=function(){function e(e){(0,s.default)(this,"timeout",null),(0,s.default)(this,"seconds",0),e&&(this.seconds=e)}var t=e.prototype;return t.start=function(e,t){var r=t||this.seconds;r<1||(this.stop(),u.log("starting interaction timeout for "+r+" seconds"),this.timeout=setTimeout((0,o.default)(i.default.mark((function t(){return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:u.log("interaction timed out"),e();case 2:case"end":return t.stop()}}),t)}))),1e3*r))},t.stop=function(){this.timeout&&(u.log("clearing interaction timeout"),clearTimeout(this.timeout))},(0,a.default)(e,[{key:"seconds",get:function(){return this.seconds},set:function(e){this.seconds=e}}]),e}();t.default=f},function(e,t){function r(e,t){for(var r=0;rparseInt(r.version,10)));return{name:r.name+": "+r.version+"; "+n.name+": "+n.version+";",osname:n.name,mobile:i,supported:a,outdated:s}};t.suggestBridgeInstaller=function(){var e=(0,a.getBridgeInfo)();if(!e.packages.find((function(e){return e.preferred}))){var t=function(){if(navigator&&navigator.userAgent){var e=navigator.userAgent;switch(o.default.getParser(e).getOS().name.toLowerCase()){case"linux":return""+(e.match(/CentOS|Fedora|Mandriva|Mageia|Red Hat|Scientific|SUSE/)?"rpm":"deb")+(e.match(/Linux i[3456]86/)?"32":"64");case"macos":return"mac";case"windows":return"win"+(e.match(/(Win64|WOW64)/)?"64":"32")}}}();t&&(e.packages=e.packages.map((function(e){return u(u({},e),{},{preferred:e.platform.indexOf(t)>=0})})))}return e}},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(r),a=Math.max(i,o),s=0,u=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(s=a-Math.min(i,o)),a-=1;a>=s;){if(u[0][a]>u[1][a])return 1;if(u[0][a]===u[1][a]){if(a===s)return 0;a-=1}else if(u[0][a]1?i-1:0),a=1;a0){var a=Object.keys(r),u=s.default.find(a,(function(e){return t.isOS(e)}));if(u){var f=this.satisfies(r[u]);if(void 0!==f)return f}var c=s.default.find(a,(function(e){return t.isPlatform(e)}));if(c){var l=this.satisfies(r[c]);if(void 0!==l)return l}}if(o>0){var h=Object.keys(i),d=s.default.find(h,(function(e){return t.isBrowser(e,!0)}));if(void 0!==d)return this.compareVersion(i[d])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=s.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(s.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=f,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default},93:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:o.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:o.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:o.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default}})}]); \ No newline at end of file + */var n=r(118).validate,i={q:0,p:1,z:2,r:3,y:4,9:5,x:6,8:7,g:8,f:9,2:10,t:11,v:12,d:13,w:14,0:15,s:16,3:17,j:18,n:19,5:20,4:21,k:22,h:23,c:24,e:25,6:26,m:27,u:28,a:29,7:30,l:31};e.exports={encode:function(e){n(e instanceof Uint8Array,"Invalid data: "+e+".");for(var t="",r=0;r0?Math.floor(e):Math.ceil(e)}function p(e,r){var n,i,o=e.length,a=r.length,s=new Array(o),u=0,f=t;for(i=0;i=f?1:0,s[i]=n-u*f;for(;i0&&s.push(u),s}function g(e,t){return e.length>=t.length?p(e,t):p(t,e)}function y(e,r){var n,i,o=e.length,a=new Array(o),s=t;for(i=0;i0;)a[i++]=r%s,r=Math.floor(r/s);return a}function m(e,t){var r,n,i=e.length,o=t.length,a=new Array(i),s=0;for(r=0;r0;)a[i++]=u%s,u=Math.floor(u/s);return a}function _(e,t){for(var r=[];t-- >0;)r.push(0);return r.concat(e)}function E(e,r,n){return new BigInteger(e=0;--r)i=(o=1e7*i+e[r])-(n=d(o/t))*t,s[r]=0|n;return[s,0|i]}function I(e,r){var n,i,o=K(r),u=e.value,p=o.value;if(0===p)throw new Error("Cannot divide by zero");if(e.isSmall)return o.isSmall?[new s(d(u/p)),new s(u%p)]:[a[0],e];if(o.isSmall){if(1===p)return[e,a[0]];if(-1==p)return[e.negate(),a[0]];var g=Math.abs(p);if(g=0;i--){for(n=p-1,b[i+d]!==y&&(n=Math.floor((b[i+d]*p+b[i+d-1])/y)),o=0,a=0,u=v.length,s=0;su&&(i=1e7*(i+1)),r=Math.ceil(i/o);do{if(O(a=w(t,r),h)<=0)break;r--}while(r);f.push(r),h=m(h,a)}return f.reverse(),[c(f),c(h)]}(u,p))[0];var v=e.sign!==o.sign,_=n[1],E=e.sign;return"number"==typeof i?(v&&(i=-i),i=new s(i)):i=new BigInteger(i,v),"number"==typeof _?(E&&(_=-_),_=new s(_)):_=new BigInteger(_,E),[i,_]}function O(e,t){if(e.length!==t.length)return e.length>t.length?1:-1;for(var r=e.length-1;r>=0;r--)if(e[r]!==t[r])return e[r]>t[r]?1:-1;return 0}function P(e){var t=e.abs();return!t.isUnit()&&(!!(t.equals(2)||t.equals(3)||t.equals(5))||!(t.isEven()||t.isDivisibleBy(3)||t.isDivisibleBy(5))&&(!!t.lesser(49)||void 0))}function M(e,t){for(var r,i,o,s=e.prev(),u=s,f=0;u.isEven();)u=u.divide(2),f++;e:for(i=0;i=0?n=m(e,t):(n=m(t,e),r=!r),"number"==typeof(n=c(n))?(r&&(n=-n),new s(n)):new BigInteger(n,r)}(r,n,this.sign)},BigInteger.prototype.minus=BigInteger.prototype.subtract,s.prototype.subtract=function(e){var t=K(e),r=this.value;if(r<0!==t.sign)return this.add(t.negate());var n=t.value;return t.isSmall?new s(r-n):b(n,Math.abs(r),r>=0)},s.prototype.minus=s.prototype.subtract,BigInteger.prototype.negate=function(){return new BigInteger(this.value,!this.sign)},s.prototype.negate=function(){var e=this.sign,t=new s(-this.value);return t.sign=!e,t},BigInteger.prototype.abs=function(){return new BigInteger(this.value,!1)},s.prototype.abs=function(){return new s(Math.abs(this.value))},BigInteger.prototype.multiply=function(e){var r,n,i,o=K(e),s=this.value,u=o.value,c=this.sign!==o.sign;if(o.isSmall){if(0===u)return a[0];if(1===u)return this;if(-1===u)return this.negate();if((r=Math.abs(u))0?function e(t,r){var n=Math.max(t.length,r.length);if(n<=30)return v(t,r);n=Math.ceil(n/2);var i=t.slice(n),o=t.slice(0,n),a=r.slice(n),s=r.slice(0,n),u=e(o,s),f=e(i,a),c=e(g(o,i),g(s,a)),h=g(g(u,_(m(m(c,u),f),n)),_(f,2*n));return l(h),h}(s,u):v(s,u),c)},BigInteger.prototype.times=BigInteger.prototype.multiply,s.prototype._multiplyBySmall=function(e){return u(e.value*this.value)?new s(e.value*this.value):E(Math.abs(e.value),f(Math.abs(this.value)),this.sign!==e.sign)},BigInteger.prototype._multiplyBySmall=function(e){return 0===e.value?a[0]:1===e.value?this:-1===e.value?this.negate():E(Math.abs(e.value),this.value,this.sign!==e.sign)},s.prototype.multiply=function(e){return K(e)._multiplyBySmall(this)},s.prototype.times=s.prototype.multiply,BigInteger.prototype.square=function(){return new BigInteger(S(this.value),!1)},s.prototype.square=function(){var e=this.value*this.value;return u(e)?new s(e):new BigInteger(S(f(Math.abs(this.value))),!1)},BigInteger.prototype.divmod=function(e){var t=I(this,e);return{quotient:t[0],remainder:t[1]}},s.prototype.divmod=BigInteger.prototype.divmod,BigInteger.prototype.divide=function(e){return I(this,e)[0]},s.prototype.over=s.prototype.divide=BigInteger.prototype.over=BigInteger.prototype.divide,BigInteger.prototype.mod=function(e){return I(this,e)[1]},s.prototype.remainder=s.prototype.mod=BigInteger.prototype.remainder=BigInteger.prototype.mod,BigInteger.prototype.pow=function(e){var t,r,n,i=K(e),o=this.value,f=i.value;if(0===f)return a[1];if(0===o)return a[0];if(1===o)return a[1];if(-1===o)return i.isEven()?a[1]:a[-1];if(i.sign)return a[0];if(!i.isSmall)throw new Error("The exponent "+i.toString()+" is too large.");if(this.isSmall&&u(t=Math.pow(o,f)))return new s(d(t));for(r=this,n=a[1];!0&f&&(n=n.times(r),--f),0!==f;)f/=2,r=r.square();return n},s.prototype.pow=BigInteger.prototype.pow,BigInteger.prototype.modPow=function(e,t){if(e=K(e),(t=K(t)).isZero())throw new Error("Cannot take modPow with modulus 0");for(var r=a[1],n=this.mod(t);e.isPositive();){if(n.isZero())return a[0];e.isOdd()&&(r=r.multiply(n).mod(t)),e=e.divide(2),n=n.square().mod(t)}return r},s.prototype.modPow=BigInteger.prototype.modPow,BigInteger.prototype.compareAbs=function(e){var t=K(e),r=this.value,n=t.value;return t.isSmall?1:O(r,n)},s.prototype.compareAbs=function(e){var t=K(e),r=Math.abs(this.value),n=t.value;return t.isSmall?r===(n=Math.abs(n))?0:r>n?1:-1:-1},BigInteger.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=K(e),r=this.value,n=t.value;return this.sign!==t.sign?t.sign?1:-1:t.isSmall?this.sign?-1:1:O(r,n)*(this.sign?-1:1)},BigInteger.prototype.compareTo=BigInteger.prototype.compare,s.prototype.compare=function(e){if(e===1/0)return-1;if(e===-1/0)return 1;var t=K(e),r=this.value,n=t.value;return t.isSmall?r==n?0:r>n?1:-1:r<0!==t.sign?r<0?-1:1:r<0?1:-1},s.prototype.compareTo=s.prototype.compare,BigInteger.prototype.equals=function(e){return 0===this.compare(e)},s.prototype.eq=s.prototype.equals=BigInteger.prototype.eq=BigInteger.prototype.equals,BigInteger.prototype.notEquals=function(e){return 0!==this.compare(e)},s.prototype.neq=s.prototype.notEquals=BigInteger.prototype.neq=BigInteger.prototype.notEquals,BigInteger.prototype.greater=function(e){return this.compare(e)>0},s.prototype.gt=s.prototype.greater=BigInteger.prototype.gt=BigInteger.prototype.greater,BigInteger.prototype.lesser=function(e){return this.compare(e)<0},s.prototype.lt=s.prototype.lesser=BigInteger.prototype.lt=BigInteger.prototype.lesser,BigInteger.prototype.greaterOrEquals=function(e){return this.compare(e)>=0},s.prototype.geq=s.prototype.greaterOrEquals=BigInteger.prototype.geq=BigInteger.prototype.greaterOrEquals,BigInteger.prototype.lesserOrEquals=function(e){return this.compare(e)<=0},s.prototype.leq=s.prototype.lesserOrEquals=BigInteger.prototype.leq=BigInteger.prototype.lesserOrEquals,BigInteger.prototype.isEven=function(){return 0==(1&this.value[0])},s.prototype.isEven=function(){return 0==(1&this.value)},BigInteger.prototype.isOdd=function(){return 1==(1&this.value[0])},s.prototype.isOdd=function(){return 1==(1&this.value)},BigInteger.prototype.isPositive=function(){return!this.sign},s.prototype.isPositive=function(){return this.value>0},BigInteger.prototype.isNegative=function(){return this.sign},s.prototype.isNegative=function(){return this.value<0},BigInteger.prototype.isUnit=function(){return!1},s.prototype.isUnit=function(){return 1===Math.abs(this.value)},BigInteger.prototype.isZero=function(){return!1},s.prototype.isZero=function(){return 0===this.value},BigInteger.prototype.isDivisibleBy=function(e){var t=K(e),r=t.value;return 0!==r&&(1===r||(2===r?this.isEven():this.mod(t).equals(a[0])))},s.prototype.isDivisibleBy=BigInteger.prototype.isDivisibleBy,BigInteger.prototype.isPrime=function(e){var t=P(this);if(void 0!==t)return t;var r=this.abs(),i=r.bitLength();if(i<=64)return M(r,[2,325,9375,28178,450775,9780504,1795265022]);for(var o=Math.log(2)*i,a=Math.ceil(!0===e?2*Math.pow(o,2):o),s=[],u=0;u-r?new s(e-1):new BigInteger(i,!0)};for(var k=[1];2*k[k.length-1]<=t;)k.push(2*k[k.length-1]);var T=k.length,x=k[T-1];function R(e){return("number"==typeof e||"string"==typeof e)&&+Math.abs(e)<=t||e instanceof BigInteger&&e.value.length<=1}function C(e,t,r){t=K(t);for(var i=e.isNegative(),o=t.isNegative(),a=i?e.not():e,s=o?t.not():t,u=0,f=0,c=null,l=null,h=[];!a.isZero()||!s.isZero();)u=(c=I(a,x))[1].toJSNumber(),i&&(u=x-1-u),f=(l=I(s,x))[1].toJSNumber(),o&&(f=x-1-f),a=c[0],s=l[0],h.push(r(u,f));for(var d=0!==r(i?1:0,o?1:0)?n(-1):n(0),p=h.length-1;p>=0;p-=1)d=d.multiply(x).add(n(h[p]));return d}BigInteger.prototype.shiftLeft=function(e){if(!R(e))throw new Error(String(e)+" is too large for shifting.");if((e=+e)<0)return this.shiftRight(-e);var t=this;if(t.isZero())return t;for(;e>=T;)t=t.multiply(x),e-=T-1;return t.multiply(k[e])},s.prototype.shiftLeft=BigInteger.prototype.shiftLeft,BigInteger.prototype.shiftRight=function(e){var t;if(!R(e))throw new Error(String(e)+" is too large for shifting.");if((e=+e)<0)return this.shiftLeft(-e);for(var r=this;e>=T;){if(r.isZero()||r.isNegative()&&r.isUnit())return r;r=(t=I(r,x))[1].isNegative()?t[0].prev():t[0],e-=T-1}return(t=I(r,k[e]))[1].isNegative()?t[0].prev():t[0]},s.prototype.shiftRight=BigInteger.prototype.shiftRight,BigInteger.prototype.not=function(){return this.negate().prev()},s.prototype.not=BigInteger.prototype.not,BigInteger.prototype.and=function(e){return C(this,e,(function(e,t){return e&t}))},s.prototype.and=BigInteger.prototype.and,BigInteger.prototype.or=function(e){return C(this,e,(function(e,t){return e|t}))},s.prototype.or=BigInteger.prototype.or,BigInteger.prototype.xor=function(e){return C(this,e,(function(e,t){return e^t}))},s.prototype.xor=BigInteger.prototype.xor;function N(e){var r=e.value,n="number"==typeof r?r|1<<30:r[0]+r[1]*t|1073758208;return n&-n}function B(e,t){return e=K(e),t=K(t),e.greater(t)?e:t}function D(e,t){return e=K(e),t=K(t),e.lesser(t)?e:t}function U(e,t){if(e=K(e).abs(),t=K(t).abs(),e.equals(t))return e;if(e.isZero())return t;if(t.isZero())return e;for(var r,n,i=a[1];e.isEven()&&t.isEven();)r=Math.min(N(e),N(t)),e=e.divide(r),t=t.divide(r),i=i.multiply(r);for(;e.isEven();)e=e.divide(N(e));do{for(;t.isEven();)t=t.divide(N(t));e.greater(t)&&(n=t,t=e,e=n),t=t.subtract(e)}while(!t.isZero());return i.isUnit()?e:e.multiply(i)}BigInteger.prototype.bitLength=function(){var e=this;return e.compareTo(n(0))<0&&(e=e.negate().subtract(n(1))),0===e.compareTo(n(0))?n(0):n(function e(t,r){if(r.compareTo(t)<=0){var i=e(t,r.square(r)),o=i.p,a=i.e,s=o.multiply(r);return s.compareTo(t)<=0?{p:s,e:2*a+1}:{p:o,e:2*a}}return{p:n(1),e:0}}(e,n(2)).e).add(n(1))},s.prototype.bitLength=BigInteger.prototype.bitLength;var j=function(e,t){for(var r=e.length,n=Math.abs(t),i=0;i=n){if("1"===c&&1===n)continue;throw new Error(c+" is not a valid digit in base "+t+".")}if(c.charCodeAt(0)-87>=n)throw new Error(c+" is not a valid digit in base "+t+".")}}if(2<=t&&t<=36&&r<=o/Math.log(t)){var a=parseInt(e,t);if(isNaN(a))throw new Error(c+" is not a valid digit in base "+t+".");return new s(parseInt(e,t))}t=K(t);var u=[],f="-"===e[0];for(i=f?1:0;i"!==e[i]);u.push(K(e.slice(h+1,i)))}}return L(u,t,f)};function L(e,t,r){var n,i=a[0],o=a[1];for(n=e.length-1;n>=0;n--)i=i.add(e[n].times(o)),o=o.times(t);return r?i.negate():i}function F(e){return e<=35?"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e):"<"+e+">"}function H(e,t){if((t=n(t)).isZero()){if(e.isZero())return{value:[0],isNegative:!1};throw new Error("Cannot convert nonzero numbers to base 0.")}if(t.equals(-1)){if(e.isZero())return{value:[0],isNegative:!1};if(e.isNegative())return{value:[].concat.apply([],Array.apply(null,Array(-e)).map(Array.prototype.valueOf,[1,0])),isNegative:!1};var r=Array.apply(null,Array(+e-1)).map(Array.prototype.valueOf,[0,1]);return r.unshift([1]),{value:[].concat.apply([],r),isNegative:!1}}var i=!1;if(e.isNegative()&&t.isPositive()&&(i=!0,e=e.abs()),t.equals(1))return e.isZero()?{value:[0],isNegative:!1}:{value:Array.apply(null,Array(+e)).map(Number.prototype.valueOf,1),isNegative:i};for(var o,a=[],s=e;s.isNegative()||s.compareAbs(t)>=0;){o=s.divmod(t),s=o.quotient;var u=o.remainder;u.isNegative()&&(u=t.minus(u).abs(),s=s.next()),a.push(u.toJSNumber())}return a.push(s.toJSNumber()),{value:a.reverse(),isNegative:i}}function q(e,t){var r=H(e,t);return(r.isNegative?"-":"")+r.value.map(F).join("")}function V(e){if(u(+e)){var t=+e;if(t===d(t))return new s(t);throw new Error("Invalid integer: "+e)}var r="-"===e[0];r&&(e=e.slice(1));var n=e.split(/e/i);if(n.length>2)throw new Error("Invalid integer: "+n.join("e"));if(2===n.length){var i=n[1];if("+"===i[0]&&(i=i.slice(1)),(i=+i)!==d(i)||!u(i))throw new Error("Invalid integer: "+i+" is not a valid exponent.");var o=n[0],a=o.indexOf(".");if(a>=0&&(i-=o.length-a-1,o=o.slice(0,a)+o.slice(a+1)),i<0)throw new Error("Cannot include negative exponent part for integers");e=o+=new Array(i+1).join("0")}if(!/^([0-9][0-9]*)$/.test(e))throw new Error("Invalid integer: "+e);for(var f=[],c=e.length,h=c-7;c>0;)f.push(+e.slice(h,c)),(h-=7)<0&&(h=0),c-=7;return l(f),new BigInteger(f,r)}function K(e){return"number"==typeof e?function(e){if(u(e)){if(e!==d(e))throw new Error(e+" is not an integer.");return new s(e)}return V(e.toString())}(e):"string"==typeof e?V(e):e}BigInteger.prototype.toArray=function(e){return H(this,e)},s.prototype.toArray=function(e){return H(this,e)},BigInteger.prototype.toString=function(e){if(void 0===e&&(e=10),10!==e)return q(this,e);for(var t,r=this.value,n=r.length,i=String(r[--n]);--n>=0;)t=String(r[n]),i+="0000000".slice(t.length)+t;return(this.sign?"-":"")+i},s.prototype.toString=function(e){return void 0===e&&(e=10),10!=e?q(this,e):String(this.value)},BigInteger.prototype.toJSON=s.prototype.toJSON=function(){return this.toString()},BigInteger.prototype.valueOf=function(){return parseInt(this.toString(),10)},BigInteger.prototype.toJSNumber=BigInteger.prototype.valueOf,s.prototype.valueOf=function(){return this.value},s.prototype.toJSNumber=s.prototype.valueOf;for(var z=0;z<1e3;z++)a[z]=new s(z),z>0&&(a[-z]=new s(-z));return a.one=a[1],a.zero=a[0],a.minusOne=a[-1],a.max=B,a.min=D,a.gcd=U,a.lcm=function(e,t){return e=K(e).abs(),t=K(t).abs(),e.divide(U(e,t)).multiply(t)},a.isInstance=function(e){return e instanceof BigInteger||e instanceof s},a.randBetween=function(e,r){var n=D(e=K(e),r=K(r)),i=B(e,r).subtract(n).add(1);if(i.isSmall)return n.add(Math.floor(Math.random()*i));for(var o=[],a=!0,u=i.value.length-1;u>=0;u--){var f=a?i.value[u]:t,l=d(Math.random()*f);o.unshift(l),l>t==0,"Invalid value: "+h+"."),f=f<=r;)c-=r,s[u]=f>>c&a,++u}return i?n(c0&&(s[u]=f<=this.concurrency))if(0!==this.jobs.length){var t=this,r=this.jobs.shift(),n=!0,i=this.session,o=null,a=!1,f=null,c=r.hasOwnProperty("timeout")?r.timeout:this.timeout;c&&(o=setTimeout((function(){a=!0,t.listeners("timeout").length>0?t.emit("timeout",h,r):h()}),c),this.timers[o]=o),this.results&&(f=this.results.length,this.results[f]=null),this.pending++,t.emit("start",r);var l=r(h);l&&l.then&&"function"==typeof l.then&&l.then((function(e){return h(null,e)})).catch((function(e){return h(e||!0)})),this.running&&this.jobs.length>0&&this.start()}else 0===this.pending&&u.call(this);function h(e,s){n&&t.session===i&&(n=!1,t.pending--,null!==o&&(delete t.timers[o],clearTimeout(o)),e?t.emit("error",e,r):!1===a&&(null!==f&&(t.results[f]=Array.prototype.slice.call(arguments,1)),t.emit("success",s,r)),t.session===i&&(0===t.pending&&0===t.jobs.length?u.call(t):t.running&&t.start()))}},o.prototype.stop=function(){this.running=!1},o.prototype.end=function(e){a.call(this),this.jobs.length=0,this.pending=0,u.call(this,e)}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.buildTx=function(e){var t=e.utxos,r=e.outputs,n=e.height,u=e.feeRate,f=e.segwit,c=e.inputAmounts,l=e.basePath,h=e.network,d=e.changeId,p=e.changeAddress,g=e.dustThreshold,y=e.baseFee,m=e.floorBaseFee,b=e.dustOutputFee,v=e.skipUtxoSelection;if(0===r.length)return o.empty;if(0===t.length)return{type:"error",error:"NOT-ENOUGH-FUNDS"};var w={exists:!1,id:0};try{w=i.getMax(r)}catch(e){return{type:"error",error:e.message}}var _=i.splitByCompleteness(r),E={type:"false"};try{E=s.coinselect(t,r,n,u,f,w.exists,w.id,g,h,y,m,b,v)}catch(e){return{type:"error",error:e.message}}if("false"===E.type)return{type:"error",error:"NOT-ENOUGH-FUNDS"};if(_.incomplete.length>0)return o.getNonfinalResult(E);var S=a.createTransaction(t,E.result.inputs,_.complete,E.result.outputs,f,c,l,d,p,h);return o.getFinalResult(E,S)},Object.defineProperty(t,"BuildTxRequest",{enumerable:!0,get:function(){return i.Request}}),Object.defineProperty(t,"BuildTxOutputRequest",{enumerable:!0,get:function(){return i.OutputRequest}}),Object.defineProperty(t,"BuildTxEmptyResult",{enumerable:!0,get:function(){return o.empty}}),Object.defineProperty(t,"BuildTxResult",{enumerable:!0,get:function(){return o.Result}}),Object.defineProperty(t,"BuildTxTransaction",{enumerable:!0,get:function(){return a.Transaction}}),Object.defineProperty(t,"BuildTxOutput",{enumerable:!0,get:function(){return a.Output}}),Object.defineProperty(t,"BuildTxInput",{enumerable:!0,get:function(){return a.Input}});var i=f(r(119)),o=f(r(494)),a=f(r(221)),s=f(r(120));function u(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return u=function(){return e},e}function f(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=u();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,t&&t.set(e,r),r}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.getNonfinalResult=function(e){var t=e.result,r=t.max,n=t.fee,i=t.feePerByte,o=t.bytes,a=t.totalSpent;return{type:"nonfinal",fee:n,feePerByte:i,bytes:o,max:r,totalSpent:a}},t.getFinalResult=function(e,t){var r=e.result,n=r.max,i=r.fee,o=r.feePerByte,a=r.bytes,s=r.totalSpent;return{type:"final",fee:i,feePerByte:o,bytes:a,transaction:t,max:n,totalSpent:s}},t.empty=void 0;o(r(221)),o(r(120));function i(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return i=function(){return e},e}function o(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=i();if(t&&t.has(e))return t.get(e);var r={},o=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var a in e)if(Object.prototype.hasOwnProperty.call(e,a)){var s=o?Object.getOwnPropertyDescriptor(e,a):null;s&&(s.get||s.set)?Object.defineProperty(r,a,s):r[a]=e[a]}return r.default=e,t&&t.set(e,r),r}t.empty={type:"error",error:"EMPTY"}},function(e,t,r){"use strict";function n(e){return function(e){if(Array.isArray(e))return i(e)}(e)||function(e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return i(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return i(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=t}))}(e,i),c=a.transactionBytes(f,t),l=a.getFee(u,c,n,t),h={fee:l.toString()};if(0===t.length)return h;var d=a.sumOrNaN(f);if(d.isNaN())return h;var p=a.sumOrNaN(t,!0),g=d.minus(p).minus(new o.default(l));if(g.comparedTo(new o.default(0))<0)return h;var y=t.reduce((function(e,t){return e+(a.bignumberOrNaN(t.value).isNaN()?1:0)}),0);if("0"===g.toString()&&0===y)return a.finalize(f,t,u,n);var m=g.div(new o.default(y)),b=a.dustThreshold(u,n.inputLength,n.changeOutputLength,n.dustThreshold);if(y&&m.lte(b))return h;var v=t.map((function(e){if(void 0!==e.value)return e;var t={};return Object.keys(e).forEach((function(r){t[r]=e[r]})),t.value=m.toString(),t}));return a.finalize(f,v,u,n)};var i,o=(i=r(29))&&i.__esModule?i:{default:i},a=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r(52));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var f=e.sort(a.score(r));return(0,u.default)(s.anyOf([(0,o.default)(.5),i.default]),n)(f,t,r,n)};var i=l(r(498)),o=l(r(499)),a=c(r(500)),s=c(r(52)),u=l(r(501));function f(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return f=function(){return e},e}function c(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=f();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}return r.default=e,t&&t.set(e,r),r}function l(e){return e&&e.__esModule?e:{default:e}}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,r,n){var i=a.bignumberOrNaN(r);if(i.isNaN()||!i.isInteger())return{};var s=i.toNumber(),u=a.transactionBytes([],t),f=new o.default(0),c=[],l=a.sumOrNaN(t),h=[],d=[];if(e.forEach((function(e){if(e.required){h.push(e);var t=a.inputBytes(e),r=a.bignumberOrNaN(e.value);u+=t,f=f.plus(r),c.push(e)}else d.push(e)})),h.length>0){var p=a.finalize(h,t,s,n);if(p.inputs)return p}for(var g=0;g=0)return a.finalize(c,t,s,n)}}return{fee:a.getFee(s,u,n,t).toString()}};var i,o=(i=r(29))&&i.__esModule?i:{default:i},a=function(e){if(e&&e.__esModule)return e;if(null===e||"object"!==n(e)&&"function"!=typeof e)return{default:e};var t=s();if(t&&t.has(e))return t.get(e);var r={},i=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var a=i?Object.getOwnPropertyDescriptor(e,o):null;a&&(a.get||a.set)?Object.defineProperty(r,o,a):r[o]=e[o]}r.default=e,t&&t.set(e,r);return r}(r(52));function s(){if("function"!=typeof WeakMap)return null;var e=new WeakMap;return s=function(){return e},e}},function(e,t,r){"use strict";function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){return function(t,r,n,i){var s=i.inputLength,u=i.changeOutputLength;if(i.baseFee)return{};var f=a.bignumberOrNaN(n);if(f.isNaN()||!f.isInteger())return{};var c=f.toNumber(),l=a.outputBytes({script:{length:u}})*c,h=a.inputBytes({script:{length:s}})*c,d=Math.floor((h+l)*e),p=a.transactionBytes([],r),g=f.times(p),y=a.sumOrNaN(r);if(y.isNaN())return{fee:"0"};var m=y.plus(g),b=function(e,t){return e.map((function(e){var r=a.bignumberOrNaN(e.value);if(r.isNaN())return{utxo:e,effectiveValue:new o.default(0)};var n=a.inputBytes(e)*t;return{utxo:e,effectiveValue:r.minus(n)}}))}(t,c).filter((function(e){return e.effectiveValue.comparedTo(new o.default(0))>0})).sort((function(e,t){var r=t.effectiveValue.minus(e.effectiveValue).toNumber();return 0!==r?r:e.utxo.i-t.utxo.i})),v=function(e,t,r){if(0===e.length)return null;var n=1e6,i=[],a=new o.default(0),s=!1,u=!1,f=e.reduce((function(e,t){return t.effectiveValue.plus(e)}),new o.default(0)),c=t.plus(r),l=0;for(;!s;){if(n<=0)return null;if(a.comparedTo(c)>0)u=!0;else if(a.comparedTo(t)>=0)s=!0;else if(l>=e.length)u=!0;else if(a.plus(f).comparedTo(t)<0){if(0===l)return null;u=!0}else f=f.minus(e[l].effectiveValue),i[l]=!0,a=a.plus(e[l].effectiveValue),l++;if(u){for(u=!1,l--;!i[l];)if(f=f.plus(e[l].effectiveValue),--l<0)return null;i[l]=!1,a=a.minus(e[l].effectiveValue),l++}n--}return i}(b,m,d);if(null!==v){for(var w=[],_=0;_=t:a.confirmations>=r)?n.push(a):i.push(a)}return{usable:n,unusable:i}}Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t){var r=t.own||1,i=t.other||6,o=t.coinbase||100;return function(t,a,s,u){t.forEach((function(e){if(null==e.coinbase||null==e.own||null==e.confirmations)throw new Error("Missing information.")}));var f=function(e,t){return e.filter((function(e){return!e.coinbase||e.confirmations>=t}))}(t,o);if(0===f.length)return{};var c,l=[];for(c=r;c>0;c--)l.push({other:i,own:c});for(c=i-1;c>0;c--)l.push({other:c,own:1});l.push({other:1,own:0}),l.push({other:0,own:0});var h=f,d=[];for(c=0;c0){d=d.concat(g.usable),h=g.unusable;var y=e(d,a,s,u);if(y.inputs)return y;if(0===h.length)return y}}throw new Error("Unexpected unreturned result")}}},function(e,t,r){"use strict";(function(Buffer){t.__esModule=!0,t.inputToTrezor=t.inputToHD=t.enhanceTrezorInputs=t.validateTrezorInputs=void 0;var e=r(224),n=r(12),i=r(115),o=r(4);function a(e,t){var r;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return s(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return s(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=e.length?{done:!0}:{done:!1,value:e[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(r=e[Symbol.iterator]()).next.bind(r)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r=3?l.versionGroupId:void 0;return[{version:l.isDashSpecialTransaction()?l.version|l.type<<16:l.version,hash:l.getId(),inputs:l.ins.map((function(e,t){var r=f[t].addresses.join(""),a=h.find((function(e){return e.address===r})),s=a?(0,i.getHDPath)(a.path):[];return{address_n:s,prev_hash:(0,n.reverseBuffer)(e.hash).toString("hex"),prev_index:e.index,script_sig:e.script.toString("hex"),sequence:e.sequence,script_type:(0,i.getScriptType)(s),multisig:void 0,amount:f[t].value,decred_tree:void 0,witness:l.hasWitnesses()?o(e.witness):void 0,ownership_proof:void 0,commitment_data:void 0}})),outputs:l.outs.map((function(e,t){var r=c[t].addresses.join(""),n=a.change.find((function(e){return e.address===r})),o=n&&(0,i.getHDPath)(n.path),s="number"==typeof e.value?e.value.toString():e.value;return o?{address_n:o,amount:s,script_type:(0,i.getOutputScriptType)(o)}:{address:r,amount:s,script_type:"PAYTOADDRESS"}})),extra_data:d?d.toString("hex"):void 0,lock_time:l.locktime,timestamp:l.timestamp,version_group_id:p,expiry:l.expiryHeight}]}))};t.transformReferencedTransactions=function(t,r){return t.flatMap((function(t){if("bitcoin"!==r.type||"blockbook"!==t.type)return[];var i=t.tx.hex,o=e.Transaction.fromHex(i,r.network),a=o.getExtraData(),s=e.coins.isZcashType(o.network)&&"number"==typeof o.versionGroupId&&o.version>=3?o.versionGroupId:void 0;return[{version:o.isDashSpecialTransaction()?o.version|o.type<<16:o.version,hash:o.getId(),inputs:o.ins.map((function(e,t){return{prev_index:e.index,sequence:e.sequence,prev_hash:(0,n.reverseBuffer)(e.hash).toString("hex"),script_sig:e.script.toString("hex")}})),bin_outputs:o.outs.map((function(e){return{amount:"number"==typeof e.value?e.value.toString():e.value,script_pubkey:e.script.toString("hex")}})),extra_data:a?a.toString("hex"):void 0,lock_time:o.locktime,timestamp:o.timestamp,version_group_id:s,expiry:o.expiryHeight}]}))}}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=r(6),c=r(13),l=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["custom-message","read","write"],r.info="Custom message";var n=t.payload;if((0,u.validateParams)(t.payload,[{name:"message",type:"string",obligatory:!0},{name:"params",type:"object",obligatory:!0}]),Object.prototype.hasOwnProperty.call(n,"messages"))try{JSON.parse(JSON.stringify(n.messages))}catch(e){throw f.ERRORS.TypedError("Method_InvalidParameter",'Parameter "messages" has invalid type. JSON expected.')}return r.params={customMessages:n.messages,message:n.message,params:n.params},r}(0,a.default)(t,e);var r=t.prototype;return r.getCustomMessages=function(){return this.params.customMessages},r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n,o;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if("trezor.io"!==this.device.features.vendor&&"bitcointrezor.com"!==this.device.features.vendor){e.next=2;break}throw f.ERRORS.TypedError("Runtime",'Cannot use custom message on device with official firmware. Change device "vendor" field.');case 2:return e.next=4,this.device.getCommands()._commonCall(this.params.message,this.params.params);case 4:return t=e.sent,r=this.createUiPromise(f.UI.CUSTOM_MESSAGE_RESPONSE,this.device),this.postMessage((0,c.UiMessage)(f.UI.CUSTOM_MESSAGE_REQUEST,t)),e.next=9,r.promise;case 9:if(n=e.sent,o=n.payload,(0,u.validateParams)(o,[{name:"message",type:"string",obligatory:!0}]),"release"!==o.message.toLowerCase()){e.next=16;break}return e.abrupt("return",t);case 16:return(0,u.validateParams)(o,[{name:"params",type:"object",obligatory:!0}]),this.params.message=o.message,this.params.params=o.params,e.next=21,this.run();case 21:return e.abrupt("return",e.sent);case 22:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=r(6),c=function(e){function t(t){var r;(r=e.call(this,t)||this).useDevice=!0,r.debugLink=!0,r.useUi=!1,r.requiredPermissions=["management"];var n=t.payload;return(0,u.validateParams)(n,[{name:"yes_no",type:"boolean"},{name:"up_down",type:"boolean"},{name:"input",type:"string"}]),r.params={yes_no:n.yes_no,input:n.input},r}return(0,a.default)(t,e),t.prototype.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.device.hasDebugLink){e.next=2;break}throw f.ERRORS.TypedError("Runtime","Device is not a debug link");case 2:if(this.device.isUsedHere()){e.next=4;break}throw f.ERRORS.TypedError("Runtime","DebugLinkDecision: Device is not acquired!");case 4:return t=this.device.getCommands(),e.next=7,t.typedCall("DebugLinkDecision","Success",this.params);case 7:return e.abrupt("return",{debugLink:!0});case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=c},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(11)),a=n(r(2)),s=n(r(3)),u=n(r(5)),f=r(6);function c(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function l(e){for(var t=1;t1)throw Error("Discovery for multiple coins in not supported");n=!0}e.coinInfo=t,r.firmwareRange=(0,l.getFirmwareRange)(r.name,t,r.firmwareRange)})),r.params=i.bundle,r.useDevice=n,r.useUi=n,r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n,o;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(y.UI.RECEIVE_CONFIRMATION,this.device),1!==this.params.length||this.params[0].path||this.params[0].descriptor?(r={},this.params.forEach((function(e){r[e.coinInfo.label]||(r[e.coinInfo.label]={coinInfo:e.coinInfo,values:[]}),r[e.coinInfo.label].values.push(e.descriptor||e.address_n)})),n=[],Object.keys(r).forEach((function(e,t,i){var o=r[e];o.values.forEach((function(t,r){n.push(""),n.push(e),n.push(" "),"string"==typeof t?n.push(t):n.push((0,d.getAccountLabel)(t,o.coinInfo)),n.push("")}))})),this.postMessage((0,m.UiMessage)(y.UI.REQUEST_CONFIRMATION,{view:"export-account-info",label:"Export info for: "+n.join("")}))):this.postMessage((0,m.UiMessage)(y.UI.REQUEST_CONFIRMATION,{view:"export-account-info",label:"Export info for "+this.params[0].coinInfo.label+" account of your selection",customConfirmButton:{label:"Proceed to account selection",className:"not-empty-css"}})),e.next=6,t.promise;case 6:return o=e.sent,e.abrupt("return",o.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.noBackupConfirmation=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(y.UI.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,m.UiMessage)(y.UI.REQUEST_CONFIRMATION,{view:"no-backup"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.checkFirmwareRange=function(){var t=(0,o.default)(i.default.mark((function t(r){var n,o,a,s;return i.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!r&&1!==this.params.length){t.next=2;break}return t.abrupt("return",e.prototype.checkFirmwareRange.call(this,r));case 2:n={1:{min:"1.0.0",max:"0"},2:{min:"2.0.0",max:"0"}},o=[],a=0;case 5:if(!(a0)){t.next=16;break}throw y.ERRORS.TypedError("Method_Discovery_BundleException",JSON.stringify(o));case 16:return t.abrupt("return",null);case 17:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n,o,a,s,u,f,c,l,h,d,p=this;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(1!==this.params.length||this.params[0].address_n||this.params[0].descriptor){e.next=2;break}return e.abrupt("return",this.discover(this.params[0]));case 2:t=[],r=function(e,t,r){!p.hasBundle||p.device&&p.device.getCommands().disposed||p.postMessage((0,m.UiMessage)(y.UI.BUNDLE_PROGRESS,{progress:e,response:t,error:r}))},n=0;case 5:if(!(n1?"Export multiple public keys":(0,y.getPublicKeyLabel)(this.params[0].address_n,this.params[0].coinInfo),this.postMessage((0,p.UiMessage)(d.REQUEST_CONFIRMATION,{view:"export-xpub",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n1?"Export multiple Lisk public keys":"Export Lisk public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,g.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-xpub",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n>24&255,timestamp:e.timeStamp,fee:e.fee,deadline:e.deadline,signer:t?void 0:e.signer}};t.createTx=function(e,t){var r=e,n={transaction:c(e,t),transfer:void 0,importance_transfer:void 0,aggregate_modification:void 0,provision_namespace:void 0,mosaic_creation:void 0,supply_change:void 0};switch(258!==e.type&&4100!==e.type&&4098!==e.type||(n.cosigning=258===e.type||4098===e.type,r=e.otherTrans,n.multisig=c(r)),r.type){case 257:n.transfer=function(e){var t=e.mosaics?e.mosaics.map((function(e){return{namespace:e.mosaicId.namespaceId,mosaic:e.mosaicId.name,quantity:e.quantity}})):void 0;return{recipient:e.recipient,amount:e.amount,payload:e.message?e.message.payload:void 0,public_key:e.message&&2===e.message.type?e.message.publicKey:void 0,mosaics:t}}(r);break;case 2049:n.importance_transfer=function(e){return{mode:f[e.importanceTransfer.mode],public_key:e.importanceTransfer.publicKey}}(r);break;case 4097:n.aggregate_modification=function(e){return{modifications:e.modifications?e.modifications.map((function(e){return{type:u[e.modificationType],public_key:e.cosignatoryAccount}})):void 0,relative_change:e.minCosignatories.relativeChange}}(r);break;case 8193:n.provision_namespace=function(e){return{namespace:e.newPart,parent:e.parent||void 0,sink:e.rentalFeeSink,fee:e.rentalFee}}(r);break;case 16385:n.mosaic_creation=function(e){var t=e.mosaicDefinition.levy,r={namespace:e.mosaicDefinition.id.namespaceId,mosaic:e.mosaicDefinition.id.name,levy:t&&t.type?a[t.type]:void 0,fee:t&&t.fee,levy_address:t&&t.recipient,levy_namespace:t&&t.mosaicId&&t.mosaicId.namespaceId,levy_mosaic:t&&t.mosaicId&&t.mosaicId.name,description:e.mosaicDefinition.description},n=e.mosaicDefinition.properties;return Array.isArray(n)&&n.forEach((function(e){var t=e.name,n=e.value;switch(t){case"divisibility":r.divisibility=parseInt(n);break;case"initialSupply":r.supply=parseInt(n);break;case"supplyMutable":r.mutable_supply="true"===n;break;case"transferable":r.transferable="true"===n}})),{definition:r,sink:e.creationFeeSink,fee:e.creationFee}}(r);break;case 16386:n.supply_change=function(e){return{namespace:e.mosaicId.namespaceId,mosaic:e.mosaicId.name,type:s[e.supplyType],delta:e.delta}}(r);break;default:throw i.ERRORS.TypedError("Method_InvalidParameter","Unknown transaction type")}return n}},function(e,t,r){},function(e,t,r){"use strict";(function(Buffer){var e=r(0);t.__esModule=!0,t.default=void 0;var n=e(r(1)),i=e(r(2)),o=e(r(3)),a=e(r(5)),s=r(4),u=r(12),f=r(8),c=r(33),l=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["read","write"];var n=t.payload;(0,s.validateParams)(n,[{name:"path",obligatory:!0},{name:"coin",type:"string"},{name:"message",type:"string",obligatory:!0},{name:"hex",type:"boolean"}]);var i,o=(0,u.validatePath)(n.path);n.coin?(i=(0,f.getBitcoinNetwork)(n.coin),(0,s.validateCoinPath)(i,o)):i=(0,f.getBitcoinNetwork)(o),r.info=(0,u.getLabel)("Sign #NETWORK message",i),i&&(r.firmwareRange=(0,s.getFirmwareRange)(r.name,i,r.firmwareRange));var a=n.hex?(0,c.messageToHex)(n.message):Buffer.from(n.message,"utf8").toString("hex"),l=(0,u.getScriptType)(o);return r.params={address_n:o,message:a,coin_name:i?i.name:void 0,script_type:l&&"SPENDMULTISIG"!==l?l:"SPENDADDRESS"},r}return(0,o.default)(t,e),t.prototype.run=function(){var e=(0,i.default)(n.default.mark((function e(){var t,r,i,o;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("SignMessage","MessageSignature",this.params);case 3:return r=e.sent,i=r.message,o=Buffer.from(i.signature,"hex"),i.signature=o.toString("base64"),e.abrupt("return",i);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(a.default);t.default=l}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(11)),a=n(r(2)),s=n(r(3)),u=n(r(29)),f=n(r(5)),c=r(4),l=r(8),h=r(12),d=r(6),p=r(23),g=n(r(226)),y=n(r(227)),m=n(r(228)),b=r(223);function v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function w(e){for(var t=1;t0&&a.reduce((function(e,t){return e.plus("string"==typeof t.amount?t.amount:"0")}),new u.default(0)).lte(i.dustLimit))throw d.ERRORS.TypedError("Method_InvalidParameter","Total amount is below dust limit.");if(r.params={inputs:o,outputs:n.outputs,refTxs:n.refTxs,addresses:n.account?n.account.addresses:void 0,options:{lock_time:n.locktime,timestamp:n.timestamp,version:n.version,expiry:n.expiry,overwintered:n.overwintered,version_group_id:n.versionGroupId,branch_id:n.branchId},coinInfo:i,push:"boolean"==typeof n.push&&n.push},i.hasTimestamp&&!Object.prototype.hasOwnProperty.call(n,"timestamp")){var s=new Date;r.params.options.timestamp=Math.round(s.getTime()/1e3)}return r}return(0,s.default)(t,e),t.prototype.run=function(){var e=(0,a.default)(i.default.mark((function e(){var t,r,n,o,a,s,u,f,c,l,h,d,v,_,E,S,A;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.device,r=this.params,n=[],o=t.unavailableCapabilities.replaceTransaction,r.refTxs){e.next=33;break}if(!((a=(0,b.getReferencedTransactions)(r.inputs)).length>0)){e.next=31;break}return(0,p.isBackendSupported)(r.coinInfo),e.next=9,(0,p.initBlockchain)(r.coinInfo,this.postMessage);case 9:return s=e.sent,e.next=12,s.getTransactions(a);case 12:if(u=e.sent,(0,b.enhanceTrezorInputs)(this.params.inputs,u),n=(0,b.transformReferencedTransactions)(u,r.coinInfo),f=(0,b.getOrigTransactions)(r.inputs,r.outputs),o||!(f.length>0)){e.next=31;break}return e.next=19,s.getTransactions(f);case 19:if(c=e.sent,l=r.addresses){e.next=29;break}return e.next=24,t.getCommands().getHDNode(r.inputs[0].address_n.slice(0,3),r.coinInfo);case 24:return h=e.sent,e.next=27,s.getAccountInfo({descriptor:h.xpubSegwit||h.xpub,coin:r.coinInfo.name,details:"tokens"});case 27:d=e.sent,l=d.addresses;case 29:v=(0,b.transformOrigTransactions)(c,r.coinInfo,l),n=n.concat(v);case 31:e.next=34;break;case 33:n=r.refTxs;case 34:return _=o?y.default:g.default,e.next=37,_(t.getCommands().typedCall.bind(t.getCommands()),r.inputs,r.outputs,n,r.options,r.coinInfo);case 37:return E=e.sent,e.next=40,(0,m.default)(t.getCommands().getHDNode.bind(t.getCommands()),r.inputs,r.outputs,E.serializedTx,r.coinInfo);case 40:if(!r.push){e.next=49;break}return(0,p.isBackendSupported)(r.coinInfo),e.next=44,(0,p.initBlockchain)(r.coinInfo,this.postMessage);case 44:return S=e.sent,e.next=47,S.pushTransaction(E.serializedTx);case 47:return A=e.sent,e.abrupt("return",w(w({},E),{},{txid:A}));case 49:return e.abrupt("return",E);case 50:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(f.default);t.default=_},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(5)),c=r(4),l=r(8),h=r(12),d=r(6),p=r(13);function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t=r.length,s=r[n],u=s.type,f=(0,a.default)(s,["type"]),!i){e.next=9;break}return e.next=5,t(u,"StellarSignedTx",f);case 5:return c=e.sent,e.abrupt("return",c.message);case 9:return e.next=11,t(u,"StellarTxOpRequest",f);case 11:return e.abrupt("return",l(t,r,n+1));case 12:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}(),h=function(){var e=(0,s.default)(o.default.mark((function e(t,r,n,i){var a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return(a=d(i)).address_n=r,a.network_passphrase=n,s=[],i.operations.forEach((function(e){var t=p(e);t&&s.push(t)})),e.next=7,t("StellarSignTx","StellarTxOpRequest",a);case 7:return e.abrupt("return",l(t,s,0));case 8:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}();t.stellarSignTx=h;var d=function(e){var t={};return e.timebounds&&(t.timebounds_start=e.timebounds.minTime,t.timebounds_end=e.timebounds.maxTime),e.memo&&(t.memo_type=e.memo.type,t.memo_text=e.memo.text,t.memo_id=e.memo.id,t.memo_hash=e.memo.hash),c({address_n:[],network_passphrase:"",source_account:e.source,fee:e.fee,sequence_number:e.sequence,num_operations:e.operations.length},t)},p=function(e){switch(e.type){case"createAccount":return(0,u.validateParams)(e,[{name:"destination",type:"string",obligatory:!0},{name:"startingBalance",type:"amount",obligatory:!0}]),{type:"StellarCreateAccountOp",source_account:e.source,new_account:e.destination,starting_balance:e.startingBalance};case"payment":return(0,u.validateParams)(e,[{name:"destination",type:"string",obligatory:!0},{name:"amount",type:"amount",obligatory:!0}]),{type:"StellarPaymentOp",source_account:e.source,destination_account:e.destination,asset:e.asset,amount:e.amount};case"pathPayment":return(0,u.validateParams)(e,[{name:"destAmount",type:"amount",obligatory:!0}]),{type:"StellarPathPaymentOp",source_account:e.source,send_asset:e.sendAsset,send_max:e.sendMax,destination_account:e.destination,destination_asset:e.destAsset,destination_amount:e.destAmount,paths:e.path};case"createPassiveOffer":return(0,u.validateParams)(e,[{name:"amount",type:"amount",obligatory:!0}]),{type:"StellarCreatePassiveOfferOp",source_account:e.source,buying_asset:e.buying,selling_asset:e.selling,amount:e.amount,price_n:e.price.n,price_d:e.price.d};case"manageOffer":return(0,u.validateParams)(e,[{name:"amount",type:"amount",obligatory:!0}]),{type:"StellarManageOfferOp",source_account:e.source,buying_asset:e.buying,selling_asset:e.selling,amount:e.amount,offer_id:e.offerId,price_n:e.price.n,price_d:e.price.d};case"setOptions":var t=e.signer?{signer_type:e.signer.type,signer_key:e.signer.key,signer_weight:e.signer.weight}:void 0;return c({type:"StellarSetOptionsOp",source_account:e.source,clear_flags:e.clearFlags,set_flags:e.setFlags,master_weight:e.masterWeight,low_threshold:e.lowThreshold,medium_threshold:e.medThreshold,high_threshold:e.highThreshold,home_domain:e.homeDomain,inflation_destination_account:e.inflationDest},t);case"changeTrust":return(0,u.validateParams)(e,[{name:"limit",type:"amount"}]),{type:"StellarChangeTrustOp",source_account:e.source,asset:e.line,limit:e.limit};case"allowTrust":return{type:"StellarAllowTrustOp",source_account:e.source,trusted_account:e.trustor,asset_type:e.assetType,asset_code:e.assetCode,is_authorized:e.authorize?1:0};case"accountMerge":return{type:"StellarAccountMergeOp",source_account:e.source,destination_account:e.destination};case"manageData":return{type:"StellarManageDataOp",source_account:e.source,key:e.name,value:e.value};case"bumpSequence":return{type:"StellarBumpSequenceOp",source_account:e.source,bump_to:e.bumpTo}}}},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(17)),s=n(r(3)),u=n(r(11)),f=n(r(5)),c=r(4),l=r(8),h=r(12),d=r(6),p=r(13);function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function y(e){for(var t=1;t1?"Export multiple Tezos public keys":"Export Tezos public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,g.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-address",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n1?"Export multiple Eos public keys":"Export Eos public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,g.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-address",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n=0;--n){for(var i=e[n],o=0;o="a".charCodeAt(0)&&e<="z".charCodeAt(0)?e-"a".charCodeAt(0)+6:e>="1".charCodeAt(0)&&e<="5".charCodeAt(0)?e-"1".charCodeAt(0)+1:0}for(var r=new Uint8Array(8),n=63,i=0;i=0;--a)n>=0&&(r[Math.floor(n/8)]|=(o>>a&1)<="0".charCodeAt(0)&&e.charCodeAt(t)<="9".charCodeAt(0);)i=!0,r+=e[t],++t;if(!i)throw f.ERRORS.TypedError("Method_InvalidParameter","Eos serialization error. Asset must begin with a number");if("."===e[t])for(++t;t="0".charCodeAt(0)&&e.charCodeAt(t)<="9".charCodeAt(0);)r+=e[t],++n,++t;for(var o=e.substr(t).trim(),a=[255&n],s=0;s0?e.length-2*t:0;return e.substring(r,r+4096)}},w=function(){var e=(0,a.default)(o.default.mark((function e(t,r,n,i){var a,s,u,f,c,l,h,d,p,g,y,m;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=n[i],s=i+1>=n.length,f=r.data_size,!a.unknown){e.next=23;break}if(c=a.unknown,l="number"==typeof f?f:0,h=v(c.data_chunk,l),d={common:a.common,unknown:{data_size:c.data_size,data_chunk:h}},p=l>0?c.data_size-l+2048:2048,g=p>=c.data_size,!s||!g){e.next=17;break}return e.next=13,t("EosTxActionAck","EosSignedTx",d);case 13:return y=e.sent,e.abrupt("return",y.message);case 17:return e.next=19,t("EosTxActionAck","EosTxActionRequest",d);case 19:u=e.sent,g&&i++;case 21:e.next=32;break;case 23:if(!s){e.next=28;break}return e.next=26,t("EosTxActionAck","EosSignedTx",a);case 26:return m=e.sent,e.abrupt("return",m.message);case 28:return e.next=30,t("EosTxActionAck","EosTxActionRequest",a);case 30:u=e.sent,i++;case 32:return e.abrupt("return",w(t,u.message,n,i));case 33:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}(),_=function(){var e=(0,a.default)(o.default.mark((function e(t,r,n,i,a){var s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t("EosSignTx","EosTxActionRequest",{address_n:r,chain_id:n,header:i,num_actions:a.length});case 2:return s=e.sent,e.abrupt("return",w(t,s.message,a,0));case 4:case"end":return e.stop()}}),e)})));return function(t,r,n,i,o){return e.apply(this,arguments)}}();t.signTx=_},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(17)),u=i(r(3)),f=i(r(11)),c=i(r(5)),l=r(4),h=r(8),d=r(12),p=n(r(20)),g=r(13);function y(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function m(e){for(var t=1;t1?"Export multiple Binance public keys":"Export Binance public key for account #"+((0,d.fromHardened)(this.params[0].address_n[2])+1),this.postMessage((0,g.UiMessage)(p.REQUEST_CONFIRMATION,{view:"export-address",label:r})),e.next=9,t.promise;case 9:return n=e.sent,this.confirmed=n.payload,e.abrupt("return",this.confirmed);case 12:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r,n,i,a,s;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:t=[],r=this.device.getCommands(),n=0;case 3:if(!(n=r.length)){e.next=7;break}return e.next=5,t(s,"BinanceSignedTx",u);case 5:return f=e.sent,e.abrupt("return",f.message);case 7:return e.next=9,t(s,"BinanceTxRequest",u);case 9:return n++,e.abrupt("return",h(t,r,n));case 11:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();t.validate=function(e){(0,f.validateParams)(e,[{name:"chain_id",type:"string",obligatory:!0},{name:"account_number",type:"number"},{name:"memo",type:"string"},{name:"sequence",type:"number"},{name:"source",type:"number"},{name:"message",type:"object"}]);var t={chain_id:e.chain_id,account_number:e.account_number||0,memo:e.memo,sequence:e.sequence||0,source:e.source||0,messages:[]},r=e.transfer,n=e.placeOrder,i=e.cancelOrder;if(r&&((0,f.validateParams)(r,[{name:"inputs",type:"array",obligatory:!0},{name:"outputs",type:"array",obligatory:!0}]),t.messages.push(l(l({},r),{},{type:"BinanceTransferMsg"}))),n&&((0,f.validateParams)(n,[{name:"id",type:"string"},{name:"ordertype",type:"number"},{name:"price",type:"number"},{name:"quantity",type:"number"},{name:"sender",type:"string"},{name:"side",type:"number"}]),t.messages.push(l(l({},n),{},{type:"BinanceOrderMsg"}))),i&&((0,f.validateParams)(e.cancelOrder,[{name:"refid",type:"string",obligatory:!0},{name:"sender",type:"string",obligatory:!0},{name:"symbol",type:"string",obligatory:!0}]),t.messages.push(l(l({},i),{},{type:"BinanceCancelMsg"}))),t.messages.length<1)throw u.ERRORS.TypedError("Method_InvalidParameter","Transaction does not have any message");return t};var d=function(){var e=(0,s.default)(o.default.mark((function e(t,r,n){var i,a,s,u,f,c,l;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return i=n.account_number,a=n.chain_id,s=n.memo,u=n.sequence,f=n.source,c=n.messages,l=c.length,e.next=4,t("BinanceSignTx","BinanceTxRequest",{address_n:r,msg_count:l,account_number:i,chain_id:a,memo:s,sequence:u,source:f});case 4:return e.abrupt("return",h(t,c,0));case 5:case"end":return e.stop()}}),e)})));return function(t,r,n){return e.apply(this,arguments)}}();t.signTx=d},function(e,t,r){"use strict";(function(Buffer){var e=r(0);t.__esModule=!0,t.default=void 0;var n=e(r(1)),i=e(r(2)),o=e(r(3)),a=e(r(5)),s=r(4),u=r(8),f=r(12),c=r(33),l=r(6),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["read","write"],r.info="Verify message";var n=t.payload;(0,s.validateParams)(n,[{name:"address",type:"string",obligatory:!0},{name:"signature",type:"string",obligatory:!0},{name:"message",type:"string",obligatory:!0},{name:"coin",type:"string",obligatory:!0},{name:"hex",type:"boolean"}]);var i=(0,u.getBitcoinNetwork)(n.coin);if(!i)throw l.ERRORS.TypedError("Method_UnknownCoin");r.firmwareRange=(0,s.getFirmwareRange)(r.name,i,r.firmwareRange),r.info=(0,f.getLabel)("Verify #NETWORK message",i);var o=n.hex?(0,c.messageToHex)(n.message):Buffer.from(n.message,"utf8").toString("hex"),a=Buffer.from(n.signature,"base64").toString("hex");return r.params={address:n.address,signature:a,message:o,coin_name:i.name},r}return(0,o.default)(t,e),t.prototype.run=function(){var e=(0,i.default)(n.default.mark((function e(){var t,r;return n.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("VerifyMessage","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(a.default);t.default=h}).call(this,r(9).Buffer)},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(13),l=r(4),h=function(e){function t(t){var r;return(r=e.call(this,t)||this).allowDeviceMode=[f.INITIALIZE,f.SEEDLESS],r.useDeviceState=!1,r.requiredPermissions=["management"],r.firmwareRange=(0,l.getFirmwareRange)(r.name,null,r.firmwareRange),r.info="Wipe device",r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!this.confirmed){e.next=2;break}return e.abrupt("return",!0);case 2:return e.next=4,this.getPopupPromise().promise;case 4:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,c.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"wipe",label:"Wipe "+this.device.toMessageObject().label},label:"Are you sure you want to wipe your device?"})),e.next=8,t.promise;case 8:return r=e.sent,this.confirmed=r.payload,e.abrupt("return",this.confirmed);case 11:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("WipeDevice","Success");case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=r(4),c=n(r(20)),l=r(13),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1;var n=t.payload;return(0,f.validateParams)(n,[{name:"flags",type:"number",obligatory:!0}]),r.params={flags:n.flags},r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(c.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(c.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you really want to apply flags?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("ApplyFlags","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(4),l=r(13),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1;var n=t.payload;return(0,c.validateParams)(n,[{name:"language",type:"string"},{name:"label",type:"string"},{name:"use_passphrase",type:"boolean"},{name:"homescreen",type:"string"},{name:"passphrase_source",type:"number"},{name:"passphrase_always_on_device",type:"boolean"},{name:"auto_lock_delay_ms",type:"number"},{name:"display_rotation",type:"number"},{name:"safety_checks",type:"number"}]),r.params={language:n.language,label:n.label,use_passphrase:n.use_passphrase,homescreen:n.homescreen,passphrase_source:n.passphrase_source,passphrase_always_on_device:n.passphrase_always_on_device,auto_lock_delay_ms:n.auto_lock_delay_ms,display_rotation:n.display_rotation,safety_checks:n.safety_checks},r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you really want to change device settings?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("ApplySettings","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(13),l=function(e){function t(t){var r;return(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1,r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,c.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you want to initiate backup procedure?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("BackupDevice","Success");case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=l},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=n(r(5)),u=r(4),f=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useDeviceState=!1;var n=t.payload;return(0,u.validateParams)(n,[{name:"remove",type:"boolean"}]),r.params={remove:n.remove},r}return(0,a.default)(t,e),t.prototype.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("ChangePin","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(s.default);t.default=f},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(1)),o=n(r(2)),a=n(r(3)),s=r(128),u=n(r(5)),f=r(6),c=r(559),l=r(13),h=r(4),d=r(80),p=function(e){function t(t){var r;(r=e.call(this,t)||this).useEmptyPassphrase=!0,r.requiredPermissions=["management"],r.allowDeviceMode=[f.UI.BOOTLOADER,f.UI.INITIALIZE],r.requireDeviceMode=[f.UI.BOOTLOADER],r.useDeviceState=!1,r.skipFirmwareCheck=!0;var n=t.payload;return(0,h.validateParams)(n,[{name:"version",type:"array"},{name:"btcOnly",type:"boolean"},{name:"baseUrl",type:"string"},{name:"binary",type:"buffer"},{name:"intermediary",type:"boolean"}]),r.params={version:n.version,btcOnly:n.btcOnly,baseUrl:n.baseUrl||"https://data.trezor.io",binary:n.binary,intermediary:n.intermediary},r}(0,a.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.UI.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(f.UI.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"wipe",label:"Proceed"},label:"Do you want to update firmware? Never do this without your recovery card."})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,o.default)(i.default.mark((function e(){var t,r,n;return i.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t=this.device,e.prev=1,!this.params.binary){e.next=6;break}r=this.params.binary,e.next=10;break;case 6:return e.next=8,(0,s.getBinary)({features:t.features,releases:(0,d.getReleases)(t.features.major_version),version:this.params.version,btcOnly:this.params.btcOnly,baseUrl:this.params.baseUrl,intermediary:this.params.intermediary});case 8:n=e.sent,r=n.binary;case 10:e.next=15;break;case 12:throw e.prev=12,e.t0=e.catch(1),f.ERRORS.TypedError("Method_FirmwareUpdate_DownloadFailed","Failed to download firmware binary");case 15:return e.abrupt("return",(0,c.uploadFirmware)(this.device.getCommands().typedCall.bind(this.device.getCommands()),this.postMessage,t,{payload:r}));case 16:case"end":return e.stop()}}),e,this,[[1,12]])})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=p},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.uploadFirmware=void 0;var o=i(r(1)),a=i(r(2)),s=r(13),u=n(r(20)),f=n(r(78)),c=function(e){e.features.firmware_present&&e.emit(f.BUTTON,e,"ButtonRequest_FirmwareUpdate")},l=function(e,t,r){r((0,s.UiMessage)(u.FIRMWARE_PROGRESS,{device:e.toMessageObject(),progress:t}))},h=function(){var e=(0,a.default)(o.default.mark((function e(t,r,n,i){var a,s,u,f,h,d,p,g;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=i.payload,s={},1!==n.features.major_version){e.next=13;break}return c(n),e.next=6,t("FirmwareErase","Success",{});case 6:return l(n,0,r),e.next=9,t("FirmwareUpload","Success",{payload:a});case 9:return u=e.sent,f=u.message,l(n,100,r),e.abrupt("return",f);case 13:if(2!==n.features.major_version){e.next=31;break}return c(n),h=a.byteLength,e.next=18,t("FirmwareErase","FirmwareRequest",{length:h});case 18:s=e.sent;case 19:if("Success"===s.type){e.next=29;break}return d=s.message.offset,p=s.message.offset+s.message.length,g=a.slice(d,p),d>0&&l(n,Math.round(d/h*100),r),e.next=26,t("FirmwareUpload","FirmwareRequest|Success",{payload:g});case 26:s=e.sent,e.next=19;break;case 29:return l(n,100,r),e.abrupt("return",s.message);case 31:case"end":return e.stop()}}),e)})));return function(t,r,n,i){return e.apply(this,arguments)}}();t.uploadFirmware=h},function(e,t,r){"use strict";var n=r(14),i=r(0);t.__esModule=!0,t.default=void 0;var o=i(r(1)),a=i(r(2)),s=i(r(3)),u=i(r(5)),f=n(r(20)),c=r(4),l=r(13),h=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=["management"],r.useEmptyPassphrase=!0;var n=t.payload;return(0,c.validateParams)(n,[{name:"word_count",type:"number"},{name:"passphrase_protection",type:"boolean"},{name:"pin_protection",type:"boolean"},{name:"language",type:"string"},{name:"label",type:"string"},{name:"enforce_wordlist",type:"boolean"},{name:"type",type:"number"},{name:"u2f_counter",type:"number"},{name:"dry_run",type:"boolean"}]),r.params={word_count:n.word_count,passphrase_protection:n.passphrase_protection,pin_protection:n.pin_protection,language:n.language,label:n.label,enforce_wordlist:n.enforce_wordlist,type:n.type,u2f_counter:n.u2f_counter,dry_run:n.dry_run},r.allowDeviceMode=[].concat(r.allowDeviceMode,[f.INITIALIZE]),r.useDeviceState=!1,r}(0,s.default)(t,e);var r=t.prototype;return r.confirmation=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,this.getPopupPromise().promise;case 2:return t=this.createUiPromise(f.RECEIVE_CONFIRMATION,this.device),this.postMessage((0,l.UiMessage)(f.REQUEST_CONFIRMATION,{view:"device-management",customConfirmButton:{className:"confirm",label:"Proceed"},label:"Do you want to recover device from seed?"})),e.next=6,t.promise;case 6:return r=e.sent,e.abrupt("return",r.payload);case 8:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),r.run=function(){var e=(0,a.default)(o.default.mark((function e(){var t,r;return o.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return t=this.device.getCommands(),e.next=3,t.typedCall("RecoveryDevice","Success",this.params);case 3:return r=e.sent,e.abrupt("return",r.message);case 5:case"end":return e.stop()}}),e,this)})));return function(){return e.apply(this,arguments)}}(),t}(u.default);t.default=h},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(3)),o=n(r(5)),a=r(4),s=r(6),u=r(8),f=function(e){function t(t){var r;(r=e.call(this,t)||this).requiredPermissions=[],r.useDevice=!1,r.useUi=!1;var n=t.payload;(0,a.validateParams)(n,[{name:"coin",type:"string",obligatory:!0}]);var i=(0,u.getCoinInfo)(n.coin);if(!i)throw s.ERRORS.TypedError("Method_UnknownCoin");return r.params={coinInfo:i},r}return(0,i.default)(t,e),t.prototype.run=function(){return Promise.resolve(this.params.coinInfo)},t}(o.default);t.default=f},function(e,t,r){"use strict";var n=r(0);t.__esModule=!0,t.default=void 0;var i=n(r(563)),o=n(r(11)),a=(0,r(49).initLog)("InteractionTimeout"),s=function(){function e(e){(0,o.default)(this,"timeout",null),(0,o.default)(this,"seconds",0),e&&(this.seconds=e)}var t=e.prototype;return t.start=function(e,t){var r=t||this.seconds;r<1||(this.stop(),a.log("starting interaction timeout for "+r+" seconds"),this.timeout=setTimeout((function(){a.log("interaction timed out"),e()}),1e3*r))},t.stop=function(){this.timeout&&(a.log("clearing interaction timeout"),clearTimeout(this.timeout))},(0,i.default)(e,[{key:"seconds",get:function(){return this.seconds},set:function(e){this.seconds=e}}]),e}();t.default=s},function(e,t){function r(e,t){for(var r=0;rparseInt(r.version,10)));return{name:r.name+": "+r.version+"; "+n.name+": "+n.version+";",osname:n.name,mobile:i,supported:a,outdated:s}};t.suggestBridgeInstaller=function(){var e=(0,a.getBridgeInfo)();if(!e.packages.find((function(e){return e.preferred}))){var t=function(){if(navigator&&navigator.userAgent){var e=navigator.userAgent;switch(o.default.getParser(e).getOS().name.toLowerCase()){case"linux":return""+(e.match(/CentOS|Fedora|Mandriva|Mageia|Red Hat|Scientific|SUSE/)?"rpm":"deb")+(e.match(/Linux i[3456]86/)?"32":"64");case"macos":return"mac";case"windows":return"win"+(e.match(/(Win64|WOW64)/)?"64":"32")}}}();t&&(e.packages=e.packages.map((function(e){return u(u({},e),{},{preferred:e.platform.indexOf(t)>=0})})))}return e}},function(e,t,r){e.exports=function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=90)}({17:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n=r(18),i=function(){function e(){}return e.getFirstMatch=function(e,t){var r=t.match(e);return r&&r.length>0&&r[1]||""},e.getSecondMatch=function(e,t){var r=t.match(e);return r&&r.length>1&&r[2]||""},e.matchAndReturnConst=function(e,t,r){if(e.test(t))return r},e.getWindowsVersionName=function(e){switch(e){case"NT":return"NT";case"XP":return"XP";case"NT 5.0":return"2000";case"NT 5.1":return"XP";case"NT 5.2":return"2003";case"NT 6.0":return"Vista";case"NT 6.1":return"7";case"NT 6.2":return"8";case"NT 6.3":return"8.1";case"NT 10.0":return"10";default:return}},e.getMacOSVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),10===t[0])switch(t[1]){case 5:return"Leopard";case 6:return"Snow Leopard";case 7:return"Lion";case 8:return"Mountain Lion";case 9:return"Mavericks";case 10:return"Yosemite";case 11:return"El Capitan";case 12:return"Sierra";case 13:return"High Sierra";case 14:return"Mojave";case 15:return"Catalina";default:return}},e.getAndroidVersionName=function(e){var t=e.split(".").splice(0,2).map((function(e){return parseInt(e,10)||0}));if(t.push(0),!(1===t[0]&&t[1]<5))return 1===t[0]&&t[1]<6?"Cupcake":1===t[0]&&t[1]>=6?"Donut":2===t[0]&&t[1]<2?"Eclair":2===t[0]&&2===t[1]?"Froyo":2===t[0]&&t[1]>2?"Gingerbread":3===t[0]?"Honeycomb":4===t[0]&&t[1]<1?"Ice Cream Sandwich":4===t[0]&&t[1]<4?"Jelly Bean":4===t[0]&&t[1]>=4?"KitKat":5===t[0]?"Lollipop":6===t[0]?"Marshmallow":7===t[0]?"Nougat":8===t[0]?"Oreo":9===t[0]?"Pie":void 0},e.getVersionPrecision=function(e){return e.split(".").length},e.compareVersions=function(t,r,n){void 0===n&&(n=!1);var i=e.getVersionPrecision(t),o=e.getVersionPrecision(r),a=Math.max(i,o),s=0,u=e.map([t,r],(function(t){var r=a-e.getVersionPrecision(t),n=t+new Array(r+1).join(".0");return e.map(n.split("."),(function(e){return new Array(20-e.length).join("0")+e})).reverse()}));for(n&&(s=a-Math.min(i,o)),a-=1;a>=s;){if(u[0][a]>u[1][a])return 1;if(u[0][a]===u[1][a]){if(a===s)return 0;a-=1}else if(u[0][a]1?i-1:0),a=1;a0){var a=Object.keys(r),u=s.default.find(a,(function(e){return t.isOS(e)}));if(u){var f=this.satisfies(r[u]);if(void 0!==f)return f}var c=s.default.find(a,(function(e){return t.isPlatform(e)}));if(c){var l=this.satisfies(r[c]);if(void 0!==l)return l}}if(o>0){var h=Object.keys(i),d=s.default.find(h,(function(e){return t.isBrowser(e,!0)}));if(void 0!==d)return this.compareVersion(i[d])}},t.isBrowser=function(e,t){void 0===t&&(t=!1);var r=this.getBrowserName().toLowerCase(),n=e.toLowerCase(),i=s.default.getBrowserTypeByAlias(n);return t&&i&&(n=i.toLowerCase()),n===r},t.compareVersion=function(e){var t=[0],r=e,n=!1,i=this.getBrowserVersion();if("string"==typeof i)return">"===e[0]||"<"===e[0]?(r=e.substr(1),"="===e[1]?(n=!0,r=e.substr(2)):t=[],">"===e[0]?t.push(1):t.push(-1)):"="===e[0]?r=e.substr(1):"~"===e[0]&&(n=!0,r=e.substr(1)),t.indexOf(s.default.compareVersions(i,r,n))>-1},t.isOS=function(e){return this.getOSName(!0)===String(e).toLowerCase()},t.isPlatform=function(e){return this.getPlatformType(!0)===String(e).toLowerCase()},t.isEngine=function(e){return this.getEngineName(!0)===String(e).toLowerCase()},t.is=function(e,t){return void 0===t&&(t=!1),this.isBrowser(e,t)||this.isOS(e)||this.isPlatform(e)},t.some=function(e){var t=this;return void 0===e&&(e=[]),e.some((function(e){return t.is(e)}))},e}();t.default=f,e.exports=t.default},92:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=/version\/(\d+(\.?_?\d+)+)/i,a=[{test:[/googlebot/i],describe:function(e){var t={name:"Googlebot"},r=i.default.getFirstMatch(/googlebot\/(\d+(\.\d+))/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/opera/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:opera)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opr\/|opios/i],describe:function(e){var t={name:"Opera"},r=i.default.getFirstMatch(/(?:opr|opios)[\s/](\S+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/SamsungBrowser/i],describe:function(e){var t={name:"Samsung Internet for Android"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:SamsungBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Whale/i],describe:function(e){var t={name:"NAVER Whale Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:whale)[\s/](\d+(?:\.\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MZBrowser/i],describe:function(e){var t={name:"MZ Browser"},r=i.default.getFirstMatch(/(?:MZBrowser)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/focus/i],describe:function(e){var t={name:"Focus"},r=i.default.getFirstMatch(/(?:focus)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/swing/i],describe:function(e){var t={name:"Swing"},r=i.default.getFirstMatch(/(?:swing)[\s/](\d+(?:\.\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/coast/i],describe:function(e){var t={name:"Opera Coast"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:coast)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/opt\/\d+(?:.?_?\d+)+/i],describe:function(e){var t={name:"Opera Touch"},r=i.default.getFirstMatch(/(?:opt)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/yabrowser/i],describe:function(e){var t={name:"Yandex Browser"},r=i.default.getFirstMatch(/(?:yabrowser)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/ucbrowser/i],describe:function(e){var t={name:"UC Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:ucbrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/Maxthon|mxios/i],describe:function(e){var t={name:"Maxthon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:Maxthon|mxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/epiphany/i],describe:function(e){var t={name:"Epiphany"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:epiphany)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/puffin/i],describe:function(e){var t={name:"Puffin"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:puffin)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sleipnir/i],describe:function(e){var t={name:"Sleipnir"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:sleipnir)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/k-meleon/i],describe:function(e){var t={name:"K-Meleon"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/(?:k-meleon)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/micromessenger/i],describe:function(e){var t={name:"WeChat"},r=i.default.getFirstMatch(/(?:micromessenger)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qqbrowser/i],describe:function(e){var t={name:/qqbrowserlite/i.test(e)?"QQ Browser Lite":"QQ Browser"},r=i.default.getFirstMatch(/(?:qqbrowserlite|qqbrowser)[/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/msie|trident/i],describe:function(e){var t={name:"Internet Explorer"},r=i.default.getFirstMatch(/(?:msie |rv:)(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/\sedg\//i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getFirstMatch(/\sedg\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/edg([ea]|ios)/i],describe:function(e){var t={name:"Microsoft Edge"},r=i.default.getSecondMatch(/edg([ea]|ios)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/vivaldi/i],describe:function(e){var t={name:"Vivaldi"},r=i.default.getFirstMatch(/vivaldi\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/seamonkey/i],describe:function(e){var t={name:"SeaMonkey"},r=i.default.getFirstMatch(/seamonkey\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/sailfish/i],describe:function(e){var t={name:"Sailfish"},r=i.default.getFirstMatch(/sailfish\s?browser\/(\d+(\.\d+)?)/i,e);return r&&(t.version=r),t}},{test:[/silk/i],describe:function(e){var t={name:"Amazon Silk"},r=i.default.getFirstMatch(/silk\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/phantom/i],describe:function(e){var t={name:"PhantomJS"},r=i.default.getFirstMatch(/phantomjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/slimerjs/i],describe:function(e){var t={name:"SlimerJS"},r=i.default.getFirstMatch(/slimerjs\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t={name:"BlackBerry"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/blackberry[\d]+\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t={name:"WebOS Browser"},r=i.default.getFirstMatch(o,e)||i.default.getFirstMatch(/w(?:eb)?[o0]sbrowser\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/bada/i],describe:function(e){var t={name:"Bada"},r=i.default.getFirstMatch(/dolfin\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/tizen/i],describe:function(e){var t={name:"Tizen"},r=i.default.getFirstMatch(/(?:tizen\s?)?browser\/(\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/qupzilla/i],describe:function(e){var t={name:"QupZilla"},r=i.default.getFirstMatch(/(?:qupzilla)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/firefox|iceweasel|fxios/i],describe:function(e){var t={name:"Firefox"},r=i.default.getFirstMatch(/(?:firefox|iceweasel|fxios)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/electron/i],describe:function(e){var t={name:"Electron"},r=i.default.getFirstMatch(/(?:electron)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/MiuiBrowser/i],describe:function(e){var t={name:"Miui"},r=i.default.getFirstMatch(/(?:MiuiBrowser)[\s/](\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/chromium/i],describe:function(e){var t={name:"Chromium"},r=i.default.getFirstMatch(/(?:chromium)[\s/](\d+(\.?_?\d+)+)/i,e)||i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/chrome|crios|crmo/i],describe:function(e){var t={name:"Chrome"},r=i.default.getFirstMatch(/(?:chrome|crios|crmo)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/GSA/i],describe:function(e){var t={name:"Google Search"},r=i.default.getFirstMatch(/(?:GSA)\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t={name:"Android Browser"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/playstation 4/i],describe:function(e){var t={name:"PlayStation 4"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/safari|applewebkit/i],describe:function(e){var t={name:"Safari"},r=i.default.getFirstMatch(o,e);return r&&(t.version=r),t}},{test:[/.*/i],describe:function(e){var t=-1!==e.search("\\(")?/^(.*)\/(.*)[ \t]\((.*)/:/^(.*)\/(.*) /;return{name:i.default.getFirstMatch(t,e),version:i.default.getSecondMatch(t,e)}}}];t.default=a,e.exports=t.default},93:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/Roku\/DVP/],describe:function(e){var t=i.default.getFirstMatch(/Roku\/DVP-(\d+\.\d+)/i,e);return{name:o.OS_MAP.Roku,version:t}}},{test:[/windows phone/i],describe:function(e){var t=i.default.getFirstMatch(/windows phone (?:os)?\s?(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.WindowsPhone,version:t}}},{test:[/windows /i],describe:function(e){var t=i.default.getFirstMatch(/Windows ((NT|XP)( \d\d?.\d)?)/i,e),r=i.default.getWindowsVersionName(t);return{name:o.OS_MAP.Windows,version:t,versionName:r}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(e){var t={name:o.OS_MAP.iOS},r=i.default.getSecondMatch(/(Version\/)(\d[\d.]+)/,e);return r&&(t.version=r),t}},{test:[/macintosh/i],describe:function(e){var t=i.default.getFirstMatch(/mac os x (\d+(\.?_?\d+)+)/i,e).replace(/[_\s]/g,"."),r=i.default.getMacOSVersionName(t),n={name:o.OS_MAP.MacOS,version:t};return r&&(n.versionName=r),n}},{test:[/(ipod|iphone|ipad)/i],describe:function(e){var t=i.default.getFirstMatch(/os (\d+([_\s]\d+)*) like mac os x/i,e).replace(/[_\s]/g,".");return{name:o.OS_MAP.iOS,version:t}}},{test:function(e){var t=!e.test(/like android/i),r=e.test(/android/i);return t&&r},describe:function(e){var t=i.default.getFirstMatch(/android[\s/-](\d+(\.\d+)*)/i,e),r=i.default.getAndroidVersionName(t),n={name:o.OS_MAP.Android,version:t};return r&&(n.versionName=r),n}},{test:[/(web|hpw)[o0]s/i],describe:function(e){var t=i.default.getFirstMatch(/(?:web|hpw)[o0]s\/(\d+(\.\d+)*)/i,e),r={name:o.OS_MAP.WebOS};return t&&t.length&&(r.version=t),r}},{test:[/blackberry|\bbb\d+/i,/rim\stablet/i],describe:function(e){var t=i.default.getFirstMatch(/rim\stablet\sos\s(\d+(\.\d+)*)/i,e)||i.default.getFirstMatch(/blackberry\d+\/(\d+([_\s]\d+)*)/i,e)||i.default.getFirstMatch(/\bbb(\d+)/i,e);return{name:o.OS_MAP.BlackBerry,version:t}}},{test:[/bada/i],describe:function(e){var t=i.default.getFirstMatch(/bada\/(\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Bada,version:t}}},{test:[/tizen/i],describe:function(e){var t=i.default.getFirstMatch(/tizen[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.Tizen,version:t}}},{test:[/linux/i],describe:function(){return{name:o.OS_MAP.Linux}}},{test:[/CrOS/],describe:function(){return{name:o.OS_MAP.ChromeOS}}},{test:[/PlayStation 4/],describe:function(e){var t=i.default.getFirstMatch(/PlayStation 4[/\s](\d+(\.\d+)*)/i,e);return{name:o.OS_MAP.PlayStation4,version:t}}}];t.default=a,e.exports=t.default},94:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:[/googlebot/i],describe:function(){return{type:"bot",vendor:"Google"}}},{test:[/huawei/i],describe:function(e){var t=i.default.getFirstMatch(/(can-l01)/i,e)&&"Nova",r={type:o.PLATFORMS_MAP.mobile,vendor:"Huawei"};return t&&(r.model=t),r}},{test:[/nexus\s*(?:7|8|9|10).*/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Nexus"}}},{test:[/ipad/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/Macintosh(.*?) FxiOS(.*?)\//],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Apple",model:"iPad"}}},{test:[/kftt build/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon",model:"Kindle Fire HD 7"}}},{test:[/silk/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet,vendor:"Amazon"}}},{test:[/tablet(?! pc)/i],describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){var t=e.test(/ipod|iphone/i),r=e.test(/like (ipod|iphone)/i);return t&&!r},describe:function(e){var t=i.default.getFirstMatch(/(ipod|iphone)/i,e);return{type:o.PLATFORMS_MAP.mobile,vendor:"Apple",model:t}}},{test:[/nexus\s*[0-6].*/i,/galaxy nexus/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Nexus"}}},{test:[/[^-]mobi/i],describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"blackberry"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"BlackBerry"}}},{test:function(e){return"bada"===e.getBrowserName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"windows phone"===e.getBrowserName()},describe:function(){return{type:o.PLATFORMS_MAP.mobile,vendor:"Microsoft"}}},{test:function(e){var t=Number(String(e.getOSVersion()).split(".")[0]);return"android"===e.getOSName(!0)&&t>=3},describe:function(){return{type:o.PLATFORMS_MAP.tablet}}},{test:function(e){return"android"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.mobile}}},{test:function(e){return"macos"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop,vendor:"Apple"}}},{test:function(e){return"windows"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"linux"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.desktop}}},{test:function(e){return"playstation 4"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}},{test:function(e){return"roku"===e.getOSName(!0)},describe:function(){return{type:o.PLATFORMS_MAP.tv}}}];t.default=a,e.exports=t.default},95:function(e,t,r){"use strict";t.__esModule=!0,t.default=void 0;var n,i=(n=r(17))&&n.__esModule?n:{default:n},o=r(18),a=[{test:function(e){return"microsoft edge"===e.getBrowserName(!0)},describe:function(e){if(/\sedg\//i.test(e))return{name:o.ENGINE_MAP.Blink};var t=i.default.getFirstMatch(/edge\/(\d+(\.?_?\d+)+)/i,e);return{name:o.ENGINE_MAP.EdgeHTML,version:t}}},{test:[/trident/i],describe:function(e){var t={name:o.ENGINE_MAP.Trident},r=i.default.getFirstMatch(/trident\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){return e.test(/presto/i)},describe:function(e){var t={name:o.ENGINE_MAP.Presto},r=i.default.getFirstMatch(/presto\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:function(e){var t=e.test(/gecko/i),r=e.test(/like gecko/i);return t&&!r},describe:function(e){var t={name:o.ENGINE_MAP.Gecko},r=i.default.getFirstMatch(/gecko\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}},{test:[/(apple)?webkit\/537\.36/i],describe:function(){return{name:o.ENGINE_MAP.Blink}}},{test:[/(apple)?webkit/i],describe:function(e){var t={name:o.ENGINE_MAP.WebKit},r=i.default.getFirstMatch(/webkit\/(\d+(\.?_?\d+)+)/i,e);return r&&(t.version=r),t}}];t.default=a,e.exports=t.default}})}]); \ No newline at end of file diff --git a/packages/suite/package.json b/packages/suite/package.json index 882a596647d..5c8ce54c5e3 100644 --- a/packages/suite/package.json +++ b/packages/suite/package.json @@ -54,7 +54,7 @@ "redux-thunk": "^2.3.0", "styled-components": "5.1.1", "trezor-address-validator": "^0.3.22", - "trezor-connect": "8.1.24-extended", + "trezor-connect": "8.1.25-extended", "uuid": "^8.3.2", "web3-utils": "^1.2.6", "zxcvbn": "^4.4.2" diff --git a/yarn.lock b/yarn.lock index 7ae54a2b1a0..bd9eb2a6500 100644 --- a/yarn.lock +++ b/yarn.lock @@ -21985,10 +21985,10 @@ trezor-address-validator@^0.3.22: jssha "2.3.1" lodash "^4.17.15" -trezor-connect@8.1.24-extended: - version "8.1.24-extended" - resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-8.1.24-extended.tgz#0191c51528aab8ed94a3cae8ea663340893299b2" - integrity sha512-puptEtlhY0qjZUFYLgFUSHjy4CyJ+uVuCmnaVO+1J2OqXcconXIArH3frrqTgTPCxiisoDoRl2S3aKQBH/N2rQ== +trezor-connect@8.1.25-extended: + version "8.1.25-extended" + resolved "https://registry.yarnpkg.com/trezor-connect/-/trezor-connect-8.1.25-extended.tgz#a20d7e32c56b863d16d6783db4a6538f4bc31b51" + integrity sha512-wRdyNid0bpaUAF8ExUNu8FOh97DiznaEnRIPYjDmIZL/ValJIzyROUxNCznA+6I1ilg+wfEb6LOpTWQkwbrPyA== dependencies: "@babel/runtime" "^7.12.5" "@trezor/blockchain-link" "^1.0.17"