diff --git a/.babelrc b/.babelrc new file mode 100644 index 000000000..c99adb87c --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": [["@babel/env", { "modules": false }]] +} diff --git a/dist/cjs/index.js b/dist/cjs/index.js new file mode 100644 index 000000000..91f6911e9 --- /dev/null +++ b/dist/cjs/index.js @@ -0,0 +1,3482 @@ +'use strict'; + +function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; } + +var blocknativeApi = _interopDefault(require('bn-sdk')); +var internal = require('svelte/internal'); +var store = require('svelte/store'); +var ow = _interopDefault(require('ow')); +var transition = require('svelte/transition'); +var bowser = _interopDefault(require('bowser')); + +function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); +} + +function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { + try { + var info = gen[key](arg); + var value = info.value; + } catch (error) { + reject(error); + return; + } + + if (info.done) { + resolve(value); + } else { + Promise.resolve(value).then(_next, _throw); + } +} + +function _asyncToGenerator(fn) { + return function () { + var self = this, + args = arguments; + return new Promise(function (resolve, reject) { + var gen = fn.apply(self, args); + + function _next(value) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); + } + + function _throw(err) { + asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); + } + + _next(undefined); + }); + }; +} + +function _defineProperty(obj, key, value) { + if (key in obj) { + Object.defineProperty(obj, key, { + value: value, + enumerable: true, + configurable: true, + writable: true + }); + } else { + obj[key] = value; + } + + return obj; +} + +function ownKeys(object, enumerableOnly) { + var keys = Object.keys(object); + + if (Object.getOwnPropertySymbols) { + var symbols = Object.getOwnPropertySymbols(object); + if (enumerableOnly) symbols = symbols.filter(function (sym) { + return Object.getOwnPropertyDescriptor(object, sym).enumerable; + }); + keys.push.apply(keys, symbols); + } + + return keys; +} + +function _objectSpread2(target) { + for (var i = 1; i < arguments.length; i++) { + var source = arguments[i] != null ? arguments[i] : {}; + + if (i % 2) { + ownKeys(source, true).forEach(function (key) { + _defineProperty(target, key, source[key]); + }); + } else if (Object.getOwnPropertyDescriptors) { + Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); + } else { + ownKeys(source).forEach(function (key) { + Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); + }); + } + } + + return target; +} + +function _objectWithoutPropertiesLoose(source, excluded) { + if (source == null) return {}; + var target = {}; + var sourceKeys = Object.keys(source); + var key, i; + + for (i = 0; i < sourceKeys.length; i++) { + key = sourceKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + target[key] = source[key]; + } + + return target; +} + +function _objectWithoutProperties(source, excluded) { + if (source == null) return {}; + + var target = _objectWithoutPropertiesLoose(source, excluded); + + var key, i; + + if (Object.getOwnPropertySymbols) { + var sourceSymbolKeys = Object.getOwnPropertySymbols(source); + + for (i = 0; i < sourceSymbolKeys.length; i++) { + key = sourceSymbolKeys[i]; + if (excluded.indexOf(key) >= 0) continue; + if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; + target[key] = source[key]; + } + } + + return target; +} + +function validateInit(init) { + ow(init, "Initialization Options", ow.object.exactShape({ + networkId: ow.number, + dappId: ow.string, + subscriptions: ow.optional.object.exactShape({ + address: ow.optional["function"], + network: ow.optional["function"], + balance: ow.optional["function"], + provider: ow.optional["function"] + }), + modules: ow.object.exactShape({ + selectWallet: ow.object.exactShape({ + heading: ow.string, + description: ow.string, + wallets: ow.object.exactShape({ + mobile: ow.optional.array.nonEmpty.ofType(ow.object.exactShape({ + name: ow.string, + iconSrc: ow.optional.string, + iconSrcSet: ow.optional.string, + svg: ow.optional.string, + wallet: ow["function"], + link: ow.optional.string, + installMessage: ow.optional["function"] + })), + desktop: ow.optional.array.nonEmpty.ofType(ow.object.exactShape({ + name: ow.string, + iconSrc: ow.optional.string, + iconSrcSet: ow.optional.string, + svg: ow.optional.string, + wallet: ow["function"], + link: ow.optional.string, + installMessage: ow.optional["function"] + })) + }) + }), + prepareWallet: ow.array.nonEmpty.ofType(ow["function"]) + }) + })); +} +function validateConfig(configuration) { + ow(configuration, "config", ow.object.exactShape({ + darkMode: ow["boolean"] + })); +} +function validateModal(modal) { + var _ow$object$exactShape; + + ow(modal, "modal", ow.object.exactShape((_ow$object$exactShape = { + img: ow.optional.string, + heading: ow.string, + description: ow.string, + button: ow.optional.string, + invalidMsg: ow.optional.string, + eventCode: ow.string, + action: ow.optional["function"] + }, _defineProperty(_ow$object$exactShape, "button", ow.optional.object.exactShape({ + onclick: ow["function"], + text: ow.string + })), _defineProperty(_ow$object$exactShape, "icon", ow.optional.string), _ow$object$exactShape))); +} +function validateWalletInterface(walletInterface) { + ow(walletInterface, "wallet interface", ow.object.exactShape({ + name: ow.string, + connect: ow.optional["function"], + address: ow.object.hasAnyKeys("get", "onChange").valuesOfType(ow["function"]), + network: ow.object.hasAnyKeys("get", "onChange").valuesOfType(ow["function"]), + balance: ow.object.hasAnyKeys("get", "onChange").valuesOfType(ow["function"]) + })); +} + +var app = store.writable({ + dappId: null, + networkId: null, + version: null, + selectWallet: false, + selectWalletCompleted: false, + prepareWallet: false, + prepareWalletCompleted: false, + modules: null +}); +var configuration = store.writable({ + darkMode: false +}); +var address = createUserStateStore("address"); +var network = createUserStateStore("network"); +var balance = createUserStateStore("balance"); +var provider = store.writable(null); +var state = createState({ + mobileDevice: null, + walletName: null, + address: null, + network: null, + balance: null, + connect: null, + provider: null +}); // make sure state store is updated when any of these change + +address.subscribe(function (value) { + return state.update({ + address: value + }); +}); +network.subscribe(function (value) { + return state.update({ + network: value + }); +}); +balance.subscribe(function (value) { + return state.update({ + balance: value + }); +}); +provider.subscribe(function (value) { + return state.update({ + provider: value + }); +}); // keep track of intervals that are syncing state so they can be cleared + +var currentSyncerIntervals = []; +var walletInterface = createWalletInterfaceStore(null); +walletInterface.subscribe(function (wallet) { + if (wallet) { + // clear all current intervals if they exist + currentSyncerIntervals.forEach(function (clearInterval) { + return clearInterval && clearInterval(); + }); // start syncing state and save intervals + + currentSyncerIntervals = [address.setStateSyncer(wallet.address), network.setStateSyncer(wallet.network), balance.setStateSyncer(wallet.balance)]; + state.update({ + connect: wallet.connect, + walletName: wallet.name + }); + } +}); + +function createState(initialState) { + var state = initialState; + var subscribers = []; + return { + get: function get() { + return state; + }, + subscribe: function subscribe(func) { + if (!func) return; + subscribers.push(func); + return function () { + subscribers = subscribers.filter(function (f) { + return f !== func; + }); + }; + }, + update: function update(newState) { + state = _objectSpread2({}, state, {}, newState); + subscribers.forEach(function (sub) { + return sub(state); + }); + return state; + } + }; +} + +function createWalletInterfaceStore(initialState) { + var _writable = store.writable(initialState), + subscribe = _writable.subscribe, + _set = _writable.set; + + return { + subscribe: subscribe, + set: function set(walletInterface) { + validateWalletInterface(walletInterface); + + _set(walletInterface); + } + }; +} + +function createUserStateStore(parameter) { + var _writable2 = store.writable(null), + subscribe = _writable2.subscribe, + set = _writable2.set; + + return { + subscribe: subscribe, + setStateSyncer: function setStateSyncer(stateSyncer) { + if (!stateSyncer || _typeof(stateSyncer) !== "object") { + throw new Error("setStateSyncer must be called with a valid interface"); + } + + if (stateSyncer.onChange) { + stateSyncer.onChange(set); + return; + } + + if (stateSyncer.get) { + var interval = setInterval(function () { + stateSyncer.get().then(set)["catch"](function (err) { + throw new Error("Error getting ".concat(parameter, " from state syncer: ").concat(err)); + }); + }, 250); + return function () { + return clearInterval(interval); + }; + } + } + }; +} + +/* src/components/Modal.svelte generated by Svelte v3.12.1 */ + +function add_css() { + var style = internal.element("style"); + style.id = 'svelte-1iuesc6-style'; + style.textContent = "aside.svelte-1iuesc6{display:flex;justify-content:center;align-items:center;position:absolute;z-index:10;top:0;left:0;width:100vw;height:100vh;background:rgba(0, 0, 0, 0.3)}section.svelte-1iuesc6{background:#ffffff;border-radius:10px;box-shadow:0 1px 5px 0 rgba(0, 0, 0, 0.1);font-family:\"Helvetica Neue\";padding:1.33rem;position:relative;overflow:hidden;max-width:36rem;color:#4a4a4a}div.svelte-1iuesc6{height:0.66rem;position:absolute;padding:0.8rem;top:1.33rem;right:1.33rem;border-radius:5px;transition:background 200ms ease-in-out;display:flex;justify-content:center;align-items:center}div.svelte-1iuesc6:hover{cursor:pointer;background:#eeeeee}svg.svelte-1iuesc6{width:10px;height:10px}.bn-onboard-dark-mode-close-background.svelte-1iuesc6:hover{background:#00222c}"; + internal.append(document.head, style); +} + +function create_fragment(ctx) { + var aside, section, t, div, svg, g0, path, g1, g2, g3, g4, g5, g6, g7, g8, g9, g10, g11, g12, g13, g14, g15, svg_fill_value, aside_transition, current, dispose; + + const default_slot_template = ctx.$$slots.default; + const default_slot = internal.create_slot(default_slot_template, ctx, null); + + return { + c() { + aside = internal.element("aside"); + section = internal.element("section"); + + if (default_slot) default_slot.c(); + t = internal.space(); + div = internal.element("div"); + svg = internal.svg_element("svg"); + g0 = internal.svg_element("g"); + path = internal.svg_element("path"); + g1 = internal.svg_element("g"); + g2 = internal.svg_element("g"); + g3 = internal.svg_element("g"); + g4 = internal.svg_element("g"); + g5 = internal.svg_element("g"); + g6 = internal.svg_element("g"); + g7 = internal.svg_element("g"); + g8 = internal.svg_element("g"); + g9 = internal.svg_element("g"); + g10 = internal.svg_element("g"); + g11 = internal.svg_element("g"); + g12 = internal.svg_element("g"); + g13 = internal.svg_element("g"); + g14 = internal.svg_element("g"); + g15 = internal.svg_element("g"); + + internal.attr(path, "d", "M28.228,23.986L47.092,5.122c1.172-1.171,1.172-3.071,0-4.242c-1.172-1.172-3.07-1.172-4.242,0L23.986,19.744L5.121,0.88\n c-1.172-1.172-3.07-1.172-4.242,0c-1.172,1.171-1.172,3.071,0,4.242l18.865,18.864L0.879,42.85c-1.172,1.171-1.172,3.071,0,4.242\n C1.465,47.677,2.233,47.97,3,47.97s1.535-0.293,2.121-0.879l18.865-18.864L42.85,47.091c0.586,0.586,1.354,0.879,2.121,0.879\n s1.535-0.293,2.121-0.879c1.172-1.171,1.172-3.071,0-4.242L28.228,23.986z"); + internal.attr(svg, "version", "1.1"); + internal.attr(svg, "id", "Capa_1"); + internal.attr(svg, "xmlns", "http://www.w3.org/2000/svg"); + internal.attr(svg, "xmlns:xlink", "http://www.w3.org/1999/xlink"); + internal.attr(svg, "x", "0px"); + internal.attr(svg, "y", "0px"); + internal.attr(svg, "viewBox", "0 0 47.971 47.971"); + internal.set_style(svg, "enable-background", "new 0 0 47.971 47.971"); + internal.set_style(svg, "transition", "fill 150ms\n ease-in-out"); + internal.attr(svg, "fill", svg_fill_value = ctx.closeHovered ? (ctx.$configuration.darkMode ? '#ffffff' : '#4a4a4a') : '#9B9B9B'); + internal.attr(svg, "xml:space", "preserve"); + internal.attr(svg, "class", "svelte-1iuesc6"); + internal.attr(div, "class", "bn-onboard-custom bn-onboard-modal-content-close svelte-1iuesc6"); + internal.toggle_class(div, "bn-onboard-dark-mode-close-background", ctx.$configuration.darkMode); + internal.attr(section, "class", "bn-onboard-custom bn-onboard-modal-content svelte-1iuesc6"); + internal.toggle_class(section, "bn-onboard-dark-mode", ctx.$configuration.darkMode); + internal.attr(aside, "class", "bn-onboard-custom bn-onboard-modal svelte-1iuesc6"); + + dispose = [ + internal.listen(div, "click", ctx.closeModal), + internal.listen(div, "mouseenter", ctx.mouseenter_handler), + internal.listen(div, "mouseleave", ctx.mouseleave_handler) + ]; + }, + + l(nodes) { + if (default_slot) default_slot.l(section_nodes); + }, + + m(target, anchor) { + internal.insert(target, aside, anchor); + internal.append(aside, section); + + if (default_slot) { + default_slot.m(section, null); + } + + internal.append(section, t); + internal.append(section, div); + internal.append(div, svg); + internal.append(svg, g0); + internal.append(g0, path); + internal.append(svg, g1); + internal.append(svg, g2); + internal.append(svg, g3); + internal.append(svg, g4); + internal.append(svg, g5); + internal.append(svg, g6); + internal.append(svg, g7); + internal.append(svg, g8); + internal.append(svg, g9); + internal.append(svg, g10); + internal.append(svg, g11); + internal.append(svg, g12); + internal.append(svg, g13); + internal.append(svg, g14); + internal.append(svg, g15); + current = true; + }, + + p(changed, ctx) { + if (default_slot && default_slot.p && changed.$$scope) { + default_slot.p( + internal.get_slot_changes(default_slot_template, ctx, changed, null), + internal.get_slot_context(default_slot_template, ctx, null) + ); + } + + if ((!current || changed.closeHovered || changed.$configuration) && svg_fill_value !== (svg_fill_value = ctx.closeHovered ? (ctx.$configuration.darkMode ? '#ffffff' : '#4a4a4a') : '#9B9B9B')) { + internal.attr(svg, "fill", svg_fill_value); + } + + if (changed.$configuration) { + internal.toggle_class(div, "bn-onboard-dark-mode-close-background", ctx.$configuration.darkMode); + internal.toggle_class(section, "bn-onboard-dark-mode", ctx.$configuration.darkMode); + } + }, + + i(local) { + if (current) return; + internal.transition_in(default_slot, local); + + internal.add_render_callback(() => { + if (!aside_transition) aside_transition = internal.create_bidirectional_transition(aside, transition.fade, {}, true); + aside_transition.run(1); + }); + + current = true; + }, + + o(local) { + internal.transition_out(default_slot, local); + + if (!aside_transition) aside_transition = internal.create_bidirectional_transition(aside, transition.fade, {}, false); + aside_transition.run(0); + + current = false; + }, + + d(detaching) { + if (detaching) { + internal.detach(aside); + } + + if (default_slot) default_slot.d(detaching); + + if (detaching) { + if (aside_transition) aside_transition.end(); + } + + internal.run_all(dispose); + } + }; +} + +function instance($$self, $$props, $$invalidate) { + let $configuration; + + internal.component_subscribe($$self, configuration, $$value => { $configuration = $$value; $$invalidate('$configuration', $configuration); }); + + + let { closeModal } = $$props; + + let closeHovered; + + let { $$slots = {}, $$scope } = $$props; + + const mouseenter_handler = () => ($$invalidate('closeHovered', closeHovered = true)); + + const mouseleave_handler = () => ($$invalidate('closeHovered', closeHovered = false)); + + $$self.$set = $$props => { + if ('closeModal' in $$props) $$invalidate('closeModal', closeModal = $$props.closeModal); + if ('$$scope' in $$props) $$invalidate('$$scope', $$scope = $$props.$$scope); + }; + + return { + closeModal, + closeHovered, + $configuration, + mouseenter_handler, + mouseleave_handler, + $$slots, + $$scope + }; +} + +class Modal extends internal.SvelteComponent { + constructor(options) { + super(); + if (!document.getElementById("svelte-1iuesc6-style")) add_css(); + internal.init(this, options, instance, create_fragment, internal.safe_not_equal, ["closeModal"]); + } +} + +/* src/components/ModalHeader.svelte generated by Svelte v3.12.1 */ + +function add_css$1() { + var style = internal.element("style"); + style.id = 'svelte-14pgfgy-style'; + style.textContent = "header.svelte-14pgfgy{display:flex;align-items:center;margin-bottom:0.66rem}div.svelte-14pgfgy{display:flex;justify-content:center;align-items:center;padding:0.6rem;border-radius:30px;background:#eeeeee}h3.svelte-14pgfgy{font-weight:bold;font-size:1.33rem;margin:0 0 0 0.5rem}"; + internal.append(document.head, style); +} + +function create_fragment$1(ctx) { + var header, div, t0, h3, t1; + + return { + c() { + header = internal.element("header"); + div = internal.element("div"); + t0 = internal.space(); + h3 = internal.element("h3"); + t1 = internal.text(ctx.heading); + internal.attr(div, "class", "bn-onboard-custom bn-onboard-modal-content-header-icon svelte-14pgfgy"); + internal.toggle_class(div, "bn-onboard-dark-mode-background", ctx.$configuration.darkMode); + internal.attr(h3, "class", "bn-onboard-custom bn-onboard-modal-content-header-heading svelte-14pgfgy"); + internal.attr(header, "class", "bn-onboard-custom bn-onboard-modal-content-header svelte-14pgfgy"); + }, + + m(target, anchor) { + internal.insert(target, header, anchor); + internal.append(header, div); + div.innerHTML = ctx.icon; + internal.append(header, t0); + internal.append(header, h3); + internal.append(h3, t1); + }, + + p(changed, ctx) { + if (changed.icon) { + div.innerHTML = ctx.icon; + } + + if (changed.$configuration) { + internal.toggle_class(div, "bn-onboard-dark-mode-background", ctx.$configuration.darkMode); + } + + if (changed.heading) { + internal.set_data(t1, ctx.heading); + } + }, + + i: internal.noop, + o: internal.noop, + + d(detaching) { + if (detaching) { + internal.detach(header); + } + } + }; +} + +function instance$1($$self, $$props, $$invalidate) { + let $configuration; + + internal.component_subscribe($$self, configuration, $$value => { $configuration = $$value; $$invalidate('$configuration', $configuration); }); + + let { heading, icon } = $$props; + + $$self.$set = $$props => { + if ('heading' in $$props) $$invalidate('heading', heading = $$props.heading); + if ('icon' in $$props) $$invalidate('icon', icon = $$props.icon); + }; + + return { heading, icon, $configuration }; +} + +class ModalHeader extends internal.SvelteComponent { + constructor(options) { + super(); + if (!document.getElementById("svelte-14pgfgy-style")) add_css$1(); + internal.init(this, options, instance$1, create_fragment$1, internal.safe_not_equal, ["heading", "icon"]); + } +} + +/* src/elements/Button.svelte generated by Svelte v3.12.1 */ + +function add_css$2() { + var style = internal.element("style"); + style.id = 'svelte-v6p7u9-style'; + style.textContent = "button.svelte-v6p7u9{background:inherit;font-size:0.889rem;border:1px solid #4a90e2;border-radius:40px;padding:0.55rem 1.4rem;margin-top:0.33rem;cursor:pointer;color:#4a90e2;transition:background 150ms ease-in-out}button.svelte-v6p7u9:focus{outline:none}button.svelte-v6p7u9:hover{background:#ecf3fc}"; + internal.append(document.head, style); +} + +function create_fragment$2(ctx) { + var button, current, dispose; + + const default_slot_template = ctx.$$slots.default; + const default_slot = internal.create_slot(default_slot_template, ctx, null); + + return { + c() { + button = internal.element("button"); + + if (default_slot) default_slot.c(); + + internal.attr(button, "class", "bn-onboard-custom bn-onboard-button svelte-v6p7u9"); + internal.toggle_class(button, "bn-onboard-dark-mode-link", ctx.$configuration.darkMode); + internal.toggle_class(button, "bn-onboard-dark-mode-background-hover", ctx.$configuration.darkMode); + dispose = internal.listen(button, "click", ctx.onclick); + }, + + l(nodes) { + if (default_slot) default_slot.l(button_nodes); + }, + + m(target, anchor) { + internal.insert(target, button, anchor); + + if (default_slot) { + default_slot.m(button, null); + } + + current = true; + }, + + p(changed, ctx) { + if (default_slot && default_slot.p && changed.$$scope) { + default_slot.p( + internal.get_slot_changes(default_slot_template, ctx, changed, null), + internal.get_slot_context(default_slot_template, ctx, null) + ); + } + + if (changed.$configuration) { + internal.toggle_class(button, "bn-onboard-dark-mode-link", ctx.$configuration.darkMode); + internal.toggle_class(button, "bn-onboard-dark-mode-background-hover", ctx.$configuration.darkMode); + } + }, + + i(local) { + if (current) return; + internal.transition_in(default_slot, local); + current = true; + }, + + o(local) { + internal.transition_out(default_slot, local); + current = false; + }, + + d(detaching) { + if (detaching) { + internal.detach(button); + } + + if (default_slot) default_slot.d(detaching); + dispose(); + } + }; +} + +function instance$2($$self, $$props, $$invalidate) { + let $configuration; + + internal.component_subscribe($$self, configuration, $$value => { $configuration = $$value; $$invalidate('$configuration', $configuration); }); + + let { highlight = false, onclick = null } = $$props; + + let { $$slots = {}, $$scope } = $$props; + + $$self.$set = $$props => { + if ('highlight' in $$props) $$invalidate('highlight', highlight = $$props.highlight); + if ('onclick' in $$props) $$invalidate('onclick', onclick = $$props.onclick); + if ('$$scope' in $$props) $$invalidate('$$scope', $$scope = $$props.$$scope); + }; + + return { + highlight, + onclick, + $configuration, + $$slots, + $$scope + }; +} + +class Button extends internal.SvelteComponent { + constructor(options) { + super(); + if (!document.getElementById("svelte-v6p7u9-style")) add_css$2(); + internal.init(this, options, instance$2, create_fragment$2, internal.safe_not_equal, ["highlight", "onclick"]); + } +} + +/* src/elements/IconButton.svelte generated by Svelte v3.12.1 */ + +function add_css$3() { + var style = internal.element("style"); + style.id = 'svelte-1lc48tf-style'; + style.textContent = "button.svelte-1lc48tf{display:flex;align-items:center;border:none;margin:0.33rem 0;background:inherit;width:18rem;padding:0.625rem 1.25rem;transition:box-shadow 150ms ease-in-out, background 200ms ease-in-out;border-radius:40px;cursor:pointer;color:inherit}button.svelte-1lc48tf:hover{box-shadow:0 2px 10px 0 rgba(0, 0, 0, 0.1)}button.svelte-1lc48tf:focus{outline:none}div.svelte-1lc48tf{justify-content:center;align-items:center;text-align:center;height:40px;width:40px;line-height:40px}img.svelte-1lc48tf{max-height:100%;max-width:100%;vertical-align:middle}span.svelte-1lc48tf{margin-left:0.66rem;font-weight:bold;font-size:1rem;text-align:left}@media only screen and (max-width: 700px){button.svelte-1lc48tf{width:100%}}"; + internal.append(document.head, style); +} + +// (70:4) {:else} +function create_else_block(ctx) { + var img; + + return { + c() { + img = internal.element("img"); + internal.attr(img, "src", ctx.iconSrc); + internal.attr(img, "srcset", ctx.iconSrcSet); + internal.attr(img, "alt", ctx.text); + internal.attr(img, "class", "svelte-1lc48tf"); + }, + + m(target, anchor) { + internal.insert(target, img, anchor); + }, + + p(changed, ctx) { + if (changed.iconSrc) { + internal.attr(img, "src", ctx.iconSrc); + } + + if (changed.iconSrcSet) { + internal.attr(img, "srcset", ctx.iconSrcSet); + } + + if (changed.text) { + internal.attr(img, "alt", ctx.text); + } + }, + + d(detaching) { + if (detaching) { + internal.detach(img); + } + } + }; +} + +// (68:4) {#if svg} +function create_if_block(ctx) { + var html_tag; + + return { + c() { + html_tag = new internal.HtmlTag(ctx.svg, null); + }, + + m(target, anchor) { + html_tag.m(target, anchor); + }, + + p(changed, ctx) { + if (changed.svg) { + html_tag.p(ctx.svg); + } + }, + + d(detaching) { + if (detaching) { + html_tag.d(); + } + } + }; +} + +function create_fragment$3(ctx) { + var button, div, t0, span, t1, dispose; + + function select_block_type(changed, ctx) { + if (ctx.svg) return create_if_block; + return create_else_block; + } + + var current_block_type = select_block_type(null, ctx); + var if_block = current_block_type(ctx); + + return { + c() { + button = internal.element("button"); + div = internal.element("div"); + if_block.c(); + t0 = internal.space(); + span = internal.element("span"); + t1 = internal.text(ctx.text); + internal.attr(div, "class", "svelte-1lc48tf"); + internal.attr(span, "class", "svelte-1lc48tf"); + internal.attr(button, "class", "bn-onboard-custom bn-onboard-icon-button svelte-1lc48tf"); + internal.toggle_class(button, "bn-onboard-dark-mode-background-hover", ctx.$configuration.darkMode); + dispose = internal.listen(button, "click", ctx.onclick); + }, + + m(target, anchor) { + internal.insert(target, button, anchor); + internal.append(button, div); + if_block.m(div, null); + internal.append(button, t0); + internal.append(button, span); + internal.append(span, t1); + }, + + p(changed, ctx) { + if (current_block_type === (current_block_type = select_block_type(changed, ctx)) && if_block) { + if_block.p(changed, ctx); + } else { + if_block.d(1); + if_block = current_block_type(ctx); + if (if_block) { + if_block.c(); + if_block.m(div, null); + } + } + + if (changed.text) { + internal.set_data(t1, ctx.text); + } + + if (changed.$configuration) { + internal.toggle_class(button, "bn-onboard-dark-mode-background-hover", ctx.$configuration.darkMode); + } + }, + + i: internal.noop, + o: internal.noop, + + d(detaching) { + if (detaching) { + internal.detach(button); + } + + if_block.d(); + dispose(); + } + }; +} + +function instance$3($$self, $$props, $$invalidate) { + let $configuration; + + internal.component_subscribe($$self, configuration, $$value => { $configuration = $$value; $$invalidate('$configuration', $configuration); }); + + let { iconSrc, iconSrcSet = null, svg, onclick = null, text } = $$props; + + $$self.$set = $$props => { + if ('iconSrc' in $$props) $$invalidate('iconSrc', iconSrc = $$props.iconSrc); + if ('iconSrcSet' in $$props) $$invalidate('iconSrcSet', iconSrcSet = $$props.iconSrcSet); + if ('svg' in $$props) $$invalidate('svg', svg = $$props.svg); + if ('onclick' in $$props) $$invalidate('onclick', onclick = $$props.onclick); + if ('text' in $$props) $$invalidate('text', text = $$props.text); + }; + + return { + iconSrc, + iconSrcSet, + svg, + onclick, + text, + $configuration + }; +} + +class IconButton extends internal.SvelteComponent { + constructor(options) { + super(); + if (!document.getElementById("svelte-1lc48tf-style")) add_css$3(); + internal.init(this, options, instance$3, create_fragment$3, internal.safe_not_equal, ["iconSrc", "iconSrcSet", "svg", "onclick", "text"]); + } +} + +/* src/components/Wallets.svelte generated by Svelte v3.12.1 */ + +function add_css$4() { + var style = internal.element("style"); + style.id = 'svelte-a3m86z-style'; + style.textContent = "ul.svelte-a3m86z{display:flex;flex-flow:row wrap;align-items:center;list-style-type:none;margin-bottom:0.66rem;padding:0}div.svelte-a3m86z{width:100%;display:flex;justify-content:center}@media only screen and (max-width: 700px){ul.svelte-a3m86z li.svelte-a3m86z{width:100%}}"; + internal.append(document.head, style); +} + +function get_each_context(ctx, list, i) { + const child_ctx = Object.create(ctx); + child_ctx.wallet = list[i]; + return child_ctx; +} + +function get_each_context_1(ctx, list, i) { + const child_ctx = Object.create(ctx); + child_ctx.wallet = list[i]; + return child_ctx; +} + +// (36:2) {#each modalData.walletModules as wallet} +function create_each_block_1(ctx) { + var li, li_intro, current; + + function func() { + return ctx.func(ctx); + } + + var iconbutton = new IconButton({ + props: { + onclick: func, + iconSrc: ctx.wallet.iconSrc, + iconSrcSet: ctx.wallet.iconSrcSet, + text: ctx.wallet.name + } + }); + + return { + c() { + li = internal.element("li"); + iconbutton.$$.fragment.c(); + internal.attr(li, "class", "svelte-a3m86z"); + }, + + m(target, anchor) { + internal.insert(target, li, anchor); + internal.mount_component(iconbutton, li, null); + current = true; + }, + + p(changed, new_ctx) { + ctx = new_ctx; + var iconbutton_changes = {}; + if (changed.handleWalletSelect || changed.modalData) iconbutton_changes.onclick = func; + if (changed.modalData) iconbutton_changes.iconSrc = ctx.wallet.iconSrc; + if (changed.modalData) iconbutton_changes.iconSrcSet = ctx.wallet.iconSrcSet; + if (changed.modalData) iconbutton_changes.text = ctx.wallet.name; + iconbutton.$set(iconbutton_changes); + }, + + i(local) { + if (current) return; + internal.transition_in(iconbutton.$$.fragment, local); + + if (!li_intro) { + internal.add_render_callback(() => { + li_intro = internal.create_in_transition(li, transition.fade, {}); + li_intro.start(); + }); + } + + current = true; + }, + + o(local) { + internal.transition_out(iconbutton.$$.fragment, local); + current = false; + }, + + d(detaching) { + if (detaching) { + internal.detach(li); + } + + internal.destroy_component(iconbutton); + } + }; +} + +// (46:2) {#if modalData.extraWalletModules && !showingAllWalletModules} +function create_if_block_1(ctx) { + var div, current; + + var button = new Button({ + props: { + highlight: true, + onclick: ctx.func_1, + $$slots: { default: [create_default_slot] }, + $$scope: { ctx } + } + }); + + return { + c() { + div = internal.element("div"); + button.$$.fragment.c(); + internal.attr(div, "class", "svelte-a3m86z"); + }, + + m(target, anchor) { + internal.insert(target, div, anchor); + internal.mount_component(button, div, null); + current = true; + }, + + p(changed, ctx) { + var button_changes = {}; + if (changed.showingAllWalletModules) button_changes.onclick = ctx.func_1; + if (changed.$$scope) button_changes.$$scope = { changed, ctx }; + button.$set(button_changes); + }, + + i(local) { + if (current) return; + internal.transition_in(button.$$.fragment, local); + + current = true; + }, + + o(local) { + internal.transition_out(button.$$.fragment, local); + current = false; + }, + + d(detaching) { + if (detaching) { + internal.detach(div); + } + + internal.destroy_component(button); + } + }; +} + +// (48:6) \n \n \n \n',document.body&&document.body.appendChild(n),n.getElementsByClassName("trezorconnect-open")[0].onclick=function(){t(),document.body&&document.body.removeChild(n)},n.getElementsByClassName("trezorconnect-close")[0].onclick=function(){e(),document.body&&document.body.removeChild(n)}}}});g(ft);ft.showPopupRequest;var ct={searchParams:"URLSearchParams"in self,iterable:"Symbol"in self&&"iterator"in Symbol,blob:"FileReader"in self&&"Blob"in self&&function(){try{return new Blob,!0}catch(t){return!1}}(),formData:"FormData"in self,arrayBuffer:"ArrayBuffer"in self};if(ct.arrayBuffer)var ht=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],lt=ArrayBuffer.isView||function(t){return t&&ht.indexOf(Object.prototype.toString.call(t))>-1};function dt(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function pt(t){return"string"!=typeof t&&(t=String(t)),t}function gt(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return ct.iterable&&(e[Symbol.iterator]=function(){return e}),e}function vt(t){this.map={},t instanceof vt?t.forEach(function(t,e){this.append(e,t)},this):Array.isArray(t)?t.forEach(function(t){this.append(t[0],t[1])},this):t&&Object.getOwnPropertyNames(t).forEach(function(e){this.append(e,t[e])},this)}function mt(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function yt(t){return new Promise(function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}})}function bt(t){var e=new FileReader,r=yt(e);return e.readAsArrayBuffer(t),r}function wt(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function At(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:ct.blob&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:ct.formData&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:ct.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():ct.arrayBuffer&&ct.blob&&((e=t)&&DataView.prototype.isPrototypeOf(e))?(this._bodyArrayBuffer=wt(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):ct.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(t)||lt(t))?this._bodyArrayBuffer=wt(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):ct.searchParams&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},ct.blob&&(this.blob=function(){var t=mt(this);if(t)return t;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?mt(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(bt)}),this.text=function(){var t,e,r,n=mt(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=yt(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.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 Mt(t){var e=new FormData;return t.trim().split("&").forEach(function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),i=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(i))}}),e}function It(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new vt(e.headers),this.url=e.url||"",this._initBody(t)}Et.prototype.clone=function(){return new Et(this,{body:this._bodyInit})},At.call(Et.prototype),At.call(It.prototype),It.prototype.clone=function(){return new It(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new vt(this.headers),url:this.url})},It.error=function(){var t=new It(null,{status:0,statusText:""});return t.type="error",t};var St=[301,302,303,307,308];It.redirect=function(t,e){if(-1===St.indexOf(e))throw new RangeError("Invalid status code");return new It(null,{status:e,headers:{location:t}})};var Tt=self.DOMException;try{new Tt}catch(t){(Tt=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack}).prototype=Object.create(Error.prototype),Tt.prototype.constructor=Tt}function Nt(t,e){return new Promise(function(r,n){var i=new Et(t,e);if(i.signal&&i.signal.aborted)return n(new Tt("Aborted","AbortError"));var o=new XMLHttpRequest;function a(){o.abort()}o.onload=function(){var t,e,n={status:o.status,statusText:o.statusText,headers:(t=o.getAllResponseHeaders()||"",e=new vt,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach(function(t){var r=t.split(":"),n=r.shift().trim();if(n){var i=r.join(":").trim();e.append(n,i)}}),e)};n.url="responseURL"in o?o.responseURL:n.headers.get("X-Request-URL");var i="response"in o?o.response:o.responseText;r(new It(i,n))},o.onerror=function(){n(new TypeError("Network request failed"))},o.ontimeout=function(){n(new TypeError("Network request failed"))},o.onabort=function(){n(new Tt("Aborted","AbortError"))},o.open(i.method,i.url,!0),"include"===i.credentials?o.withCredentials=!0:"omit"===i.credentials&&(o.withCredentials=!1),"responseType"in o&&ct.blob&&(o.responseType="blob"),i.headers.forEach(function(t,e){o.setRequestHeader(e,t)}),i.signal&&(i.signal.addEventListener("abort",a),o.onreadystatechange=function(){4===o.readyState&&i.signal.removeEventListener("abort",a)}),o.send(void 0===i._bodyInit?null:i._bodyInit)})}Nt.polyfill=!0,self.fetch||(self.fetch=Nt,self.Headers=vt,self.Request=Et,self.Response=It);var xt=v(function(t,e){e.__esModule=!0,e.getOrigin=e.httpRequest=void 0;var r=O(C),n=O(L),i=function(){var t=(0,n.default)(r.default.mark(function t(e,n){var i,o;return r.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===n&&(n="text"),t.next=3,fetch(e,{credentials:"same-origin"});case 3:if(!(i=t.sent).ok){t.next=23;break}if("json"!==n){t.next=12;break}return t.next=8,i.text();case 8:return o=t.sent,t.abrupt("return",JSON.parse(o));case 12:if("binary"!==n){t.next=18;break}return t.next=15,i.arrayBuffer();case 15:return t.abrupt("return",t.sent);case 18:return t.next=20,i.text();case 20:return t.abrupt("return",t.sent);case 21:t.next=24;break;case 23:throw new Error("httpRequest error: "+e+" "+i.statusText);case 24:case"end":return t.stop()}},t)}));return function(e,r){return t.apply(this,arguments)}}();e.httpRequest=i;e.getOrigin=function(t){var e=t.match(/^.+\:\/\/[^\/]+/);return Array.isArray(e)&&e.length>0?e[0]:"unknown"}});g(xt);xt.getOrigin,xt.httpRequest;var Pt=v(function(t,e){e.__esModule=!0,e.create=function(t,e){var i,o=function(t){},a=function(t){},s=new Promise(function(){var e=(0,n.default)(r.default.mark(function e(n,s){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n,a=s,"function"!=typeof t){e.next=11;break}return e.prev=3,e.next=6,t();case 6:e.next=11;break;case 8:e.prev=8,e.t0=e.catch(3),s(e.t0);case 11:"string"==typeof t&&(i=t);case 12:case"end":return e.stop()}},e,null,[[3,8]])}));return function(t,r){return e.apply(this,arguments)}}());return{id:i,device:e,resolve:o,reject:a,promise:s}},e.createAsync=function(t){var e=function(t){},i=function(t){},o=new Promise(function(t,r){e=t,i=r}),a=function(){var e=(0,n.default)(r.default.mark(function e(){return r.default.wrap(function(e){for(;;)switch(e.prev=e.next){case 0:return e.next=2,t();case 2:case"end":return e.stop()}},e)}));return function(){return e.apply(this,arguments)}}();return{resolve:e,reject:i,promise:o,run:function(){return a(),o}}},e.resolveTimeoutPromise=function(t,e){return new Promise(function(r){setTimeout(function(){r(e)},t)})},e.rejectTimeoutPromise=function(t,e){return new Promise(function(r,n){setTimeout(function(){n(e)},t)})};var r=O(C),n=O(L)});g(Pt);Pt.create,Pt.createAsync,Pt.resolveTimeoutPromise,Pt.rejectTimeoutPromise;var Ot=v(function(t,e){e.__esModule=!0,e.default=void 0;var r=O(C),n=O(L),i=O(ut),o=O(et),a=O(k),s=O(B),u=P(K),f=P(st),c=function(t){function e(e){var r;return r=t.call(this)||this,(0,a.default)((0,i.default)(r),"requestTimeout",0),(0,a.default)((0,i.default)(r),"closeInterval",0),(0,a.default)((0,i.default)(r),"extension",!1),(0,a.default)((0,i.default)(r),"extensionTabId",0),r.settings=e,r.src=e.popupSrc,r.origin=(0,xt.getOrigin)(e.popupSrc),r.handleLazyLoading=r.handleLazyLoading.bind((0,i.default)(r)),r.extension="undefined"!=typeof chrome&&chrome.runtime&&void 0!==chrome.runtime.onConnect,r.extension&&(r.handleExtensionConnect=r.handleExtensionConnect.bind((0,i.default)(r)),r.handleExtensionMessage=r.handleExtensionMessage.bind((0,i.default)(r)),chrome.runtime.onConnect.addListener(r.handleExtensionConnect)),r}(0,o.default)(e,t);var s=e.prototype;return s.request=function(t){var e=this;if(void 0===t&&(t=!1),this.locked)this._window&&(this.extension?chrome.tabs.update(this._window.id,{active:!0}):this._window.focus());else{this.lazyLoad=t?(0,Pt.create)(u.INIT):null,this.lazyLoad&&(this.extension||window.addEventListener("message",this.handleLazyLoading,!1));var r=this.open.bind(this);this.locked=!0,this.settings.supportedBrowser?this.requestTimeout=window.setTimeout(function(){e.requestTimeout=0,r()},t||this.extension?1:850):r()}},s.cancel=function(){this.close()},s.unlock=function(){this.locked=!1},s.open=function(){var t=this;this.settings.supportedBrowser?(this.openWrapper(this.lazyLoad?this.src+"#loading":this.src),this.closeInterval=window.setInterval(function(){t._window&&(t.extension?chrome.tabs.get(t._window.id,function(e){e||(t.close(),t.emit(u.CLOSED))}):t._window.closed&&(t.close(),t.emit(u.CLOSED)))},500),this.openTimeout=window.setTimeout(function(){t._window&&!t._window.closed||(t.close(),(0,ft.showPopupRequest)(t.open.bind(t),function(){t.emit(u.CLOSED)}))},2e3)):this.openWrapper(this.src+"#unsupported")},s.openWrapper=function(t){var e=this;this.extension?chrome.windows.getCurrent(null,function(r){"normal"!==r.type?chrome.windows.create({url:t},function(t){chrome.tabs.query({windowId:t.id,active:!0},function(t){e._window=t[0]})}):chrome.tabs.query({currentWindow:!0,active:!0},function(r){e.extensionTabId=r[0].id,chrome.tabs.create({url:t,index:r[0].index+1},function(t){e._window=t})})}):(this._window=window.open("","_blank"),this._window&&(this._window.location.href=t))},s.handleExtensionConnect=function(t){if("trezor-connect"===t.name){if(!this._window||this._window&&this._window.id!==t.sender.tab.id)return void t.disconnect();this.extensionPort=t,this.extensionPort.onMessage.addListener(this.handleExtensionMessage)}else"trezor-usb-permissions"===t.name&&t.postMessage({broadcast:this.broadcast})},s.handleExtensionMessage=function(t){this.extensionPort&&(t===u.EXTENSION_REQUEST?this.extensionPort.postMessage({type:u.EXTENSION_REQUEST,broadcast:this.broadcast}):t===u.INIT&&this.lazyLoad?this.lazyLoad.resolve(!0):t===u.EXTENSION_USB_PERMISSIONS?chrome.tabs.query({currentWindow:!0,active:!0},function(t){chrome.tabs.create({url:"trezor-usb-permissions.html",index:t[0].index+1},function(t){})}):t===u.CLOSE_WINDOW&&(this.emit(u.CLOSED),this.close()))},s.setBroadcast=function(t){this.broadcast=t},s.handleLazyLoading=function(t){this.lazyLoad&&t.data&&t.data===u.INIT&&(this.lazyLoad.resolve(!0),window.removeEventListener("message",this.handleLazyLoading,!1))},s.resolveLazyLoad=function(){var t=(0,n.default)(r.default.mark(function t(){return r.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.lazyLoad){t.next=5;break}return t.next=3,this.lazyLoad.promise;case 3:t.next=6;break;case 5:throw f.POPUP_CLOSED.message;case 6:this.extension?this.extensionPort&&this.extensionPort.postMessage({type:u.INIT}):this._window&&this._window.postMessage({type:u.INIT},this.origin);case 7:case"end":return t.stop()}},t,this)}));return function(){return t.apply(this,arguments)}}(),s.close=function(){this.locked=!1,this.requestTimeout&&(window.clearTimeout(this.requestTimeout),this.requestTimeout=0),this.openTimeout&&(window.clearTimeout(this.openTimeout),this.openTimeout=0),this.closeInterval&&(window.clearInterval(this.closeInterval),this.closeInterval=0),this.extensionPort&&(this.extensionPort.disconnect(),this.extensionPort=null),this.extensionTabId&&(chrome.tabs.update(this.extensionTabId,{active:!0}),this.extensionTabId=0),this.lazyLoad&&(this.lazyLoad=null),this._window&&(this.extension?chrome.tabs.remove(this._window.id):this._window.close(),this._window=null)},s.postMessage=function(t){var e=this;if(!this.requestTimeout)return!this._window&&"ui_request_window"!==t.type&&this.openTimeout?(this.close(),void(0,ft.showPopupRequest)(this.open.bind(this),function(){e.emit(u.CLOSED)})):void(this._window&&this._window.postMessage(t,this.origin))},s.onBeforeUnload=function(){this.close()},s.cancelOpenTimeout=function(){window.clearTimeout(this.openTimeout)},e}(s.default);e.default=c});g(Ot);var kt=v(function(t,e){e.__esModule=!0,e.default=void 0;e.default='.trezorconnect-container{position:fixed!important;display:-webkit-box!important;display:-webkit-flex!important;display:-ms-flexbox!important;display:flex!important;-webkit-box-orient:vertical!important;-webkit-box-direction:normal!important;-webkit-flex-direction:column!important;-ms-flex-direction:column!important;flex-direction:column!important;-webkit-box-align:center!important;-webkit-align-items:center!important;-ms-flex-align:center!important;align-items:center!important;z-index:10000!important;width:100%!important;height:100%!important;top:0!important;left:0!important;background:rgba(0,0,0,.35)!important;overflow:auto!important;padding:20px!important;margin:0!important}.trezorconnect-container .trezorconnect-window{position:relative!important;display:block!important;width:370px!important;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif!important;margin:auto!important;border-radius:3px!important;background-color:#fff!important;text-align:center!important;overflow:hidden!important}.trezorconnect-container .trezorconnect-window .trezorconnect-head{text-align:left;padding:12px 24px!important;display:-webkit-box!important;display:-webkit-flex!important;display:-ms-flexbox!important;display:flex!important;-webkit-box-align:center!important;-webkit-align-items:center!important;-ms-flex-align:center!important;align-items:center!important}.trezorconnect-container .trezorconnect-window .trezorconnect-head .trezorconnect-logo{-webkit-box-flex:1;-webkit-flex:1;-ms-flex:1;flex:1}.trezorconnect-container .trezorconnect-window .trezorconnect-head .trezorconnect-close{cursor:pointer!important;height:24px!important}.trezorconnect-container .trezorconnect-window .trezorconnect-head .trezorconnect-close svg{fill:#757575;-webkit-transition:fill .3s ease-in-out!important;transition:fill .3s ease-in-out!important}.trezorconnect-container .trezorconnect-window .trezorconnect-head .trezorconnect-close:hover svg{fill:#494949}.trezorconnect-container .trezorconnect-window .trezorconnect-body{padding:24px 24px 32px!important;background:#FBFBFB!important;border-top:1px solid #EBEBEB}.trezorconnect-container .trezorconnect-window .trezorconnect-body h3{color:#505050!important;font-size:16px!important;font-weight:500!important}.trezorconnect-container .trezorconnect-window .trezorconnect-body p{margin:8px 0 24px!important;font-weight:400!important;color:#A9A9A9!important;font-size:12px!important}.trezorconnect-container .trezorconnect-window .trezorconnect-body button{width:100%!important;padding:12px 24px!important;margin:0!important;border-radius:3px!important;font-size:14px!important;font-weight:300!important;cursor:pointer!important;background:#01B757!important;color:#fff!important;border:0!important;-webkit-transition:background-color .3s ease-in-out!important;transition:background-color .3s ease-in-out!important}.trezorconnect-container .trezorconnect-window .trezorconnect-body button:hover{background-color:#00AB51!important}.trezorconnect-container .trezorconnect-window .trezorconnect-body button:active{background-color:#009546!important}/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImlucHV0IiwiJHN0ZGluIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQWNBLHlCQUNJLFNBQUEsZ0JBQ0EsUUFBQSxzQkFDQSxRQUFBLHVCQUNBLFFBQUEsc0JBRUEsUUFBQSxlQUNBLG1CQUFBLG1CQUNBLHNCQUFBLGlCQUNBLHVCQUFBLGlCQUNBLG1CQUFBLGlCQUNBLGVBQUEsaUJBRUEsa0JBQUEsaUJBQ0Esb0JBQUEsaUJBQ0EsZUFBQSxpQkNmTSxZQUFhLGlCREFyQixRQUFTLGdCQWtCSCxNQUFBLGVBQ0EsT0FBQSxlQUNBLElBQUEsWUFDQSxLQUFBLFlBQ0EsV0FBQSwwQkFDQSxTQUFBLGVBQ0EsUUFBQSxlQUNBLE9BQUEsWUNkUiwrQ0RYRSxTQUFVLG1CQTZCQSxRQUFBLGdCQUNBLE1BQUEsZ0JBQ0EsWUFBQSxjQUFBLG1CQUFBLFdBQUEsT0FBQSxpQkFBQSxNQUFBLHFCQUNBLE9BQUEsZUNmVixjQUFlLGNEakJmLGlCQWlCRSxlQWtCWSxXQUFBLGlCQ2ZkLFNBQVUsaUJEbUJJLG1FQUNBLFdBQUEsS0NoQmQsUUFBUyxLQUFLLGVEeEJkLFFBQVMsc0JBMENTLFFBQUEsdUJBQ0EsUUFBQSxzQkNmbEIsUUFBUyxlRGlCSyxrQkE1QlosaUJBOEJvQixvQkFBQSxpQkNoQmxCLGVBQWdCLGlCRC9CWixZQWlCTixpQkFzQ1EsdUZBQ0EsaUJBQUEsRUNwQlYsYUFBYyxFRHBDVixTQUFVLEVBMkRBLEtBQUEsRUFFQSx3RkNwQmQsT0FBUSxrQkR6Q1IsT0FBUSxlQWlFTSw0RkFDQSxLQUFBLFFBQ0EsbUJBQUEsS0FBQSxJQUFBLHNCQ3BCZCxXQUFZLEtBQUssSUFBSyxzQkR3QlIsa0dBQ0EsS0FBQSxRQUVBLG1FQUNBLFFBQUEsS0FBQSxLQUFBLGVBQ0EsV0FBQSxrQkFDQSxXQUFBLElBQUEsTUFBQSxRQUVBLHNFQUNBLE1BQUEsa0JBQ0EsVUFBQSxlQ3JCZCxZQUFhLGNEd0JLLHFFQ3JCbEIsT0FBUSxJQUFJLEVBQUksZUR3QkYsWUFBQSxjQUNJLE1BQUEsa0JDdEJsQixVQUFXLGVBRWIsMEVBQ0UsTUFBTyxlQUNQLFFBQVMsS0FBSyxlQUNkLE9BQVEsWUFDUixjQUFlLGNBQ2YsVUFBVyxlQUNYLFlBQWEsY0FDYixPQUFRLGtCQUNSLFdBQVksa0JBQ1osTUFBTyxlQUNQLE9BQVEsWUFDUixtQkFBb0IsaUJBQWlCLElBQUssc0JBQzFDLFdBQVksaUJBQWlCLElBQUssc0JBRXBDLGdGQUNFLGlCQUFrQixrQkFFcEIsaUZBQ0UsaUJBQWtCIn0= */'});g(kt);var Ct=v(function(t,e){e.__esModule=!0,e.clearTimeout=e.dispose=e.postMessage=e.init=e.messagePromises=e.error=e.timeout=e.initPromise=e.origin=e.instance=void 0;var r,n,i=O(C),o=O(L),a=O(kt);e.instance=r,e.origin=n;var s=(0,Pt.create)();e.initPromise=s;var u,f=0;e.timeout=f,e.error=u;var c=0,h={};e.messagePromises=h;var l=function(){var t=(0,o.default)(i.default.mark(function t(o){var a,u,c,h,l,g;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return(a=document.getElementById("trezorconnect"))?e.instance=r=a:(e.instance=r=document.createElement("iframe"),r.frameBorder="0",r.width="0px",r.height="0px",r.style.position="absolute",r.style.display="none",r.style.border="0px",r.style.width="0px",r.style.height="0px",r.id="trezorconnect"),u=o.manifest?JSON.stringify(o.manifest):"undefined",c="&version="+o.version+"&manifest="+encodeURIComponent(btoa(JSON.stringify(u))),h=o.iframeSrc+"?"+Date.now()+c,r.setAttribute("src",h),o.webusb&&r.setAttribute("allow","usb"),(l=r.src.match(/^.+\:\/\/[^\/]+/))&&l.length>0&&(e.origin=n=l[0]),e.timeout=f=window.setTimeout(function(){s.reject(st.IFRAME_TIMEOUT)},1e4),g=function(){if(r){try{var t=r.contentWindow.location.origin;if(!t||"null"===t)return void p()}catch(t){}var e;"undefined"!=typeof chrome&&chrome.runtime&&void 0!==chrome.runtime.onConnect&&(chrome.runtime.onConnect.addListener(function(){}),e=chrome.runtime.id),r.contentWindow.postMessage({type:X.IFRAME_HANDSHAKE,payload:{settings:o,extension:e}},n),r.onload=void 0}else s.reject(st.IFRAME_BLOCKED)},r.attachEvent?r.attachEvent("onload",g):r.onload=g,document.body&&(document.body.appendChild(r),d()),t.prev=13,t.next=16,s.promise;case 16:t.next=21;break;case 18:throw t.prev=18,t.t0=t.catch(13),t.t0.message||t.t0;case 21:return t.prev=21,window.clearTimeout(f),e.timeout=f=0,t.finish(21);case 25:case"end":return t.stop()}},t,null,[[13,18,21,25]])}));return function(e){return t.apply(this,arguments)}}();e.init=l;var d=function(){if(!r)throw st.IFRAME_BLOCKED;var t=r.ownerDocument,e=t.head||t.getElementsByTagName("head")[0],n=document.createElement("style");n.setAttribute("type","text/css"),n.setAttribute("id","TrezorConnectStylesheet"),n.styleSheet?n.styleSheet.cssText=a.default:n.appendChild(document.createTextNode(a.default)),e.append(n)},p=function(){window.clearTimeout(f),e.error=u=st.IFRAME_BLOCKED.message,g(),s.reject(st.IFRAME_BLOCKED)};e.postMessage=function(t,e){if(void 0===e&&(e=!0),!r)throw st.IFRAME_BLOCKED;return e?(c++,t.id=c,h[c]=(0,Pt.create)(),r.contentWindow.postMessage(t,n),h[c].promise):(r.contentWindow.postMessage(t,n),null)};var g=function(){if(r&&r.parentNode)try{r.parentNode.removeChild(r)}catch(t){}e.instance=r=null,e.timeout=f=0};e.dispose=g;e.clearTimeout=function(){window.clearTimeout(f)}});g(Ct);Ct.clearTimeout,Ct.dispose,Ct.postMessage,Ct.init,Ct.messagePromises,Ct.error,Ct.timeout,Ct.initPromise,Ct.origin,Ct.instance;var Rt=v(function(t,e){e.__esModule=!0,e.default=void 0;var r=function(t,e,r){var n=t||".trezor-webusb-button",i=document.querySelectorAll(n),o=e+"?"+Date.now();i.forEach(function(t){if(t.getElementsByTagName("iframe").length<1){var e=t.getBoundingClientRect(),n=document.createElement("iframe");n.frameBorder="0",n.width=Math.round(e.width)+"px",n.height=Math.round(e.height)+"px",n.style.position="absolute",n.style.top="0px",n.style.left="0px",n.style.zIndex="1",n.setAttribute("allow","usb"),n.setAttribute("scrolling","no"),n.onload=function(){n.contentWindow.postMessage({},r)},n.src=o,t.append(n)}})};e.default=r});g(Rt);var Lt=v(function(t,e){e.__esModule=!0,e.popupConsole=e.enableByPrefix=e.getLog=e.enable=e.init=e.default=void 0;var r={DescriptorStream:"color: #77ab59",DeviceList:"color: #36802d",Device:"color: #bada55",Core:"color: #c9df8a",IFrame:"color: #FFFFFF; background: #f4a742;",Popup:"color: #f48a00"},n=function(){function t(t,e){void 0===e&&(e=!1),this.prefix=t,this.enabled=e,this.messages=[],this.css=r[t]||"color: #000000; background: #FFFFFF;"}var e=t.prototype;return e.addMessage=function(t,e){for(var r=arguments.length,n=new Array(r>2?r-2:0),i=2;i0?"."+i[1]:"")+"/");e.DEFAULT_PRIORITY=2;var a={configSrc:"data/config.json",version:"7.0.5",debug:!1,origin:null,priority:2,trustedHost:!1,connectSrc:o,iframeSrc:o+"iframe.html",popup:!0,popupSrc:o+"popup.html",webusbSrc:o+"webusb.html",transportReconnect:!1,webusb:!0,pendingTransportEvent:!0,supportedBrowser:"undefined"==typeof navigator||!/Trident|MSIE/.test(navigator.userAgent),extension:null,manifest:null};e.parse=function(t){if(!t)return a;var e,i=function(t){for(var e=1;e0,t.next=3,T(b({method:"cardanoGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"cardanoGetPublicKey",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"cardanoGetPublicKey"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"cardanoSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"cardanoSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"cipherKeyValue",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"cipherKeyValue"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"composeTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"composeTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"debugLinkDecision",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"debugLinkDecision"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"debugLinkGetState",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"debugLinkGetState"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"ethereumGetAccountInfo",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"ethereumGetAccountInfo"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"ethereumGetAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"ethereumGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"ethereumGetPublicKey",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"ethereumGetPublicKey"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"ethereumSignMessage",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"ethereumSignMessage"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"ethereumSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"ethereumSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"ethereumVerifyMessage",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"ethereumVerifyMessage"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"getAccountInfo",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"getAccountInfo"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"getAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"getAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"getDeviceState",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"getDeviceState"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"getFeatures",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"getFeatures"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"getPublicKey",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"getPublicKey"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"liskGetAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"liskGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"liskGetPublicKey",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"liskGetPublicKey"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"liskSignMessage",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"liskSignMessage"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"liskSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"liskSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"liskVerifyMessage",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"liskVerifyMessage"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"nemGetAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"nemGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"nemSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"nemSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"pushTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"pushTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"rippleGetAccountInfo",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"rippleGetAccountInfo"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"rippleGetAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"rippleGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"rippleSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"rippleSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"signMessage",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"signMessage"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"signTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"signTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"stellarGetAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"stellarGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"stellarSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"stellarSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"tezosGetAddress",function(){var t=(0,o.default)(i.default.mark(function t(e){var r;return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return r=_.listenerCount(c.ADDRESS_VALIDATION)>0,t.next=3,T(b({method:"tezosGetAddress"},e,{useEventListener:r}));case 3:return t.abrupt("return",t.sent);case 4:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"tezosGetPublicKey",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"tezosGetPublicKey"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"tezosSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"tezosSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"eosGetPublicKey",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"eosGetPublicKey"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"eosSignTransaction",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"eosSignTransaction"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"verifyMessage",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"verifyMessage"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"wipeDevice",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"wipeDevice"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"applyFlags",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"applyFlags"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"applySettings",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"applySettings"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"backupDevice",(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,T({method:"backupDevice"});case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}))),(0,n.default)(x,"changePin",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"changePin"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"firmwareErase",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"firmwareErase"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"firmwareUpload",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"firmwareUpload"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"firmwareUpdate",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"firmwareUpdate"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"recoveryDevice",function(){var t=(0,o.default)(i.default.mark(function t(e){return i.default.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,T(b({method:"recoveryDevice"},e));case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}},t)}));return function(e){return t.apply(this,arguments)}}()),(0,n.default)(x,"dispose",function(){g.dispose(),A&&A.close()}),(0,n.default)(x,"cancel",function(){A&&A.emit(u.CLOSED)}),(0,n.default)(x,"renderWebUSBButton",function(t){(0,v.default)(t,w.webusbSrc,g.origin)});var R=x;e.default=R}),$t=g(Xt),te=(Xt.BLOCKCHAIN,Xt.DEVICE,Xt.UI,Xt.TRANSPORT,Xt.UI_EVENT,Xt.DEVICE_EVENT,Xt.RESPONSE_EVENT,Xt.TRANSPORT_EVENT,Xt.BLOCKCHAIN_EVENT,x.Signer),ee=x.providers,re=x.utils,ne=["44'/1'","44'/60'","44'/61'"];function ie(t,e){var r=new Error(t);return r.id=e,r}var oe={path:"44'/60'/0'/0/0",accountsLength:1,accountsOffset:0},ae=function(t){function n(t){var e,r=t.network,i=t.apiKey,o=t.email,s=t.appUrl;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,n),(e=u(this,a(n).call(this))).provider=new ee.InfuraProvider(r,i),e.address=null,e.path=oe.path,e.accountsLength=oe.accountsLength,e.accountsOffset=oe.accountsOffset,e.pathComponents=function(t){var e=/^(44'\/(?:1|60|61)'\/\d+'\/\d+?\/)(\d+)$/.exec(t);if(null===e)throw ie("To get multiple accounts your derivation path must follow pattern 44'/60|61'/x'/n ","InvalidDerivationPath");return{basePath:e[1],index:parseInt(e[2],10)}}(e.path),e.addressToPathMap={},e.alreadyOpenTrezorModal=!1,!ne.some(function(t){return e.path.startsWith(t)}))throw ie("Trezor derivation path allowed are ".concat(ne.join(", "),". ").concat(e.path," is not supported"),"InvalidDerivationPath");return $t.manifest({email:o,appUrl:s}),e}var i,o,f,c,h,l,d,p;return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&s(t,e)}(n,te),i=n,(o=[{key:"getPublicKey",value:(p=e(regeneratorRuntime.mark(function t(){var e,r,n=arguments;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:return e=n.length>0&&void 0!==n[0]?n[0]:this.path,this.path=e,t.next=4,$t.getPublicKey({path:e});case 4:if(!(r=t.sent).success){t.next=7;break}return t.abrupt("return",r.payload);case 7:throw new Error(r.payload.error);case 8:case"end":return t.stop()}},t,this)})),function(){return p.apply(this,arguments)})},{key:"getAddress",value:(d=e(regeneratorRuntime.mark(function t(){var e,r,n,i,o,a=this;return regeneratorRuntime.wrap(function(t){for(;;)switch(t.prev=t.next){case 0:if(t.prev=0,this.alreadyOpenTrezorModal){t.next=15;break}for(this.alreadyOpenTrezorModal=!0,e=[],r=this.accountsOffset;r\n \n \n \n',wallet:function(){var t=new ae({email:e,appUrl:r,rpcUrl:n,network:i});return{provider:t,interface:{name:"Trezor",connect:t.getAddress.bind(t),address:{get:function(){return Promise.resolve(t.address)}},network:{get:function(){return Promise.resolve(t.provider._network.chainId)}},balance:{get:function(){return t.address?t.provider.getBalance(t.address):Promise.resolve(null)}}}}}}}(o({},s,{network:c}))),{heading:e||"Select a Wallet",description:r||"Please select the wallet that you would like to use with this dapp:",wallets:{mobile:f,desktop:u}}}}); -//# sourceMappingURL=bn-select-wallet.js.map diff --git a/public/demo.js b/public/demo.js deleted file mode 100644 index 61f0973d6..000000000 --- a/public/demo.js +++ /dev/null @@ -1,64 +0,0 @@ -import Onboard from "./Onboard" - -const onboard = Onboard.init({ - dappId: "12153f55-f29e-4f11-aa07-90f10da5d778", - networkId: 4, - subscriptions: { - address: a => { - const address = document.getElementById("address") - if (address) { - address.innerHTML = a || "" - } - }, - network: n => { - const network = document.getElementById("network") - if (network) { - network.innerHTML = networkName(Number(n)) || "" - } - }, - balance: b => { - const balance = document.getElementById("balance") - if (balance != null) { - balance.innerHTML = b == 0 ? 0 : b / 1000000000000000000 + " ETH" - } - }, - provider: p => p && console.log("provider:", p) - }, - modules: { - selectWallet: window.selectWallet({ - fortmaticInit: { apiKey: "pk_test_886ADCAB855632AA" }, - portisInit: { apiKey: "d7d72646-709a-45ab-aa43-8de5307ae0df" }, - trezorInit: { - email: "aaron@flexdapps.com", - appUrl: "https://flexdapps.com", - apiKey: "d5e29c9b9a9d4116a7348113f57770a8" - }, - networkId: 4 - }), - prepareWallet: window.prepareWallet({ - networkId: 4, - minimumBalance: "20000000000000000" - }) - } -}) - -function networkName(id) { - switch (id) { - case 1: - return "main" - case 3: - return "ropsten" - case 4: - return "rinkeby" - case 5: - return "goerli" - case 42: - return "kovan" - case "localhost": - return "localhost" - default: - return "local" - } -} - -window.onboard = onboard diff --git a/public/favicon.png b/public/favicon.png deleted file mode 100644 index 7e6f5eb5a..000000000 Binary files a/public/favicon.png and /dev/null differ diff --git a/public/global.css b/public/global.css deleted file mode 100644 index df9a70510..000000000 --- a/public/global.css +++ /dev/null @@ -1,46 +0,0 @@ -body { - max-width: 100vw; - overflow-x: hidden; - font-family: "Helvetica Neue"; -} - -.bn-demo-button { - background: #ffffff; - font-size: 0.889rem; - border: 1px solid #eeeeee; - border-radius: 40px; - padding: 0.55rem 1.4rem; - color: #4a90e2; -} - -.bn-demo-button:focus { - outline: none; -} - -.bn-demo-button:hover { - cursor: pointer; -} - -.bn-demo-info { - display: flex; -} - -.bn-demo-info p { - margin: 0.5rem; -} - -.bn-demo-info p:first-of-type { - color: #727272; -} - -.bn-demo-info p:last-child { - color: #4a4a4a; -} - -/* .bn-styles.bn-custom.bn-modal { - background: pink; -} - -.bn-styles.bn-custom.bn-modal-content { - background: hotpink; -} */ diff --git a/public/index.html b/public/index.html deleted file mode 100644 index 2fb00af10..000000000 --- a/public/index.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - Blocknative Onboard Demo - - - - - - - - - -
-

ADDRESS:

-

-
-
-

NETWORK:

-

-
-
-

BALANCE:

-

-
- - -
- - -
- - diff --git a/rollup.config.js b/rollup.config.js index 1e5361550..a1382bb27 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,70 +1,64 @@ import svelte from "rollup-plugin-svelte" import resolve from "rollup-plugin-node-resolve" +import babel from "rollup-plugin-babel" import commonjs from "rollup-plugin-commonjs" -import livereload from "rollup-plugin-livereload" -import image from "rollup-plugin-img" +import globals from "rollup-plugin-node-globals" import json from "rollup-plugin-json" import builtins from "rollup-plugin-node-builtins" -import globals from "rollup-plugin-node-globals" import { terser } from "rollup-plugin-terser" -const production = !process.env.ROLLUP_WATCH - export default [ { input: "src/index.js", output: { - sourcemap: true, - format: "umd", - name: "Onboard", - file: "public/Onboard.js" + format: "iife", + name: "onboard", + file: "dist/iife/onboard.js", + esModule: false }, plugins: [ - json({ - include: "package.json", - exclude: ["node_modules"] - }), - image(), - svelte({ - dev: !production - }), + json(), + svelte(), resolve({ + preferBuiltins: true, browser: true, dedupe: importee => - importee === "svelte" || importee.startsWith("svelte/"), - preferBuiltins: true + importee === "svelte" || importee.startsWith("svelte/") }), commonjs(), globals(), + babel({ exclude: "node_modules/**" }), builtins(), - - !production && livereload("public"), - production && terser() - ], - watch: { - clearScreen: false - } + terser() + ] }, { - input: "public/demo.js", - output: { - format: "iife", - name: "demo", - file: "public/demo-bundle.js" - }, + input: "src/index.js", + external: [ + "bowser", + "bn-sdk", + "ow", + "svelte-i18n", + "svelte", + "svelte/store", + "svelte/internal", + "svelte/transition" + ], plugins: [ - resolve({ - preferBuiltins: true, - browser: true - }), + svelte(), + json(), commonjs(), - globals(), - builtins(), - - production && terser() + babel({ exclude: "node_modules/**" }) ], - watch: { - clearScreen: false - } + output: [ + { + dir: "dist/esm", + format: "esm" + }, + { + dir: "dist/cjs", + format: "cjs" + } + ] } ] diff --git a/src/api.js b/src/api.js new file mode 100644 index 000000000..b4cc6ede5 --- /dev/null +++ b/src/api.js @@ -0,0 +1,47 @@ +import { app, configuration, walletInterface, state } from "./stores" +import { validateConfig } from "./validation" + +export function selectWallet() { + return new Promise(resolve => { + app.update(store => ({ ...store, selectWallet: true })) + + const appUnsubscribe = app.subscribe( + ({ selectWallet, selectWalletCompleted }) => { + if (selectWallet === false) { + appUnsubscribe() + setTimeout(() => resolve(selectWalletCompleted), 500) + } + } + ) + }) +} + +export function prepareWallet() { + return new Promise(resolve => { + walletInterface.subscribe(provider => { + if (!provider) { + throw new Error("selectWallet must be called before prepareWallet") + } + }) + + app.update(store => ({ ...store, prepareWallet: true })) + + const appUnsubscribe = app.subscribe( + ({ prepareWallet, prepareWalletCompleted }) => { + if (prepareWallet === false) { + appUnsubscribe() + setTimeout(() => resolve(prepareWalletCompleted), 500) + } + } + ) + }) +} + +export function config(options) { + validateConfig(options) + configuration.update(store => ({ ...store, ...options })) +} + +export function getState() { + return state.get() +} diff --git a/src/bn-client-sdk.js b/src/bn-client-sdk.js deleted file mode 100644 index 157557477..000000000 --- a/src/bn-client-sdk.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict";function _defineProperty(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function ownKeys(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 _objectSpread2(e){for(var t=1;t1?r[i-1]:void 0,s=i>2?r[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,s&&isIterateeCall(r[0],r[1],s)&&(a=i<3?void 0:a,i=1),t=Object(t);++n-1&&e%1==0&&e-1&&e%1==0&&e<=MAX_SAFE_INTEGER}function isObject(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function isObjectLike(e){return!!e&&"object"==typeof e}var assignInWith=createAssigner(function(e,t,r,n){copyObject(t,keysIn(t),e,n)}),defaults=baseRest(function(e){return e.push(void 0,assignInDefaults),apply(assignInWith,void 0,e)});function keysIn(e){return isArrayLike(e)?arrayLikeKeys(e,!0):baseKeysIn(e)}var lodash_defaults=defaults,dist=createCommonjsModule(function(e,t){Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(t,r,n){if(this.url=t,this.onclose=null,this.onerror=null,this.onmessage=null,this.onopen=null,this.ondown=null,this.onreopen=null,this.CONNECTING=e.CONNECTING,this.OPEN=e.OPEN,this.CLOSING=e.CLOSING,this.CLOSED=e.CLOSED,this.hasBeenOpened=!1,this.isClosed=!1,this.messageBuffer=[],this.nextRetryTime=0,this.reconnectCount=0,this.lastKnownExtensions="",this.lastKnownProtocol="",this.listeners={},null==r||"string"==typeof r||Array.isArray(r)?this.protocols=r:n=r,this.options=lodash_defaults({},n,e.DEFAULT_OPTIONS),!this.options.wsConstructor){if("undefined"==typeof WebSocket)throw new Error("WebSocket not present in global scope and no wsConstructor option was provided.");this.options.wsConstructor=WebSocket}this.openNewWebSocket()}return Object.defineProperty(e.prototype,"binaryType",{get:function(){return this.binaryTypeInternal||"blob"},set:function(e){this.binaryTypeInternal=e,this.ws&&(this.ws.binaryType=e)},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"bufferedAmount",{get:function(){var e=this.ws?this.ws.bufferedAmount:0,t=!1;return this.messageBuffer.forEach(function(r){var n=function(e){return"string"==typeof e?2*e.length:e instanceof ArrayBuffer?e.byteLength:e instanceof Blob?e.size:void 0}(r);null!=n?e+=n:t=!0}),t&&this.debugLog("Some buffered data had unknown length. bufferedAmount() return value may be below the correct amount."),e},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"extensions",{get:function(){return this.ws?this.ws.extensions:this.lastKnownExtensions},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"protocol",{get:function(){return this.ws?this.ws.protocol:this.lastKnownProtocol},enumerable:!0,configurable:!0}),Object.defineProperty(e.prototype,"readyState",{get:function(){return this.isClosed?e.CLOSED:e.OPEN},enumerable:!0,configurable:!0}),e.prototype.close=function(e,t){this.ws&&this.ws.close(e,t),this.shutdown(),this.debugLog("WebSocket permanently closed by client.")},e.prototype.send=function(e){this.ws&&this.ws.readyState===this.OPEN?this.ws.send(e):this.messageBuffer.push(e)},e.prototype.addEventListener=function(e,t){this.listeners[e]||(this.listeners[e]=[]),this.listeners[e].push(t)},e.prototype.dispatchEvent=function(e){return this.dispatchEventOfType(e.type,e)},e.prototype.removeEventListener=function(e,t){this.listeners[e]&&(this.listeners[e]=this.listeners[e].filter(function(e){return e!==t}))},e.prototype.openNewWebSocket=function(){var e=this;if(!this.isClosed){var t=this.options,r=t.connectTimeout,n=t.wsConstructor;this.debugLog("Opening new WebSocket to "+this.url+".");var i=new n(this.url,this.protocols);i.onclose=function(t){return e.handleClose(t)},i.onerror=function(t){return e.handleError(t)},i.onmessage=function(t){return e.handleMessage(t)},i.onopen=function(t){return e.handleOpen(t)},this.connectTimeoutId=setTimeout(function(){e.clearConnectTimeout(),i.close()},r),this.ws=i}},e.prototype.handleOpen=function(e){var t=this;if(this.ws&&!this.isClosed){var r=this.options.allClearResetTime;this.debugLog("WebSocket opened."),null!=this.binaryTypeInternal?this.ws.binaryType=this.binaryTypeInternal:this.binaryTypeInternal=this.ws.binaryType,this.clearConnectTimeout(),this.hasBeenOpened?this.dispatchEventOfType("reopen",e):(this.dispatchEventOfType("open",e),this.hasBeenOpened=!0),this.messageBuffer.forEach(function(e){return t.send(e)}),this.messageBuffer=[],this.allClearTimeoutId=setTimeout(function(){t.clearAllClearTimeout(),t.nextRetryTime=0,t.reconnectCount=0;var e=r/1e3|0;t.debugLog("WebSocket remained open for "+e+" seconds. Resetting retry time and count.")},r)}},e.prototype.handleMessage=function(e){this.isClosed||this.dispatchEventOfType("message",e)},e.prototype.handleClose=function(e){var t=this;if(!this.isClosed){var r=this.options,n=r.maxReconnectAttempts,i=r.shouldReconnect;if(this.clearConnectTimeout(),this.clearAllClearTimeout(),this.ws&&(this.lastKnownExtensions=this.ws.extensions,this.lastKnownProtocol=this.ws.protocol,this.ws=void 0),this.dispatchEventOfType("down",e),this.reconnectCount>=n)this.stopReconnecting(e,this.getTooManyFailedReconnectsMessage());else{var a=i(e);"boolean"==typeof a?this.handleWillReconnect(a,e,"Provided shouldReconnect() returned false. Closing permanently."):a.then(function(r){t.isClosed||t.handleWillReconnect(r,e,"Provided shouldReconnect() resolved to false. Closing permanently.")})}}},e.prototype.handleError=function(e){this.dispatchEventOfType("error",e),this.debugLog("WebSocket encountered an error.")},e.prototype.handleWillReconnect=function(e,t,r){e?this.reconnect():this.stopReconnecting(t,r)},e.prototype.reconnect=function(){var e=this,t=this.options,r=t.minReconnectDelay,n=t.maxReconnectDelay,i=t.reconnectBackoffFactor;this.reconnectCount++;var a=this.nextRetryTime;this.nextRetryTime=Math.max(r,Math.min(this.nextRetryTime*i,n)),setTimeout(function(){return e.openNewWebSocket()},a);var s=a/1e3|0;this.debugLog("WebSocket was closed. Re-opening in "+s+" seconds.")},e.prototype.stopReconnecting=function(e,t){this.debugLog(t),this.shutdown(),this.dispatchEventOfType("close",e)},e.prototype.shutdown=function(){this.isClosed=!0,this.clearAllTimeouts(),this.messageBuffer=[]},e.prototype.clearAllTimeouts=function(){this.clearConnectTimeout(),this.clearAllClearTimeout()},e.prototype.clearConnectTimeout=function(){null!=this.connectTimeoutId&&(clearTimeout(this.connectTimeoutId),this.connectTimeoutId=void 0)},e.prototype.clearAllClearTimeout=function(){null!=this.allClearTimeoutId&&(clearTimeout(this.allClearTimeoutId),this.allClearTimeoutId=void 0)},e.prototype.dispatchEventOfType=function(e,t){var r=this;switch(e){case"close":this.onclose&&this.onclose(t);break;case"error":this.onerror&&this.onerror(t);break;case"message":this.onmessage&&this.onmessage(t);break;case"open":this.onopen&&this.onopen(t);break;case"down":this.ondown&&this.ondown(t);break;case"reopen":this.onreopen&&this.onreopen(t)}return e in this.listeners&&this.listeners[e].slice().forEach(function(e){return r.callListener(e,t)}),!t||!t.defaultPrevented},e.prototype.callListener=function(e,t){"function"==typeof e?e.call(this,t):e.handleEvent.call(this,t)},e.prototype.debugLog=function(e){this.options.debug&&console.log(e)},e.prototype.getTooManyFailedReconnectsMessage=function(){var e=this.options.maxReconnectAttempts;return"Failed to reconnect after "+e+" "+function(e,t){return 1===t?e:e+"s"}("attempt",e)+". Closing permanently."},e.DEFAULT_OPTIONS={allClearResetTime:5e3,connectTimeout:5e3,debug:!1,minReconnectDelay:1e3,maxReconnectDelay:3e4,maxReconnectAttempts:Number.POSITIVE_INFINITY,reconnectBackoffFactor:1.5,shouldReconnect:function(){return!0},wsConstructor:void 0},e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}();t.default=r}),SturdyWebSocket=unwrapExports(dist),version="0.0.1",require$$0={},maxInt=2147483647,base=36,tMin=1,tMax=26,skew=38,damp=700,initialBias=72,initialN=128,delimiter="-",regexNonASCII=/[^\x20-\x7E]/,regexSeparators=/[\x2E\u3002\uFF0E\uFF61]/g,errors={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},baseMinusTMin=base-tMin,floor=Math.floor,stringFromCharCode=String.fromCharCode;function error(e){throw new RangeError(errors[e])}function map(e,t){for(var r=e.length,n=[];r--;)n[r]=t(e[r]);return n}function mapDomain(e,t){var r=e.split("@"),n="";return r.length>1&&(n=r[0]+"@",e=r[1]),n+map((e=e.replace(regexSeparators,".")).split("."),t).join(".")}function ucs2decode(e){for(var t,r,n=[],i=0,a=e.length;i=55296&&t<=56319&&i>1,e+=floor(e/t);e>baseMinusTMin*tMax>>1;n+=base)e=floor(e/baseMinusTMin);return floor(n+(baseMinusTMin+1)*e/(e+skew))}function encode(e){var t,r,n,i,a,s,o,f,u,c,d,h,l,p,b,m=[];for(h=(e=ucs2decode(e)).length,t=initialN,r=0,a=initialBias,s=0;s=t&&dfloor((maxInt-r)/(l=n+1))&&error("overflow"),r+=(o-t)*l,t=o,s=0;smaxInt&&error("overflow"),d==t){for(f=r,u=base;!(f<(c=u<=a?tMin:u>=a+tMax?tMax:u-a));u+=base)b=f-c,p=base-c,m.push(stringFromCharCode(digitToBasic(c+b%p,0))),f=floor(b/p);m.push(stringFromCharCode(digitToBasic(f,0))),a=adapt(r,l,n==i),r=0,++n}++r,++t}return m.join("")}function toASCII(e){return mapDomain(e,function(e){return regexNonASCII.test(e)?"xn--"+encode(e):e})}function defaultSetTimout(){throw new Error("setTimeout has not been defined")}function defaultClearTimeout(){throw new Error("clearTimeout has not been defined")}var cachedSetTimeout=defaultSetTimout,cachedClearTimeout=defaultClearTimeout;function runTimeout(e){if(cachedSetTimeout===setTimeout)return setTimeout(e,0);if((cachedSetTimeout===defaultSetTimout||!cachedSetTimeout)&&setTimeout)return cachedSetTimeout=setTimeout,setTimeout(e,0);try{return cachedSetTimeout(e,0)}catch(t){try{return cachedSetTimeout.call(null,e,0)}catch(t){return cachedSetTimeout.call(this,e,0)}}}function runClearTimeout(e){if(cachedClearTimeout===clearTimeout)return clearTimeout(e);if((cachedClearTimeout===defaultClearTimeout||!cachedClearTimeout)&&clearTimeout)return cachedClearTimeout=clearTimeout,clearTimeout(e);try{return cachedClearTimeout(e)}catch(t){try{return cachedClearTimeout.call(null,e)}catch(t){return cachedClearTimeout.call(this,e)}}}"function"==typeof global.setTimeout&&(cachedSetTimeout=setTimeout),"function"==typeof global.clearTimeout&&(cachedClearTimeout=clearTimeout);var currentQueue,queue=[],draining=!1,queueIndex=-1;function cleanUpNextTick(){draining&¤tQueue&&(draining=!1,currentQueue.length?queue=currentQueue.concat(queue):queueIndex=-1,queue.length&&drainQueue())}function drainQueue(){if(!draining){var e=runTimeout(cleanUpNextTick);draining=!0;for(var t=queue.length;t;){for(currentQueue=queue,queue=[];++queueIndex1)for(var r=1;r=i)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}}),s=n[r];r=3&&(r.depth=arguments[2]),arguments.length>=4&&(r.colors=arguments[3]),isBoolean(t)?r.showHidden=t:t&&_extend(r,t),isUndefined(r.showHidden)&&(r.showHidden=!1),isUndefined(r.depth)&&(r.depth=2),isUndefined(r.colors)&&(r.colors=!1),isUndefined(r.customInspect)&&(r.customInspect=!0),r.colors&&(r.stylize=stylizeWithColor),formatValue(r,e,r.depth)}function stylizeWithColor(e,t){var r=inspect.styles[t];return r?"["+inspect.colors[r][0]+"m"+e+"["+inspect.colors[r][1]+"m":e}function stylizeNoColor(e,t){return e}function arrayToHash(e){var t={};return e.forEach(function(e,r){t[e]=!0}),t}function formatValue(e,t,r){if(e.customInspect&&t&&isFunction$1(t.inspect)&&t.inspect!==inspect&&(!t.constructor||t.constructor.prototype!==t)){var n=t.inspect(r,e);return isString(n)||(n=formatValue(e,n,r)),n}var i=formatPrimitive(e,t);if(i)return i;var a=Object.keys(t),s=arrayToHash(a);if(e.showHidden&&(a=Object.getOwnPropertyNames(t)),isError(t)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return formatError(t);if(0===a.length){if(isFunction$1(t)){var o=t.name?": "+t.name:"";return e.stylize("[Function"+o+"]","special")}if(isRegExp(t))return e.stylize(RegExp.prototype.toString.call(t),"regexp");if(isDate(t))return e.stylize(Date.prototype.toString.call(t),"date");if(isError(t))return formatError(t)}var f,u="",c=!1,d=["{","}"];(isArray$1(t)&&(c=!0,d=["[","]"]),isFunction$1(t))&&(u=" [Function"+(t.name?": "+t.name:"")+"]");return isRegExp(t)&&(u=" "+RegExp.prototype.toString.call(t)),isDate(t)&&(u=" "+Date.prototype.toUTCString.call(t)),isError(t)&&(u=" "+formatError(t)),0!==a.length||c&&0!=t.length?r<0?isRegExp(t)?e.stylize(RegExp.prototype.toString.call(t),"regexp"):e.stylize("[Object]","special"):(e.seen.push(t),f=c?formatArray(e,t,r,s,a):a.map(function(n){return formatProperty(e,t,r,s,n,c)}),e.seen.pop(),reduceToSingleString(f,u,d)):d[0]+u+d[1]}function formatPrimitive(e,t){if(isUndefined(t))return e.stylize("undefined","undefined");if(isString(t)){var r="'"+JSON.stringify(t).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return e.stylize(r,"string")}return isNumber(t)?e.stylize(""+t,"number"):isBoolean(t)?e.stylize(""+t,"boolean"):isNull(t)?e.stylize("null","null"):void 0}function formatError(e){return"["+Error.prototype.toString.call(e)+"]"}function formatArray(e,t,r,n,i){for(var a=[],s=0,o=t.length;s-1&&(o=a?o.split("\n").map(function(e){return" "+e}).join("\n").substr(2):"\n"+o.split("\n").map(function(e){return" "+e}).join("\n")):o=e.stylize("[Circular]","special")),isUndefined(s)){if(a&&i.match(/^\d+$/))return o;(s=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(s=s.substr(1,s.length-2),s=e.stylize(s,"name")):(s=s.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),s=e.stylize(s,"string"))}return s+": "+o}function reduceToSingleString(e,t,r){return e.reduce(function(e,t){return t.indexOf("\n"),e+t.replace(/\u001b\[\d\d?m/g,"").length+1},0)>60?r[0]+(""===t?"":t+"\n ")+" "+e.join(",\n ")+" "+r[1]:r[0]+t+" "+e.join(", ")+" "+r[1]}function isArray$1(e){return Array.isArray(e)}function isBoolean(e){return"boolean"==typeof e}function isNull(e){return null===e}function isNullOrUndefined(e){return null==e}function isNumber(e){return"number"==typeof e}function isString(e){return"string"==typeof e}function isUndefined(e){return void 0===e}function isRegExp(e){return isObject$1(e)&&"[object RegExp]"===objectToString$1(e)}function isObject$1(e){return"object"==typeof e&&null!==e}function isDate(e){return isObject$1(e)&&"[object Date]"===objectToString$1(e)}function isError(e){return isObject$1(e)&&("[object Error]"===objectToString$1(e)||e instanceof Error)}function isFunction$1(e){return"function"==typeof e}function isPrimitive(e){return null===e||"boolean"==typeof e||"number"==typeof e||"string"==typeof e||"symbol"==typeof e||void 0===e}function objectToString$1(e){return Object.prototype.toString.call(e)}function _extend(e,t){if(!t||!isObject$1(t))return e;for(var r=Object.keys(t),n=r.length;n--;)e[r[n]]=t[r[n]];return e}function hasOwnProperty$1(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function hasOwnProperty$2(e,t){return Object.prototype.hasOwnProperty.call(e,t)}inspect.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]},inspect.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"};var isArray$2=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};function stringifyPrimitive(e){switch(typeof e){case"string":return e;case"boolean":return e?"true":"false";case"number":return isFinite(e)?e:"";default:return""}}function stringify(e,t,r,n){return t=t||"&",r=r||"=",null===e&&(e=void 0),"object"==typeof e?map$1(objectKeys(e),function(n){var i=encodeURIComponent(stringifyPrimitive(n))+r;return isArray$2(e[n])?map$1(e[n],function(e){return i+encodeURIComponent(stringifyPrimitive(e))}).join(t):i+encodeURIComponent(stringifyPrimitive(e[n]))}).join(t):n?encodeURIComponent(stringifyPrimitive(n))+r+encodeURIComponent(stringifyPrimitive(e)):""}function map$1(e,t){if(e.map)return e.map(t);for(var r=[],n=0;n0&&o>s&&(o=s);for(var f=0;f=0?(u=l.substr(0,p),c=l.substr(p+1)):(u=l,c=""),d=decodeURIComponent(u),h=decodeURIComponent(c),hasOwnProperty$2(i,d)?isArray$2(i[d])?i[d].push(h):i[d]=[i[d],h]:i[d]=h}return i}var require$$1={parse:urlParse,resolve:urlResolve,resolveObject:urlResolveObject,format:urlFormat,Url:Url};function Url(){this.protocol=null,this.slashes=null,this.auth=null,this.host=null,this.port=null,this.hostname=null,this.hash=null,this.search=null,this.query=null,this.pathname=null,this.path=null,this.href=null}var protocolPattern=/^([a-z0-9.+-]+:)/i,portPattern=/:[0-9]*$/,simplePathPattern=/^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/,delims=["<",">",'"',"`"," ","\r","\n","\t"],unwise=["{","}","|","\\","^","`"].concat(delims),autoEscape=["'"].concat(unwise),nonHostChars=["%","/","?",";","#"].concat(autoEscape),hostEndingChars=["/","?","#"],hostnameMaxLen=255,hostnamePartPattern=/^[+a-z0-9A-Z_-]{0,63}$/,hostnamePartStart=/^([+a-z0-9A-Z_-]{0,63})(.*)$/,unsafeProtocol={javascript:!0,"javascript:":!0},hostlessProtocol={javascript:!0,"javascript:":!0},slashedProtocol={http:!0,https:!0,ftp:!0,gopher:!0,file:!0,"http:":!0,"https:":!0,"ftp:":!0,"gopher:":!0,"file:":!0};function urlParse(e,t,r){if(e&&isObject$1(e)&&e instanceof Url)return e;var n=new Url;return n.parse(e,t,r),n}function parse$1(e,t,r,n){if(!isString(t))throw new TypeError("Parameter 'url' must be a string, not "+typeof t);var i=t.indexOf("?"),a=-1!==i&&i127?w+="x":w+=E[A];if(!w.match(hostnamePartPattern)){var S=y.slice(0,u),$=y.slice(u+1),P=E.match(hostnamePartStart);P&&(S.push(P[1]),$.unshift(P[2])),$.length&&(o="/"+$.join(".")+o),e.hostname=S.join(".");break}}}}e.hostname.length>hostnameMaxLen?e.hostname="":e.hostname=e.hostname.toLowerCase(),v||(e.hostname=toASCII(e.hostname)),h=e.port?":"+e.port:"";var M=e.hostname||"";e.host=M+h,e.href+=e.host,v&&(e.hostname=e.hostname.substr(1,e.hostname.length-2),"/"!==o[0]&&(o="/"+o))}if(!unsafeProtocol[p])for(u=0,d=autoEscape.length;u0)&&n.host.split("@"))&&(n.auth=b.shift(),n.host=n.hostname=b.shift())),n.search=e.search,n.query=e.query,isNull(n.pathname)&&isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.href=n.format(),n;if(!y.length)return n.pathname=null,n.search?n.path="/"+n.search:n.path=null,n.href=n.format(),n;for(var w=y.slice(-1)[0],A=(n.host||e.host||y.length>1)&&("."===w||".."===w)||""===w,I=0,S=y.length;S>=0;S--)"."===(w=y[S])?y.splice(S,1):".."===w?(y.splice(S,1),I++):I&&(y.splice(S,1),I--);if(!_&&!v)for(;I--;I)y.unshift("..");!_||""===y[0]||y[0]&&"/"===y[0].charAt(0)||y.unshift(""),A&&"/"!==y.join("/").substr(-1)&&y.push("");var $=""===y[0]||y[0]&&"/"===y[0].charAt(0);return E&&(n.hostname=n.host=$?"":y.length?y.shift():"",(b=!!(n.host&&n.host.indexOf("@")>0)&&n.host.split("@"))&&(n.auth=b.shift(),n.host=n.hostname=b.shift())),(_=_||n.host&&y.length)&&!$&&y.unshift(""),y.length?n.pathname=y.join("/"):(n.pathname=null,n.path=null),isNull(n.pathname)&&isNull(n.search)||(n.path=(n.pathname?n.pathname:"")+(n.search?n.search:"")),n.auth=e.auth||n.auth,n.slashes=n.slashes||e.slashes,n.href=n.format(),n},Url.prototype.parseHost=function(){return parseHost(this)};var source=createCommonjsModule(function(e){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=4)}([function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(1)),a=r(8),s=r(2),o=r(16);t.validatorSymbol=Symbol("validators"),t.Predicate=class{constructor(e,t={}){this.type=e,this.options=t,this.context={validators:[]},this.context=Object.assign({},this.context,this.options);const r=this.type[0].toLowerCase()+this.type.slice(1);this.addValidator({message:(e,t)=>`Expected ${t&&t.substring(this.type.length+1)||"argument"} to be of type \`${this.type}\` but received type \`${i.default(e)}\``,validator:e=>i.default[r](e)})}[s.testSymbol](e,t,r){for(const{validator:n,message:i}of this.context.validators){if(!0===this.options.optional&&void 0===e)continue;const s=n(e);if(!0===s)continue;let o=r;throw"function"==typeof r&&(o=r()),o=o?`${this.type} \`${o}\``:this.type,new a.ArgumentError(i(e,o,s),t)}}get[t.validatorSymbol](){return this.context.validators}get not(){return o.not(this)}validate(e){return this.addValidator({message:(e,t,r)=>"string"==typeof r?`(${t}) ${r}`:r(t),validator:t=>{const{message:r,validator:n}=e(t);return!!n||r}})}is(e){return this.addValidator({message:(e,t,r)=>r?`(${t}) ${r}`:`Expected ${t} \`${e}\` to pass custom validation function`,validator:e})}addValidator(e){return this.context.validators.push(e),this}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n="undefined"==typeof URL?r(15).URL:URL,{toString:i}=Object.prototype,a=e=>t=>typeof t===e,s=e=>{const t=i.call(e).slice(8,-1);if(t)return t},o=e=>t=>s(t)===e;function f(e){switch(e){case null:return"null";case!0:case!1:return"boolean"}switch(typeof e){case"undefined":return"undefined";case"string":return"string";case"number":return"number";case"bigint":return"bigint";case"symbol":return"symbol"}if(f.function_(e))return"Function";if(f.observable(e))return"Observable";if(f.array(e))return"Array";if(f.buffer(e))return"Buffer";const t=s(e);if(t)return t;if(e instanceof String||e instanceof Boolean||e instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}const u=e=>"object"==typeof e;f.undefined=a("undefined"),f.string=a("string"),f.number=a("number"),f.bigint=a("bigint"),f.function_=a("function"),f.null_=e=>null===e,f.class_=e=>f.function_(e)&&e.toString().startsWith("class "),f.boolean=e=>!0===e||!1===e,f.symbol=a("symbol"),f.numericString=e=>f.string(e)&&e.length>0&&!Number.isNaN(Number(e)),f.array=Array.isArray,f.buffer=e=>!f.nullOrUndefined(e)&&!f.nullOrUndefined(e.constructor)&&f.function_(e.constructor.isBuffer)&&e.constructor.isBuffer(e),f.nullOrUndefined=e=>f.null_(e)||f.undefined(e),f.object=e=>!f.nullOrUndefined(e)&&(f.function_(e)||u(e)),f.iterable=e=>!f.nullOrUndefined(e)&&f.function_(e[Symbol.iterator]),f.asyncIterable=e=>!f.nullOrUndefined(e)&&f.function_(e[Symbol.asyncIterator]),f.generator=e=>f.iterable(e)&&f.function_(e.next)&&f.function_(e.throw),f.nativePromise=e=>o("Promise")(e),f.promise=e=>f.nativePromise(e)||(e=>!f.null_(e)&&u(e)&&f.function_(e.then)&&f.function_(e.catch))(e),f.generatorFunction=o("GeneratorFunction"),f.asyncFunction=o("AsyncFunction"),f.boundFunction=e=>f.function_(e)&&!e.hasOwnProperty("prototype"),f.regExp=o("RegExp"),f.date=o("Date"),f.error=o("Error"),f.map=e=>o("Map")(e),f.set=e=>o("Set")(e),f.weakMap=e=>o("WeakMap")(e),f.weakSet=e=>o("WeakSet")(e),f.int8Array=o("Int8Array"),f.uint8Array=o("Uint8Array"),f.uint8ClampedArray=o("Uint8ClampedArray"),f.int16Array=o("Int16Array"),f.uint16Array=o("Uint16Array"),f.int32Array=o("Int32Array"),f.uint32Array=o("Uint32Array"),f.float32Array=o("Float32Array"),f.float64Array=o("Float64Array"),f.bigint64Array=o("BigInt64Array"),f.biguint64Array=o("BigUint64Array"),f.arrayBuffer=o("ArrayBuffer"),f.sharedArrayBuffer=o("SharedArrayBuffer"),f.dataView=o("DataView"),f.directInstanceOf=(e,t)=>Object.getPrototypeOf(e)===t.prototype,f.urlInstance=e=>o("URL")(e),f.urlString=e=>{if(!f.string(e))return!1;try{return new n(e),!0}catch(e){return!1}},f.truthy=e=>Boolean(e),f.falsy=e=>!e,f.nan=e=>Number.isNaN(e);const c=new Set(["undefined","string","number","bigint","boolean","symbol"]);f.primitive=e=>f.null_(e)||c.has(typeof e),f.integer=e=>Number.isInteger(e),f.safeInteger=e=>Number.isSafeInteger(e),f.plainObject=e=>{if("Object"!==s(e))return!1;const t=Object.getPrototypeOf(e);return null===t||t===Object.getPrototypeOf({})};const d=new Set(["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"]);f.typedArray=e=>{const t=s(e);return void 0!==t&&d.has(t)},f.arrayLike=e=>!f.nullOrUndefined(e)&&!f.function_(e)&&(e=>f.safeInteger(e)&&e>=0)(e.length),f.inRange=(e,t)=>{if(f.number(t))return e>=Math.min(0,t)&&e<=Math.max(t,0);if(f.array(t)&&2===t.length)return e>=Math.min(...t)&&e<=Math.max(...t);throw new TypeError(`Invalid range: ${JSON.stringify(t)}`)};const h=["innerHTML","ownerDocument","style","attributes","nodeValue"];f.domElement=e=>f.object(e)&&1===e.nodeType&&f.string(e.nodeName)&&!f.plainObject(e)&&h.every(t=>t in e),f.observable=e=>!!(e&&(e[Symbol.observable]&&e===e[Symbol.observable]()||e["@@observable"]&&e===e["@@observable"]())),f.nodeStream=e=>!f.nullOrUndefined(e)&&u(e)&&f.function_(e.pipe)&&!f.observable(e),f.infinite=e=>e===1/0||e===-1/0;const l=e=>t=>f.integer(t)&&Math.abs(t%2)===e;f.evenInteger=l(0),f.oddInteger=l(1),f.emptyArray=e=>f.array(e)&&0===e.length,f.nonEmptyArray=e=>f.array(e)&&e.length>0,f.emptyString=e=>f.string(e)&&0===e.length,f.nonEmptyString=e=>f.string(e)&&e.length>0,f.emptyStringOrWhitespace=e=>f.emptyString(e)||(e=>f.string(e)&&!1===/\S/.test(e))(e),f.emptyObject=e=>f.object(e)&&!f.map(e)&&!f.set(e)&&0===Object.keys(e).length,f.nonEmptyObject=e=>f.object(e)&&!f.map(e)&&!f.set(e)&&Object.keys(e).length>0,f.emptySet=e=>f.set(e)&&0===e.size,f.nonEmptySet=e=>f.set(e)&&e.size>0,f.emptyMap=e=>f.map(e)&&0===e.size,f.nonEmptyMap=e=>f.map(e)&&e.size>0;const p=(e,t,r)=>{if(!1===f.function_(t))throw new TypeError(`Invalid predicate: ${JSON.stringify(t)}`);if(0===r.length)throw new TypeError("Invalid number of values");return e.call(r,t)};f.any=(e,...t)=>p(Array.prototype.some,e,t),f.all=(e,...t)=>p(Array.prototype.every,e,t),Object.defineProperties(f,{class:{value:f.class_},function:{value:f.function_},null:{value:f.null_}}),e.exports=f,t.default=f},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.testSymbol=Symbol("test"),t.isPredicate=e=>Boolean(e&&e[t.testSymbol])},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=(e,t,r=5)=>{const n=[];for(const i of t)if(!e.has(i)&&(n.push(i),n.length===r))return n;return 0===n.length||n}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(10)),a=r(11),s=r(0);t.Predicate=s.Predicate;const o=r(2),f=n(r(17)),u=n(r(6)),c=n(r(9)),d=(e,t,r)=>{if(!o.isPredicate(t)&&"string"!=typeof t)throw new TypeError(`Expected second argument to be a predicate or a string, got \`${typeof t}\``);if(o.isPredicate(t)){const r=i.default();c.default(e,()=>a.inferLabel(r),t)}else c.default(e,t,r)};Object.defineProperties(d,{isValid:{value:(e,t)=>{try{return d(e,t),!0}catch(e){return!1}}},create:{value:(e,t)=>r=>{if(o.isPredicate(e)){const t=i.default();c.default(r,()=>a.inferLabel(t),e)}else c.default(r,e,t)}}}),t.default=u.default(f.default(d));var h=r(6);t.StringPredicate=h.StringPredicate,t.NumberPredicate=h.NumberPredicate,t.BooleanPredicate=h.BooleanPredicate,t.ArrayPredicate=h.ArrayPredicate,t.ObjectPredicate=h.ObjectPredicate,t.DatePredicate=h.DatePredicate,t.ErrorPredicate=h.ErrorPredicate,t.MapPredicate=h.MapPredicate,t.WeakMapPredicate=h.WeakMapPredicate,t.SetPredicate=h.SetPredicate,t.WeakSetPredicate=h.WeakSetPredicate,t.AnyPredicate=h.AnyPredicate},function(e,t,r){(function(e){var r="__lodash_hash_undefined__",n=1,i=2,a=9007199254740991,s="[object Arguments]",o="[object Array]",f="[object AsyncFunction]",u="[object Boolean]",c="[object Date]",d="[object Error]",h="[object Function]",l="[object GeneratorFunction]",p="[object Map]",b="[object Number]",m="[object Null]",g="[object Object]",_="[object Proxy]",v="[object RegExp]",y="[object Set]",E="[object String]",w="[object Symbol]",A="[object Undefined]",I="[object ArrayBuffer]",S="[object DataView]",$=/^\[object .+?Constructor\]$/,P=/^(?:0|[1-9]\d*)$/,M={};M["[object Float32Array]"]=M["[object Float64Array]"]=M["[object Int8Array]"]=M["[object Int16Array]"]=M["[object Int32Array]"]=M["[object Uint8Array]"]=M["[object Uint8ClampedArray]"]=M["[object Uint16Array]"]=M["[object Uint32Array]"]=!0,M[s]=M[o]=M[I]=M[u]=M[S]=M[c]=M[d]=M[h]=M[p]=M[b]=M[g]=M[v]=M[y]=M[E]=M["[object WeakMap]"]=!1;var T="object"==typeof commonjsGlobal&&commonjsGlobal&&commonjsGlobal.Object===Object&&commonjsGlobal,L="object"==typeof self&&self&&self.Object===Object&&self,B=T||L||Function("return this")(),C=t&&!t.nodeType&&t,R=C&&"object"==typeof e&&e&&!e.nodeType&&e,x=R&&R.exports===C,k=x&&T.process,N=function(){try{return k&&k.binding&&k.binding("util")}catch(e){}}(),O=N&&N.isTypedArray;function D(e,t){for(var r=-1,n=null==e?0:e.length;++ru))return!1;var d=o.get(e);if(d&&o.get(t))return d==t;var h=-1,l=!0,p=r&i?new Ie:void 0;for(o.set(e,t),o.set(t,e);++h-1},we.prototype.set=function(e,t){var r=this.__data__,n=$e(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this},Ae.prototype.clear=function(){this.size=0,this.__data__={hash:new Ee,map:new(ue||we),string:new Ee}},Ae.prototype.delete=function(e){var t=Ce(this,e).delete(e);return this.size-=t?1:0,t},Ae.prototype.get=function(e){return Ce(this,e).get(e)},Ae.prototype.has=function(e){return Ce(this,e).has(e)},Ae.prototype.set=function(e,t){var r=Ce(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this},Ie.prototype.add=Ie.prototype.push=function(e){return this.__data__.set(e,r),this},Ie.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.clear=function(){this.__data__=new we,this.size=0},Se.prototype.delete=function(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r},Se.prototype.get=function(e){return this.__data__.get(e)},Se.prototype.has=function(e){return this.__data__.has(e)},Se.prototype.set=function(e,t){var r=this.__data__;if(r instanceof we){var n=r.__data__;if(!ue||n.length<199)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Ae(n)}return r.set(e,t),this.size=r.size,this};var xe=ae?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var r=-1,n=null==e?0:e.length,i=0,a=[];++r-1&&e%1==0&&e-1&&e%1==0&&e<=a}function Ye(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function He(e){return null!=e&&"object"==typeof e}var qe=O?function(e){return function(t){return e(t)}}(O):function(e){return He(e)&&ze(e.length)&&!!M[Pe(e)]};function Fe(e){return null!=(t=e)&&ze(t.length)&&!Ue(t)?function(e,t){var r=Ve(e),n=!r&&je(e),i=!r&&!n&&Ke(e),a=!r&&!n&&!i&&qe(e),s=r||n||i||a,o=s?function(e,t){for(var r=-1,n=Array(e);++r(Object.defineProperties(e,{string:{get:()=>new n.StringPredicate(t)},number:{get:()=>new i.NumberPredicate(t)},boolean:{get:()=>new a.BooleanPredicate(t)},undefined:{get:()=>new s.Predicate("undefined",t)},null:{get:()=>new s.Predicate("null",t)},nullOrUndefined:{get:()=>new s.Predicate("nullOrUndefined",t)},nan:{get:()=>new s.Predicate("nan",t)},symbol:{get:()=>new s.Predicate("symbol",t)},array:{get:()=>new o.ArrayPredicate(t)},object:{get:()=>new f.ObjectPredicate(t)},date:{get:()=>new u.DatePredicate(t)},error:{get:()=>new c.ErrorPredicate(t)},map:{get:()=>new d.MapPredicate(t)},weakMap:{get:()=>new h.WeakMapPredicate(t)},set:{get:()=>new l.SetPredicate(t)},weakSet:{get:()=>new p.WeakSetPredicate(t)},function:{get:()=>new s.Predicate("Function",t)},buffer:{get:()=>new s.Predicate("Buffer",t)},regExp:{get:()=>new s.Predicate("RegExp",t)},promise:{get:()=>new s.Predicate("Promise",t)},typedArray:{get:()=>new s.Predicate("TypedArray",t)},int8Array:{get:()=>new s.Predicate("Int8Array",t)},uint8Array:{get:()=>new s.Predicate("Uint8Array",t)},uint8ClampedArray:{get:()=>new s.Predicate("Uint8ClampedArray",t)},int16Array:{get:()=>new s.Predicate("Int16Array",t)},uint16Array:{get:()=>new s.Predicate("Uint16Array",t)},int32Array:{get:()=>new s.Predicate("Int32Array",t)},uint32Array:{get:()=>new s.Predicate("Uint32Array",t)},float32Array:{get:()=>new s.Predicate("Float32Array",t)},float64Array:{get:()=>new s.Predicate("Float64Array",t)},arrayBuffer:{get:()=>new s.Predicate("ArrayBuffer",t)},dataView:{get:()=>new s.Predicate("DataView",t)},iterable:{get:()=>new s.Predicate("Iterable",t)},any:{value:(...e)=>new b.AnyPredicate(e,t)}}),e)},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(4));t.default=(e,t)=>{try{for(const r of e)i.default(r,t);return!0}catch(e){return e.message}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.ArgumentError=class extends Error{constructor(e,t){super(e),"captureStackTrace"in Error&&Error.captureStackTrace(this,t),this.name="ArgumentError"}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(2);t.default=function e(t,r,i){i[n.testSymbol](t,e,r)}},function(e,t,r){const n=()=>{const e=Error.prepareStackTrace;Error.prepareStackTrace=(e,t)=>t;const t=(new Error).stack.slice(1);return Error.prepareStackTrace=e,t};e.exports=n,e.exports.default=n},function(e,t,r){var n=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t},i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const a=n(r(12)),s=i(r(13)),o=i(r(14)),f=/^.*?\((.*?)[,)]/;t.inferLabel=e=>{if(!o.default)return;const t=e[1],r=t.getFileName(),n=t.getLineNumber(),i=t.getColumnNumber();if(!r||null===n||null===i)return;let u=[];try{u=a.readFileSync(r,"utf8").split("\n")}catch(e){return}let c=u[n-1];if(!c)return;c=c.slice(i-1);const d=f.exec(c);if(!d||!d[1])return;const h=d[1];return s.default(h)||s.default(h.split(".").pop())?h:void 0}},function(e,t){e.exports=require$$0},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=/^[a-z$_][a-z$_0-9]*$/i,i=new Set(["undefined","null","true","false","super","this","Infinity","NaN"]);t.default=e=>e&&!i.has(e)&&n.test(e)},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0}),t.default=Boolean("undefined"!=typeof process&&process.versions&&process.versions.node)},function(e,t){e.exports=require$$1},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.not=e=>{const t=e.addValidator;return e.addValidator=r=>{const i=r.validator,a=r.message;return r.message=(e,t)=>`[NOT] ${a(e,t)}`,r.validator=e=>!i(e),e[n.validatorSymbol].push(r),e.addValidator=t,e},e}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(6));t.default=e=>(Object.defineProperties(e,{optional:{get:()=>i.default({},{optional:!0})}}),e)},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(1)),a=n(r(19)),s=r(0);t.StringPredicate=class extends s.Predicate{constructor(e){super("string",e)}length(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have length \`${e}\`, got \`${t}\``,validator:t=>t.length===e})}minLength(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a minimum length of \`${e}\`, got \`${t}\``,validator:t=>t.length>=e})}maxLength(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a maximum length of \`${e}\`, got \`${t}\``,validator:t=>t.length<=e})}matches(e){return this.addValidator({message:(t,r)=>`Expected ${r} to match \`${e}\`, got \`${t}\``,validator:t=>e.test(t)})}startsWith(e){return this.addValidator({message:(t,r)=>`Expected ${r} to start with \`${e}\`, got \`${t}\``,validator:t=>t.startsWith(e)})}endsWith(e){return this.addValidator({message:(t,r)=>`Expected ${r} to end with \`${e}\`, got \`${t}\``,validator:t=>t.endsWith(e)})}includes(e){return this.addValidator({message:(t,r)=>`Expected ${r} to include \`${e}\`, got \`${t}\``,validator:t=>t.includes(e)})}oneOf(e){return this.addValidator({message:(t,r)=>{let n=JSON.stringify(e);if(e.length>10){const t=e.length-10;n=JSON.stringify(e.slice(0,10)).replace(/]$/,`,…+${t} more]`)}return`Expected ${r} to be one of \`${n}\`, got \`${t}\``},validator:t=>e.includes(t)})}get empty(){return this.addValidator({message:(e,t)=>`Expected ${t} to be empty, got \`${e}\``,validator:e=>""===e})}get nonEmpty(){return this.addValidator({message:(e,t)=>`Expected ${t} to not be empty`,validator:e=>""!==e})}equals(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be equal to \`${e}\`, got \`${t}\``,validator:t=>t===e})}get alphanumeric(){return this.addValidator({message:(e,t)=>`Expected ${t} to be alphanumeric, got \`${e}\``,validator:e=>/^[a-z\d]+$/i.test(e)})}get alphabetical(){return this.addValidator({message:(e,t)=>`Expected ${t} to be alphabetical, got \`${e}\``,validator:e=>/^[a-z]+$/gi.test(e)})}get numeric(){return this.addValidator({message:(e,t)=>`Expected ${t} to be numeric, got \`${e}\``,validator:e=>/^(\+|-)?\d+$/i.test(e)})}get date(){return this.addValidator({message:(e,t)=>`Expected ${t} to be a date, got \`${e}\``,validator:a.default})}get lowercase(){return this.addValidator({message:(e,t)=>`Expected ${t} to be lowercase, got \`${e}\``,validator:e=>""!==e.trim()&&e===e.toLowerCase()})}get uppercase(){return this.addValidator({message:(e,t)=>`Expected ${t} to be uppercase, got \`${e}\``,validator:e=>""!==e.trim()&&e===e.toUpperCase()})}get url(){return this.addValidator({message:(e,t)=>`Expected ${t} to be a URL, got \`${e}\``,validator:i.default.urlString})}}},function(e,t,r){e.exports=function(e){return!isNaN(Date.parse(e))}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(1)),a=r(0);t.NumberPredicate=class extends a.Predicate{constructor(e){super("number",e)}inRange(e,t){return this.addValidator({message:(r,n)=>`Expected ${n} to be in range [${e}..${t}], got ${r}`,validator:r=>i.default.inRange(r,[e,t])})}greaterThan(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be greater than ${e}, got ${t}`,validator:t=>t>e})}greaterThanOrEqual(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be greater than or equal to ${e}, got ${t}`,validator:t=>t>=e})}lessThan(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be less than ${e}, got ${t}`,validator:t=>t`Expected ${r} to be less than or equal to ${e}, got ${t}`,validator:t=>t<=e})}equal(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be equal to ${e}, got ${t}`,validator:t=>t===e})}oneOf(e){return this.addValidator({message:(t,r)=>{let n=JSON.stringify(e);if(e.length>10){const t=e.length-10;n=JSON.stringify(e.slice(0,10)).replace(/]$/,`,…+${t} more]`)}return`Expected ${r} to be one of \`${n}\`, got ${t}`},validator:t=>e.includes(t)})}get integer(){return this.addValidator({message:(e,t)=>`Expected ${t} to be an integer, got ${e}`,validator:e=>i.default.integer(e)})}get finite(){return this.addValidator({message:(e,t)=>`Expected ${t} to be finite, got ${e}`,validator:e=>!i.default.infinite(e)})}get infinite(){return this.addValidator({message:(e,t)=>`Expected ${t} to be infinite, got ${e}`,validator:e=>i.default.infinite(e)})}get positive(){return this.addValidator({message:(e,t)=>`Expected ${t} to be positive, got ${e}`,validator:e=>e>0})}get negative(){return this.addValidator({message:(e,t)=>`Expected ${t} to be negative, got ${e}`,validator:e=>e<0})}get integerOrInfinite(){return this.addValidator({message:(e,t)=>`Expected ${t} to be an integer or infinite, got ${e}`,validator:e=>i.default.integer(e)||i.default.infinite(e)})}get uint8(){return this.integer.inRange(0,255)}get uint16(){return this.integer.inRange(0,65535)}get uint32(){return this.integer.inRange(0,4294967295)}get int8(){return this.integer.inRange(-128,127)}get int16(){return this.integer.inRange(-32768,32767)}get int32(){return this.integer.inRange(-2147483648,2147483647)}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.BooleanPredicate=class extends n.Predicate{constructor(e){super("boolean",e)}get true(){return this.addValidator({message:(e,t)=>`Expected ${t} to be true, got ${e}`,validator:e=>!0===e})}get false(){return this.addValidator({message:(e,t)=>`Expected ${t} to be false, got ${e}`,validator:e=>!1===e})}}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(5)),a=n(r(4)),s=r(0);t.ArrayPredicate=class extends s.Predicate{constructor(e){super("array",e)}length(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have length \`${e}\`, got \`${t.length}\``,validator:t=>t.length===e})}minLength(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a minimum length of \`${e}\`, got \`${t.length}\``,validator:t=>t.length>=e})}maxLength(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a maximum length of \`${e}\`, got \`${t.length}\``,validator:t=>t.length<=e})}startsWith(e){return this.addValidator({message:(t,r)=>`Expected ${r} to start with \`${e}\`, got \`${t[0]}\``,validator:t=>t[0]===e})}endsWith(e){return this.addValidator({message:(t,r)=>`Expected ${r} to end with \`${e}\`, got \`${t[t.length-1]}\``,validator:t=>t[t.length-1]===e})}includes(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to include all elements of \`${JSON.stringify(e)}\`, got \`${JSON.stringify(t)}\``,validator:t=>e.every(e=>-1!==t.indexOf(e))})}includesAny(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to include any element of \`${JSON.stringify(e)}\`, got \`${JSON.stringify(t)}\``,validator:t=>e.some(e=>-1!==t.indexOf(e))})}get empty(){return this.addValidator({message:(e,t)=>`Expected ${t} to be empty, got \`${JSON.stringify(e)}\``,validator:e=>0===e.length})}get nonEmpty(){return this.addValidator({message:(e,t)=>`Expected ${t} to not be empty`,validator:e=>e.length>0})}deepEqual(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be deeply equal to \`${JSON.stringify(e)}\`, got \`${JSON.stringify(t)}\``,validator:t=>i.default(t,e)})}ofType(e){let t;return this.addValidator({message:(e,r)=>`(${r}) ${t}`,validator:r=>{try{for(const t of r)a.default(t,e);return!0}catch(e){return t=e.message,!1}}})}}},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){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(1)),a=n(r(25)),s=n(r(5)),o=r(0),f=n(r(3)),u=n(r(7)),c=n(r(27)),d=r(28);t.ObjectPredicate=class extends o.Predicate{constructor(e){super("object",e)}get plain(){return this.addValidator({message:(e,t)=>`Expected ${t} to be a plain object`,validator:e=>i.default.plainObject(e)})}get empty(){return this.addValidator({message:(e,t)=>`Expected ${t} to be empty, got \`${JSON.stringify(e)}\``,validator:e=>0===Object.keys(e).length})}get nonEmpty(){return this.addValidator({message:(e,t)=>`Expected ${t} to not be empty`,validator:e=>Object.keys(e).length>0})}valuesOfType(e){return this.addValidator({message:(e,t,r)=>`(${t}) ${r}`,validator:t=>{const r=Object.keys(t).map(e=>t[e]);return u.default(r,e)}})}deepValuesOfType(e){return this.addValidator({message:(e,t,r)=>`(${t}) ${r}`,validator:t=>c.default(t,e)})}deepEqual(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be deeply equal to \`${JSON.stringify(e)}\`, got \`${JSON.stringify(t)}\``,validator:t=>s.default(t,e)})}instanceOf(e){return this.addValidator({message:(t,r)=>{let n=t.constructor.name;return n&&"Object"!==n||(n=JSON.stringify(t)),`Expected ${r} \`${n}\` to be of type \`${e.name}\``},validator:t=>t instanceof e})}hasKeys(...e){return this.addValidator({message:(e,t,r)=>`Expected ${t} to have keys \`${JSON.stringify(r)}\``,validator:t=>f.default({has:e=>a.default.has(t,e)},e)})}hasAnyKeys(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to have any key of \`${JSON.stringify(e)}\``,validator:t=>e.some(e=>a.default.has(t,e))})}partialShape(e){return this.addValidator({message:(e,t,r)=>`${r.replace("Expected","Expected property")} in ${t}`,validator:t=>d.partial(t,e)})}exactShape(e){return this.addValidator({message:(e,t,r)=>`${r.replace("Expected","Expected property")} in ${t}`,validator:t=>d.exact(t,e)})}}},function(e,t,r){const n=r(26);function i(e){const t=e.split("."),r=[];for(let e=0;ei.default.plainObject(e)?Object.keys(e).every(r=>s(e[r],t)):(a.default(e,t),!0);t.default=(e,t)=>{try{return s(e,t)}catch(e){return e.message}}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(1)),a=n(r(9)),s=r(2);t.partial=function e(t,r,n){try{for(const o of Object.keys(r)){const f=n?`${n}.${o}`:o;if(s.isPredicate(r[o]))a.default(t[o],f,r[o]);else if(i.default.plainObject(r[o])){const n=e(t[o],r[o],f);if(!0!==n)return n}}return!0}catch(e){return e.message}},t.exact=function e(t,r,n){try{const o=new Set(Object.keys(t));for(const f of Object.keys(r)){o.delete(f);const u=n?`${n}.${f}`:f;if(s.isPredicate(r[f]))a.default(t[f],u,r[f]);else if(i.default.plainObject(r[f])){if(!Object.prototype.hasOwnProperty.call(t,f))return`Expected \`${u}\` to exist`;const n=e(t[f],r[f],u);if(!0!==n)return n}}if(o.size>0){const e=Array.from(o.keys())[0];return`Did not expect property \`${n?`${n}.${e}`:e}\` to exist, got \`${t[e]}\``}return!0}catch(e){return e.message}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.DatePredicate=class extends n.Predicate{constructor(e){super("date",e)}before(e){return this.addValidator({message:(t,r)=>`Expected ${r} ${t.toISOString()} to be before ${e.toISOString()}`,validator:t=>t.getTime()`Expected ${r} ${t.toISOString()} to be after ${e.toISOString()}`,validator:t=>t.getTime()>e.getTime()})}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(0);t.ErrorPredicate=class extends n.Predicate{constructor(e){super("error",e)}name(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have name \`${e}\`, got \`${t.name}\``,validator:t=>t.name===e})}message(e){return this.addValidator({message:(t,r)=>`Expected ${r} message to be \`${e}\`, got \`${t.message}\``,validator:t=>t.message===e})}messageIncludes(e){return this.addValidator({message:(t,r)=>`Expected ${r} message to include \`${e}\`, got \`${t.message}\``,validator:t=>t.message.includes(e)})}hasKeys(...e){return this.addValidator({message:(t,r)=>`Expected ${r} message to have keys \`${e.join("`, `")}\``,validator:t=>e.every(e=>t.hasOwnProperty(e))})}instanceOf(e){return this.addValidator({message:(t,r)=>`Expected ${r} \`${t.name}\` to be of type \`${e.name}\``,validator:t=>t instanceof e})}get typeError(){return this.instanceOf(TypeError)}get evalError(){return this.instanceOf(EvalError)}get rangeError(){return this.instanceOf(RangeError)}get referenceError(){return this.instanceOf(ReferenceError)}get syntaxError(){return this.instanceOf(SyntaxError)}get uriError(){return this.instanceOf(URIError)}}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(5)),a=r(0),s=n(r(3)),o=n(r(7));t.MapPredicate=class extends a.Predicate{constructor(e){super("Map",e)}size(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have size \`${e}\`, got \`${t.size}\``,validator:t=>t.size===e})}minSize(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a minimum size of \`${e}\`, got \`${t.size}\``,validator:t=>t.size>=e})}maxSize(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a maximum size of \`${e}\`, got \`${t.size}\``,validator:t=>t.size<=e})}hasKeys(...e){return this.addValidator({message:(e,t,r)=>`Expected ${t} to have keys \`${JSON.stringify(r)}\``,validator:t=>s.default(t,e)})}hasAnyKeys(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to have any key of \`${JSON.stringify(e)}\``,validator:t=>e.some(e=>t.has(e))})}hasValues(...e){return this.addValidator({message:(e,t,r)=>`Expected ${t} to have values \`${JSON.stringify(r)}\``,validator:t=>s.default(new Set(t.values()),e)})}hasAnyValues(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to have any value of \`${JSON.stringify(e)}\``,validator:t=>{const r=new Set(t.values());return e.some(e=>r.has(e))}})}keysOfType(e){return this.addValidator({message:(e,t,r)=>`(${t}) ${r}`,validator:t=>o.default(t.keys(),e)})}valuesOfType(e){return this.addValidator({message:(e,t,r)=>`(${t}) ${r}`,validator:t=>o.default(t.values(),e)})}get empty(){return this.addValidator({message:(e,t)=>`Expected ${t} to be empty, got \`${JSON.stringify(Array.from(e))}\``,validator:e=>0===e.size})}get nonEmpty(){return this.addValidator({message:(e,t)=>`Expected ${t} to not be empty`,validator:e=>e.size>0})}deepEqual(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be deeply equal to \`${JSON.stringify(Array.from(e))}\`, got \`${JSON.stringify(Array.from(t))}\``,validator:t=>i.default(t,e)})}}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(0),a=n(r(3));t.WeakMapPredicate=class extends i.Predicate{constructor(e){super("WeakMap",e)}hasKeys(...e){return this.addValidator({message:(e,t,r)=>`Expected ${t} to have keys \`${JSON.stringify(r)}\``,validator:t=>a.default(t,e)})}hasAnyKeys(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to have any key of \`${JSON.stringify(e)}\``,validator:t=>e.some(e=>t.has(e))})}}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=n(r(5)),a=r(0),s=n(r(3)),o=n(r(7));t.SetPredicate=class extends a.Predicate{constructor(e){super("Set",e)}size(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have size \`${e}\`, got \`${t.size}\``,validator:t=>t.size===e})}minSize(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a minimum size of \`${e}\`, got \`${t.size}\``,validator:t=>t.size>=e})}maxSize(e){return this.addValidator({message:(t,r)=>`Expected ${r} to have a maximum size of \`${e}\`, got \`${t.size}\``,validator:t=>t.size<=e})}has(...e){return this.addValidator({message:(e,t,r)=>`Expected ${t} to have items \`${JSON.stringify(r)}\``,validator:t=>s.default(t,e)})}hasAny(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to have any item of \`${JSON.stringify(e)}\``,validator:t=>e.some(e=>t.has(e))})}ofType(e){return this.addValidator({message:(e,t,r)=>`(${t}) ${r}`,validator:t=>o.default(t,e)})}get empty(){return this.addValidator({message:(e,t)=>`Expected ${t} to be empty, got \`${JSON.stringify(Array.from(e))}\``,validator:e=>0===e.size})}get nonEmpty(){return this.addValidator({message:(e,t)=>`Expected ${t} to not be empty`,validator:e=>e.size>0})}deepEqual(e){return this.addValidator({message:(t,r)=>`Expected ${r} to be deeply equal to \`${JSON.stringify(Array.from(e))}\`, got \`${JSON.stringify(Array.from(t))}\``,validator:t=>i.default(t,e)})}}},function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const i=r(0),a=n(r(3));t.WeakSetPredicate=class extends i.Predicate{constructor(e){super("WeakSet",e)}has(...e){return this.addValidator({message:(e,t,r)=>`Expected ${t} to have items \`${JSON.stringify(r)}\``,validator:t=>a.default(t,e)})}hasAny(...e){return this.addValidator({message:(t,r)=>`Expected ${r} to have any item of \`${JSON.stringify(e)}\``,validator:t=>e.some(e=>t.has(e))})}}},function(e,t,r){Object.defineProperty(t,"__esModule",{value:!0});const n=r(8),i=r(2);t.AnyPredicate=class{constructor(e,t={}){this.predicates=e,this.options=t}[i.testSymbol](e,t,r){const i=["Any predicate failed with the following errors:"];for(const n of this.predicates)try{return void t(e,r,n)}catch(t){if(void 0===e&&!0===this.options.optional)return;i.push(`- ${t.message}`)}throw new n.ArgumentError(i.join("\n"),t)}}}]);const t=e.exports;e.exports=t.default,Object.assign(e.exports,t)}),ow=unwrapExports(source),_nodeResolve_empty={},_nodeResolve_empty$1=Object.freeze({default:_nodeResolve_empty}),require$$0$1=getCjsExportFromNamespace(_nodeResolve_empty$1),bn=createCommonjsModule(function(e){!function(e,t){function r(e,t){if(!e)throw new Error(t||"Assertion failed")}function n(e,t){e.super_=t;var r=function(){};r.prototype=t.prototype,e.prototype=new r,e.prototype.constructor=e}function i(e,t,r){if(i.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(r=t,t=10),this._init(e||0,t||10,r||"be"))}var a;"object"==typeof e?e.exports=i:t.BN=i,i.BN=i,i.wordSize=26;try{a=require$$0$1.Buffer}catch(e){}function s(e,t,r){for(var n=0,i=Math.min(e.length,r),a=t;a=49&&s<=54?s-49+10:s>=17&&s<=22?s-17+10:15&s}return n}function o(e,t,r,n){for(var i=0,a=Math.min(e.length,r),s=t;s=49?o-49+10:o>=17?o-17+10:o}return i}i.isBN=function(e){return e instanceof i||null!==e&&"object"==typeof e&&e.constructor.wordSize===i.wordSize&&Array.isArray(e.words)},i.max=function(e,t){return e.cmp(t)>0?e:t},i.min=function(e,t){return e.cmp(t)<0?e:t},i.prototype._init=function(e,t,n){if("number"==typeof e)return this._initNumber(e,t,n);if("object"==typeof e)return this._initArray(e,t,n);"hex"===t&&(t=16),r(t===(0|t)&&t>=2&&t<=36);var 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"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initNumber=function(e,t,n){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(r(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===n&&this._initArray(this.toArray(),t,n)},i.prototype._initArray=function(e,t,n){if(r("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var i=0;i=0;i-=3)s=e[i]|e[i-1]<<8|e[i-2]<<16,this.words[a]|=s<>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);else if("le"===n)for(i=0,a=0;i>>26-o&67108863,(o+=24)>=26&&(o-=26,a++);return this.strip()},i.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=s(e,r,r+6),this.words[n]|=i<>>26-a&4194303,(a+=24)>=26&&(a-=26,n++);r+6!==t&&(i=s(e,t,r+6),this.words[n]|=i<>>26-a&4194303),this.strip()},i.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 a=e.length-r,s=a%n,f=Math.min(a,a-s)+r,u=0,c=r;c1&&0===this.words[this.length-1];)this.length--;return this._normSign()},i.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},i.prototype.inspect=function(){return(this.red?""};var f=["","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"],u=[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 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],a=0|t.words[0],s=i*a,o=67108863&s,f=s/67108864|0;r.words[0]=o;for(var u=1;u>>26,d=67108863&f,h=Math.min(u,t.length-1),l=Math.max(0,u-e.length+1);l<=h;l++){var p=u-l|0;c+=(s=(i=0|e.words[p])*(a=0|t.words[l])+d)/67108864|0,d=67108863&s}r.words[u]=0|d,f=0|c}return 0!==f?r.words[u]=0|f:r.length--,r.strip()}i.prototype.toString=function(e,t){var n;if(t=0|t||1,16===(e=e||10)||"hex"===e){n="";for(var i=0,a=0,s=0;s>>24-i&16777215)||s!==this.length-1?f[6-d.length]+d+n:d+n,(i+=2)>=26&&(i-=26,s--)}for(0!==a&&(n=a.toString(16)+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}if(e===(0|e)&&e>=2&&e<=36){var h=u[e],l=c[e];n="";var p=this.clone();for(p.negative=0;!p.isZero();){var b=p.modn(l).toString(e);n=(p=p.idivn(l)).isZero()?b+n:f[h-b.length]+b+n}for(this.isZero()&&(n="0"+n);n.length%t!=0;)n="0"+n;return 0!==this.negative&&(n="-"+n),n}r(!1,"Base should be between 2 and 36")},i.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&r(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},i.prototype.toJSON=function(){return this.toString(16)},i.prototype.toBuffer=function(e,t){return r(void 0!==a),this.toArrayLike(a,e,t)},i.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},i.prototype.toArrayLike=function(e,t,n){var i=this.byteLength(),a=n||Math.max(1,i);r(i<=a,"byte array longer than desired length"),r(a>0,"Requested array length <= 0"),this.strip();var s,o,f="le"===t,u=new e(a),c=this.clone();if(f){for(o=0;!c.isZero();o++)s=c.andln(255),c.iushrn(8),u[o]=s;for(;o=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},i.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},i.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},i.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;te.length?this.clone().ior(e):e.clone().ior(this)},i.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},i.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var r=0;re.length?this.clone().iand(e):e.clone().iand(this)},i.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},i.prototype.iuxor=function(e){var t,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)},i.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},i.prototype.inotn=function(e){r("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),n=e%26;this._expand(t),n>0&&t--;for(var i=0;i0&&(this.words[i]=~this.words[i]&67108863>>26-n),this.strip()},i.prototype.notn=function(e){return this.clone().inotn(e)},i.prototype.setn=function(e,t){r("number"==typeof e&&e>=0);var n=e/26|0,i=e%26;return this._expand(n+1),this.words[n]=t?this.words[n]|1<e.length?(r=this,n=e):(r=e,n=this);for(var i=0,a=0;a>>26;for(;0!==i&&a>>26;if(this.length=r.length,0!==i)this.words[this.length]=i,this.length++;else if(r!==this)for(;ae.length?this.clone().iadd(e):e.clone().iadd(this)},i.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var 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 a=0,s=0;s>26,this.words[s]=67108863&t;for(;0!==a&&s>26,this.words[s]=67108863&t;if(0===a&&s>>13,l=0|s[1],p=8191&l,b=l>>>13,m=0|s[2],g=8191&m,_=m>>>13,v=0|s[3],y=8191&v,E=v>>>13,w=0|s[4],A=8191&w,I=w>>>13,S=0|s[5],$=8191&S,P=S>>>13,M=0|s[6],T=8191&M,L=M>>>13,B=0|s[7],C=8191&B,R=B>>>13,x=0|s[8],k=8191&x,N=x>>>13,O=0|s[9],D=8191&O,j=O>>>13,V=0|o[0],K=8191&V,U=V>>>13,z=0|o[1],Y=8191&z,H=z>>>13,q=0|o[2],F=8191&q,W=q>>>13,G=0|o[3],J=8191&G,Z=G>>>13,X=0|o[4],Q=8191&X,ee=X>>>13,te=0|o[5],re=8191&te,ne=te>>>13,ie=0|o[6],ae=8191&ie,se=ie>>>13,oe=0|o[7],fe=8191&oe,ue=oe>>>13,ce=0|o[8],de=8191&ce,he=ce>>>13,le=0|o[9],pe=8191&le,be=le>>>13;r.negative=e.negative^t.negative,r.length=19;var me=(u+(n=Math.imul(d,K))|0)+((8191&(i=(i=Math.imul(d,U))+Math.imul(h,K)|0))<<13)|0;u=((a=Math.imul(h,U))+(i>>>13)|0)+(me>>>26)|0,me&=67108863,n=Math.imul(p,K),i=(i=Math.imul(p,U))+Math.imul(b,K)|0,a=Math.imul(b,U);var ge=(u+(n=n+Math.imul(d,Y)|0)|0)+((8191&(i=(i=i+Math.imul(d,H)|0)+Math.imul(h,Y)|0))<<13)|0;u=((a=a+Math.imul(h,H)|0)+(i>>>13)|0)+(ge>>>26)|0,ge&=67108863,n=Math.imul(g,K),i=(i=Math.imul(g,U))+Math.imul(_,K)|0,a=Math.imul(_,U),n=n+Math.imul(p,Y)|0,i=(i=i+Math.imul(p,H)|0)+Math.imul(b,Y)|0,a=a+Math.imul(b,H)|0;var _e=(u+(n=n+Math.imul(d,F)|0)|0)+((8191&(i=(i=i+Math.imul(d,W)|0)+Math.imul(h,F)|0))<<13)|0;u=((a=a+Math.imul(h,W)|0)+(i>>>13)|0)+(_e>>>26)|0,_e&=67108863,n=Math.imul(y,K),i=(i=Math.imul(y,U))+Math.imul(E,K)|0,a=Math.imul(E,U),n=n+Math.imul(g,Y)|0,i=(i=i+Math.imul(g,H)|0)+Math.imul(_,Y)|0,a=a+Math.imul(_,H)|0,n=n+Math.imul(p,F)|0,i=(i=i+Math.imul(p,W)|0)+Math.imul(b,F)|0,a=a+Math.imul(b,W)|0;var ve=(u+(n=n+Math.imul(d,J)|0)|0)+((8191&(i=(i=i+Math.imul(d,Z)|0)+Math.imul(h,J)|0))<<13)|0;u=((a=a+Math.imul(h,Z)|0)+(i>>>13)|0)+(ve>>>26)|0,ve&=67108863,n=Math.imul(A,K),i=(i=Math.imul(A,U))+Math.imul(I,K)|0,a=Math.imul(I,U),n=n+Math.imul(y,Y)|0,i=(i=i+Math.imul(y,H)|0)+Math.imul(E,Y)|0,a=a+Math.imul(E,H)|0,n=n+Math.imul(g,F)|0,i=(i=i+Math.imul(g,W)|0)+Math.imul(_,F)|0,a=a+Math.imul(_,W)|0,n=n+Math.imul(p,J)|0,i=(i=i+Math.imul(p,Z)|0)+Math.imul(b,J)|0,a=a+Math.imul(b,Z)|0;var ye=(u+(n=n+Math.imul(d,Q)|0)|0)+((8191&(i=(i=i+Math.imul(d,ee)|0)+Math.imul(h,Q)|0))<<13)|0;u=((a=a+Math.imul(h,ee)|0)+(i>>>13)|0)+(ye>>>26)|0,ye&=67108863,n=Math.imul($,K),i=(i=Math.imul($,U))+Math.imul(P,K)|0,a=Math.imul(P,U),n=n+Math.imul(A,Y)|0,i=(i=i+Math.imul(A,H)|0)+Math.imul(I,Y)|0,a=a+Math.imul(I,H)|0,n=n+Math.imul(y,F)|0,i=(i=i+Math.imul(y,W)|0)+Math.imul(E,F)|0,a=a+Math.imul(E,W)|0,n=n+Math.imul(g,J)|0,i=(i=i+Math.imul(g,Z)|0)+Math.imul(_,J)|0,a=a+Math.imul(_,Z)|0,n=n+Math.imul(p,Q)|0,i=(i=i+Math.imul(p,ee)|0)+Math.imul(b,Q)|0,a=a+Math.imul(b,ee)|0;var Ee=(u+(n=n+Math.imul(d,re)|0)|0)+((8191&(i=(i=i+Math.imul(d,ne)|0)+Math.imul(h,re)|0))<<13)|0;u=((a=a+Math.imul(h,ne)|0)+(i>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,n=Math.imul(T,K),i=(i=Math.imul(T,U))+Math.imul(L,K)|0,a=Math.imul(L,U),n=n+Math.imul($,Y)|0,i=(i=i+Math.imul($,H)|0)+Math.imul(P,Y)|0,a=a+Math.imul(P,H)|0,n=n+Math.imul(A,F)|0,i=(i=i+Math.imul(A,W)|0)+Math.imul(I,F)|0,a=a+Math.imul(I,W)|0,n=n+Math.imul(y,J)|0,i=(i=i+Math.imul(y,Z)|0)+Math.imul(E,J)|0,a=a+Math.imul(E,Z)|0,n=n+Math.imul(g,Q)|0,i=(i=i+Math.imul(g,ee)|0)+Math.imul(_,Q)|0,a=a+Math.imul(_,ee)|0,n=n+Math.imul(p,re)|0,i=(i=i+Math.imul(p,ne)|0)+Math.imul(b,re)|0,a=a+Math.imul(b,ne)|0;var we=(u+(n=n+Math.imul(d,ae)|0)|0)+((8191&(i=(i=i+Math.imul(d,se)|0)+Math.imul(h,ae)|0))<<13)|0;u=((a=a+Math.imul(h,se)|0)+(i>>>13)|0)+(we>>>26)|0,we&=67108863,n=Math.imul(C,K),i=(i=Math.imul(C,U))+Math.imul(R,K)|0,a=Math.imul(R,U),n=n+Math.imul(T,Y)|0,i=(i=i+Math.imul(T,H)|0)+Math.imul(L,Y)|0,a=a+Math.imul(L,H)|0,n=n+Math.imul($,F)|0,i=(i=i+Math.imul($,W)|0)+Math.imul(P,F)|0,a=a+Math.imul(P,W)|0,n=n+Math.imul(A,J)|0,i=(i=i+Math.imul(A,Z)|0)+Math.imul(I,J)|0,a=a+Math.imul(I,Z)|0,n=n+Math.imul(y,Q)|0,i=(i=i+Math.imul(y,ee)|0)+Math.imul(E,Q)|0,a=a+Math.imul(E,ee)|0,n=n+Math.imul(g,re)|0,i=(i=i+Math.imul(g,ne)|0)+Math.imul(_,re)|0,a=a+Math.imul(_,ne)|0,n=n+Math.imul(p,ae)|0,i=(i=i+Math.imul(p,se)|0)+Math.imul(b,ae)|0,a=a+Math.imul(b,se)|0;var Ae=(u+(n=n+Math.imul(d,fe)|0)|0)+((8191&(i=(i=i+Math.imul(d,ue)|0)+Math.imul(h,fe)|0))<<13)|0;u=((a=a+Math.imul(h,ue)|0)+(i>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,n=Math.imul(k,K),i=(i=Math.imul(k,U))+Math.imul(N,K)|0,a=Math.imul(N,U),n=n+Math.imul(C,Y)|0,i=(i=i+Math.imul(C,H)|0)+Math.imul(R,Y)|0,a=a+Math.imul(R,H)|0,n=n+Math.imul(T,F)|0,i=(i=i+Math.imul(T,W)|0)+Math.imul(L,F)|0,a=a+Math.imul(L,W)|0,n=n+Math.imul($,J)|0,i=(i=i+Math.imul($,Z)|0)+Math.imul(P,J)|0,a=a+Math.imul(P,Z)|0,n=n+Math.imul(A,Q)|0,i=(i=i+Math.imul(A,ee)|0)+Math.imul(I,Q)|0,a=a+Math.imul(I,ee)|0,n=n+Math.imul(y,re)|0,i=(i=i+Math.imul(y,ne)|0)+Math.imul(E,re)|0,a=a+Math.imul(E,ne)|0,n=n+Math.imul(g,ae)|0,i=(i=i+Math.imul(g,se)|0)+Math.imul(_,ae)|0,a=a+Math.imul(_,se)|0,n=n+Math.imul(p,fe)|0,i=(i=i+Math.imul(p,ue)|0)+Math.imul(b,fe)|0,a=a+Math.imul(b,ue)|0;var Ie=(u+(n=n+Math.imul(d,de)|0)|0)+((8191&(i=(i=i+Math.imul(d,he)|0)+Math.imul(h,de)|0))<<13)|0;u=((a=a+Math.imul(h,he)|0)+(i>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,n=Math.imul(D,K),i=(i=Math.imul(D,U))+Math.imul(j,K)|0,a=Math.imul(j,U),n=n+Math.imul(k,Y)|0,i=(i=i+Math.imul(k,H)|0)+Math.imul(N,Y)|0,a=a+Math.imul(N,H)|0,n=n+Math.imul(C,F)|0,i=(i=i+Math.imul(C,W)|0)+Math.imul(R,F)|0,a=a+Math.imul(R,W)|0,n=n+Math.imul(T,J)|0,i=(i=i+Math.imul(T,Z)|0)+Math.imul(L,J)|0,a=a+Math.imul(L,Z)|0,n=n+Math.imul($,Q)|0,i=(i=i+Math.imul($,ee)|0)+Math.imul(P,Q)|0,a=a+Math.imul(P,ee)|0,n=n+Math.imul(A,re)|0,i=(i=i+Math.imul(A,ne)|0)+Math.imul(I,re)|0,a=a+Math.imul(I,ne)|0,n=n+Math.imul(y,ae)|0,i=(i=i+Math.imul(y,se)|0)+Math.imul(E,ae)|0,a=a+Math.imul(E,se)|0,n=n+Math.imul(g,fe)|0,i=(i=i+Math.imul(g,ue)|0)+Math.imul(_,fe)|0,a=a+Math.imul(_,ue)|0,n=n+Math.imul(p,de)|0,i=(i=i+Math.imul(p,he)|0)+Math.imul(b,de)|0,a=a+Math.imul(b,he)|0;var Se=(u+(n=n+Math.imul(d,pe)|0)|0)+((8191&(i=(i=i+Math.imul(d,be)|0)+Math.imul(h,pe)|0))<<13)|0;u=((a=a+Math.imul(h,be)|0)+(i>>>13)|0)+(Se>>>26)|0,Se&=67108863,n=Math.imul(D,Y),i=(i=Math.imul(D,H))+Math.imul(j,Y)|0,a=Math.imul(j,H),n=n+Math.imul(k,F)|0,i=(i=i+Math.imul(k,W)|0)+Math.imul(N,F)|0,a=a+Math.imul(N,W)|0,n=n+Math.imul(C,J)|0,i=(i=i+Math.imul(C,Z)|0)+Math.imul(R,J)|0,a=a+Math.imul(R,Z)|0,n=n+Math.imul(T,Q)|0,i=(i=i+Math.imul(T,ee)|0)+Math.imul(L,Q)|0,a=a+Math.imul(L,ee)|0,n=n+Math.imul($,re)|0,i=(i=i+Math.imul($,ne)|0)+Math.imul(P,re)|0,a=a+Math.imul(P,ne)|0,n=n+Math.imul(A,ae)|0,i=(i=i+Math.imul(A,se)|0)+Math.imul(I,ae)|0,a=a+Math.imul(I,se)|0,n=n+Math.imul(y,fe)|0,i=(i=i+Math.imul(y,ue)|0)+Math.imul(E,fe)|0,a=a+Math.imul(E,ue)|0,n=n+Math.imul(g,de)|0,i=(i=i+Math.imul(g,he)|0)+Math.imul(_,de)|0,a=a+Math.imul(_,he)|0;var $e=(u+(n=n+Math.imul(p,pe)|0)|0)+((8191&(i=(i=i+Math.imul(p,be)|0)+Math.imul(b,pe)|0))<<13)|0;u=((a=a+Math.imul(b,be)|0)+(i>>>13)|0)+($e>>>26)|0,$e&=67108863,n=Math.imul(D,F),i=(i=Math.imul(D,W))+Math.imul(j,F)|0,a=Math.imul(j,W),n=n+Math.imul(k,J)|0,i=(i=i+Math.imul(k,Z)|0)+Math.imul(N,J)|0,a=a+Math.imul(N,Z)|0,n=n+Math.imul(C,Q)|0,i=(i=i+Math.imul(C,ee)|0)+Math.imul(R,Q)|0,a=a+Math.imul(R,ee)|0,n=n+Math.imul(T,re)|0,i=(i=i+Math.imul(T,ne)|0)+Math.imul(L,re)|0,a=a+Math.imul(L,ne)|0,n=n+Math.imul($,ae)|0,i=(i=i+Math.imul($,se)|0)+Math.imul(P,ae)|0,a=a+Math.imul(P,se)|0,n=n+Math.imul(A,fe)|0,i=(i=i+Math.imul(A,ue)|0)+Math.imul(I,fe)|0,a=a+Math.imul(I,ue)|0,n=n+Math.imul(y,de)|0,i=(i=i+Math.imul(y,he)|0)+Math.imul(E,de)|0,a=a+Math.imul(E,he)|0;var Pe=(u+(n=n+Math.imul(g,pe)|0)|0)+((8191&(i=(i=i+Math.imul(g,be)|0)+Math.imul(_,pe)|0))<<13)|0;u=((a=a+Math.imul(_,be)|0)+(i>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,n=Math.imul(D,J),i=(i=Math.imul(D,Z))+Math.imul(j,J)|0,a=Math.imul(j,Z),n=n+Math.imul(k,Q)|0,i=(i=i+Math.imul(k,ee)|0)+Math.imul(N,Q)|0,a=a+Math.imul(N,ee)|0,n=n+Math.imul(C,re)|0,i=(i=i+Math.imul(C,ne)|0)+Math.imul(R,re)|0,a=a+Math.imul(R,ne)|0,n=n+Math.imul(T,ae)|0,i=(i=i+Math.imul(T,se)|0)+Math.imul(L,ae)|0,a=a+Math.imul(L,se)|0,n=n+Math.imul($,fe)|0,i=(i=i+Math.imul($,ue)|0)+Math.imul(P,fe)|0,a=a+Math.imul(P,ue)|0,n=n+Math.imul(A,de)|0,i=(i=i+Math.imul(A,he)|0)+Math.imul(I,de)|0,a=a+Math.imul(I,he)|0;var Me=(u+(n=n+Math.imul(y,pe)|0)|0)+((8191&(i=(i=i+Math.imul(y,be)|0)+Math.imul(E,pe)|0))<<13)|0;u=((a=a+Math.imul(E,be)|0)+(i>>>13)|0)+(Me>>>26)|0,Me&=67108863,n=Math.imul(D,Q),i=(i=Math.imul(D,ee))+Math.imul(j,Q)|0,a=Math.imul(j,ee),n=n+Math.imul(k,re)|0,i=(i=i+Math.imul(k,ne)|0)+Math.imul(N,re)|0,a=a+Math.imul(N,ne)|0,n=n+Math.imul(C,ae)|0,i=(i=i+Math.imul(C,se)|0)+Math.imul(R,ae)|0,a=a+Math.imul(R,se)|0,n=n+Math.imul(T,fe)|0,i=(i=i+Math.imul(T,ue)|0)+Math.imul(L,fe)|0,a=a+Math.imul(L,ue)|0,n=n+Math.imul($,de)|0,i=(i=i+Math.imul($,he)|0)+Math.imul(P,de)|0,a=a+Math.imul(P,he)|0;var Te=(u+(n=n+Math.imul(A,pe)|0)|0)+((8191&(i=(i=i+Math.imul(A,be)|0)+Math.imul(I,pe)|0))<<13)|0;u=((a=a+Math.imul(I,be)|0)+(i>>>13)|0)+(Te>>>26)|0,Te&=67108863,n=Math.imul(D,re),i=(i=Math.imul(D,ne))+Math.imul(j,re)|0,a=Math.imul(j,ne),n=n+Math.imul(k,ae)|0,i=(i=i+Math.imul(k,se)|0)+Math.imul(N,ae)|0,a=a+Math.imul(N,se)|0,n=n+Math.imul(C,fe)|0,i=(i=i+Math.imul(C,ue)|0)+Math.imul(R,fe)|0,a=a+Math.imul(R,ue)|0,n=n+Math.imul(T,de)|0,i=(i=i+Math.imul(T,he)|0)+Math.imul(L,de)|0,a=a+Math.imul(L,he)|0;var Le=(u+(n=n+Math.imul($,pe)|0)|0)+((8191&(i=(i=i+Math.imul($,be)|0)+Math.imul(P,pe)|0))<<13)|0;u=((a=a+Math.imul(P,be)|0)+(i>>>13)|0)+(Le>>>26)|0,Le&=67108863,n=Math.imul(D,ae),i=(i=Math.imul(D,se))+Math.imul(j,ae)|0,a=Math.imul(j,se),n=n+Math.imul(k,fe)|0,i=(i=i+Math.imul(k,ue)|0)+Math.imul(N,fe)|0,a=a+Math.imul(N,ue)|0,n=n+Math.imul(C,de)|0,i=(i=i+Math.imul(C,he)|0)+Math.imul(R,de)|0,a=a+Math.imul(R,he)|0;var Be=(u+(n=n+Math.imul(T,pe)|0)|0)+((8191&(i=(i=i+Math.imul(T,be)|0)+Math.imul(L,pe)|0))<<13)|0;u=((a=a+Math.imul(L,be)|0)+(i>>>13)|0)+(Be>>>26)|0,Be&=67108863,n=Math.imul(D,fe),i=(i=Math.imul(D,ue))+Math.imul(j,fe)|0,a=Math.imul(j,ue),n=n+Math.imul(k,de)|0,i=(i=i+Math.imul(k,he)|0)+Math.imul(N,de)|0,a=a+Math.imul(N,he)|0;var Ce=(u+(n=n+Math.imul(C,pe)|0)|0)+((8191&(i=(i=i+Math.imul(C,be)|0)+Math.imul(R,pe)|0))<<13)|0;u=((a=a+Math.imul(R,be)|0)+(i>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,n=Math.imul(D,de),i=(i=Math.imul(D,he))+Math.imul(j,de)|0,a=Math.imul(j,he);var Re=(u+(n=n+Math.imul(k,pe)|0)|0)+((8191&(i=(i=i+Math.imul(k,be)|0)+Math.imul(N,pe)|0))<<13)|0;u=((a=a+Math.imul(N,be)|0)+(i>>>13)|0)+(Re>>>26)|0,Re&=67108863;var xe=(u+(n=Math.imul(D,pe))|0)+((8191&(i=(i=Math.imul(D,be))+Math.imul(j,pe)|0))<<13)|0;return u=((a=Math.imul(j,be))+(i>>>13)|0)+(xe>>>26)|0,xe&=67108863,f[0]=me,f[1]=ge,f[2]=_e,f[3]=ve,f[4]=ye,f[5]=Ee,f[6]=we,f[7]=Ae,f[8]=Ie,f[9]=Se,f[10]=$e,f[11]=Pe,f[12]=Me,f[13]=Te,f[14]=Le,f[15]=Be,f[16]=Ce,f[17]=Re,f[18]=xe,0!==u&&(f[19]=u,r.length++),r};function l(e,t,r){return(new p).mulp(e,t,r)}function p(e,t){this.x=e,this.y=t}Math.imul||(h=d),i.prototype.mulTo=function(e,t){var r=this.length+e.length;return 10===this.length&&10===e.length?h(this,e,t):r<63?d(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,a=0;a>>26)|0)>>>26,s&=67108863}r.words[a]=o,n=s,s=i}return 0!==n?r.words[a]=n:r.length--,r.strip()}(this,e,t):l(this,e,t)},p.prototype.makeRBT=function(e){for(var t=new Array(e),r=i.prototype._countBits(e)-1,n=0;n>=1;return n},p.prototype.permute=function(e,t,r,n,i,a){for(var s=0;s>>=1)i++;return 1<>>=13,n[2*s+1]=8191&a,a>>>=13;for(s=2*t;s>=26,t+=i/67108864|0,t+=a>>>26,this.words[n]=67108863&a}return 0!==t&&(this.words[n]=t,this.length++),this},i.prototype.muln=function(e){return this.clone().imuln(e)},i.prototype.sqr=function(){return this.mul(this)},i.prototype.isqr=function(){return this.imul(this.clone())},i.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),r=0;r>>i}return t}(e);if(0===t.length)return new i(1);for(var r=this,n=0;n=0);var t,n=e%26,i=(e-n)/26,a=67108863>>>26-n<<26-n;if(0!==n){var s=0;for(t=0;t>>26-n}s&&(this.words[t]=s,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 a=e%26,s=Math.min((e-a)/26,this.length),o=67108863^67108863>>>a<s)for(this.length-=s,u=0;u=0&&(0!==c||u>=i);u--){var d=0|this.words[u];this.words[u]=c<<26-a|d>>>a,c=d&o}return f&&0!==c&&(f.words[f.length++]=c),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},i.prototype.ishrn=function(e,t,n){return r(0===this.negative),this.iushrn(e,t,n)},i.prototype.shln=function(e){return this.clone().ishln(e)},i.prototype.ushln=function(e){return this.clone().iushln(e)},i.prototype.shrn=function(e){return this.clone().ishrn(e)},i.prototype.ushrn=function(e){return this.clone().iushrn(e)},i.prototype.testn=function(e){r("number"==typeof e&&e>=0);var t=e%26,n=(e-t)/26,i=1<=0);var t=e%26,n=(e-t)/26;if(r(0===this.negative,"imaskn works only with positive numbers"),this.length<=n)return this;if(0!==t&&n++,this.length=Math.min(n,this.length),0!==t){var 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},i.prototype.isubn=function(e){if(r("number"==typeof e),r(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t>26)-(f/67108864|0),this.words[i+n]=67108863&a}for(;i>26,this.words[i+n]=67108863&a;if(0===o)return this.strip();for(r(-1===o),o=0,i=0;i>26,this.words[i]=67108863&a;return this.negative=1,this.strip()},i.prototype._wordDiv=function(e,t){var r=(this.length,e.length),n=this.clone(),a=e,s=0|a.words[a.length-1];0!==(r=26-this._countBits(s))&&(a=a.ushln(r),n.iushln(r),s=0|a.words[a.length-1]);var o,f=n.length-a.length;if("mod"!==t){(o=new i(null)).length=f+1,o.words=new Array(o.length);for(var u=0;u=0;d--){var h=67108864*(0|n.words[a.length+d])+(0|n.words[a.length+d-1]);for(h=Math.min(h/s|0,67108863),n._ishlnsubmul(a,h,d);0!==n.negative;)h--,n.negative=0,n._ishlnsubmul(a,1,d),n.isZero()||(n.negative^=1);o&&(o.words[d]=h)}return o&&o.strip(),n.strip(),"div"!==t&&0!==r&&n.iushrn(r),{div:o||null,mod:n}},i.prototype.divmod=function(e,t,n){return r(!e.isZero()),this.isZero()?{div:new i(0),mod:new i(0)}:0!==this.negative&&0===e.negative?(o=this.neg().divmod(e,t),"mod"!==t&&(a=o.div.neg()),"div"!==t&&(s=o.mod.neg(),n&&0!==s.negative&&s.iadd(e)),{div:a,mod:s}):0===this.negative&&0!==e.negative?(o=this.divmod(e.neg(),t),"mod"!==t&&(a=o.div.neg()),{div:a,mod:o.mod}):0!=(this.negative&e.negative)?(o=this.neg().divmod(e.neg(),t),"div"!==t&&(s=o.mod.neg(),n&&0!==s.negative&&s.isub(e)),{div:o.div,mod:s}):e.length>this.length||this.cmp(e)<0?{div:new i(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new i(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new i(this.modn(e.words[0]))}:this._wordDiv(e,t);var a,s,o},i.prototype.div=function(e){return this.divmod(e,"div",!1).div},i.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},i.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},i.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var r=0!==t.div.negative?t.mod.isub(e):t.mod,n=e.ushrn(1),i=e.andln(1),a=r.cmp(n);return a<0||1===i&&0===a?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},i.prototype.modn=function(e){r(e<=67108863);for(var t=(1<<26)%e,n=0,i=this.length-1;i>=0;i--)n=(t*n+(0|this.words[i]))%e;return n},i.prototype.idivn=function(e){r(e<=67108863);for(var t=0,n=this.length-1;n>=0;n--){var i=(0|this.words[n])+67108864*t;this.words[n]=i/e|0,t=i%e}return this.strip()},i.prototype.divn=function(e){return this.clone().idivn(e)},i.prototype.egcd=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var a=new i(1),s=new i(0),o=new i(0),f=new i(1),u=0;t.isEven()&&n.isEven();)t.iushrn(1),n.iushrn(1),++u;for(var c=n.clone(),d=t.clone();!t.isZero();){for(var h=0,l=1;0==(t.words[0]&l)&&h<26;++h,l<<=1);if(h>0)for(t.iushrn(h);h-- >0;)(a.isOdd()||s.isOdd())&&(a.iadd(c),s.isub(d)),a.iushrn(1),s.iushrn(1);for(var p=0,b=1;0==(n.words[0]&b)&&p<26;++p,b<<=1);if(p>0)for(n.iushrn(p);p-- >0;)(o.isOdd()||f.isOdd())&&(o.iadd(c),f.isub(d)),o.iushrn(1),f.iushrn(1);t.cmp(n)>=0?(t.isub(n),a.isub(o),s.isub(f)):(n.isub(t),o.isub(a),f.isub(s))}return{a:o,b:f,gcd:n.iushln(u)}},i.prototype._invmp=function(e){r(0===e.negative),r(!e.isZero());var t=this,n=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var a,s=new i(1),o=new i(0),f=n.clone();t.cmpn(1)>0&&n.cmpn(1)>0;){for(var u=0,c=1;0==(t.words[0]&c)&&u<26;++u,c<<=1);if(u>0)for(t.iushrn(u);u-- >0;)s.isOdd()&&s.iadd(f),s.iushrn(1);for(var d=0,h=1;0==(n.words[0]&h)&&d<26;++d,h<<=1);if(d>0)for(n.iushrn(d);d-- >0;)o.isOdd()&&o.iadd(f),o.iushrn(1);t.cmp(n)>=0?(t.isub(n),s.isub(o)):(n.isub(t),o.isub(s))}return(a=0===t.cmpn(1)?s:o).cmpn(0)<0&&a.iadd(e),a},i.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 a=t;t=r,r=a}else if(0===i||0===r.cmpn(1))break;t.isub(r)}return r.iushln(n)},i.prototype.invm=function(e){return this.egcd(e).a.umod(e)},i.prototype.isEven=function(){return 0==(1&this.words[0])},i.prototype.isOdd=function(){return 1==(1&this.words[0])},i.prototype.andln=function(e){return this.words[0]&e},i.prototype.bincn=function(e){r("number"==typeof e);var t=e%26,n=(e-t)/26,i=1<>>26,o&=67108863,this.words[s]=o}return 0!==a&&(this.words[s]=a,this.length++),this},i.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},i.prototype.cmpn=function(e){var t,n=e<0;if(0!==this.negative&&!n)return-1;if(0===this.negative&&n)return 1;if(this.strip(),this.length>1)t=1;else{n&&(e=-e),r(e<=67108863,"Number is too big");var 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},i.prototype.gtn=function(e){return 1===this.cmpn(e)},i.prototype.gt=function(e){return 1===this.cmp(e)},i.prototype.gten=function(e){return this.cmpn(e)>=0},i.prototype.gte=function(e){return this.cmp(e)>=0},i.prototype.ltn=function(e){return-1===this.cmpn(e)},i.prototype.lt=function(e){return-1===this.cmp(e)},i.prototype.lten=function(e){return this.cmpn(e)<=0},i.prototype.lte=function(e){return this.cmp(e)<=0},i.prototype.eqn=function(e){return 0===this.cmpn(e)},i.prototype.eq=function(e){return 0===this.cmp(e)},i.red=function(e){return new E(e)},i.prototype.toRed=function(e){return r(!this.red,"Already a number in reduction context"),r(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},i.prototype.fromRed=function(){return r(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},i.prototype._forceRed=function(e){return this.red=e,this},i.prototype.forceRed=function(e){return r(!this.red,"Already a number in reduction context"),this._forceRed(e)},i.prototype.redAdd=function(e){return r(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},i.prototype.redIAdd=function(e){return r(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},i.prototype.redSub=function(e){return r(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},i.prototype.redISub=function(e){return r(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},i.prototype.redShl=function(e){return r(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},i.prototype.redMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},i.prototype.redIMul=function(e){return r(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},i.prototype.redSqr=function(){return r(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},i.prototype.redISqr=function(){return r(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},i.prototype.redSqrt=function(){return r(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},i.prototype.redInvm=function(){return r(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},i.prototype.redNeg=function(){return r(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},i.prototype.redPow=function(e){return r(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function m(e,t){this.name=e,this.p=new i(t,16),this.n=this.p.bitLength(),this.k=new i(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function g(){m.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function _(){m.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function v(){m.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function y(){m.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function E(e){if("string"==typeof e){var t=i._prime(e);this.m=t.p,this.prime=t}else r(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function w(e){E.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new i(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}m.prototype._tmp=function(){var e=new i(null);return e.words=new Array(Math.ceil(this.n/13)),e},m.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):r.strip(),r},m.prototype.split=function(e,t){e.iushrn(this.n,0,t)},m.prototype.imulK=function(e){return e.imul(this.k)},n(g,m),g.prototype.split=function(e,t){for(var r=Math.min(e.length,9),n=0;n>>22,i=a}i>>>=22,e.words[n-10]=i,0===i&&e.length>10?e.length-=10:e.length-=9},g.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},i._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new g;else if("p224"===e)t=new _;else if("p192"===e)t=new v;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new y}return b[e]=t,t},E.prototype._verify1=function(e){r(0===e.negative,"red works only with positives"),r(e.red,"red works only with red numbers")},E.prototype._verify2=function(e,t){r(0==(e.negative|t.negative),"red works only with positives"),r(e.red&&e.red===t.red,"red works only with red numbers")},E.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},E.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},E.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)},E.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},E.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)},E.prototype.isub=function(e,t){this._verify2(e,t);var r=e.isub(t);return r.cmpn(0)<0&&r.iadd(this.m),r},E.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},E.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},E.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},E.prototype.isqr=function(e){return this.imul(e,e.clone())},E.prototype.sqr=function(e){return this.mul(e,e)},E.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(r(t%2==1),3===t){var n=this.m.add(new i(1)).iushrn(2);return this.pow(e,n)}for(var a=this.m.subn(1),s=0;!a.isZero()&&0===a.andln(1);)s++,a.iushrn(1);r(!a.isZero());var o=new i(1).toRed(this),f=o.redNeg(),u=this.m.subn(1).iushrn(1),c=this.m.bitLength();for(c=new i(2*c*c).toRed(this);0!==this.pow(c,u).cmp(f);)c.redIAdd(f);for(var d=this.pow(c,a),h=this.pow(e,a.addn(1).iushrn(1)),l=this.pow(e,a),p=s;0!==l.cmp(o);){for(var b=l,m=0;0!==b.cmp(o);m++)b=b.redSqr();r(m=0;n--){for(var u=t.words[n],c=f-1;c>=0;c--){var d=u>>c&1;a!==r[0]&&(a=this.sqr(a)),0!==d||0!==s?(s<<=1,s|=d,(4===++o||0===n&&0===c)&&(a=this.mul(a,r[s]),o=0,s=0)):o=0}f=26}return a},E.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},E.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},i.mont=function(e){return new w(e)},n(w,E),w.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},w.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},w.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),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)},w.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new i(0)._forceRed(this);var r=e.mul(t),n=r.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),a=r.isub(n).iushrn(this.shift),s=a;return a.cmp(this.m)>=0?s=a.isub(this.m):a.cmpn(0)<0&&(s=a.iadd(this.m)),s._forceRed(this)},w.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e,commonjsGlobal)}),dist$1=createCommonjsModule(function(e,t){function r(e,t){if("00"===e.slice(0,2))throw new Error("invalid RLP: extra zeros");return parseInt(e,t)}function n(e,t){if(e<56)return Buffer.from([e+t]);var r=a(e),n=a(t+55+r.length/2);return Buffer.from(n+r,"hex")}function i(e){return"0x"===e.slice(0,2)}function a(e){if(e<0)throw new Error("Invalid integer as argument, must be unsigned!");var t=e.toString(16);return t.length%2?"0"+t:t}function s(e){if(!Buffer.isBuffer(e)){if("string"==typeof e)return i(e)?Buffer.from((r="string"!=typeof(n=e)?n:i(n)?n.slice(2):n).length%2?"0"+r:r,"hex"):Buffer.from(e);if("number"==typeof e)return e?(t=a(e),Buffer.from(t,"hex")):Buffer.from([]);if(null==e)return Buffer.from([]);if(e instanceof Uint8Array)return Buffer.from(e);if(bn.isBN(e))return Buffer.from(e.toArray());throw new Error("invalid type")}var t,r,n;return e}Object.defineProperty(t,"__esModule",{value:!0}),t.encode=function e(t){if(Array.isArray(t)){for(var r=[],i=0;it.length)throw new Error("invalid rlp: total length is larger than the data");if(0===(s=t.slice(i,c)).length)throw new Error("invalid rlp, List has a invalid length");for(;s.length;)o=e(s),f.push(o.data),s=o.remainder;return{data:f,remainder:t.slice(c)}}(s(e));if(t)return n;if(0!==n.remainder.length)throw new Error("invalid remainder");return n.data},t.getLength=function(e){if(!e||0===e.length)return Buffer.from([]);var t=s(e),n=t[0];if(n<=127)return t.length;if(n<=183)return n-127;if(n<=191)return n-182;if(n<=247)return n-191;var i=n-246;return i+r(t.slice(1,i).toString("hex"),16)}});unwrapExports(dist$1);var dist_1=dist$1.encode,dist_2=dist$1.decode,dist_3=dist$1.getLength,lookup=[],revLookup=[],Arr="undefined"!=typeof Uint8Array?Uint8Array:Array,inited=!1;function init(){inited=!0;for(var e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",t=0,r=e.length;t0)throw new Error("Invalid string. Length must be a multiple of 4");a="="===e[o-2]?2:"="===e[o-1]?1:0,s=new Arr(3*o/4-a),n=a>0?o-4:o;var f=0;for(t=0,r=0;t>16&255,s[f++]=i>>8&255,s[f++]=255&i;return 2===a?(i=revLookup[e.charCodeAt(t)]<<2|revLookup[e.charCodeAt(t+1)]>>4,s[f++]=255&i):1===a&&(i=revLookup[e.charCodeAt(t)]<<10|revLookup[e.charCodeAt(t+1)]<<4|revLookup[e.charCodeAt(t+2)]>>2,s[f++]=i>>8&255,s[f++]=255&i),s}function tripletToBase64(e){return lookup[e>>18&63]+lookup[e>>12&63]+lookup[e>>6&63]+lookup[63&e]}function encodeChunk(e,t,r){for(var n,i=[],a=t;ao?o:s+16383));return 1===n?(t=e[r-1],i+=lookup[t>>2],i+=lookup[t<<4&63],i+="=="):2===n&&(t=(e[r-2]<<8)+e[r-1],i+=lookup[t>>10],i+=lookup[t>>4&63],i+=lookup[t<<2&63],i+="="),a.push(i),a.join("")}function read(e,t,r,n,i){var a,s,o=8*i-n-1,f=(1<>1,c=-7,d=r?i-1:0,h=r?-1:1,l=e[t+d];for(d+=h,a=l&(1<<-c)-1,l>>=-c,c+=o;c>0;a=256*a+e[t+d],d+=h,c-=8);for(s=a&(1<<-c)-1,a>>=-c,c+=n;c>0;s=256*s+e[t+d],d+=h,c-=8);if(0===a)a=1-u;else{if(a===f)return s?NaN:1/0*(l?-1:1);s+=Math.pow(2,n),a-=u}return(l?-1:1)*s*Math.pow(2,a-n)}function write(e,t,r,n,i,a){var s,o,f,u=8*a-i-1,c=(1<>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,l=n?0:a-1,p=n?1:-1,b=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(o=isNaN(t)?1:0,s=c):(s=Math.floor(Math.log(t)/Math.LN2),t*(f=Math.pow(2,-s))<1&&(s--,f*=2),(t+=s+d>=1?h/f:h*Math.pow(2,1-d))*f>=2&&(s++,f/=2),s+d>=c?(o=0,s=c):s+d>=1?(o=(t*f-1)*Math.pow(2,i),s+=d):(o=t*Math.pow(2,d-1)*Math.pow(2,i),s=0));i>=8;e[r+l]=255&o,l+=p,o/=256,i-=8);for(s=s<0;e[r+l]=255&s,l+=p,s/=256,u-=8);e[r+l-p]|=128*b}var toString={}.toString,isArray$3=Array.isArray||function(e){return"[object Array]"==toString.call(e)},INSPECT_MAX_BYTES=50;Buffer$1.TYPED_ARRAY_SUPPORT=void 0===global.TYPED_ARRAY_SUPPORT||global.TYPED_ARRAY_SUPPORT;var _kMaxLength=kMaxLength();function kMaxLength(){return Buffer$1.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function createBuffer(e,t){if(kMaxLength()=kMaxLength())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+kMaxLength().toString(16)+" bytes");return 0|e}function SlowBuffer(e){return+e!=e&&(e=0),Buffer$1.alloc(+e)}function internalIsBuffer(e){return!(null==e||!e._isBuffer)}function byteLength(e,t){if(internalIsBuffer(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 utf8ToBytes(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return base64ToBytes(e).length;default:if(n)return utf8ToBytes(e).length;t=(""+t).toLowerCase(),n=!0}}function slowToString(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 hexSlice(this,t,r);case"utf8":case"utf-8":return utf8Slice(this,t,r);case"ascii":return asciiSlice(this,t,r);case"latin1":case"binary":return latin1Slice(this,t,r);case"base64":return base64Slice(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return utf16leSlice(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function swap(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function bidirectionalIndexOf(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$1.from(t,n)),internalIsBuffer(t))return 0===t.length?-1:arrayIndexOf(e,t,r,n,i);if("number"==typeof t)return t&=255,Buffer$1.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):arrayIndexOf(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function arrayIndexOf(e,t,r,n,i){var a,s=1,o=e.length,f=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;s=2,o/=2,f/=2,r/=2}function u(e,t){return 1===s?e[t]:e.readUInt16BE(t*s)}if(i){var c=-1;for(a=r;ao&&(r=o-f),a=r;a>=0;a--){for(var d=!0,h=0;hi&&(n=i):n=i;var a=t.length;if(a%2!=0)throw new TypeError("Invalid hex string");n>a/2&&(n=a/2);for(var s=0;s239?4:u>223?3:u>191?2:1;if(i+d<=r)switch(d){case 1:u<128&&(c=u);break;case 2:128==(192&(a=e[i+1]))&&(f=(31&u)<<6|63&a)>127&&(c=f);break;case 3:a=e[i+1],s=e[i+2],128==(192&a)&&128==(192&s)&&(f=(15&u)<<12|(63&a)<<6|63&s)>2047&&(f<55296||f>57343)&&(c=f);break;case 4:a=e[i+1],s=e[i+2],o=e[i+3],128==(192&a)&&128==(192&s)&&128==(192&o)&&(f=(15&u)<<18|(63&a)<<12|(63&s)<<6|63&o)>65535&&f<1114112&&(c=f)}null===c?(c=65533,d=1):c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|1023&c),n.push(c),i+=d}return decodeCodePointsArray(n)}Buffer$1.poolSize=8192,Buffer$1._augment=function(e){return e.__proto__=Buffer$1.prototype,e},Buffer$1.from=function(e,t,r){return from(null,e,t,r)},Buffer$1.TYPED_ARRAY_SUPPORT&&(Buffer$1.prototype.__proto__=Uint8Array.prototype,Buffer$1.__proto__=Uint8Array),Buffer$1.alloc=function(e,t,r){return alloc(null,e,t,r)},Buffer$1.allocUnsafe=function(e){return allocUnsafe(null,e)},Buffer$1.allocUnsafeSlow=function(e){return allocUnsafe(null,e)},Buffer$1.isBuffer=isBuffer,Buffer$1.compare=function(e,t){if(!internalIsBuffer(e)||!internalIsBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i0&&(e=this.toString("hex",0,t).match(/.{2}/g).join(" "),this.length>t&&(e+=" ... ")),""},Buffer$1.prototype.compare=function(e,t,r,n,i){if(!internalIsBuffer(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 a=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(t>>>=0),o=Math.min(a,s),f=this.slice(n,i),u=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 a=!1;;)switch(n){case"hex":return hexWrite(this,e,t,r);case"utf8":case"utf-8":return utf8Write(this,e,t,r);case"ascii":return asciiWrite(this,e,t,r);case"latin1":case"binary":return latin1Write(this,e,t,r);case"base64":return base64Write(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return ucs2Write(this,e,t,r);default:if(a)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),a=!0}},Buffer$1.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var MAX_ARGUMENTS_LENGTH=4096;function decodeCodePointsArray(e){var t=e.length;if(t<=MAX_ARGUMENTS_LENGTH)return String.fromCharCode.apply(String,e);for(var r="",n=0;nn)&&(r=n);for(var i="",a=t;ar)throw new RangeError("Trying to access beyond buffer length")}function checkInt(e,t,r,n,i,a){if(!internalIsBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||te.length)throw new RangeError("Index out of range")}function objectWriteUInt16(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,a=Math.min(e.length-r,2);i>>8*(n?i:1-i)}function objectWriteUInt32(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,a=Math.min(e.length-r,4);i>>8*(n?i:3-i)&255}function checkIEEE754(e,t,r,n,i,a){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function writeFloat(e,t,r,n,i){return i||checkIEEE754(e,t,r,4),write(e,t,r,n,23,4),r+4}function writeDouble(e,t,r,n,i){return i||checkIEEE754(e,t,r,8),write(e,t,r,n,52,8),r+8}Buffer$1.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$1.prototype.readUInt8=function(e,t){return t||checkOffset(e,1,this.length),this[e]},Buffer$1.prototype.readUInt16LE=function(e,t){return t||checkOffset(e,2,this.length),this[e]|this[e+1]<<8},Buffer$1.prototype.readUInt16BE=function(e,t){return t||checkOffset(e,2,this.length),this[e]<<8|this[e+1]},Buffer$1.prototype.readUInt32LE=function(e,t){return t||checkOffset(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},Buffer$1.prototype.readUInt32BE=function(e,t){return t||checkOffset(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},Buffer$1.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||checkOffset(e,t,this.length);for(var n=this[e],i=1,a=0;++a=(i*=128)&&(n-=Math.pow(2,8*t)),n},Buffer$1.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||checkOffset(e,t,this.length);for(var n=t,i=1,a=this[e+--n];n>0&&(i*=256);)a+=this[e+--n]*i;return a>=(i*=128)&&(a-=Math.pow(2,8*t)),a},Buffer$1.prototype.readInt8=function(e,t){return t||checkOffset(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},Buffer$1.prototype.readInt16LE=function(e,t){t||checkOffset(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},Buffer$1.prototype.readInt16BE=function(e,t){t||checkOffset(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},Buffer$1.prototype.readInt32LE=function(e,t){return t||checkOffset(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},Buffer$1.prototype.readInt32BE=function(e,t){return t||checkOffset(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},Buffer$1.prototype.readFloatLE=function(e,t){return t||checkOffset(e,4,this.length),read(this,e,!0,23,4)},Buffer$1.prototype.readFloatBE=function(e,t){return t||checkOffset(e,4,this.length),read(this,e,!1,23,4)},Buffer$1.prototype.readDoubleLE=function(e,t){return t||checkOffset(e,8,this.length),read(this,e,!0,52,8)},Buffer$1.prototype.readDoubleBE=function(e,t){return t||checkOffset(e,8,this.length),read(this,e,!1,52,8)},Buffer$1.prototype.writeUIntLE=function(e,t,r,n){(e=+e,t|=0,r|=0,n)||checkInt(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,a=0;for(this[t]=255&e;++a=0&&(a*=256);)this[t+i]=e/a&255;return t+r},Buffer$1.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,1,255,0),Buffer$1.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},Buffer$1.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,2,65535,0),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):objectWriteUInt16(this,e,t,!0),t+2},Buffer$1.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,2,65535,0),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):objectWriteUInt16(this,e,t,!1),t+2},Buffer$1.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,4,4294967295,0),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):objectWriteUInt32(this,e,t,!0),t+4},Buffer$1.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,4,4294967295,0),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):objectWriteUInt32(this,e,t,!1),t+4},Buffer$1.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);checkInt(this,e,t,r,i-1,-i)}var a=0,s=1,o=0;for(this[t]=255&e;++a>0)-o&255;return t+r},Buffer$1.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);checkInt(this,e,t,r,i-1,-i)}var a=r-1,s=1,o=0;for(this[t+a]=255&e;--a>=0&&(s*=256);)e<0&&0===o&&0!==this[t+a+1]&&(o=1),this[t+a]=(e/s>>0)-o&255;return t+r},Buffer$1.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,1,127,-128),Buffer$1.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},Buffer$1.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,2,32767,-32768),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):objectWriteUInt16(this,e,t,!0),t+2},Buffer$1.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,2,32767,-32768),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):objectWriteUInt16(this,e,t,!1),t+2},Buffer$1.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,4,2147483647,-2147483648),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):objectWriteUInt32(this,e,t,!0),t+4},Buffer$1.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||checkInt(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),Buffer$1.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):objectWriteUInt32(this,e,t,!1),t+4},Buffer$1.prototype.writeFloatLE=function(e,t,r){return writeFloat(this,e,t,!0,r)},Buffer$1.prototype.writeFloatBE=function(e,t,r){return writeFloat(this,e,t,!1,r)},Buffer$1.prototype.writeDoubleLE=function(e,t,r){return writeDouble(this,e,t,!0,r)},Buffer$1.prototype.writeDoubleBE=function(e,t,r){return writeDouble(this,e,t,!1,r)},Buffer$1.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(a<1e3||!Buffer$1.TYPED_ARRAY_SUPPORT)for(i=0;i>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(a=t;a55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&a.push(239,191,189);continue}if(s+1===n){(t-=3)>-1&&a.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&a.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&a.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;a.push(r)}else if(r<2048){if((t-=2)<0)break;a.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;a.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;a.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return a}function asciiToBytes(e){for(var t=[],r=0;r>8,i=r%256,a.push(i),a.push(n);return a}function base64ToBytes(e){return toByteArray(base64clean(e))}function blitBuffer(e,t,r,n){for(var i=0;i=t.length||i>=e.length);++i)t[i+r]=e[i];return i}function isnan(e){return e!=e}function isBuffer(e){return null!=e&&(!!e._isBuffer||isFastBuffer(e)||isSlowBuffer(e))}function isFastBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isFastBuffer(e.slice(0,0))}var domain,bufferEs6=Object.freeze({INSPECT_MAX_BYTES:INSPECT_MAX_BYTES,kMaxLength:_kMaxLength,Buffer:Buffer$1,SlowBuffer:SlowBuffer,isBuffer:isBuffer}),safeBuffer=createCommonjsModule(function(e,t){var r=bufferEs6.Buffer;function n(e,t){for(var r in e)t[r]=e[r]}function i(e,t,n){return r(e,t,n)}r.from&&r.alloc&&r.allocUnsafe&&r.allocUnsafeSlow?e.exports=bufferEs6:(n(bufferEs6,t),t.Buffer=i),i.prototype=Object.create(r.prototype),n(r,i),i.from=function(e,t,n){if("number"==typeof e)throw new TypeError("Argument must not be a number");return r(e,t,n)},i.alloc=function(e,t,n){if("number"!=typeof e)throw new TypeError("Argument must be a number");var i=r(e);return void 0!==t?"string"==typeof n?i.fill(t,n):i.fill(t):i.fill(0),i},i.allocUnsafe=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return r(e)},i.allocUnsafeSlow=function(e){if("number"!=typeof e)throw new TypeError("Argument must be a number");return bufferEs6.SlowBuffer(e)}}),safeBuffer_1=safeBuffer.Buffer;function EventHandlers(){}function EventEmitter(){EventEmitter.init.call(this)}function $getMaxListeners(e){return void 0===e._maxListeners?EventEmitter.defaultMaxListeners:e._maxListeners}function emitNone(e,t,r){if(t)e.call(r);else for(var n=e.length,i=arrayClone(e,n),a=0;a0&&s.length>i){s.warned=!0;var o=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+t+" listeners added. Use emitter.setMaxListeners() to increase limit");o.name="MaxListenersExceededWarning",o.emitter=e,o.type=t,o.count=s.length,emitWarning(o)}}else s=a[t]=r,++e._eventsCount;return e}function emitWarning(e){"function"==typeof console.warn?console.warn(e):console.log(e)}function _onceWrap(e,t,r){var n=!1;function i(){e.removeListener(t,i),n||(n=!0,r.apply(e,arguments))}return i.listener=r,i}function listenerCount(e){var t=this._events;if(t){var r=t[e];if("function"==typeof r)return 1;if(r)return r.length}return 0}function spliceOne(e,t){for(var r=t,n=r+1,i=e.length;n0;)if(r[a]===t||r[a].listener&&r[a].listener===t){s=r[a].listener,i=a;break}if(i<0)return this;if(1===r.length){if(r[0]=void 0,0==--this._eventsCount)return this._events=new EventHandlers,this;delete n[e]}else spliceOne(r,i);n.removeListener&&this.emit("removeListener",e,s||t)}return this},EventEmitter.prototype.removeAllListeners=function(e){var t,r;if(!(r=this._events))return this;if(!r.removeListener)return 0===arguments.length?(this._events=new EventHandlers,this._eventsCount=0):r[e]&&(0==--this._eventsCount?this._events=new EventHandlers:delete r[e]),this;if(0===arguments.length){for(var n,i=Object.keys(r),a=0;a0?Reflect.ownKeys(this._events):[]},BufferList.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},BufferList.prototype.unshift=function(e){var t={data:e,next:this.head};0===this.length&&(this.tail=t),this.head=t,++this.length},BufferList.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}},BufferList.prototype.clear=function(){this.head=this.tail=null,this.length=0},BufferList.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},BufferList.prototype.concat=function(e){if(0===this.length)return Buffer$1.alloc(0);if(1===this.length)return this.head.data;for(var t=Buffer$1.allocUnsafe(e>>>0),r=this.head,n=0;r;)r.data.copy(t,n),n+=r.data.length,r=r.next;return t};var isBufferEncoding=Buffer$1.isEncoding||function(e){switch(e&&e.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};function assertEncoding(e){if(e&&!isBufferEncoding(e))throw new Error("Unknown encoding: "+e)}function StringDecoder(e){switch(this.encoding=(e||"utf8").toLowerCase().replace(/[-_]/,""),assertEncoding(e),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=utf16DetectIncompleteChar;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=base64DetectIncompleteChar;break;default:return void(this.write=passThroughWrite)}this.charBuffer=new Buffer$1(6),this.charReceived=0,this.charLength=0}function passThroughWrite(e){return e.toString(this.encoding)}function utf16DetectIncompleteChar(e){this.charReceived=e.length%2,this.charLength=this.charReceived?2:0}function base64DetectIncompleteChar(e){this.charReceived=e.length%3,this.charLength=this.charReceived?3:0}StringDecoder.prototype.write=function(e){for(var t="";this.charLength;){var r=e.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:e.length;if(e.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived=55296&&i<=56319)){if(this.charReceived=this.charLength=0,0===e.length)return t;break}this.charLength+=this.surrogateSize,t=""}this.detectIncompleteChar(e);var n=e.length;this.charLength&&(e.copy(this.charBuffer,0,e.length-this.charReceived,n),n-=this.charReceived);var i;n=(t+=e.toString(this.encoding,0,n)).length-1;if((i=t.charCodeAt(n))>=55296&&i<=56319){var a=this.surrogateSize;return this.charLength+=a,this.charReceived+=a,this.charBuffer.copy(this.charBuffer,a,0,a),e.copy(this.charBuffer,0,0,a),t.substring(0,n)}return t},StringDecoder.prototype.detectIncompleteChar=function(e){for(var t=e.length>=3?3:e.length;t>0;t--){var r=e[e.length-t];if(1==t&&r>>5==6){this.charLength=2;break}if(t<=2&&r>>4==14){this.charLength=3;break}if(t<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=t},StringDecoder.prototype.end=function(e){var t="";if(e&&e.length&&(t=this.write(e)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;t+=n.slice(0,r).toString(i)}return t};var stringDecoder=Object.freeze({StringDecoder:StringDecoder});Readable.ReadableState=ReadableState;var debug=debuglog("stream");function prependListener(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)}function listenerCount$1(e,t){return e.listeners(t).length}function ReadableState(e,t){e=e||{},this.objectMode=!!e.objectMode,t instanceof Duplex&&(this.objectMode=this.objectMode||!!e.readableObjectMode);var r=e.highWaterMark,n=this.objectMode?16:16384;this.highWaterMark=r||0===r?r:n,this.highWaterMark=~~this.highWaterMark,this.buffer=new BufferList,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.defaultEncoding=e.defaultEncoding||"utf8",this.ranOut=!1,this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,e.encoding&&(this.decoder=new StringDecoder(e.encoding),this.encoding=e.encoding)}function Readable(e){if(!(this instanceof Readable))return new Readable(e);this._readableState=new ReadableState(e,this),this.readable=!0,e&&"function"==typeof e.read&&(this._read=e.read),EventEmitter.call(this)}function readableAddChunk(e,t,r,n,i){var a=chunkInvalid(t,r);if(a)e.emit("error",a);else if(null===r)t.reading=!1,onEofChunk(e,t);else if(t.objectMode||r&&r.length>0)if(t.ended&&!i){var s=new Error("stream.push() after EOF");e.emit("error",s)}else if(t.endEmitted&&i){var o=new Error("stream.unshift() after end event");e.emit("error",o)}else{var f;!t.decoder||i||n||(r=t.decoder.write(r),f=!t.objectMode&&0===r.length),i||(t.reading=!1),f||(t.flowing&&0===t.length&&!t.sync?(e.emit("data",r),e.read(0)):(t.length+=t.objectMode?1:r.length,i?t.buffer.unshift(r):t.buffer.push(r),t.needReadable&&emitReadable(e))),maybeReadMore(e,t)}else i||(t.reading=!1);return needMoreData(t)}function needMoreData(e){return!e.ended&&(e.needReadable||e.length=MAX_HWM?e=MAX_HWM:(e--,e|=e>>>1,e|=e>>>2,e|=e>>>4,e|=e>>>8,e|=e>>>16,e++),e}function howMuchToRead(e,t){return e<=0||0===t.length&&t.ended?0:t.objectMode?1:e!=e?t.flowing&&t.length?t.buffer.head.data.length:t.length:(e>t.highWaterMark&&(t.highWaterMark=computeNewHighWaterMark(e)),e<=t.length?e:t.ended?t.length:(t.needReadable=!0,0))}function chunkInvalid(e,t){var r=null;return Buffer.isBuffer(t)||"string"==typeof t||null==t||e.objectMode||(r=new TypeError("Invalid non-string/buffer chunk")),r}function onEofChunk(e,t){if(!t.ended){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,emitReadable(e)}}function emitReadable(e){var t=e._readableState;t.needReadable=!1,t.emittedReadable||(debug("emitReadable",t.flowing),t.emittedReadable=!0,t.sync?nextTick(emitReadable_,e):emitReadable_(e))}function emitReadable_(e){debug("emit readable"),e.emit("readable"),flow(e)}function maybeReadMore(e,t){t.readingMore||(t.readingMore=!0,nextTick(maybeReadMore_,e,t))}function maybeReadMore_(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=fromListPartial(e,t.buffer,t.decoder),r);var r}function fromListPartial(e,t,r){var n;return ea.length?a.length:e;if(s===a.length?i+=a:i+=a.slice(0,e),0===(e-=s)){s===a.length?(++n,r.next?t.head=r.next:t.head=t.tail=null):(t.head=r,r.data=a.slice(s));break}++n}return t.length-=n,i}function copyFromBuffer(e,t){var r=Buffer.allocUnsafe(e),n=t.head,i=1;for(n.data.copy(r),e-=n.data.length;n=n.next;){var a=n.data,s=e>a.length?a.length:e;if(a.copy(r,r.length-e,0,s),0===(e-=s)){s===a.length?(++i,n.next?t.head=n.next:t.head=t.tail=null):(t.head=n,n.data=a.slice(s));break}++i}return t.length-=i,r}function endReadable(e){var t=e._readableState;if(t.length>0)throw new Error('"endReadable()" called on non-empty stream');t.endEmitted||(t.ended=!0,nextTick(endReadableNT,t,e))}function endReadableNT(e,t){e.endEmitted||0!==e.length||(e.endEmitted=!0,t.readable=!1,t.emit("end"))}function forEach(e,t){for(var r=0,n=e.length;r=t.highWaterMark||t.ended))return debug("read: emitReadable",t.length,t.ended),0===t.length&&t.ended?endReadable(this):emitReadable(this),null;if(0===(e=howMuchToRead(e,t))&&t.ended)return 0===t.length&&endReadable(this),null;var n,i=t.needReadable;return debug("need readable",i),(0===t.length||t.length-e0?fromList(e,t):null)?(t.needReadable=!0,e=0):t.length-=e,0===t.length&&(t.ended||(t.needReadable=!0),r!==e&&t.ended&&endReadable(this)),null!==n&&this.emit("data",n),n},Readable.prototype._read=function(e){this.emit("error",new Error("not implemented"))},Readable.prototype.pipe=function(e,t){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=e;break;case 1:n.pipes=[n.pipes,e];break;default:n.pipes.push(e)}n.pipesCount+=1,debug("pipe count=%d opts=%j",n.pipesCount,t);var i=!t||!1!==t.end?s:u;function a(e){debug("onunpipe"),e===r&&u()}function s(){debug("onend"),e.end()}n.endEmitted?nextTick(i):r.once("end",i),e.on("unpipe",a);var o=pipeOnDrain(r);e.on("drain",o);var f=!1;function u(){debug("cleanup"),e.removeListener("close",l),e.removeListener("finish",p),e.removeListener("drain",o),e.removeListener("error",h),e.removeListener("unpipe",a),r.removeListener("end",s),r.removeListener("end",u),r.removeListener("data",d),f=!0,!n.awaitDrain||e._writableState&&!e._writableState.needDrain||o()}var c=!1;function d(t){debug("ondata"),c=!1,!1!==e.write(t)||c||((1===n.pipesCount&&n.pipes===e||n.pipesCount>1&&-1!==indexOf(n.pipes,e))&&!f&&(debug("false write response, pause",r._readableState.awaitDrain),r._readableState.awaitDrain++,c=!0),r.pause())}function h(t){debug("onerror",t),b(),e.removeListener("error",h),0===listenerCount$1(e,"error")&&e.emit("error",t)}function l(){e.removeListener("finish",p),b()}function p(){debug("onfinish"),e.removeListener("close",l),b()}function b(){debug("unpipe"),r.unpipe(e)}return r.on("data",d),prependListener(e,"error",h),e.once("close",l),e.once("finish",p),e.emit("pipe",r),n.flowing||(debug("pipe resume"),r.resume()),e},Readable.prototype.unpipe=function(e){var t=this._readableState;if(0===t.pipesCount)return this;if(1===t.pipesCount)return e&&e!==t.pipes?this:(e||(e=t.pipes),t.pipes=null,t.pipesCount=0,t.flowing=!1,e&&e.emit("unpipe",this),this);if(!e){var r=t.pipes,n=t.pipesCount;t.pipes=null,t.pipesCount=0,t.flowing=!1;for(var i=0;i-1))throw new TypeError("Unknown encoding: "+e);return this._writableState.defaultEncoding=e,this},Writable.prototype._write=function(e,t,r){r(new Error("not implemented"))},Writable.prototype._writev=null,Writable.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||endWritable(this,n,r)},inherits$1(Duplex,Readable);for(var keys=Object.keys(Writable.prototype),v=0;v>>31),l=d^(a<<1|i>>>31),p=e[0]^h,b=e[1]^l,m=e[10]^h,g=e[11]^l,_=e[20]^h,v=e[21]^l,y=e[30]^h,E=e[31]^l,w=e[40]^h,A=e[41]^l;h=r^(s<<1|o>>>31),l=n^(o<<1|s>>>31);var I=e[2]^h,S=e[3]^l,$=e[12]^h,P=e[13]^l,M=e[22]^h,T=e[23]^l,L=e[32]^h,B=e[33]^l,C=e[42]^h,R=e[43]^l;h=i^(f<<1|u>>>31),l=a^(u<<1|f>>>31);var x=e[4]^h,k=e[5]^l,N=e[14]^h,O=e[15]^l,D=e[24]^h,j=e[25]^l,V=e[34]^h,K=e[35]^l,U=e[44]^h,z=e[45]^l;h=s^(c<<1|d>>>31),l=o^(d<<1|c>>>31);var Y=e[6]^h,H=e[7]^l,q=e[16]^h,F=e[17]^l,W=e[26]^h,G=e[27]^l,J=e[36]^h,Z=e[37]^l,X=e[46]^h,Q=e[47]^l;h=f^(r<<1|n>>>31),l=u^(n<<1|r>>>31);var ee=e[8]^h,te=e[9]^l,re=e[18]^h,ne=e[19]^l,ie=e[28]^h,ae=e[29]^l,se=e[38]^h,oe=e[39]^l,fe=e[48]^h,ue=e[49]^l,ce=p,de=b,he=g<<4|m>>>28,le=m<<4|g>>>28,pe=_<<3|v>>>29,be=v<<3|_>>>29,me=E<<9|y>>>23,ge=y<<9|E>>>23,_e=w<<18|A>>>14,ve=A<<18|w>>>14,ye=I<<1|S>>>31,Ee=S<<1|I>>>31,we=P<<12|$>>>20,Ae=$<<12|P>>>20,Ie=M<<10|T>>>22,Se=T<<10|M>>>22,$e=B<<13|L>>>19,Pe=L<<13|B>>>19,Me=C<<2|R>>>30,Te=R<<2|C>>>30,Le=k<<30|x>>>2,Be=x<<30|k>>>2,Ce=N<<6|O>>>26,Re=O<<6|N>>>26,xe=j<<11|D>>>21,ke=D<<11|j>>>21,Ne=V<<15|K>>>17,Oe=K<<15|V>>>17,De=z<<29|U>>>3,je=U<<29|z>>>3,Ve=Y<<28|H>>>4,Ke=H<<28|Y>>>4,Ue=F<<23|q>>>9,ze=q<<23|F>>>9,Ye=W<<25|G>>>7,He=G<<25|W>>>7,qe=J<<21|Z>>>11,Fe=Z<<21|J>>>11,We=Q<<24|X>>>8,Ge=X<<24|Q>>>8,Je=ee<<27|te>>>5,Ze=te<<27|ee>>>5,Xe=re<<20|ne>>>12,Qe=ne<<20|re>>>12,et=ae<<7|ie>>>25,tt=ie<<7|ae>>>25,rt=se<<8|oe>>>24,nt=oe<<8|se>>>24,it=fe<<14|ue>>>18,at=ue<<14|fe>>>18;e[0]=ce^~we&xe,e[1]=de^~Ae&ke,e[10]=Ve^~Xe&pe,e[11]=Ke^~Qe&be,e[20]=ye^~Ce&Ye,e[21]=Ee^~Re&He,e[30]=Je^~he&Ie,e[31]=Ze^~le&Se,e[40]=Le^~Ue&et,e[41]=Be^~ze&tt,e[2]=we^~xe&qe,e[3]=Ae^~ke&Fe,e[12]=Xe^~pe&$e,e[13]=Qe^~be&Pe,e[22]=Ce^~Ye&rt,e[23]=Re^~He&nt,e[32]=he^~Ie&Ne,e[33]=le^~Se&Oe,e[42]=Ue^~et&me,e[43]=ze^~tt&ge,e[4]=xe^~qe&it,e[5]=ke^~Fe&at,e[14]=pe^~$e&De,e[15]=be^~Pe&je,e[24]=Ye^~rt&_e,e[25]=He^~nt&ve,e[34]=Ie^~Ne&We,e[35]=Se^~Oe&Ge,e[44]=et^~me&Me,e[45]=tt^~ge&Te,e[6]=qe^~it&ce,e[7]=Fe^~at&de,e[16]=$e^~De&Ve,e[17]=Pe^~je&Ke,e[26]=rt^~_e&ye,e[27]=nt^~ve&Ee,e[36]=Ne^~We&Je,e[37]=Oe^~Ge&Ze,e[46]=me^~Me&Le,e[47]=ge^~Te&Be,e[8]=it^~ce&we,e[9]=at^~de&Ae,e[18]=De^~Ve&Xe,e[19]=je^~Ke&Qe,e[28]=_e^~ye&Ce,e[29]=ve^~Ee&Re,e[38]=We^~Je&he,e[39]=Ge^~Ze&le,e[48]=Me^~Le&Ue,e[49]=Te^~Be&ze,e[0]^=P1600_ROUND_CONSTANTS[2*t],e[1]^=P1600_ROUND_CONSTANTS[2*t+1]}},keccakStateUnroll={p1600:p1600},Buffer$4=safeBuffer.Buffer;function Keccak(){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}Keccak.prototype.initialize=function(e,t){for(var r=0;r<50;++r)this.state[r]=0;this.blockSize=e/8,this.count=0,this.squeezing=!1},Keccak.prototype.absorb=function(e){for(var t=0;t>>this.count%4*8&255,this.count+=1,this.count===this.blockSize&&(keccakStateUnroll.p1600(this.state),this.count=0);return t},Keccak.prototype.copy=function(e){for(var t=0;t<50;++t)e.state[t]=this.state[t];e.blockSize=this.blockSize,e.count=this.count,e.squeezing=this.squeezing};var keccak$1=Keccak,js=api(keccak$1),toString$1=Object.prototype.toString,isArray$4=function(e,t){if(!Array.isArray(e))throw TypeError(t)},isBoolean$1=function(e,t){if("[object Boolean]"!==toString$1.call(e))throw TypeError(t)},isBuffer$1=function(e,t){if(!Buffer.isBuffer(e))throw TypeError(t)},isFunction$2=function(e,t){if("[object Function]"!==toString$1.call(e))throw TypeError(t)},isNumber$1=function(e,t){if("[object Number]"!==toString$1.call(e))throw TypeError(t)},isObject$2=function(e,t){if("[object Object]"!==toString$1.call(e))throw TypeError(t)},isBufferLength=function(e,t,r){if(e.length!==t)throw RangeError(r)},isBufferLength2=function(e,t,r,n){if(e.length!==t&&e.length!==r)throw RangeError(n)},isLengthGTZero=function(e,t){if(0===e.length)throw RangeError(t)},isNumberInInterval=function(e,t,r,n){if(e<=t||e>=r)throw RangeError(n)},assert={isArray:isArray$4,isBoolean:isBoolean$1,isBuffer:isBuffer$1,isFunction:isFunction$2,isNumber:isNumber$1,isObject:isObject$2,isBufferLength:isBufferLength,isBufferLength2:isBufferLength2,isLengthGTZero:isLengthGTZero,isNumberInInterval:isNumberInInterval},Buffer$5=safeBuffer.Buffer;function check(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]))))))}function decode(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)}}function encode$1(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$5.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}var bip66={check:check,decode:decode,encode:encode$1},Buffer$6=safeBuffer.Buffer,EC_PRIVKEY_EXPORT_DER_COMPRESSED=Buffer$6.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]),EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED=Buffer$6.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]),privateKeyExport=function(e,t,r){var n=Buffer$6.from(r?EC_PRIVKEY_EXPORT_DER_COMPRESSED:EC_PRIVKEY_EXPORT_DER_UNCOMPRESSED);return e.copy(n,r?8:9),t.copy(n,r?181:214),n},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[n]&&!(128&t[n+1]);--r,++n);for(var i=Buffer$6.concat([Buffer$6.from([0]),e.s]),a=33,s=0;a>1&&0===i[s]&&!(128&i[s+1]);--a,++s);return bip66.encode(t.slice(n),i.slice(s))},signatureImport=function(e){var t=Buffer$6.alloc(32,0),r=Buffer$6.alloc(32,0);try{var n=bip66.decode(e);if(33===n.r.length&&0===n.r[0]&&(n.r=n.r.slice(1)),n.r.length>32)throw new Error("R length is too long");if(33===n.s.length&&0===n.s[0]&&(n.s=n.s.slice(1)),n.s.length>32)throw new Error("S length is too long")}catch(e){return}return n.r.copy(t,32-n.r.length),n.s.copy(r,32-n.s.length),{r:t,s:r}},signatureImportLax=function(e){var t=Buffer$6.alloc(32,0),r=Buffer$6.alloc(32,0),n=e.length,i=0;if(48===e[i++]){var a=e[i++];if(!(128&a&&(i+=a-128)>n)&&2===e[i++]){var s=e[i++];if(128&s){if(i+(a=s-128)>n)return;for(;a>0&&0===e[i];i+=1,a-=1);for(s=0;a>0;i+=1,a-=1)s=(s<<8)+e[i]}if(!(s>n-i)){var o=i;if(i+=s,2===e[i++]){var f=e[i++];if(128&f){if(i+(a=f-128)>n)return;for(;a>0&&0===e[i];i+=1,a-=1);for(f=0;a>0;i+=1,a-=1)f=(f<<8)+e[i]}if(!(f>n-i)){var u=i;for(i+=f;s>0&&0===e[o];s-=1,o+=1);if(!(s>32)){var c=e.slice(o,o+s);for(c.copy(t,32-c.length);f>0&&0===e[u];f-=1,u+=1);if(!(f>32)){var d=e.slice(u,u+f);return d.copy(r,32-d.length),{r:t,s:r}}}}}}}}},der={privateKeyExport:privateKeyExport,privateKeyImport:privateKeyImport,signatureExport:signatureExport,signatureImport:signatureImport,signatureImportLax:signatureImportLax},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",messages={COMPRESSED_TYPE_INVALID:COMPRESSED_TYPE_INVALID,EC_PRIVATE_KEY_TYPE_INVALID:EC_PRIVATE_KEY_TYPE_INVALID,EC_PRIVATE_KEY_LENGTH_INVALID:EC_PRIVATE_KEY_LENGTH_INVALID,EC_PRIVATE_KEY_RANGE_INVALID:EC_PRIVATE_KEY_RANGE_INVALID,EC_PRIVATE_KEY_TWEAK_ADD_FAIL:EC_PRIVATE_KEY_TWEAK_ADD_FAIL,EC_PRIVATE_KEY_TWEAK_MUL_FAIL:EC_PRIVATE_KEY_TWEAK_MUL_FAIL,EC_PRIVATE_KEY_EXPORT_DER_FAIL:EC_PRIVATE_KEY_EXPORT_DER_FAIL,EC_PRIVATE_KEY_IMPORT_DER_FAIL:EC_PRIVATE_KEY_IMPORT_DER_FAIL,EC_PUBLIC_KEYS_TYPE_INVALID:EC_PUBLIC_KEYS_TYPE_INVALID,EC_PUBLIC_KEYS_LENGTH_INVALID:EC_PUBLIC_KEYS_LENGTH_INVALID,EC_PUBLIC_KEY_TYPE_INVALID:EC_PUBLIC_KEY_TYPE_INVALID,EC_PUBLIC_KEY_LENGTH_INVALID:EC_PUBLIC_KEY_LENGTH_INVALID,EC_PUBLIC_KEY_PARSE_FAIL:EC_PUBLIC_KEY_PARSE_FAIL,EC_PUBLIC_KEY_CREATE_FAIL:EC_PUBLIC_KEY_CREATE_FAIL,EC_PUBLIC_KEY_TWEAK_ADD_FAIL:EC_PUBLIC_KEY_TWEAK_ADD_FAIL,EC_PUBLIC_KEY_TWEAK_MUL_FAIL:EC_PUBLIC_KEY_TWEAK_MUL_FAIL,EC_PUBLIC_KEY_COMBINE_FAIL:EC_PUBLIC_KEY_COMBINE_FAIL,ECDH_FAIL:ECDH_FAIL,ECDSA_SIGNATURE_TYPE_INVALID:ECDSA_SIGNATURE_TYPE_INVALID,ECDSA_SIGNATURE_LENGTH_INVALID:ECDSA_SIGNATURE_LENGTH_INVALID,ECDSA_SIGNATURE_PARSE_FAIL:ECDSA_SIGNATURE_PARSE_FAIL,ECDSA_SIGNATURE_PARSE_DER_FAIL:ECDSA_SIGNATURE_PARSE_DER_FAIL,ECDSA_SIGNATURE_SERIALIZE_DER_FAIL:ECDSA_SIGNATURE_SERIALIZE_DER_FAIL,ECDSA_SIGN_FAIL:ECDSA_SIGN_FAIL,ECDSA_RECOVER_FAIL:ECDSA_RECOVER_FAIL,MSG32_TYPE_INVALID:MSG32_TYPE_INVALID,MSG32_LENGTH_INVALID:MSG32_LENGTH_INVALID,OPTIONS_TYPE_INVALID:OPTIONS_TYPE_INVALID,OPTIONS_DATA_TYPE_INVALID:OPTIONS_DATA_TYPE_INVALID,OPTIONS_DATA_LENGTH_INVALID:OPTIONS_DATA_LENGTH_INVALID,OPTIONS_NONCEFN_TYPE_INVALID:OPTIONS_NONCEFN_TYPE_INVALID,RECOVERY_ID_TYPE_INVALID:RECOVERY_ID_TYPE_INVALID,RECOVERY_ID_VALUE_INVALID:RECOVERY_ID_VALUE_INVALID,TWEAK_TYPE_INVALID:TWEAK_TYPE_INVALID,TWEAK_LENGTH_INVALID:TWEAK_LENGTH_INVALID},messages$1=Object.freeze({COMPRESSED_TYPE_INVALID:COMPRESSED_TYPE_INVALID,EC_PRIVATE_KEY_TYPE_INVALID:EC_PRIVATE_KEY_TYPE_INVALID,EC_PRIVATE_KEY_LENGTH_INVALID:EC_PRIVATE_KEY_LENGTH_INVALID,EC_PRIVATE_KEY_RANGE_INVALID:EC_PRIVATE_KEY_RANGE_INVALID,EC_PRIVATE_KEY_TWEAK_ADD_FAIL:EC_PRIVATE_KEY_TWEAK_ADD_FAIL,EC_PRIVATE_KEY_TWEAK_MUL_FAIL:EC_PRIVATE_KEY_TWEAK_MUL_FAIL,EC_PRIVATE_KEY_EXPORT_DER_FAIL:EC_PRIVATE_KEY_EXPORT_DER_FAIL,EC_PRIVATE_KEY_IMPORT_DER_FAIL:EC_PRIVATE_KEY_IMPORT_DER_FAIL,EC_PUBLIC_KEYS_TYPE_INVALID:EC_PUBLIC_KEYS_TYPE_INVALID,EC_PUBLIC_KEYS_LENGTH_INVALID:EC_PUBLIC_KEYS_LENGTH_INVALID,EC_PUBLIC_KEY_TYPE_INVALID:EC_PUBLIC_KEY_TYPE_INVALID,EC_PUBLIC_KEY_LENGTH_INVALID:EC_PUBLIC_KEY_LENGTH_INVALID,EC_PUBLIC_KEY_PARSE_FAIL:EC_PUBLIC_KEY_PARSE_FAIL,EC_PUBLIC_KEY_CREATE_FAIL:EC_PUBLIC_KEY_CREATE_FAIL,EC_PUBLIC_KEY_TWEAK_ADD_FAIL:EC_PUBLIC_KEY_TWEAK_ADD_FAIL,EC_PUBLIC_KEY_TWEAK_MUL_FAIL:EC_PUBLIC_KEY_TWEAK_MUL_FAIL,EC_PUBLIC_KEY_COMBINE_FAIL:EC_PUBLIC_KEY_COMBINE_FAIL,ECDH_FAIL:ECDH_FAIL,ECDSA_SIGNATURE_TYPE_INVALID:ECDSA_SIGNATURE_TYPE_INVALID,ECDSA_SIGNATURE_LENGTH_INVALID:ECDSA_SIGNATURE_LENGTH_INVALID,ECDSA_SIGNATURE_PARSE_FAIL:ECDSA_SIGNATURE_PARSE_FAIL,ECDSA_SIGNATURE_PARSE_DER_FAIL:ECDSA_SIGNATURE_PARSE_DER_FAIL,ECDSA_SIGNATURE_SERIALIZE_DER_FAIL:ECDSA_SIGNATURE_SERIALIZE_DER_FAIL,ECDSA_SIGN_FAIL:ECDSA_SIGN_FAIL,ECDSA_RECOVER_FAIL:ECDSA_RECOVER_FAIL,MSG32_TYPE_INVALID:MSG32_TYPE_INVALID,MSG32_LENGTH_INVALID:MSG32_LENGTH_INVALID,OPTIONS_TYPE_INVALID:OPTIONS_TYPE_INVALID,OPTIONS_DATA_TYPE_INVALID:OPTIONS_DATA_TYPE_INVALID,OPTIONS_DATA_LENGTH_INVALID:OPTIONS_DATA_LENGTH_INVALID,OPTIONS_NONCEFN_TYPE_INVALID:OPTIONS_NONCEFN_TYPE_INVALID,RECOVERY_ID_TYPE_INVALID:RECOVERY_ID_TYPE_INVALID,RECOVERY_ID_VALUE_INVALID:RECOVERY_ID_VALUE_INVALID,TWEAK_TYPE_INVALID:TWEAK_TYPE_INVALID,TWEAK_LENGTH_INVALID:TWEAK_LENGTH_INVALID,default:messages}),messages$2=getCjsExportFromNamespace(messages$1);function initCompressedValue(e,t){return void 0===e?t:(assert.isBoolean(e,messages$2.COMPRESSED_TYPE_INVALID),e)}var lib=function(e){return{privateKeyVerify:function(t){return assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),32===t.length&&e.privateKeyVerify(t)},privateKeyExport:function(t,r){assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(t,32,messages$2.EC_PRIVATE_KEY_LENGTH_INVALID),r=initCompressedValue(r,!0);var n=e.privateKeyExport(t,r);return der.privateKeyExport(t,n,r)},privateKeyImport:function(t){if(assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),(t=der.privateKeyImport(t))&&32===t.length&&e.privateKeyVerify(t))return t;throw new Error(messages$2.EC_PRIVATE_KEY_IMPORT_DER_FAIL)},privateKeyNegate:function(t){return assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(t,32,messages$2.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyNegate(t)},privateKeyModInverse:function(t){return assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(t,32,messages$2.EC_PRIVATE_KEY_LENGTH_INVALID),e.privateKeyModInverse(t)},privateKeyTweakAdd:function(t,r){return assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(t,32,messages$2.EC_PRIVATE_KEY_LENGTH_INVALID),assert.isBuffer(r,messages$2.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages$2.TWEAK_LENGTH_INVALID),e.privateKeyTweakAdd(t,r)},privateKeyTweakMul:function(t,r){return assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(t,32,messages$2.EC_PRIVATE_KEY_LENGTH_INVALID),assert.isBuffer(r,messages$2.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages$2.TWEAK_LENGTH_INVALID),e.privateKeyTweakMul(t,r)},publicKeyCreate:function(t,r){return assert.isBuffer(t,messages$2.EC_PRIVATE_KEY_TYPE_INVALID),assert.isBufferLength(t,32,messages$2.EC_PRIVATE_KEY_LENGTH_INVALID),r=initCompressedValue(r,!0),e.publicKeyCreate(t,r)},publicKeyConvert:function(t,r){return assert.isBuffer(t,messages$2.EC_PUBLIC_KEY_TYPE_INVALID),assert.isBufferLength2(t,33,65,messages$2.EC_PUBLIC_KEY_LENGTH_INVALID),r=initCompressedValue(r,!0),e.publicKeyConvert(t,r)},publicKeyVerify:function(t){return assert.isBuffer(t,messages$2.EC_PUBLIC_KEY_TYPE_INVALID),e.publicKeyVerify(t)},publicKeyTweakAdd:function(t,r,n){return assert.isBuffer(t,messages$2.EC_PUBLIC_KEY_TYPE_INVALID),assert.isBufferLength2(t,33,65,messages$2.EC_PUBLIC_KEY_LENGTH_INVALID),assert.isBuffer(r,messages$2.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages$2.TWEAK_LENGTH_INVALID),n=initCompressedValue(n,!0),e.publicKeyTweakAdd(t,r,n)},publicKeyTweakMul:function(t,r,n){return assert.isBuffer(t,messages$2.EC_PUBLIC_KEY_TYPE_INVALID),assert.isBufferLength2(t,33,65,messages$2.EC_PUBLIC_KEY_LENGTH_INVALID),assert.isBuffer(r,messages$2.TWEAK_TYPE_INVALID),assert.isBufferLength(r,32,messages$2.TWEAK_LENGTH_INVALID),n=initCompressedValue(n,!0),e.publicKeyTweakMul(t,r,n)},publicKeyCombine:function(t,r){assert.isArray(t,messages$2.EC_PUBLIC_KEYS_TYPE_INVALID),assert.isLengthGTZero(t,messages$2.EC_PUBLIC_KEYS_LENGTH_INVALID);for(var n=0;n=this._blockSize;){for(var i=this._blockOffset;i0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);return this},HashBase.prototype._update=function(){throw new Error("_update is not implemented")},HashBase.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},HashBase.prototype._digest=function(){throw new Error("_digest is not implemented")};var hashBase=HashBase,Buffer$8=safeBuffer.Buffer,ARRAY16=new Array(16);function MD5(){hashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}function rotl(e,t){return e<>>32-t}function fnF(e,t,r,n,i,a,s){return rotl(e+(t&r|~t&n)+i+a|0,s)+t|0}function fnG(e,t,r,n,i,a,s){return rotl(e+(t&n|r&~n)+i+a|0,s)+t|0}function fnH(e,t,r,n,i,a,s){return rotl(e+(t^r^n)+i+a|0,s)+t|0}function fnI(e,t,r,n,i,a,s){return rotl(e+(r^(t|~n))+i+a|0,s)+t|0}inherits_browser(MD5,hashBase),MD5.prototype._update=function(){for(var e=ARRAY16,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=fnF(r,n,i,a,e[0],3614090360,7),a=fnF(a,r,n,i,e[1],3905402710,12),i=fnF(i,a,r,n,e[2],606105819,17),n=fnF(n,i,a,r,e[3],3250441966,22),r=fnF(r,n,i,a,e[4],4118548399,7),a=fnF(a,r,n,i,e[5],1200080426,12),i=fnF(i,a,r,n,e[6],2821735955,17),n=fnF(n,i,a,r,e[7],4249261313,22),r=fnF(r,n,i,a,e[8],1770035416,7),a=fnF(a,r,n,i,e[9],2336552879,12),i=fnF(i,a,r,n,e[10],4294925233,17),n=fnF(n,i,a,r,e[11],2304563134,22),r=fnF(r,n,i,a,e[12],1804603682,7),a=fnF(a,r,n,i,e[13],4254626195,12),i=fnF(i,a,r,n,e[14],2792965006,17),r=fnG(r,n=fnF(n,i,a,r,e[15],1236535329,22),i,a,e[1],4129170786,5),a=fnG(a,r,n,i,e[6],3225465664,9),i=fnG(i,a,r,n,e[11],643717713,14),n=fnG(n,i,a,r,e[0],3921069994,20),r=fnG(r,n,i,a,e[5],3593408605,5),a=fnG(a,r,n,i,e[10],38016083,9),i=fnG(i,a,r,n,e[15],3634488961,14),n=fnG(n,i,a,r,e[4],3889429448,20),r=fnG(r,n,i,a,e[9],568446438,5),a=fnG(a,r,n,i,e[14],3275163606,9),i=fnG(i,a,r,n,e[3],4107603335,14),n=fnG(n,i,a,r,e[8],1163531501,20),r=fnG(r,n,i,a,e[13],2850285829,5),a=fnG(a,r,n,i,e[2],4243563512,9),i=fnG(i,a,r,n,e[7],1735328473,14),r=fnH(r,n=fnG(n,i,a,r,e[12],2368359562,20),i,a,e[5],4294588738,4),a=fnH(a,r,n,i,e[8],2272392833,11),i=fnH(i,a,r,n,e[11],1839030562,16),n=fnH(n,i,a,r,e[14],4259657740,23),r=fnH(r,n,i,a,e[1],2763975236,4),a=fnH(a,r,n,i,e[4],1272893353,11),i=fnH(i,a,r,n,e[7],4139469664,16),n=fnH(n,i,a,r,e[10],3200236656,23),r=fnH(r,n,i,a,e[13],681279174,4),a=fnH(a,r,n,i,e[0],3936430074,11),i=fnH(i,a,r,n,e[3],3572445317,16),n=fnH(n,i,a,r,e[6],76029189,23),r=fnH(r,n,i,a,e[9],3654602809,4),a=fnH(a,r,n,i,e[12],3873151461,11),i=fnH(i,a,r,n,e[15],530742520,16),r=fnI(r,n=fnH(n,i,a,r,e[2],3299628645,23),i,a,e[0],4096336452,6),a=fnI(a,r,n,i,e[7],1126891415,10),i=fnI(i,a,r,n,e[14],2878612391,15),n=fnI(n,i,a,r,e[5],4237533241,21),r=fnI(r,n,i,a,e[12],1700485571,6),a=fnI(a,r,n,i,e[3],2399980690,10),i=fnI(i,a,r,n,e[10],4293915773,15),n=fnI(n,i,a,r,e[1],2240044497,21),r=fnI(r,n,i,a,e[8],1873313359,6),a=fnI(a,r,n,i,e[15],4264355552,10),i=fnI(i,a,r,n,e[6],2734768916,15),n=fnI(n,i,a,r,e[13],1309151649,21),r=fnI(r,n,i,a,e[4],4149444226,6),a=fnI(a,r,n,i,e[11],3174756917,10),i=fnI(i,a,r,n,e[2],718787259,15),n=fnI(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},MD5.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$8.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};var md5_js=MD5,Buffer$9=bufferEs6.Buffer,ARRAY16$1=new Array(16),zl=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],zr=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],sl=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],sr=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],hl=[0,1518500249,1859775393,2400959708,2840853838],hr=[1352829926,1548603684,1836072691,2053994217,0];function RIPEMD160(){hashBase.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function rotl$1(e,t){return e<>>32-t}function fn1(e,t,r,n,i,a,s,o){return rotl$1(e+(t^r^n)+a+s|0,o)+i|0}function fn2(e,t,r,n,i,a,s,o){return rotl$1(e+(t&r|~t&n)+a+s|0,o)+i|0}function fn3(e,t,r,n,i,a,s,o){return rotl$1(e+((t|~r)^n)+a+s|0,o)+i|0}function fn4(e,t,r,n,i,a,s,o){return rotl$1(e+(t&n|r&~n)+a+s|0,o)+i|0}function fn5(e,t,r,n,i,a,s,o){return rotl$1(e+(t^(r|~n))+a+s|0,o)+i|0}inherits_browser(RIPEMD160,hashBase),RIPEMD160.prototype._update=function(){for(var e=ARRAY16$1,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,a=0|this._d,s=0|this._e,o=0|this._a,f=0|this._b,u=0|this._c,c=0|this._d,d=0|this._e,h=0;h<80;h+=1){var l,p;h<16?(l=fn1(r,n,i,a,s,e[zl[h]],hl[0],sl[h]),p=fn5(o,f,u,c,d,e[zr[h]],hr[0],sr[h])):h<32?(l=fn2(r,n,i,a,s,e[zl[h]],hl[1],sl[h]),p=fn4(o,f,u,c,d,e[zr[h]],hr[1],sr[h])):h<48?(l=fn3(r,n,i,a,s,e[zl[h]],hl[2],sl[h]),p=fn3(o,f,u,c,d,e[zr[h]],hr[2],sr[h])):h<64?(l=fn4(r,n,i,a,s,e[zl[h]],hl[3],sl[h]),p=fn2(o,f,u,c,d,e[zr[h]],hr[3],sr[h])):(l=fn5(r,n,i,a,s,e[zl[h]],hl[4],sl[h]),p=fn1(o,f,u,c,d,e[zr[h]],hr[4],sr[h])),r=s,s=a,a=rotl$1(i,10),i=n,n=l,o=d,d=c,c=rotl$1(u,10),u=f,f=p}var b=this._b+i+c|0;this._b=this._c+a+d|0,this._c=this._d+s+o|0,this._d=this._e+r+f|0,this._e=this._a+n+u|0,this._a=b},RIPEMD160.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$9.alloc?Buffer$9.alloc(20):new Buffer$9(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};var ripemd160=RIPEMD160,Buffer$a=safeBuffer.Buffer;function Hash(e,t){this._block=Buffer$a.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Hash.prototype.update=function(e,t){"string"==typeof e&&(t=t||"utf8",e=Buffer$a.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,a=this._len,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 a=this._hash();return e?a.toString(e):a},Hash.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var hash=Hash,Buffer$b=safeBuffer.Buffer,K=[1518500249,1859775393,-1894007588,-899497514],W=new Array(80);function Sha(){this.init(),this._w=W,hash.call(this,64,56)}function rotl5(e){return e<<5|e>>>27}function rotl30(e){return e<<30|e>>>2}function ft(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}inherits_browser(Sha,hash),Sha.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,a=0|this._d,s=0|this._e,o=0;o<16;++o)t[o]=e.readInt32BE(4*o);for(;o<80;++o)t[o]=t[o-3]^t[o-8]^t[o-14]^t[o-16];for(var f=0;f<80;++f){var u=~~(f/20),c=rotl5(r)+ft(u,n,i,a)+s+t[f]+K[u]|0;s=a,a=i,i=rotl30(n),n=r,r=c}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},Sha.prototype._hash=function(){var e=Buffer$b.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};var sha=Sha,Buffer$c=safeBuffer.Buffer,K$1=[1518500249,1859775393,-1894007588,-899497514],W$1=new Array(80);function Sha1(){this.init(),this._w=W$1,hash.call(this,64,56)}function rotl1(e){return e<<1|e>>>31}function rotl5$1(e){return e<<5|e>>>27}function rotl30$1(e){return e<<30|e>>>2}function ft$1(e,t,r,n){return 0===e?t&r|~t&n:2===e?t&r|t&n|r&n:t^r^n}inherits_browser(Sha1,hash),Sha1.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},Sha1.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,a=0|this._d,s=0|this._e,o=0;o<16;++o)t[o]=e.readInt32BE(4*o);for(;o<80;++o)t[o]=rotl1(t[o-3]^t[o-8]^t[o-14]^t[o-16]);for(var f=0;f<80;++f){var u=~~(f/20),c=rotl5$1(r)+ft$1(u,n,i,a)+s+t[f]+K$1[u]|0;s=a,a=i,i=rotl30$1(n),n=r,r=c}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0},Sha1.prototype._hash=function(){var e=Buffer$c.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};var sha1=Sha1,Buffer$d=safeBuffer.Buffer,K$2=[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],W$2=new Array(64);function Sha256(){this.init(),this._w=W$2,hash.call(this,64,56)}function ch(e,t,r){return r^e&(t^r)}function maj(e,t,r){return e&t|r&(e|t)}function sigma0(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function sigma1(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function gamma0(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function gamma1(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}inherits_browser(Sha256,hash),Sha256.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},Sha256.prototype._update=function(e){for(var t=this._w,r=0|this._a,n=0|this._b,i=0|this._c,a=0|this._d,s=0|this._e,o=0|this._f,f=0|this._g,u=0|this._h,c=0;c<16;++c)t[c]=e.readInt32BE(4*c);for(;c<64;++c)t[c]=gamma1(t[c-2])+t[c-7]+gamma0(t[c-15])+t[c-16]|0;for(var d=0;d<64;++d){var h=u+sigma1(s)+ch(s,o,f)+K$2[d]+t[d]|0,l=sigma0(r)+maj(r,n,i)|0;u=f,f=o,o=s,s=a+h|0,a=i,i=n,n=r,r=h+l|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=s+this._e|0,this._f=o+this._f|0,this._g=f+this._g|0,this._h=u+this._h|0},Sha256.prototype._hash=function(){var e=Buffer$d.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};var sha256=Sha256,Buffer$e=safeBuffer.Buffer,W$3=new Array(64);function Sha224(){this.init(),this._w=W$3,hash.call(this,64,56)}inherits_browser(Sha224,sha256),Sha224.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},Sha224.prototype._hash=function(){var e=Buffer$e.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};var sha224=Sha224,Buffer$f=safeBuffer.Buffer,K$3=[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],W$4=new Array(160);function Sha512(){this.init(),this._w=W$4,hash.call(this,128,112)}function Ch(e,t,r){return r^e&(t^r)}function maj$1(e,t,r){return e&t|r&(e|t)}function sigma0$1(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function sigma1$1(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Gamma0(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function Gamma0l(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Gamma1(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Gamma1l(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function getCarry(e,t){return e>>>0>>0?1:0}inherits_browser(Sha512,hash),Sha512.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},Sha512.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,o=0|this._fh,f=0|this._gh,u=0|this._hh,c=0|this._al,d=0|this._bl,h=0|this._cl,l=0|this._dl,p=0|this._el,b=0|this._fl,m=0|this._gl,g=0|this._hl,_=0;_<32;_+=2)t[_]=e.readInt32BE(4*_),t[_+1]=e.readInt32BE(4*_+4);for(;_<160;_+=2){var v=t[_-30],y=t[_-30+1],E=Gamma0(v,y),w=Gamma0l(y,v),A=Gamma1(v=t[_-4],y=t[_-4+1]),I=Gamma1l(y,v),S=t[_-14],$=t[_-14+1],P=t[_-32],M=t[_-32+1],T=w+$|0,L=E+S+getCarry(T,w)|0;L=(L=L+A+getCarry(T=T+I|0,I)|0)+P+getCarry(T=T+M|0,M)|0,t[_]=L,t[_+1]=T}for(var B=0;B<160;B+=2){L=t[B],T=t[B+1];var C=maj$1(r,n,i),R=maj$1(c,d,h),x=sigma0$1(r,c),k=sigma0$1(c,r),N=sigma1$1(s,p),O=sigma1$1(p,s),D=K$3[B],j=K$3[B+1],V=Ch(s,o,f),K=Ch(p,b,m),U=g+O|0,z=u+N+getCarry(U,g)|0;z=(z=(z=z+V+getCarry(U=U+K|0,K)|0)+D+getCarry(U=U+j|0,j)|0)+L+getCarry(U=U+T|0,T)|0;var Y=k+R|0,H=x+C+getCarry(Y,k)|0;u=f,g=m,f=o,m=b,o=s,b=p,s=a+z+getCarry(p=l+U|0,l)|0,a=i,l=h,i=n,h=d,n=r,d=c,r=z+H+getCarry(c=U+Y|0,U)|0}this._al=this._al+c|0,this._bl=this._bl+d|0,this._cl=this._cl+h|0,this._dl=this._dl+l|0,this._el=this._el+p|0,this._fl=this._fl+b|0,this._gl=this._gl+m|0,this._hl=this._hl+g|0,this._ah=this._ah+r+getCarry(this._al,c)|0,this._bh=this._bh+n+getCarry(this._bl,d)|0,this._ch=this._ch+i+getCarry(this._cl,h)|0,this._dh=this._dh+a+getCarry(this._dl,l)|0,this._eh=this._eh+s+getCarry(this._el,p)|0,this._fh=this._fh+o+getCarry(this._fl,b)|0,this._gh=this._gh+f+getCarry(this._gl,m)|0,this._hh=this._hh+u+getCarry(this._hl,g)|0},Sha512.prototype._hash=function(){var e=Buffer$f.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};var sha512=Sha512,Buffer$g=safeBuffer.Buffer,W$5=new Array(160);function Sha384(){this.init(),this._w=W$5,hash.call(this,128,112)}inherits_browser(Sha384,sha512),Sha384.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},Sha384.prototype._hash=function(){var e=Buffer$g.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};var sha384=Sha384,sha_js=createCommonjsModule(function(e){var 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};t.sha=sha,t.sha1=sha1,t.sha224=sha224,t.sha256=sha256,t.sha384=sha384,t.sha512=sha512}),Buffer$h=safeBuffer.Buffer,Transform$4=Stream.Transform,StringDecoder$1=stringDecoder.StringDecoder;function CipherBase(e){Transform$4.call(this),this.hashMode="string"==typeof e,this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}inherits_browser(CipherBase,Transform$4),CipherBase.prototype.update=function(e,t,r){"string"==typeof e&&(e=Buffer$h.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)},CipherBase.prototype.setAutoPadding=function(){},CipherBase.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},CipherBase.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},CipherBase.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},CipherBase.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(e){n=e}finally{r(n)}},CipherBase.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(e){t=e}e(t)},CipherBase.prototype._finalOrDigest=function(e){var t=this.__final()||Buffer$h.alloc(0);return e&&(t=this._toString(t,e,!0)),t},CipherBase.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new StringDecoder$1(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};var cipherBase=CipherBase;function Hash$1(e){cipherBase.call(this,"digest"),this._hash=e}inherits_browser(Hash$1,cipherBase),Hash$1.prototype._update=function(e){this._hash.update(e)},Hash$1.prototype._final=function(){return this._hash.digest()};var browser=function(e){return"md5"===(e=e.toLowerCase())?new md5_js:"rmd160"===e||"ripemd160"===e?new ripemd160:new Hash$1(sha_js(e))},name="elliptic",version$1="6.5.0",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:"^2.11.3",grunt:"^0.4.5","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":"^8.6.2",istanbul:"^0.4.2",jscs:"^2.9.0",jshint:"^2.6.0",mocha:"^2.1.0"},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"},_package={name:name,version:version$1,description:description,main:main,files:files,scripts:scripts,repository:repository,keywords:keywords,author:author,license:license,bugs:bugs,homepage:homepage,devDependencies:devDependencies,dependencies:dependencies},_package$1=Object.freeze({name:name,version:version$1,description:description,main:main,files:files,scripts:scripts,repository:repository,keywords:keywords,author:author,license:license,bugs:bugs,homepage:homepage,devDependencies:devDependencies,dependencies:dependencies,default:_package}),minimalisticAssert=assert$1;function assert$1(e,t){if(!e)throw new Error(t||"Assertion failed")}assert$1.equal=function(e,t,r){if(e!=t)throw new Error(r||"Assertion failed: "+e+" != "+t)};var r,utils_1=createCommonjsModule(function(e,t){var r=t;function n(e){return 1===e.length?"0"+e:e}function i(e){for(var t="",r=0;r>8,s=255&i;a?r.push(a,s):r.push(s)}return r},r.zero2=n,r.toHex=i,r.encode=function(e,t){return"hex"===t?i(e):e}}),utils_1$1=createCommonjsModule(function(e,t){var r=t;r.assert=minimalisticAssert,r.toArray=utils_1.toArray,r.zero2=utils_1.zero2,r.toHex=utils_1.toHex,r.encode=utils_1.encode,r.getNAF=function(e,t){for(var r=[],n=1<=0;){var a;if(i.isOdd()){var s=i.andln(n-1);a=s>(n>>1)-1?(n>>1)-s:s,i.isubn(a)}else a=0;r.push(a);for(var o=0!==i.cmpn(0)&&0===i.andln(n-1)?t+1:1,f=1;f0||t.cmpn(-i)>0;){var a,s,o,f=e.andln(3)+n&3,u=t.andln(3)+i&3;if(3===f&&(f=-1),3===u&&(u=-1),0==(1&f))a=0;else a=3!==(o=e.andln(7)+n&7)&&5!==o||2!==u?f:-f;if(r[0].push(a),0==(1&u))s=0;else s=3!==(o=t.andln(7)+i&7)&&5!==o||2!==f?u:-u;r[1].push(s),2*n===a+1&&(n=1-n),2*i===s+1&&(i=1-i),e.iushrn(1),t.iushrn(1)}return r},r.cachedProperty=function(e,t,r){var n="_"+t;e.prototype[t]=function(){return void 0!==this[n]?this[n]:this[n]=r.call(this)}},r.parseBytes=function(e){return"string"==typeof e?r.toArray(e,"hex"):e},r.intFromLE=function(e){return new bn(e,"hex","le")}}),brorand=function(e){return r||(r=new Rand(null)),r.generate(e)};function Rand(e){this.rand=e}var Rand_1=Rand;if(Rand.prototype.generate=function(e){return this._rand(e)},Rand.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),r=0;r0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}var base$1=BaseCurve;function BasePoint(e,t){this.curve=e,this.type=t,this.precomputed=null}BaseCurve.prototype.point=function(){throw new Error("Not implemented")},BaseCurve.prototype.validate=function(){throw new Error("Not implemented")},BaseCurve.prototype._fixedNafMul=function(e,t){assert$2(e.precomputed);var r=e._getDoubles(),n=getNAF(t,1),i=(1<=s;t--)o=(o<<1)+n[t];a.push(o)}for(var f=this.jpoint(null,null,null),u=this.jpoint(null,null,null),c=i;c>0;c--){for(s=0;s=0;o--){for(t=0;o>=0&&0===a[o];o--)t++;if(o>=0&&t++,s=s.dblp(t),o<0)break;var f=a[o];assert$2(0!==f),s="affine"===e.type?f>0?s.mixedAdd(i[f-1>>1]):s.mixedAdd(i[-f-1>>1].neg()):f>0?s.add(i[f-1>>1]):s.add(i[-f-1>>1].neg())}return"affine"===e.type?s.toP():s},BaseCurve.prototype._wnafMulAdd=function(e,t,r,n,i){for(var a=this._wnafT1,s=this._wnafT2,o=this._wnafT3,f=0,u=0;u=1;u-=2){var d=u-1,h=u;if(1===a[d]&&1===a[h]){var l=[t[d],null,null,t[h]];0===t[d].y.cmp(t[h].y)?(l[1]=t[d].add(t[h]),l[2]=t[d].toJ().mixedAdd(t[h].neg())):0===t[d].y.cmp(t[h].y.redNeg())?(l[1]=t[d].toJ().mixedAdd(t[h]),l[2]=t[d].add(t[h].neg())):(l[1]=t[d].toJ().mixedAdd(t[h]),l[2]=t[d].toJ().mixedAdd(t[h].neg()));var p=[-3,-1,-5,-7,0,7,5,1,3],b=getJSF(r[d],r[h]);f=Math.max(b[0].length,f),o[d]=new Array(f),o[h]=new Array(f);for(var m=0;m=0;u--){for(var E=0;u>=0;){var w=!0;for(m=0;m=0&&E++,v=v.dblp(E),u<0)break;for(m=0;m0?A=s[m][I-1>>1]:I<0&&(A=s[m][-I-1>>1].neg()),v="affine"===A.type?v.mixedAdd(A):v.add(A))}}for(u=0;u=Math.ceil((e.bitLength()+1)/t.step)},BasePoint.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var r=[this],n=this,i=0;i=0&&(a=t,s=r),n.negative&&(n=n.neg(),i=i.neg()),a.negative&&(a=a.neg(),s=s.neg()),[{a:n,b:i},{a:a,b:s}]},ShortCurve.prototype._endoSplit=function(e){var t=this.endo.basis,r=t[0],n=t[1],i=n.b.mul(e).divRound(this.n),a=r.b.neg().mul(e).divRound(this.n),s=i.mul(r.a),o=a.mul(n.a),f=i.mul(r.b),u=a.mul(n.b);return{k1:e.sub(s).sub(o),k2:f.add(u).neg()}},ShortCurve.prototype.pointFromX=function(e,t){(e=new bn(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 i=n.fromRed().isOdd();return(t&&!i||!t&&i)&&(n=n.redNeg()),this.point(e,n)},ShortCurve.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)},ShortCurve.prototype._endoWnafMulAdd=function(e,t,r){for(var n=this._endoWnafT1,i=this._endoWnafT2,a=0;a":""},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),a=i.redSqr().redISub(this.x.redAdd(this.x)),s=i.redMul(this.x.redSub(a)).redISub(this.y);return this.curve.point(a,s)},Point.prototype.getX=function(){return this.x.fromRed()},Point.prototype.getY=function(){return this.y.fromRed()},Point.prototype.mul=function(e){return e=new bn(e,16),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)},inherits_browser(JPoint,base$1.BasePoint),ShortCurve.prototype.jpoint=function(e,t,r){return new JPoint(this,e,t,r)},JPoint.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)},JPoint.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},JPoint.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),a=this.y.redMul(t.redMul(e.z)),s=e.y.redMul(r.redMul(this.z)),o=n.redSub(i),f=a.redSub(s);if(0===o.cmpn(0))return 0!==f.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var u=o.redSqr(),c=u.redMul(o),d=n.redMul(u),h=f.redSqr().redIAdd(c).redISub(d).redISub(d),l=f.redMul(d.redISub(h)).redISub(a.redMul(c)),p=this.z.redMul(e.z).redMul(o);return this.curve.jpoint(h,l,p)},JPoint.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,a=e.y.redMul(t).redMul(this.z),s=r.redSub(n),o=i.redSub(a);if(0===s.cmpn(0))return 0!==o.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var f=s.redSqr(),u=f.redMul(s),c=r.redMul(f),d=o.redSqr().redIAdd(u).redISub(c).redISub(c),h=o.redMul(c.redISub(d)).redISub(i.redMul(u)),l=this.z.redMul(s);return this.curve.jpoint(d,h,l)},JPoint.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}},JPoint.prototype.inspect=function(){return this.isInfinity()?"":""},JPoint.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},inherits_browser(MontCurve,base$1);var mont=MontCurve;function Point$1(e,t,r){base$1.BasePoint.call(this,e,"projective"),null===t&&null===r?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new bn(t,16),this.z=new bn(r,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}MontCurve.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)},inherits_browser(Point$1,base$1.BasePoint),MontCurve.prototype.decodePoint=function(e,t){return this.point(utils_1$1.toArray(e,t),1)},MontCurve.prototype.point=function(e,t){return new Point$1(this,e,t)},MontCurve.prototype.pointFromJSON=function(e){return Point$1.fromJSON(this,e)},Point$1.prototype.precompute=function(){},Point$1.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},Point$1.fromJSON=function(e,t){return new Point$1(e,t[0],t[1]||e.one)},Point$1.prototype.inspect=function(){return this.isInfinity()?"":""},Point$1.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},Point$1.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$1.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},Point$1.prototype.diffAdd=function(e,t){var r=this.x.redAdd(this.z),n=this.x.redSub(this.z),i=e.x.redAdd(e.z),a=e.x.redSub(e.z).redMul(r),s=i.redMul(n),o=t.z.redMul(a.redAdd(s).redSqr()),f=t.x.redMul(a.redISub(s).redSqr());return this.curve.point(o,f)},Point$1.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 a=i.length-1;a>=0;a--)0===i[a]?(r=r.diffAdd(n,this),n=n.dbl()):(n=r.diffAdd(n,this),r=r.dbl());return n},Point$1.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},Point$1.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},Point$1.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},Point$1.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},Point$1.prototype.getX=function(){return this.normalize(),this.x.fromRed()};var assert$4=utils_1$1.assert;function EdwardsCurve(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,base$1.call(this,"edwards",e),this.a=new bn(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new bn(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new bn(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),assert$4(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}inherits_browser(EdwardsCurve,base$1);var edwards=EdwardsCurve;function Point$2(e,t,r,n,i){base$1.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 bn(t,16),this.y=new bn(r,16),this.z=n?new bn(n,16):this.curve.one,this.t=i&&new bn(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}EdwardsCurve.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},EdwardsCurve.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},EdwardsCurve.prototype.jpoint=function(e,t,r,n){return this.point(e,t,r,n)},EdwardsCurve.prototype.pointFromX=function(e,t){(e=new bn(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=this.c2.redSub(this.a.redMul(r)),i=this.one.redSub(this.c2.redMul(this.d).redMul(r)),a=n.redMul(i.redInvm()),s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");var o=s.fromRed().isOdd();return(t&&!o||!t&&o)&&(s=s.redNeg()),this.point(e,s)},EdwardsCurve.prototype.pointFromY=function(e,t){(e=new bn(e,16)).red||(e=e.toRed(this.red));var r=e.redSqr(),n=r.redSub(this.c2),i=r.redMul(this.d).redMul(this.c2).redSub(this.a),a=n.redMul(i.redInvm());if(0===a.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var s=a.redSqrt();if(0!==s.redSqr().redSub(a).cmp(this.zero))throw new Error("invalid point");return s.fromRed().isOdd()!==t&&(s=s.redNeg()),this.point(s,e)},EdwardsCurve.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)},inherits_browser(Point$2,base$1.BasePoint),EdwardsCurve.prototype.pointFromJSON=function(e){return Point$2.fromJSON(this,e)},EdwardsCurve.prototype.point=function(e,t,r,n){return new Point$2(this,e,t,r,n)},Point$2.fromJSON=function(e,t){return new Point$2(e,t[0],t[1],t[2])},Point$2.prototype.inspect=function(){return this.isInfinity()?"":""},Point$2.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$2.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),a=n.redAdd(t),s=a.redSub(r),o=n.redSub(t),f=i.redMul(s),u=a.redMul(o),c=i.redMul(o),d=s.redMul(a);return this.curve.point(f,u,d,c)},Point$2.prototype._projDbl=function(){var e,t,r,n=this.x.redAdd(this.y).redSqr(),i=this.x.redSqr(),a=this.y.redSqr();if(this.curve.twisted){var s=(u=this.curve._mulA(i)).redAdd(a);if(this.zOne)e=n.redSub(i).redSub(a).redMul(s.redSub(this.curve.two)),t=s.redMul(u.redSub(a)),r=s.redSqr().redSub(s).redSub(s);else{var o=this.z.redSqr(),f=s.redSub(o).redISub(o);e=n.redSub(i).redISub(a).redMul(f),t=s.redMul(u.redSub(a)),r=s.redMul(f)}}else{var u=i.redAdd(a);o=this.curve._mulC(this.z).redSqr(),f=u.redSub(o).redSub(o);e=this.curve._mulC(n.redISub(u)).redMul(f),t=this.curve._mulC(u).redMul(i.redISub(a)),r=u.redMul(f)}return this.curve.point(e,t,r)},Point$2.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},Point$2.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)),a=r.redSub(t),s=i.redSub(n),o=i.redAdd(n),f=r.redAdd(t),u=a.redMul(s),c=o.redMul(f),d=a.redMul(f),h=s.redMul(o);return this.curve.point(u,c,h,d)},Point$2.prototype._projAdd=function(e){var t,r,n=this.z.redMul(e.z),i=n.redSqr(),a=this.x.redMul(e.x),s=this.y.redMul(e.y),o=this.curve.d.redMul(a).redMul(s),f=i.redSub(o),u=i.redAdd(o),c=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(a).redISub(s),d=n.redMul(f).redMul(c);return this.curve.twisted?(t=n.redMul(u).redMul(s.redSub(this.curve._mulA(a))),r=f.redMul(u)):(t=n.redMul(u).redMul(s.redSub(a)),r=this.curve._mulC(f).redMul(u)),this.curve.point(d,t,r)},Point$2.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},Point$2.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},Point$2.prototype.mulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!1)},Point$2.prototype.jmulAdd=function(e,t,r){return this.curve._wnafMulAdd(1,[this,t],[e,r],2,!0)},Point$2.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$2.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},Point$2.prototype.getX=function(){return this.normalize(),this.x.fromRed()},Point$2.prototype.getY=function(){return this.normalize(),this.y.fromRed()},Point$2.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},Point$2.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$2.prototype.toP=Point$2.prototype.normalize,Point$2.prototype.mixedAdd=Point$2.prototype.add;var curve_1=createCommonjsModule(function(e,t){var r=t;r.base=base$1,r.short=short_1,r.mont=mont,r.edwards=edwards}),inherits_1=inherits_browser;function isSurrogatePair(e,t){return 55296==(64512&e.charCodeAt(t))&&(!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1)))}function toArray(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):isSurrogatePair(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>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}var htonl_1=htonl;function toHex32(e,t){for(var r="",n=0;n>>0}return a}var join32_1=join32;function split32(e,t){for(var r=new Array(4*e.length),n=0,i=0;n>>24,r[i+1]=a>>>16&255,r[i+2]=a>>>8&255,r[i+3]=255&a):(r[i+3]=a>>>24,r[i+2]=a>>>16&255,r[i+1]=a>>>8&255,r[i]=255&a)}return r}var split32_1=split32;function rotr32(e,t){return e>>>t|e<<32-t}var rotr32_1=rotr32;function rotl32(e,t){return e<>>32-t}var rotl32_1=rotl32;function sum32(e,t){return e+t>>>0}var sum32_1=sum32;function sum32_3(e,t,r){return e+t+r>>>0}var sum32_3_1=sum32_3;function sum32_4(e,t,r,n){return e+t+r+n>>>0}var sum32_4_1=sum32_4;function sum32_5(e,t,r,n,i){return e+t+r+n+i>>>0}var sum32_5_1=sum32_5;function sum64(e,t,r,n){var i=e[t],a=n+e[t+1]>>>0,s=(a>>0,e[t+1]=a}var sum64_1=sum64;function sum64_hi(e,t,r,n){return(t+n>>>0>>0}var sum64_hi_1=sum64_hi;function sum64_lo(e,t,r,n){return t+n>>>0}var sum64_lo_1=sum64_lo;function sum64_4_hi(e,t,r,n,i,a,s,o){var f=0,u=t;return f+=(u=u+n>>>0)>>0)>>0)>>0}var sum64_4_hi_1=sum64_4_hi;function sum64_4_lo(e,t,r,n,i,a,s,o){return t+n+a+o>>>0}var sum64_4_lo_1=sum64_4_lo;function sum64_5_hi(e,t,r,n,i,a,s,o,f,u){var c=0,d=t;return c+=(d=d+n>>>0)>>0)>>0)>>0)>>0}var sum64_5_hi_1=sum64_5_hi;function sum64_5_lo(e,t,r,n,i,a,s,o,f,u){return t+n+a+o+u>>>0}var sum64_5_lo_1=sum64_5_lo;function rotr64_hi(e,t,r){return(t<<32-r|e>>>r)>>>0}var rotr64_hi_1=rotr64_hi;function rotr64_lo(e,t,r){return(e<<32-r|t>>>r)>>>0}var rotr64_lo_1=rotr64_lo;function shr64_hi(e,t,r){return e>>>r}var shr64_hi_1=shr64_hi;function shr64_lo(e,t,r){return(e<<32-r|t>>>r)>>>0}var shr64_lo_1=shr64_lo,utils={inherits:inherits_1,toArray:toArray_1,toHex:toHex_1,htonl:htonl_1,toHex32:toHex32_1,zero2:zero2_1,zero8:zero8_1,join32:join32_1,split32:split32_1,rotr32:rotr32_1,rotl32:rotl32_1,sum32:sum32_1,sum32_3:sum32_3_1,sum32_4:sum32_4_1,sum32_5:sum32_5_1,sum64:sum64_1,sum64_hi:sum64_hi_1,sum64_lo:sum64_lo_1,sum64_4_hi:sum64_4_hi_1,sum64_4_lo:sum64_4_lo_1,sum64_5_hi:sum64_5_hi_1,sum64_5_lo:sum64_5_lo_1,rotr64_hi:rotr64_hi_1,rotr64_lo:rotr64_lo_1,shr64_hi:shr64_hi_1,shr64_lo:shr64_lo_1};function BlockHash(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}var BlockHash_1=BlockHash;BlockHash.prototype.update=function(e,t){if(e=utils.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=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=utils.join32(e,0,e.length-r,this.endian);for(var n=0;n>>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,a=8;a>>3}var g0_256_1=g0_256;function g1_256(e){return rotr32$1(e,17)^rotr32$1(e,19)^e>>>10}var g1_256_1=g1_256,common$1={ft_1:ft_1_1,ch32:ch32_1,maj32:maj32_1,p32:p32_1,s0_256:s0_256_1,s1_256:s1_256_1,g0_256:g0_256_1,g1_256:g1_256_1},rotl32$1=utils.rotl32,sum32$1=utils.sum32,sum32_5$1=utils.sum32_5,ft_1$1=common$1.ft_1,BlockHash$1=common.BlockHash,sha1_K=[1518500249,1859775393,2400959708,3395469782];function SHA1(){if(!(this instanceof SHA1))return new SHA1;BlockHash$1.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}utils.inherits(SHA1,BlockHash$1);var _1=SHA1;SHA1.blockSize=512,SHA1.outSize=160,SHA1.hmacStrength=80,SHA1.padLength=64,SHA1.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()),minimalisticAssert(e.length<=this.blockSize);for(var t=e.length;t=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,r,n)}var hmacDrbg=HmacDRBG;HmacDRBG.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},HmacDRBG.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=utils_1.toArray(r,n||"hex"),this._update(r));for(var i=[];i.length"};var assert$6=utils_1$1.assert;function Signature(e,t){if(e instanceof Signature)return e;this._importDER(e,t)||(assert$6(e.r&&e.s,"Signature without r or s"),this.r=new bn(e.r,16),this.s=new bn(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}var signature=Signature;function Position(){this.place=0}function getLength(e,t){var r=e[t.place++];if(!(128&r))return r;for(var n=15&r,i=0,a=0,s=t.place;a>>3);for(e.push(128|r);--r;)e.push(t>>>(r<<3)&255);e.push(t)}}Signature.prototype._importDER=function(e,t){e=utils_1$1.toArray(e,t);var r=new Position;if(48!==e[r.place++])return!1;if(getLength(e,r)+r.place!==e.length)return!1;if(2!==e[r.place++])return!1;var n=getLength(e,r),i=e.slice(r.place,n+r.place);if(r.place+=n,2!==e[r.place++])return!1;var a=getLength(e,r);if(e.length!==a+r.place)return!1;var s=e.slice(r.place,a+r.place);return 0===i[0]&&128&i[1]&&(i=i.slice(1)),0===s[0]&&128&s[1]&&(s=s.slice(1)),this.r=new bn(i),this.s=new bn(s),this.recoveryParam=null,!0},Signature.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=rmPadding(t),r=rmPadding(r);!(r[0]||128&r[1]);)r=r.slice(1);var n=[2];constructLength(n,t.length),(n=n.concat(t)).push(2),constructLength(n,r.length);var i=n.concat(r),a=[48];return constructLength(a,i.length),a=a.concat(i),utils_1$1.encode(a,e)};var assert$7=utils_1$1.assert;function EC(e){if(!(this instanceof EC))return new EC(e);"string"==typeof e&&(assert$7(curves_1.hasOwnProperty(e),"Unknown curve "+e),e=curves_1[e]),e instanceof curves_1.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}var ec=EC;EC.prototype.keyPair=function(e){return new key(this,e)},EC.prototype.keyFromPrivate=function(e,t){return key.fromPrivate(this,e,t)},EC.prototype.keyFromPublic=function(e,t){return key.fromPublic(this,e,t)},EC.prototype.genKeyPair=function(e){e||(e={});for(var t=new hmacDrbg({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||brorand(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),r=this.n.byteLength(),n=this.n.sub(new bn(2));;){var i=new bn(t.generate(r));if(!(i.cmp(n)>0))return i.iaddn(1),this.keyFromPrivate(i)}},EC.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},EC.prototype.sign=function(e,t,r,n){"object"==typeof r&&(n=r,r=null),n||(n={}),t=this.keyFromPrivate(t,r),e=this._truncateToN(new bn(e,16));for(var i=this.n.byteLength(),a=t.getPrivate().toArray("be",i),s=e.toArray("be",i),o=new hmacDrbg({hash:this.hash,entropy:a,nonce:s,pers:n.pers,persEnc:n.persEnc||"utf8"}),f=this.n.sub(new bn(1)),u=0;;u++){var c=n.k?n.k(u):new bn(o.generate(this.n.byteLength()));if(!((c=this._truncateToN(c,!0)).cmpn(1)<=0||c.cmp(f)>=0)){var d=this.g.mul(c);if(!d.isInfinity()){var h=d.getX(),l=h.umod(this.n);if(0!==l.cmpn(0)){var p=c.invm(this.n).mul(l.mul(t.getPrivate()).iadd(e));if(0!==(p=p.umod(this.n)).cmpn(0)){var b=(d.getY().isOdd()?1:0)|(0!==h.cmp(l)?2:0);return n.canonical&&p.cmp(this.nh)>0&&(p=this.n.sub(p),b^=1),new signature({r:l,s:p,recoveryParam:b})}}}}}},EC.prototype.verify=function(e,t,r,n){e=this._truncateToN(new bn(e,16)),r=this.keyFromPublic(r,n);var i=(t=new signature(t,"hex")).r,a=t.s;if(i.cmpn(1)<0||i.cmp(this.n)>=0)return!1;if(a.cmpn(1)<0||a.cmp(this.n)>=0)return!1;var s,o=a.invm(this.n),f=o.mul(e).umod(this.n),u=o.mul(i).umod(this.n);return this.curve._maxwellTrick?!(s=this.g.jmulAdd(f,r.getPublic(),u)).isInfinity()&&s.eqXToP(i):!(s=this.g.mulAdd(f,r.getPublic(),u)).isInfinity()&&0===s.getX().umod(this.n).cmp(i)},EC.prototype.recoverPubKey=function(e,t,r,n){assert$7((3&r)===r,"The recovery param is more than two bits"),t=new signature(t,n);var i=this.n,a=new bn(e),s=t.r,o=t.s,f=1&r,u=r>>1;if(s.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");s=u?this.curve.pointFromX(s.add(this.curve.n),f):this.curve.pointFromX(s,f);var c=t.r.invm(i),d=i.sub(a).mul(c).umod(i),h=o.mul(c).umod(i);return this.g.mulAdd(d,s,h)},EC.prototype.getKeyRecoveryParam=function(e,t,r,n){if(null!==(t=new signature(t,n)).recoveryParam)return t.recoveryParam;for(var i=0;i<4;i++){var a;try{a=this.recoverPubKey(e,t,i)}catch(e){continue}if(a.eq(r))return i}throw new Error("Unable to find valid recovery factor")};var assert$8=utils_1$1.assert,parseBytes=utils_1$1.parseBytes,cachedProperty=utils_1$1.cachedProperty;function KeyPair$1(e,t){this.eddsa=e,this._secret=parseBytes(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=parseBytes(t.pub)}KeyPair$1.fromPublic=function(e,t){return t instanceof KeyPair$1?t:new KeyPair$1(e,{pub:t})},KeyPair$1.fromSecret=function(e,t){return t instanceof KeyPair$1?t:new KeyPair$1(e,{secret:t})},KeyPair$1.prototype.secret=function(){return this._secret},cachedProperty(KeyPair$1,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),cachedProperty(KeyPair$1,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),cachedProperty(KeyPair$1,"privBytes",function(){var e=this.eddsa,t=this.hash(),r=e.encodingLength-1,n=t.slice(0,e.encodingLength);return n[0]&=248,n[r]&=127,n[r]|=64,n}),cachedProperty(KeyPair$1,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),cachedProperty(KeyPair$1,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),cachedProperty(KeyPair$1,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),KeyPair$1.prototype.sign=function(e){return assert$8(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},KeyPair$1.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},KeyPair$1.prototype.getSecret=function(e){return assert$8(this._secret,"KeyPair is public only"),utils_1$1.encode(this.secret(),e)},KeyPair$1.prototype.getPublic=function(e){return utils_1$1.encode(this.pubBytes(),e)};var key$1=KeyPair$1,assert$9=utils_1$1.assert,cachedProperty$1=utils_1$1.cachedProperty,parseBytes$1=utils_1$1.parseBytes;function Signature$1(e,t){this.eddsa=e,"object"!=typeof t&&(t=parseBytes$1(t)),Array.isArray(t)&&(t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),assert$9(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof bn&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}cachedProperty$1(Signature$1,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),cachedProperty$1(Signature$1,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),cachedProperty$1(Signature$1,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),cachedProperty$1(Signature$1,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),Signature$1.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},Signature$1.prototype.toHex=function(){return utils_1$1.encode(this.toBytes(),"hex").toUpperCase()};var signature$1=Signature$1,assert$a=utils_1$1.assert,parseBytes$2=utils_1$1.parseBytes;function EDDSA(e){if(assert$a("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof EDDSA))return new EDDSA(e);e=curves_1[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=hash_1.sha512}var eddsa=EDDSA;EDDSA.prototype.sign=function(e,t){e=parseBytes$2(e);var r=this.keyFromSecret(t),n=this.hashInt(r.messagePrefix(),e),i=this.g.mul(n),a=this.encodePoint(i),s=this.hashInt(a,r.pubBytes(),e).mul(r.priv()),o=n.add(s).umod(this.curve.n);return this.makeSignature({R:i,S:o,Rencoded:a})},EDDSA.prototype.verify=function(e,t,r){e=parseBytes$2(e),t=this.makeSignature(t);var n=this.keyFromPublic(r),i=this.hashInt(t.Rencoded(),n.pubBytes(),e),a=this.g.mul(t.S());return t.R().add(n.pub().mul(i)).eq(a)},EDDSA.prototype.hashInt=function(){for(var e=this.hash(),t=0;t=0)return null;var a=(r=r.toRed(i.red)).redSqr().redIMul(r).redIAdd(i.b).redSqrt();return 3===e!==a.isOdd()&&(a=a.redNeg()),n.keyPair({pub:{x:r,y:a}})}(t,e.slice(1,33));case 4:case 6:case 7:return 65!==e.length?null:function(e,t,r){var a=new bn(t),s=new bn(r);if(a.cmp(i.p)>=0||s.cmp(i.p)>=0)return null;if(a=a.toRed(i.red),s=s.toRed(i.red),(6===e||7===e)&&s.isOdd()!==(7===e))return null;var o=a.redSqr().redIMul(a);return s.redSqr().redISub(o.redIAdd(i.b)).isZero()?n.keyPair({pub:{x:a,y:s}}):null}(t,e.slice(1,33),e.slice(33,65));default:return null}}t.privateKeyVerify=function(e){var t=new bn(e);return t.cmp(i.n)<0&&!t.isZero()},t.privateKeyExport=function(e,t){var a=new bn(e);if(a.cmp(i.n)>=0||a.isZero())throw new Error(messages$2.EC_PRIVATE_KEY_EXPORT_DER_FAIL);return r.from(n.keyFromPrivate(e).getPublic(t,!0))},t.privateKeyNegate=function(e){var t=new bn(e);return t.isZero()?r.alloc(32):i.n.sub(t).umod(i.n).toArrayLike(r,"be",32)},t.privateKeyModInverse=function(e){var t=new bn(e);if(t.cmp(i.n)>=0||t.isZero())throw new Error(messages$2.EC_PRIVATE_KEY_RANGE_INVALID);return t.invm(i.n).toArrayLike(r,"be",32)},t.privateKeyTweakAdd=function(e,t){var n=new bn(t);if(n.cmp(i.n)>=0)throw new Error(messages$2.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);if(n.iadd(new bn(e)),n.cmp(i.n)>=0&&n.isub(i.n),n.isZero())throw new Error(messages$2.EC_PRIVATE_KEY_TWEAK_ADD_FAIL);return n.toArrayLike(r,"be",32)},t.privateKeyTweakMul=function(e,t){var n=new bn(t);if(n.cmp(i.n)>=0||n.isZero())throw new Error(messages$2.EC_PRIVATE_KEY_TWEAK_MUL_FAIL);return n.imul(new bn(e)),n.cmp(i.n)&&(n=n.umod(i.n)),n.toArrayLike(r,"be",32)},t.publicKeyCreate=function(e,t){var a=new bn(e);if(a.cmp(i.n)>=0||a.isZero())throw new Error(messages$2.EC_PUBLIC_KEY_CREATE_FAIL);return r.from(n.keyFromPrivate(e).getPublic(t,!0))},t.publicKeyConvert=function(e,t){var n=a(e);if(null===n)throw new Error(messages$2.EC_PUBLIC_KEY_PARSE_FAIL);return r.from(n.getPublic(t,!0))},t.publicKeyVerify=function(e){return null!==a(e)},t.publicKeyTweakAdd=function(e,t,n){var s=a(e);if(null===s)throw new Error(messages$2.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new bn(t)).cmp(i.n)>=0)throw new Error(messages$2.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);var o=i.g.mul(t).add(s.pub);if(o.isInfinity())throw new Error(messages$2.EC_PUBLIC_KEY_TWEAK_ADD_FAIL);return r.from(o.encode(!0,n))},t.publicKeyTweakMul=function(e,t,n){var s=a(e);if(null===s)throw new Error(messages$2.EC_PUBLIC_KEY_PARSE_FAIL);if((t=new bn(t)).cmp(i.n)>=0||t.isZero())throw new Error(messages$2.EC_PUBLIC_KEY_TWEAK_MUL_FAIL);return r.from(s.pub.mul(t).encode(!0,n))},t.publicKeyCombine=function(e,t){for(var n=new Array(e.length),i=0;i=0||a.cmp(i.n)>=0)throw new Error(messages$2.ECDSA_SIGNATURE_PARSE_FAIL);var s=r.from(e);return 1===a.cmp(n.nh)&&i.n.sub(a).toArrayLike(r,"be",32).copy(s,32),s},t.signatureExport=function(e){var t=e.slice(0,32),r=e.slice(32,64);if(new bn(t).cmp(i.n)>=0||new bn(r).cmp(i.n)>=0)throw new Error(messages$2.ECDSA_SIGNATURE_PARSE_FAIL);return{r:t,s:r}},t.signatureImport=function(e){var t=new bn(e.r);t.cmp(i.n)>=0&&(t=new bn(0));var n=new bn(e.s);return n.cmp(i.n)>=0&&(n=new bn(0)),r.concat([t.toArrayLike(r,"be",32),n.toArrayLike(r,"be",32)])},t.sign=function(e,t,a,s){if("function"==typeof a){var o=a;a=function(n){var i=o(e,t,null,s,n);if(!r.isBuffer(i)||32!==i.length)throw new Error(messages$2.ECDSA_SIGN_FAIL);return new bn(i)}}var f=new bn(t);if(f.cmp(i.n)>=0||f.isZero())throw new Error(messages$2.ECDSA_SIGN_FAIL);var u=n.sign(e,t,{canonical:!0,k:a,pers:s});return{signature:r.concat([u.r.toArrayLike(r,"be",32),u.s.toArrayLike(r,"be",32)]),recovery:u.recoveryParam}},t.verify=function(e,t,r){var s={r:t.slice(0,32),s:t.slice(32,64)},o=new bn(s.r),f=new bn(s.s);if(o.cmp(i.n)>=0||f.cmp(i.n)>=0)throw new Error(messages$2.ECDSA_SIGNATURE_PARSE_FAIL);if(1===f.cmp(n.nh)||o.isZero()||f.isZero())return!1;var u=a(r);if(null===u)throw new Error(messages$2.EC_PUBLIC_KEY_PARSE_FAIL);return n.verify(e,s,{x:u.pub.x,y:u.pub.y})},t.recover=function(e,t,a,s){var o={r:t.slice(0,32),s:t.slice(32,64)},f=new bn(o.r),u=new bn(o.s);if(f.cmp(i.n)>=0||u.cmp(i.n)>=0)throw new Error(messages$2.ECDSA_SIGNATURE_PARSE_FAIL);try{if(f.isZero()||u.isZero())throw new Error;var c=n.recoverPubKey(e,o,a);return r.from(c.encode(!0,s))}catch(e){throw new Error(messages$2.ECDSA_RECOVER_FAIL)}},t.ecdh=function(e,r){var n=t.ecdhUnsafe(e,r,!0);return browser("sha256").update(n).digest()},t.ecdhUnsafe=function(e,t,n){var s=a(e);if(null===s)throw new Error(messages$2.EC_PUBLIC_KEY_PARSE_FAIL);var o=new bn(t);if(o.cmp(i.n)>=0||o.isZero())throw new Error(messages$2.ECDH_FAIL);return r.from(s.pub.mul(o).encode(!0,n))}}),elliptic_1$1=elliptic.privateKeyVerify,elliptic_2=elliptic.privateKeyExport,elliptic_3=elliptic.privateKeyNegate,elliptic_4=elliptic.privateKeyModInverse,elliptic_5=elliptic.privateKeyTweakAdd,elliptic_6=elliptic.privateKeyTweakMul,elliptic_7=elliptic.publicKeyCreate,elliptic_8=elliptic.publicKeyConvert,elliptic_9=elliptic.publicKeyVerify,elliptic_10=elliptic.publicKeyTweakAdd,elliptic_11=elliptic.publicKeyTweakMul,elliptic_12=elliptic.publicKeyCombine,elliptic_13=elliptic.signatureNormalize,elliptic_14=elliptic.signatureExport,elliptic_15=elliptic.signatureImport,elliptic_16=elliptic.sign,elliptic_17=elliptic.verify,elliptic_18=elliptic.recover,elliptic_19=elliptic.ecdh,elliptic_20=elliptic.ecdhUnsafe,elliptic$1=lib(elliptic);function compare(e,t){if(e===t)return 0;for(var r=e.length,n=t.length,i=0,a=Math.min(r,n);i=0){var s=n.indexOf("\n",a+1);n=n.substring(s+1)}this.stack=n}}}function truncate(e,t){return"string"==typeof e?e.length=0;o--)if(f[o]!==u[o])return!1;for(o=f.length-1;o>=0;o--)if(!_deepEqual(e[s=f[o]],t[s],r,n))return!1;return!0}function notDeepEqual(e,t,r){_deepEqual(e,t,!1)&&fail(e,t,r,"notDeepEqual",notDeepEqual)}function notDeepStrictEqual(e,t,r){_deepEqual(e,t,!0)&&fail(e,t,r,"notDeepStrictEqual",notDeepStrictEqual)}function strictEqual(e,t,r){e!==t&&fail(e,t,r,"===",strictEqual)}function notStrictEqual(e,t,r){e===t&&fail(e,t,r,"!==",notStrictEqual)}function expectedException(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 _tryBlock(e){var t;try{e()}catch(e){t=e}return t}function _throws(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=_tryBlock(t),n=(r&&r.name?" ("+r.name+").":".")+(n?" "+n:"."),e&&!i&&fail(i,r,"Missing expected exception"+n);var a="string"==typeof n,s=!e&&i&&!r;if((!e&&isError(i)&&a&&expectedException(i,r)||s)&&fail(i,r,"Got unwanted exception"+n),e&&i&&r&&!expectedException(i,r)||!e&&i)throw i}function throws(e,t,r){_throws(!0,e,t,r)}function doesNotThrow(e,t,r){_throws(!1,e,t,r)}function ifError(e){if(e)throw e}assert$b.AssertionError=AssertionError,inherits$1(AssertionError,Error),assert$b.fail=fail,assert$b.ok=ok,assert$b.equal=equal,assert$b.notEqual=notEqual,assert$b.deepEqual=deepEqual,assert$b.deepStrictEqual=deepStrictEqual,assert$b.notDeepEqual=notDeepEqual,assert$b.notDeepStrictEqual=notDeepStrictEqual,assert$b.strictEqual=strictEqual,assert$b.notStrictEqual=notStrictEqual,assert$b.throws=throws,assert$b.doesNotThrow=doesNotThrow,assert$b.ifError=ifError;var src=function(e){if("string"!=typeof e)throw new Error("[is-hex-prefixed] value must be type 'string', is currently type "+typeof e+", while checking isHexPrefixed.");return"0x"===e.slice(0,2)},src$1=function(e){return"string"!=typeof e?e:src(e)?e.slice(2):e};function padToEven(e){var t=e;if("string"!=typeof t)throw new Error("[ethjs-util] while padding to even, value must be string, is currently "+typeof t+", while padToEven.");return t.length%2&&(t="0"+t),t}function intToHex(e){return"0x"+e.toString(16)}function intToBuffer(e){var t=intToHex(e);return new Buffer(padToEven(t.slice(2)),"hex")}function getBinarySize(e){if("string"!=typeof e)throw new Error("[ethjs-util] while getting binary size, method getBinarySize requires input 'str' to be type String, got '"+typeof e+"'.");return Buffer.byteLength(e,"utf8")}function arrayContainsArray(e,t,r){if(!0!==Array.isArray(e))throw new Error("[ethjs-util] method arrayContainsArray requires input 'superset' to be an array got type '"+typeof e+"'");if(!0!==Array.isArray(t))throw new Error("[ethjs-util] method arrayContainsArray requires input 'subset' to be an array got type '"+typeof t+"'");return t[Boolean(r)?"some":"every"](function(t){return e.indexOf(t)>=0})}function toUtf8(e){return new Buffer(padToEven(src$1(e).replace(/^0+|0+$/g,"")),"hex").toString("utf8")}function toAscii(e){var t="",r=0,n=e.length;for("0x"===e.substring(0,2)&&(r=2);r0&&"0"===t.toString();)t=(e=e.slice(1))[0];return e},t.stripZeros=t.unpad,t.toBuffer=function(e){if(!r.isBuffer(e))if(Array.isArray(e))e=r.from(e);else if("string"==typeof e)e=t.isHexString(e)?r.from(t.padToEven(t.stripHexPrefix(e)),"hex"):r.from(e);else if("number"==typeof e)e=t.intToBuffer(e);else if(null==e)e=r.allocUnsafe(0);else if(bn.isBN(e))e=e.toArrayLike(r);else{if(!e.toArray)throw new Error("invalid type");e=r.from(e.toArray())}return e},t.bufferToInt=function(e){return new bn(t.toBuffer(e)).toNumber()},t.bufferToHex=function(e){return"0x"+(e=t.toBuffer(e)).toString("hex")},t.fromSigned=function(e){return new bn(e).fromTwos(256)},t.toUnsigned=function(e){return r.from(e.toTwos(256).toArray())},t.keccak=function(e,r){return void 0===r&&(r=256),e=t.toBuffer(e),r||(r=256),js("keccak"+r).update(e).digest()},t.keccak256=function(e){return t.keccak(e)},t.sha256=function(e){return e=t.toBuffer(e),browser("sha256").update(e).digest()},t.ripemd160=function(e,r){e=t.toBuffer(e);var n=browser("rmd160").update(e).digest();return!0===r?t.setLength(n,32):n},t.rlphash=function(e){return t.keccak(dist$1.encode(e))},t.isValidPrivate=function(e){return elliptic$1.privateKeyVerify(e)},t.isValidPublic=function(e,t){return void 0===t&&(t=!1),64===e.length?elliptic$1.publicKeyVerify(r.concat([r.from([4]),e])):!!t&&elliptic$1.publicKeyVerify(e)},t.pubToAddress=function(e,r){return void 0===r&&(r=!1),e=t.toBuffer(e),r&&64!==e.length&&(e=elliptic$1.publicKeyConvert(e,!1).slice(1)),assert$b(64===e.length),t.keccak(e).slice(-20)},t.publicToAddress=t.pubToAddress,t.privateToPublic=function(e){return e=t.toBuffer(e),elliptic$1.publicKeyCreate(e,!1).slice(1)},t.importPublic=function(e){return 64!==(e=t.toBuffer(e)).length&&(e=elliptic$1.publicKeyConvert(e,!1).slice(1)),e},t.ecsign=function(e,t,r){var n=elliptic$1.sign(e,t),i=n.recovery;return{r:n.signature.slice(0,32),s:n.signature.slice(32,64),v:r?i+(2*r+35):i+27}},t.hashPersonalMessage=function(e){var n=t.toBuffer("Ethereum Signed Message:\n"+e.length.toString());return t.keccak(r.concat([n,e]))},t.ecrecover=function(e,a,s,o,f){var u=r.concat([t.setLength(s,32),t.setLength(o,32)],64),c=n(a,f);if(!i(c))throw new Error("Invalid signature v value");var d=elliptic$1.recover(e,u,c);return elliptic$1.publicKeyConvert(d,!1).slice(1)},t.toRpcSig=function(e,a,s,o){if(!i(n(e,o)))throw new Error("Invalid signature v value");return t.bufferToHex(r.concat([t.setLengthLeft(a,32),t.setLengthLeft(s,32),t.toBuffer(e)]))},t.fromRpcSig=function(e){var r=t.toBuffer(e);if(65!==r.length)throw new Error("Invalid signature length");var n=r[64];return n<27&&(n+=27),{v:n,r:r.slice(0,32),s:r.slice(32,64)}},t.privateToAddress=function(e){return t.publicToAddress(t.privateToPublic(e))},t.isValidAddress=function(e){return/^0x[0-9a-fA-F]{40}$/.test(e)},t.isZeroAddress=function(e){return t.zeroAddress()===t.addHexPrefix(e)},t.toChecksumAddress=function(e){e=lib$1.stripHexPrefix(e).toLowerCase();for(var r=t.keccak(e).toString("hex"),n="0x",i=0;i=8?n+=e[i].toUpperCase():n+=e[i];return n},t.isValidChecksumAddress=function(e){return t.isValidAddress(e)&&t.toChecksumAddress(e)===e},t.generateAddress=function(e,n){e=t.toBuffer(e);var i=new bn(n);return i.isZero()?t.rlphash([e,null]).slice(-20):t.rlphash([e,r.from(i.toArray())]).slice(-20)},t.generateAddress2=function(e,n,i){var a=t.toBuffer(e),s=t.toBuffer(n),o=t.toBuffer(i);return assert$b(20===a.length),assert$b(32===s.length),t.keccak256(r.concat([r.from("ff","hex"),a,s,t.keccak256(o)])).slice(-20)},t.isPrecompiled=function(e){var r=t.unpad(e);return 1===r.length&&r[0]>=1&&r[0]<=8},t.addHexPrefix=function(e){return"string"!=typeof e?e:lib$1.isHexPrefixed(e)?e:"0x"+e},t.isValidSignature=function(e,t,r,a,s){void 0===a&&(a=!0);var o=new bn("7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0",16),f=new bn("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141",16);if(32!==t.length||32!==r.length)return!1;if(!i(n(e,s)))return!1;var u=new bn(t),c=new bn(r);return!(u.isZero()||u.gt(f)||c.isZero()||c.gt(f))&&(!a||1!==c.cmp(o))},t.baToJSON=function(e){if(r.isBuffer(e))return"0x"+e.toString("hex");if(e instanceof Array){for(var n=[],i=0;i=a.length,"The field "+n.name+" must not have more "+n.length+" bytes")):n.allowZero&&0===a.length||!n.length||assert$b(n.length===a.length,"The field "+n.name+" must have byte length of "+n.length),e.raw[i]=a}e._fields.push(n.name),Object.defineProperty(e,n.name,{enumerable:!0,configurable:!0,get:a,set:s}),n.default&&(e[n.name]=n.default),n.alias&&Object.defineProperty(e,n.alias,{enumerable:!1,configurable:!0,set:s,get:a})}),i)if("string"==typeof i&&(i=r.from(lib$1.stripHexPrefix(i),"hex")),r.isBuffer(i)&&(i=dist$1.decode(i)),Array.isArray(i)){if(i.length>e._fields.length)throw new Error("wrong number of fields in data");i.forEach(function(r,n){e[e._fields[n]]=t.toBuffer(r)})}else{if("object"!=typeof i)throw new Error("invalid data");var a=Object.keys(i);n.forEach(function(t){-1!==a.indexOf(t.name)&&(e[t.name]=i[t.name]),-1!==a.indexOf(t.alias)&&(e[t.alias]=i[t.alias])})}}});unwrapExports(dist$2);var dist_1$1=dist$2.BN,dist_2$1=dist$2.rlp,dist_3$1=dist$2.secp256k1,dist_4=dist$2.MAX_INTEGER,dist_5=dist$2.TWO_POW256,dist_6=dist$2.KECCAK256_NULL_S,dist_7=dist$2.KECCAK256_NULL,dist_8=dist$2.KECCAK256_RLP_ARRAY_S,dist_9=dist$2.KECCAK256_RLP_ARRAY,dist_10=dist$2.KECCAK256_RLP_S,dist_11=dist$2.KECCAK256_RLP,dist_12=dist$2.zeros,dist_13=dist$2.zeroAddress,dist_14=dist$2.setLengthLeft,dist_15=dist$2.setLength,dist_16=dist$2.setLengthRight,dist_17=dist$2.unpad,dist_18=dist$2.stripZeros,dist_19=dist$2.toBuffer,dist_20=dist$2.bufferToInt,dist_21=dist$2.bufferToHex,dist_22=dist$2.fromSigned,dist_23=dist$2.toUnsigned,dist_24=dist$2.keccak,dist_25=dist$2.keccak256,dist_26=dist$2.sha256,dist_27=dist$2.ripemd160,dist_28=dist$2.rlphash,dist_29=dist$2.isValidPrivate,dist_30=dist$2.isValidPublic,dist_31=dist$2.pubToAddress,dist_32=dist$2.publicToAddress,dist_33=dist$2.privateToPublic,dist_34=dist$2.importPublic,dist_35=dist$2.ecsign,dist_36=dist$2.hashPersonalMessage,dist_37=dist$2.ecrecover,dist_38=dist$2.toRpcSig,dist_39=dist$2.fromRpcSig,dist_40=dist$2.privateToAddress,dist_41=dist$2.isValidAddress,dist_42=dist$2.isZeroAddress,dist_43=dist$2.toChecksumAddress,dist_44=dist$2.isValidChecksumAddress,dist_45=dist$2.generateAddress,dist_46=dist$2.generateAddress2,dist_47=dist$2.isPrecompiled,dist_48=dist$2.addHexPrefix,dist_49=dist$2.isValidSignature,dist_50=dist$2.baToJSON,dist_51=dist$2.defineProperties;function validateOptions(e){ow(e,"options",ow.object.exactShape({networkId:ow.number,dappId:ow.string,transactionCallback:ow.optional.function,apiUrl:ow.optional.string}))}function validateEvent(e){ow(e,"event",ow.object.exactShape({eventCode:ow.string,categoryCode:ow.string,transaction:ow.optional.object.exactShape({id:ow.optional.string,to:ow.string,from:ow.optional.string,value:ow.optional.string,gas:ow.optional.string,gasPrice:ow.optional.string,nonce:ow.optional.number,status:ow.optional.string}),wallet:ow.optional.object.exactShape({balance:ow.optional.string}),contract:ow.optional.object.exactShape({methodName:ow.optional.string,parameters:ow.optional.array})}))}function validateAddress(e){ow(e,"address",ow.string.is(validAddress))}function validateHash(e){ow(e,"hash",ow.string.is(validTxHash))}function validateId(e){ow(e,"id",ow.string)}function validAddress(e){return dist_41(e)||"".concat(e," is an invalid ethereum address")}function validTxHash(e){return/^0x([A-Fa-f0-9]{64})$/.test(String(e))||"".concat(e," is an invalid hash")}var session={socket:null,networkId:null,dappId:null,transactionCallback:null,status:{nodeSynced:!0,connected:null}},transactions=[],accounts=[];function Blocknative(e){return validateOptions(e),(session=_objectSpread2({},session,{},e)).socket=new SturdyWebSocket(e.apiUrl||"wss://api.blocknative.com/v0"),session.socket.onopen=function(){session.status.connected=!0},session.socket.ondown=function(){session.status.connected=!1},session.socket.onreopen=function(){session.status.connected=!0},session.socket.onmessage=handleSocketMessage,logToServer({categoryCode:"initialize",eventCode:"checkDappId",connectionId:window.localStorage.getItem("connectionId")||void 0}),{transaction:transaction,account:account,event:event,status:session.status}}function transaction(e,t){validateHash(e),t&&validateId(t);var r=Date.now(),n=createEmitter();return transactions.push({hash:e,emitter:n}),logToServer({eventCode:"txSent",categoryCode:"activeTransaction",transaction:{hash:e,id:t||e,startTime:r,status:"sent"}}),{details:{hash:e,startTime:r,eventCode:"txSent"},emitter:n}}function account(e){validateAddress(e);var t=createEmitter();return accounts.push({address:e,emitter:t}),logToServer({eventCode:"accountAddress",categoryCode:"watch",account:{address:e}}),{emitter:t,details:{address:e}}}function event(e){validateEvent(e),logToServer(e)}var createEmitter=function(){return{listeners:{},on:function(e,t){switch(e){case"txPool":case"txConfirmed":case"txSpeedUp":case"txCancel":case"txFailed":break;default:throw new Error("".concat(e," is not a valid event code, for a list of valid event codes see: https://github.com/blocknative/bn-api-client#event-codes"))}if("function"!=typeof t)throw new Error("Listener must be a function");this.listeners[e]=t}}};function handleSocketMessage(e){var t=JSON.parse(e.data),r=t.status,n=t.reason,i=t.event,a=t.connectionId,s=t.nodeSyncStatus;if(void 0!==s&&"ethereum"===s.blockchain&&s.network===networkName(session.networkId)&&(session.status.nodeSynced=s.synced),"error"===r){if(n.includes("not a valid API key")){var o=new Error(n);throw o.eventCode="initFail",o}if(n.includes("network not supported")){var f=new Error(n);throw f.eventCode="initFail",f}if(n.includes("maximum allowed amount")){var u=new Error(n);throw u.eventCode="maximumAddresses",u}}if(i&&i.transaction){var c,d=i.transaction,h=i.eventCode,l=i.contractCall,p=_objectSpread2({},d,{eventCode:h,contractCall:l});"txSpeedUp"!==h&&"txCancel"!==h||(transactions=transactions.map(function(e){return e.hash===d.originalHash&&(e.hash=d.hash),e}));var b=(c=d.watchedAddress?accounts.find(function(e){return e.address.toLowerCase()===d.watchedAddress.toLowerCase()}):transactions.find(function(e){return e.id===d.id||e.hash===d.hash}))&&c.emitter&&c.emitter.listeners[h]&&c.emitter.listeners[h](p);session.transactionCallback&&session.transactionCallback({transaction:p,emitterResult:b})}a&&window.localStorage.setItem("connectionId",a)}function logToServer(e){session.socket.send(createEventLog(e))}function createEventLog(e){var t=session,r=t.dappId,n=t.networkId;return JSON.stringify(_objectSpread2({timeStamp:new Date,dappId:r,version:version,blockchain:{system:"ethereum",network:networkName(n)}},e))}function networkName(e){switch(e){case 1:return"main";case 3:return"ropsten";case 4:return"rinkeby";case 5:return"goerli";case 42:return"kovan";case"localhost":return"localhost";default:return"local"}}module.exports=Blocknative; -//# sourceMappingURL=bn-client-sdk.js.map diff --git a/src/index.js b/src/index.js index dc5968aa0..5fc70bd41 100644 --- a/src/index.js +++ b/src/index.js @@ -1,15 +1,8 @@ +import blocknativeApi from "bn-sdk" import Onboard from "./views/Onboard.svelte" - -import { - app, - configuration, - address, - network, - balance, - walletInterface, - provider -} from "./stores" -import { validateInit, validateConfig } from "./validation" +import { app, address, network, balance, provider } from "./stores" +import { selectWallet, prepareWallet, config, getState } from "./api" +import { validateInit } from "./validation" import { getUserAgent } from "./utilities" function init(initialization) { @@ -19,9 +12,15 @@ function init(initialization) { const { subscriptions, ...rest } = initialization - app.update(store => ({ ...store, ...rest })) + app.update(store => ({ + ...store, + ...rest, + blocknative: new blocknativeApi({ + dappId: initialization.dappId, + networkId: initialization.networkId + }) + })) - // mount assist to the DOM new Onboard({ target: document.body }) @@ -45,49 +44,7 @@ function init(initialization) { } } - return { selectWallet, prepareWallet, config } -} - -export function selectWallet() { - return new Promise(resolve => { - app.update(store => ({ ...store, selectWallet: true })) - - const appUnsubscribe = app.subscribe( - ({ selectWallet, selectWalletCompleted }) => { - if (selectWallet === false) { - appUnsubscribe() - resolve(selectWalletCompleted) - } - } - ) - }) -} - -function prepareWallet() { - return new Promise(resolve => { - const walletUnsubscribe = walletInterface.subscribe(provider => { - if (!provider) { - walletUnsubscribe() - throw new Error("selectWallet must be called before prepareWallet") - } - }) - - app.update(store => ({ ...store, prepareWallet: true })) - - const appUnsubscribe = app.subscribe( - ({ prepareWallet, prepareWalletCompleted }) => { - if (prepareWallet === false) { - appUnsubscribe() - resolve(prepareWalletCompleted) - } - } - ) - }) -} - -function config(options) { - validateConfig(options) - configuration.update(store => ({ ...store, ...options })) + return { selectWallet, prepareWallet, config, getState } } -export default { init } +export default init diff --git a/src/provider.js b/src/provider.js index 7e4e8ec7f..d79708c5e 100644 --- a/src/provider.js +++ b/src/provider.js @@ -45,7 +45,7 @@ export function createModernProviderInterface(provider) { id: 1 }, (e, res) => { - resolve(parseInt(res.result, 16)) + resolve(String(parseInt(res.result, 16))) } ) }) @@ -82,7 +82,7 @@ export function createLegacyProviderInterface(provider) { params: [provider._address, "latest"] }, (e, res) => { - resolve(parseInt(res.result, 16)) + resolve(String(parseInt(res.result, 16))) } ) }) diff --git a/src/services.js b/src/services.js deleted file mode 100644 index 1918b7d85..000000000 --- a/src/services.js +++ /dev/null @@ -1,13 +0,0 @@ -import BlocknativeApi from "./bn-client-sdk" -import { app } from "./stores" - -export let blocknative - -app.subscribe(({ dappId, networkId }) => { - if (dappId) { - blocknative = BlocknativeApi({ - dappId, - networkId - }) - } -}) diff --git a/src/stores.js b/src/stores.js index cebfa40c8..b7a1eae93 100644 --- a/src/stores.js +++ b/src/stores.js @@ -1,4 +1,4 @@ -import { writable, derived } from "svelte/store" +import { writable } from "svelte/store" import { validateWalletInterface } from "./validation" export const app = writable({ @@ -20,7 +20,7 @@ export let syncingState = false export const address = createUserStateStore("address") export const network = createUserStateStore("network") -export const balance = createBalanceStore() +export const balance = createUserStateStore("balance") export const provider = writable(null) export const state = createState({ @@ -29,13 +29,15 @@ export const state = createState({ address: null, network: null, balance: null, - connect: null + connect: null, + provider: null }) // make sure state store is updated when any of these change address.subscribe(value => state.update({ address: value })) network.subscribe(value => state.update({ network: value })) balance.subscribe(value => state.update({ balance: value })) +provider.subscribe(value => state.update({ provider: value })) // keep track of intervals that are syncing state so they can be cleared let currentSyncerIntervals = [] @@ -126,35 +128,3 @@ function createUserStateStore(parameter) { } } } - -function createBalanceStore() { - let stateSyncer - const { subscribe } = derived( - [address, network], - ([$address, $network], set) => { - if (stateSyncer) { - const syncProm = stateSyncer.get() - syncingState = syncProm - syncProm - .then(result => { - set(result) - syncingState = false - }) - .catch(err => { - throw new Error(`Error getting balance from state syncer: ${err}`) - }) - } - } - ) - - return { - subscribe, - setStateSyncer: syncer => { - if (!syncer || typeof syncer !== "object") { - throw new Error("setStateSyncer must be called with a valid interface") - } - - stateSyncer = syncer - } - } -} diff --git a/src/views/PrepareWallet.svelte b/src/views/PrepareWallet.svelte index 8681074b9..5d519f8bb 100644 --- a/src/views/PrepareWallet.svelte +++ b/src/views/PrepareWallet.svelte @@ -1,15 +1,13 @@